[libwnck/wip/muktupavels/wnck-handle: 2/8] add wnck_handle_new and deprecate wnck_set_client_type




commit 568e87d4be8fe464ba1735ae368b4326c1307c55
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Mon Aug 19 17:29:54 2019 +0300

    add wnck_handle_new and deprecate wnck_set_client_type

 libwnck/private.h             |  2 --
 libwnck/screen.c              | 20 ++++++++++++++++++++
 libwnck/screen.h              |  4 ++++
 libwnck/util.c                |  8 +-------
 libwnck/util.h                |  1 +
 libwnck/window.c              |  6 +++++-
 libwnck/wnck-handle-private.h |  2 --
 libwnck/wnck-handle.c         | 12 ++++++++++--
 libwnck/wnck-handle.h         |  3 +++
 libwnck/xutils.c              | 25 +++++++++++++++++++------
 libwnck/xutils.h              |  3 +++
 11 files changed, 66 insertions(+), 20 deletions(-)
---
diff --git a/libwnck/private.h b/libwnck/private.h
index f1a4af2..4e35c98 100644
--- a/libwnck/private.h
+++ b/libwnck/private.h
@@ -41,8 +41,6 @@ G_BEGIN_DECLS
 
 WnckHandle *_wnck_get_handle (void);
 
-WnckClientType _wnck_get_client_type (void);
-
 gsize _wnck_get_default_icon_size (void);
 gsize _wnck_get_default_mini_icon_size (void);
 
diff --git a/libwnck/screen.c b/libwnck/screen.c
index d6db387..e6364eb 100644
--- a/libwnck/screen.c
+++ b/libwnck/screen.c
@@ -69,6 +69,8 @@ static WnckScreen** screens = NULL;
 
 struct _WnckScreenPrivate
 {
+  WnckHandle *handle;
+
   int number;
   Window xroot;
   Screen *xscreen;
@@ -529,6 +531,8 @@ wnck_screen_construct (Display    *display,
                        WnckScreen *screen,
                        int         number)
 {
+  screen->priv->handle = _wnck_get_handle ();
+
   /* Create the initial state of the screen. */
   screen->priv->xroot = RootWindow (display, number);
   screen->priv->xscreen = ScreenOfDisplay (display, number);
@@ -674,6 +678,22 @@ wnck_screen_get_for_root (gulong root_window_id)
   return NULL;
 }
 
+/**
+ * wnck_screen_get_handle:
+ * @screen: a #WnckScreen.
+ *
+ * Gets the handle.
+ *
+ * Returns: (transfer none): a #WnckHandle, or %NULL.
+ */
+WnckHandle *
+wnck_screen_get_handle (WnckScreen *screen)
+{
+  g_return_val_if_fail (WNCK_IS_SCREEN (screen), NULL);
+
+  return screen->priv->handle;
+}
+
 /**
  * wnck_screen_get_number:
  * @screen: a #WnckScreen.
diff --git a/libwnck/screen.h b/libwnck/screen.h
index 3140ea5..153cf5f 100644
--- a/libwnck/screen.h
+++ b/libwnck/screen.h
@@ -33,6 +33,7 @@ G_BEGIN_DECLS
 /* forward decls */
 typedef struct _WnckApplication WnckApplication;
 typedef struct _WnckClassGroup  WnckClassGroup;
+typedef struct _WnckHandle      WnckHandle;
 typedef struct _WnckWindow      WnckWindow;
 typedef struct _WnckWorkspace   WnckWorkspace;
 
@@ -196,6 +197,9 @@ GType wnck_screen_get_type (void) G_GNUC_CONST;
 WnckScreen*    wnck_screen_get_default              (void);
 WnckScreen*    wnck_screen_get                      (int         index);
 WnckScreen*    wnck_screen_get_for_root             (gulong      root_window_id);
+
+WnckHandle*    wnck_screen_get_handle               (WnckScreen *screen);
+
 int            wnck_screen_get_number               (WnckScreen *screen);
 WnckWorkspace* wnck_screen_get_workspace            (WnckScreen *screen,
                                                      int         workspace);
diff --git a/libwnck/util.c b/libwnck/util.c
index e908a1c..c2c4147 100644
--- a/libwnck/util.c
+++ b/libwnck/util.c
@@ -668,18 +668,12 @@ _wnck_get_handle (void)
       if (client_type == 0)
         client_type = WNCK_CLIENT_TYPE_APPLICATION;
 
-      wnck_handle = _wnck_handle_new (client_type);
+      wnck_handle = wnck_handle_new (client_type);
     }
 
   return wnck_handle;
 }
 
