From bf0c99f51986737c26e01c331b3e9d82ef099bd1 Mon Sep 17 00:00:00 2001 From: Marius Vlad Date: Mon, 29 Aug 2022 18:31:52 +0300 Subject: [PATCH] libweston/desktop, desktop-shell: Add getters for pending state This introduces a few getters to retrieve the pending state from libweston-desktop, now just libweston, and makes use of it, specifically get_pending_maximized to avoid sending invalid dimensions to the client in the particular use case set_maximized/unset_fullscreen. These pending state getters are useful to query/poke a not-applied yet state, and could be useful where we don't have a buffer attached where the client might be set-up as maximized, but internally libweston hasn't yet applied that pending state. Fixes #645 Suggested-by: Morgane Glidic Signed-off-by: Marius Vlad --- desktop-shell/shell.c | 3 ++- include/libweston/desktop.h | 8 +++++++ libweston/desktop/internal.h | 8 +++++++ libweston/desktop/surface.c | 36 ++++++++++++++++++++++++++++ libweston/desktop/xdg-shell-v6.c | 41 ++++++++++++++++++++++++++++++++ libweston/desktop/xdg-shell.c | 41 ++++++++++++++++++++++++++++++++ 6 files changed, 136 insertions(+), 1 deletion(-) diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c index 2ab7d72db..e9f740872 100644 --- a/desktop-shell/shell.c +++ b/desktop-shell/shell.c @@ -2177,7 +2177,8 @@ set_fullscreen(struct shell_surface *shsurf, bool fullscreen, } weston_desktop_surface_set_orientation(shsurf->desktop_surface, WESTON_TOP_LEVEL_TILED_ORIENTATION_NONE); - } else if (weston_desktop_surface_get_maximized(desktop_surface)) { + } else if (weston_desktop_surface_get_maximized(desktop_surface) || + weston_desktop_surface_get_pending_maximized(desktop_surface)) { get_maximized_size(shsurf, &width, &height); } weston_desktop_surface_set_fullscreen(desktop_surface, fullscreen); diff --git a/include/libweston/desktop.h b/include/libweston/desktop.h index 3536935b9..dd09c887c 100644 --- a/include/libweston/desktop.h +++ b/include/libweston/desktop.h @@ -201,6 +201,14 @@ weston_desktop_surface_get_maximized(struct weston_desktop_surface *surface); bool weston_desktop_surface_get_fullscreen(struct weston_desktop_surface *surface); bool +weston_desktop_surface_get_pending_resizing(struct weston_desktop_surface *surface); +bool +weston_desktop_surface_get_pending_activated(struct weston_desktop_surface *surface); +bool +weston_desktop_surface_get_pending_maximized(struct weston_desktop_surface *surface); +bool +weston_desktop_surface_get_pending_fullscreen(struct weston_desktop_surface *surface); +bool weston_desktop_surface_get_resizing(struct weston_desktop_surface *surface); struct weston_geometry weston_desktop_surface_get_geometry(struct weston_desktop_surface *surface); diff --git a/libweston/desktop/internal.h b/libweston/desktop/internal.h index 1d035d5c4..c6c93d4a9 100644 --- a/libweston/desktop/internal.h +++ b/libweston/desktop/internal.h @@ -123,6 +123,14 @@ struct weston_desktop_surface_implementation { void *user_data); bool (*get_resizing)(struct weston_desktop_surface *surface, void *user_data); + bool (*get_pending_activated)(struct weston_desktop_surface *surface, + void *user_data); + bool (*get_pending_fullscreen)(struct weston_desktop_surface *surface, + void *user_data); + bool (*get_pending_maximized)(struct weston_desktop_surface *surface, + void *user_data); + bool (*get_pending_resizing)(struct weston_desktop_surface *surface, + void *user_data); struct weston_size (*get_max_size)(struct weston_desktop_surface *surface, void *user_data); diff --git a/libweston/desktop/surface.c b/libweston/desktop/surface.c index 30b9cdcee..e76111f04 100644 --- a/libweston/desktop/surface.c +++ b/libweston/desktop/surface.c @@ -665,6 +665,42 @@ weston_desktop_surface_get_fullscreen(struct weston_desktop_surface *surface) surface->implementation_data); } +WL_EXPORT bool +weston_desktop_surface_get_pending_activated(struct weston_desktop_surface *surface) +{ + if (surface->implementation->get_pending_activated == NULL) + return false; + return surface->implementation->get_pending_activated(surface, + surface->implementation_data); +} + +WL_EXPORT bool +weston_desktop_surface_get_pending_resizing(struct weston_desktop_surface *surface) +{ + if (surface->implementation->get_pending_resizing == NULL) + return false; + return surface->implementation->get_pending_resizing(surface, + surface->implementation_data); +} + +WL_EXPORT bool +weston_desktop_surface_get_pending_maximized(struct weston_desktop_surface *surface) +{ + if (surface->implementation->get_pending_maximized == NULL) + return false; + return surface->implementation->get_pending_maximized(surface, + surface->implementation_data); +} + +WL_EXPORT bool +weston_desktop_surface_get_pending_fullscreen(struct weston_desktop_surface *surface) +{ + if (surface->implementation->get_pending_fullscreen == NULL) + return false; + return surface->implementation->get_pending_fullscreen(surface, + surface->implementation_data); +} + WL_EXPORT struct weston_geometry weston_desktop_surface_get_geometry(struct weston_desktop_surface *surface) { diff --git a/libweston/desktop/xdg-shell-v6.c b/libweston/desktop/xdg-shell-v6.c index 8aacc53ae..3cf6e8afa 100644 --- a/libweston/desktop/xdg-shell-v6.c +++ b/libweston/desktop/xdg-shell-v6.c @@ -720,6 +720,42 @@ weston_desktop_xdg_toplevel_get_activated(struct weston_desktop_surface *dsurfac return toplevel->current.state.activated; } +static bool +weston_desktop_xdg_toplevel_get_pending_maximized(struct weston_desktop_surface *dsurface, + void *user_data) +{ + struct weston_desktop_xdg_toplevel *toplevel = user_data; + + return toplevel->pending.state.maximized; +} + +static bool +weston_desktop_xdg_toplevel_get_pending_fullscreen(struct weston_desktop_surface *dsurface, + void *user_data) +{ + struct weston_desktop_xdg_toplevel *toplevel = user_data; + + return toplevel->pending.state.fullscreen; +} + +static bool +weston_desktop_xdg_toplevel_get_pending_resizing(struct weston_desktop_surface *dsurface, + void *user_data) +{ + struct weston_desktop_xdg_toplevel *toplevel = user_data; + + return toplevel->pending.state.resizing; +} + +static bool +weston_desktop_xdg_toplevel_get_pending_activated(struct weston_desktop_surface *dsurface, + void *user_data) +{ + struct weston_desktop_xdg_toplevel *toplevel = user_data; + + return toplevel->pending.state.activated; +} + static void weston_desktop_xdg_toplevel_destroy(struct weston_desktop_xdg_toplevel *toplevel) { @@ -1312,6 +1348,11 @@ static const struct weston_desktop_surface_implementation weston_desktop_xdg_sur .get_resizing = weston_desktop_xdg_toplevel_get_resizing, .get_activated = weston_desktop_xdg_toplevel_get_activated, + .get_pending_maximized = weston_desktop_xdg_toplevel_get_pending_maximized, + .get_pending_fullscreen = weston_desktop_xdg_toplevel_get_pending_fullscreen, + .get_pending_resizing = weston_desktop_xdg_toplevel_get_pending_resizing, + .get_pending_activated = weston_desktop_xdg_toplevel_get_pending_activated, + /* These are used for popup only */ .update_position = weston_desktop_xdg_popup_update_position, diff --git a/libweston/desktop/xdg-shell.c b/libweston/desktop/xdg-shell.c index 88b9f72bb..1bcbbaf7a 100644 --- a/libweston/desktop/xdg-shell.c +++ b/libweston/desktop/xdg-shell.c @@ -825,6 +825,42 @@ weston_desktop_xdg_toplevel_get_activated(struct weston_desktop_surface *dsurfac return toplevel->current.state.activated; } +static bool +weston_desktop_xdg_toplevel_get_pending_maximized(struct weston_desktop_surface *dsurface, + void *user_data) +{ + struct weston_desktop_xdg_toplevel *toplevel = user_data; + + return toplevel->pending.state.maximized; +} + +static bool +weston_desktop_xdg_toplevel_get_pending_fullscreen(struct weston_desktop_surface *dsurface, + void *user_data) +{ + struct weston_desktop_xdg_toplevel *toplevel = user_data; + + return toplevel->pending.state.fullscreen; +} + +static bool +weston_desktop_xdg_toplevel_get_pending_resizing(struct weston_desktop_surface *dsurface, + void *user_data) +{ + struct weston_desktop_xdg_toplevel *toplevel = user_data; + + return toplevel->pending.state.resizing; +} + +static bool +weston_desktop_xdg_toplevel_get_pending_activated(struct weston_desktop_surface *dsurface, + void *user_data) +{ + struct weston_desktop_xdg_toplevel *toplevel = user_data; + + return toplevel->pending.state.activated; +} + static void weston_desktop_xdg_toplevel_destroy(struct weston_desktop_xdg_toplevel *toplevel) { @@ -1523,6 +1559,11 @@ static const struct weston_desktop_surface_implementation weston_desktop_xdg_sur .get_resizing = weston_desktop_xdg_toplevel_get_resizing, .get_activated = weston_desktop_xdg_toplevel_get_activated, + .get_pending_maximized = weston_desktop_xdg_toplevel_get_pending_maximized, + .get_pending_fullscreen = weston_desktop_xdg_toplevel_get_pending_fullscreen, + .get_pending_resizing = weston_desktop_xdg_toplevel_get_pending_resizing, + .get_pending_activated = weston_desktop_xdg_toplevel_get_pending_activated, + /* These are used for popup only */ .update_position = weston_desktop_xdg_popup_update_position,