summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2019-05-24 21:09:32 +0200
committerCarlos Garnacho <mrgarnacho@gmail.com>2019-08-06 00:41:36 +0000
commitf5a2694eba8244a1acaeb39a8b11e5dcb6e6d981 (patch)
treed0afb876ce12d74b0a084719c00352759784b082
parent319f7f5b63633a94da9e9c53f9a0d6d804213fc1 (diff)
downloadmutter-f5a2694eba8244a1acaeb39a8b11e5dcb6e6d981.tar.gz
wayland: Add tracking of X11 windows
This is unused ATM, but will be used to check whether it is safe to shut Xwayland down. https://gitlab.gnome.org/GNOME/mutter/merge_requests/709
-rw-r--r--src/wayland/meta-wayland-private.h2
-rw-r--r--src/wayland/meta-xwayland.c36
2 files changed, 38 insertions, 0 deletions
diff --git a/src/wayland/meta-wayland-private.h b/src/wayland/meta-wayland-private.h
index 594088535..6acbafc1f 100644
--- a/src/wayland/meta-wayland-private.h
+++ b/src/wayland/meta-wayland-private.h
@@ -58,6 +58,8 @@ typedef struct
GSubprocess *proc;
GMainLoop *init_loop;
+ GList *x11_windows;
+
MetaXWaylandDnd *dnd;
} MetaXWaylandManager;
diff --git a/src/wayland/meta-xwayland.c b/src/wayland/meta-xwayland.c
index aba16413a..03f492fe4 100644
--- a/src/wayland/meta-xwayland.c
+++ b/src/wayland/meta-xwayland.c
@@ -43,6 +43,7 @@
#include "compositor/meta-window-actor-private.h"
#include "meta/main.h"
#include "wayland/meta-wayland-actor-surface.h"
+#include "x11/meta-x11-display-private.h"
enum
{
@@ -620,6 +621,31 @@ meta_xwayland_start_xserver (MetaXWaylandManager *manager)
return TRUE;
}
+static void
+window_unmanaged_cb (MetaWindow *window,
+ MetaXWaylandManager *manager)
+{
+ manager->x11_windows = g_list_remove (manager->x11_windows, window);
+ g_signal_handlers_disconnect_by_func (window,
+ window_unmanaged_cb,
+ manager);
+}
+
+static void
+window_created_cb (MetaDisplay *display,
+ MetaWindow *window,
+ MetaXWaylandManager *manager)
+{
+ /* Ignore all internal windows */
+ if (!window->xwindow ||
+ meta_window_get_client_pid (window) == getpid ())
+ return;
+
+ manager->x11_windows = g_list_prepend (manager->x11_windows, window);
+ g_signal_connect (window, "unmanaged",
+ G_CALLBACK (window_unmanaged_cb), manager);
+}
+
gboolean
meta_xwayland_init (MetaXWaylandManager *manager,
struct wl_display *wl_display)
@@ -647,6 +673,9 @@ on_x11_display_closing (MetaDisplay *display)
void
meta_xwayland_complete_init (MetaDisplay *display)
{
+ MetaWaylandCompositor *compositor = meta_wayland_compositor_get_default ();
+ MetaXWaylandManager *manager = &compositor->xwayland_manager;
+
/* We install an X IO error handler in addition to the child watch,
because after Xlib connects our child watch may not be called soon
enough, and therefore we won't crash when X exits (and most important
@@ -657,6 +686,9 @@ meta_xwayland_complete_init (MetaDisplay *display)
g_signal_connect (display, "x11-display-closing",
G_CALLBACK (on_x11_display_closing), NULL);
meta_xwayland_init_dnd ();
+
+ g_signal_connect (meta_get_display (), "window-created",
+ G_CALLBACK (window_created_cb), manager);
}
void
@@ -664,6 +696,10 @@ meta_xwayland_shutdown (MetaXWaylandManager *manager)
{
char path[256];
+ g_signal_handlers_disconnect_by_func (meta_get_display (),
+ window_created_cb,
+ manager);
+
g_cancellable_cancel (manager->xserver_died_cancellable);
g_clear_object (&manager->proc);
g_clear_object (&manager->xserver_died_cancellable);