[libwnck/wip/muktupavels/wnck-handle: 37/44] add wnck_handle_new and deprecate wnck_set_client_type
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libwnck/wip/muktupavels/wnck-handle: 37/44] add wnck_handle_new and deprecate wnck_set_client_type
- Date: Mon, 10 May 2021 17:57:03 +0000 (UTC)
commit 2937fc7c47567601e9f676775d217617233034dc
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 48e7c77..1eec498 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);
@@ -675,6 +679,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 b3d8750..e08fabc 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 ());
-}
-
static gsize default_icon_size = WNCK_DEFAULT_ICON_SIZE;
/**
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 66a4386..cd72e96 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"
/**
* SECTION:window
@@ -2361,12 +2362,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 fc3b0cc..6571f1c 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);
G_END_DECLS
diff --git a/libwnck/wnck-handle.c b/libwnck/wnck-handle.c
index 3b6bd0c..a8a7cb1 100644
--- a/libwnck/wnck-handle.c
+++ b/libwnck/wnck-handle.c
@@ -126,8 +126,16 @@ wnck_handle_init (WnckHandle *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 12362d8..874d3ba 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 8c14234..c9ba814 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,
@@ -886,11 +887,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);
@@ -903,7 +906,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;
@@ -933,11 +936,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);
@@ -953,7 +958,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,
@@ -968,11 +973,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);
@@ -988,7 +995,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,
@@ -1006,6 +1013,7 @@ _wnck_change_state (WnckScreen *screen,
Atom state1,
Atom state2)
{
+ WnckHandle *handle;
Screen *xscreen;
Display *display;
Window root;
@@ -1015,6 +1023,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);
@@ -1029,7 +1038,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);
@@ -1046,11 +1055,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);
@@ -1063,7 +1074,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;
@@ -1082,6 +1093,7 @@ _wnck_activate (WnckScreen *screen,
Window xwindow,
Time timestamp)
{
+ WnckHandle *handle;
Screen *xscreen;
Display *display;
Window root;
@@ -1091,6 +1103,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);
@@ -1102,7 +1115,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 e5ef85d..b2db9ca 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]