Use new calling conventions of xcb:keysyms

* exwm-input.el: Use new calling conventions of xcb:keysyms
This commit is contained in:
Chris Feng 2015-10-30 17:23:02 +08:00
parent b2ee102051
commit 45c24eac7a

View file

@ -238,7 +238,7 @@ It's updated in several occasions, and only used by `exwm-input--set-focus'.")
"Update `exwm-input--global-prefix-keys'." "Update `exwm-input--global-prefix-keys'."
(when exwm--connection (when exwm--connection
(let ((original exwm-input--global-prefix-keys) (let ((original exwm-input--global-prefix-keys)
keysym) keysym keycode)
(setq exwm-input--global-prefix-keys nil) (setq exwm-input--global-prefix-keys nil)
(dolist (i exwm-input--global-keys) (dolist (i exwm-input--global-keys)
(cl-pushnew (elt i 0) exwm-input--global-prefix-keys)) (cl-pushnew (elt i 0) exwm-input--global-prefix-keys))
@ -250,15 +250,16 @@ It's updated in several occasions, and only used by `exwm-input--set-focus'.")
:modifiers xcb:ModMask:Any)) :modifiers xcb:ModMask:Any))
(exwm--log "Failed to ungrab keys") (exwm--log "Failed to ungrab keys")
(dolist (i exwm-input--global-prefix-keys) (dolist (i exwm-input--global-prefix-keys)
(setq keysym (xcb:keysyms:event->keysym i)) (setq keysym (xcb:keysyms:event->keysym exwm--connection i))
(when (or (not keysym) (when (or (not keysym)
(not (setq keycode (xcb:keysyms:keysym->keycode
exwm--connection (car keysym))))
(xcb:+request-checked+request-check exwm--connection (xcb:+request-checked+request-check exwm--connection
(make-instance 'xcb:GrabKey (make-instance 'xcb:GrabKey
:owner-events 0 :owner-events 0
:grab-window exwm--root :grab-window exwm--root
:modifiers (cadr keysym) :modifiers (cadr keysym)
:key (xcb:keysyms:keysym->keycode :key keycode
exwm--connection (car keysym))
:pointer-mode xcb:GrabMode:Async :pointer-mode xcb:GrabMode:Async
:keyboard-mode xcb:GrabMode:Async))) :keyboard-mode xcb:GrabMode:Async)))
(user-error "[EXWM] Failed to grab key: %s" (user-error "[EXWM] Failed to grab key: %s"
@ -283,7 +284,8 @@ It's updated in several occasions, and only used by `exwm-input--set-focus'.")
(let ((keysym (xcb:keysyms:keycode->keysym exwm--connection detail state)) (let ((keysym (xcb:keysyms:keycode->keysym exwm--connection detail state))
event minibuffer-window mode) event minibuffer-window mode)
(when (and keysym (when (and keysym
(setq event (xcb:keysyms:keysym->event keysym state)) (setq event (xcb:keysyms:keysym->event exwm--connection
keysym state))
(or exwm-input--during-key-sequence (or exwm-input--during-key-sequence
(setq minibuffer-window (active-minibuffer-window)) (setq minibuffer-window (active-minibuffer-window))
(memq real-this-command exwm-input-command-whitelist) (memq real-this-command exwm-input-command-whitelist)
@ -319,7 +321,9 @@ It's updated in several occasions, and only used by `exwm-input--set-focus'.")
:event id :event id
:mode xcb:NotifyMode:Normal) :mode xcb:NotifyMode:Normal)
exwm--connection))))) exwm--connection)))))
(when (and keysym (setq event (xcb:keysyms:keysym->event keysym state))) (when (and keysym
(setq event (xcb:keysyms:keysym->event exwm--connection
keysym state)))
(when (eq major-mode 'exwm-mode) (when (eq major-mode 'exwm-mode)
(setq exwm-input--temp-line-mode t (setq exwm-input--temp-line-mode t
exwm-input--during-key-sequence t) exwm-input--during-key-sequence t)
@ -392,7 +396,7 @@ It's updated in several occasions, and only used by `exwm-input--set-focus'.")
(defun exwm-input--fake-key (event) (defun exwm-input--fake-key (event)
"Fake a key event equivalent to Emacs event EVENT." "Fake a key event equivalent to Emacs event EVENT."
(let* ((keysym (xcb:keysyms:event->keysym event)) (let* ((keysym (xcb:keysyms:event->keysym exwm--connection event))
keycode id) keycode id)
(unless keysym (unless keysym
(user-error "[EXWM] Invalid key: %s" (single-key-description event))) (user-error "[EXWM] Invalid key: %s" (single-key-description event)))
@ -475,8 +479,10 @@ SIMULATION-KEYS is a list of alist (key-sequence1 . key-sequence2)."
;; Refresh keyboard mapping ;; Refresh keyboard mapping
(xcb:keysyms:init exwm--connection) (xcb:keysyms:init exwm--connection)
;; Convert move/resize buttons ;; Convert move/resize buttons
(let ((move-key (xcb:keysyms:event->keysym exwm-input-move-event)) (let ((move-key (xcb:keysyms:event->keysym exwm--connection
(resize-key (xcb:keysyms:event->keysym exwm-input-resize-event))) exwm-input-move-event))
(resize-key (xcb:keysyms:event->keysym exwm--connection
exwm-input-resize-event)))
(unless move-key (unless move-key
(user-error "[EXWM] Invalid key: %s" (user-error "[EXWM] Invalid key: %s"
(single-key-description exwm-input-move-event))) (single-key-description exwm-input-move-event)))