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

[WIP] Add Wayland backend #11546

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

Conversation

affederaffe
Copy link
Contributor

@affederaffe affederaffe commented May 28, 2023

What does the pull request do?

Add a Wayland backend for Linux.
This PR is based on the previous one with significant bug fixes and easier maintenance .

In order to test this PR, locally building NWayland NuGet packages is required:
git clone --recursive https://github.com/affederaffe/NWayland next to the Avalonia directory

├── Avalonia
│ ├── samples
│ ├── src
│ ├── ...
├── NWayland
│ ├── src
│ ├── ...

Navigate to ./NWayland/src/NWayland.Scanner and dotnet run to generate the bindings.
Then dotnet build -c Release the ./NWayland/src/NWayland and ./NWayland/src/NWayland.Protocols.Plasma projects, which creates the required NuGet packages.

These steps won't be necessary once NWayland is released officially on NuGet.

TODOs:

  • Better CSD integration
  • IME

What is the current behavior?

XWayland is used in order to run Avalonia apps on Wayland systems.

What is the updated/expected behavior with this PR?

Use Wayland instead of X11 on compatible systems.

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

Checklist

Breaking changes

None

Obsoletions / Deprecations

None

Fixed issues

Fixes #1243
Fixes #2338

@iMonZ
Copy link

iMonZ commented May 29, 2023

Thank you so much for your work! I hope this gets merged into 11!

@iMonZ
Copy link

iMonZ commented May 29, 2023

@affederaffe Do you think this can be still merged for the 11 update?

@affederaffe
Copy link
Contributor Author

There are still some minor bugs to be fixed before merging and since Avalonia 11 seems to be moving closer and closer to RCs (feature freeze), I don't think we'll see this merged before 11.0. 11.x seems to be possible though, see the prior discussion

# Conflicts:
#	src/Avalonia.DesignerSupport/Remote/Stubs.cs
#	src/Headless/Avalonia.Headless/HeadlessWindowImpl.cs
@danwalmsley
Copy link
Member

There are still some minor bugs to be fixed before merging and since Avalonia 11 seems to be moving closer and closer to RCs (feature freeze), I don't think we'll see this merged before 11.0. 11.x seems to be possible though, see the prior discussion

11.1.

11.0 rc is coming in a matter of days and the team wont have time to test or review this in that time.

11.1 is likely to be very very soon after 11.0 however.

@jgcodes2020
Copy link
Contributor

jgcodes2020 commented Oct 25, 2023

It's not really possible to share a single connection between two toolkits (in some event handlers it's not clear which of the subscribers has ownership over the object created by libwayland-client and it's not possible to tell if there are subscriptions from another toolkit

When it comes to "ownership" of a Wayland object there is wl_proxy_set_tag but it's just a tag that exists per-object. The event handler thing is still definitely an issue I think.

@jgcodes2020
Copy link
Contributor

Adding on to some of my previous comments here: providing access to all Wayland singletons used by Avalonia (wl_display, wl_compositor, etc.) plus wl_surface handles is necessary for embedding, as the wl_subsurface has to be created on the same connection as the parent.

@iMonZ
Copy link

iMonZ commented Jan 4, 2024

There are at least 2 blockers from my side:

  • general support for CSD in the base framework (stealing pixels from ClientSize isn't a good idea)
  • merge changes to NWayland and make it to be properly packaged

Still the same issues left?

@ErikApption
Copy link

ErikApption commented Jan 4, 2024

We'll need to think about SDL/VLC integration, since those probably expect being non-primary toolkits in the app.

Going to assume that this is wayland related - I'm using the unofficial avalonia vlc with overlay on Avalonia. Overlay/compositing/alpha works fine but when I exit the app the whole screen freezes and spits

gnome-shell[1685]: Window manager warning: Buggy client sent a _NET_ACTIVE_WINDOW message with a timestamp of 0 for 0xa0016f
mpp[35290]: mpp_info: mpp version: unknown mpp version for missing VCS info
gnome-shell[1685]: Window manager warning: Invalid WM_TRANSIENT_FOR window 0xa00169 specified for 0xa0016f.

Looking at the Avalonia Window source code and Ryujinx, I'm wondering if Avalonia needs to expose better Window close methods for native components but other than that, the hack from the unofficial VLC with an Avalonia window on top of the VLC component works like a charm.

@affederaffe
Copy link
Contributor Author

affederaffe commented Jan 24, 2024

As I see it window embedding isn't really a problem anymore, at least on the video-player side.
phonon-vlc seems to be able to integrate vlc and mpv can also be used with an GL context iirc.
SDL seems also be possible now: https://wiki.libsdl.org/SDL3/README/wayland#importing-external-surfaces-into-sdl-windows

@IsaacMarovitz
Copy link

Any update on this PR?

@affederaffe
Copy link
Contributor Author

There's still some work to do:

  1. Client Side Decorations: Probably needs support in Avalonia.Base Window itself, as pointed out, stealing client side pixels isn't a good idea
  2. Touch support: currently just crashes when receiving a touch
  3. IME support: currently in progress
  4. NWayland NuGet package (submopdules are tolerable for my own development, but this approach won't work for master)
  5. For a smooth transition, 3rd-party-support, most important video players: needs to use the library directly without window embedding, see libMpv (for example, mpvqt and libVlc. Embedding support is just not feasible as stated above
  6. (optional) survive compositor crashes
    There's probably some more, those are just the things from the top of my head.

@cla-avalonia
Copy link
Collaborator

cla-avalonia commented Apr 26, 2024

  • All contributors have signed the CLA.

@barolo
Copy link

barolo commented Jul 26, 2024

is this dead?

@kekekeks
Copy link
Member

The plan is to figure something about CSD support in core avalonia and continue.

Alternatively we could release it without CSD for usage with embedded systems, wayland seems to be ready enough for those.

@affederaffe
Copy link
Contributor Author

There are just too many unresolved issues, until I have the time and motivation to address those this PR continues to be WIP and thus unmergable from my perspective.
If everything goes well I'll probably have some time in September to work on some of these issues.

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.

Chrome OS? Our own backend for Wayland