about summary refs log tree commit diff
path: root/exwm-input.el
diff options
context:
space:
mode:
authorChris Feng <chris.w.feng@gmail.com>2019-09-22T00·00+0000
committerChris Feng <chris.w.feng@gmail.com>2019-09-22T00·00+0000
commit9c85f172e5697f85bdea67ef8b23819448abd31a (patch)
treecb146275816f5346420f94becca86bd2f6907ff0 /exwm-input.el
parent988f983233275b84ee3587af8a449a44d95c6752 (diff)
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).
Diffstat (limited to 'exwm-input.el')
-rw-r--r--exwm-input.el39
1 files changed, 21 insertions, 18 deletions
diff --git a/exwm-input.el b/exwm-input.el
index 52370bf8f4..c5eedc9e1d 100644
--- a/exwm-input.el
+++ b/exwm-input.el
@@ -488,24 +488,27 @@ ARGS are additional arguments to CALLBACK."
                             :keyboard-mode xcb:GrabMode:Async))
         keysyms keycode alt-modifier)
     (dolist (k exwm-input--global-prefix-keys)
-      (setq keysyms (xcb:keysyms:event->keysyms exwm--connection k)
-            keycode (xcb:keysyms:keysym->keycode exwm--connection
-                                                 (caar keysyms)))
-      (exwm--log "Grabbing key=%s (keysyms=%s keycode=%s)"
-                 (single-key-description k) keysyms keycode)
-      (dolist (keysym keysyms)
-        (setf (slot-value req 'modifiers) (cdr keysym)
-              (slot-value req 'key) keycode)
-        ;; Also grab this key with num-lock mask set.
-        (when (and (/= 0 xcb:keysyms:num-lock-mask)
-                   (= 0 (logand (cdr keysym) xcb:keysyms:num-lock-mask)))
-          (setf alt-modifier (logior (cdr keysym) xcb:keysyms:num-lock-mask)))
-        (dolist (xwin xwins)
-          (setf (slot-value req 'grab-window) xwin)
-          (xcb:+request exwm--connection req)
-          (when alt-modifier
-            (setf (slot-value req 'modifiers) alt-modifier)
-            (xcb:+request exwm--connection req)))))
+      (setq keysyms (xcb:keysyms:event->keysyms exwm--connection k))
+      (if (not keysyms)
+          (warn "Key unavailable: %s" (key-description (vector k)))
+        (setq keycode (xcb:keysyms:keysym->keycode exwm--connection
+                                                   (caar keysyms)))
+        (exwm--log "Grabbing key=%s (keysyms=%s keycode=%s)"
+                   (single-key-description k) keysyms keycode)
+        (dolist (keysym keysyms)
+          (setf (slot-value req 'modifiers) (cdr keysym)
+                (slot-value req 'key) keycode)
+          ;; Also grab this key with num-lock mask set.
+          (when (and (/= 0 xcb:keysyms:num-lock-mask)
+                     (= 0 (logand (cdr keysym) xcb:keysyms:num-lock-mask)))
+            (setf alt-modifier (logior (cdr keysym)
+                                       xcb:keysyms:num-lock-mask)))
+          (dolist (xwin xwins)
+            (setf (slot-value req 'grab-window) xwin)
+            (xcb:+request exwm--connection req)
+            (when alt-modifier
+              (setf (slot-value req 'modifiers) alt-modifier)
+              (xcb:+request exwm--connection req))))))
     (xcb:flush exwm--connection)))
 
 (defun exwm-input--set-key (key command)