Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XEmbed client support draft #17446

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

Conversation

kekekeks
Copy link
Member

@kekekeks kekekeks commented Nov 7, 2024

This will later be split into multiple PRs since alongside with XEmbed protocol changes it needs a refactor of our resize/rendering code for smooth window resize support.

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.3.999-cibuild0053137-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

EmbeddableControlRoot? Root => Window._inputRoot as EmbeddableControlRoot;
private bool _focusedInEmbedder;
private bool _embedderActivated;
private IInputElement? _savedFocus;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WeakReference?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although, if element is removed from the visual tree, KeyboardDevice should notify about this change.

{
((FocusManager?)Root?.FocusManager)?.SetFocusScope(Root);
if (_savedFocus != null)
KeyboardDevice.Instance?.SetFocusedElement(_savedFocus, NavigationMethod.Unspecified, KeyModifiers.None);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any particular reason to use KeyboardDevice? I don't see why we would avoid logical focus here, especially when we set focus scope explicitly.

You can use stable API and call _savedFocus.Focus(NavigationMethod.Unspecified, KeyModifiers.None). Which internally will also set focus correct scope, so you don't need to do it manually.


static XEmbedClientWindowMode()
{
KeyboardDevice.Instance.PropertyChanged += (_, args) =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have a good stable API for that. Needs something like FocusManager.GotFocus.
But InputElemement.GotFocusEvent.AddClassHandler should work here.

src/Avalonia.X11/X11Window.cs Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants