Repository navigation
Conversation
A shell can flip a layer surface from None to OnDemand in the same interaction as the popup grab — e.g. a tray menu whose bar was None at click time and is switched to OnDemand right before the popup maps, so the grabbed popup can carry keyboard. The grab handler then takes a keyboard grab, but the root never holds focus: the next focus recompute resolves target = None, reads "focus left the grab root", tears the grab down and ungrabs, dismissing the just-opened menu. Grant the OnDemand layer root the on-demand focus in the grab handler, mirroring what happens when the user clicks the layer first. Repro in src/tests/tray_menu_repro.rs. Fixes malbiruk#342
ReDeced
force-pushed
the
fix/layer-popup-grab-focus
branch
from
November 13, 2026 13:52
5fd9a30 to
0ff13e1
Compare
This branch has not been deployed
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.
Fixes #342.
Problem
A popup grabbed against a layer surface whose interactivity was flipped
None→OnDemandin the same interaction gets dismissed bypopup_doneone roundtrip after the grab. The grab handler takes a keyboard grab (the layer reads asOnDemand), but the root holds no focus: at click time the layer was stillNone, sofocus_layer_if_on_demandnever registered it, and the client's flip doesn't grant focus. The next focus recompute resolvestarget = None, reads "focus left the grab root", tears the grab down and ungrabs — dismissing the menu. Real-world symptom: tray menus in noctalia flash for ~13 ms and close.Fix
In the grab handler, when the popup root is a layer surface with
OnDemandinteractivity, grant it the on-demand focus before installing the grabs. Same state as the already-covered path where the user clicks the layer first.Tests
src/tests/tray_menu_repro.rs:None-interactivity layer (already worked, stays covered)None→ flip toOnDemand→ popup + grab (pre-fix: grab torn down,popup_done; post-fix: stays mapped)OnDemand+ click grants the layer focuscargo fmt --check,cargo clippy --all-targets -- -D warnings, fullcargo testpass.