From 2c0d3843a9e77f849f5f02a8b0ca9253a467e13e Mon Sep 17 00:00:00 2001 From: Joakim Tjernlund Date: Mon, 19 Dec 2022 16:59:06 +0100 Subject: Test Xres 1.2 is present Before using any Xres extension one must call XResQueryExtension() Also make sure Xres 1.2 is available as marco need XResQueryClientIds() --- src/core/display-private.h | 1 + src/core/display.c | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/core/display-private.h b/src/core/display-private.h index 0352c2ad..62be08ce 100644 --- a/src/core/display-private.h +++ b/src/core/display-private.h @@ -80,6 +80,7 @@ typedef enum { struct _MetaDisplay { char* name; Display* xdisplay; + gboolean have_xres; /* Got XRES >= 1.2 */ Window leader_window; Window timestamp_pinging_window; diff --git a/src/core/display.c b/src/core/display.c index 7edf41b8..b3552cc9 100644 --- a/src/core/display.c +++ b/src/core/display.c @@ -50,6 +50,7 @@ #include "compositor.h" #include #include +#include #ifdef HAVE_SOLARIS_XINERAMA #include @@ -329,7 +330,8 @@ meta_display_open (void) Display *xdisplay; GSList *screens; GSList *tmp; - int i; + int i, event_base, error_base, major, minor; + gboolean have_xres = FALSE; guint32 timestamp; /* A list of all atom names, so that we can intern them in one go. */ @@ -343,6 +345,7 @@ meta_display_open (void) meta_verbose ("Opening display '%s'\n", XDisplayName (NULL)); xdisplay = meta_ui_get_display (); + event_base = error_base = major = minor = 0; if (xdisplay == NULL) { @@ -350,7 +353,13 @@ meta_display_open (void) XDisplayName (NULL)); return FALSE; } - + /* Make sure to init Xres any extensions */ + if (XResQueryExtension(xdisplay, &event_base, &error_base) && + XResQueryVersion (xdisplay, &major, &minor) == 1) + { + if (major > 1 || (major == 1 && minor >= 2)) + have_xres = TRUE; + } if (meta_is_syncing ()) XSynchronize (xdisplay, True); @@ -365,6 +374,7 @@ meta_display_open (void) */ the_display->name = g_strdup (XDisplayName (NULL)); the_display->xdisplay = xdisplay; + the_display->have_xres = have_xres; the_display->error_trap_synced_at_last_pop = TRUE; the_display->error_traps = 0; the_display->error_trap_handler = NULL; -- cgit v1.2.1