wayland: Untie MetaWindowXwayland lifetime from the wl_surface

For the most part, a MetaWindow is expected to live roughly as long as
the associated wl_surface, give or take asynchronous API discrepancies.

The exception to this rule is handling of reparenting when decorating or
undecorating a window, when a MetaWindow on X11 is made to survive the
unmap/map cycle. The fact that this didn't hold on Wayland caused
various issues, such as a feedback loop where the X11 window kept being
remapped. By making the MetaWindow lifetime for Xwayland windows being
the same as they are on plain X11, we remove the different semantics
here, which seem to lower the risk of hitting the race condition causing
the feedback loop mentioned above.

What this commit do is separate MetaWindow lifetime handling between
native Wayland windows and Xwayland windows. Wayland windows are handled
just as they were, i.e. unmanaged together as part of the wl_surface
destruction; while during the Xwayland wl_surface destruction, the
MetaWindow <-> MetaWaylandSurface association is simply broken.

Related: https://gitlab.freedesktop.org/xorg/xserver/issues/740
Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/762

https://gitlab.gnome.org/GNOME/mutter/merge_requests/774
This commit is contained in:
Jonas Ådahl
2019-09-04 18:35:08 +02:00
parent 2c388e2155
commit b5f50028f2
8 changed files with 85 additions and 51 deletions

View File

@ -212,6 +212,37 @@ meta_wayland_shell_surface_sync_actor_state (MetaWaylandActorSurface *actor_surf
actor_surface_class->sync_actor_state (actor_surface);
}
void
meta_wayland_shell_surface_destroy_window (MetaWaylandShellSurface *shell_surface)
{
MetaWaylandSurfaceRole *surface_role =
META_WAYLAND_SURFACE_ROLE (shell_surface);
MetaWaylandSurface *surface =
meta_wayland_surface_role_get_surface (surface_role);
MetaWindow *window;
MetaDisplay *display;
uint32_t timestamp;
window = surface->window;
if (!window)
return;
display = meta_window_get_display (window);
timestamp = meta_display_get_current_time_roundtrip (display);
meta_window_unmanage (surface->window, timestamp);
g_assert (!surface->window);
}
static void
meta_wayland_shell_surface_finalize (GObject *object)
{
MetaWaylandShellSurface *shell_surface = META_WAYLAND_SHELL_SURFACE (object);
meta_wayland_shell_surface_destroy_window (shell_surface);
G_OBJECT_CLASS (meta_wayland_shell_surface_parent_class)->finalize (object);
}
static void
meta_wayland_shell_surface_init (MetaWaylandShellSurface *role)
{
@ -220,11 +251,14 @@ meta_wayland_shell_surface_init (MetaWaylandShellSurface *role)
static void
meta_wayland_shell_surface_class_init (MetaWaylandShellSurfaceClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
MetaWaylandSurfaceRoleClass *surface_role_class =
META_WAYLAND_SURFACE_ROLE_CLASS (klass);
MetaWaylandActorSurfaceClass *actor_surface_class =
META_WAYLAND_ACTOR_SURFACE_CLASS (klass);
object_class->finalize = meta_wayland_shell_surface_finalize;
surface_role_class->commit = meta_wayland_shell_surface_surface_commit;
actor_surface_class->get_geometry_scale =