diff --git a/include/libweston/libweston.h b/include/libweston/libweston.h index 4a397bf0f..e73797658 100644 --- a/include/libweston/libweston.h +++ b/include/libweston/libweston.h @@ -558,6 +558,8 @@ struct weston_output { uint32_t id; char *name; + void *shell_private; + struct weston_backend *backend; /** Matches the lifetime from the user perspective */ diff --git a/include/libweston/shell-utils.h b/include/libweston/shell-utils.h index 01306c13f..ddc32df9e 100644 --- a/include/libweston/shell-utils.h +++ b/include/libweston/shell-utils.h @@ -75,6 +75,13 @@ weston_shell_utils_curtain_destroy(struct weston_curtain *curtain); enum weston_layer_position weston_shell_utils_view_get_layer_position(struct weston_view *view); +void +weston_output_set_shell_private(struct weston_output *output, + void *private_data); + +void * +weston_output_get_shell_private(struct weston_output *output); + #ifdef __cplusplus } #endif diff --git a/kiosk-shell/kiosk-shell.c b/kiosk-shell/kiosk-shell.c index 88fb85aef..168f71101 100644 --- a/kiosk-shell/kiosk-shell.c +++ b/kiosk-shell/kiosk-shell.c @@ -147,9 +147,6 @@ kiosk_shell_output_set_active_surface_tree(struct kiosk_shell_output *shoutput, static void kiosk_shell_output_raise_surface_subtree(struct kiosk_shell_output *shoutput, struct kiosk_shell_surface *shroot); -static struct kiosk_shell_output * -kiosk_shell_find_shell_output(struct kiosk_shell *shell, - struct weston_output *output); static void kiosk_shell_surface_notify_parent_destroy(struct wl_listener *listener, void *data) @@ -271,12 +268,11 @@ kiosk_shell_surface_find_best_output(struct kiosk_shell_surface *shsurf) output = weston_shell_utils_get_focused_output(shsurf->shell->compositor); if (output) - return kiosk_shell_find_shell_output(shsurf->shell, - output); + return weston_output_get_shell_private(output); + output = weston_shell_utils_get_default_output(shsurf->shell->compositor); if (output) - return kiosk_shell_find_shell_output(shsurf->shell, - output); + return weston_output_get_shell_private(output); return NULL; } @@ -824,6 +820,8 @@ kiosk_shell_output_create(struct kiosk_shell *shell, struct weston_output *outpu wl_list_insert(shell->output_list.prev, &shoutput->link); + weston_output_set_shell_private(output, shoutput); + kiosk_shell_output_recreate_background(shoutput); kiosk_shell_output_configure(shoutput); @@ -1136,7 +1134,7 @@ desktop_surface_fullscreen_requested(struct weston_desktop_surface *desktop_surf struct kiosk_shell_surface *shsurf = weston_desktop_surface_get_user_data(desktop_surface); struct kiosk_shell_output *shoutput = - kiosk_shell_find_shell_output(shsurf->shell, output); + weston_output_get_shell_private(output); /* We should normally be able to ignore fullscreen requests for * top-level surfaces, since we set them as fullscreen at creation * time. However, xwayland surfaces set their internal WM state @@ -1234,20 +1232,6 @@ static const struct weston_desktop_api kiosk_shell_desktop_api = { * kiosk_shell */ -static struct kiosk_shell_output * -kiosk_shell_find_shell_output(struct kiosk_shell *shell, - struct weston_output *output) -{ - struct kiosk_shell_output *shoutput; - - wl_list_for_each(shoutput, &shell->output_list, link) { - if (shoutput->output == output) - return shoutput; - } - - return NULL; -} - static void kiosk_shell_activate_view(struct kiosk_shell *shell, struct weston_view *view, @@ -1336,7 +1320,7 @@ kiosk_shell_handle_output_resized(struct wl_listener *listener, void *data) container_of(listener, struct kiosk_shell, output_resized_listener); struct weston_output *output = data; struct kiosk_shell_output *shoutput = - kiosk_shell_find_shell_output(shell, output); + weston_output_get_shell_private(output); struct weston_view *view; kiosk_shell_output_recreate_background(shoutput); diff --git a/libweston/compositor.c b/libweston/compositor.c index 6ca1279dd..ef72bcd5e 100644 --- a/libweston/compositor.c +++ b/libweston/compositor.c @@ -8194,6 +8194,7 @@ weston_output_init(struct weston_output *output, { struct weston_color_manager *cm; + output->shell_private = NULL; output->pos.c = weston_coord(0, 0); output->compositor = compositor; output->destroying = 0; diff --git a/libweston/shell-utils/shell-utils.c b/libweston/shell-utils/shell-utils.c index 5587d44e9..23815c79e 100644 --- a/libweston/shell-utils/shell-utils.c +++ b/libweston/shell-utils/shell-utils.c @@ -261,3 +261,45 @@ weston_shell_utils_view_get_layer_position(struct weston_view *view) return view->layer_link.layer->position; } + +/** Assign shell private data to an output + * + * Shells will have their own private structures for output management. + * Some callbacks will provide a weston_output to the shell, and the + * shell will need to map that to its internal abstraction. Allow the + * shell to assign private data to an output to make this mapping easier. + * + * This can only be done once for an output. + * + * \param output The output to assign private data to + * \param private_data The shell private data + * + * \ingroup shell-utils + */ +WL_EXPORT void +weston_output_set_shell_private(struct weston_output *output, + void *private_data) +{ + assert(!output->shell_private); + + output->shell_private = private_data; +} + +/** Get private data for an output + * + * Allows the shell to retreive the private data it set for an output. + * The shell must have set private data previously, or an assert() is + * generated. + * + * \param output The output to get private data for + * \return The private data + * + * \ingroup shell-utils + */ +WL_EXPORT void * +weston_output_get_shell_private(struct weston_output *output) +{ + assert(output->shell_private); + + return output->shell_private; +}