|
|
776610 |
From ca78984a92c84e8684455c80efb5a86c65061f96 Mon Sep 17 00:00:00 2001
|
|
|
776610 |
From: Olivier Fourdan <ofourdan@redhat.com>
|
|
|
776610 |
Date: Fri, 21 Sep 2018 17:49:36 +0200
|
|
|
776610 |
Subject: [PATCH 09/12] window: Add window id
|
|
|
776610 |
|
|
|
776610 |
Generate a unique 64bit window-id which is unrelated to any windowing
|
|
|
776610 |
backend.
|
|
|
776610 |
|
|
|
776610 |
https://gitlab.gnome.org/GNOME/mutter/merge_requests/306
|
|
|
776610 |
(cherry picked from commit bbcb66ddf4f5eeff379f250b361de0366459b4a3)
|
|
|
776610 |
---
|
|
|
776610 |
src/core/display-private.h | 4 ++++
|
|
|
776610 |
src/core/display.c | 32 ++++++++++++++++++++++++++++++++
|
|
|
776610 |
src/core/window-private.h | 1 +
|
|
|
776610 |
src/core/window.c | 16 ++++++++++++++++
|
|
|
776610 |
src/meta/window.h | 2 ++
|
|
|
776610 |
5 files changed, 55 insertions(+)
|
|
|
776610 |
|
|
|
776610 |
diff --git a/src/core/display-private.h b/src/core/display-private.h
|
|
|
776610 |
index 9e4518b..d24ee00 100644
|
|
|
776610 |
--- a/src/core/display-private.h
|
|
|
776610 |
+++ b/src/core/display-private.h
|
|
|
776610 |
@@ -507,4 +507,8 @@ void meta_display_notify_pad_group_switch (MetaDisplay *display,
|
|
|
776610 |
guint n_mode,
|
|
|
776610 |
guint n_modes);
|
|
|
776610 |
|
|
|
776610 |
+MetaWindow *meta_display_get_window_from_id (MetaDisplay *display,
|
|
|
776610 |
+ uint64_t window_id);
|
|
|
776610 |
+uint64_t meta_display_generate_window_id (MetaDisplay *display);
|
|
|
776610 |
+
|
|
|
776610 |
#endif
|
|
|
776610 |
diff --git a/src/core/display.c b/src/core/display.c
|
|
|
776610 |
index e7dd453..d09f119 100644
|
|
|
776610 |
--- a/src/core/display.c
|
|
|
776610 |
+++ b/src/core/display.c
|
|
|
776610 |
@@ -3269,3 +3269,35 @@ meta_display_notify_pad_group_switch (MetaDisplay *display,
|
|
|
776610 |
|
|
|
776610 |
g_string_free (message, TRUE);
|
|
|
776610 |
}
|
|
|
776610 |
+
|
|
|
776610 |
+MetaWindow *
|
|
|
776610 |
+meta_display_get_window_from_id (MetaDisplay *display,
|
|
|
776610 |
+ uint64_t window_id)
|
|
|
776610 |
+{
|
|
|
776610 |
+ g_autoptr (GSList) windows = NULL;
|
|
|
776610 |
+ GSList *l;
|
|
|
776610 |
+
|
|
|
776610 |
+ windows = meta_display_list_windows (display, META_LIST_DEFAULT);
|
|
|
776610 |
+ for (l = windows; l; l = l->next)
|
|
|
776610 |
+ {
|
|
|
776610 |
+ MetaWindow *window = l->data;
|
|
|
776610 |
+
|
|
|
776610 |
+ if (window->id == window_id)
|
|
|
776610 |
+ return window;
|
|
|
776610 |
+ }
|
|
|
776610 |
+
|
|
|
776610 |
+ return NULL;
|
|
|
776610 |
+}
|
|
|
776610 |
+
|
|
|
776610 |
+uint64_t
|
|
|
776610 |
+meta_display_generate_window_id (MetaDisplay *display)
|
|
|
776610 |
+{
|
|
|
776610 |
+ static uint64_t base_window_id;
|
|
|
776610 |
+ static uint64_t last_window_id;
|
|
|
776610 |
+
|
|
|
776610 |
+ if (!base_window_id)
|
|
|
776610 |
+ base_window_id = g_random_int () + 1;
|
|
|
776610 |
+
|
|
|
776610 |
+ /* We can overflow here, that's fine */
|
|
|
776610 |
+ return (base_window_id + last_window_id++);
|
|
|
776610 |
+}
|
|
|
776610 |
diff --git a/src/core/window-private.h b/src/core/window-private.h
|
|
|
776610 |
index 8552829..0f652b9 100644
|
|
|
776610 |
--- a/src/core/window-private.h
|
|
|
776610 |
+++ b/src/core/window-private.h
|
|
|
776610 |
@@ -153,6 +153,7 @@ struct _MetaWindow
|
|
|
776610 |
|
|
|
776610 |
MetaDisplay *display;
|
|
|
776610 |
MetaScreen *screen;
|
|
|
776610 |
+ uint64_t id;
|
|
|
776610 |
guint64 stamp;
|
|
|
776610 |
MetaLogicalMonitor *monitor;
|
|
|
776610 |
MetaWorkspace *workspace;
|
|
|
776610 |
diff --git a/src/core/window.c b/src/core/window.c
|
|
|
776610 |
index a1f4aa4..00b2e4d 100644
|
|
|
776610 |
--- a/src/core/window.c
|
|
|
776610 |
+++ b/src/core/window.c
|
|
|
776610 |
@@ -1142,6 +1142,8 @@ _meta_window_shared_new (MetaDisplay *display,
|
|
|
776610 |
window->has_resize_func = FALSE;
|
|
|
776610 |
}
|
|
|
776610 |
|
|
|
776610 |
+ window->id = meta_display_generate_window_id (display);
|
|
|
776610 |
+
|
|
|
776610 |
META_WINDOW_GET_CLASS (window)->manage (window);
|
|
|
776610 |
|
|
|
776610 |
if (!window->override_redirect)
|
|
|
776610 |
@@ -8466,3 +8468,17 @@ meta_window_is_stackable (MetaWindow *window)
|
|
|
776610 |
{
|
|
|
776610 |
return META_WINDOW_GET_CLASS (window)->is_stackable (window);
|
|
|
776610 |
}
|
|
|
776610 |
+
|
|
|
776610 |
+/**
|
|
|
776610 |
+ * meta_window_get_id:
|
|
|
776610 |
+ * @window: a #MetaWindow
|
|
|
776610 |
+ *
|
|
|
776610 |
+ * Returns the window id associated with window.
|
|
|
776610 |
+ *
|
|
|
776610 |
+ * Returns: (transfer none): The window id
|
|
|
776610 |
+ */
|
|
|
776610 |
+uint64_t
|
|
|
776610 |
+meta_window_get_id (MetaWindow *window)
|
|
|
776610 |
+{
|
|
|
776610 |
+ return window->id;
|
|
|
776610 |
+}
|
|
|
776610 |
diff --git a/src/meta/window.h b/src/meta/window.h
|
|
|
776610 |
index 09317e6..364d541 100644
|
|
|
776610 |
--- a/src/meta/window.h
|
|
|
776610 |
+++ b/src/meta/window.h
|
|
|
776610 |
@@ -260,4 +260,6 @@ gboolean meta_window_is_client_decorated (MetaWindow *window);
|
|
|
776610 |
gboolean meta_window_titlebar_is_onscreen (MetaWindow *window);
|
|
|
776610 |
void meta_window_shove_titlebar_onscreen (MetaWindow *window);
|
|
|
776610 |
|
|
|
776610 |
+uint64_t meta_window_get_id (MetaWindow *window);
|
|
|
776610 |
+
|
|
|
776610 |
#endif
|
|
|
776610 |
--
|
|
|
776610 |
2.19.2
|
|
|
776610 |
|