AvaloniaUI / Avalonia

Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The most popular .NET UI client technology
https://avaloniaui.net
MIT License
26.06k stars 2.25k forks source link

Fixed getting text from clipboard in Linux #17467

Open DemonExposer opened 2 weeks ago

DemonExposer commented 2 weeks ago

What does the pull request do?

It fixes issue #4320

What is the current behavior?

When calling X11Clipboard.GetTextAsync() in Linux (tested on Debian based), the task runs indefinitely (i.e. awaiting or .Result makes the current thread wait for an event to be handled, which does not happen)

What is the updated/expected behavior with this PR?

It returns the text which is in the clipboard without issue.

How was the solution implemented (if it's not obvious)?

It was implemented by skipping all the generic event handling and just handling the event in X11Clipboard itself (by calling X11Clipboard.OnEvent). The reason for this is that the generic event handling in Avalonia does not catch SelectionEvent. I could not figure out why. I assume it's some X11 issue not properly working with GLib. Either way, it works with my changes and OnEvent is still used.

Checklist

Breaking changes

Obsoletions / Deprecations

Fixed issues

Fixes #4320

avaloniaui-bot commented 2 weeks ago

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

cla-avalonia commented 2 weeks ago
DemonExposer commented 2 weeks ago

@cla-avalonia agree

avaloniaui-bot commented 1 week ago

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

avaloniaui-bot commented 6 days ago

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

DemonExposer commented 6 days ago

@kekekeks when is this going to get reviewed?

ApaulMyLittleAirport commented 5 days ago

I'm also having this clipboard issue on linux, hope to fix it, thank you very much!