1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Alberts=20Muktup=C4=81vels?= <alberts.muktupavels@gmail.com>
3 Date: Fri, 30 Sep 2022 17:32:09 +0300
4 Subject: [PATCH] handle: init XRes extension
6 XResQueryClientIds needs XRes 1.2 or newer.
8 libwnck/wnck-handle-private.h | 2 ++
9 libwnck/wnck-handle.c | 48 +++++++++++++++++++++++++++++++++++
11 3 files changed, 51 insertions(+), 1 deletion(-)
13 diff --git a/libwnck/wnck-handle-private.h b/libwnck/wnck-handle-private.h
14 index c4217cefd277..063310400934 100644
15 --- a/libwnck/wnck-handle-private.h
16 +++ b/libwnck/wnck-handle-private.h
17 @@ -26,6 +26,8 @@ G_BEGIN_DECLS
19 WnckClientType _wnck_handle_get_client_type (WnckHandle *self);
21 +gboolean _wnck_handle_has_xres (WnckHandle *self);
23 gsize _wnck_handle_get_default_icon_size (WnckHandle *self);
25 gsize _wnck_handle_get_default_mini_icon_size (WnckHandle *self);
26 diff --git a/libwnck/wnck-handle.c b/libwnck/wnck-handle.c
27 index 8d5da45c8787..fa11d3d16cd1 100644
28 --- a/libwnck/wnck-handle.c
29 +++ b/libwnck/wnck-handle.c
32 #include "wnck-handle-private.h"
34 +#include <X11/Xlib.h>
36 +#include <X11/extensions/XRes.h>
42 #include "wnck-enum-types.h"
51 WnckClientType client_type;
55 gsize default_icon_size;
56 gsize default_mini_icon_size;
58 @@ -167,6 +174,40 @@ filter_func (GdkXEvent *gdkxevent,
59 return GDK_FILTER_CONTINUE;
63 +init_xres (WnckHandle *self)
72 + xdisplay = _wnck_get_default_display ();
73 + event_base = error_base = major = minor = 0;
75 + if (XResQueryExtension (xdisplay, &event_base, &error_base) &&
76 + XResQueryVersion (xdisplay, &major, &minor) == 1)
78 + if (major > 1 || (major == 1 && minor >= 2))
79 + self->have_xres = TRUE;
85 +wnck_handle_constructed (GObject *object)
89 + self = WNCK_HANDLE (object);
91 + G_OBJECT_CLASS (wnck_handle_parent_class)->constructed (object);
97 wnck_handle_finalize (GObject *object)
99 @@ -293,6 +334,7 @@ wnck_handle_class_init (WnckHandleClass *self_class)
101 object_class = G_OBJECT_CLASS (self_class);
103 + object_class->constructed = wnck_handle_constructed;
104 object_class->finalize = wnck_handle_finalize;
105 object_class->get_property = wnck_handle_get_property;
106 object_class->set_property = wnck_handle_set_property;
107 @@ -346,6 +388,12 @@ _wnck_handle_get_client_type (WnckHandle *self)
108 return self->client_type;
112 +_wnck_handle_has_xres (WnckHandle *self)
114 + return self->have_xres;
118 * wnck_handle_get_default_screen:
119 * @self: a #WnckHandle
120 diff --git a/meson.build b/meson.build
121 index 6b0eea97af5b..907fdf269e7e 100644
124 @@ -45,7 +45,7 @@ pkg_deps = [
125 {'name': 'gtk+-3.0', 'version': '>= 3.22.0' },
126 {'name': STARTUP_NOTIFICATION_PACKAGE, 'version': '>= 0.4', 'required': get_option('startup_notification')},
127 {'name': X11_PACKAGE },
128 - {'name': XRES_PACKAGE, 'required': false},
129 + {'name': XRES_PACKAGE, 'version': '>= 1.2', 'required': false},