From 26d24e534a227d3d4de199f8ae3d098ef647f71d Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 2 Jan 2025 09:46:22 -0800 Subject: [PATCH] Set _NET_ACTIVE_WINDOW to the current EXWM workspace When a non-X window is selected, set _NET_ACTIVE_WINDOW to the current EXWM workspace (i.e., the Emacs frame containing the selected window). This behavior can be tested with, e.g., `xdotool getactivewindow'. * exwm-input.el (exwm-input--set-active-window): The window ID is now mandatory. (exwm--input-update-focus): When focusing on a workspace, set the active window to the workspace's window ID. (#77) --- exwm-input.el | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/exwm-input.el b/exwm-input.el index 8c602c4..fc0d0b1 100644 --- a/exwm-input.el +++ b/exwm-input.el @@ -373,23 +373,25 @@ attempt later." window) (exwm--defer 0 #'exwm-workspace-switch (selected-frame))) ;; The focus is still on the current workspace. - (if (not (and (exwm-workspace--minibuffer-own-frame-p) - (minibufferp))) - (x-focus-frame (window-frame window)) - ;; X input focus should be set on the previously selected - ;; frame. - (x-focus-frame (window-frame (minibuffer-window)))) - (exwm-input--set-active-window) + (let ((frame (if (not (and (exwm-workspace--minibuffer-own-frame-p) + (minibufferp))) + (window-frame window) + ;; X input focus should be set on the previously + ;; selected frame. + (window-frame (minibuffer-window))))) + (x-focus-frame frame) + (exwm-input--set-active-window + (or (frame-parameter exwm-workspace--current 'exwm-outer-id) + xcb:Window:None))) (xcb:flush exwm--connection))))))) -(defun exwm-input--set-active-window (&optional id) - "Set _NET_ACTIVE_WINDOW. -When non-nil, ID is passed as the window data." +(defun exwm-input--set-active-window (id) + "Set _NET_ACTIVE_WINDOW to ID." (exwm--log) (xcb:+request exwm--connection (make-instance 'xcb:ewmh:set-_NET_ACTIVE_WINDOW :window exwm--root - :data (or id xcb:Window:None)))) + :data id))) (defun exwm-input--on-ButtonPress (data _synthetic) "Handle ButtonPress event with DATA."