mirror of
https://github.com/brl/mutter.git
synced 2025-02-16 13:24:09 +00:00
wayland/window: Don't lose precision in MetaWaylandWindowConfiguration
Commit 8bdd2aa7 would offset the window position by the difference between the configured window size and the committed size from the client to prevent the window from drifting while resizing. This, however, did not take into account the actual geometry scale, so when using any scale greater than 1, the window would rapidly drift away due to that offset. In order to solve this, we need to make sure we store away the pending window configuration in the stage coordinate space, in order to not loose precision. When we then calculate the offset given the result from the client, it'll use the right scalars, while before, one scalar was in surface coordinates, while the other in stage coordinates. https://gitlab.gnome.org/GNOME/mutter/-/issues/1490
This commit is contained in:
parent
514b2ff424
commit
eaa6efef56
@ -609,8 +609,8 @@ meta_wayland_zxdg_toplevel_v6_send_configure (MetaWaylandZxdgToplevelV6 *xd
|
|||||||
fill_states (&states, window);
|
fill_states (&states, window);
|
||||||
|
|
||||||
zxdg_toplevel_v6_send_configure (xdg_toplevel->resource,
|
zxdg_toplevel_v6_send_configure (xdg_toplevel->resource,
|
||||||
configuration->width,
|
configuration->width / configuration->scale,
|
||||||
configuration->height,
|
configuration->height / configuration->scale,
|
||||||
&states);
|
&states);
|
||||||
wl_array_release (&states);
|
wl_array_release (&states);
|
||||||
|
|
||||||
@ -1075,7 +1075,8 @@ meta_wayland_zxdg_popup_v6_configure (MetaWaylandShellSurface *shell_surf
|
|||||||
|
|
||||||
zxdg_popup_v6_send_configure (xdg_popup->resource,
|
zxdg_popup_v6_send_configure (xdg_popup->resource,
|
||||||
x, y,
|
x, y,
|
||||||
configuration->width, configuration->height);
|
configuration->width / configuration->scale,
|
||||||
|
configuration->height / configuration->scale);
|
||||||
meta_wayland_zxdg_surface_v6_send_configure (xdg_surface, configuration);
|
meta_wayland_zxdg_surface_v6_send_configure (xdg_surface, configuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ meta_wayland_window_configuration_new (int x,
|
|||||||
int y,
|
int y,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
|
int scale,
|
||||||
MetaMoveResizeFlags flags,
|
MetaMoveResizeFlags flags,
|
||||||
MetaGravity gravity)
|
MetaGravity gravity)
|
||||||
{
|
{
|
||||||
@ -46,6 +47,7 @@ meta_wayland_window_configuration_new (int x,
|
|||||||
.width = width,
|
.width = width,
|
||||||
.height = height,
|
.height = height,
|
||||||
|
|
||||||
|
.scale = scale,
|
||||||
.gravity = gravity,
|
.gravity = gravity,
|
||||||
.flags = flags,
|
.flags = flags,
|
||||||
};
|
};
|
||||||
@ -57,7 +59,8 @@ MetaWaylandWindowConfiguration *
|
|||||||
meta_wayland_window_configuration_new_relative (int rel_x,
|
meta_wayland_window_configuration_new_relative (int rel_x,
|
||||||
int rel_y,
|
int rel_y,
|
||||||
int width,
|
int width,
|
||||||
int height)
|
int height,
|
||||||
|
int scale)
|
||||||
{
|
{
|
||||||
MetaWaylandWindowConfiguration *configuration;
|
MetaWaylandWindowConfiguration *configuration;
|
||||||
|
|
||||||
@ -72,6 +75,8 @@ meta_wayland_window_configuration_new_relative (int rel_x,
|
|||||||
.has_size = TRUE,
|
.has_size = TRUE,
|
||||||
.width = width,
|
.width = width,
|
||||||
.height = height,
|
.height = height,
|
||||||
|
|
||||||
|
.scale = scale,
|
||||||
};
|
};
|
||||||
|
|
||||||
return configuration;
|
return configuration;
|
||||||
@ -85,6 +90,7 @@ meta_wayland_window_configuration_new_empty (void)
|
|||||||
configuration = g_new0 (MetaWaylandWindowConfiguration, 1);
|
configuration = g_new0 (MetaWaylandWindowConfiguration, 1);
|
||||||
*configuration = (MetaWaylandWindowConfiguration) {
|
*configuration = (MetaWaylandWindowConfiguration) {
|
||||||
.serial = ++global_serial_counter,
|
.serial = ++global_serial_counter,
|
||||||
|
.scale = 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
return configuration;
|
return configuration;
|
||||||
|
@ -43,6 +43,7 @@ struct _MetaWaylandWindowConfiguration
|
|||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
|
|
||||||
|
int scale;
|
||||||
MetaGravity gravity;
|
MetaGravity gravity;
|
||||||
MetaMoveResizeFlags flags;
|
MetaMoveResizeFlags flags;
|
||||||
};
|
};
|
||||||
@ -51,13 +52,15 @@ MetaWaylandWindowConfiguration * meta_wayland_window_configuration_new (int
|
|||||||
int y,
|
int y,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
|
int scale,
|
||||||
MetaMoveResizeFlags flags,
|
MetaMoveResizeFlags flags,
|
||||||
MetaGravity gravity);
|
MetaGravity gravity);
|
||||||
|
|
||||||
MetaWaylandWindowConfiguration * meta_wayland_window_configuration_new_relative (int rel_x,
|
MetaWaylandWindowConfiguration * meta_wayland_window_configuration_new_relative (int rel_x,
|
||||||
int rel_y,
|
int rel_y,
|
||||||
int width,
|
int width,
|
||||||
int height);
|
int height,
|
||||||
|
int scale);
|
||||||
|
|
||||||
MetaWaylandWindowConfiguration * meta_wayland_window_configuration_new_empty (void);
|
MetaWaylandWindowConfiguration * meta_wayland_window_configuration_new_empty (void);
|
||||||
|
|
||||||
|
@ -657,7 +657,8 @@ wl_shell_surface_role_configure (MetaWaylandShellSurface *shell_surface,
|
|||||||
|
|
||||||
wl_shell_surface_send_configure (wl_shell_surface->resource,
|
wl_shell_surface_send_configure (wl_shell_surface->resource,
|
||||||
0,
|
0,
|
||||||
configuration->width, configuration->height);
|
configuration->width / configuration->scale,
|
||||||
|
configuration->height / configuration->scale);
|
||||||
|
|
||||||
wl_shell_surface->emulated_ack_configure_serial = configuration->serial;
|
wl_shell_surface->emulated_ack_configure_serial = configuration->serial;
|
||||||
}
|
}
|
||||||
|
@ -700,8 +700,8 @@ meta_wayland_xdg_toplevel_send_configure (MetaWaylandXdgToplevel *xdg_to
|
|||||||
fill_states (xdg_toplevel, &states);
|
fill_states (xdg_toplevel, &states);
|
||||||
|
|
||||||
xdg_toplevel_send_configure (xdg_toplevel->resource,
|
xdg_toplevel_send_configure (xdg_toplevel->resource,
|
||||||
configuration->width,
|
configuration->width / configuration->scale,
|
||||||
configuration->height,
|
configuration->height / configuration->scale,
|
||||||
&states);
|
&states);
|
||||||
wl_array_release (&states);
|
wl_array_release (&states);
|
||||||
|
|
||||||
@ -1250,7 +1250,8 @@ meta_wayland_xdg_popup_configure (MetaWaylandShellSurface *shell_surface,
|
|||||||
}
|
}
|
||||||
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->scale,
|
||||||
|
configuration->height / configuration->scale);
|
||||||
|
|
||||||
meta_wayland_xdg_surface_send_configure (xdg_surface, configuration);
|
meta_wayland_xdg_surface_send_configure (xdg_surface, configuration);
|
||||||
}
|
}
|
||||||
@ -2046,8 +2047,10 @@ meta_wayland_xdg_positioner_to_placement (MetaWaylandXdgPositioner *xdg_position
|
|||||||
}
|
}
|
||||||
if (configuration->has_size)
|
if (configuration->has_size)
|
||||||
{
|
{
|
||||||
parent_rect.width = configuration->width;
|
parent_rect.width =
|
||||||
parent_rect.height = configuration->height;
|
configuration->width / configuration->scale;
|
||||||
|
parent_rect.height =
|
||||||
|
configuration->height / configuration->scale;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (xdg_positioner->has_parent_size)
|
else if (xdg_positioner->has_parent_size)
|
||||||
|
@ -59,6 +59,7 @@ struct _MetaWindowWayland
|
|||||||
int last_sent_height;
|
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;
|
||||||
MetaGravity last_sent_gravity;
|
MetaGravity last_sent_gravity;
|
||||||
|
|
||||||
gboolean has_been_shown;
|
gboolean has_been_shown;
|
||||||
@ -192,6 +193,7 @@ surface_state_changed (MetaWindow *window)
|
|||||||
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,
|
||||||
|
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);
|
||||||
|
|
||||||
@ -256,8 +258,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 / geometry_scale;
|
configured_width = constrained_rect.width;
|
||||||
configured_height = constrained_rect.height / geometry_scale;
|
configured_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
|
||||||
@ -318,7 +320,8 @@ meta_window_wayland_move_resize_internal (MetaWindow *window,
|
|||||||
meta_wayland_window_configuration_new_relative (rel_x,
|
meta_wayland_window_configuration_new_relative (rel_x,
|
||||||
rel_y,
|
rel_y,
|
||||||
configured_width,
|
configured_width,
|
||||||
configured_height);
|
configured_height,
|
||||||
|
geometry_scale);
|
||||||
meta_window_wayland_configure (wl_window, configuration);
|
meta_window_wayland_configure (wl_window, configuration);
|
||||||
|
|
||||||
wl_window->last_sent_rel_x = rel_x;
|
wl_window->last_sent_rel_x = rel_x;
|
||||||
@ -370,6 +373,7 @@ meta_window_wayland_move_resize_internal (MetaWindow *window,
|
|||||||
configured_y,
|
configured_y,
|
||||||
configured_width,
|
configured_width,
|
||||||
configured_height,
|
configured_height,
|
||||||
|
geometry_scale,
|
||||||
flags,
|
flags,
|
||||||
gravity);
|
gravity);
|
||||||
meta_window_wayland_configure (wl_window, configuration);
|
meta_window_wayland_configure (wl_window, configuration);
|
||||||
@ -385,6 +389,7 @@ meta_window_wayland_move_resize_internal (MetaWindow *window,
|
|||||||
wl_window->last_sent_y = configured_y;
|
wl_window->last_sent_y = configured_y;
|
||||||
wl_window->last_sent_width = configured_width;
|
wl_window->last_sent_width = configured_width;
|
||||||
wl_window->last_sent_height = configured_height;
|
wl_window->last_sent_height = configured_height;
|
||||||
|
wl_window->last_sent_geometry_scale = geometry_scale;
|
||||||
wl_window->last_sent_gravity = gravity;
|
wl_window->last_sent_gravity = gravity;
|
||||||
|
|
||||||
if (can_move_now)
|
if (can_move_now)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user