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

OptionalFeatureProvider in Linux Framebuffer platform #15657

Open
Oaz opened this issue May 8, 2024 · 4 comments
Open

OptionalFeatureProvider in Linux Framebuffer platform #15657

Oaz opened this issue May 8, 2024 · 4 comments

Comments

@Oaz
Copy link

Oaz commented May 8, 2024

Is your feature request related to a problem? Please describe.

FramebufferToplevelImpl.TryGetFeature currently return "null".
public object TryGetFeature(Type featureType) => null;

As a consequence, optional features such as Clipboard cannot work on Linux Framebuffer platform

Describe the solution you'd like

FramebufferToplevelImpl could implement basic optional services retrieval

e.g.
public object? TryGetFeature(Type featureType) => AvaloniaLocator.Current.GetRequiredService(featureType);

As far as I can tell, it would be enough for a working custom clipboard in Linux Framebuffer.
The clipboard could just be injected with

  private static AppBuilder BuildAvaloniaApp() => AppBuilder.Configure<App>()
      .With((IClipboard) new MyCustomClipboard())

Describe alternatives you've considered

I could not find any other option to inject a clipboard in Linux Framebuffer as creation of FramebufferToplevelImpl is hardcoded in LinuxFramebufferPlatform.
The only alternative would be to entirely rewrite LinuxFramebufferPlatform.

Additional context

This issue came up as I was writing an extended LibInputBackend with keyboard event handling : https://github.com/Oaz/Avalonia.LibInputExperiments

In a TextBox control most of Ctrl Keys are working fine (Ctrl-A, Ctrl-Z...) but copy pasting is not working even though the CopyingToClipboard/PastingFromClipboard events are raised as expected. I eventually figured out that a clipboard instance was missing.

@Oaz Oaz added the enhancement label May 8, 2024
@maxkatz6
Copy link
Member

maxkatz6 commented May 8, 2024

public object? TryGetFeature(Type featureType) => AvaloniaLocator.Current.GetRequiredService(featureType);

It shouldn't call GetRequiredService on any type. Instead, it should check only for known interfaces, like IClipboard.

@kekekeks
Copy link
Member

kekekeks commented May 8, 2024

We should probably provide a stub clipboard implementation for fbdev, yes.
However we shoudn't fallback to locator.

@Oaz
Copy link
Author

Oaz commented May 10, 2024

As far as I am concerned, just having a clipboard is fine.

Though, by curiosity, I'd like to know what is wrong with calling locator on any required type in this scenario since AppBuilder.With binds the options into the locator with no type filtering? The absence of symmetry does not feel intuitive to me.

@maxkatz6
Copy link
Member

We don't encourage AppBuilder.With/TryGetService to be used as a public service locator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants