]> git.eshelyaron.com Git - emacs.git/commitdiff
Test for Xkb support when opening a display
authorPo Lu <luangruo@yahoo.com>
Wed, 29 Dec 2021 09:49:42 +0000 (17:49 +0800)
committerPo Lu <luangruo@yahoo.com>
Wed, 29 Dec 2021 09:49:42 +0000 (17:49 +0800)
* src/xfns.c (Fx_backspace_delete_keys_p): Use
dpyinfo->supports_xkb instead of testing for its presence
manually.

* src/xterm.c (x_term_init): Test for Xkb presence
and set supports_xkb appropriately.

* src/xterm.h (struct x_display_info): New field `supports_xkb'.

src/xfns.c
src/xterm.c
src/xterm.h

index 8dc383ddfa8e270760e1be9290651fec941cf6f3..ae01bb040536299d8131877cd0174de1fcc16915 100644 (file)
@@ -7748,27 +7748,11 @@ present and mapped to the usual X keysyms.  */)
   struct frame *f = decode_window_system_frame (frame);
   Display *dpy = FRAME_X_DISPLAY (f);
   Lisp_Object have_keys;
-  int major, minor, op, event, error_code;
 
   block_input ();
 
-  /* Check library version in case we're dynamically linked.  */
-  major = XkbMajorVersion;
-  minor = XkbMinorVersion;
-  if (!XkbLibraryVersion (&major, &minor))
-    {
-      unblock_input ();
-      return Qlambda;
-    }
-
-  /* Check that the server supports XKB.  */
-  major = XkbMajorVersion;
-  minor = XkbMinorVersion;
-  if (!XkbQueryExtension (dpy, &op, &event, &error_code, &major, &minor))
-    {
-      unblock_input ();
-      return Qlambda;
-    }
+  if (!FRAME_DISPLAY_INFO (f)->supports_xkb)
+    return Qlambda;
 
   /* In this code we check that the keyboard has physical keys with names
      that start with BKSP (Backspace) and DELE (Delete), and that they
index e3079727d5da6b85ccb4f1f2d0a1031a9505d03b..61dff7aaab66d807f35f60fbe339b1cde3b6f6f9 100644 (file)
@@ -14887,9 +14887,19 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
 #endif
 
 #ifdef HAVE_XKB
-  dpyinfo->xkb_desc = XkbGetMap (dpyinfo->display,
-                                XkbAllComponentsMask,
-                                XkbUseCoreKbd);
+  int xkb_major, xkb_minor, xkb_op, xkb_event, xkb_error_code;
+  xkb_major = XkbMajorVersion;
+  xkb_minor = XkbMinorVersion;
+
+  if (XkbLibraryVersion (&xkb_major, &xkb_minor)
+      && XkbQueryExtension (dpyinfo->display, &xkb_op, &xkb_event,
+                           &xkb_error_code, &xkb_major, &xkb_minor))
+    {
+      dpyinfo->supports_xkb = true;
+      dpyinfo->xkb_desc = XkbGetMap (dpyinfo->display,
+                                    XkbAllComponentsMask,
+                                    XkbUseCoreKbd);
+    }
 #endif
 
 #if defined USE_CAIRO || defined HAVE_XFT
index 5615a55d6b96a1b953208f83bd7f551ea656f2b1..a233e28dbeba6092189b22aade9d9b15bb89d15a 100644 (file)
@@ -522,6 +522,7 @@ struct x_display_info
 #endif
 
 #ifdef HAVE_XKB
+  bool supports_xkb;
   XkbDescPtr xkb_desc;
 #endif
 };