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 <sardemff7+git@sardemff7.net>
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
This commit is contained in:
Marius Vlad 2022-08-29 18:31:52 +03:00
parent 91750cdbd4
commit bf0c99f519
6 changed files with 136 additions and 1 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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)
{

View File

@ -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,

View File

@ -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,