Repository navigation
linux: focus follows window activation - #98
Draft
sduguay-devolutions wants to merge 2 commits into
Draft
sduguay-devolutions wants to merge 2 commits into
sduguay-devolutions wants to merge 2 commits into
Conversation
Focus reached the native web view only through the control's OnGotFocus and OnLostFocus, which follow Avalonia's logical focus inside the window. Avalonia leaves that focus on the control while the window is deactivated, so the adapter was never told, and a GTK toplevel that is offscreen or reparented into another window never hears from the window manager either. The focus synthesized for the caret therefore stood while the user worked in another application: the caret went on blinking and the page still reported document.hasFocus(). Follow the top level's activation as well, resigning while the control holds focus and taking it back when the window is activated again.
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.
Issue
Related to #85
Click into another application and the web view act as if it still had focus.
The text caret keeps blinking and the page still reports document.hasFocus() true.
Focus only ever reached the adapter through the control's OnGotFocus and OnLostFocus,
which follow Avalonia's logical focus inside the window. Avalonia leaves that focus on
the control when the window is deactivated and ResignFocus is never
called.
Fix
Follow the top level's activation as well as the control's focus. On attach we take
TopLevel.GetTopLevel(this) as WindowBase and listen for Activated and Deactivated,
resigning focus on the way out and taking it back on the way in, in both cases only
while the control actually holds focus. Unsubscribed on detach, and re-resolved if the
control is attached somewhere else.
Verified on both Linux adapters, offscreen and native X11.
One thing to know