summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Ã…dahl <jadahl@gmail.com>2020-02-13 22:20:15 +0100
committerCarlos Garnacho <mrgarnacho@gmail.com>2020-02-29 21:01:50 +0000
commitd22f947bf57a835b2ec243ee765c05835f687a80 (patch)
tree6c9e150d9071cc0d0274e8fd6abf7b7c59e30cb5
parent9b97e5ed583566d6e0a2a14acb18d2eb5c8d3ec4 (diff)
downloadmutter-d22f947bf57a835b2ec243ee765c05835f687a80.tar.gz
wayland/window: Pass popup configuration using relative coordinates
After popup placement rules have gone through the constraints engine has ended up resulting in an actual move, pass the window configuration down the path using relative coordinates, as that is what the next layer (xdg-shell implementation) actually cares about. In the future, this will also be helpful when the configured position is not against the current state of the parent. https://gitlab.gnome.org/GNOME/mutter/merge_requests/705
-rw-r--r--src/wayland/meta-wayland-legacy-xdg-shell.c4
-rw-r--r--src/wayland/meta-wayland-window-configuration.c24
-rw-r--r--src/wayland/meta-wayland-window-configuration.h10
-rw-r--r--src/wayland/meta-wayland-xdg-shell.c4
-rw-r--r--src/wayland/meta-window-wayland.c57
5 files changed, 75 insertions, 24 deletions
diff --git a/src/wayland/meta-wayland-legacy-xdg-shell.c b/src/wayland/meta-wayland-legacy-xdg-shell.c
index 35f3af95f..e438f2460 100644
--- a/src/wayland/meta-wayland-legacy-xdg-shell.c
+++ b/src/wayland/meta-wayland-legacy-xdg-shell.c
@@ -1037,8 +1037,8 @@ meta_wayland_zxdg_popup_v6_configure (MetaWaylandShellSurface *shell_surf
return;
geometry_scale = meta_window_wayland_get_geometry_scale (parent_window);
- x = (configuration->x - parent_window->rect.x) / geometry_scale;
- y = (configuration->y - parent_window->rect.y) / geometry_scale;
+ x = configuration->rel_x / geometry_scale;
+ y = configuration->rel_y / geometry_scale;
zxdg_popup_v6_send_configure (xdg_popup->resource,
x, y,
diff --git a/src/wayland/meta-wayland-window-configuration.c b/src/wayland/meta-wayland-window-configuration.c
index ca8b1125a..81a321dfe 100644
--- a/src/wayland/meta-wayland-window-configuration.c
+++ b/src/wayland/meta-wayland-window-configuration.c
@@ -49,6 +49,30 @@ meta_wayland_window_configuration_new (int x,
}
MetaWaylandWindowConfiguration *
+meta_wayland_window_configuration_new_relative (int rel_x,
+ int rel_y,
+ int width,
+ int height)
+{
+ MetaWaylandWindowConfiguration *configuration;
+
+ configuration = g_new0 (MetaWaylandWindowConfiguration, 1);
+ *configuration = (MetaWaylandWindowConfiguration) {
+ .serial = ++global_serial_counter,
+
+ .has_relative_position = TRUE,
+ .rel_x = rel_x,
+ .rel_y = rel_y,
+
+ .has_size = TRUE,
+ .width = width,
+ .height = height,
+ };
+
+ return configuration;
+}
+
+MetaWaylandWindowConfiguration *
meta_wayland_window_configuration_new_empty (void)
{
MetaWaylandWindowConfiguration *configuration;
diff --git a/src/wayland/meta-wayland-window-configuration.h b/src/wayland/meta-wayland-window-configuration.h
index 69f340c81..06e8b39d8 100644
--- a/src/wayland/meta-wayland-window-configuration.h
+++ b/src/wayland/meta-wayland-window-configuration.h
@@ -34,6 +34,10 @@ struct _MetaWaylandWindowConfiguration
int x;
int y;
+ gboolean has_relative_position;
+ int rel_x;
+ int rel_y;
+
gboolean has_size;
int width;
int height;
@@ -43,6 +47,12 @@ MetaWaylandWindowConfiguration * meta_wayland_window_configuration_new (int x,
int y,
int width,
int height);
+
+MetaWaylandWindowConfiguration * meta_wayland_window_configuration_new_relative (int rel_x,
+ int rel_y,
+ int width,
+ int height);
+
MetaWaylandWindowConfiguration * meta_wayland_window_configuration_new_empty (void);
void meta_wayland_window_configuration_free (MetaWaylandWindowConfiguration *configuration);
diff --git a/src/wayland/meta-wayland-xdg-shell.c b/src/wayland/meta-wayland-xdg-shell.c
index 63325110e..89e33d5d3 100644
--- a/src/wayland/meta-wayland-xdg-shell.c
+++ b/src/wayland/meta-wayland-xdg-shell.c
@@ -1145,8 +1145,8 @@ meta_wayland_xdg_popup_configure (MetaWaylandShellSurface *shell_surface,
return;
geometry_scale = meta_window_wayland_get_geometry_scale (parent_window);
- x = (configuration->x - parent_window->rect.x) / geometry_scale;
- y = (configuration->y - parent_window->rect.y) / geometry_scale;
+ x = configuration->rel_x / geometry_scale;
+ y = configuration->rel_y / geometry_scale;
xdg_popup_send_configure (xdg_popup->resource,
x, y,
configuration->width, configuration->height);
diff --git a/src/wayland/meta-window-wayland.c b/src/wayland/meta-window-wayland.c
index a83cd163c..910dd0e48 100644
--- a/src/wayland/meta-window-wayland.c
+++ b/src/wayland/meta-window-wayland.c
@@ -57,6 +57,8 @@ struct _MetaWindowWayland
int last_sent_y;
int last_sent_width;
int last_sent_height;
+ int last_sent_rel_x;
+ int last_sent_rel_y;
gboolean has_been_shown;
};
@@ -163,16 +165,10 @@ meta_window_wayland_focus (MetaWindow *window,
}
static void
-meta_window_wayland_configure (MetaWindowWayland *wl_window,
- int x,
- int y,
- int width,
- int height)
+meta_window_wayland_configure (MetaWindowWayland *wl_window,
+ MetaWaylandWindowConfiguration *configuration)
{
MetaWindow *window = META_WINDOW (wl_window);
- MetaWaylandWindowConfiguration *configuration;
-
- configuration = meta_wayland_window_configuration_new (x, y, width, height);
meta_wayland_surface_configure_notify (window->surface, configuration);
@@ -184,16 +180,19 @@ static void
surface_state_changed (MetaWindow *window)
{
MetaWindowWayland *wl_window = META_WINDOW_WAYLAND (window);
+ MetaWaylandWindowConfiguration *configuration;
/* don't send notify when the window is being unmanaged */
if (window->unmanaging)
return;
- meta_window_wayland_configure (wl_window,
- wl_window->last_sent_x,
- wl_window->last_sent_y,
- wl_window->last_sent_width,
- wl_window->last_sent_height);
+ configuration =
+ meta_wayland_window_configuration_new (wl_window->last_sent_x,
+ wl_window->last_sent_y,
+ wl_window->last_sent_width,
+ wl_window->last_sent_height);
+
+ meta_window_wayland_configure (wl_window, configuration);
}
static void
@@ -306,6 +305,8 @@ meta_window_wayland_move_resize_internal (MetaWindow *window,
constrained_rect.height != window->rect.height ||
(flags & META_MOVE_RESIZE_STATE_CHANGED))
{
+ MetaWaylandWindowConfiguration *configuration;
+
/* If the constrained size is 1x1 and the unconstrained size is 0x0
* it means that we are trying to resize a window where the client has
* not yet committed a buffer. The 1x1 constrained size is a result of
@@ -323,13 +324,29 @@ meta_window_wayland_move_resize_internal (MetaWindow *window,
constrained_rect.height == 1)
return;
- meta_window_wayland_configure (wl_window,
- configured_x,
- configured_y,
- configured_width,
- configured_height);
-
- /* We need to wait until the resize completes before we can move */
+ if (window->placement_rule)
+ {
+ MetaWindow *parent = meta_window_get_transient_for (window);
+ int rel_x, rel_y;
+
+ rel_x = configured_x - parent->rect.x;
+ rel_y = configured_y - parent->rect.y;
+ configuration =
+ meta_wayland_window_configuration_new_relative (rel_x,
+ rel_y,
+ configured_width,
+ configured_height);
+ }
+ else
+ {
+ configuration =
+ meta_wayland_window_configuration_new (configured_x,
+ configured_y,
+ configured_width,
+ configured_height);
+ }
+
+ meta_window_wayland_configure (wl_window, configuration);
can_move_now = FALSE;
}
else