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
This commit is contained in:
Jonas Ådahl 2020-02-13 22:20:15 +01:00 committed by Carlos Garnacho
parent 9b97e5ed58
commit d22f947bf5
5 changed files with 74 additions and 23 deletions

View File

@ -1037,8 +1037,8 @@ meta_wayland_zxdg_popup_v6_configure (MetaWaylandShellSurface *shell_surf
return; return;
geometry_scale = meta_window_wayland_get_geometry_scale (parent_window); geometry_scale = meta_window_wayland_get_geometry_scale (parent_window);
x = (configuration->x - parent_window->rect.x) / geometry_scale; x = configuration->rel_x / geometry_scale;
y = (configuration->y - parent_window->rect.y) / geometry_scale; y = configuration->rel_y / geometry_scale;
zxdg_popup_v6_send_configure (xdg_popup->resource, zxdg_popup_v6_send_configure (xdg_popup->resource,
x, y, x, y,

View File

@ -48,6 +48,30 @@ meta_wayland_window_configuration_new (int x,
return configuration; 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 * MetaWaylandWindowConfiguration *
meta_wayland_window_configuration_new_empty (void) meta_wayland_window_configuration_new_empty (void)
{ {

View File

@ -34,6 +34,10 @@ struct _MetaWaylandWindowConfiguration
int x; int x;
int y; int y;
gboolean has_relative_position;
int rel_x;
int rel_y;
gboolean has_size; gboolean has_size;
int width; int width;
int height; int height;
@ -43,6 +47,12 @@ MetaWaylandWindowConfiguration * meta_wayland_window_configuration_new (int x,
int y, int y,
int width, int width,
int height); 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); MetaWaylandWindowConfiguration * meta_wayland_window_configuration_new_empty (void);
void meta_wayland_window_configuration_free (MetaWaylandWindowConfiguration *configuration); void meta_wayland_window_configuration_free (MetaWaylandWindowConfiguration *configuration);

View File

@ -1145,8 +1145,8 @@ meta_wayland_xdg_popup_configure (MetaWaylandShellSurface *shell_surface,
return; return;
geometry_scale = meta_window_wayland_get_geometry_scale (parent_window); geometry_scale = meta_window_wayland_get_geometry_scale (parent_window);
x = (configuration->x - parent_window->rect.x) / geometry_scale; x = configuration->rel_x / geometry_scale;
y = (configuration->y - parent_window->rect.y) / geometry_scale; y = configuration->rel_y / geometry_scale;
xdg_popup_send_configure (xdg_popup->resource, xdg_popup_send_configure (xdg_popup->resource,
x, y, x, y,
configuration->width, configuration->height); configuration->width, configuration->height);

View File

@ -57,6 +57,8 @@ struct _MetaWindowWayland
int last_sent_y; int last_sent_y;
int last_sent_width; int last_sent_width;
int last_sent_height; int last_sent_height;
int last_sent_rel_x;
int last_sent_rel_y;
gboolean has_been_shown; gboolean has_been_shown;
}; };
@ -163,16 +165,10 @@ meta_window_wayland_focus (MetaWindow *window,
} }
static void static void
meta_window_wayland_configure (MetaWindowWayland *wl_window, meta_window_wayland_configure (MetaWindowWayland *wl_window,
int x, MetaWaylandWindowConfiguration *configuration)
int y,
int width,
int height)
{ {
MetaWindow *window = META_WINDOW (wl_window); 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); meta_wayland_surface_configure_notify (window->surface, configuration);
@ -184,16 +180,19 @@ static void
surface_state_changed (MetaWindow *window) surface_state_changed (MetaWindow *window)
{ {
MetaWindowWayland *wl_window = META_WINDOW_WAYLAND (window); MetaWindowWayland *wl_window = META_WINDOW_WAYLAND (window);
MetaWaylandWindowConfiguration *configuration;
/* don't send notify when the window is being unmanaged */ /* don't send notify when the window is being unmanaged */
if (window->unmanaging) if (window->unmanaging)
return; return;
meta_window_wayland_configure (wl_window, configuration =
wl_window->last_sent_x, meta_wayland_window_configuration_new (wl_window->last_sent_x,
wl_window->last_sent_y, wl_window->last_sent_y,
wl_window->last_sent_width, wl_window->last_sent_width,
wl_window->last_sent_height); wl_window->last_sent_height);
meta_window_wayland_configure (wl_window, configuration);
} }
static void static void
@ -306,6 +305,8 @@ meta_window_wayland_move_resize_internal (MetaWindow *window,
constrained_rect.height != window->rect.height || constrained_rect.height != window->rect.height ||
(flags & META_MOVE_RESIZE_STATE_CHANGED)) (flags & META_MOVE_RESIZE_STATE_CHANGED))
{ {
MetaWaylandWindowConfiguration *configuration;
/* If the constrained size is 1x1 and the unconstrained size is 0x0 /* 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 * 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 * 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) constrained_rect.height == 1)
return; return;
meta_window_wayland_configure (wl_window, if (window->placement_rule)
configured_x, {
configured_y, MetaWindow *parent = meta_window_get_transient_for (window);
configured_width, int rel_x, rel_y;
configured_height);
/* 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; can_move_now = FALSE;
} }
else else