Skip global keys unavailable in X server

* exwm-input.el (exwm-input--grab-global-prefix-keys): Some global
keys might not be available in X server (perhaps due to
misconfiguration).
This commit is contained in:
Chris Feng 2019-09-22 00:00:00 +00:00
parent 988f983233
commit 9c85f172e5

View file

@ -488,24 +488,27 @@ ARGS are additional arguments to CALLBACK."
:keyboard-mode xcb:GrabMode:Async)) :keyboard-mode xcb:GrabMode:Async))
keysyms keycode alt-modifier) keysyms keycode alt-modifier)
(dolist (k exwm-input--global-prefix-keys) (dolist (k exwm-input--global-prefix-keys)
(setq keysyms (xcb:keysyms:event->keysyms exwm--connection k) (setq keysyms (xcb:keysyms:event->keysyms exwm--connection k))
keycode (xcb:keysyms:keysym->keycode exwm--connection (if (not keysyms)
(caar keysyms))) (warn "Key unavailable: %s" (key-description (vector k)))
(exwm--log "Grabbing key=%s (keysyms=%s keycode=%s)" (setq keycode (xcb:keysyms:keysym->keycode exwm--connection
(single-key-description k) keysyms keycode) (caar keysyms)))
(dolist (keysym keysyms) (exwm--log "Grabbing key=%s (keysyms=%s keycode=%s)"
(setf (slot-value req 'modifiers) (cdr keysym) (single-key-description k) keysyms keycode)
(slot-value req 'key) keycode) (dolist (keysym keysyms)
;; Also grab this key with num-lock mask set. (setf (slot-value req 'modifiers) (cdr keysym)
(when (and (/= 0 xcb:keysyms:num-lock-mask) (slot-value req 'key) keycode)
(= 0 (logand (cdr keysym) xcb:keysyms:num-lock-mask))) ;; Also grab this key with num-lock mask set.
(setf alt-modifier (logior (cdr keysym) xcb:keysyms:num-lock-mask))) (when (and (/= 0 xcb:keysyms:num-lock-mask)
(dolist (xwin xwins) (= 0 (logand (cdr keysym) xcb:keysyms:num-lock-mask)))
(setf (slot-value req 'grab-window) xwin) (setf alt-modifier (logior (cdr keysym)
(xcb:+request exwm--connection req) xcb:keysyms:num-lock-mask)))
(when alt-modifier (dolist (xwin xwins)
(setf (slot-value req 'modifiers) alt-modifier) (setf (slot-value req 'grab-window) xwin)
(xcb:+request exwm--connection req))))) (xcb:+request exwm--connection req)
(when alt-modifier
(setf (slot-value req 'modifiers) alt-modifier)
(xcb:+request exwm--connection req))))))
(xcb:flush exwm--connection))) (xcb:flush exwm--connection)))
(defun exwm-input--set-key (key command) (defun exwm-input--set-key (key command)