Skip to content

qt: add Wayland compositing

qt: add Wayland window compositing

Patch

The window compositing is organized like so:

  • A main window is created to render potential window decorations
  • An interface window is created to render the UI and attached to the main window.
  • A video window is created and attached to the main window.

When starting a video, both the interface and the video are made subsurfaces of the main window, by tinkering with the underlying wayland objects. This is done in a separate module (which is only started when necessary) in order to prevent the compositing module from depending on Wayland.

Known issues

  • The window is moved suddenly when first resized frop the top or left under Weston - this does not happen under any other desktop environment. This bug disappears with Qt 5.15, but some distros do not ship this version.
  • The video and interface subsurfaces are not resized correctly when starting a video under Enlightenment - resizing it manually fixes the issue. Seems I can't reproduce this anymore.
  • The UI becomes unresponsive after closing the PiP video, but this is because of the EGL context reference counting issue.
  • The Client-Side Decorations can't be used to move or resize the window, and with certain compositors some buttons (minimize, maximize, close) do not work or cause problems (the window disappears when exiting maximized mode with Weston, and maximizing behaves unpredictably with Sway).

Tested desktop environments

  • Enlightenment
  • Plasma
  • Gnome
  • Sway
  • Weston

Why such a complicated setup

The obvious approach of rendering the UI in the main window and only using one subsurface for the video is unfortunately not very realistic since several major desktop environments only support ordering subsurfaces among themselves (and not relative to the main surface). This results in the video surface appearing on top of the translucent UI or randomly switching from foreground to background.

It is technically possible to detect the Wayland compositor in use (albeit in an extremely dirty way) and get its version number, so we could alternatively use this broken approach where applicable and refuse compositing on old or buggy compositors. Here is the list of compositors without support for this obvious approach so far:

  • Enlightenment
  • Sway (or any wlroots-based compositor before 0.14.1)
  • Plasma (should be fixed in kwin 5.23)

A compositor detection proof-of-concept has been developed and can be tested using this branch (modules/gui/qt/maininterface/compositor_wayland.cpp lines 70 to 700).

Edited by Guillaume Nicolussi Castellan

Merge request reports