Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set _NET_ACTIVE_WINDOW to the current EXWM workspace #111

Merged
merged 1 commit into from
Jan 3, 2025

Conversation

Stebalien
Copy link
Contributor

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'.

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)
@Stebalien Stebalien linked an issue Jan 2, 2025 that may be closed by this pull request
(x-focus-frame frame)
(exwm-input--set-active-window
(or (frame-parameter exwm-workspace--current 'exwm-outer-id)
xcb:Window:None)))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should never hit this case but I'm not 100% sure there isn't a race somewhere (e.g., when creating new workspaces).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why use exwm-workspace--current here instead of frame, since we called x-focus-frame on frame? Should be the same, right? Instead of the or with xcb:Window:None you could also preserve the old exwm-input--set-active-window calling convention which allows a nil argument, such that the change is overall more minimal.

@@ -373,23 +373,25 @@ attempt later."
window)
(exwm--defer 0 #'exwm-workspace-switch (selected-frame)))
;; The focus is still on the current workspace.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This case is only supposed to cover switching focus within a workspace, not between workspaces. However, from my testing, we hit this case when switching workspaces anyways so there's no need to update _NET_ACTIVE_WINDOW from the other case.

@Stebalien
Copy link
Contributor Author

I've tested this with multiple workspaces, multiple monitors, floating windows, etc. so I think I've covered most cases. Posframe windows that take focus (e.g., vertico-posframe) treat the current workspace as focused but, IMO, that's fine.

@minad
Copy link
Member

minad commented Jan 2, 2025

There are two other places in exwm.el and exwm-workspace.el where x-focus-frame is used. Would they also need a similar treatment? Most likely not given that exwm-input--set-active-window is not already used there?

@Stebalien
Copy link
Contributor Author

  • exwm--on-net-active-window is reacting to _NET_ACTIVE_WINDOW.
  • I'm not entirely sure why this doesn't need to be called in exwm-workspace-switch, but it seems to work. My guess is that exwm-input--update-focus gets called because we're focusing a new window. From what I can tell, that x-frame-focus call isn't actually necessary either. The git history indicates otherwise but the focus switching logic has changed significantly since then.

@Stebalien Stebalien merged commit 26d24e5 into master Jan 3, 2025
@Stebalien Stebalien deleted the steb/mark-emacs-as-active branch January 3, 2025 17:37
@Stebalien
Copy link
Contributor Author

(merging because I haven't run into any bugs so far)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Setting _NET_ACTIVE_WINDOW to emacs when non-EXWM buffer in focus
2 participants