add click-to-focus player window with menu close - #936
Open
romanstingler wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a
Raisecommand to the media player module that focuses the player's window through the compositor.Clicking a player card now triggers this behavior, selecting the most recently focused window when multiple windows exist for the same player.
org.mpris.MediaPlayer2.Raise()is the MPRIS method intended to bring the player's UI to the front, and the players tested here advertiseCanRaise = true.On Wayland, successfully handling
Raise()still requires the player to get its own surface activated: normal activation is mediated byxdg-activation-v1and an activation token, and the compositor decides whether to honor it.The MPRIS spec itself notes that
Raise()may be prevented by the window manager even whenCanRaiseis true.In the tested cases the D-Bus call therefore succeeds while the player's window stays unfocused:
Since the tested players do not reliably get their windows activated this way, asking
the compositor directly is the dependable alternative.
FocusWindowByPidis thereforeimplemented for the Hyprland and Niri backends, and MPRIS
Raise()is kept as thefallback, for backends that cannot focus by pid (MangoWC, generic Wayland) and for
clients where self-activation does work, such as X11/XWayland windows.
Clicking a card also closes the menu, so it does not sit on top of the window that
was just focused.
Caveat
This focuses the player's window, not a browser tab. MPRIS reports that a player is playing but carries no tab information, so with
resolving pid to window gets you to the application/window level, not to the tab that owns the media.
A video playing in a background tab stays in the background.
Testing
configProvider: lua) with Firefox and Spotify: clicking acard focuses the player, and with two Firefox windows open it lands on the one that
was last used rather than on the picture-in-picture pop-up.
@MalpenZibo are you still using Niri ?
niri-ipc26.4 but is untested on a live Nirisession.