From 8bdd2aa7dbb80594b37fa384cf6a4c1007e29852 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Wed, 7 Oct 2020 16:01:17 +0200 Subject: [PATCH] window/wayland: Offset position with size mismatch when resizing When we resize a window we send it configure requests with size suggestion. Some clients, e.g. gnome-terminal will limit its size to a discrete set given the font size resulting in the size often not being respected completely, but used as a hint to find a size as large as possible but not larger than the configured size. When doing an interactive resize dragging the right or top side of a window, this caused issues with the configured window size not matching the one used by the client, as the configured position wouldn't be correct for the actual size. Fix this by offsetting the position given the size mismatch offset, making the position again in sync with the size. Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1447 https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1477 --- src/wayland/meta-window-wayland.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/wayland/meta-window-wayland.c b/src/wayland/meta-window-wayland.c index a942dc9a3..9a33f73e0 100644 --- a/src/wayland/meta-window-wayland.c +++ b/src/wayland/meta-window-wayland.c @@ -956,8 +956,31 @@ meta_window_wayland_finish_move_resize (MetaWindow *window, { if (acked_configuration) { + int offset_x; + int offset_y; + rect.x = acked_configuration->x; rect.y = acked_configuration->y; + + offset_x = acked_configuration->width - new_geom.width; + offset_y = acked_configuration->height - new_geom.height; + switch (acked_configuration->gravity) + { + case META_GRAVITY_SOUTH: + case META_GRAVITY_SOUTH_WEST: + rect.y += offset_y; + break; + case META_GRAVITY_EAST: + case META_GRAVITY_NORTH_EAST: + rect.x += offset_x; + break; + case META_GRAVITY_SOUTH_EAST: + rect.x += offset_x; + rect.y += offset_y; + break; + default: + break; + } } }