Wine and Wayland take another step closer with more code merged
The ongoing work bit by bit to get Wine and Wayland to fully work together on Linux has taken another step, with a third big merge request accepted. Wine 8.4 from mid-March was the first development release to actually have some of the initial Wayland work in it.
From the merge request that's now accepted:
This MR introduces the driver mechanisms to handle dynamic events from the Wayland compositor, using wl_output events as the guiding use case (i.e., we want to update the win32u display settings when the host settings change).
In this design we create a dedicated thread to read and dispatch Wayland events received from the compositor. If a Wayland event handler wants some code to be run in the context of a particular HWND's thread, it can add an internal event to a custom queue we have for each (GUI enabled) thread. The ProcessEvents driver callback processes internal events from that queue. In order to wake up waiting threads we use a pipe to notify about new internal events, with the read end acting as the thread's host queue fd. This is similar to how winemac.drv works.
We use the aforementioned mechanisms to queue win32u display device updates to the desktop window thread. Since there are many pieces that need to fall into place, this MR gradually reaches the final design:
Why is this actually needed? Well currently Wine uses X11, and so for anyone running Wayland it will then be run through XWayland, which is basically X running under Wayland like a compatibility layer. As Collabora said in their original announcement back in 2020 talking about it they said it's "a source of complexity and possible inefficiencies" and so it would "be ideal if Wine could talk directly to Wayland to enable a leaner and more efficient stack on modern systems"
So the end result should be for users on Wayland, which will eventually be everyone, to have Wine work without the XWayland layer and have it all work nicely far into the future.
Liam Dawe About the author - Liam Dawe