Grab global keys on newly created workspaces
* exwm-input.el (exwm-input--update-global-prefix-keys): Label grabbed workspaces and re-grab keys only when keys change or there are newly created workspaces. (exwm-input--init, exwm-input--exit): Use the function in `exwm-workspace-list-change-hook'.
This commit is contained in:
parent
6bfedf8bf7
commit
9f68fbd906
1 changed files with 13 additions and 2 deletions
|
@ -292,7 +292,11 @@ This value should always be overwritten.")
|
||||||
(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))
|
||||||
(unless (equal original exwm-input--global-prefix-keys)
|
;; Stop here if the global prefix keys are update-to-date and
|
||||||
|
;; there's no new workspace.
|
||||||
|
(unless (and (equal original exwm-input--global-prefix-keys)
|
||||||
|
(cl-every (lambda (w) (frame-parameter w 'exwm-grabbed))
|
||||||
|
exwm-workspace--list))
|
||||||
(setq ungrab-key (make-instance 'xcb:UngrabKey
|
(setq ungrab-key (make-instance 'xcb:UngrabKey
|
||||||
:key xcb:Grab:Any :grab-window nil
|
:key xcb:Grab:Any :grab-window nil
|
||||||
:modifiers xcb:ModMask:Any)
|
:modifiers xcb:ModMask:Any)
|
||||||
|
@ -308,6 +312,8 @@ This value should always be overwritten.")
|
||||||
(setf (slot-value ungrab-key 'grab-window) workspace)
|
(setf (slot-value ungrab-key 'grab-window) workspace)
|
||||||
(if (xcb:+request-checked+request-check exwm--connection ungrab-key)
|
(if (xcb:+request-checked+request-check exwm--connection ungrab-key)
|
||||||
(exwm--log "Failed to ungrab keys")
|
(exwm--log "Failed to ungrab keys")
|
||||||
|
;; Label this frame.
|
||||||
|
(set-frame-parameter w 'exwm-grabbed t)
|
||||||
(dolist (k exwm-input--global-prefix-keys)
|
(dolist (k exwm-input--global-prefix-keys)
|
||||||
(setq keysym (xcb:keysyms:event->keysym exwm--connection k)
|
(setq keysym (xcb:keysyms:event->keysym exwm--connection k)
|
||||||
keycode (xcb:keysyms:keysym->keycode exwm--connection
|
keycode (xcb:keysyms:keysym->keycode exwm--connection
|
||||||
|
@ -640,6 +646,9 @@ Its usage is the same with `exwm-input-set-simulation-keys'."
|
||||||
(add-hook 'post-command-hook #'exwm-input--on-post-command)
|
(add-hook 'post-command-hook #'exwm-input--on-post-command)
|
||||||
;; Update focus when buffer list updates
|
;; Update focus when buffer list updates
|
||||||
(add-hook 'buffer-list-update-hook #'exwm-input--on-buffer-list-update)
|
(add-hook 'buffer-list-update-hook #'exwm-input--on-buffer-list-update)
|
||||||
|
;; Re-grab global keys.
|
||||||
|
(add-hook 'exwm-workspace-list-change-hook
|
||||||
|
#'exwm-input--update-global-prefix-keys)
|
||||||
;; Update prefix keys for global keys
|
;; Update prefix keys for global keys
|
||||||
(exwm-input--update-global-prefix-keys))
|
(exwm-input--update-global-prefix-keys))
|
||||||
|
|
||||||
|
@ -648,7 +657,9 @@ Its usage is the same with `exwm-input-set-simulation-keys'."
|
||||||
(remove-hook 'pre-command-hook #'exwm-input--finish-key-sequence)
|
(remove-hook 'pre-command-hook #'exwm-input--finish-key-sequence)
|
||||||
(remove-hook 'pre-command-hook #'exwm-input--on-pre-command)
|
(remove-hook 'pre-command-hook #'exwm-input--on-pre-command)
|
||||||
(remove-hook 'post-command-hook #'exwm-input--on-post-command)
|
(remove-hook 'post-command-hook #'exwm-input--on-post-command)
|
||||||
(remove-hook 'buffer-list-update-hook #'exwm-input--on-buffer-list-update))
|
(remove-hook 'buffer-list-update-hook #'exwm-input--on-buffer-list-update)
|
||||||
|
(remove-hook 'exwm-workspace-list-change-hook
|
||||||
|
#'exwm-input--update-global-prefix-keys))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue