From 213f0d8dd3aaa4fd24bd0eca228c5581ab7f4f9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Fri, 17 Dec 2021 16:31:48 +0100 Subject: [PATCH] window/wayland: Pass x,y,width,height as rectangle Will make the number of variables a bit more managable. Part-of: --- .../meta-wayland-window-configuration.c | 21 +++++------ .../meta-wayland-window-configuration.h | 5 +-- src/wayland/meta-window-wayland.c | 37 ++++++------------- 3 files changed, 21 insertions(+), 42 deletions(-) diff --git a/src/wayland/meta-wayland-window-configuration.c b/src/wayland/meta-wayland-window-configuration.c index 8349d2ac3..c1712136f 100644 --- a/src/wayland/meta-wayland-window-configuration.c +++ b/src/wayland/meta-wayland-window-configuration.c @@ -42,10 +42,7 @@ is_window_size_fixed (MetaWindow *window) MetaWaylandWindowConfiguration * meta_wayland_window_configuration_new (MetaWindow *window, - int x, - int y, - int width, - int height, + MetaRectangle rect, int scale, MetaMoveResizeFlags flags, MetaGravity gravity) @@ -62,22 +59,22 @@ meta_wayland_window_configuration_new (MetaWindow *window, }; if (flags & META_MOVE_RESIZE_MOVE_ACTION || - window->rect.x != x || - window->rect.y != y) + window->rect.x != rect.x || + window->rect.y != rect.y) { configuration->has_position = TRUE; - configuration->x = x; - configuration->y = y; + configuration->x = rect.x; + configuration->y = rect.y; } if (flags & META_MOVE_RESIZE_RESIZE_ACTION || is_window_size_fixed (window) || - window->rect.width != width || - window->rect.height != height) + window->rect.width != rect.width || + window->rect.height != rect.height) { configuration->has_size = TRUE; - configuration->width = width; - configuration->height = height; + configuration->width = rect.width; + configuration->height = rect.height; } return configuration; diff --git a/src/wayland/meta-wayland-window-configuration.h b/src/wayland/meta-wayland-window-configuration.h index b3211d1ad..7e91a778e 100644 --- a/src/wayland/meta-wayland-window-configuration.h +++ b/src/wayland/meta-wayland-window-configuration.h @@ -49,10 +49,7 @@ struct _MetaWaylandWindowConfiguration }; MetaWaylandWindowConfiguration * meta_wayland_window_configuration_new (MetaWindow *window, - int x, - int y, - int width, - int height, + MetaRectangle rect, int scale, MetaMoveResizeFlags flags, MetaGravity gravity); diff --git a/src/wayland/meta-window-wayland.c b/src/wayland/meta-window-wayland.c index fb7198e8b..8190a01b4 100644 --- a/src/wayland/meta-window-wayland.c +++ b/src/wayland/meta-window-wayland.c @@ -54,10 +54,7 @@ struct _MetaWindowWayland gboolean has_pending_state_change; gboolean has_last_sent_configuration; - int last_sent_x; - int last_sent_y; - int last_sent_width; - int last_sent_height; + MetaRectangle last_sent_rect; int last_sent_rel_x; int last_sent_rel_y; int last_sent_geometry_scale; @@ -193,10 +190,7 @@ surface_state_changed (MetaWindow *window) configuration = meta_wayland_window_configuration_new (window, - wl_window->last_sent_x, - wl_window->last_sent_y, - wl_window->last_sent_width, - wl_window->last_sent_height, + wl_window->last_sent_rect, wl_window->last_sent_geometry_scale, META_MOVE_RESIZE_STATE_CHANGED, wl_window->last_sent_gravity); @@ -237,10 +231,7 @@ meta_window_wayland_move_resize_internal (MetaWindow *window, { MetaWindowWayland *wl_window = META_WINDOW_WAYLAND (window); gboolean can_move_now = FALSE; - int configured_x; - int configured_y; - int configured_width; - int configured_height; + MetaRectangle configured_rect; int geometry_scale; int new_x; int new_y; @@ -253,8 +244,8 @@ meta_window_wayland_move_resize_internal (MetaWindow *window, if (window->unmanaging) return; - configured_x = constrained_rect.x; - configured_y = constrained_rect.y; + configured_rect.x = constrained_rect.x; + configured_rect.y = constrained_rect.y; /* 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 @@ -262,8 +253,8 @@ meta_window_wayland_move_resize_internal (MetaWindow *window, * to the Wayland surface. */ geometry_scale = meta_window_wayland_get_geometry_scale (window); - configured_width = constrained_rect.width; - configured_height = constrained_rect.height; + configured_rect.width = constrained_rect.width; + configured_rect.height = constrained_rect.height; /* For wayland clients, the size is completely determined by the client, * 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 = meta_wayland_window_configuration_new_relative (rel_x, rel_y, - configured_width, - configured_height, + configured_rect.width, + configured_rect.height, geometry_scale); meta_window_wayland_configure (wl_window, configuration); @@ -363,10 +354,7 @@ meta_window_wayland_move_resize_internal (MetaWindow *window, configuration = meta_wayland_window_configuration_new (window, - configured_x, - configured_y, - configured_width, - configured_height, + configured_rect, geometry_scale, flags, gravity); @@ -380,10 +368,7 @@ meta_window_wayland_move_resize_internal (MetaWindow *window, } wl_window->has_last_sent_configuration = TRUE; - wl_window->last_sent_x = configured_x; - 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_rect = configured_rect; wl_window->last_sent_geometry_scale = geometry_scale; wl_window->last_sent_gravity = gravity;