-WnckClientType
-_wnck_get_client_type (void)
-{
-  return _wnck_handle_get_client_type (_wnck_get_handle ());
-}
-
 /**
  * wnck_set_default_icon_size:
  * @size: the default size for windows and application standard icons.
diff --git a/libwnck/util.h b/libwnck/util.h
index 8d0c77b..f17d37a 100644
--- a/libwnck/util.h
+++ b/libwnck/util.h
@@ -100,6 +100,7 @@ typedef enum {
   WNCK_CLIENT_TYPE_PAGER = 2
 } WnckClientType;
 
+G_DEPRECATED_FOR(wnck_handle_new)
 void wnck_set_client_type (WnckClientType ewmh_sourceindication_client_type);
 
 #define WNCK_DEFAULT_ICON_SIZE 32
diff --git a/libwnck/window.c b/libwnck/window.c
index 25c56a5..b26c020 100644
--- a/libwnck/window.c
+++ b/libwnck/window.c
@@ -33,6 +33,7 @@
 #include "xutils.h"
 #include "private.h"
 #include "wnck-enum-types.h"
+#include "wnck-handle-private.h"
 #include "wnck-icon-cache-private.h"
 
 /**
@@ -2362,12 +2363,15 @@ wnck_window_set_geometry (WnckWindow               *window,
                           int                       width,
                           int                       height)
 {
+  WnckHandle *handle;
   int gravity_and_flags;
   int source;
 
   g_return_if_fail (WNCK_IS_WINDOW (window));
 
-  source = _wnck_get_client_type();
+  handle = wnck_screen_get_handle (window->priv->screen);
+  source = _wnck_handle_get_client_type (handle);
+
   gravity_and_flags = gravity;
   gravity_and_flags |= geometry_mask << 8;
   gravity_and_flags |= source << 12;
diff --git a/libwnck/wnck-handle-private.h b/libwnck/wnck-handle-private.h
index bc3d6b1..3cbe0e6 100644
--- a/libwnck/wnck-handle-private.h
+++ b/libwnck/wnck-handle-private.h
@@ -23,8 +23,6 @@
 
 G_BEGIN_DECLS
 
-WnckHandle     *_wnck_handle_new                        (WnckClientType  client_type);
-
 WnckClientType  _wnck_handle_get_client_type            (WnckHandle     *self);
 
 void            _wnck_handle_set_default_icon_size      (WnckHandle     *self,
diff --git a/libwnck/wnck-handle.c b/libwnck/wnck-handle.c
index 9eaca94..dd068bb 100644
--- a/libwnck/wnck-handle.c
+++ b/libwnck/wnck-handle.c
@@ -237,8 +237,16 @@ wnck_handle_init (WnckHandle *self)
   gdk_window_add_filter (NULL, filter_func, self);
 }
 
-WnckHandle
-*_wnck_handle_new (WnckClientType client_type)
+/**
+ * wnck_handle_new:
+ * @client_type: a role for the client
+ *
+ * Creates a new #WnckHandle object with a given @client_type.
+ *
+ * Returns: (transfer full): newly created #WnckHandle.
+ */
+WnckHandle *
+wnck_handle_new (WnckClientType client_type)
 {
   return g_object_new (WNCK_TYPE_HANDLE,
                        "client-type", client_type,
diff --git a/libwnck/wnck-handle.h b/libwnck/wnck-handle.h
index 1bb2a27..08c100c 100644
--- a/libwnck/wnck-handle.h
+++ b/libwnck/wnck-handle.h
@@ -23,12 +23,15 @@
 #define WNCK_HANDLE_H
 
 #include <glib-object.h>
+#include <libwnck/util.h>
 
 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);
+
 G_END_DECLS
 
 #endif
diff --git a/libwnck/xutils.c b/libwnck/xutils.c
index 08e6325..f2a2d3c 100644
--- a/libwnck/xutils.c
+++ b/libwnck/xutils.c
@@ -30,6 +30,7 @@
 #include "screen.h"
 #include "window.h"
 #include "private.h"
+#include "wnck-handle-private.h"
 
 gboolean
 _wnck_get_cardinal (Screen *screen,
@@ -779,11 +780,13 @@ _wnck_close (WnckScreen *screen,
              Window      xwindow,
              Time        timestamp)
 {
+  WnckHandle *handle;
   Screen *xscreen;
   Display *display;
   Window root;
   XEvent xev;
 
+  handle = wnck_screen_get_handle (screen);
   xscreen = _wnck_screen_get_xscreen (screen);
   display = DisplayOfScreen (xscreen);
   root = RootWindowOfScreen (xscreen);
@@ -796,7 +799,7 @@ _wnck_close (WnckScreen *screen,
   xev.xclient.message_type = _wnck_atom_get ("_NET_CLOSE_WINDOW");
   xev.xclient.format = 32;
   xev.xclient.data.l[0] = timestamp;
-  xev.xclient.data.l[1] = _wnck_get_client_type ();
+  xev.xclient.data.l[1] = _wnck_handle_get_client_type (handle);
   xev.xclient.data.l[2] = 0;
   xev.xclient.data.l[3] = 0;
   xev.xclient.data.l[4] = 0;
@@ -826,11 +829,13 @@ void
 _wnck_keyboard_move (WnckScreen *screen,
                      Window      xwindow)
 {
+  WnckHandle *handle;
   Screen *xscreen;
   Display *display;
   Window root;
   XEvent xev;
 
+  handle = wnck_screen_get_handle (screen);
   xscreen = _wnck_screen_get_xscreen (screen);
   display = DisplayOfScreen (xscreen);
   root = RootWindowOfScreen (xscreen);
@@ -846,7 +851,7 @@ _wnck_keyboard_move (WnckScreen *screen,
   xev.xclient.data.l[1] = 0; /* unused */
   xev.xclient.data.l[2] = _NET_WM_MOVERESIZE_MOVE_KEYBOARD;
   xev.xclient.data.l[3] = 0; /* unused */
-  xev.xclient.data.l[4] = _wnck_get_client_type ();
+  xev.xclient.data.l[4] = _wnck_handle_get_client_type (handle);
 
   _wnck_error_trap_push (display);
   XSendEvent (display,
@@ -861,11 +866,13 @@ void
 _wnck_keyboard_size (WnckScreen *screen,
                      Window      xwindow)
 {
+  WnckHandle *handle;
   Screen *xscreen;
   Display *display;
   Window root;
   XEvent xev;
 
+  handle = wnck_screen_get_handle (screen);
   xscreen = _wnck_screen_get_xscreen (screen);
   display = DisplayOfScreen (xscreen);
   root = RootWindowOfScreen (xscreen);
@@ -881,7 +888,7 @@ _wnck_keyboard_size (WnckScreen *screen,
   xev.xclient.data.l[1] = 0; /* unused */
   xev.xclient.data.l[2] = _NET_WM_MOVERESIZE_SIZE_KEYBOARD;
   xev.xclient.data.l[3] = 0; /* unused */
-  xev.xclient.data.l[4] = _wnck_get_client_type ();
+  xev.xclient.data.l[4] = _wnck_handle_get_client_type (handle);
 
   _wnck_error_trap_push (display);
   XSendEvent (display,
@@ -899,6 +906,7 @@ _wnck_change_state (WnckScreen *screen,
                     Atom        state1,
                     Atom        state2)
 {
+  WnckHandle *handle;
   Screen *xscreen;
   Display *display;
   Window root;
@@ -908,6 +916,7 @@ _wnck_change_state (WnckScreen *screen,
 #define _NET_WM_STATE_ADD           1    /* add/set property */
 #define _NET_WM_STATE_TOGGLE        2    /* toggle property  */
 
+  handle = wnck_screen_get_handle (screen);
   xscreen = _wnck_screen_get_xscreen (screen);
   display = DisplayOfScreen (xscreen);
   root = RootWindowOfScreen (xscreen);
@@ -922,7 +931,7 @@ _wnck_change_state (WnckScreen *screen,
   xev.xclient.data.l[0] = add ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
   xev.xclient.data.l[1] = state1;
   xev.xclient.data.l[2] = state2;
-  xev.xclient.data.l[3] = _wnck_get_client_type ();
+  xev.xclient.data.l[3] = _wnck_handle_get_client_type (handle);
   xev.xclient.data.l[4] = 0;
 
   _wnck_error_trap_push (display);
@@ -939,11 +948,13 @@ _wnck_change_workspace (WnckScreen *screen,
                         Window      xwindow,
                         int         new_space)
 {
+  WnckHandle *handle;
   Screen *xscreen;
   Display *display;
   Window root;
   XEvent xev;
 
+  handle = wnck_screen_get_handle (screen);
   xscreen = _wnck_screen_get_xscreen (screen);
   display = DisplayOfScreen (xscreen);
   root = RootWindowOfScreen (xscreen);
@@ -956,7 +967,7 @@ _wnck_change_workspace (WnckScreen *screen,
   xev.xclient.message_type = _wnck_atom_get ("_NET_WM_DESKTOP");
   xev.xclient.format = 32;
   xev.xclient.data.l[0] = new_space;
-  xev.xclient.data.l[1] = _wnck_get_client_type ();
+  xev.xclient.data.l[1] = _wnck_handle_get_client_type (handle);
   xev.xclient.data.l[2] = 0;
   xev.xclient.data.l[3] = 0;
   xev.xclient.data.l[4] = 0;
@@ -975,6 +986,7 @@ _wnck_activate (WnckScreen *screen,
                 Window      xwindow,
                 Time        timestamp)
 {
+  WnckHandle *handle;
   Screen *xscreen;
   Display *display;
   Window root;
@@ -984,6 +996,7 @@ _wnck_activate (WnckScreen *screen,
     g_warning ("Received a timestamp of 0; window activation may not "
                "function properly.\n");
 
+  handle = wnck_screen_get_handle (screen);
   xscreen = _wnck_screen_get_xscreen (screen);
   display = DisplayOfScreen (xscreen);
   root = RootWindowOfScreen (xscreen);
@@ -995,7 +1008,7 @@ _wnck_activate (WnckScreen *screen,
   xev.xclient.window = xwindow;
   xev.xclient.message_type = _wnck_atom_get ("_NET_ACTIVE_WINDOW");
   xev.xclient.format = 32;
-  xev.xclient.data.l[0] = _wnck_get_client_type ();
+  xev.xclient.data.l[0] = _wnck_handle_get_client_type (handle);
   xev.xclient.data.l[1] = timestamp;
   xev.xclient.data.l[2] = 0;
   xev.xclient.data.l[3] = 0;
diff --git a/libwnck/xutils.h b/libwnck/xutils.h
index 4e5c620..951bd49 100644
--- a/libwnck/xutils.h
+++ b/libwnck/xutils.h
@@ -31,6 +31,9 @@
 
 G_BEGIN_DECLS
 
+/* forward decls */
+typedef struct _WnckScreen WnckScreen;
+
 #define WNCK_APP_WINDOW_EVENT_MASK (PropertyChangeMask | StructureNotifyMask)
 
 gboolean _wnck_get_cardinal      (Screen *screen,


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