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)
This commit is contained in:
Steven Allen 2025-01-02 09:46:22 -08:00
parent 521cdb824e
commit 26d24e534a

View file

@ -373,23 +373,25 @@ attempt later."
window) window)
(exwm--defer 0 #'exwm-workspace-switch (selected-frame))) (exwm--defer 0 #'exwm-workspace-switch (selected-frame)))
;; The focus is still on the current workspace. ;; The focus is still on the current workspace.
(if (not (and (exwm-workspace--minibuffer-own-frame-p) (let ((frame (if (not (and (exwm-workspace--minibuffer-own-frame-p)
(minibufferp))) (minibufferp)))
(x-focus-frame (window-frame window)) (window-frame window)
;; X input focus should be set on the previously selected ;; X input focus should be set on the previously
;; frame. ;; selected frame.
(x-focus-frame (window-frame (minibuffer-window)))) (window-frame (minibuffer-window)))))
(exwm-input--set-active-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))))))) (xcb:flush exwm--connection)))))))
(defun exwm-input--set-active-window (&optional id) (defun exwm-input--set-active-window (id)
"Set _NET_ACTIVE_WINDOW. "Set _NET_ACTIVE_WINDOW to ID."
When non-nil, ID is passed as the window data."
(exwm--log) (exwm--log)
(xcb:+request exwm--connection (xcb:+request exwm--connection
(make-instance 'xcb:ewmh:set-_NET_ACTIVE_WINDOW (make-instance 'xcb:ewmh:set-_NET_ACTIVE_WINDOW
:window exwm--root :window exwm--root
:data (or id xcb:Window:None)))) :data id)))
(defun exwm-input--on-ButtonPress (data _synthetic) (defun exwm-input--on-ButtonPress (data _synthetic)
"Handle ButtonPress event with DATA." "Handle ButtonPress event with DATA."