diff options
author | Chris Feng <chris.w.feng@gmail.com> | 2015-10-28T12·38+0800 |
---|---|---|
committer | Chris Feng <chris.w.feng@gmail.com> | 2015-10-28T12·38+0800 |
commit | 51f5e35aa6a85516bcd00b3bf874f3f3261ebfdc (patch) | |
tree | a2f4c6e0b0deb99fc9e99253b23a5299664d0874 | |
parent | 34d588599d2d7ef46db6a810c1549199f78cf8ba (diff) |
Check KEYSYMs converted from events
* exwm-input.el (exwm-input--update-global-prefix-keys) (exwm-input--fake-key, exwm-input--init): Check the return value of xcb:keysyms:event->keysym.
-rw-r--r-- | exwm-input.el | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/exwm-input.el b/exwm-input.el index f54c6307106b..5cf5f95c1e29 100644 --- a/exwm-input.el +++ b/exwm-input.el @@ -261,7 +261,8 @@ It's updated in several occasions, and only used by `exwm-input--set-focus'.") exwm--connection (car keysym)) :pointer-mode xcb:GrabMode:Async :keyboard-mode xcb:GrabMode:Async))) - (user-error "[EXWM] Failed to grab key: %s" i)))))))) + (user-error "[EXWM] Failed to grab key: %s" + (single-key-description i))))))))) (defun exwm-input-set-key (key command) "Set a global key binding." @@ -392,9 +393,13 @@ It's updated in several occasions, and only used by `exwm-input--set-focus'.") (defun exwm-input--fake-key (event) "Fake a key event equivalent to Emacs event EVENT." (let* ((keysym (xcb:keysyms:event->keysym event)) - (keycode (xcb:keysyms:keysym->keycode exwm--connection (car keysym))) - (id (exwm--buffer->id (window-buffer (selected-window))))) + keycode id) + (unless keysym + (user-error "[EXWM] Invalid key: %s" (single-key-description event))) + (setq keycode (xcb:keysyms:keysym->keycode exwm--connection + (car keysym))) (when keycode + (setq id (exwm--buffer->id (window-buffer (selected-window)))) (dolist (class '(xcb:KeyPress xcb:KeyRelease)) (xcb:+request exwm--connection (make-instance 'xcb:SendEvent @@ -472,6 +477,12 @@ SIMULATION-KEYS is a list of alist (key-sequence1 . key-sequence2)." ;; Convert move/resize buttons (let ((move-key (xcb:keysyms:event->keysym exwm-input-move-event)) (resize-key (xcb:keysyms:event->keysym exwm-input-resize-event))) + (unless move-key + (user-error "[EXWM] Invalid key: %s" + (single-key-description exwm-input-move-event))) + (unless resize-key + (user-error "[EXWM] Invalid key: %s" + (single-key-description exwm-input-resize-event))) (setq exwm-input--move-keysym (car move-key) exwm-input--move-mask (cadr move-key) exwm-input--resize-keysym (car resize-key) |