mirror of
https://github.com/ch11ng/exwm.git
synced 2024-11-30 14:38:00 +01:00
Add support for various key processing variables
* exwm-input.el (exwm-input--mimic-read-event): New function for handling `extra-keyboard-modifiers' and `keyboard-translate-table'. (exwm-input--cache-event): Do not unread events here. (exwm-input--on-KeyPress-line-mode) (exwm-input--on-KeyPress-char-mode): Compare with preprocessed events and unread raw ones. * exwm-input.el (exwm-input--on-KeyPress-line-mode): Add support for `overriding-terminal-local-map'.
This commit is contained in:
parent
f4aa8389fc
commit
fbdcd42b0a
1 changed files with 32 additions and 13 deletions
|
@ -522,6 +522,19 @@ instead."
|
|||
(setq unread-command-events
|
||||
(append unread-command-events `((t . ,event)))))))
|
||||
|
||||
(defun exwm-input--mimic-read-event (event)
|
||||
"Process EVENT as if it were returned by `read-event'."
|
||||
(unless (eq 0 extra-keyboard-modifiers)
|
||||
(setq event (event-convert-list (append (event-modifiers
|
||||
extra-keyboard-modifiers)
|
||||
event))))
|
||||
(when (characterp event)
|
||||
(let ((event* (when keyboard-translate-table
|
||||
(aref keyboard-translate-table event))))
|
||||
(when event*
|
||||
(setq event event*))))
|
||||
event)
|
||||
|
||||
(cl-defun exwm-input--translate (key)
|
||||
(let (translation)
|
||||
(dolist (map (list input-decode-map
|
||||
|
@ -546,18 +559,18 @@ instead."
|
|||
(setq exwm-input--line-mode-cache nil)
|
||||
(when exwm-input--temp-line-mode
|
||||
(setq exwm-input--temp-line-mode nil)
|
||||
(exwm-input--release-keyboard)))
|
||||
(exwm-input--unread-event event))
|
||||
(exwm-input--release-keyboard))))
|
||||
|
||||
(defun exwm-input--on-KeyPress-line-mode (key-press raw-data)
|
||||
"Parse X KeyPress event to Emacs key event and then feed the command loop."
|
||||
(with-slots (detail state) key-press
|
||||
(let ((keysym (xcb:keysyms:keycode->keysym exwm--connection detail state))
|
||||
event mode)
|
||||
event raw-event mode)
|
||||
(when (and (/= 0 (car keysym))
|
||||
(setq event (xcb:keysyms:keysym->event
|
||||
(setq raw-event (xcb:keysyms:keysym->event
|
||||
exwm--connection (car keysym)
|
||||
(logand state (lognot (cdr keysym)))))
|
||||
(setq event (exwm-input--mimic-read-event raw-event))
|
||||
(or exwm-input-line-mode-passthrough
|
||||
exwm-input--during-command
|
||||
;; Forward the event when there is an incomplete key
|
||||
|
@ -567,10 +580,14 @@ instead."
|
|||
;;
|
||||
(memq event exwm-input--global-prefix-keys)
|
||||
(memq event exwm-input-prefix-keys)
|
||||
(when overriding-terminal-local-map
|
||||
(lookup-key overriding-terminal-local-map
|
||||
(vector event)))
|
||||
(lookup-key (current-local-map) (vector event))
|
||||
(gethash event exwm-input--simulation-keys)))
|
||||
(setq mode xcb:Allow:AsyncKeyboard)
|
||||
(exwm-input--cache-event event))
|
||||
(exwm-input--cache-event event)
|
||||
(exwm-input--unread-event raw-event))
|
||||
(unless mode
|
||||
(if (= 0 (logand #x6000 state)) ;Check the 13~14 bits.
|
||||
;; Not an XKB state; just replay it.
|
||||
|
@ -599,17 +616,19 @@ instead."
|
|||
"Handle KeyPress event in char-mode."
|
||||
(with-slots (detail state) key-press
|
||||
(let ((keysym (xcb:keysyms:keycode->keysym exwm--connection detail state))
|
||||
event)
|
||||
event raw-event)
|
||||
(when (and (/= 0 (car keysym))
|
||||
(setq event (xcb:keysyms:keysym->event
|
||||
(setq raw-event (xcb:keysyms:keysym->event
|
||||
exwm--connection (car keysym)
|
||||
(logand state (lognot (cdr keysym))))))
|
||||
(logand state (lognot (cdr keysym)))))
|
||||
(setq event (exwm-input--mimic-read-event raw-event)))
|
||||
(if (not (eq major-mode 'exwm-mode))
|
||||
(exwm-input--unread-event event)
|
||||
(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)
|
||||
(exwm-input--unread-event raw-event)))))
|
||||
(xcb:+request exwm--connection
|
||||
(make-instance 'xcb:AllowEvents
|
||||
:mode xcb:Allow:AsyncKeyboard
|
||||
|
|
Loading…
Reference in a new issue