Communicating with a custom Qt Wayland compositor

269 Views Asked by At

I'm building a frontend on an embedded system running yocto, and using wayland for window compositing.

For reasons relating to threading, Qt, and external libraries, the application has been split in two. There is an application displaying a map, and there is a semi-transparent application showing an overlay with controls. The issue is that the background application takes longer to start, and is thus in the foreground when it starts.

My initial plan was simply to set 'Always on top' on the overlay and be done with it, but searching and reading have led me to the fact that this is not really a thing in Wayland.

The current solution in place hides the foreground window for a split second and shows it again, which works, but flickers the foreground window in an unpleasant way.

All of this has led me to attempt to create my own compositor based on Qt's example code, creating a compositor that will have a fixed layering order irrespective of startup sequence or clicking.

Now I run into the meat of the issue: I can't find a reasonable way to identify the windows I am creating in order to set their layering order. Ideally I'd like to find a window title or some other reproducible key, but it seems that Wayland does not support these things by design.

I've moved on to trying to identify the windows by their dimensions: setting the background window to be one pixel wider than the foreground. This seems like it could work, but checking the QWaylandCompositor (and related) objects when views/surfaces are created gives me -1 for both dimensions. I find that they are at some point later set to their proper dimensions, but this seems janky.

The ideal way would be to send some metadata from the client during surface creation, communicating whether the window should be on top. I'm assuming this could be possible using extensions, but I've not been able to find anything worthwhile on the subject online.

Is this possible at all? Am I looking in the wrong place?

1

There are 1 best solutions below

0
Axel Þór Ásþórsson On

I believe what you are looking for is the IVI Wayland shell. The IVI shell identifies application windows based on an environment variable that you set before an application is launched. The compositor will recognize this ID will move and resize the window so it fits the predefined area defined for this particular ID.

Please have a look at the IVI example from Qt on GitHub: https://github.com/qt/qtwayland/tree/dev/examples/wayland/ivi-compositor

The Weston compositor does have an implementation of this IVI shell as well that you could use, in which case you would have to configure Weston and define these areas.