aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/xterm.c49
1 files changed, 47 insertions, 2 deletions
diff --git a/src/xterm.c b/src/xterm.c
index 103573d1fdc..8f0a7ffaaa7 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -27737,6 +27737,42 @@ xi_select_hierarchy_events (struct x_display_info *dpyinfo)
27737 27737
27738#endif 27738#endif
27739 27739
27740#if defined HAVE_XINPUT2 && defined HAVE_GTK3
27741
27742/* Look up whether or not GTK already initialized the X input
27743 extension.
27744
27745 Value is 0 if GTK was not built with the input extension, or if it
27746 was explictly disabled, 1 if GTK enabled the input extension and
27747 the version was successfully determined, and 2 if that information
27748 could not be determined. */
27749
27750static int
27751xi_check_toolkit (Display *display)
27752{
27753 GdkDisplay *gdpy;
27754 GdkDeviceManager *manager;
27755
27756 gdpy = gdk_x11_lookup_xdisplay (display);
27757 eassume (gdpy);
27758 manager = gdk_display_get_device_manager (gdpy);
27759
27760 if (!strcmp (G_OBJECT_TYPE_NAME (manager),
27761 "GdkX11DeviceManagerXI2"))
27762 return 1;
27763
27764 if (!strcmp (G_OBJECT_TYPE_NAME (manager),
27765 "GdkX11DeviceManagerCore"))
27766 return 0;
27767
27768 /* Something changed in GDK so this information is no longer
27769 available. */
27770
27771 return 2;
27772}
27773
27774#endif
27775
27740/* Open a connection to X display DISPLAY_NAME, and return 27776/* Open a connection to X display DISPLAY_NAME, and return
27741 the structure that describes the open display. 27777 the structure that describes the open display.
27742 If we cannot contact the display, return null. */ 27778 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)
28281 28317
28282 dpyinfo->client_pointer_device = -1; 28318 dpyinfo->client_pointer_device = -1;
28283 28319
28320#ifdef HAVE_GTK3
28321 /* GTK gets a chance to request use of the input extension first.
28322 If we later try to enable it if GDK did not, then GTK will not
28323 get the resulting extension events. */
28324
28325 rc = xi_check_toolkit (dpyinfo->display);
28326
28327 if (!rc)
28328 goto skip_xi_setup;
28329#endif
28330
28284 if (XQueryExtension (dpyinfo->display, "XInputExtension", 28331 if (XQueryExtension (dpyinfo->display, "XInputExtension",
28285 &dpyinfo->xi2_opcode, &xi_first_event, 28332 &dpyinfo->xi2_opcode, &xi_first_event,
28286 &xi_first_error)) 28333 &xi_first_error))
@@ -28377,9 +28424,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
28377 } 28424 }
28378 28425
28379 dpyinfo->xi2_version = minor; 28426 dpyinfo->xi2_version = minor;
28380#ifndef HAVE_GTK3
28381 skip_xi_setup: 28427 skip_xi_setup:
28382#endif
28383 ; 28428 ;
28384#endif 28429#endif
28385 28430