wayland: Move MetaWindow ownership to window owning roles

There are two surface roles owning a MetaWindow: MetaWaylandShellSurface
(basis of MetaWaylandXdgToplevel, MetaWaylandXdgPopup,
MetaWaylandWlShellSurface, etc), and MetaXwaylandSurface.

With these two role types, the MetaWindow has two different types of
life times. With MetaWaylandShellSurface, the window is owned and
managed by the role itself, while with MetaXwaylandSurface, the
MetaWindow is tied to the X11 window, while the Wayland surface and its
role plays more the role of the backing rendering surface.

Before, for historical reasons, MetaWindow was part of
MetaWaylandSurface, even though just some roles used it, and before
'wayland: Untie MetaWindowXwayland lifetime from the wl_surface' had
equivalent life times as well. But since that commit, the management
changed. To not have the same fied in MetaWaylandSurface being managed
in such drastically different ways, rearrange it so that the roles that
has a MetaWindow themself manages it in the way it is meant to; meaning
MetaWaylandShellSurface practically owns it, while with Xwayland, the
existance of a MetaWindow is tracked via X11.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/835
This commit is contained in:
Jonas Ådahl
2019-10-09 09:57:40 +02:00
committed by Robert Mader
parent df642eb150
commit 44ae38599f
5 changed files with 265 additions and 127 deletions

View File

@ -223,6 +223,7 @@ enum
WORKSPACE_CHANGED,
FOCUS,
RAISED,
UNMANAGING,
UNMANAGED,
SIZE_CHANGED,
POSITION_CHANGED,
@ -649,6 +650,14 @@ meta_window_class_init (MetaWindowClass *klass)
NULL, NULL, NULL,
G_TYPE_NONE, 0);
window_signals[UNMANAGING] =
g_signal_new ("unmanaging",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
0,
NULL, NULL, NULL,
G_TYPE_NONE, 0);
window_signals[UNMANAGED] =
g_signal_new ("unmanaged",
G_TYPE_FROM_CLASS (object_class),
@ -1435,17 +1444,9 @@ meta_window_unmanage (MetaWindow *window,
g_clear_handle_id (&window->unmanage_idle_id, g_source_remove);
meta_window_free_delete_dialog (window);
g_signal_emit (window, window_signals[UNMANAGING], 0);
#ifdef HAVE_WAYLAND
/* This needs to happen for both Wayland and XWayland clients,
* so it can't be in MetaWindowWayland. */
if (window->surface)
{
meta_wayland_surface_set_window (window->surface, NULL);
window->surface = NULL;
}
#endif
meta_window_free_delete_dialog (window);
if (window->visible_to_compositor)
{