fix(taskbar): focus Niri windows by compositor ID - #3705
Open
eaceaser wants to merge 1 commit into
Open
Conversation
Use Niri's ext-foreign-toplevel identifier to tie taskbar entries to numeric IPC window IDs, and prefer FocusWindow for activation. This avoids ambiguous app/title association and unreliable foreign-toplevel activation. Keep focus and close behavior keyed by the same IDs, with tests for activation precedence, stale IDs, focus events, and close requests.
eaceaser
force-pushed
the
fix/niri-taskbar-window-focus
branch
from
July 30, 2026 05:24
e6582ba to
1dad3fb
Compare
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.
Summary
Use Niri’s compositor window IDs to give each taskbar entry a stable identity for ordering, focus state, and window actions.
On
main, the taskbar builds its window list from the generic foreign-toplevel interface and reconciles those entries with compositor workspace data separately. This works when a foreign-toplevel handle is sufficient, but Niri’s workspace layout and focus operations are addressed by numeric window ID. Multiple windows from the same application can therefore be assigned by less-specific metadata such as app ID and title.This change adds a Niri-specific taskbar path that:
ext-foreign-toplevelidentifier as the immutable identity stored by each task.doneevent, so the taskbar only consumes complete records.When the exact Niri association is temporarily unavailable, the taskbar waits for the next IPC or foreign-toplevel update instead of assigning the window through app/title matching. Other compositors retain the existing generic behavior.
Motivation
On Niri, clicking a taskbar entry does not always focus the window represented by that entry. The problem is most noticeable with several windows from the same application and with windows on secondary monitors or other workspaces.
For example, two Ghostty windows can appear in one left-to-right order while clicking their taskbar entries focuses them in the opposite order. The focused-window indicator can consequently appear under the wrong entry as well.
Niri exposes the information needed to avoid this ambiguity:
ext-foreign-toplevel.Using that ID throughout the taskbar model ensures that displayed position, focused state, and click target all refer to the same compositor window.
Type of Change
Related Issue
N/A
Testing
meson test -C build-debug --print-errorlogs— 64/64 tests passedmeson compile -C build-debug noctalia--dry-run --WerrordoneManual Coverage
Screenshots / Videos
N/A — this changes taskbar window association and interaction behavior without changing its visual design.
Checklist
CONTRIBUTING.md.Additional Notes
gpt-5.6-sol was used extensively in debugging and implementation. I reviewed + iterated on the implementation to try to not overcomplicate this patch, but I did some digging around how other bars with Niri-specific behavior manage this, and they seem to just rely on Niri's specific IPC interface vs. using Wayland's generic interface. This avoids all ambiguity and issues with joining the Wayland vs. Niri representations together. I don't have enough context on the direction Noctalia is trying to take to know if that's a refactor worth exploring, but it does seem to be cleaner as far as the data model is concerned when using Niri.