2 * Copyright © 2012-2021 Collabora, Ltd.
4 * Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files (the
6 * "Software"), to deal in the Software without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, sublicense, and/or sell copies of the Software, and to
9 * permit persons to whom the Software is furnished to do so, subject to
10 * the following conditions:
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial
14 * portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
20 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 #include "ivi-compositor.h"
38 #include <linux/input.h>
40 #include <libweston/backend-drm.h>
41 #include <libweston/backend-wayland.h>
42 #ifdef HAVE_BACKEND_HEADLESS
43 #include <libweston/backend-headless.h>
45 #ifdef HAVE_BACKEND_X11
46 #include <libweston/backend-x11.h>
48 #include <libweston/libweston.h>
49 #include <libweston/windowed-output-api.h>
50 #include <libweston/config-parser.h>
51 #include <libweston/weston-log.h>
54 #include "shared/os-compatibility.h"
55 #include "shared/helpers.h"
57 #include "agl-shell-server-protocol.h"
64 #include <waltham-transmitter/transmitter_api.h>
67 static int cached_tm_mday = -1;
68 static struct weston_log_scope *log_scope;
70 struct ivi_compositor *
71 to_ivi_compositor(struct weston_compositor *ec)
73 return weston_compositor_get_user_data(ec);
77 sigint_helper(int sig)
83 ivi_layout_save(struct ivi_compositor *ivi, struct ivi_output *output)
85 struct ivi_output *new_output;
86 ivi->need_ivi_output_relayout = true;
88 new_output = zalloc(sizeof(*new_output));
90 new_output->ivi = ivi;
91 new_output->background = output->background;
93 new_output->top = output->top;
94 new_output->bottom = output->bottom;
95 new_output->left = output->left;
96 new_output->right = output->right;
98 new_output->active = output->active;
99 new_output->previous_active = output->previous_active;
100 new_output->name = strdup(output->name);
102 new_output->app_ids = strdup(output->app_ids);
104 new_output->area = output->area;
105 new_output->area_saved = output->area_saved;
106 new_output->area_activation = output->area_activation;
108 weston_log("saving output layout for output %s\n", new_output->name);
110 wl_list_insert(&ivi->saved_outputs, &new_output->link);
114 ivi_layout_restore(struct ivi_compositor *ivi, struct ivi_output *n_output)
116 struct ivi_output *output = NULL;
117 struct ivi_output *iter_output;
119 if (!ivi->need_ivi_output_relayout)
122 ivi->need_ivi_output_relayout = false;
124 wl_list_for_each(iter_output, &ivi->saved_outputs, link) {
125 if (strcmp(n_output->name, iter_output->name) == 0) {
126 output = iter_output;
134 weston_log("restoring output layout for output %s\n", output->name);
135 n_output->background = output->background;
137 n_output->top = output->top;
138 n_output->bottom = output->bottom;
139 n_output->left = output->left;
140 n_output->right = output->right;
142 n_output->active = output->active;
143 n_output->previous_active = output->previous_active;
145 n_output->app_ids = strdup(output->app_ids);
147 n_output->area = output->area;
148 n_output->area_saved = output->area_saved;
149 n_output->area_activation = output->area_activation;
151 free(output->app_ids);
153 wl_list_remove(&output->link);
158 ivi_layout_destroy_saved_outputs(struct ivi_compositor *ivi)
160 struct ivi_output *output, *output_next;
162 wl_list_for_each_safe(output, output_next, &ivi->saved_outputs, link) {
163 free(output->app_ids);
166 wl_list_remove(&output->link);
172 handle_output_destroy(struct wl_listener *listener, void *data)
174 struct ivi_output *output;
176 output = wl_container_of(listener, output, output_destroy);
177 assert(output->output == data);
179 if (output->fullscreen_view.fs &&
180 output->fullscreen_view.fs->view) {
181 weston_surface_destroy(output->fullscreen_view.fs->view->surface);
182 output->fullscreen_view.fs->view = NULL;
185 ivi_layout_save(output->ivi, output);
187 output->output = NULL;
188 wl_list_remove(&output->output_destroy.link);
192 to_ivi_output(struct weston_output *o)
194 struct wl_listener *listener;
195 struct ivi_output *output;
197 listener = weston_output_get_destroy_listener(o, handle_output_destroy);
198 output = wl_container_of(listener, output, output_destroy);
204 ivi_output_configure_app_id(struct ivi_output *ivi_output)
206 if (ivi_output->config) {
207 if (ivi_output->app_ids != NULL)
210 weston_config_section_get_string(ivi_output->config,
212 &ivi_output->app_ids,
215 if (ivi_output->app_ids == NULL)
218 weston_log("Will place app_id %s on output %s\n",
219 ivi_output->app_ids, ivi_output->name);
223 static struct ivi_output *
224 ivi_ensure_output(struct ivi_compositor *ivi, char *name,
225 struct weston_config_section *config)
227 struct ivi_output *output = NULL;
228 wl_list_for_each(output, &ivi->outputs, link) {
229 if (strcmp(output->name, name) == 0) {
235 output = zalloc(sizeof *output);
243 output->config = config;
245 output->output = weston_compositor_create_output(ivi->compositor, name);
246 if (!output->output) {
252 output->output_destroy.notify = handle_output_destroy;
253 weston_output_add_destroy_listener(output->output,
254 &output->output_destroy);
256 wl_list_insert(&ivi->outputs, &output->link);
257 ivi_output_configure_app_id(output);
262 count_heads(struct weston_output *output)
264 struct weston_head *iter = NULL;
267 while ((iter = weston_output_iterate_heads(output, iter)))
274 handle_head_destroy(struct wl_listener *listener, void *data)
276 struct weston_head *head = data;
277 struct weston_output *output;
279 wl_list_remove(&listener->link);
282 output = weston_head_get_output(head);
284 /* On shutdown path, the output might be already gone. */
288 /* We're the last head */
289 if (count_heads(output) <= 1)
290 weston_output_destroy(output);
294 add_head_destroyed_listener(struct weston_head *head)
296 /* We already have a destroy listener */
297 if (weston_head_get_destroy_listener(head, handle_head_destroy))
300 struct wl_listener *listener = zalloc(sizeof *listener);
304 listener->notify = handle_head_destroy;
305 weston_head_add_destroy_listener(head, listener);
309 drm_configure_output(struct ivi_output *output)
311 struct ivi_compositor *ivi = output->ivi;
312 struct weston_config_section *section = output->config;
313 enum weston_drm_backend_output_mode mode =
314 WESTON_DRM_BACKEND_OUTPUT_PREFERRED;
315 char *modeline = NULL;
316 char *gbm_format = NULL;
321 weston_config_section_get_string(section, "mode", &m, "preferred");
323 /* This should have been handled earlier */
324 assert(strcmp(m, "off") != 0);
326 if (ivi->cmdline.use_current_mode || strcmp(m, "current") == 0) {
327 mode = WESTON_DRM_BACKEND_OUTPUT_CURRENT;
328 } else if (strcmp(m, "preferred") != 0) {
334 weston_config_section_get_string(section, "gbm-format",
337 weston_config_section_get_string(section, "seat", &seat, "");
340 if (ivi->drm_api->set_mode(output->output, mode, modeline) < 0) {
341 weston_log("Cannot configure output using weston_drm_output_api.\n");
347 ivi->drm_api->set_gbm_format(output->output, gbm_format);
350 ivi->drm_api->set_seat(output->output, seat);
356 #define WINDOWED_DEFAULT_WIDTH 1024
357 #define WINDOWED_DEFAULT_HEIGHT 768
360 windowed_configure_output(struct ivi_output *output)
362 struct ivi_compositor *ivi = output->ivi;
363 struct weston_config_section *section = output->config;
364 int width = WINDOWED_DEFAULT_WIDTH;
365 int height = WINDOWED_DEFAULT_HEIGHT;
370 weston_config_section_get_string(section, "mode", &mode, NULL);
371 if (!mode || sscanf(mode, "%dx%d", &width, &height) != 2) {
372 weston_log("Invalid mode for output %s. Using defaults.\n",
374 width = WINDOWED_DEFAULT_WIDTH;
375 height = WINDOWED_DEFAULT_HEIGHT;
380 if (ivi->cmdline.width)
381 width = ivi->cmdline.width;
382 if (ivi->cmdline.height)
383 height = ivi->cmdline.height;
384 if (ivi->cmdline.scale)
385 weston_output_set_scale(output->output, ivi->cmdline.scale);
387 if (ivi->window_api->output_set_size(output->output, width, height) < 0) {
388 weston_log("Cannot configure output '%s' using weston_windowed_output_api.\n",
393 weston_log("Configured windowed_output_api to %dx%d\n", width, height);
399 parse_transform(const char *transform, uint32_t *out)
401 static const struct { const char *name; uint32_t token; } transforms[] = {
402 { "normal", WL_OUTPUT_TRANSFORM_NORMAL },
403 { "rotate-90", WL_OUTPUT_TRANSFORM_90 },
404 { "rotate-180", WL_OUTPUT_TRANSFORM_180 },
405 { "rotate-270", WL_OUTPUT_TRANSFORM_270 },
406 { "flipped", WL_OUTPUT_TRANSFORM_FLIPPED },
407 { "flipped-rotate-90", WL_OUTPUT_TRANSFORM_FLIPPED_90 },
408 { "flipped-rotate-180", WL_OUTPUT_TRANSFORM_FLIPPED_180 },
409 { "flipped-rotate-270", WL_OUTPUT_TRANSFORM_FLIPPED_270 },
412 for (size_t i = 0; i < ARRAY_LENGTH(transforms); i++)
413 if (strcmp(transforms[i].name, transform) == 0) {
414 *out = transforms[i].token;
418 *out = WL_OUTPUT_TRANSFORM_NORMAL;
423 parse_activation_area(const char *geometry, struct ivi_output *output)
426 unsigned width, height, x, y;
428 n = sscanf(geometry, "%ux%u+%u,%u", &width, &height, &x, &y);
432 output->area_activation.width = width;
433 output->area_activation.height = height;
434 output->area_activation.x = x;
435 output->area_activation.y = y;
440 configure_output(struct ivi_output *output)
442 struct ivi_compositor *ivi = output->ivi;
443 struct weston_config_section *section = output->config;
445 uint32_t transform = WL_OUTPUT_TRANSFORM_NORMAL;
448 * This can happen with the wayland backend with 'sprawl'. The config
449 * is hard-coded, so we don't need to do anything.
451 if (!ivi->drm_api && !ivi->window_api)
457 weston_config_section_get_int(section, "scale", &scale, 1);
458 weston_config_section_get_string(section, "transform", &t, "normal");
459 if (parse_transform(t, &transform) < 0)
460 weston_log("Invalid transform \"%s\" for output %s\n",
462 weston_config_section_get_string(section, "activation-area", &t, "");
463 if (parse_activation_area(t, output) < 0)
464 weston_log("Invalid activation-area \"%s\" for output %s\n",
469 weston_output_set_scale(output->output, scale);
470 weston_output_set_transform(output->output, transform);
473 return drm_configure_output(output);
475 return windowed_configure_output(output);
479 * Reorgainizes the output's add array into two sections.
480 * add[0..ret-1] are the heads that failed to get attached.
481 * add[ret..add_len] are the heads that were successfully attached.
483 * The order between elements in each section is stable.
486 try_attach_heads(struct ivi_output *output)
490 for (size_t i = 0; i < output->add_len; ++i) {
491 if (weston_output_attach_head(output->output, output->add[i]) < 0) {
492 struct weston_head *tmp = output->add[i];
493 memmove(&output->add[fail_len + 1], output->add[fail_len],
494 sizeof output->add[0] * (i - fail_len));
495 output->add[fail_len++] = tmp;
503 * Like try_attach_heads, this reorganizes the output's add array into a failed
504 * and successful section.
505 * i is the number of heads that already failed the previous step.
508 try_enable_output(struct ivi_output *output, size_t i)
510 for (; i < output->add_len; ++i) {
511 struct weston_head *head;
513 if (weston_output_enable(output->output) == 0)
516 head = output->add[output->add_len - 1];
517 memmove(&output->add[i + 1], &output->add[i],
518 sizeof output->add[0] * (output->add_len - i));
519 output->add[i] = head;
521 weston_head_detach(head);
528 try_attach_enable_heads(struct ivi_output *output)
531 assert(!output->output->enabled);
533 fail_len = try_attach_heads(output);
535 if (configure_output(output) < 0)
538 fail_len = try_enable_output(output, fail_len);
540 /* All heads failed to be attached */
541 if (fail_len == output->add_len)
544 /* For each successful head attached */
545 for (size_t i = fail_len; i < output->add_len; ++i)
546 add_head_destroyed_listener(output->add[i]);
548 ivi_layout_restore(output->ivi, output);
550 output->add_len = fail_len;
555 process_output(struct ivi_output *output)
557 if (output->output->enabled) {
558 output->add_len = try_attach_heads(output);
559 return output->add_len == 0 ? 0 : -1;
562 return try_attach_enable_heads(output);
566 head_disable(struct ivi_compositor *ivi, struct weston_head *head)
568 struct weston_output *output;
569 struct ivi_output *ivi_output;
570 struct wl_listener *listener;
572 output = weston_head_get_output(head);
575 listener = weston_output_get_destroy_listener(output,
576 handle_output_destroy);
579 ivi_output = wl_container_of(listener, ivi_output, output_destroy);
580 assert(ivi_output->output == output);
582 weston_head_detach(head);
583 if (count_heads(ivi_output->output) == 0) {
584 if (ivi_output->output) {
585 /* ivi_output->output destruction may be deferred in
586 * some cases (see drm_output_destroy()), so we need to
587 * forcibly trigger the destruction callback now, or
588 * otherwise would later access data that we are about
591 struct weston_output *save = ivi_output->output;
593 handle_output_destroy(&ivi_output->output_destroy, save);
594 weston_output_destroy(save);
597 wl_list_remove(&ivi_output->link);
598 free(ivi_output->app_ids);
602 static struct weston_config_section *
603 find_controlling_output_config(struct weston_config *config,
606 struct weston_config_section *section;
610 same_as = strdup(name);
612 section = weston_config_get_section(config, "output",
614 if (!section && depth > 0)
615 weston_log("Configuration error: output section reffered"
616 "to by same-as=%s not found.\n", same_as);
623 weston_log("Configuration error: same-as nested too "
624 "deep for output '%s'.\n", name);
628 weston_config_section_get_string(section, "same-as",
636 head_prepare_enable(struct ivi_compositor *ivi, struct weston_head *head)
638 const char *name = weston_head_get_name(head);
639 struct weston_config_section *section;
640 struct ivi_output *output;
641 char *output_name = NULL;
643 section = find_controlling_output_config(ivi->config, name);
647 weston_config_section_get_string(section, "mode", &mode, NULL);
648 if (mode && strcmp(mode, "off") == 0) {
654 weston_config_section_get_string(section, "name",
657 output_name = strdup(name);
663 output = ivi_ensure_output(ivi, output_name, section);
667 if (output->add_len >= ARRAY_LENGTH(output->add))
670 output->add[output->add_len++] = head;
674 heads_changed(struct wl_listener *listener, void *arg)
676 struct weston_compositor *compositor = arg;
677 struct weston_head *head = NULL;
678 struct ivi_compositor *ivi = to_ivi_compositor(compositor);
679 struct ivi_output *output;
681 while ((head = weston_compositor_iterate_heads(ivi->compositor, head))) {
682 bool connected = weston_head_is_connected(head);
683 bool enabled = weston_head_is_enabled(head);
684 bool changed = weston_head_is_device_changed(head);
685 bool non_desktop = weston_head_is_non_desktop(head);
687 if (connected && !enabled && !non_desktop)
688 head_prepare_enable(ivi, head);
689 else if (!connected && enabled)
690 head_disable(ivi, head);
691 else if (enabled && changed)
692 weston_log("Detected a monitor change on head '%s', "
693 "not bothering to do anything about it.\n",
694 weston_head_get_name(head));
696 weston_head_reset_device_changed(head);
699 wl_list_for_each(output, &ivi->outputs, link) {
700 if (output->add_len == 0)
703 if (process_output(output) < 0) {
705 ivi->init_failed = true;
712 load_waltham_plugin(struct ivi_compositor *ivi, struct weston_config *config)
714 struct weston_compositor *compositor = ivi->compositor;
715 int (*module_init)(struct weston_compositor *wc);
717 module_init = weston_load_module("waltham-transmitter.so",
722 if (module_init(compositor) < 0)
725 ivi->waltham_transmitter_api = weston_get_transmitter_api(compositor);
726 if (!ivi->waltham_transmitter_api) {
727 weston_log("Failed to load waltham-transmitter plugin.\n");
731 weston_log("waltham-transmitter plug-in loaded\n");
736 load_waltham_plugin(struct ivi_compositor *ivi, struct weston_config *config)
744 drm_backend_remoted_output_configure(struct weston_output *output,
745 struct weston_config_section *section,
747 const struct weston_remoting_api *api)
749 char *gbm_format = NULL;
752 char *pipeline = NULL;
755 uint32_t transform = WL_OUTPUT_TRANSFORM_NORMAL;
758 ret = api->set_mode(output, modeline);
760 weston_log("Cannot configure an output \"%s\" using "
761 "weston_remoting_api. Invalid mode\n",
766 weston_config_section_get_int(section, "scale", &scale, 1);
767 weston_output_set_scale(output, scale);
769 weston_config_section_get_string(section, "transform", &trans, "normal");
770 if (parse_transform(trans, &transform) < 0) {
771 weston_log("Invalid transform \"%s\" for output %s\n",
772 trans, output->name);
774 weston_output_set_transform(output, transform);
776 weston_config_section_get_string(section, "gbm-format",
778 api->set_gbm_format(output, gbm_format);
781 weston_config_section_get_string(section, "seat", &seat, "");
783 api->set_seat(output, seat);
786 weston_config_section_get_string(section, "gst-pipeline", &pipeline,
789 api->set_gst_pipeline(output, pipeline);
794 weston_config_section_get_string(section, "host", &host, NULL);
795 weston_config_section_get_int(section, "port", &port, 0);
796 if (!host || port <= 0 || 65533 < port) {
797 weston_log("Cannot configure an output \"%s\". "
798 "Need to specify gst-pipeline or "
799 "host and port (1-65533).\n", output->name);
801 api->set_host(output, host);
803 api->set_port(output, port);
810 remote_output_init(struct ivi_output *ivi_output,
811 struct weston_compositor *compositor,
812 struct weston_config_section *section,
813 const struct weston_remoting_api *api)
815 char *output_name, *modeline = NULL;
818 weston_config_section_get_string(section, "name", &output_name, NULL);
822 weston_config_section_get_string(section, "mode", &modeline, "off");
823 if (strcmp(modeline, "off") == 0)
826 ivi_output->output = api->create_output(compositor, output_name);
827 if (!ivi_output->output) {
828 weston_log("Cannot create remoted output \"%s\".\n",
833 ret = drm_backend_remoted_output_configure(ivi_output->output, section,
836 weston_log("Cannot configure remoted output \"%s\".\n",
841 if ((ret = weston_output_enable(ivi_output->output)) < 0) {
842 weston_log("Enabling remoted output \"%s\" failed.\n",
849 weston_log("remoted output '%s' enabled\n", ivi_output->output->name);
856 if (ivi_output->output)
857 weston_output_destroy(ivi_output->output);
863 ivi_enable_remote_outputs(struct ivi_compositor *ivi)
865 struct weston_config_section *remote_section = NULL;
866 const char *section_name;
867 struct weston_config *config = ivi->config;
869 while (weston_config_next_section(config, &remote_section, §ion_name)) {
870 if (strcmp(section_name, "remote-output"))
873 struct ivi_output *ivi_output = NULL;
874 bool output_found = false;
877 weston_config_section_get_string(remote_section,
878 "name", &_name, NULL);
879 wl_list_for_each(ivi_output, &ivi->outputs, link) {
880 if (!strcmp(ivi_output->name, _name)) {
891 ivi_output = zalloc(sizeof(*ivi_output));
897 ivi_output->ivi = ivi;
898 ivi_output->name = _name;
899 ivi_output->config = remote_section;
900 ivi_output->type = OUTPUT_REMOTE;
902 if (remote_output_init(ivi_output, ivi->compositor,
903 remote_section, ivi->remoting_api)) {
904 free(ivi_output->name);
909 ivi_output->output_destroy.notify = handle_output_destroy;
910 weston_output_add_destroy_listener(ivi_output->output,
911 &ivi_output->output_destroy);
913 wl_list_insert(&ivi->outputs, &ivi_output->link);
914 ivi_output_configure_app_id(ivi_output);
919 ivi_enable_waltham_outputs(struct ivi_compositor *ivi)
921 struct weston_config_section *transmitter_section = NULL;
922 const char *sect_name;
923 struct weston_config *config = ivi->config;
925 while (weston_config_next_section(config, &transmitter_section, §_name)) {
926 if (strcmp(sect_name, "transmitter-output"))
929 struct ivi_output *ivi_output = NULL;
930 bool output_found = false;
933 weston_config_section_get_string(transmitter_section,
934 "name", &_name, NULL);
935 wl_list_for_each(ivi_output, &ivi->outputs, link) {
936 if (!strcmp(ivi_output->name, _name)) {
947 ivi_output = zalloc(sizeof(*ivi_output));
953 ivi_output->ivi = ivi;
954 ivi_output->name = _name;
955 ivi_output->config = transmitter_section;
957 if (remote_output_init(ivi_output, ivi->compositor,
958 transmitter_section, ivi->remoting_api)) {
959 free(ivi_output->name);
964 ivi_output->type = OUTPUT_WALTHAM;
965 ivi_output->output_destroy.notify = handle_output_destroy;
966 weston_output_add_destroy_listener(ivi_output->output,
967 &ivi_output->output_destroy);
969 wl_list_insert(&ivi->outputs, &ivi_output->link);
970 ivi_output_configure_app_id(ivi_output);
975 load_remoting_plugin(struct ivi_compositor *ivi, struct weston_config *config)
977 struct weston_compositor *compositor = ivi->compositor;
978 int (*module_init)(struct weston_compositor *wc);
980 module_init = weston_load_module("remoting-plugin.so",
981 "weston_module_init");
985 if (module_init(compositor) < 0)
988 ivi->remoting_api = weston_remoting_get_api(compositor);
989 if (!ivi->remoting_api)
995 load_remoting_plugin(struct weston_compositor *compositor, struct weston_config *config)
1002 load_drm_backend(struct ivi_compositor *ivi, int *argc, char *argv[])
1004 struct weston_drm_backend_config config = {
1006 .struct_version = WESTON_DRM_BACKEND_CONFIG_VERSION,
1007 .struct_size = sizeof config,
1010 struct weston_config_section *section;
1011 int use_current_mode = 0;
1014 bool without_input = false;
1017 const struct weston_option options[] = {
1018 { WESTON_OPTION_STRING, "seat", 0, &config.seat_id },
1019 { WESTON_OPTION_STRING, "drm-device", 0, &config.specific_device },
1020 { WESTON_OPTION_BOOLEAN, "current-mode", 0, &use_current_mode },
1021 { WESTON_OPTION_BOOLEAN, "use-pixman", 0, &use_pixman },
1022 { WESTON_OPTION_BOOLEAN, "continue-without-input", false, &without_input }
1025 parse_options(options, ARRAY_LENGTH(options), argc, argv);
1026 config.use_pixman = use_pixman;
1027 ivi->cmdline.use_current_mode = use_current_mode;
1029 section = weston_config_get_section(ivi->config, "core", NULL, NULL);
1030 weston_config_section_get_string(section, "gbm-format",
1031 &config.gbm_format, NULL);
1032 weston_config_section_get_uint(section, "pageflip-timeout",
1033 &config.pageflip_timeout, 0);
1034 weston_config_section_get_bool(section, "pixman-shadow", &use_shadow, 1);
1035 config.use_pixman_shadow = use_shadow;
1038 ivi->compositor->require_input = !without_input;
1040 ret = weston_compositor_load_backend(ivi->compositor, WESTON_BACKEND_DRM,
1045 ivi->drm_api = weston_drm_output_get_api(ivi->compositor);
1046 if (!ivi->drm_api) {
1047 weston_log("Cannot use drm output api.\n");
1052 load_remoting_plugin(ivi, ivi->config);
1053 load_waltham_plugin(ivi, ivi->config);
1056 free(config.gbm_format);
1057 free(config.seat_id);
1062 windowed_parse_common_options(struct ivi_compositor *ivi, int *argc, char *argv[],
1063 bool *use_pixman, bool *fullscreen, int *output_count)
1065 struct weston_config_section *section;
1069 const struct weston_option options[] = {
1070 { WESTON_OPTION_INTEGER, "width", 0, &ivi->cmdline.width },
1071 { WESTON_OPTION_INTEGER, "height", 0, &ivi->cmdline.height },
1072 { WESTON_OPTION_INTEGER, "scale", 0, &ivi->cmdline.scale },
1073 { WESTON_OPTION_BOOLEAN, "use-pixman", 0, &pixman },
1074 { WESTON_OPTION_BOOLEAN, "fullscreen", 0, &fs },
1075 { WESTON_OPTION_INTEGER, "output-count", 0, output_count },
1078 section = weston_config_get_section(ivi->config, "core", NULL, NULL);
1079 weston_config_section_get_bool(section, "use-pixman", &pixman, 0);
1082 parse_options(options, ARRAY_LENGTH(options), argc, argv);
1083 *use_pixman = pixman;
1088 windowed_create_outputs(struct ivi_compositor *ivi, int output_count,
1089 const char *match_prefix, const char *name_prefix)
1091 struct weston_config_section *section = NULL;
1092 const char *section_name;
1093 char *default_output = NULL;
1095 size_t match_len = strlen(match_prefix);
1097 while (weston_config_next_section(ivi->config, §ion, §ion_name)) {
1100 if (i >= output_count)
1103 if (strcmp(section_name, "output") != 0)
1106 weston_config_section_get_string(section, "name", &output_name, NULL);
1107 if (output_name == NULL)
1109 if (strncmp(output_name, match_prefix, match_len) != 0) {
1114 if (ivi->window_api->create_head(ivi->compositor, output_name) < 0) {
1123 for (; i < output_count; ++i) {
1124 if (asprintf(&default_output, "%s%d", name_prefix, i) < 0)
1127 if (ivi->window_api->create_head(ivi->compositor, default_output) < 0) {
1128 free(default_output);
1132 free(default_output);
1139 load_wayland_backend(struct ivi_compositor *ivi, int *argc, char *argv[])
1141 struct weston_wayland_backend_config config = {
1143 .struct_version = WESTON_WAYLAND_BACKEND_CONFIG_VERSION,
1144 .struct_size = sizeof config,
1147 struct weston_config_section *section;
1152 const struct weston_option options[] = {
1153 { WESTON_OPTION_STRING, "display", 0, &config.display_name },
1154 { WESTON_OPTION_STRING, "sprawl", 0, &sprawl },
1157 windowed_parse_common_options(ivi, argc, argv, &config.use_pixman,
1158 &config.fullscreen, &output_count);
1160 parse_options(options, ARRAY_LENGTH(options), argc, argv);
1161 config.sprawl = sprawl;
1163 section = weston_config_get_section(ivi->config, "shell", NULL, NULL);
1164 weston_config_section_get_string(section, "cursor-theme",
1165 &config.cursor_theme, NULL);
1166 weston_config_section_get_int(section, "cursor-size",
1167 &config.cursor_size, 32);
1169 ret = weston_compositor_load_backend(ivi->compositor, WESTON_BACKEND_WAYLAND,
1172 free(config.cursor_theme);
1173 free(config.display_name);
1178 ivi->window_api = weston_windowed_output_get_api(ivi->compositor);
1181 * We will just assume if load_backend() finished cleanly and
1182 * windowed_output_api is not present that wayland backend is started
1183 * with --sprawl or runs on fullscreen-shell. In this case, all values
1184 * are hardcoded, so nothing can be configured; simply create and
1187 if (ivi->window_api == NULL)
1190 return windowed_create_outputs(ivi, output_count, "WL", "wayland");
1193 #ifdef HAVE_BACKEND_X11
1195 load_x11_backend(struct ivi_compositor *ivi, int *argc, char *argv[])
1197 struct weston_x11_backend_config config = {
1199 .struct_version = WESTON_X11_BACKEND_CONFIG_VERSION,
1200 .struct_size = sizeof config,
1207 const struct weston_option options[] = {
1208 { WESTON_OPTION_BOOLEAN, "no-input", 0, &no_input },
1211 windowed_parse_common_options(ivi, argc, argv, &config.use_pixman,
1212 &config.fullscreen, &output_count);
1214 parse_options(options, ARRAY_LENGTH(options), argc, argv);
1215 config.no_input = no_input;
1217 ret = weston_compositor_load_backend(ivi->compositor, WESTON_BACKEND_X11,
1223 ivi->window_api = weston_windowed_output_get_api(ivi->compositor);
1224 if (!ivi->window_api) {
1225 weston_log("Cannot use weston_windowed_output_api.\n");
1229 return windowed_create_outputs(ivi, output_count, "X", "screen");
1233 load_x11_backend(struct ivi_compositor *ivi, int *argc, char *argv[])
1239 #ifdef HAVE_BACKEND_HEADLESS
1241 load_headless_backend(struct ivi_compositor *ivi, int *argc, char **argv)
1243 struct weston_headless_backend_config config = {};
1251 struct weston_compositor *c = ivi->compositor;
1253 const struct weston_option options[] = {
1254 { WESTON_OPTION_BOOLEAN, "use-pixman", 0, &use_pixman },
1255 { WESTON_OPTION_BOOLEAN, "use-gl", 0, &use_gl },
1258 windowed_parse_common_options(ivi, argc, argv, &use_pixman,
1259 &fullscreen, &output_count);
1261 parse_options(options, ARRAY_LENGTH(options), argc, argv);
1262 config.use_pixman = use_pixman;
1263 config.use_gl = use_gl;
1265 config.base.struct_version = WESTON_HEADLESS_BACKEND_CONFIG_VERSION;
1266 config.base.struct_size = sizeof(struct weston_headless_backend_config);
1268 /* load the actual headless-backend and configure it */
1269 ret = weston_compositor_load_backend(c, WESTON_BACKEND_HEADLESS,
1274 ivi->window_api = weston_windowed_output_get_api(c);
1275 if (!ivi->window_api) {
1276 weston_log("Cannot use weston_windowed_output_api.\n");
1280 if (ivi->window_api->create_head(c, "headless") < 0) {
1281 weston_log("Cannot create headless back-end\n");
1289 load_headless_backend(struct ivi_compositor *ivi, int *argc, char **argv)
1296 load_backend(struct ivi_compositor *ivi, const char *backend,
1297 int *argc, char *argv[])
1299 if (strcmp(backend, "drm-backend.so") == 0) {
1300 return load_drm_backend(ivi, argc, argv);
1301 } else if (strcmp(backend, "wayland-backend.so") == 0) {
1302 return load_wayland_backend(ivi, argc, argv);
1303 } else if (strcmp(backend, "x11-backend.so") == 0) {
1304 return load_x11_backend(ivi, argc, argv);
1305 } else if (strcmp(backend, "headless-backend.so") == 0) {
1306 return load_headless_backend(ivi, argc, argv);
1309 weston_log("fatal: unknown backend '%s'.\n", backend);
1314 load_modules(struct ivi_compositor *ivi, const char *modules,
1315 int *argc, char *argv[], bool *xwayland)
1317 const char *p, *end;
1319 int (*module_init)(struct weston_compositor *wc, int argc, char *argv[]);
1321 if (modules == NULL)
1326 end = strchrnul(p, ',');
1327 snprintf(buffer, sizeof buffer, "%.*s", (int) (end - p), p);
1329 if (strstr(buffer, "xwayland.so")) {
1331 } else if (strstr(buffer, "systemd-notify.so")) {
1332 weston_log("systemd-notify plug-in already loaded!\n");
1334 module_init = weston_load_module(buffer, "wet_module_init");
1338 if (module_init(ivi->compositor, *argc, argv) < 0)
1353 choose_default_backend(void)
1355 char *backend = NULL;
1357 if (getenv("WAYLAND_DISPLAY") || getenv("WAYLAND_SOCKET"))
1358 backend = strdup("wayland-backend.so");
1359 else if (getenv("DISPLAY"))
1360 backend = strdup("x11-backend.so");
1362 backend = strdup("drm-backend.so");
1368 compositor_init_config(struct ivi_compositor *ivi)
1370 struct xkb_rule_names xkb_names;
1371 struct weston_config_section *section;
1372 struct weston_compositor *compositor = ivi->compositor;
1373 struct weston_config *config = ivi->config;
1378 /* agl-compositor.ini [keyboard] */
1379 section = weston_config_get_section(config, "keyboard", NULL, NULL);
1380 weston_config_section_get_string(section, "keymap_rules",
1381 (char **) &xkb_names.rules, NULL);
1382 weston_config_section_get_string(section, "keymap_model",
1383 (char **) &xkb_names.model, NULL);
1384 weston_config_section_get_string(section, "keymap_layout",
1385 (char **) &xkb_names.layout, NULL);
1386 weston_config_section_get_string(section, "keymap_variant",
1387 (char **) &xkb_names.variant, NULL);
1388 weston_config_section_get_string(section, "keymap_options",
1389 (char **) &xkb_names.options, NULL);
1391 if (weston_compositor_set_xkb_rule_names(compositor, &xkb_names) < 0)
1394 weston_config_section_get_int(section, "repeat-rate",
1395 &compositor->kb_repeat_rate, 40);
1396 weston_config_section_get_int(section, "repeat-delay",
1397 &compositor->kb_repeat_delay, 400);
1399 weston_config_section_get_bool(section, "vt-switching",
1400 &vt_switching, false);
1401 compositor->vt_switching = vt_switching;
1403 /* agl-compositor.ini [core] */
1404 section = weston_config_get_section(config, "core", NULL, NULL);
1406 weston_config_section_get_bool(section, "disable-cursor",
1407 &ivi->disable_cursor, false);
1408 weston_config_section_get_bool(section, "activate-by-default",
1409 &ivi->activate_by_default, true);
1411 weston_config_section_get_bool(section, "require-input", &require_input, true);
1412 compositor->require_input = require_input;
1414 weston_config_section_get_int(section, "repaint-window", &repaint_msec,
1415 compositor->repaint_msec);
1416 if (repaint_msec < -10 || repaint_msec > 1000) {
1417 weston_log("Invalid repaint_window value in config: %d\n",
1420 compositor->repaint_msec = repaint_msec;
1422 weston_log("Output repaint window is %d ms maximum.\n",
1423 compositor->repaint_msec);
1428 struct ivi_surface *
1429 to_ivi_surface(struct weston_surface *surface)
1431 struct weston_desktop_surface *dsurface;
1433 dsurface = weston_surface_get_desktop_surface(surface);
1437 return weston_desktop_surface_get_user_data(dsurface);
1441 activate_binding(struct weston_seat *seat,
1442 struct weston_view *focus_view, uint32_t flags)
1444 struct weston_surface *focus_surface;
1445 struct weston_surface *main_surface;
1446 struct ivi_surface *ivi_surface;
1447 struct ivi_shell_seat *ivi_seat = get_ivi_shell_seat(seat);
1452 focus_surface = focus_view->surface;
1453 main_surface = weston_surface_get_main_surface(focus_surface);
1455 ivi_surface = to_ivi_surface(main_surface);
1460 ivi_shell_activate_surface(ivi_surface, ivi_seat, flags);
1464 click_to_activate_binding(struct weston_pointer *pointer,
1465 const struct timespec *time,
1466 uint32_t button, void *data)
1468 if (pointer->grab != &pointer->default_grab)
1470 if (pointer->focus == NULL)
1473 activate_binding(pointer->seat, pointer->focus,
1474 WESTON_ACTIVATE_FLAG_CLICKED);
1478 touch_to_activate_binding(struct weston_touch *touch,
1479 const struct timespec *time,
1482 if (touch->grab != &touch->default_grab)
1484 if (touch->focus == NULL)
1487 activate_binding(touch->seat, touch->focus,
1488 WESTON_ACTIVATE_FLAG_NONE);
1492 add_bindings(struct weston_compositor *compositor)
1494 weston_compositor_add_button_binding(compositor, BTN_LEFT, 0,
1495 click_to_activate_binding,
1497 weston_compositor_add_button_binding(compositor, BTN_RIGHT, 0,
1498 click_to_activate_binding,
1500 weston_compositor_add_touch_binding(compositor, 0,
1501 touch_to_activate_binding,
1506 create_listening_socket(struct wl_display *display, const char *socket_name)
1509 if (wl_display_add_socket(display, socket_name)) {
1510 weston_log("fatal: failed to add socket: %s\n",
1515 socket_name = wl_display_add_socket_auto(display);
1517 weston_log("fatal: failed to add socket: %s\n",
1523 setenv("WAYLAND_DISPLAY", socket_name, 1);
1529 global_filter(const struct wl_client *client, const struct wl_global *global,
1536 load_config(struct weston_config **config, bool no_config,
1537 const char *config_file)
1539 const char *file = "agl-compositor.ini";
1540 const char *full_path;
1546 *config = weston_config_parse(file);
1549 full_path = weston_config_get_full_path(*config);
1551 weston_log("Using config file '%s'.\n", full_path);
1552 setenv(WESTON_CONFIG_FILE_ENV_VAR, full_path, 1);
1557 if (config_file && !no_config) {
1558 weston_log("fatal: error opening or reading config file '%s'.\n",
1564 weston_log("Starting with no config file.\n");
1565 setenv(WESTON_CONFIG_FILE_ENV_VAR, "", 1);
1570 static FILE *logfile;
1573 log_timestamp(char *buf, size_t len)
1576 struct tm *brokendown_time;
1580 gettimeofday(&tv, NULL);
1582 brokendown_time = localtime(&tv.tv_sec);
1583 if (brokendown_time == NULL) {
1584 snprintf(buf, len, "%s", "[(NULL)localtime] ");
1588 memset(datestr, 0, sizeof(datestr));
1589 if (brokendown_time->tm_mday != cached_tm_mday) {
1590 strftime(datestr, sizeof(datestr), "Date: %Y-%m-%d %Z\n",
1592 cached_tm_mday = brokendown_time->tm_mday;
1595 strftime(timestr, sizeof(timestr), "%H:%M:%S", brokendown_time);
1596 /* if datestr is empty it prints only timestr*/
1597 snprintf(buf, len, "%s[%s.%03li]", datestr,
1598 timestr, (tv.tv_usec / 1000));
1604 custom_handler(const char *fmt, va_list arg)
1608 weston_log_scope_printf(log_scope, "%s libwayland: ",
1609 log_timestamp(timestr, sizeof(timestr)));
1610 weston_log_scope_vprintf(log_scope, fmt, arg);
1614 log_file_open(const char *filename)
1616 wl_log_set_handler_server(custom_handler);
1619 logfile = fopen(filename, "a");
1624 os_fd_set_cloexec(fileno(logfile));
1625 setvbuf(logfile, NULL, _IOLBF, 256);
1630 log_file_close(void)
1632 if (logfile && logfile != stderr)
1638 vlog(const char *fmt, va_list ap)
1640 const char *oom = "Out of memory";
1645 if (weston_log_scope_is_enabled(log_scope)) {
1647 char *xlog_timestamp = log_timestamp(timestr, sizeof(timestr));
1648 len_va = vasprintf(&str, fmt, ap);
1650 len = weston_log_scope_printf(log_scope, "%s %s",
1651 xlog_timestamp, str);
1654 len = weston_log_scope_printf(log_scope, "%s %s",
1655 xlog_timestamp, oom);
1664 vlog_continue(const char *fmt, va_list ap)
1666 return weston_log_scope_vprintf(log_scope, fmt, ap);
1670 on_term_signal(int signo, void *data)
1672 struct wl_display *display = data;
1674 weston_log("caught signal %d\n", signo);
1675 wl_display_terminate(display);
1681 handle_exit(struct weston_compositor *compositor)
1683 wl_display_terminate(compositor->wl_display);
1687 usage(int error_code)
1689 FILE *out = error_code == EXIT_SUCCESS ? stdout : stderr;
1691 "Usage: agl-compositor [OPTIONS]\n"
1693 "This is " PACKAGE_STRING ", the reference compositor for\n"
1694 "Automotive Grade Linux. " PACKAGE_STRING " supports multiple "
1695 "backends,\nand depending on which backend is in use different "
1696 "options will be accepted.\n"
1700 " --version\t\tPrint agl-compositor version\n"
1701 " -B, --backend=MODULE\tBackend module, one of\n"
1702 "\t\t\t\tdrm-backend.so\n"
1703 "\t\t\t\twayland-backend.so\n"
1704 "\t\t\t\tx11-backend.so\n"
1705 "\t\t\t\theadless-backend.so\n"
1706 " -S, --socket=NAME\tName of socket to listen on\n"
1707 " --log=FILE\t\tLog to the given file\n"
1708 " -c, --config=FILE\tConfig file to load, defaults to agl-compositor.ini\n"
1709 " --no-config\t\tDo not read agl-compositor.ini\n"
1710 " --debug\t\tEnable debug extension(s)\n"
1711 " -h, --help\t\tThis help message\n"
1717 copy_command_line(int argc, char * const argv[])
1724 fp = open_memstream(&str, &size);
1728 fprintf(fp, "%s", argv[0]);
1729 for (i = 1; i < argc; i++)
1730 fprintf(fp, " %s", argv[i]);
1736 #if !defined(BUILD_XWAYLAND)
1738 wet_load_xwayland(struct weston_compositor *comp)
1745 weston_log_setup_scopes(struct weston_log_context *log_ctx,
1746 struct weston_log_subscriber *subscriber,
1752 char *tokenize = strdup(names);
1753 char *token = strtok(tokenize, ",");
1755 weston_log_subscribe(log_ctx, subscriber, token);
1756 token = strtok(NULL, ",");
1762 weston_log_subscribe_to_scopes(struct weston_log_context *log_ctx,
1763 struct weston_log_subscriber *logger,
1764 const char *debug_scopes)
1766 if (logger && debug_scopes)
1767 weston_log_setup_scopes(log_ctx, logger, debug_scopes);
1769 weston_log_subscribe(log_ctx, logger, "log");
1773 int wet_main(int argc, char *argv[], const struct weston_testsuite_data *test_data)
1775 struct ivi_compositor ivi = { 0 };
1777 struct wl_display *display = NULL;
1778 struct wl_event_loop *loop;
1779 struct wl_event_source *signals[3] = { 0 };
1780 struct weston_config_section *section;
1781 /* Command line options */
1782 char *backend = NULL;
1783 char *socket_name = NULL;
1785 char *modules = NULL;
1786 char *option_modules = NULL;
1787 char *debug_scopes = NULL;
1792 bool list_debug_scopes = false;
1793 char *config_file = NULL;
1794 struct weston_log_context *log_ctx = NULL;
1795 struct weston_log_subscriber *logger;
1796 int ret = EXIT_FAILURE;
1797 bool xwayland = false;
1798 struct sigaction action;
1800 const struct weston_option core_options[] = {
1801 { WESTON_OPTION_STRING, "backend", 'B', &backend },
1802 { WESTON_OPTION_STRING, "socket", 'S', &socket_name },
1803 { WESTON_OPTION_STRING, "log", 0, &log },
1804 { WESTON_OPTION_BOOLEAN, "help", 'h', &help },
1805 { WESTON_OPTION_BOOLEAN, "version", 0, &version },
1806 { WESTON_OPTION_BOOLEAN, "no-config", 0, &no_config },
1807 { WESTON_OPTION_BOOLEAN, "debug", 0, &debug },
1808 { WESTON_OPTION_STRING, "config", 'c', &config_file },
1809 { WESTON_OPTION_STRING, "modules", 0, &option_modules },
1810 { WESTON_OPTION_STRING, "debug-scopes", 'l', &debug_scopes },
1811 { WESTON_OPTION_STRING, "list-debug-scopes", 'L', &list_debug_scopes },
1814 wl_list_init(&ivi.outputs);
1815 wl_list_init(&ivi.saved_outputs);
1816 wl_list_init(&ivi.surfaces);
1817 wl_list_init(&ivi.pending_surfaces);
1818 wl_list_init(&ivi.popup_pending_apps);
1819 wl_list_init(&ivi.fullscreen_pending_apps);
1820 wl_list_init(&ivi.split_pending_apps);
1821 wl_list_init(&ivi.remote_pending_apps);
1822 wl_list_init(&ivi.desktop_clients);
1823 wl_list_init(&ivi.child_process_list);
1825 /* Prevent any clients we spawn getting our stdin */
1826 os_fd_set_cloexec(STDIN_FILENO);
1828 cmdline = copy_command_line(argc, argv);
1829 parse_options(core_options, ARRAY_LENGTH(core_options), &argc, argv);
1832 usage(EXIT_SUCCESS);
1835 printf(PACKAGE_STRING "\n");
1840 log_ctx = weston_log_ctx_create();
1842 fprintf(stderr, "Failed to initialize weston debug framework.\n");
1846 log_scope = weston_log_ctx_add_log_scope(log_ctx, "log",
1847 "agl-compositor log\n",
1851 weston_log_set_handler(vlog, vlog_continue);
1853 logger = weston_log_subscriber_create_log(logfile);
1854 weston_log_subscribe_to_scopes(log_ctx, logger, debug_scopes);
1856 weston_log("Command line: %s\n", cmdline);
1859 if (load_config(&ivi.config, no_config, config_file) < 0)
1861 section = weston_config_get_section(ivi.config, "core", NULL, NULL);
1863 weston_config_section_get_string(section, "backend", &backend,
1866 backend = choose_default_backend();
1869 display = wl_display_create();
1870 loop = wl_display_get_event_loop(display);
1872 wl_display_set_global_filter(display,
1873 global_filter, &ivi);
1875 /* Register signal handlers so we shut down cleanly */
1877 signals[0] = wl_event_loop_add_signal(loop, SIGTERM, on_term_signal,
1879 signals[1] = wl_event_loop_add_signal(loop, SIGUSR2, on_term_signal,
1881 signals[2] = wl_event_loop_add_signal(loop, SIGCHLD, sigchld_handler,
1884 /* When debugging the compositor, if use wl_event_loop_add_signal() to
1885 * catch SIGINT, the debugger can't catch it, and attempting to stop
1886 * the compositor from within the debugger results in weston exiting
1889 * Instead, use the sigaction() function, which sets up the signal in a
1890 * way that gdb can successfully catch, but have the handler for SIGINT
1891 * send SIGUSR2 (xwayland uses SIGUSR1), which we catch via
1892 * wl_event_loop_add_signal().
1894 action.sa_handler = sigint_helper;
1895 sigemptyset(&action.sa_mask);
1896 action.sa_flags = 0;
1897 sigaction(SIGINT, &action, NULL);
1899 for (size_t i = 0; i < ARRAY_LENGTH(signals); ++i)
1903 ivi.compositor = weston_compositor_create(display, log_ctx, &ivi, test_data);
1904 if (!ivi.compositor) {
1905 weston_log("fatal: failed to create compositor.\n");
1909 if (compositor_init_config(&ivi) < 0)
1910 goto error_compositor;
1912 if (load_backend(&ivi, backend, &argc, argv) < 0) {
1913 weston_log("fatal: failed to create compositor backend.\n");
1914 goto error_compositor;
1917 ivi.heads_changed.notify = heads_changed;
1918 weston_compositor_add_heads_changed_listener(ivi.compositor,
1919 &ivi.heads_changed);
1921 if (ivi_desktop_init(&ivi) < 0)
1922 goto error_compositor;
1924 ivi_seat_init(&ivi);
1926 /* load additional modules */
1927 weston_config_section_get_string(section, "modules", &modules, "");
1928 if (load_modules(&ivi, modules, &argc, argv, &xwayland) < 0)
1929 goto error_compositor;
1931 if (load_modules(&ivi, option_modules, &argc, argv, &xwayland) < 0)
1932 goto error_compositor;
1935 weston_config_section_get_bool(section, "xwayland", &xwayland,
1940 if (wet_load_xwayland(ivi.compositor) < 0)
1941 goto error_compositor;
1944 if (ivi_policy_init(&ivi) < 0)
1945 goto error_compositor;
1947 if (ivi_shell_init(&ivi) < 0)
1948 goto error_compositor;
1950 if (list_debug_scopes) {
1951 struct weston_log_scope *nscope = NULL;
1953 weston_log("Printing available debug scopes:\n");
1955 while ((nscope = weston_log_scopes_iterate(ivi.compositor, nscope))) {
1956 weston_log("\tscope name: %s, desc: %s",
1957 weston_log_scope_get_name(nscope),
1958 weston_log_scope_get_description(nscope));
1963 goto error_compositor;
1966 add_bindings(ivi.compositor);
1968 weston_compositor_flush_heads_changed(ivi.compositor);
1970 if (ivi.remoting_api)
1971 ivi_enable_remote_outputs(&ivi);
1973 if (ivi.waltham_transmitter_api)
1974 ivi_enable_waltham_outputs(&ivi);
1976 if (create_listening_socket(display, socket_name) < 0)
1977 goto error_compositor;
1979 ivi_shell_init_black_fs(&ivi);
1981 ivi.compositor->exit = handle_exit;
1983 weston_compositor_wake(ivi.compositor);
1985 ivi_shell_create_global(&ivi);
1987 ivi_launch_shell_client(&ivi, "shell-client",
1988 &ivi.shell_client.client);
1989 ivi_launch_shell_client(&ivi, "shell-client-ext",
1990 &ivi.shell_client_ext.client);
1993 ivi_screenshooter_create(&ivi);
1994 ivi_agl_systemd_notify(&ivi);
1996 wl_display_run(display);
1998 ret = ivi.compositor->exit_code;
2000 wl_display_destroy_clients(display);
2008 weston_compositor_destroy(ivi.compositor);
2010 weston_log_scope_destroy(log_scope);
2013 weston_log_subscriber_destroy(logger);
2014 weston_log_ctx_destroy(log_ctx);
2016 ivi_policy_destroy(ivi.policy);
2019 for (size_t i = 0; i < ARRAY_LENGTH(signals); ++i)
2021 wl_event_source_remove(signals[i]);
2023 wl_display_destroy(display);
2027 weston_config_destroy(ivi.config);
2033 free(option_modules);