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)
(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)
(let ((frame (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)
(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."