[libwnck/wip/muktupavels/wnck-handle: 8/8] support multiple handles at same time
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libwnck/wip/muktupavels/wnck-handle: 8/8] support multiple handles at same time
- Date: Tue, 28 Dec 2021 12:36:46 +0000 (UTC)
commit 86b552b751ecd10e2ccd4befa71ec05960acc01e
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Tue Aug 20 17:27:13 2019 +0300
support multiple handles at same time
libwnck/application.c | 37 ++++-------
libwnck/application.h | 1 +
libwnck/class-group.c | 35 +++-------
libwnck/class-group.h | 1 +
libwnck/private.h | 4 --
libwnck/screen.c | 10 +--
libwnck/window.c | 47 ++++++-------
libwnck/window.h | 1 +
libwnck/wnck-handle-private.h | 23 +++++++
libwnck/wnck-handle.c | 150 ++++++++++++++++++++++++++++++++++++++++--
libwnck/wnck-handle.h | 45 ++++++++-----
libwnck/wnckprop.c | 45 +++++++------
12 files changed, 267 insertions(+), 132 deletions(-)
---
diff --git a/libwnck/application.c b/libwnck/application.c
index dc1e1c0..60aa764 100644
--- a/libwnck/application.c
+++ b/libwnck/application.c
@@ -50,8 +50,6 @@
#define FALLBACK_NAME _("Untitled application")
-static GHashTable *app_hash = NULL;
-
struct _WnckApplicationPrivate
{
Window xwindow; /* group leader */
@@ -97,16 +95,6 @@ static void wnck_application_finalize (GObject *object);
static guint signals[LAST_SIGNAL] = { 0 };
-void
-_wnck_application_shutdown_all (void)
-{
- if (app_hash != NULL)
- {
- g_hash_table_destroy (app_hash);
- app_hash = NULL;
- }
-}
-
static void
wnck_application_init (WnckApplication *application)
{
@@ -204,10 +192,7 @@ wnck_application_finalize (GObject *object)
WnckApplication*
wnck_application_get (gulong xwindow)
{
- if (app_hash == NULL)
- return NULL;
- else
- return g_hash_table_lookup (app_hash, &xwindow);
+ return wnck_handle_get_application (_wnck_get_handle (), xwindow);
}
/**
@@ -518,15 +503,12 @@ WnckApplication*
_wnck_application_create (Window xwindow,
WnckScreen *screen)
{
+ WnckHandle *handle;
WnckApplication *application;
Screen *xscreen;
- if (app_hash == NULL)
- app_hash = g_hash_table_new_full (_wnck_xid_hash, _wnck_xid_equal,
- NULL, g_object_unref);
-
- g_return_val_if_fail (g_hash_table_lookup (app_hash, &xwindow) == NULL,
- NULL);
+ handle = wnck_screen_get_handle (screen);
+ g_return_val_if_fail (wnck_handle_get_application (handle, xwindow) == NULL, NULL);
xscreen = WNCK_SCREEN_XSCREEN (screen);
@@ -549,7 +531,7 @@ _wnck_application_create (Window xwindow,
application->priv->xwindow,
_wnck_atom_get ("_NET_STARTUP_ID"));
- g_hash_table_insert (app_hash, &application->priv->xwindow, application);
+ wnck_handle_insert_application (handle, &application->priv->xwindow, application);
/* Hash now owns one ref, caller gets none */
@@ -567,15 +549,18 @@ _wnck_application_create (Window xwindow,
void
_wnck_application_destroy (WnckApplication *application)
{
+ WnckHandle *handle;
Window xwindow = application->priv->xwindow;
- g_return_if_fail (wnck_application_get (xwindow) == application);
+ handle = wnck_screen_get_handle (application->priv->screen);
+
+ g_return_if_fail (wnck_handle_get_application (handle, xwindow) == application);
- g_hash_table_remove (app_hash, &xwindow);
+ wnck_handle_remove_application (handle, &xwindow);
/* Removing from hash also removes the only ref WnckApplication had */
- g_return_if_fail (wnck_application_get (xwindow) == NULL);
+ g_return_if_fail (wnck_handle_get_application (handle, xwindow) == NULL);
}
static void
diff --git a/libwnck/application.h b/libwnck/application.h
index 7966a81..40fe4c6 100644
--- a/libwnck/application.h
+++ b/libwnck/application.h
@@ -74,6 +74,7 @@ struct _WnckApplicationClass
GType wnck_application_get_type (void) G_GNUC_CONST;
+G_DEPRECATED_FOR(wnck_handle_get_application)
WnckApplication* wnck_application_get (gulong xwindow);
gulong wnck_application_get_xid (WnckApplication *app);
diff --git a/libwnck/class-group.c b/libwnck/class-group.c
index 5a1aec2..41d7e9b 100644
--- a/libwnck/class-group.c
+++ b/libwnck/class-group.c
@@ -65,9 +65,6 @@ struct _WnckClassGroupPrivate {
G_DEFINE_TYPE_WITH_PRIVATE (WnckClassGroup, wnck_class_group, G_TYPE_OBJECT);
-/* Hash table that maps res_class strings -> WnckClassGroup instances */
-static GHashTable *class_group_hash = NULL;
-
static void wnck_class_group_finalize (GObject *object);
enum {
@@ -78,16 +75,6 @@ enum {
static guint signals[LAST_SIGNAL] = { 0 };
-void
-_wnck_class_group_shutdown_all (void)
-{
- if (class_group_hash != NULL)
- {
- g_hash_table_destroy (class_group_hash);
- class_group_hash = NULL;
- }
-}
-
static void
wnck_class_group_class_init (WnckClassGroupClass *class)
{
@@ -215,10 +202,7 @@ wnck_class_group_finalize (GObject *object)
WnckClassGroup *
wnck_class_group_get (const char *id)
{
- if (!class_group_hash)
- return NULL;
- else
- return g_hash_table_lookup (class_group_hash, id ? id : "");
+ return wnck_handle_get_class_group (_wnck_get_handle (), id);
}
/**
@@ -237,22 +221,18 @@ WnckClassGroup *
_wnck_class_group_create (WnckScreen *screen,
const char *res_class)
{
+ WnckHandle *handle;
WnckClassGroup *class_group;
- if (class_group_hash == NULL)
- class_group_hash = g_hash_table_new_full (g_str_hash, g_str_equal,
- NULL, g_object_unref);
-
- g_return_val_if_fail (g_hash_table_lookup (class_group_hash, res_class ? res_class : "") == NULL,
- NULL);
+ handle = wnck_screen_get_handle (screen);
+ g_return_val_if_fail (wnck_handle_get_class_group (handle, res_class) == NULL, NULL);
class_group = g_object_new (WNCK_TYPE_CLASS_GROUP, NULL);
class_group->priv->screen = screen;
class_group->priv->res_class = g_strdup (res_class ? res_class : "");
- g_hash_table_insert (class_group_hash,
- class_group->priv->res_class, class_group);
+ wnck_handle_insert_class_group (handle, class_group->priv->res_class, class_group);
/* Hash now owns one ref, caller gets none */
return class_group;
@@ -267,9 +247,12 @@ _wnck_class_group_create (WnckScreen *screen,
void
_wnck_class_group_destroy (WnckClassGroup *class_group)
{
+ WnckHandle *handle;
+
g_return_if_fail (WNCK_IS_CLASS_GROUP (class_group));
- g_hash_table_remove (class_group_hash, class_group->priv->res_class);
+ handle = wnck_screen_get_handle (class_group->priv->screen);
+ wnck_handle_remove_class_group (handle, class_group->priv->res_class);
/* Removing from hash also removes the only ref WnckClassGroup had */
}
diff --git a/libwnck/class-group.h b/libwnck/class-group.h
index ce084c3..581cd22 100644
--- a/libwnck/class-group.h
+++ b/libwnck/class-group.h
@@ -72,6 +72,7 @@ struct _WnckClassGroupClass
GType wnck_class_group_get_type (void) G_GNUC_CONST;
+G_DEPRECATED_FOR(wnck_handle_get_class_group)
WnckClassGroup *wnck_class_group_get (const char *id);
GList *wnck_class_group_get_windows (WnckClassGroup *class_group);
diff --git a/libwnck/private.h b/libwnck/private.h
index 887455b..3c03658 100644
--- a/libwnck/private.h
+++ b/libwnck/private.h
@@ -65,8 +65,6 @@ const char* _wnck_window_get_startup_id (WnckWindow *window);
time_t _wnck_window_get_needs_attention_time (WnckWindow *window);
time_t _wnck_window_or_transient_get_needs_attention_time (WnckWindow *window);
-void _wnck_window_shutdown_all (void);
-
WnckWorkspace* _wnck_workspace_create (int number,
WnckScreen *screen);
void _wnck_workspace_destroy (WnckWorkspace *space);
@@ -91,7 +89,6 @@ WnckApplication* _wnck_application_create (Window xwindow,
WnckScreen *screen);
void _wnck_application_destroy (WnckApplication *app);
void _wnck_application_load_icons (WnckApplication *app);
-void _wnck_application_shutdown_all (void);
WnckClassGroup *_wnck_class_group_create (WnckScreen *screen,
const char *res_class);
@@ -100,7 +97,6 @@ void _wnck_class_group_add_window (WnckClassGroup *class_group,
WnckWindow *window);
void _wnck_class_group_remove_window (WnckClassGroup *class_group,
WnckWindow *window);
-void _wnck_class_group_shutdown_all (void);
void _wnck_workspace_update_name (WnckWorkspace *workspace,
const char *name);
diff --git a/libwnck/screen.c b/libwnck/screen.c
index f12e065..ce78cc6 100644
--- a/libwnck/screen.c
+++ b/libwnck/screen.c
@@ -1412,7 +1412,7 @@ update_client_list (WnckScreen *screen)
{
WnckWindow *window;
- window = wnck_window_get (mapping[i]);
+ window = wnck_handle_get_window (screen->priv->handle, mapping[i]);
if (window == NULL)
{
@@ -1431,7 +1431,7 @@ update_client_list (WnckScreen *screen)
leader = wnck_window_get_group_leader (window);
- app = wnck_application_get (leader);
+ app = wnck_handle_get_application (screen->priv->handle, leader);
if (app == NULL)
{
app = _wnck_application_create (leader, screen);
@@ -1444,7 +1444,7 @@ update_client_list (WnckScreen *screen)
res_class = wnck_window_get_class_group_name (window);
- class_group = wnck_class_group_get (res_class);
+ class_group = wnck_handle_get_class_group (screen->priv->handle, res_class);
if (class_group == NULL)
{
class_group = _wnck_class_group_create (screen, res_class);
@@ -1508,7 +1508,7 @@ update_client_list (WnckScreen *screen)
{
WnckWindow *window;
- window = wnck_window_get (stack[i]);
+ window = wnck_handle_get_window (screen->priv->handle, stack[i]);
g_assert (window != NULL);
@@ -1922,7 +1922,7 @@ update_active_window (WnckScreen *screen)
_wnck_atom_get ("_NET_ACTIVE_WINDOW"),
&xwindow);
- window = wnck_window_get (xwindow);
+ window = wnck_handle_get_window (screen->priv->handle, xwindow);
if (window == screen->priv->active_window)
return;
diff --git a/libwnck/window.c b/libwnck/window.c
index 3098339..85a8745 100644
--- a/libwnck/window.c
+++ b/libwnck/window.c
@@ -49,8 +49,6 @@
#define FALLBACK_NAME _("Untitled window")
#define ALL_WORKSPACES ((int) 0xFFFFFFFF)
-static GHashTable *window_hash = NULL;
-
/* Keep 0-7 in sync with the numbers in the WindowState enum. Yeah I'm
* a loser.
*/
@@ -220,16 +218,6 @@ static WnckWindow* find_last_transient_for (GList *windows,
static guint signals[LAST_SIGNAL] = { 0 };
-void
-_wnck_window_shutdown_all (void)
-{
- if (window_hash != NULL)
- {
- g_hash_table_destroy (window_hash);
- window_hash = NULL;
- }
-}
-
static void
wnck_window_init (WnckWindow *window)
{
@@ -461,10 +449,7 @@ wnck_window_finalize (GObject *object)
WnckWindow*
wnck_window_get (gulong xwindow)
{
- if (window_hash == NULL)
- return NULL;
- else
- return g_hash_table_lookup (window_hash, &xwindow);
+ return wnck_handle_get_window (_wnck_get_handle (), xwindow);
}
/**
@@ -489,15 +474,12 @@ _wnck_window_create (Window xwindow,
WnckScreen *screen,
gint sort_order)
{
+ WnckHandle *handle;
WnckWindow *window;
Screen *xscreen;
- if (window_hash == NULL)
- window_hash = g_hash_table_new_full (_wnck_xid_hash, _wnck_xid_equal,
- NULL, g_object_unref);
-
- g_return_val_if_fail (g_hash_table_lookup (window_hash, &xwindow) == NULL,
- NULL);
+ handle = wnck_screen_get_handle (screen);
+ g_return_val_if_fail (wnck_handle_get_window (handle, xwindow) == NULL, NULL);
xscreen = WNCK_SCREEN_XSCREEN (screen);
@@ -505,7 +487,7 @@ _wnck_window_create (Window xwindow,
window->priv->xwindow = xwindow;
window->priv->screen = screen;
- g_hash_table_insert (window_hash, &window->priv->xwindow, window);
+ wnck_handle_insert_window (handle, &window->priv->xwindow, window);
/* Hash now owns one ref, caller gets none */
@@ -568,17 +550,20 @@ _wnck_window_create (Window xwindow,
void
_wnck_window_destroy (WnckWindow *window)
{
+ WnckHandle *handle;
Window xwindow = window->priv->xwindow;
g_return_if_fail (WNCK_IS_WINDOW (window));
- g_return_if_fail (wnck_window_get (xwindow) == window);
+ handle = wnck_screen_get_handle (window->priv->screen);
- g_hash_table_remove (window_hash, &xwindow);
+ g_return_if_fail (wnck_handle_get_window (handle, xwindow) == window);
+
+ wnck_handle_remove_window (handle, &xwindow);
/* Removing from hash also removes the only ref WnckWindow had */
- g_return_if_fail (wnck_window_get (xwindow) == NULL);
+ g_return_if_fail (wnck_handle_get_window (handle, xwindow) == NULL);
}
static Display *
@@ -754,9 +739,13 @@ wnck_window_get_application (WnckWindow *window)
WnckWindow*
wnck_window_get_transient (WnckWindow *window)
{
+ WnckHandle *handle;
+
g_return_val_if_fail (WNCK_IS_WINDOW (window), NULL);
- return wnck_window_get (window->priv->transient_for);
+ handle = wnck_screen_get_handle (window->priv->screen);
+
+ return wnck_handle_get_window (handle, window->priv->transient_for);
}
/**
@@ -1175,11 +1164,13 @@ _wnck_window_get_startup_id (WnckWindow *window)
if (window->priv->startup_id == NULL &&
window->priv->group_leader != None)
{
+ WnckHandle *handle;
WnckApplication *app;
/* Fall back to group leader property */
- app = wnck_application_get (window->priv->group_leader);
+ handle = wnck_screen_get_handle (window->priv->screen);
+ app = wnck_handle_get_application (handle, window->priv->group_leader);
if (app != NULL)
return wnck_application_get_startup_id (app);
diff --git a/libwnck/window.h b/libwnck/window.h
index 72545aa..47c6543 100644
--- a/libwnck/window.h
+++ b/libwnck/window.h
@@ -288,6 +288,7 @@ struct _WnckWindowClass
GType wnck_window_get_type (void) G_GNUC_CONST;
+G_DEPRECATED_FOR(wnck_handle_get_window)
WnckWindow* wnck_window_get (gulong xwindow);
WnckScreen* wnck_window_get_screen (WnckWindow *window);
diff --git a/libwnck/wnck-handle-private.h b/libwnck/wnck-handle-private.h
index c791560..31c4b01 100644
--- a/libwnck/wnck-handle-private.h
+++ b/libwnck/wnck-handle-private.h
@@ -32,6 +32,29 @@ gsize _wnck_handle_get_default_icon_size (WnckHandle *self);
gsize _wnck_handle_get_default_mini_icon_size (WnckHandle *self);
+void wnck_handle_insert_class_group (WnckHandle *self,
+ const char *id,
+ WnckClassGroup *class_group);
+
+
+void wnck_handle_remove_class_group (WnckHandle *self,
+ const char *id);
+
+void wnck_handle_insert_application (WnckHandle *self,
+ gpointer xwindow,
+ WnckApplication *app);
+
+
+void wnck_handle_remove_application (WnckHandle *self,
+ gpointer xwindow);
+
+void wnck_handle_insert_window (WnckHandle *self,
+ gpointer xwindow,
+ WnckWindow *window);
+
+void wnck_handle_remove_window (WnckHandle *self,
+ gpointer xwindow);
+
G_END_DECLS
#endif
diff --git a/libwnck/wnck-handle.c b/libwnck/wnck-handle.c
index 9a7f565..16a0b83 100644
--- a/libwnck/wnck-handle.c
+++ b/libwnck/wnck-handle.c
@@ -70,6 +70,10 @@ struct _WnckHandle
gsize default_icon_size;
gsize default_mini_icon_size;
+ GHashTable *class_group_hash;
+ GHashTable *app_hash;
+ GHashTable *window_hash;
+
xresclient_state xres_state;
guint xres_idleid;
GHashTable *xres_hashtable;
@@ -467,8 +471,8 @@ filter_func (GdkXEvent *gdkxevent,
WnckWindow *window;
WnckApplication *app;
- window = wnck_window_get (xevent->xany.window);
- app = wnck_application_get (xevent->xany.window);
+ window = wnck_handle_get_window (self, xevent->xany.window);
+ app = wnck_handle_get_application (self, xevent->xany.window);
if (app)
_wnck_application_process_property_notify (app, xevent);
@@ -483,7 +487,7 @@ filter_func (GdkXEvent *gdkxevent,
{
WnckWindow *window;
- window = wnck_window_get (xevent->xconfigure.window);
+ window = wnck_handle_get_window (self, xevent->xconfigure.window);
if (window)
_wnck_window_process_configure_notify (window, xevent);
@@ -548,9 +552,23 @@ wnck_handle_finalize (GObject *object)
* actually be done before shutting down global WnckWindow structures
* (because the WnckScreen has a list of WnckWindow that will get mis-used
* otherwise). */
- _wnck_class_group_shutdown_all ();
- _wnck_application_shutdown_all ();
- _wnck_window_shutdown_all ();
+ if (self->class_group_hash != NULL)
+ {
+ g_hash_table_destroy (self->class_group_hash);
+ self->class_group_hash = NULL;
+ }
+
+ if (self->app_hash != NULL)
+ {
+ g_hash_table_destroy (self->app_hash);
+ self->app_hash = NULL;
+ }
+
+ if (self->window_hash != NULL)
+ {
+ g_hash_table_destroy (self->window_hash);
+ self->window_hash = NULL;
+ }
if (self->screens != NULL)
{
@@ -657,6 +675,15 @@ wnck_handle_init (WnckHandle *self)
self->default_icon_size = WNCK_DEFAULT_ICON_SIZE;
self->default_mini_icon_size = WNCK_DEFAULT_MINI_ICON_SIZE;
+ self->class_group_hash = g_hash_table_new_full (g_str_hash, g_str_equal,
+ NULL, g_object_unref);
+
+ self->app_hash = g_hash_table_new_full (_wnck_xid_hash, _wnck_xid_equal,
+ NULL, g_object_unref);
+
+ self->window_hash = g_hash_table_new_full (_wnck_xid_hash, _wnck_xid_equal,
+ NULL, g_object_unref);
+
self->xres_state = (xresclient_state) { self, NULL, 0, -1, NULL, NULL };
gdk_window_add_filter (NULL, filter_func, self);
@@ -1028,3 +1055,114 @@ wnck_handle_read_resource_usage_pid (WnckHandle *self,
wnck_pid_read_resource_usage_no_cache (self, gdk_display, pid, usage);
#endif /* HAVE_XRES */
}
+
+void
+wnck_handle_insert_class_group (WnckHandle *self,
+ const char *id,
+ WnckClassGroup *class_group)
+{
+ g_return_if_fail (id != NULL);
+
+ g_hash_table_insert (self->class_group_hash, (gpointer) id, class_group);
+}
+
+void
+wnck_handle_remove_class_group (WnckHandle *self,
+ const char *id)
+{
+ g_hash_table_remove (self->class_group_hash, id);
+}
+
+/**
+ * wnck_handle_get_class_group:
+ * @self: a #WnckHandle
+ * @id: identifier name of the sought resource class.
+ *
+ * Gets the #WnckClassGroup corresponding to @id.
+ *
+ * Returns: (transfer none): the #WnckClassGroup corresponding to
+ * @id, or %NULL if there is no #WnckClassGroup with the specified
+ * @id. The returned #WnckClassGroup is owned by libwnck and must not be
+ * referenced or unreferenced.
+ */
+WnckClassGroup *
+wnck_handle_get_class_group (WnckHandle *self,
+ const char *id)
+{
+ g_return_val_if_fail (WNCK_IS_HANDLE (self), NULL);
+
+ return g_hash_table_lookup (self->class_group_hash, id ? id : "");
+}
+
+void
+wnck_handle_insert_application (WnckHandle *self,
+ gpointer xwindow,
+ WnckApplication *app)
+{
+ g_hash_table_insert (self->app_hash, xwindow, app);
+}
+
+void
+wnck_handle_remove_application (WnckHandle *self,
+ gpointer xwindow)
+{
+ g_hash_table_remove (self->app_hash, xwindow);
+}
+
+/**
+ * wnck_handle_get_application:
+ * @self: a #WnckHandle
+ * @xwindow: the X window ID of a group leader.
+ *
+ * Gets the #WnckApplication corresponding to the group leader with @xwindow
+ * as X window ID.
+ *
+ * Returns: (transfer none): the #WnckApplication corresponding to
+ * @xwindow, or %NULL if there no such #WnckApplication could be found. The
+ * returned #WnckApplication is owned by libwnck and must not be referenced or
+ * unreferenced.
+ */
+WnckApplication *
+wnck_handle_get_application (WnckHandle *self,
+ gulong xwindow)
+{
+ g_return_val_if_fail (WNCK_IS_HANDLE (self), NULL);
+
+ return g_hash_table_lookup (self->app_hash, &xwindow);
+}
+
+void
+wnck_handle_insert_window (WnckHandle *self,
+ gpointer xwindow,
+ WnckWindow *window)
+{
+ g_hash_table_insert (self->window_hash, xwindow, window);
+}
+
+void
+wnck_handle_remove_window (WnckHandle *self,
+ gpointer xwindow)
+{
+ g_hash_table_remove (self->window_hash, xwindow);
+}
+
+/**
+ * wnck_handle_get_window:
+ * @self: a #WnckHandle
+ * @xwindow: an X window ID.
+ *
+ * Gets a preexisting #WnckWindow for the X window @xwindow. This will not
+ * create a #WnckWindow if none exists. The function is robust against bogus
+ * window IDs.
+ *
+ * Returns: (transfer none): the #WnckWindow for @xwindow. The returned
+ * #WnckWindow is owned by libwnck and must not be referenced or unreferenced.
+ */
+WnckWindow *
+wnck_handle_get_window (WnckHandle *self,
+ gulong xwindow)
+{
+ g_return_val_if_fail (WNCK_IS_HANDLE (self), NULL);
+
+ return g_hash_table_lookup (self->window_hash, &xwindow);
+}
diff --git a/libwnck/wnck-handle.h b/libwnck/wnck-handle.h
index 0c76ab1..5183b2a 100644
--- a/libwnck/wnck-handle.h
+++ b/libwnck/wnck-handle.h
@@ -31,31 +31,40 @@ G_BEGIN_DECLS
#define WNCK_TYPE_HANDLE (wnck_handle_get_type ())
G_DECLARE_FINAL_TYPE (WnckHandle, wnck_handle, WNCK, HANDLE, GObject)
-WnckHandle *wnck_handle_new (WnckClientType client_type);
+WnckHandle *wnck_handle_new (WnckClientType client_type);
-WnckScreen *wnck_handle_get_default_screen (WnckHandle *self);
+WnckScreen *wnck_handle_get_default_screen (WnckHandle *self);
-WnckScreen *wnck_handle_get_screen (WnckHandle *self,
- int index);
+WnckScreen *wnck_handle_get_screen (WnckHandle *self,
+ int index);
-WnckScreen *wnck_handle_get_screen_for_root (WnckHandle *self,
- gulong root_window_id);
+WnckScreen *wnck_handle_get_screen_for_root (WnckHandle *self,
+ gulong root_window_id);
-void wnck_handle_set_default_icon_size (WnckHandle *self,
- gsize icon_size);
+void wnck_handle_set_default_icon_size (WnckHandle *self,
+ gsize icon_size);
-void wnck_handle_set_default_mini_icon_size (WnckHandle *self,
- gsize icon_size);
+void wnck_handle_set_default_mini_icon_size (WnckHandle *self,
+ gsize icon_size);
-void wnck_handle_read_resource_usage_xid (WnckHandle *self,
- GdkDisplay *gdk_display,
- gulong xid,
- WnckResourceUsage *usage);
+void wnck_handle_read_resource_usage_xid (WnckHandle *self,
+ GdkDisplay *gdk_display,
+ gulong xid,
+ WnckResourceUsage *usage);
-void wnck_handle_read_resource_usage_pid (WnckHandle *self,
- GdkDisplay *gdk_display,
- gulong pid,
- WnckResourceUsage *usage);
+void wnck_handle_read_resource_usage_pid (WnckHandle *self,
+ GdkDisplay *gdk_display,
+ gulong pid,
+ WnckResourceUsage *usage);
+
+WnckClassGroup *wnck_handle_get_class_group (WnckHandle *self,
+ const char *id);
+
+WnckApplication *wnck_handle_get_application (WnckHandle *self,
+ gulong xwindow);
+
+WnckWindow *wnck_handle_get_window (WnckHandle *self,
+ gulong xwindow);
G_END_DECLS
diff --git a/libwnck/wnckprop.c b/libwnck/wnckprop.c
index fa4844a..a6622b5 100644
--- a/libwnck/wnckprop.c
+++ b/libwnck/wnckprop.c
@@ -291,7 +291,7 @@ static GOptionEntry space_entries[] = {
{ NULL }
};
-static void clean_up (void);
+static void clean_up (WnckHandle *handle);
/* this part is mostly stolen from xutils.c */
typedef struct
@@ -1708,8 +1708,9 @@ wm_state_set (Display *display,
}
static WnckWindow *
-find_managed_window (Display *display,
- Window window)
+find_managed_window (WnckHandle *handle,
+ Display *display,
+ Window window)
{
GdkDisplay *gdk_display;
Window root;
@@ -1720,7 +1721,7 @@ find_managed_window (Display *display,
int result;
if (wm_state_set (display, window))
- return wnck_window_get (window);
+ return wnck_handle_get_window (handle, window);
gdk_display = gdk_x11_lookup_xdisplay (display);
g_assert (gdk_display != NULL);
@@ -1736,11 +1737,11 @@ find_managed_window (Display *display,
{
if (wm_state_set (display, kids [i]))
{
- retval = wnck_window_get (kids [i]);
+ retval = wnck_handle_get_window (handle, kids [i]);
break;
}
- retval = find_managed_window (display, kids [i]);
+ retval = find_managed_window (handle, display, kids [i]);
if (retval != NULL)
break;
}
@@ -1752,12 +1753,14 @@ find_managed_window (Display *display,
}
static void
-handle_button_press_event (Display *dpy, XIDeviceEvent *event)
+handle_button_press_event (WnckHandle *handle,
+ Display *dpy,
+ XIDeviceEvent *event)
{
if (event->child == None)
return;
- got_from_user = find_managed_window (dpy, event->child);
+ got_from_user = find_managed_window (handle, dpy, event->child);
}
static GdkFilterReturn
@@ -1765,6 +1768,7 @@ target_filter (GdkXEvent *gdk_xevent,
GdkEvent *gdk_event,
gpointer data)
{
+ WnckHandle *handle = data;
XEvent *xevent = (XEvent *) gdk_xevent;
XGenericEventCookie *cookie = &xevent->xcookie;
@@ -1779,13 +1783,13 @@ target_filter (GdkXEvent *gdk_xevent,
switch (event->evtype)
{
case XI_ButtonPress:
- handle_button_press_event (cookie->display, event);
- clean_up ();
+ handle_button_press_event (handle, cookie->display, event);
+ clean_up (handle);
return GDK_FILTER_REMOVE;
case XI_KeyPress:
if (event->detail == XKeysymToKeycode (cookie->display, XK_Escape))
{
- clean_up ();
+ clean_up (handle);
return GDK_FILTER_REMOVE;
}
break;
@@ -1808,6 +1812,7 @@ prepare (GdkSeat *seat,
static gboolean
get_target (gpointer data)
{
+ WnckHandle *handle;
GdkWindow *root;
GdkDisplay *display;
GdkSeat *seat;
@@ -1815,13 +1820,15 @@ get_target (gpointer data)
GdkSeatCapabilities caps;
GdkGrabStatus status;
+ handle = data;
+
root = gdk_get_default_root_window ();
display = gdk_display_get_default ();
seat = gdk_display_get_default_seat (display);
cross = gdk_cursor_new_for_display (display, GDK_CROSS);
caps = GDK_SEAT_CAPABILITY_POINTER | GDK_SEAT_CAPABILITY_KEYBOARD;
- gdk_window_add_filter (root, (GdkFilterFunc) target_filter, NULL);
+ gdk_window_add_filter (root, (GdkFilterFunc) target_filter, handle);
status = gdk_seat_grab (seat, root, caps, TRUE, cross, NULL, prepare, NULL);
g_object_unref (cross);
@@ -1829,7 +1836,7 @@ get_target (gpointer data)
if (status != GDK_GRAB_SUCCESS)
{
g_warning ("Seat grab failed.");
- clean_up ();
+ clean_up (handle);
return FALSE;
}
@@ -1839,7 +1846,7 @@ get_target (gpointer data)
}
static void
-clean_up (void)
+clean_up (WnckHandle *handle)
{
GdkWindow *root;
GdkDisplay *display;
@@ -1849,7 +1856,7 @@ clean_up (void)
display = gdk_display_get_default ();
seat = gdk_display_get_default_seat (display);
- gdk_window_remove_filter (root, (GdkFilterFunc) target_filter, NULL);
+ gdk_window_remove_filter (root, (GdkFilterFunc) target_filter, handle);
gdk_seat_ungrab (seat);
gtk_main_quit ();
@@ -1966,7 +1973,7 @@ main (int argc, char **argv)
if (get_from_user)
{
- g_idle_add (get_target, NULL);
+ g_idle_add (get_target, handle);
gtk_main ();
@@ -2014,7 +2021,7 @@ main (int argc, char **argv)
if (got_from_user)
class_group = wnck_window_get_class_group (got_from_user);
else
- class_group = wnck_class_group_get (interact_class_group);
+ class_group = wnck_handle_get_class_group (handle, interact_class_group);
if (class_group)
{
@@ -2039,7 +2046,7 @@ main (int argc, char **argv)
if (got_from_user)
app = wnck_window_get_application (got_from_user);
else
- app = wnck_application_get (interact_app_xid);
+ app = wnck_handle_get_application (handle, interact_app_xid);
if (app)
{
@@ -2062,7 +2069,7 @@ main (int argc, char **argv)
if (got_from_user)
window = got_from_user;
else
- window = wnck_window_get (xid);
+ window = wnck_handle_get_window (handle, xid);
if (window)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]