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 @@ -48,6 +48,30 @@ meta_wayland_window_configuration_new (int x, return configuration; } +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) { 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); + if (window->placement_rule) + { + MetaWindow *parent = meta_window_get_transient_for (window); + int rel_x, rel_y; - /* We need to wait until the resize completes before we can move */ + 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