Repository navigation
Conversation
A window that starts without the keyboard focus, as a screenshot run's often does, can still be sent WindowFocused(false). The WindowBlur rule then dismissed any overlay already drawn, so a popover opened on the first frames closed at once. An open overlay now remembers, on its stack entry, whether the window had the focus (egui's InputState::focused) in a frame it was drawn. A window blur dismisses only an overlay that has; a window that never had the focus can't lose it. The other rules are unchanged. Behaviour change: an overlay opened while its window has no keyboard focus is no longer dismissed by a blur until the window has gained the focus while it is open. Part of #326. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PWiKKf74MNWrhkW1CvKVUP
Owner
Author
|
Approved by the user (2026-11-18). Gate (my run with current main): |
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.
Part of #326: the blur bug, which needs no API decision.
DismissOn::Outside,on_dismiss_withandfocus_on_openwait for the user's answers on the issue.The bug
A window that starts without the keyboard focus, as a screenshot run's often does, can still be sent
WindowFocused(false). TheWindowBlurrule indismiss::dismissalsthen dismissed any overlay already drawn, so a popover opened in the first frames closed at once.Proven first:
a_window_that_never_had_focus_while_it_was_open_does_not_dismiss_itfailed on main. It takes the window's focus away (as egui-winit does:RawInput::focused = falseplus the event), opens the popover, and sendsWindowFocused(false). On main the popover was dismissed.The fix
dismiss::WindowFocus { Had, NotYet }: a crate-internal enum, kept on each open overlay's stack entry (stack::Open::window_focus) and carried into itsLayer.judgesetsHadat the end of a frame in which the overlay is drawn while egui says the window has the focus (InputState::focused).Had. A window that never had the focus while the overlay was open can't lose it.focuseddefaults totrue, so the existing blur test is unaffected.layers_of's closure now returns a namedRemembered { focus_before, focus_now, window_focus }instead of a tuple.Behaviour change
An overlay opened while its window doesn't have the keyboard focus is no longer dismissed by a window blur until the window has gained the focus while the overlay is open. Gaining the focus doesn't dismiss anything.
Tests
tests/it/overlay_input.rs, popover module, through the real draw path:a_window_that_never_had_focus_while_it_was_open_does_not_dismiss_it(failed on main);a_window_that_gains_focus_while_it_is_open_dismisses_it_on_losing_it: the window is unfocused when the popover opens, gains the focus (nothing is dismissed), then loses it (dismissed);dismiss.rs):a_window_blur_dismisses_only_an_overlay_shown_while_the_window_had_focus, which also checks that an outside press still dismisses aNotYetlayer.Hadset whether or not the window has the focus: the never-had-focus test fails;Hadnever set: the existingthe_window_losing_focus_dismisses_itand the gains-focus test fail.No UI change and no public API change. No
TODO(prose).git diff origin/main HEAD --statcargo xtask ciexits 0 on 7f485ab (ef87169 merged with main a8e1ec7).🤖 Generated with Claude Code
https://claude.ai/code/session_01PWiKKf74MNWrhkW1CvKVUP