[Top][All Lists]

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

[elpa] externals/exwm 38e343f: Avoid unnecessary keyboard grab/ungrab in

From: Chris Feng
Subject: [elpa] externals/exwm 38e343f: Avoid unnecessary keyboard grab/ungrab in char-mode
Date: Sun, 25 Nov 2018 02:58:01 -0500 (EST)

branch: externals/exwm
commit 38e343ff076e1a00826986b302e389e3f2873cbd
Author: Chris Feng <address@hidden>
Commit: Chris Feng <address@hidden>

    Avoid unnecessary keyboard grab/ungrab in char-mode
    * exwm-input.el (exwm-input--cache-event): Optimize the handling of
    single event global key by not grabbing/ungrabbing the keyboard.
 exwm-input.el | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/exwm-input.el b/exwm-input.el
index c757b09..e184b39 100644
--- a/exwm-input.el
+++ b/exwm-input.el
@@ -565,7 +565,7 @@ instead."
           (cl-return-from exwm-input--translate translation)))))
-(defun exwm-input--cache-event (event)
+(defun exwm-input--cache-event (event &optional temp-line-mode)
   "Cache EVENT."
   (setq exwm-input--line-mode-cache
         (vconcat exwm-input--line-mode-cache (vector event)))
@@ -575,8 +575,12 @@ instead."
   ;; When the key sequence is complete (not a keymap).
   ;; Note that `exwm-input--line-mode-cache' might get translated to nil, for
   ;; example 'mouse--down-1-maybe-follows-link' does this.
-  (unless (and exwm-input--line-mode-cache
-               (keymapp (key-binding exwm-input--line-mode-cache)))
+  (if (and exwm-input--line-mode-cache
+           (keymapp (key-binding exwm-input--line-mode-cache)))
+      ;; Grab keyboard temporarily to intercept the complete key sequence.
+      (when temp-line-mode
+        (setq exwm-input--temp-line-mode t)
+        (exwm-input--grab-keyboard))
     (setq exwm-input--line-mode-cache nil)
     (when exwm-input--temp-line-mode
       (setq exwm-input--temp-line-mode nil)
@@ -652,10 +656,7 @@ Current buffer must be an `exwm-mode' buffer."
                  (setq event (exwm-input--mimic-read-event raw-event)))
         (if (not (derived-mode-p 'exwm-mode))
             (exwm-input--unread-event raw-event)
-          ;; Grab keyboard temporarily.
-          (setq exwm-input--temp-line-mode t)
-          (exwm-input--grab-keyboard)
-          (exwm-input--cache-event event)
+          (exwm-input--cache-event event t)
           (exwm-input--unread-event raw-event)))))
   (xcb:+request exwm--connection
       (make-instance 'xcb:AllowEvents

reply via email to

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