From 93b58c56486ea623d6146113463b01b5ea07f41e Mon Sep 17 00:00:00 2001 From: Derek Foreman Date: Mon, 6 Jun 2022 13:30:59 -0500 Subject: [PATCH] xwayland: Don't move window in response to geometry change if state changed When we leave fullscreen or maximized mode we restore a saved window position. This is expected, but that saved position was saved when window geometry was set to have shadows rendered. Since we restore a saved position that had shadow geometry, we don't want to move the window when we set geometry again, or we'll move away from the intended saved position. I guess this is a counter-proposal to !614 Fixes #454 Signed-off-by: Derek Foreman --- libweston-desktop/xwayland.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/libweston-desktop/xwayland.c b/libweston-desktop/xwayland.c index 057fdfd5..ae6a92e4 100644 --- a/libweston-desktop/xwayland.c +++ b/libweston-desktop/xwayland.c @@ -64,6 +64,7 @@ struct weston_desktop_xwayland_surface { bool committed; bool added; enum weston_desktop_xwayland_surface_state state; + enum weston_desktop_xwayland_surface_state prev_state; }; static void @@ -150,8 +151,16 @@ weston_desktop_xwayland_surface_committed(struct weston_desktop_surface *dsurfac if (surface->has_next_geometry) { oldgeom = weston_desktop_surface_get_geometry(surface->surface); - sx -= surface->next_geometry.x - oldgeom.x; - sy -= surface->next_geometry.y - oldgeom.y; + /* If we're transitioning away from fullscreen or maximized + * we've moved to old saved co-ordinates that were saved + * with window geometry in place, so avoid adajusting by + * the geometry in those cases. + */ + if (surface->state == surface->prev_state) { + sx -= surface->next_geometry.x - oldgeom.x; + sy -= surface->next_geometry.y - oldgeom.y; + } + surface->prev_state = surface->state; surface->has_next_geometry = false; weston_desktop_surface_set_geometry(surface->surface,