emacs-diffs
[Top][All Lists]
Advanced

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

master 1f00710ecf: Fix X errors caused by GTK using newer versions of XI


From: Po Lu
Subject: master 1f00710ecf: Fix X errors caused by GTK using newer versions of XI2 than Emacs
Date: Tue, 22 Feb 2022 19:57:51 -0500 (EST)

branch: master
commit 1f00710ecfac12de12f4a2046b9b66802b8ffac6
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Fix X errors caused by GTK using newer versions of XI2 than Emacs
    
    * src/xterm.c (x_term_init): Handle errors from XIQueryVersion
    caused by Emacs requesting versions of XI2 older than 2.2 and
    what GTK requested.
---
 src/xterm.c | 33 +++++++++++++++++++++++++++++++--
 1 file changed, 31 insertions(+), 2 deletions(-)

diff --git a/src/xterm.c b/src/xterm.c
index 23721352f3..fffa40840a 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -16264,6 +16264,8 @@ x_term_init (Lisp_Object display_name, char 
*xrm_option, char *resource_name)
   dpyinfo->supports_xi2 = false;
   int rc;
   int major = 2;
+  int xi_first_event, xi_first_error;
+
 #ifdef HAVE_XINPUT2_4
   int minor = 4;
 #elif defined HAVE_XINPUT2_3 /* XInput 2.3 */
@@ -16275,12 +16277,39 @@ x_term_init (Lisp_Object display_name, char 
*xrm_option, char *resource_name)
 #else /* Some old version of XI2 we're not interested in. */
   int minor = 0;
 #endif
-  int fer, fee;
 
   if (XQueryExtension (dpyinfo->display, "XInputExtension",
-                      &dpyinfo->xi2_opcode, &fer, &fee))
+                      &dpyinfo->xi2_opcode, &xi_first_event,
+                      &xi_first_error))
     {
+#ifdef HAVE_GTK3
+    query:
+      /* Catch errors caused by GTK requesting a different version of
+        XInput 2 than what Emacs was built with.  */
+      x_catch_errors (dpyinfo->display);
+#endif
+
       rc = XIQueryVersion (dpyinfo->display, &major, &minor);
+
+#ifdef HAVE_GTK3
+      if (x_had_errors_p (dpyinfo->display))
+       {
+         /* Some unreasonable value that will probably not be
+            exceeded in the future.  */
+         if (minor > 100)
+           rc = BadRequest;
+         else
+           {
+             /* Increase the minor version until we find one the X server
+                agrees with.  */
+             minor++;
+             goto query;
+           }
+       }
+
+      x_uncatch_errors ();
+#endif
+
       if (rc == Success)
        {
          dpyinfo->supports_xi2 = true;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]