diff options
author | Alberts Muktupāvels <alberts.muktupavels@gmail.com> | 2019-08-19 17:29:54 +0300 |
---|---|---|
committer | Alberts Muktupāvels <alberts.muktupavels@gmail.com> | 2021-09-16 18:16:53 +0300 |
commit | e7272255fb1264d0a1779d676ca470ada42357a4 (patch) | |
tree | 775cfbb2378670ae50694a45ec1929382e10abda | |
parent | fff8f6435984e52e368b5ebe6ff340f7873d0537 (diff) | |
download | libwnck-e7272255fb1264d0a1779d676ca470ada42357a4.tar.gz |
add wnck_handle_new and deprecate wnck_set_client_type
-rw-r--r-- | libwnck/private.h | 2 | ||||
-rw-r--r-- | libwnck/screen.c | 20 | ||||
-rw-r--r-- | libwnck/screen.h | 4 | ||||
-rw-r--r-- | libwnck/util.c | 8 | ||||
-rw-r--r-- | libwnck/util.h | 1 | ||||
-rw-r--r-- | libwnck/window.c | 6 | ||||
-rw-r--r-- | libwnck/wnck-handle-private.h | 2 | ||||
-rw-r--r-- | libwnck/wnck-handle.c | 12 | ||||
-rw-r--r-- | libwnck/wnck-handle.h | 3 | ||||
-rw-r--r-- | libwnck/xutils.c | 25 | ||||
-rw-r--r-- | libwnck/xutils.h | 3 |
11 files changed, 67 insertions, 19 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); @@ -675,6 +679,22 @@ wnck_screen_get_for_root (gulong root_window_id) } /** + * 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..c79eb6d 100644 --- a/libwnck/util.c +++ b/libwnck/util.c @@ -668,17 +668,13 @@ _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; /** * wnck_set_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 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, |