[libwnck/wip/muktupavels/wnck-handle: 25/29] support multiple handles at same time




commit a1031f9d639ed8ba5ff24640d20d3d8c8824a3fb
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         |  8 +++----
 libwnck/class-group.c         |  4 ++--
 libwnck/screen.c              | 10 ++++----
 libwnck/window.c              | 12 +++++-----
 libwnck/wnck-handle-private.h |  9 -------
 libwnck/wnck-handle.c         | 56 ++++++++++++++++++++++++++++++++++++-------
 libwnck/wnck-handle.h         | 29 ++++++++++++++--------
 7 files changed, 83 insertions(+), 45 deletions(-)
---
diff --git a/libwnck/application.c b/libwnck/application.c
index e88b2938..cbe6c4a9 100644
--- a/libwnck/application.c
+++ b/libwnck/application.c
@@ -191,7 +191,7 @@ wnck_application_finalize (GObject *object)
 WnckApplication*
 wnck_application_get (gulong xwindow)
 {
-  return _wnck_handle_get_application (_wnck_get_handle (), xwindow);
+  return wnck_handle_get_application (_wnck_get_handle (), xwindow);
 }
 
 /**
@@ -506,7 +506,7 @@ _wnck_application_create (Window      xwindow,
   Screen          *xscreen;
 
   handle = wnck_screen_get_handle (screen);
-  application = _wnck_handle_get_application (handle, xwindow);
+  application = wnck_handle_get_application (handle, xwindow);
 
   g_return_val_if_fail (application == NULL, NULL);
 
@@ -556,13 +556,13 @@ _wnck_application_destroy (WnckApplication *application)
 
   handle = wnck_screen_get_handle (application->priv->screen);
 
-  g_return_if_fail (_wnck_handle_get_application (handle, xwindow) == application);
+  g_return_if_fail (wnck_handle_get_application (handle, xwindow) == application);
 
   _wnck_handle_remove_application (handle, &xwindow);
 
   /* Removing from handle also removes the only ref WnckApplication had */
 
-  g_return_if_fail (_wnck_handle_get_application (handle, xwindow) == NULL);
+  g_return_if_fail (wnck_handle_get_application (handle, xwindow) == NULL);
 }
 
 static void
diff --git a/libwnck/class-group.c b/libwnck/class-group.c
index 2718de77..46d1f241 100644
--- a/libwnck/class-group.c
+++ b/libwnck/class-group.c
@@ -202,7 +202,7 @@ wnck_class_group_finalize (GObject *object)
 WnckClassGroup *
 wnck_class_group_get (const char *id)
 {
-  return _wnck_handle_get_class_group (_wnck_get_handle (), id);
+  return wnck_handle_get_class_group (_wnck_get_handle (), id);
 }
 
 /**
@@ -225,7 +225,7 @@ _wnck_class_group_create (WnckScreen *screen,
   WnckClassGroup *class_group;
 
   handle = wnck_screen_get_handle (screen);
-  class_group = _wnck_handle_get_class_group (handle, res_class);
+  class_group = wnck_handle_get_class_group (handle, res_class);
 
   g_return_val_if_fail (class_group == NULL, NULL);
 
diff --git a/libwnck/screen.c b/libwnck/screen.c
index 4f1f97dd..264f49e6 100644
--- a/libwnck/screen.c
+++ b/libwnck/screen.c
@@ -1413,7 +1413,7 @@ update_client_list (WnckScreen *screen)
     {
       WnckWindow *window;
 
-      window = _wnck_handle_get_window (screen->priv->handle, mapping[i]);
+      window = wnck_handle_get_window (screen->priv->handle, mapping[i]);
 
       if (window == NULL)
         {
@@ -1432,7 +1432,7 @@ update_client_list (WnckScreen *screen)
 
           leader = wnck_window_get_group_leader (window);
 
-          app = _wnck_handle_get_application (screen->priv->handle, leader);
+          app = wnck_handle_get_application (screen->priv->handle, leader);
           if (app == NULL)
             {
               app = _wnck_application_create (leader, screen);
@@ -1445,7 +1445,7 @@ update_client_list (WnckScreen *screen)
 
          res_class = wnck_window_get_class_group_name (window);
 
-         class_group = _wnck_handle_get_class_group (screen->priv->handle, 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);
@@ -1509,7 +1509,7 @@ update_client_list (WnckScreen *screen)
     {
       WnckWindow *window;
 
-      window = _wnck_handle_get_window (screen->priv->handle, stack[i]);
+      window = wnck_handle_get_window (screen->priv->handle, stack[i]);
 
       g_assert (window != NULL);
 
@@ -1923,7 +1923,7 @@ update_active_window (WnckScreen *screen)
                     _wnck_atom_get ("_NET_ACTIVE_WINDOW"),
                     &xwindow);
 
-  window = _wnck_handle_get_window (screen->priv->handle, 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 c9feea9e..475ddad5 100644
--- a/libwnck/window.c
+++ b/libwnck/window.c
@@ -448,7 +448,7 @@ wnck_window_finalize (GObject *object)
 WnckWindow*
 wnck_window_get (gulong xwindow)
 {
-  return _wnck_handle_get_window (_wnck_get_handle (), xwindow);
+  return wnck_handle_get_window (_wnck_get_handle (), xwindow);
 }
 
 /**
@@ -478,7 +478,7 @@ _wnck_window_create (Window      xwindow,
   Screen     *xscreen;
 
   handle = wnck_screen_get_handle (screen);
-  window = _wnck_handle_get_window (handle, xwindow);
+  window = wnck_handle_get_window (handle, xwindow);
 
   g_return_val_if_fail (window == NULL, NULL);
 
@@ -558,13 +558,13 @@ _wnck_window_destroy (WnckWindow *window)
 
   handle = wnck_screen_get_handle (window->priv->screen);
 
-  g_return_if_fail (_wnck_handle_get_window (handle, xwindow) == window);
+  g_return_if_fail (wnck_handle_get_window (handle, xwindow) == window);
 
   _wnck_handle_remove_window (handle, &xwindow);
 
   /* Removing from handle also removes the only ref WnckWindow had */
 
