diff options
author | Chris Feng <chris.w.feng@gmail.com> | 2016-07-30T02·06+0800 |
---|---|---|
committer | Chris Feng <chris.w.feng@gmail.com> | 2016-07-30T02·06+0800 |
commit | 9f68fbd906ca14856a70a3c3b535188a670d01f4 (patch) | |
tree | c9a2c862ddd8985cc41e81b6fec71c627eba39c5 | |
parent | 6bfedf8bf71ef11a26f2e8c3cddbac55ce873e5c (diff) |
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'.
-rw-r--r-- | exwm-input.el | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/exwm-input.el b/exwm-input.el index 0da0558e84c0..f7a67040d60a 100644 --- a/exwm-input.el +++ b/exwm-input.el @@ -292,7 +292,11 @@ This value should always be overwritten.") (setq exwm-input--global-prefix-keys nil) (dolist (i exwm-input--global-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 :key xcb:Grab:Any :grab-window nil :modifiers xcb:ModMask:Any) @@ -308,6 +312,8 @@ This value should always be overwritten.") (setf (slot-value ungrab-key 'grab-window) workspace) (if (xcb:+request-checked+request-check exwm--connection ungrab-key) (exwm--log "Failed to ungrab keys") + ;; Label this frame. + (set-frame-parameter w 'exwm-grabbed t) (dolist (k exwm-input--global-prefix-keys) (setq keysym (xcb:keysyms:event->keysym exwm--connection k) 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) ;; Update focus when buffer list updates (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 (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--on-pre-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)) |