window/wayland: Pass x,y,width,height as rectangle

Will make the number of variables a bit more managable.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2167>
This commit is contained in:
Jonas Ådahl 2021-12-17 16:31:48 +01:00 committed by Marge Bot
parent e736b04deb
commit 213f0d8dd3
3 changed files with 21 additions and 42 deletions

View File

@ -42,10 +42,7 @@ is_window_size_fixed (MetaWindow *window)
MetaWaylandWindowConfiguration * MetaWaylandWindowConfiguration *
meta_wayland_window_configuration_new (MetaWindow *window, meta_wayland_window_configuration_new (MetaWindow *window,
int x, MetaRectangle rect,
int y,
int width,
int height,
int scale, int scale,
MetaMoveResizeFlags flags, MetaMoveResizeFlags flags,
MetaGravity gravity) MetaGravity gravity)
@ -62,22 +59,22 @@ meta_wayland_window_configuration_new (MetaWindow *window,
}; };
if (flags & META_MOVE_RESIZE_MOVE_ACTION || if (flags & META_MOVE_RESIZE_MOVE_ACTION ||
window->rect.x != x || window->rect.x != rect.x ||
window->rect.y != y) window->rect.y != rect.y)
{ {
configuration->has_position = TRUE; configuration->has_position = TRUE;
configuration->x = x; configuration->x = rect.x;
configuration->y = y; configuration->y = rect.y;
} }
if (flags & META_MOVE_RESIZE_RESIZE_ACTION || if (flags & META_MOVE_RESIZE_RESIZE_ACTION ||
is_window_size_fixed (window) || is_window_size_fixed (window) ||
window->rect.width != width || window->rect.width != rect.width ||
window->rect.height != height) window->rect.height != rect.height)
{ {
configuration->has_size = TRUE; configuration->has_size = TRUE;
configuration->width = width; configuration->width = rect.width;
configuration->height = height; configuration->height = rect.height;
} }
return configuration; return configuration;

View File

@ -49,10 +49,7 @@ struct _MetaWaylandWindowConfiguration
}; };
MetaWaylandWindowConfiguration * meta_wayland_window_configuration_new (MetaWindow *window, MetaWaylandWindowConfiguration * meta_wayland_window_configuration_new (MetaWindow *window,
int x, MetaRectangle rect,
int y,
int width,
int height,
int scale, int scale,
MetaMoveResizeFlags flags, MetaMoveResizeFlags flags,
MetaGravity gravity); MetaGravity gravity);

View File

@ -54,10 +54,7 @@ struct _MetaWindowWayland
gboolean has_pending_state_change; gboolean has_pending_state_change;
gboolean has_last_sent_configuration; gboolean has_last_sent_configuration;
int last_sent_x; MetaRectangle last_sent_rect;
int last_sent_y;
int last_sent_width;
int last_sent_height;
int last_sent_rel_x; int last_sent_rel_x;
int last_sent_rel_y; int last_sent_rel_y;
int last_sent_geometry_scale; int last_sent_geometry_scale;
@ -193,10 +190,7 @@ surface_state_changed (MetaWindow *window)
configuration = configuration =
meta_wayland_window_configuration_new (window, meta_wayland_window_configuration_new (window,
wl_window->last_sent_x, wl_window->last_sent_rect,
wl_window->last_sent_y,
wl_window->last_sent_width,
wl_window->last_sent_height,
wl_window->last_sent_geometry_scale, wl_window->last_sent_geometry_scale,
META_MOVE_RESIZE_STATE_CHANGED, META_MOVE_RESIZE_STATE_CHANGED,
wl_window->last_sent_gravity); wl_window->last_sent_gravity);
@ -237,10 +231,7 @@ meta_window_wayland_move_resize_internal (MetaWindow *window,
{ {
MetaWindowWayland *wl_window = META_WINDOW_WAYLAND (window); MetaWindowWayland *wl_window = META_WINDOW_WAYLAND (window);
gboolean can_move_now = FALSE; gboolean can_move_now = FALSE;
int configured_x; MetaRectangle configured_rect;
int configured_y;
int configured_width;
int configured_height;
int geometry_scale; int geometry_scale;
int new_x; int new_x;
int new_y; int new_y;
@ -253,8 +244,8 @@ meta_window_wayland_move_resize_internal (MetaWindow *window,
if (window->unmanaging) if (window->unmanaging)
return; return;
configured_x = constrained_rect.x; configured_rect.x = constrained_rect.x;
configured_y = constrained_rect.y; configured_rect.y = constrained_rect.y;
/* The scale the window is drawn in might change depending on what monitor it /* The scale the window is drawn in might change depending on what monitor it
* is mainly on. Scale the configured rectangle to be in logical pixel * is mainly on. Scale the configured rectangle to be in logical pixel
@ -262,8 +253,8 @@ meta_window_wayland_move_resize_internal (MetaWindow *window,
* to the Wayland surface. */ * to the Wayland surface. */
geometry_scale = meta_window_wayland_get_geometry_scale (window); geometry_scale = meta_window_wayland_get_geometry_scale (window);
configured_width = constrained_rect.width; configured_rect.width = constrained_rect.width;
configured_height = constrained_rect.height; configured_rect.height = constrained_rect.height;
/* For wayland clients, the size is completely determined by the client, /* For wayland clients, the size is completely determined by the client,
* and while this allows to avoid some trickery with frames and the resulting * and while this allows to avoid some trickery with frames and the resulting
@ -323,8 +314,8 @@ meta_window_wayland_move_resize_internal (MetaWindow *window,
configuration = configuration =
meta_wayland_window_configuration_new_relative (rel_x, meta_wayland_window_configuration_new_relative (rel_x,
rel_y, rel_y,
configured_width, configured_rect.width,
configured_height, configured_rect.height,
geometry_scale); geometry_scale);
meta_window_wayland_configure (wl_window, configuration); meta_window_wayland_configure (wl_window, configuration);
@ -363,10 +354,7 @@ meta_window_wayland_move_resize_internal (MetaWindow *window,
configuration = configuration =
meta_wayland_window_configuration_new (window, meta_wayland_window_configuration_new (window,
configured_x, configured_rect,
configured_y,
configured_width,
configured_height,
geometry_scale, geometry_scale,
flags, flags,
gravity); gravity);
@ -380,10 +368,7 @@ meta_window_wayland_move_resize_internal (MetaWindow *window,
} }
wl_window->has_last_sent_configuration = TRUE; wl_window->has_last_sent_configuration = TRUE;
wl_window->last_sent_x = configured_x; wl_window->last_sent_rect = configured_rect;
wl_window->last_sent_y = configured_y;
wl_window->last_sent_width = configured_width;
wl_window->last_sent_height = configured_height;
wl_window->last_sent_geometry_scale = geometry_scale; wl_window->last_sent_geometry_scale = geometry_scale;
wl_window->last_sent_gravity = gravity; wl_window->last_sent_gravity = gravity;