-  g_return_if_fail (_wnck_handle_get_window (handle, xwindow) == NULL);
+  g_return_if_fail (wnck_handle_get_window (handle, xwindow) == NULL);
 }
 
 static Display *
@@ -746,7 +746,7 @@ wnck_window_get_transient (WnckWindow *window)
 
   handle = wnck_screen_get_handle (window->priv->screen);
 
-  return _wnck_handle_get_window (handle, window->priv->transient_for);
+  return wnck_handle_get_window (handle, window->priv->transient_for);
 }
 
 /**
@@ -1171,7 +1171,7 @@ _wnck_window_get_startup_id (WnckWindow *window)
       /* Fall back to group leader property */
 
       handle = wnck_screen_get_handle (window->priv->screen);
-      app = _wnck_handle_get_application (handle, window->priv->group_leader);
+      app = wnck_handle_get_application (handle, window->priv->group_leader);
 
       if (app != NULL)
         return wnck_application_get_startup_id (app);
diff --git a/libwnck/wnck-handle-private.h b/libwnck/wnck-handle-private.h
index f17b3154..cca13e17 100644
--- a/libwnck/wnck-handle-private.h
+++ b/libwnck/wnck-handle-private.h
@@ -40,9 +40,6 @@ void             _wnck_handle_insert_class_group         (WnckHandle      *self,
 void             _wnck_handle_remove_class_group         (WnckHandle      *self,
                                                           const char      *id);
 
-WnckClassGroup  *_wnck_handle_get_class_group            (WnckHandle      *self,
-                                                          const char      *id);
-
 void             _wnck_handle_insert_application         (WnckHandle      *self,
                                                           gpointer         xwindow,
                                                           WnckApplication *app);
@@ -50,9 +47,6 @@ void             _wnck_handle_insert_application         (WnckHandle      *self,
 void             _wnck_handle_remove_application         (WnckHandle      *self,
                                                           gpointer         xwindow);
 
-WnckApplication *_wnck_handle_get_application            (WnckHandle      *self,
-                                                          gulong           xwindow);
-
 void             _wnck_handle_insert_window              (WnckHandle      *self,
                                                           gpointer         xwindow,
                                                           WnckWindow      *window);
@@ -60,9 +54,6 @@ void             _wnck_handle_insert_window              (WnckHandle      *self,
 void             _wnck_handle_remove_window              (WnckHandle      *self,
                                                           gpointer         xwindow);
 
-WnckWindow      *_wnck_handle_get_window                 (WnckHandle      *self,
-                                                          gulong           xwindow);
-
 G_END_DECLS
 
 #endif
diff --git a/libwnck/wnck-handle.c b/libwnck/wnck-handle.c
index 6782dfd5..5c2ba806 100644
--- a/libwnck/wnck-handle.c
+++ b/libwnck/wnck-handle.c
@@ -95,8 +95,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);
@@ -111,7 +111,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);
@@ -523,9 +523,21 @@ _wnck_handle_remove_class_group (WnckHandle *self,
   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)
+wnck_handle_get_class_group (WnckHandle *self,
+                             const char *id)
 {
   g_return_val_if_fail (WNCK_IS_HANDLE (self), NULL);
 
@@ -547,9 +559,23 @@ _wnck_handle_remove_application (WnckHandle *self,
   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)
+wnck_handle_get_application (WnckHandle *self,
+                             gulong      xwindow)
 {
   g_return_val_if_fail (WNCK_IS_HANDLE (self), NULL);
 
@@ -571,9 +597,21 @@ _wnck_handle_remove_window (WnckHandle *self,
   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)
+wnck_handle_get_window (WnckHandle *self,
+                        gulong      xwindow)
 {
   g_return_val_if_fail (WNCK_IS_HANDLE (self), NULL);
 
diff --git a/libwnck/wnck-handle.h b/libwnck/wnck-handle.h
index a7b5c861..b58a47f0 100644
--- a/libwnck/wnck-handle.h
+++ b/libwnck/wnck-handle.h
@@ -31,21 +31,30 @@ 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);
+
+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
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]