mirror of
https://github.com/ch11ng/exwm.git
synced 2024-11-30 14:38:00 +01:00
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.
This commit is contained in:
parent
786c2b4f7d
commit
38e343ff07
1 changed files with 8 additions and 7 deletions
|
@ -565,7 +565,7 @@ instead."
|
||||||
(cl-return-from exwm-input--translate translation)))))
|
(cl-return-from exwm-input--translate translation)))))
|
||||||
key)
|
key)
|
||||||
|
|
||||||
(defun exwm-input--cache-event (event)
|
(defun exwm-input--cache-event (event &optional temp-line-mode)
|
||||||
"Cache EVENT."
|
"Cache EVENT."
|
||||||
(setq exwm-input--line-mode-cache
|
(setq exwm-input--line-mode-cache
|
||||||
(vconcat exwm-input--line-mode-cache (vector event)))
|
(vconcat exwm-input--line-mode-cache (vector event)))
|
||||||
|
@ -575,8 +575,12 @@ instead."
|
||||||
;; When the key sequence is complete (not a keymap).
|
;; When the key sequence is complete (not a keymap).
|
||||||
;; Note that `exwm-input--line-mode-cache' might get translated to nil, for
|
;; Note that `exwm-input--line-mode-cache' might get translated to nil, for
|
||||||
;; example 'mouse--down-1-maybe-follows-link' does this.
|
;; example 'mouse--down-1-maybe-follows-link' does this.
|
||||||
(unless (and exwm-input--line-mode-cache
|
(if (and exwm-input--line-mode-cache
|
||||||
(keymapp (key-binding 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)
|
(setq exwm-input--line-mode-cache nil)
|
||||||
(when exwm-input--temp-line-mode
|
(when exwm-input--temp-line-mode
|
||||||
(setq exwm-input--temp-line-mode nil)
|
(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)))
|
(setq event (exwm-input--mimic-read-event raw-event)))
|
||||||
(if (not (derived-mode-p 'exwm-mode))
|
(if (not (derived-mode-p 'exwm-mode))
|
||||||
(exwm-input--unread-event raw-event)
|
(exwm-input--unread-event raw-event)
|
||||||
;; Grab keyboard temporarily.
|
(exwm-input--cache-event event t)
|
||||||
(setq exwm-input--temp-line-mode t)
|
|
||||||
(exwm-input--grab-keyboard)
|
|
||||||
(exwm-input--cache-event event)
|
|
||||||
(exwm-input--unread-event raw-event)))))
|
(exwm-input--unread-event raw-event)))))
|
||||||
(xcb:+request exwm--connection
|
(xcb:+request exwm--connection
|
||||||
(make-instance 'xcb:AllowEvents
|
(make-instance 'xcb:AllowEvents
|
||||||
|
|
Loading…
Reference in a new issue