X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fcompositor.c;h=61dbec6d024d67f3a28ee10a9572e9576c3a0975;hb=b22629f406545d7b252853b80982d59ef0fdaa81;hp=909f77193d08a7086a698b306843ec3a4988c81a;hpb=48124d46cd8cc2e0cf68805afdb7cea2c12895c2;p=src%2Fagl-compositor.git diff --git a/src/compositor.c b/src/compositor.c index 909f771..61dbec6 100644 --- a/src/compositor.c +++ b/src/compositor.c @@ -1,5 +1,5 @@ /* - * Copyright © 2012-2021 Collabora, Ltd. + * Copyright © 2012-2024 Collabora, Ltd. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -42,9 +42,6 @@ #ifdef HAVE_BACKEND_RDP #include #endif -#ifdef HAVE_BACKEND_HEADLESS -#include -#endif #ifdef HAVE_BACKEND_X11 #include #endif @@ -93,8 +90,6 @@ ivi_init_parsed_options(struct weston_compositor *compositor) return config; } - - static void sigint_helper(int sig) { @@ -117,10 +112,7 @@ struct { 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 }, }; @@ -142,7 +134,6 @@ get_backend_from_string(const char *name, return false; } - bool get_renderer_from_string(const char *name, enum weston_renderer_type *renderer) { @@ -161,96 +152,6 @@ get_renderer_from_string(const char *name, enum weston_renderer_type *renderer) return false; } - -void -ivi_layout_save(struct ivi_compositor *ivi, struct ivi_output *output) -{ - struct ivi_output *new_output; - ivi->need_ivi_output_relayout = true; - - new_output = zalloc(sizeof(*new_output)); - - new_output->ivi = ivi; - new_output->background = output->background; - - new_output->top = output->top; - new_output->bottom = output->bottom; - new_output->left = output->left; - new_output->right = output->right; - - new_output->active = output->active; - new_output->previous_active = output->previous_active; - new_output->name = strdup(output->name); - if (output->app_ids) - new_output->app_ids = strdup(output->app_ids); - - new_output->area = output->area; - new_output->area_saved = output->area_saved; - new_output->area_activation = output->area_activation; - - weston_log("saving output layout for output %s\n", new_output->name); - - wl_list_insert(&ivi->saved_outputs, &new_output->link); -} - -void -ivi_layout_restore(struct ivi_compositor *ivi, struct ivi_output *n_output) -{ - struct ivi_output *output = NULL; - struct ivi_output *iter_output; - - if (!ivi->need_ivi_output_relayout) - return; - - ivi->need_ivi_output_relayout = false; - - wl_list_for_each(iter_output, &ivi->saved_outputs, link) { - if (strcmp(n_output->name, iter_output->name) == 0) { - output = iter_output; - break; - } - } - - if (!output) - return; - - weston_log("restoring output layout for output %s\n", output->name); - n_output->background = output->background; - - n_output->top = output->top; - n_output->bottom = output->bottom; - n_output->left = output->left; - n_output->right = output->right; - - n_output->active = output->active; - n_output->previous_active = output->previous_active; - if (output->app_ids) - n_output->app_ids = strdup(output->app_ids); - - n_output->area = output->area; - n_output->area_saved = output->area_saved; - n_output->area_activation = output->area_activation; - - free(output->app_ids); - free(output->name); - wl_list_remove(&output->link); - free(output); -} - -void -ivi_layout_destroy_saved_outputs(struct ivi_compositor *ivi) -{ - struct ivi_output *output, *output_next; - - wl_list_for_each_safe(output, output_next, &ivi->saved_outputs, link) { - free(output->app_ids); - free(output->name); - - wl_list_remove(&output->link); - free(output); - } -} - static void handle_output_destroy(struct wl_listener *listener, void *data) { @@ -327,16 +228,15 @@ ivi_ensure_output(struct ivi_compositor *ivi, char *name, output->name = name; output->config = config; - 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; - } + output->output = + weston_compositor_create_output(ivi->compositor, head, head->name); + if (!output->output) { + free(output->name); + free(output); + return NULL; + } + if (ivi->simple_output_configure) { int ret = ivi->simple_output_configure(output->output); if (ret < 0) { weston_log("Configuring output \"%s\" failed.\n", @@ -353,15 +253,6 @@ ivi_ensure_output(struct ivi_compositor *ivi, char *name, 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; @@ -1105,6 +996,10 @@ load_drm_backend(struct ivi_compositor *ivi, int *argc, char *argv[], if (without_input) ivi->compositor->require_input = !without_input; + ivi->heads_changed.notify = heads_changed; + weston_compositor_add_heads_changed_listener(ivi->compositor, + &ivi->heads_changed); + if (!weston_compositor_load_backend(ivi->compositor, WESTON_BACKEND_DRM, &config.base)) return -1; @@ -1117,6 +1012,8 @@ load_drm_backend(struct ivi_compositor *ivi, int *argc, char *argv[], load_remoting_plugin(ivi, ivi->config); + return 0; + error: free(config.gbm_format); free(config.seat_id); @@ -1286,11 +1183,8 @@ load_x11_backend(struct ivi_compositor *ivi, int *argc, char *argv[], config.renderer = WESTON_RENDERER_AUTO; config.no_input = no_input; - ret = weston_compositor_load_backend(ivi->compositor, WESTON_BACKEND_X11, - &config.base); - - if (ret < 0) - return ret; + if (!weston_compositor_load_backend(ivi->compositor, WESTON_BACKEND_X11, &config.base)) + return -1; ivi->window_api = weston_windowed_output_get_api(ivi->compositor); if (!ivi->window_api) { @@ -1309,73 +1203,6 @@ load_x11_backend(struct ivi_compositor *ivi, int *argc, char **argv, } #endif -#ifdef HAVE_BACKEND_HEADLESS -static int -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 force_pixman = false; - bool fullscreen; - bool force_gl = false; - int output_count; - - struct weston_compositor *c = ivi->compositor; - - const struct weston_option options[] = { - { WESTON_OPTION_BOOLEAN, "use-pixman", false, &force_pixman }, - { WESTON_OPTION_BOOLEAN, "use-gl", false, &force_gl }, - }; - - windowed_parse_common_options(ivi, argc, argv, &force_pixman, - &fullscreen, &output_count); - - parse_options(options, ARRAY_LENGTH(options), argc, argv); - - 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); - - /* load the actual headless-backend and configure it */ - ret = weston_compositor_load_backend(c, WESTON_BACKEND_HEADLESS, - &config.base); - if (ret < 0) - return ret; - - ivi->window_api = weston_windowed_output_get_api(c); - if (!ivi->window_api) { - weston_log("Cannot use weston_windowed_output_api.\n"); - return -1; - } - - if (ivi->window_api->create_head(c->backend, "headless") < 0) { - weston_log("Cannot create headless back-end\n"); - return -1; - } - - return 0; -} -#else -static int -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) @@ -1405,6 +1232,7 @@ rdp_backend_output_configure(struct weston_output *output) struct weston_config_section *section; uint32_t transform = WL_OUTPUT_TRANSFORM_NORMAL; char *transform_string; + struct weston_mode new_mode = {}; assert(parsed_options); @@ -1441,13 +1269,12 @@ rdp_backend_output_configure(struct weston_output *output) 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; - } + new_mode.width = width; + new_mode.height = height; + + api->output_set_mode(output, &new_mode); + weston_output_set_transform(output, transform); return 0; } @@ -1456,7 +1283,6 @@ 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); @@ -1492,14 +1318,15 @@ load_rdp_backend(struct ivi_compositor *ivi, int *argc, char **argv) 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); + if (!weston_compositor_load_backend(ivi->compositor, WESTON_BACKEND_RDP, &config.base)) + return -1; free(config.bind_address); free(config.rdp_key); free(config.server_cert); free(config.server_key); - return ret; + return 0; } #else static int @@ -1526,19 +1353,21 @@ load_backend(struct ivi_compositor *ivi, int *argc, char **argv, 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) { - return load_wayland_backend(ivi, argc, argv); - } else if (strcmp(backend, "x11-backend.so") == 0) { - 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) { + + switch (backend) { + case WESTON_BACKEND_DRM: + return load_drm_backend(ivi, argc, argv, renderer); + case WESTON_BACKEND_RDP: return load_rdp_backend(ivi, argc, argv); + case WESTON_BACKEND_WAYLAND: + return load_wayland_backend(ivi, argc, argv, renderer); + case WESTON_BACKEND_X11: + return load_x11_backend(ivi, argc, argv, renderer); + default: + assert(!"unknown backend type in load_backend()"); + } - weston_log("fatal: unknown backend '%s'.\n", backend_name); - return -1; + return 0; } static int @@ -2151,11 +1980,11 @@ int wet_main(int argc, char *argv[], const struct weston_testsuite_data *test_da goto error_compositor; } - ivi.heads_changed.notify = heads_changed; - weston_compositor_add_heads_changed_listener(ivi.compositor, - &ivi.heads_changed); + if (weston_compositor_backends_loaded(ivi.compositor) < 0) + goto error_compositor; weston_compositor_flush_heads_changed(ivi.compositor); + if (ivi_desktop_init(&ivi) < 0) goto error_compositor;