530.41.03-10: linux 6.3.1.arch2-1
[arch-packages.git] / libwnck3 / trunk / 0002-handle-init-XRes-extension.patch
blobbdde146aeb79eaa6d4aa8b92f870c1a2eb89537a
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.
7 ---
8 libwnck/wnck-handle-private.h | 2 ++
9 libwnck/wnck-handle.c | 48 +++++++++++++++++++++++++++++++++++
10 meson.build | 2 +-
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
30 @@ -29,20 +29,27 @@
31 #include "config.h"
32 #include "wnck-handle-private.h"
34 +#include <X11/Xlib.h>
35 +#ifdef HAVE_XRES
36 +#include <X11/extensions/XRes.h>
37 +#endif
39 #include "private.h"
40 #include "screen.h"
41 #include "window.h"
42 #include "wnck-enum-types.h"
43 #include "xutils.h"
45 struct _WnckHandle
47 GObject parent;
49 WnckScreen **screens;
51 WnckClientType client_type;
53 + gboolean have_xres;
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;
62 +static void
63 +init_xres (WnckHandle *self)
65 +#ifdef HAVE_XRES
66 + Display *xdisplay;
67 + int event_base;
68 + int error_base;
69 + int major;
70 + int minor;
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)
77 + {
78 + if (major > 1 || (major == 1 && minor >= 2))
79 + self->have_xres = TRUE;
80 + }
81 +#endif
84 +static void
85 +wnck_handle_constructed (GObject *object)
87 + WnckHandle *self;
89 + self = WNCK_HANDLE (object);
91 + G_OBJECT_CLASS (wnck_handle_parent_class)->constructed (object);
93 + init_xres (self);
96 static void
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;
111 +gboolean
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
122 --- a/meson.build
123 +++ b/meson.build
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},
132 foreach p: pkg_deps