wayland: Respect fixed size when resizing

If a window is configured with a fixed size (it's tiled, maximized, or
fullscreen), ignore any resize call that doesn't respect this. The set
size will instead be saved, when appropriate, so that the new size is
used when e.g. unmaximizing.

This makes it possible to call 'gtk_window_resize()' while the window is
maximized, without the window actually changing size until it's
unmaximized. Changing size to a non-maximized size is a violation of the
xdg-shell protocol.
This commit is contained in:
Jonas Ådahl
2020-04-02 16:41:21 +02:00
parent 7f12dc2b66
commit 04b7853a38

View File

@ -206,6 +206,9 @@ struct _GdkWindowImplWayland
int unconfigured_width; int unconfigured_width;
int unconfigured_height; int unconfigured_height;
int fixed_size_width;
int fixed_size_height;
gulong parent_surface_committed_handler; gulong parent_surface_committed_handler;
struct { struct {
@ -1511,6 +1514,14 @@ gdk_wayland_window_create_surface (GdkWindow *window)
wl_surface_add_listener (impl->display_server.wl_surface, &surface_listener, window); wl_surface_add_listener (impl->display_server.wl_surface, &surface_listener, window);
} }
static gboolean
should_use_fixed_size (GdkWindowState state)
{
return state & (GDK_WINDOW_STATE_MAXIMIZED |
GDK_WINDOW_STATE_FULLSCREEN |
GDK_WINDOW_STATE_TILED);
}
static void static void
gdk_wayland_window_handle_configure (GdkWindow *window, gdk_wayland_window_handle_configure (GdkWindow *window,
uint32_t serial) uint32_t serial)
@ -1545,10 +1556,7 @@ gdk_wayland_window_handle_configure (GdkWindow *window,
new_state = impl->pending.state; new_state = impl->pending.state;
impl->pending.state = 0; impl->pending.state = 0;
fixed_size = fixed_size = should_use_fixed_size (new_state);
new_state & (GDK_WINDOW_STATE_MAXIMIZED |
GDK_WINDOW_STATE_FULLSCREEN |
GDK_WINDOW_STATE_TILED);
saved_size = (width == 0 && height == 0); saved_size = (width == 0 && height == 0);
/* According to xdg_shell, an xdg_surface.configure with size 0x0 /* According to xdg_shell, an xdg_surface.configure with size 0x0
@ -1596,6 +1604,11 @@ gdk_wayland_window_handle_configure (GdkWindow *window,
impl->scale); impl->scale);
} }
if (fixed_size)
{
impl->fixed_size_width = width;
impl->fixed_size_height = height;
}
GDK_NOTE (EVENTS, GDK_NOTE (EVENTS,
g_message ("configure, window %p %dx%d,%s%s%s%s", g_message ("configure, window %p %dx%d,%s%s%s%s",
@ -3345,7 +3358,12 @@ gdk_window_wayland_move_resize (GdkWindow *window,
* just move the window - don't update its size * just move the window - don't update its size
*/ */
if (width > 0 && height > 0) if (width > 0 && height > 0)
gdk_wayland_window_maybe_configure (window, width, height, impl->scale); {
if (!should_use_fixed_size (window->state) ||
(width == impl->fixed_size_width &&
height == impl->fixed_size_height))
gdk_wayland_window_maybe_configure (window, width, height, impl->scale);
}
} }
/* Avoid zero width/height as this is a protocol error */ /* Avoid zero width/height as this is a protocol error */