mirror of
https://github.com/emacs-exwm/exwm.git
synced 2024-11-23 21:17:59 +01:00
Manually run focus-in-hook' and
focus-out-hook'
; Since X windows are managed by EXWM, the current Emacs frame should always be considered focused logically. * exwm-workspace.el (exwm-workspace-switch): Manually run `focus-in-hook' and `focus-out-hook'. (exwm-workspace--handle-focus-in, exwm-workspace--handle-focus-out): New functions for overriding `handle-focus-in' and `handle-focus-out'. (exwm-workspace--init, exwm-workspace--exit): Override `handle-focus-in' and `handle-focus-out'
This commit is contained in:
parent
eebf764edd
commit
52dc261624
1 changed files with 19 additions and 0 deletions
|
@ -451,6 +451,7 @@ The optional FORCE option is for internal use only."
|
||||||
(exwm-workspace--prompt-delete-allowed t))
|
(exwm-workspace--prompt-delete-allowed t))
|
||||||
(exwm-workspace--prompt-for-workspace "Switch to [+/-]: ")))))
|
(exwm-workspace--prompt-for-workspace "Switch to [+/-]: ")))))
|
||||||
(let* ((frame (exwm-workspace--workspace-from-frame-or-index frame-or-index))
|
(let* ((frame (exwm-workspace--workspace-from-frame-or-index frame-or-index))
|
||||||
|
(old-frame exwm-workspace--current)
|
||||||
(index (exwm-workspace--position frame))
|
(index (exwm-workspace--position frame))
|
||||||
(workspace (frame-parameter frame 'exwm-workspace))
|
(workspace (frame-parameter frame 'exwm-workspace))
|
||||||
(window (frame-parameter frame 'exwm-selected-window)))
|
(window (frame-parameter frame 'exwm-selected-window)))
|
||||||
|
@ -510,6 +511,10 @@ The optional FORCE option is for internal use only."
|
||||||
(make-instance 'xcb:ewmh:set-_NET_CURRENT_DESKTOP
|
(make-instance 'xcb:ewmh:set-_NET_CURRENT_DESKTOP
|
||||||
:window exwm--root :data index))
|
:window exwm--root :data index))
|
||||||
(xcb:flush exwm--connection))
|
(xcb:flush exwm--connection))
|
||||||
|
(when (frame-live-p old-frame)
|
||||||
|
(with-selected-frame old-frame
|
||||||
|
(run-hooks 'focus-out-hook)))
|
||||||
|
(run-hooks 'focus-in-hook)
|
||||||
(run-hooks 'exwm-workspace-switch-hook)))
|
(run-hooks 'exwm-workspace-switch-hook)))
|
||||||
|
|
||||||
(defvar exwm-workspace-switch-create-limit 10
|
(defvar exwm-workspace-switch-create-limit 10
|
||||||
|
@ -1348,6 +1353,14 @@ applied to all subsequently created X frames."
|
||||||
(setf (cdr x-parameters)
|
(setf (cdr x-parameters)
|
||||||
(append new-x-parameters (cdr x-parameters)))))
|
(append new-x-parameters (cdr x-parameters)))))
|
||||||
|
|
||||||
|
(defun exwm-workspace--handle-focus-in (_orig-func _event)
|
||||||
|
"Replacement for `handle-focus-in'."
|
||||||
|
(interactive "e"))
|
||||||
|
|
||||||
|
(defun exwm-workspace--handle-focus-out (_orig-func _event)
|
||||||
|
"Replacement for `handle-focus-out'."
|
||||||
|
(interactive "e"))
|
||||||
|
|
||||||
(defun exwm-workspace--init ()
|
(defun exwm-workspace--init ()
|
||||||
"Initialize workspace module."
|
"Initialize workspace module."
|
||||||
;; Prevent unexpected exit
|
;; Prevent unexpected exit
|
||||||
|
@ -1463,6 +1476,10 @@ applied to all subsequently created X frames."
|
||||||
(xcb:flush exwm--connection)
|
(xcb:flush exwm--connection)
|
||||||
;; We have to advice `x-create-frame' or every call to it would hang EXWM
|
;; We have to advice `x-create-frame' or every call to it would hang EXWM
|
||||||
(advice-add 'x-create-frame :around #'exwm-workspace--x-create-frame)
|
(advice-add 'x-create-frame :around #'exwm-workspace--x-create-frame)
|
||||||
|
;; We have to manually handle focus-in and focus-out events for Emacs
|
||||||
|
;; frames.
|
||||||
|
(advice-add 'handle-focus-in :around #'exwm-workspace--handle-focus-in)
|
||||||
|
(advice-add 'handle-focus-out :around #'exwm-workspace--handle-focus-out)
|
||||||
;; Make new frames create new workspaces.
|
;; Make new frames create new workspaces.
|
||||||
(add-hook 'after-make-frame-functions
|
(add-hook 'after-make-frame-functions
|
||||||
#'exwm-workspace--add-frame-as-workspace)
|
#'exwm-workspace--add-frame-as-workspace)
|
||||||
|
@ -1494,6 +1511,8 @@ applied to all subsequently created X frames."
|
||||||
(cl-delete '(exwm-workspace--display-buffer) display-buffer-alist
|
(cl-delete '(exwm-workspace--display-buffer) display-buffer-alist
|
||||||
:test #'equal))
|
:test #'equal))
|
||||||
(advice-remove 'x-create-frame #'exwm-workspace--x-create-frame)
|
(advice-remove 'x-create-frame #'exwm-workspace--x-create-frame)
|
||||||
|
(advice-remove 'handle-focus-in #'exwm-workspace--handle-focus-in)
|
||||||
|
(advice-remove 'handle-focus-out #'exwm-workspace--handle-focus-out)
|
||||||
(remove-hook 'after-make-frame-functions
|
(remove-hook 'after-make-frame-functions
|
||||||
#'exwm-workspace--add-frame-as-workspace)
|
#'exwm-workspace--add-frame-as-workspace)
|
||||||
(remove-hook 'delete-frame-functions
|
(remove-hook 'delete-frame-functions
|
||||||
|
|
Loading…
Reference in a new issue