diff options
author | Alberts Muktupāvels <alberts.muktupavels@gmail.com> | 2022-09-30 17:32:09 +0300 |
---|---|---|
committer | Alberts Muktupāvels <alberts.muktupavels@gmail.com> | 2022-09-30 18:07:18 +0300 |
commit | 4ee0ab2b0665da5cb0ad16d6d163ad20549b7ba6 (patch) | |
tree | 14d855f79cf6d8084047a0501e31f1031b0378ef | |
parent | 143148b64bbee8be9351e75ce3d2d4ad9ceff77d (diff) | |
download | libwnck-4ee0ab2b0665da5cb0ad16d6d163ad20549b7ba6.tar.gz |
handle: init XRes extension
XResQueryClientIds needs XRes 1.2 or newer.
-rw-r--r-- | libwnck/wnck-handle-private.h | 2 | ||||
-rw-r--r-- | libwnck/wnck-handle.c | 48 | ||||
-rw-r--r-- | meson.build | 2 |
3 files changed, 51 insertions, 1 deletions
diff --git a/libwnck/wnck-handle-private.h b/libwnck/wnck-handle-private.h index c4217ce..0633104 100644 --- a/libwnck/wnck-handle-private.h +++ b/libwnck/wnck-handle-private.h @@ -26,6 +26,8 @@ G_BEGIN_DECLS WnckClientType _wnck_handle_get_client_type (WnckHandle *self); +gboolean _wnck_handle_has_xres (WnckHandle *self); + gsize _wnck_handle_get_default_icon_size (WnckHandle *self); gsize _wnck_handle_get_default_mini_icon_size (WnckHandle *self); diff --git a/libwnck/wnck-handle.c b/libwnck/wnck-handle.c index e12ff88..710b754 100644 --- a/libwnck/wnck-handle.c +++ b/libwnck/wnck-handle.c @@ -29,6 +29,11 @@ #include "config.h" #include "wnck-handle-private.h" +#include <X11/Xlib.h> +#ifdef HAVE_XRES +#include <X11/extensions/XRes.h> +#endif + #include "private.h" #include "screen.h" #include "window.h" @@ -43,6 +48,8 @@ struct _WnckHandle WnckClientType client_type; + gboolean have_xres; + gsize default_icon_size; gsize default_mini_icon_size; @@ -165,6 +172,40 @@ filter_func (GdkXEvent *gdkxevent, } static void +init_xres (WnckHandle *self) +{ +#ifdef HAVE_XRES + Display *xdisplay; + int event_base; + int error_base; + int major; + int minor; + + xdisplay = _wnck_get_default_display (); + event_base = error_base = major = minor = 0; + + if (XResQueryExtension (xdisplay, &event_base, &error_base) && + XResQueryVersion (xdisplay, &major, &minor) == 1) + { + if (major > 1 || (major == 1 && minor >= 2)) + self->have_xres = TRUE; + } +#endif +} + +static void +wnck_handle_constructed (GObject *object) +{ + WnckHandle *self; + + self = WNCK_HANDLE (object); + + G_OBJECT_CLASS (wnck_handle_parent_class)->constructed (object); + + init_xres (self); +} + +static void wnck_handle_finalize (GObject *object) { WnckHandle *self; @@ -290,6 +331,7 @@ wnck_handle_class_init (WnckHandleClass *self_class) object_class = G_OBJECT_CLASS (self_class); + object_class->constructed = wnck_handle_constructed; object_class->finalize = wnck_handle_finalize; object_class->get_property = wnck_handle_get_property; object_class->set_property = wnck_handle_set_property; @@ -343,6 +385,12 @@ _wnck_handle_get_client_type (WnckHandle *self) return self->client_type; } +gboolean +_wnck_handle_has_xres (WnckHandle *self) +{ + return self->have_xres; +} + /** * wnck_handle_get_default_screen: * @self: a #WnckHandle diff --git a/meson.build b/meson.build index 6b0eea9..907fdf2 100644 --- a/meson.build +++ b/meson.build @@ -45,7 +45,7 @@ pkg_deps = [ {'name': 'gtk+-3.0', 'version': '>= 3.22.0' }, {'name': STARTUP_NOTIFICATION_PACKAGE, 'version': '>= 0.4', 'required': get_option('startup_notification')}, {'name': X11_PACKAGE }, - {'name': XRES_PACKAGE, 'required': false}, + {'name': XRES_PACKAGE, 'version': '>= 1.2', 'required': false}, ] foreach p: pkg_deps |