emacs-diffs
[Top][All Lists]
Advanced

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

master e425b7d231: Allow disabling the input extension at runtime on GTK


From: Po Lu
Subject: master e425b7d231: Allow disabling the input extension at runtime on GTK 3
Date: Mon, 22 Aug 2022 21:31:44 -0400 (EDT)

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

    Allow disabling the input extension at runtime on GTK 3
    
    * src/xterm.c (xi_check_toolkit): New function.
    (x_term_init): Do not enable the input extension should that
    fail.
---
 src/xterm.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 47 insertions(+), 2 deletions(-)

diff --git a/src/xterm.c b/src/xterm.c
index 103573d1fd..8f0a7ffaaa 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -27737,6 +27737,42 @@ xi_select_hierarchy_events (struct x_display_info 
*dpyinfo)
 
 #endif
 
+#if defined HAVE_XINPUT2 && defined HAVE_GTK3
+
+/* Look up whether or not GTK already initialized the X input
+   extension.
+
+   Value is 0 if GTK was not built with the input extension, or if it
+   was explictly disabled, 1 if GTK enabled the input extension and
+   the version was successfully determined, and 2 if that information
+   could not be determined.  */
+
+static int
+xi_check_toolkit (Display *display)
+{
+  GdkDisplay *gdpy;
+  GdkDeviceManager *manager;
+
+  gdpy = gdk_x11_lookup_xdisplay (display);
+  eassume (gdpy);
+  manager = gdk_display_get_device_manager (gdpy);
+
+  if (!strcmp (G_OBJECT_TYPE_NAME (manager),
+              "GdkX11DeviceManagerXI2"))
+    return 1;
+
+  if (!strcmp (G_OBJECT_TYPE_NAME (manager),
+              "GdkX11DeviceManagerCore"))
+    return 0;
+
+  /* Something changed in GDK so this information is no longer
+     available.  */
+
+  return 2;
+}
+
+#endif
+
 /* Open a connection to X display DISPLAY_NAME, and return
    the structure that describes the open display.
    If we cannot contact the display, return null.  */
@@ -28281,6 +28317,17 @@ x_term_init (Lisp_Object display_name, char 
*xrm_option, char *resource_name)
 
   dpyinfo->client_pointer_device = -1;
 
+#ifdef HAVE_GTK3
+  /* GTK gets a chance to request use of the input extension first.
+     If we later try to enable it if GDK did not, then GTK will not
+     get the resulting extension events.  */
+
+  rc = xi_check_toolkit (dpyinfo->display);
+
+  if (!rc)
+    goto skip_xi_setup;
+#endif
+
   if (XQueryExtension (dpyinfo->display, "XInputExtension",
                       &dpyinfo->xi2_opcode, &xi_first_event,
                       &xi_first_error))
@@ -28377,9 +28424,7 @@ x_term_init (Lisp_Object display_name, char 
*xrm_option, char *resource_name)
     }
 
   dpyinfo->xi2_version = minor;
-#ifndef HAVE_GTK3
  skip_xi_setup:
-#endif
   ;
 #endif
 



reply via email to

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