[metacity] display: check if XRes extension is available



commit 700d4aa07793740bf4b92c09f4aa0a97aca04bd6
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Fri Sep 30 16:38:02 2022 +0300

    display: check if XRes extension is available
    
    We are using XResQueryClientIds that is available in 1.2 version.

 configure.ac               |  3 ++-
 src/core/display-private.h |  2 ++
 src/core/display.c         | 21 +++++++++++++++++++++
 3 files changed, 25 insertions(+), 1 deletion(-)
---
diff --git a/configure.ac b/configure.ac
index 8925a08c..2e462465 100644
--- a/configure.ac
+++ b/configure.ac
@@ -93,6 +93,7 @@ GLIB_REQUIRED_VERSION=2.67.3
 GTK_REQUIRED_VERSION=3.24.6
 PANGO_REQUIRED_VERSION=1.2.0
 XCOMPOSITE_REQUIRED_VERSION=0.3
+XRES_REQUIRED_VERSION=1.2
 
 PKG_CHECK_MODULES([LIBMETACITY], [
   glib-2.0 >= $GLIB_REQUIRED_VERSION
@@ -154,7 +155,7 @@ AC_CHECK_SIZEOF(__int64)
 ## byte order
 AC_C_BIGENDIAN
 
-METACITY_PC_MODULES="gtk+-3.0 >= $GTK_REQUIRED_VERSION gio-2.0 >= $GLIB_REQUIRED_VERSION pango >= 
$PANGO_REQUIRED_VERSION gsettings-desktop-schemas >= 3.3.0 xcomposite >= $XCOMPOSITE_REQUIRED_VERSION xfixes 
xrender xdamage xres xpresent"
+METACITY_PC_MODULES="gtk+-3.0 >= $GTK_REQUIRED_VERSION gio-2.0 >= $GLIB_REQUIRED_VERSION pango >= 
$PANGO_REQUIRED_VERSION gsettings-desktop-schemas >= 3.3.0 xcomposite >= $XCOMPOSITE_REQUIRED_VERSION xfixes 
xrender xdamage xres >= $XRES_REQUIRED_VERSION xpresent"
 
 GLIB_GSETTINGS
 
diff --git a/src/core/display-private.h b/src/core/display-private.h
index 805bd429..8e8a319c 100644
--- a/src/core/display-private.h
+++ b/src/core/display-private.h
@@ -276,6 +276,8 @@ struct _MetaDisplay
 #define META_DISPLAY_HAS_DAMAGE(display) ((display)->have_damage)
   unsigned int have_xfixes : 1;
 #define META_DISPLAY_HAS_XFIXES(display) ((display)->have_xfixes)
+  unsigned int have_xres : 1;
+#define META_DISPLAY_HAS_XRES(display) ((display)->have_xres)
 };
 
 /* Xserver time can wraparound, thus comparing two timestamps needs to take
diff --git a/src/core/display.c b/src/core/display.c
index ff909a62..17a4eaf7 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -64,6 +64,7 @@
 #include <X11/extensions/Xcomposite.h>
 #include <X11/extensions/Xdamage.h>
 #include <X11/extensions/Xfixes.h>
+#include <X11/extensions/XRes.h>
 #include <string.h>
 
 #include "compositor/meta-compositor-none.h"
@@ -687,6 +688,26 @@ meta_display_open (void)
                   the_display->xfixes_event_base);
   }
 
+  {
+    int event_base;
+    int error_base;
+    int major;
+    int minor;
+
+    event_base = error_base = major = minor = 0;
+    the_display->have_xres = FALSE;
+
+    if (XResQueryExtension (the_display->xdisplay, &event_base, &error_base) &&
+        XResQueryVersion (the_display->xdisplay, &major, &minor) == 1)
+      {
+        if (major > 1 || (major == 1 && minor >= 2))
+          the_display->have_xres = TRUE;
+      }
+
+    meta_verbose ("Attempted to init XRes, found version %d.%d error base %d event base %d\n",
+                  major, minor, error_base, event_base);
+  }
+
 #ifdef HAVE_XCURSOR
   {
     XcursorSetTheme (the_display->xdisplay, meta_prefs_get_cursor_theme ());


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]