]> git.eshelyaron.com Git - emacs.git/commitdiff
Move raw event selection on GTK+ 2 to a more appropriate place
authorPo Lu <luangruo@yahoo.com>
Wed, 13 Apr 2022 11:13:38 +0000 (19:13 +0800)
committerPo Lu <luangruo@yahoo.com>
Wed, 13 Apr 2022 11:13:38 +0000 (19:13 +0800)
* src/xfns.c (setup_xi_event_mask): Stop selecting for
RawKeyPress on the root window.
* src/xterm.c (x_new_focus_frame): Select here instead, once a
frame becomes focused.

src/xfns.c
src/xterm.c

index 2f90534c48498e662179df697cfe66ae54d89773..5cf3eb41996377558f737230d32fb4c729751bce 100644 (file)
@@ -3688,15 +3688,6 @@ setup_xi_event_mask (struct frame *f)
   XISelectEvents (FRAME_X_DISPLAY (f),
                  FRAME_X_WINDOW (f),
                  &mask, 1);
-
-#if defined USE_GTK && !defined HAVE_GTK3
-  memset (m, 0, l);
-  XISetMask (m, XI_RawKeyPress);
-
-  XISelectEvents (FRAME_X_DISPLAY (f),
-                 FRAME_DISPLAY_INFO (f)->root_window,
-                 &mask, 1);
-#endif
   unblock_input ();
 }
 #endif
index 0c1c70340de3c9147e7598489c41112c232565b3..86db1a5c5f8b15b25c63cb5d71b37faeec1ade0c 100644 (file)
@@ -9067,6 +9067,20 @@ static void
 x_new_focus_frame (struct x_display_info *dpyinfo, struct frame *frame)
 {
   struct frame *old_focus = dpyinfo->x_focus_frame;
+#if defined USE_GTK && !defined HAVE_GTK3 && defined HAVE_XINPUT2
+  XIEventMask mask;
+  ptrdiff_t l;
+
+  if (dpyinfo->supports_xi2)
+    {
+      l = XIMaskLen (XI_LASTEVENT);
+      mask.mask = alloca (l);
+      mask.mask_len = l;
+      memset (mask.mask, 0, l);
+
+      mask.deviceid = XIAllDevices;
+    }
+#endif
 
   if (frame != dpyinfo->x_focus_frame)
     {
@@ -9074,6 +9088,17 @@ x_new_focus_frame (struct x_display_info *dpyinfo, struct frame *frame)
         the correct value of x_focus_frame.  */
       dpyinfo->x_focus_frame = frame;
 
+      /* Once none of our frames are focused anymore, stop selecting
+        for raw input events from the root window.  */
+
+#if defined USE_GTK && !defined HAVE_GTK3 && defined HAVE_XINPUT2
+      if (frame && dpyinfo->supports_xi2)
+       XISetMask (mask.mask, XI_RawKeyPress);
+
+      if (dpyinfo->supports_xi2)
+       XISelectEvents (dpyinfo->display, dpyinfo->root_window, &mask, 1);
+#endif
+
       if (old_focus && old_focus->auto_lower)
        x_lower_frame (old_focus);