window-wayland: Make sure to save where the position for server-initiated resizes

For the server-initiated resize case, like unmaximize or some forms
of tiling, we dropped the x/y of the server-assigned rectangle on the
floor, which meant the surface didn't move to where it needed to be in
that case. Now, save it internally, and combine it with the dx/dy passed
in during attaches to figure out where we actually need to be.

Make sure to only use it for when we send out a configure notify. We
should use the passed in rectangle for other scenarios, like a
client-initiated resize.

This fixes incorrect surface placement after unmaximization.
This commit is contained in:
Jasper St. Pierre 2014-04-28 16:19:06 -04:00
parent 647743aa5f
commit ce5c029509

View File

@ -34,6 +34,10 @@
struct _MetaWindowWayland
{
MetaWindow parent;
gboolean has_saved_pos;
int saved_x;
int saved_y;
};
struct _MetaWindowWaylandClass
@ -119,7 +123,9 @@ meta_window_wayland_move_resize_internal (MetaWindow *window,
MetaMoveResizeFlags flags,
MetaMoveResizeResultFlags *result)
{
MetaWindowWayland *wl_window = META_WINDOW_WAYLAND (window);
gboolean should_move = FALSE;
gboolean use_saved_pos = FALSE;
g_assert (window->frame == NULL);
@ -146,11 +152,16 @@ meta_window_wayland_move_resize_internal (MetaWindow *window,
/* This is a commit of an attach. We should move the window to match the
* new position the client wants. */
should_move = TRUE;
use_saved_pos = TRUE;
}
if (constrained_rect.width != window->rect.width ||
constrained_rect.height != window->rect.height)
{
wl_window->has_saved_pos = TRUE;
wl_window->saved_x = constrained_rect.x;
wl_window->saved_y = constrained_rect.y;
meta_wayland_surface_configure_notify (window->surface,
constrained_rect.width,
constrained_rect.height);
@ -164,8 +175,26 @@ meta_window_wayland_move_resize_internal (MetaWindow *window,
if (should_move)
{
int new_x = constrained_rect.x;
int new_y = constrained_rect.y;
int new_x, new_y;
if (use_saved_pos && wl_window->has_saved_pos)
{
int dx, dy;
/* The dx/dy that the client asked for. */
dx = requested_rect.x - window->rect.x;
dy = requested_rect.y - window->rect.y;
new_x = wl_window->saved_x + dx;
new_y = wl_window->saved_y + dy;
wl_window->has_saved_pos = FALSE;
}
else
{
new_x = constrained_rect.x;
new_y = constrained_rect.y;
}
if (new_x != window->rect.x || new_y != window->rect.y)
{