emacs-diffs
[Top][All Lists]
Advanced

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

master ed6237e039: Move raw event selection on GTK+ 2 to a more appropri


From: Po Lu
Subject: master ed6237e039: Move raw event selection on GTK+ 2 to a more appropriate place
Date: Wed, 13 Apr 2022 07:14:51 -0400 (EDT)

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

    Move raw event selection on GTK+ 2 to a more appropriate place
    
    * 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  |  9 ---------
 src/xterm.c | 25 +++++++++++++++++++++++++
 2 files changed, 25 insertions(+), 9 deletions(-)

diff --git a/src/xfns.c b/src/xfns.c
index 2f90534c48..5cf3eb4199 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -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
diff --git a/src/xterm.c b/src/xterm.c
index 0c1c70340d..86db1a5c5f 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -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);
 



reply via email to

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