1
0
Fork 0

wayland: Add XDG Shell glue to cater for already restored windows

Make the restored state prevail, instead of letting the client still
pick an initial size.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3825>
This commit is contained in:
Carlos Garnacho 2024-06-19 12:51:49 +02:00 committed by Marge Bot
parent 4a3eb2f992
commit 5c30483739
2 changed files with 44 additions and 7 deletions

View file

@ -113,6 +113,7 @@ struct _MetaWaylandXdgToplevel
gboolean has_max_size;
int max_width;
int max_height;
gboolean restored_from_session;
};
G_DEFINE_TYPE (MetaWaylandXdgToplevel,
@ -876,9 +877,7 @@ meta_wayland_xdg_toplevel_apply_state (MetaWaylandSurfaceRole *surface_role,
if (!xdg_surface_priv->configure_sent)
{
MetaWaylandWindowConfiguration *configuration;
int bounds_width;
int bounds_height;
int geometry_scale;
int bounds_width, bounds_height, geometry_scale;
geometry_scale = meta_window_wayland_get_geometry_scale (window);
@ -888,10 +887,25 @@ meta_wayland_xdg_toplevel_apply_state (MetaWaylandSurfaceRole *surface_role,
bounds_height = 0;
}
configuration =
meta_wayland_window_configuration_new_empty (bounds_width,
bounds_height,
geometry_scale);
if (xdg_toplevel->restored_from_session)
{
configuration =
meta_wayland_window_configuration_new (window,
window->rect,
bounds_width,
bounds_height,
geometry_scale,
META_MOVE_RESIZE_STATE_CHANGED,
META_GRAVITY_NONE);
}
else
{
configuration =
meta_wayland_window_configuration_new_empty (bounds_width,
bounds_height,
geometry_scale);
}
meta_wayland_xdg_toplevel_send_configure (xdg_toplevel, configuration);
meta_wayland_window_configuration_free (configuration);
return;
@ -927,7 +941,14 @@ meta_wayland_xdg_toplevel_post_apply_state (MetaWaylandSurfaceRole *surface_rol
META_WAYLAND_SURFACE_ROLE_CLASS (meta_wayland_xdg_toplevel_parent_class);
surface_role_class->post_apply_state (surface_role, pending);
if (xdg_toplevel->restored_from_session)
{
xdg_toplevel->restored_from_session = FALSE;
return;
}
window_geometry = meta_wayland_xdg_surface_get_window_geometry (xdg_surface);
geometry_changed = !mtk_rectangle_equal (&old_geometry, &window_geometry);
if (geometry_changed ||
@ -1126,6 +1147,18 @@ meta_wayland_xdg_toplevel_class_init (MetaWaylandXdgToplevelClass *klass)
xdg_surface_class->reset = meta_wayland_xdg_toplevel_reset;
}
struct wl_resource *
meta_wayland_xdg_toplevel_get_resource (MetaWaylandXdgToplevel *xdg_toplevel)
{
return xdg_toplevel->resource;
}
void
meta_wayland_xdg_toplevel_set_hint_restored (MetaWaylandXdgToplevel *xdg_toplevel)
{
xdg_toplevel->restored_from_session = TRUE;
}
static void
scale_placement_rule (MetaPlacementRule *placement_rule,
MetaWaylandSurface *surface)

View file

@ -46,3 +46,7 @@ G_DECLARE_FINAL_TYPE (MetaWaylandXdgPopup,
MetaWaylandXdgSurface);
void meta_wayland_xdg_shell_init (MetaWaylandCompositor *compositor);
struct wl_resource * meta_wayland_xdg_toplevel_get_resource (MetaWaylandXdgToplevel *xdg_toplevel);
void meta_wayland_xdg_toplevel_set_hint_restored (MetaWaylandXdgToplevel *xdg_toplevel);