From 17f688735f3669a08585427341a9a2cf1cc3ea0d Mon Sep 17 00:00:00 2001 From: Brian Ashworth Date: Wed, 27 Mar 2019 01:54:05 -0400 Subject: [PATCH] wlr_xdg_toplevel_v6: store pending fullscreen output Since the fullscreen request may be made before the toplevel's surface is mapped, the requested fullscreen output needs to be stored so it can be retrieved on map (along with the existing fullscreen property). This commit makes the required changes for wlr_xdg_toplevel_v6. --- include/wlr/types/wlr_xdg_shell_v6.h | 6 +++++ types/xdg_shell_v6/wlr_xdg_toplevel_v6.c | 34 ++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/include/wlr/types/wlr_xdg_shell_v6.h b/include/wlr/types/wlr_xdg_shell_v6.h index b3ea72e0..2e3a5495 100644 --- a/include/wlr/types/wlr_xdg_shell_v6.h +++ b/include/wlr/types/wlr_xdg_shell_v6.h @@ -112,6 +112,12 @@ struct wlr_xdg_toplevel_v6_state { uint32_t width, height; uint32_t max_width, max_height; uint32_t min_width, min_height; + + // Since the fullscreen request may be made before the toplevel's surface + // is mapped, this is used to store the requested fullscreen output (if + // any) for wlr_xdg_toplevel_v6::client_pending. + struct wlr_output *fullscreen_output; + struct wl_listener fullscreen_output_destroy; }; /** diff --git a/types/xdg_shell_v6/wlr_xdg_toplevel_v6.c b/types/xdg_shell_v6/wlr_xdg_toplevel_v6.c index 297f49f5..a7a7d12b 100644 --- a/types/xdg_shell_v6/wlr_xdg_toplevel_v6.c +++ b/types/xdg_shell_v6/wlr_xdg_toplevel_v6.c @@ -19,6 +19,11 @@ void destroy_xdg_toplevel_v6(struct wlr_xdg_surface_v6 *surface) { assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL); unmap_xdg_surface_v6(surface); + if (surface->toplevel->client_pending.fullscreen_output) { + struct wlr_xdg_toplevel_v6_state *client_pending = + &surface->toplevel->client_pending; + wl_list_remove(&client_pending->fullscreen_output_destroy.link); + } wl_resource_set_user_data(surface->toplevel->resource, NULL); free(surface->toplevel); surface->toplevel = NULL; @@ -198,6 +203,31 @@ static void xdg_toplevel_handle_unset_maximized(struct wl_client *client, wlr_signal_emit_safe(&surface->toplevel->events.request_maximize, surface); } +static void handle_fullscreen_output_destroy(struct wl_listener *listener, + void *data) { + struct wlr_xdg_toplevel_v6_state *state = + wl_container_of(listener, state, fullscreen_output_destroy); + state->fullscreen_output = NULL; + wl_list_remove(&state->fullscreen_output_destroy.link); +} + +static void store_fullscreen_pending(struct wlr_xdg_surface_v6 *surface, + bool fullscreen, struct wlr_output *output) { + struct wlr_xdg_toplevel_v6_state *state = + &surface->toplevel->client_pending; + state->fullscreen = fullscreen; + if (state->fullscreen_output) { + wl_list_remove(&state->fullscreen_output_destroy.link); + } + state->fullscreen_output = output; + if (state->fullscreen_output) { + state->fullscreen_output_destroy.notify = + handle_fullscreen_output_destroy; + wl_signal_add(&state->fullscreen_output->events.destroy, + &state->fullscreen_output_destroy); + } +} + static void xdg_toplevel_handle_set_fullscreen(struct wl_client *client, struct wl_resource *resource, struct wl_resource *output_resource) { struct wlr_xdg_surface_v6 *surface = @@ -208,7 +238,7 @@ static void xdg_toplevel_handle_set_fullscreen(struct wl_client *client, output = wlr_output_from_resource(output_resource); } - surface->toplevel->client_pending.fullscreen = true; + store_fullscreen_pending(surface, true, output); struct wlr_xdg_toplevel_v6_set_fullscreen_event event = { .surface = surface, @@ -224,7 +254,7 @@ static void xdg_toplevel_handle_unset_fullscreen(struct wl_client *client, struct wlr_xdg_surface_v6 *surface = xdg_surface_from_xdg_toplevel_resource(resource); - surface->toplevel->client_pending.fullscreen = false; + store_fullscreen_pending(surface, false, NULL); struct wlr_xdg_toplevel_v6_set_fullscreen_event event = { .surface = surface,