[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/exwm 52dc261 2/2: Manually run `focus-in-hook' and `foc
From: |
Chris Feng |
Subject: |
[elpa] externals/exwm 52dc261 2/2: Manually run `focus-in-hook' and `focus-out-hook' |
Date: |
Sat, 4 Mar 2017 12:18:51 -0500 (EST) |
branch: externals/exwm
commit 52dc2616240d43b8c15e10edfdd34b1e0039a10f
Author: Chris Feng <address@hidden>
Commit: Chris Feng <address@hidden>
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'
---
exwm-workspace.el | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/exwm-workspace.el b/exwm-workspace.el
index 6686598..1b904d4 100644
--- a/exwm-workspace.el
+++ b/exwm-workspace.el
@@ -451,6 +451,7 @@ The optional FORCE option is for internal use only."
(exwm-workspace--prompt-delete-allowed t))
(exwm-workspace--prompt-for-workspace "Switch to [+/-]: ")))))
(let* ((frame (exwm-workspace--workspace-from-frame-or-index frame-or-index))
+ (old-frame exwm-workspace--current)
(index (exwm-workspace--position frame))
(workspace (frame-parameter frame 'exwm-workspace))
(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
:window exwm--root :data index))
(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)))
(defvar exwm-workspace-switch-create-limit 10
@@ -1348,6 +1353,14 @@ applied to all subsequently created X frames."
(setf (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 ()
"Initialize workspace module."
;; Prevent unexpected exit
@@ -1463,6 +1476,10 @@ applied to all subsequently created X frames."
(xcb:flush exwm--connection)
;; 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)
+ ;; 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.
(add-hook 'after-make-frame-functions
#'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
:test #'equal))
(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
#'exwm-workspace--add-frame-as-workspace)
(remove-hook 'delete-frame-functions