[Xfce4-commits] <xfce4-settings:master> Fix the check for Xi so it does not fail with Xi2 (bug #4929).

Nick Schermer noreply at xfce.org
Sun Oct 11 14:26:04 CEST 2009


Updating branch refs/heads/master
         to 22bc922adac9f1d87dc5114ea4f65bc027932baa (commit)
       from a562d10e2dbf0bdc67a99154b4860832dea5ed6c (commit)

commit 22bc922adac9f1d87dc5114ea4f65bc027932baa
Author: Nick Schermer <nick at xfce.org>
Date:   Sun Oct 11 13:46:56 2009 +0200

    Fix the check for Xi so it does not fail with Xi2 (bug #4929).

 dialogs/mouse-settings/main.c    |   22 +++++++++++++++++-----
 xfce4-settings-helper/pointers.c |   28 ++++++++++++++++++----------
 2 files changed, 35 insertions(+), 15 deletions(-)

diff --git a/dialogs/mouse-settings/main.c b/dialogs/mouse-settings/main.c
index 21d6733..2f684ad 100644
--- a/dialogs/mouse-settings/main.c
+++ b/dialogs/mouse-settings/main.c
@@ -59,6 +59,10 @@
 #define IsXExtensionPointer 4
 #endif
 
+/* Xi 1.4 is required */
+#define MIN_XI_VERS_MAJOR 1
+#define MIN_XI_VERS_MINOR 4
+
 /* settings */
 #ifdef HAVE_XCURSOR
 #define PREVIEW_ROWS    (3)
@@ -1215,16 +1219,24 @@ main (gint argc, gchar **argv)
         return EXIT_FAILURE;
     }
 
-    /* check for Xi 1.4 */
+    /* check for Xi */
     version = XGetExtensionVersion (GDK_DISPLAY (), INAME);
-    if (!version || !version->present || version->major_version < 1 || version->minor_version < 4)
+    if (version == NULL || !version->present)
     {
-        g_critical ("XI is not present or too old.");
-
+        g_critical ("XI is not present.");
+        return EXIT_FAILURE;
+    }
+    else if (version->major_version < MIN_XI_VERS_MAJOR
+             || (version->major_version == MIN_XI_VERS_MAJOR
+                 && version->minor_version < MIN_XI_VERS_MINOR))
+    {
+        g_critical ("Your XI is too old (%d.%d) version %d.%d is required.",
+                    version->major_version, version->minor_version,
+                    MIN_XI_VERS_MAJOR, MIN_XI_VERS_MINOR);
         return EXIT_FAILURE;
     }
 
-     /* hook to make sure the libxfce4ui library is linked */
+    /* hook to make sure the libxfce4ui library is linked */
     if (xfce_titled_dialog_get_type () == 0)
         return EXIT_FAILURE;
 
diff --git a/xfce4-settings-helper/pointers.c b/xfce4-settings-helper/pointers.c
index 300ed99..aaa81ba 100644
--- a/xfce4-settings-helper/pointers.c
+++ b/xfce4-settings-helper/pointers.c
@@ -42,6 +42,10 @@
 
 #define MAX_DENOMINATOR (100.00)
 
+/* Xi 1.4 is required */
+#define MIN_XI_VERS_MAJOR 1
+#define MIN_XI_VERS_MINOR 4
+
 /* test if the required version of inputproto (1.4.2) is available */
 #if XI_Add_DevicePresenceNotify_Major >= 1 && defined (DeviceRemoved)
 #define HAS_DEVICE_HOTPLUGGING
@@ -131,18 +135,22 @@ xfce_pointers_helper_init (XfcePointersHelper *helper)
 
     /* get the default display */
     xdisplay = gdk_x11_display_get_xdisplay (gdk_display_get_default ());
-    
+
     /* query the extension version */
     version = XGetExtensionVersion (xdisplay, INAME);
-    
-    /* check for Xi 1.4 */
-    if (!version || !version->present || version->major_version < 1 || version->minor_version < 4)
-    {
-        /* print error */
-        g_critical ("XI is not present or too old.");
 
-        /* no channel */
-        helper->channel = NULL;
+    /* check for Xi */
+    if (version == NULL || !version->present)
+    {
+        g_critical ("XI is not present.");
+    }
+    else if (version->major_version < MIN_XI_VERS_MAJOR
+             || (version->major_version == MIN_XI_VERS_MAJOR
+                 && version->minor_version < MIN_XI_VERS_MINOR))
+    {
+        g_critical ("Your XI is too old (%d.%d) version %d.%d is required.",
+                    version->major_version, version->minor_version,
+                    MIN_XI_VERS_MAJOR, MIN_XI_VERS_MINOR);
     }
     else
     {
@@ -160,7 +168,7 @@ xfce_pointers_helper_init (XfcePointersHelper *helper)
         gdk_flush ();
         gdk_error_trap_push ();
 
-        
+
         if (G_LIKELY (xdisplay))
         {
             /* monitor device changes */



More information about the Xfce4-commits mailing list