X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fcompositor.c;h=6097da04196ce90ba0d3b39009e8c02b395a71ac;hb=6d2720303d8441525ba2e37c9d87daef568f8cdc;hp=250c90c6b96156e1996602f0aa3d2422d91e7df9;hpb=f825bf9e71ac5adfcbdc6ef7f6c2fef8555ee4a3;p=src%2Fagl-compositor.git diff --git a/src/compositor.c b/src/compositor.c index 250c90c..6097da0 100644 --- a/src/compositor.c +++ b/src/compositor.c @@ -39,6 +39,9 @@ #include #include +#ifdef HAVE_BACKEND_RDP +#include +#endif #ifdef HAVE_BACKEND_HEADLESS #include #endif @@ -54,16 +57,13 @@ #include "shared/os-compatibility.h" #include "shared/helpers.h" +#include "config.h" #include "agl-shell-server-protocol.h" #ifdef HAVE_REMOTING #include "remote.h" #endif -#ifdef HAVE_WALTHAM -#include -#endif - static int cached_tm_mday = -1; static struct weston_log_scope *log_scope; @@ -73,12 +73,95 @@ to_ivi_compositor(struct weston_compositor *ec) return weston_compositor_get_user_data(ec); } +struct ivi_output_config * +ivi_init_parsed_options(struct weston_compositor *compositor) +{ + struct ivi_compositor *ivi = to_ivi_compositor(compositor); + struct ivi_output_config *config; + + config = zalloc(sizeof *config); + if (!config) + return NULL; + + config->width = 0; + config->height = 0; + config->scale = 0; + config->transform = UINT32_MAX; + + ivi->parsed_options = config; + + return config; +} + + + static void sigint_helper(int sig) { raise(SIGUSR2); } +struct { + char *name; + enum weston_renderer_type renderer; +} renderer_name_map[] = { + { "auto", WESTON_RENDERER_AUTO }, + { "gl", WESTON_RENDERER_GL }, + { "noop", WESTON_RENDERER_NOOP }, + { "pixman", WESTON_RENDERER_PIXMAN }, +}; + +struct { + char *short_name; + char *long_name; + enum weston_compositor_backend backend; +} backend_name_map[] = { + { "drm", "drm-backend.so", WESTON_BACKEND_DRM }, + { "headless", "headless-backend.so", WESTON_BACKEND_HEADLESS }, + { "pipewire", "pipewire-backend.so", WESTON_BACKEND_PIPEWIRE }, + { "rdp", "rdp-backend.so", WESTON_BACKEND_RDP }, + { "vnc", "vnc-backend.so", WESTON_BACKEND_VNC }, + { "wayland", "wayland-backend.so", WESTON_BACKEND_WAYLAND }, + { "x11", "x11-backend.so", WESTON_BACKEND_X11 }, +}; + +bool +get_backend_from_string(const char *name, + enum weston_compositor_backend *backend) +{ + size_t i; + + for (i = 0; i < ARRAY_LENGTH(backend_name_map); i++) { + if (strcmp(name, backend_name_map[i].short_name) == 0 || + strcmp(name, backend_name_map[i].long_name) == 0) { + *backend = backend_name_map[i].backend; + return true; + } + } + + return false; +} + + +bool +get_renderer_from_string(const char *name, enum weston_renderer_type *renderer) +{ + size_t i; + + if (!name) + name = "auto"; + + for (i = 0; i < ARRAY_LENGTH(renderer_name_map); i++) { + if (strcmp(name, renderer_name_map[i].name) == 0) { + *renderer = renderer_name_map[i].renderer; + return true; + } + } + + return false; +} + + void ivi_layout_save(struct ivi_compositor *ivi, struct ivi_output *output) { @@ -178,7 +261,8 @@ handle_output_destroy(struct wl_listener *listener, void *data) if (output->fullscreen_view.fs && output->fullscreen_view.fs->view) { - weston_surface_destroy(output->fullscreen_view.fs->view->surface); + weston_surface_unref(output->fullscreen_view.fs->view->surface); + weston_buffer_destroy_solid(output->fullscreen_view.buffer_ref); output->fullscreen_view.fs->view = NULL; } @@ -222,7 +306,8 @@ ivi_output_configure_app_id(struct ivi_output *ivi_output) static struct ivi_output * ivi_ensure_output(struct ivi_compositor *ivi, char *name, - struct weston_config_section *config) + struct weston_config_section *config, + struct weston_head *head) { struct ivi_output *output = NULL; wl_list_for_each(output, &ivi->outputs, link) { @@ -242,11 +327,41 @@ ivi_ensure_output(struct ivi_compositor *ivi, char *name, output->name = name; output->config = config; - output->output = weston_compositor_create_output(ivi->compositor, name); - if (!output->output) { - free(output->name); - free(output); - return NULL; + if (ivi->simple_output_configure) { + output->output = + weston_compositor_create_output_with_head(ivi->compositor, + head); + if (!output->output) { + free(output->name); + free(output); + return NULL; + } + + int ret = ivi->simple_output_configure(output->output); + if (ret < 0) { + weston_log("Configuring output \"%s\" failed.\n", + weston_head_get_name(head)); + weston_output_destroy(output->output); + ivi->init_failed = true; + return NULL; + } + + if (weston_output_enable(output->output) < 0) { + weston_log("Enabling output \"%s\" failed.\n", + weston_head_get_name(head)); + weston_output_destroy(output->output); + ivi->init_failed = true; + return NULL; + } + + } else { + output->output = + weston_compositor_create_output(ivi->compositor, name); + if (!output->output) { + free(output->name); + free(output); + return NULL; + } } output->output_destroy.notify = handle_output_destroy; @@ -419,7 +534,7 @@ parse_transform(const char *transform, uint32_t *out) return -1; } -static int +int parse_activation_area(const char *geometry, struct ivi_output *output) { int n; @@ -487,7 +602,7 @@ try_attach_heads(struct ivi_output *output) { size_t fail_len = 0; - for (size_t i = 0; i < output->add_len; ++i) { + for (size_t i = 1; i < output->add_len; i++) { if (weston_output_attach_head(output->output, output->add[i]) < 0) { struct weston_head *tmp = output->add[i]; memmove(&output->add[fail_len + 1], output->add[fail_len], @@ -495,10 +610,42 @@ try_attach_heads(struct ivi_output *output) output->add[fail_len++] = tmp; } } - return fail_len; } +/* Place output exactly to the right of the most recently enabled output. + * + * Historically, we haven't given much thought to output placement, + * simply adding outputs in a horizontal line as they're enabled. This + * function simply sets an output's x coordinate to the right of the + * most recently enabled output, and its y to zero. + * + * If you're adding new calls to this function, you're also not giving + * much thought to output placement, so please consider carefully if + * it's really doing what you want. + * + * You especially don't want to use this for any code that won't + * immediately enable the passed output. + */ +static void +weston_output_lazy_align(struct weston_output *output) +{ + struct weston_compositor *c; + struct weston_output *peer; + int next_x = 0; + + /* Put this output to the right of the most recently enabled output */ + c = output->compositor; + if (!wl_list_empty(&c->output_list)) { + peer = container_of(c->output_list.prev, + struct weston_output, link); + next_x = peer->pos.c.x + peer->width; + } + output->pos.c.x = next_x; + output->pos.c.y = 0; +} + + /* * Like try_attach_heads, this reorganizes the output's add array into a failed * and successful section. @@ -510,6 +657,8 @@ try_enable_output(struct ivi_output *output, size_t i) for (; i < output->add_len; ++i) { struct weston_head *head; + weston_output_lazy_align(output->output); + if (weston_output_enable(output->output) == 0) break; @@ -640,6 +789,7 @@ head_prepare_enable(struct ivi_compositor *ivi, struct weston_head *head) struct ivi_output *output; char *output_name = NULL; + section = find_controlling_output_config(ivi->config, name); if (section) { char *mode; @@ -660,7 +810,7 @@ head_prepare_enable(struct ivi_compositor *ivi, struct weston_head *head) if (!output_name) return; - output = ivi_ensure_output(ivi, output_name, section); + output = ivi_ensure_output(ivi, output_name, section, head); if (!output) return; @@ -707,38 +857,6 @@ heads_changed(struct wl_listener *listener, void *arg) } } -#ifdef HAVE_WALTHAM -static int -load_waltham_plugin(struct ivi_compositor *ivi, struct weston_config *config) -{ - struct weston_compositor *compositor = ivi->compositor; - int (*module_init)(struct weston_compositor *wc); - - module_init = weston_load_module("waltham-transmitter.so", - "wet_module_init"); - if (!module_init) - return -1; - - if (module_init(compositor) < 0) - return -1; - - ivi->waltham_transmitter_api = weston_get_transmitter_api(compositor); - if (!ivi->waltham_transmitter_api) { - weston_log("Failed to load waltham-transmitter plugin.\n"); - return -1; - } - - weston_log("waltham-transmitter plug-in loaded\n"); - return 0; -} -#else -static int -load_waltham_plugin(struct ivi_compositor *ivi, struct weston_config *config) -{ - return -1; -} -#endif - #ifdef HAVE_REMOTING static int drm_backend_remoted_output_configure(struct weston_output *output, @@ -915,62 +1033,6 @@ ivi_enable_remote_outputs(struct ivi_compositor *ivi) } } -static void -ivi_enable_waltham_outputs(struct ivi_compositor *ivi) -{ - struct weston_config_section *transmitter_section = NULL; - const char *sect_name; - struct weston_config *config = ivi->config; - - while (weston_config_next_section(config, &transmitter_section, §_name)) { - if (strcmp(sect_name, "transmitter-output")) - continue; - - struct ivi_output *ivi_output = NULL; - bool output_found = false; - char *_name = NULL; - - weston_config_section_get_string(transmitter_section, - "name", &_name, NULL); - wl_list_for_each(ivi_output, &ivi->outputs, link) { - if (!strcmp(ivi_output->name, _name)) { - output_found = true; - break; - } - } - - if (output_found) { - free(_name); - continue; - } - - ivi_output = zalloc(sizeof(*ivi_output)); - if (!ivi_output) { - free(_name); - continue; - } - - ivi_output->ivi = ivi; - ivi_output->name = _name; - ivi_output->config = transmitter_section; - - if (remote_output_init(ivi_output, ivi->compositor, - transmitter_section, ivi->remoting_api)) { - free(ivi_output->name); - free(ivi_output); - continue; - } - - ivi_output->type = OUTPUT_WALTHAM; - ivi_output->output_destroy.notify = handle_output_destroy; - weston_output_add_destroy_listener(ivi_output->output, - &ivi_output->output_destroy); - - wl_list_insert(&ivi->outputs, &ivi_output->link); - ivi_output_configure_app_id(ivi_output); - } -} - static int load_remoting_plugin(struct ivi_compositor *ivi, struct weston_config *config) { @@ -978,7 +1040,8 @@ load_remoting_plugin(struct ivi_compositor *ivi, struct weston_config *config) int (*module_init)(struct weston_compositor *wc); module_init = weston_load_module("remoting-plugin.so", - "weston_module_init"); + "weston_module_init", + LIBWESTON_MODULEDIR); if (!module_init) return -1; @@ -999,7 +1062,8 @@ load_remoting_plugin(struct weston_compositor *compositor, struct weston_config #endif static int -load_drm_backend(struct ivi_compositor *ivi, int *argc, char *argv[]) +load_drm_backend(struct ivi_compositor *ivi, int *argc, char *argv[], + enum weston_renderer_type renderer) { struct weston_drm_backend_config config = { .base = { @@ -1009,7 +1073,7 @@ load_drm_backend(struct ivi_compositor *ivi, int *argc, char *argv[]) }; struct weston_config_section *section; int use_current_mode = 0; - int use_pixman = 0; + bool force_pixman = false; bool use_shadow; bool without_input = false; int ret; @@ -1018,12 +1082,17 @@ load_drm_backend(struct ivi_compositor *ivi, int *argc, char *argv[]) { WESTON_OPTION_STRING, "seat", 0, &config.seat_id }, { WESTON_OPTION_STRING, "drm-device", 0, &config.specific_device }, { WESTON_OPTION_BOOLEAN, "current-mode", 0, &use_current_mode }, - { WESTON_OPTION_BOOLEAN, "use-pixman", 0, &use_pixman }, + { WESTON_OPTION_BOOLEAN, "use-pixman", 0, &force_pixman }, { WESTON_OPTION_BOOLEAN, "continue-without-input", false, &without_input } }; parse_options(options, ARRAY_LENGTH(options), argc, argv); - config.use_pixman = use_pixman; + + if (force_pixman) + config.renderer = WESTON_RENDERER_PIXMAN; + else + config.renderer = WESTON_RENDERER_AUTO; + ivi->cmdline.use_current_mode = use_current_mode; section = weston_config_get_section(ivi->config, "core", NULL, NULL); @@ -1050,7 +1119,6 @@ load_drm_backend(struct ivi_compositor *ivi, int *argc, char *argv[]) } load_remoting_plugin(ivi, ivi->config); - load_waltham_plugin(ivi, ivi->config); error: free(config.gbm_format); @@ -1060,7 +1128,7 @@ error: static void windowed_parse_common_options(struct ivi_compositor *ivi, int *argc, char *argv[], - bool *use_pixman, bool *fullscreen, int *output_count) + bool *force_pixman, bool *fullscreen, int *output_count) { struct weston_config_section *section; bool pixman; @@ -1070,17 +1138,17 @@ windowed_parse_common_options(struct ivi_compositor *ivi, int *argc, char *argv[ { WESTON_OPTION_INTEGER, "width", 0, &ivi->cmdline.width }, { WESTON_OPTION_INTEGER, "height", 0, &ivi->cmdline.height }, { WESTON_OPTION_INTEGER, "scale", 0, &ivi->cmdline.scale }, - { WESTON_OPTION_BOOLEAN, "use-pixman", 0, &pixman }, + { WESTON_OPTION_BOOLEAN, "use-pixman", 0, &force_pixman }, { WESTON_OPTION_BOOLEAN, "fullscreen", 0, &fs }, { WESTON_OPTION_INTEGER, "output-count", 0, output_count }, }; section = weston_config_get_section(ivi->config, "core", NULL, NULL); - weston_config_section_get_bool(section, "use-pixman", &pixman, 0); + weston_config_section_get_bool(section, "use-pixman", &pixman, false); *output_count = 1; parse_options(options, ARRAY_LENGTH(options), argc, argv); - *use_pixman = pixman; + *force_pixman = pixman; *fullscreen = fs; } @@ -1111,7 +1179,7 @@ windowed_create_outputs(struct ivi_compositor *ivi, int output_count, continue; } - if (ivi->window_api->create_head(ivi->compositor, output_name) < 0) { + if (ivi->window_api->create_head(ivi->compositor->backend, output_name) < 0) { free(output_name); return -1; } @@ -1124,7 +1192,7 @@ windowed_create_outputs(struct ivi_compositor *ivi, int output_count, if (asprintf(&default_output, "%s%d", name_prefix, i) < 0) return -1; - if (ivi->window_api->create_head(ivi->compositor, default_output) < 0) { + if (ivi->window_api->create_head(ivi->compositor->backend, default_output) < 0) { free(default_output); return -1; } @@ -1136,7 +1204,8 @@ windowed_create_outputs(struct ivi_compositor *ivi, int output_count, } static int -load_wayland_backend(struct ivi_compositor *ivi, int *argc, char *argv[]) +load_wayland_backend(struct ivi_compositor *ivi, int *argc, char *argv[], + enum weston_renderer_type renderer) { struct weston_wayland_backend_config config = { .base = { @@ -1147,6 +1216,7 @@ load_wayland_backend(struct ivi_compositor *ivi, int *argc, char *argv[]) struct weston_config_section *section; int sprawl = 0; int output_count; + bool force_pixman = false; int ret; const struct weston_option options[] = { @@ -1154,7 +1224,7 @@ load_wayland_backend(struct ivi_compositor *ivi, int *argc, char *argv[]) { WESTON_OPTION_STRING, "sprawl", 0, &sprawl }, }; - windowed_parse_common_options(ivi, argc, argv, &config.use_pixman, + windowed_parse_common_options(ivi, argc, argv, &force_pixman, &config.fullscreen, &output_count); parse_options(options, ARRAY_LENGTH(options), argc, argv); @@ -1192,7 +1262,8 @@ load_wayland_backend(struct ivi_compositor *ivi, int *argc, char *argv[]) #ifdef HAVE_BACKEND_X11 static int -load_x11_backend(struct ivi_compositor *ivi, int *argc, char *argv[]) +load_x11_backend(struct ivi_compositor *ivi, int *argc, char *argv[], + enum weston_renderer_type renderer) { struct weston_x11_backend_config config = { .base = { @@ -1203,15 +1274,20 @@ load_x11_backend(struct ivi_compositor *ivi, int *argc, char *argv[]) int no_input = 0; int output_count; int ret; + bool force_pixman = false; const struct weston_option options[] = { { WESTON_OPTION_BOOLEAN, "no-input", 0, &no_input }, }; - windowed_parse_common_options(ivi, argc, argv, &config.use_pixman, + windowed_parse_common_options(ivi, argc, argv, &force_pixman, &config.fullscreen, &output_count); parse_options(options, ARRAY_LENGTH(options), argc, argv); + if (force_pixman) + config.renderer = WESTON_RENDERER_PIXMAN; + else + config.renderer = WESTON_RENDERER_AUTO; config.no_input = no_input; ret = weston_compositor_load_backend(ivi->compositor, WESTON_BACKEND_X11, @@ -1230,7 +1306,8 @@ load_x11_backend(struct ivi_compositor *ivi, int *argc, char *argv[]) } #else static int -load_x11_backend(struct ivi_compositor *ivi, int *argc, char *argv[]) +load_x11_backend(struct ivi_compositor *ivi, int *argc, char **argv, + enum weston_renderer_type renderer) { return -1; } @@ -1238,29 +1315,40 @@ load_x11_backend(struct ivi_compositor *ivi, int *argc, char *argv[]) #ifdef HAVE_BACKEND_HEADLESS static int -load_headless_backend(struct ivi_compositor *ivi, int *argc, char **argv) +load_headless_backend(struct ivi_compositor *ivi, int *argc, char **argv, + enum weston_renderer_type renderer) { struct weston_headless_backend_config config = {}; int ret = 0; - bool use_pixman; + bool force_pixman = false; bool fullscreen; - bool use_gl; + bool force_gl = false; int output_count; struct weston_compositor *c = ivi->compositor; const struct weston_option options[] = { - { WESTON_OPTION_BOOLEAN, "use-pixman", 0, &use_pixman }, - { WESTON_OPTION_BOOLEAN, "use-gl", 0, &use_gl }, + { WESTON_OPTION_BOOLEAN, "use-pixman", false, &force_pixman }, + { WESTON_OPTION_BOOLEAN, "use-gl", false, &force_gl }, }; - windowed_parse_common_options(ivi, argc, argv, &use_pixman, + windowed_parse_common_options(ivi, argc, argv, &force_pixman, &fullscreen, &output_count); parse_options(options, ARRAY_LENGTH(options), argc, argv); - config.use_pixman = use_pixman; - config.use_gl = use_gl; + + if ((force_pixman && force_gl) || + (renderer != WESTON_RENDERER_AUTO && (force_pixman || force_gl))) { + weston_log("Conflicting renderer specifications\n"); + return -1; + } else if (force_pixman) { + config.renderer = WESTON_RENDERER_PIXMAN; + } else if (force_gl) { + config.renderer = WESTON_RENDERER_GL; + } else { + config.renderer = renderer; + } config.base.struct_version = WESTON_HEADLESS_BACKEND_CONFIG_VERSION; config.base.struct_size = sizeof(struct weston_headless_backend_config); @@ -1277,7 +1365,7 @@ load_headless_backend(struct ivi_compositor *ivi, int *argc, char **argv) return -1; } - if (ivi->window_api->create_head(c, "headless") < 0) { + if (ivi->window_api->create_head(c->backend, "headless") < 0) { weston_log("Cannot create headless back-end\n"); return -1; } @@ -1286,16 +1374,162 @@ load_headless_backend(struct ivi_compositor *ivi, int *argc, char **argv) } #else static int -load_headless_backend(struct ivi_compositor *ivi, int *argc, char **argv) +load_headless_backend(struct ivi_compositor *ivi, int *argc, char **argv, enum weston_renderer_type renderer) { return -1; } #endif +#ifdef HAVE_BACKEND_RDP +static void +weston_rdp_backend_config_init(struct weston_rdp_backend_config *config) +{ + config->base.struct_version = WESTON_RDP_BACKEND_CONFIG_VERSION; + config->base.struct_size = sizeof(struct weston_rdp_backend_config); + + config->bind_address = NULL; + config->port = 3389; + config->rdp_key = NULL; + config->server_cert = NULL; + config->server_key = NULL; + config->env_socket = 0; + config->no_clients_resize = 1; + config->force_no_compression = 0; +} + static int -load_backend(struct ivi_compositor *ivi, const char *backend, - int *argc, char *argv[]) +rdp_backend_output_configure(struct weston_output *output) +{ + struct ivi_compositor *ivi = to_ivi_compositor(output->compositor); + struct ivi_output_config *parsed_options = ivi->parsed_options; + const struct weston_rdp_output_api *api = + weston_rdp_output_get_api(output->compositor); + int width = 640; + int height = 480; + struct weston_config_section *section; + uint32_t transform = WL_OUTPUT_TRANSFORM_NORMAL; + char *transform_string; + + assert(parsed_options); + + if (!api) { + weston_log("Cannot use weston_rdp_output_api.\n"); + return -1; + } + + section = weston_config_get_section(ivi->config, "rdp", NULL, NULL); + + if (parsed_options->width) + width = parsed_options->width; + + if (parsed_options->height) + height = parsed_options->height; + + weston_output_set_scale(output, 1); + + weston_config_section_get_int(section, "width", + &width, width); + + weston_config_section_get_int(section, "height", + &height, height); + + if (parsed_options->transform) + transform = parsed_options->transform; + + weston_config_section_get_string(section, "transform", + &transform_string, "normal"); + + if (parse_transform(transform_string, &transform) < 0) { + weston_log("Invalid transform \"%s\" for output %s\n", + transform_string, output->name); + return -1; + } + + weston_output_set_transform(output, transform); + + if (api->output_set_size(output, width, height) < 0) { + weston_log("Cannot configure output \"%s\" using weston_rdp_output_api.\n", + output->name); + return -1; + } + + return 0; +} + +static int +load_rdp_backend(struct ivi_compositor *ivi, int *argc, char **argv) { + struct weston_rdp_backend_config config = {}; + int ret = 0; + struct weston_config_section *section; + + struct ivi_output_config *parsed_options = ivi_init_parsed_options(ivi->compositor); + if (!parsed_options) + return -1; + + weston_rdp_backend_config_init(&config); + + const struct weston_option rdp_options[] = { + { WESTON_OPTION_BOOLEAN, "env-socket", 0, &config.env_socket }, + { WESTON_OPTION_INTEGER, "width", 0, &parsed_options->width }, + { WESTON_OPTION_INTEGER, "height", 0, &parsed_options->height }, + { WESTON_OPTION_INTEGER, "transform", 0, &parsed_options->transform }, + { WESTON_OPTION_INTEGER, "scale", 0, &parsed_options->scale }, + { WESTON_OPTION_STRING, "address", 0, &config.bind_address }, + { WESTON_OPTION_INTEGER, "port", 0, &config.port }, + { WESTON_OPTION_BOOLEAN, "no-clients-resize", 0, &config.no_clients_resize }, + { WESTON_OPTION_STRING, "rdp4-key", 0, &config.rdp_key }, + { WESTON_OPTION_STRING, "rdp-tls-cert", 0, &config.server_cert }, + { WESTON_OPTION_STRING, "rdp-tls-key", 0, &config.server_key }, + { WESTON_OPTION_BOOLEAN, "force-no-compression", 0, &config.force_no_compression }, + }; + + section = weston_config_get_section(ivi->config, "rdp", NULL, NULL); + + weston_config_section_get_string(section, "tls-cert", + &config.server_cert, config.server_cert); + + weston_config_section_get_string(section, "tls-key", + &config.server_key, config.server_key); + + + parse_options(rdp_options, ARRAY_LENGTH(rdp_options), argc, argv); + + ivi->simple_output_configure = rdp_backend_output_configure; + ret = weston_compositor_load_backend(ivi->compositor, WESTON_BACKEND_RDP, &config.base); + + free(config.bind_address); + free(config.rdp_key); + free(config.server_cert); + free(config.server_key); + + return ret; +} +#else +static int +load_rdp_backend(struct ivi_compositor *ivi, int *argc, char **argv) +{ + return -1; +} +#endif + + +static int +load_backend(struct ivi_compositor *ivi, int *argc, char **argv, + const char *backend_name, const char *renderer_name) +{ + enum weston_compositor_backend backend; + enum weston_renderer_type renderer; + + if (!get_backend_from_string(backend_name, &backend)) { + weston_log("Error: unknown backend \"%s\"\n", backend_name); + return -1; + } + + if (!get_renderer_from_string(renderer_name, &renderer)) { + weston_log("Error: unknown renderer \"%s\"\n", renderer_name); + return -1; + } if (strcmp(backend, "drm-backend.so") == 0) { return load_drm_backend(ivi, argc, argv); } else if (strcmp(backend, "wayland-backend.so") == 0) { @@ -1304,9 +1538,10 @@ load_backend(struct ivi_compositor *ivi, const char *backend, return load_x11_backend(ivi, argc, argv); } else if (strcmp(backend, "headless-backend.so") == 0) { return load_headless_backend(ivi, argc, argv); - } + } else if (strcmp(backend, "rdp-backend.so") == 0) { + return load_rdp_backend(ivi, argc, argv); - weston_log("fatal: unknown backend '%s'.\n", backend); + weston_log("fatal: unknown backend '%s'.\n", backend_name); return -1; } @@ -1327,27 +1562,18 @@ load_modules(struct ivi_compositor *ivi, const char *modules, snprintf(buffer, sizeof buffer, "%.*s", (int) (end - p), p); if (strstr(buffer, "xwayland.so")) { - weston_log("Xwayland plug-in not supported!\n"); - p = end; - while (*p == ',') - p++; - continue; - } - - if (strstr(buffer, "systemd-notify.so")) { + *xwayland = true; + } else if (strstr(buffer, "systemd-notify.so")) { weston_log("systemd-notify plug-in already loaded!\n"); - p = end; - while (*p == ',') - p++; - continue; - } + } else { + module_init = weston_load_module(buffer, "wet_module_init", WESTON_MODULEDIR); + if (!module_init) + return -1; - module_init = weston_load_module(buffer, "wet_module_init"); - if (!module_init) - return -1; + if (module_init(ivi->compositor, *argc, argv) < 0) + return -1; - if (module_init(ivi->compositor, *argc, argv) < 0) - return -1; + } p = end; while (*p == ',') @@ -1712,6 +1938,7 @@ usage(int error_code) "\t\t\t\twayland-backend.so\n" "\t\t\t\tx11-backend.so\n" "\t\t\t\theadless-backend.so\n" + " -r, --renderer=NAME\tName of renderer to use: auto, gl, noop, pixman\n" " -S, --socket=NAME\tName of socket to listen on\n" " --log=FILE\t\tLog to the given file\n" " -c, --config=FILE\tConfig file to load, defaults to agl-compositor.ini\n" @@ -1742,6 +1969,44 @@ copy_command_line(int argc, char * const argv[]) return str; } +#if !defined(BUILD_XWAYLAND) +int +wet_load_xwayland(struct weston_compositor *comp) +{ + weston_log("Attempted to load xwayland library but compositor " + "was *not* built with xwayland support!\n"); + return -1; +} +#endif + +static void +weston_log_setup_scopes(struct weston_log_context *log_ctx, + struct weston_log_subscriber *subscriber, + const char *names) +{ + assert(log_ctx); + assert(subscriber); + + char *tokenize = strdup(names); + char *token = strtok(tokenize, ","); + while (token) { + weston_log_subscribe(log_ctx, subscriber, token); + token = strtok(NULL, ","); + } + free(tokenize); +} + +static void +weston_log_subscribe_to_scopes(struct weston_log_context *log_ctx, + struct weston_log_subscriber *logger, + const char *debug_scopes) +{ + if (logger && debug_scopes) + weston_log_setup_scopes(log_ctx, logger, debug_scopes); + else + weston_log_subscribe(log_ctx, logger, "log"); +} + WL_EXPORT int wet_main(int argc, char *argv[], const struct weston_testsuite_data *test_data) { @@ -1757,18 +2022,22 @@ int wet_main(int argc, char *argv[], const struct weston_testsuite_data *test_da char *log = NULL; char *modules = NULL; char *option_modules = NULL; + char *debug_scopes = NULL; int help = 0; int version = 0; int no_config = 0; int debug = 0; + bool list_debug_scopes = false; char *config_file = NULL; struct weston_log_context *log_ctx = NULL; struct weston_log_subscriber *logger; int ret = EXIT_FAILURE; bool xwayland = false; struct sigaction action; + char *renderer = NULL; const struct weston_option core_options[] = { + { WESTON_OPTION_STRING, "renderer", 'r', &renderer }, { WESTON_OPTION_STRING, "backend", 'B', &backend }, { WESTON_OPTION_STRING, "socket", 'S', &socket_name }, { WESTON_OPTION_STRING, "log", 0, &log }, @@ -1778,6 +2047,8 @@ int wet_main(int argc, char *argv[], const struct weston_testsuite_data *test_da { WESTON_OPTION_BOOLEAN, "debug", 0, &debug }, { WESTON_OPTION_STRING, "config", 'c', &config_file }, { WESTON_OPTION_STRING, "modules", 0, &option_modules }, + { WESTON_OPTION_STRING, "debug-scopes", 'l', &debug_scopes }, + { WESTON_OPTION_STRING, "list-debug-scopes", 'L', &list_debug_scopes }, }; wl_list_init(&ivi.outputs); @@ -1790,6 +2061,7 @@ int wet_main(int argc, char *argv[], const struct weston_testsuite_data *test_da wl_list_init(&ivi.remote_pending_apps); wl_list_init(&ivi.desktop_clients); wl_list_init(&ivi.child_process_list); + wl_list_init(&ivi.pending_apps); /* Prevent any clients we spawn getting our stdin */ os_fd_set_cloexec(STDIN_FILENO); @@ -1820,7 +2092,7 @@ int wet_main(int argc, char *argv[], const struct weston_testsuite_data *test_da weston_log_set_handler(vlog, vlog_continue); logger = weston_log_subscriber_create_log(logfile); - weston_log_subscribe(log_ctx, logger, "log"); + weston_log_subscribe_to_scopes(log_ctx, logger, debug_scopes); weston_log("Command line: %s\n", cmdline); free(cmdline); @@ -1878,7 +2150,7 @@ int wet_main(int argc, char *argv[], const struct weston_testsuite_data *test_da if (compositor_init_config(&ivi) < 0) goto error_compositor; - if (load_backend(&ivi, backend, &argc, argv) < 0) { + if (load_backend(&ivi, &argc, argv, backend, renderer) < 0) { weston_log("fatal: failed to create compositor backend.\n"); goto error_compositor; } @@ -1887,6 +2159,7 @@ int wet_main(int argc, char *argv[], const struct weston_testsuite_data *test_da weston_compositor_add_heads_changed_listener(ivi.compositor, &ivi.heads_changed); + weston_compositor_flush_heads_changed(ivi.compositor); if (ivi_desktop_init(&ivi) < 0) goto error_compositor; @@ -1900,22 +2173,44 @@ int wet_main(int argc, char *argv[], const struct weston_testsuite_data *test_da if (load_modules(&ivi, option_modules, &argc, argv, &xwayland) < 0) goto error_compositor; + if (!xwayland) { + weston_config_section_get_bool(section, "xwayland", &xwayland, + false); + } + + if (ivi_shell_init(&ivi) < 0) + goto error_compositor; + + if (xwayland) { + if (wet_load_xwayland(ivi.compositor) < 0) + goto error_compositor; + } + if (ivi_policy_init(&ivi) < 0) goto error_compositor; - if (ivi_shell_init(&ivi) < 0) + + if (list_debug_scopes) { + struct weston_log_scope *nscope = NULL; + + weston_log("Printing available debug scopes:\n"); + + while ((nscope = weston_log_scopes_iterate(log_ctx, nscope))) { + weston_log("\tscope name: %s, desc: %s", + weston_log_scope_get_name(nscope), + weston_log_scope_get_description(nscope)); + } + + weston_log("\n"); + goto error_compositor; + } add_bindings(ivi.compositor); - weston_compositor_flush_heads_changed(ivi.compositor); - if (ivi.remoting_api) ivi_enable_remote_outputs(&ivi); - if (ivi.waltham_transmitter_api) - ivi_enable_waltham_outputs(&ivi); - if (create_listening_socket(display, socket_name) < 0) goto error_compositor;