Custom Desktop Panel Placement in KWin with Wayland

I used to use KDE with X11 some time ago (pre-Wayland & Plasma) and now I’m returning to KDE. I remember that I was able to use window manager hints in Qt5 to control the placement of a custom desktop panel, specifically at the bottom of the desktop. However, with my return and KWin now using Wayland, I understand that the old method doesn’t necessarily apply, as Wayland does not allow applications to control their own window positions like X11 did.

I’m seeking advice on how to place a custom desktop panel at the bottom of the desktop under KWin with Wayland.

Is there a recommended way to achieve this in the current Wayland environment? Is there a Qt or KDE API that I can use for this? Any guidance or suggestions you can offer would be greatly appreciated.

Thank you in advance for your assistance.

If true and the devs want to make Wayland default with the release of Plasma 6.0 there IS going to be major blowback.

See here. Window and Dialog Widgets | Qt Widgets 6.6.0

Wayland Peculiarities

On Wayland, programmatically setting or getting the position of a top-level window from the client-side is typically not supported. Technically speaking, it depends on the shell interface. For typical desktop compositors, however, the default shell interface will be XDG Shell, which does not support manual positioning of windows. In such cases, Qt will ignore calls to set the top-level position of a window, and, when queried, the window position will always be returned as QPoint(0, 0).

After dedicating approximately 9 hours to studying the QtWayland APIs and engaging in brainstorming sessions with ChatGPT, I’ve come to the conclusion that the most suitable approach for creating a desktop panel involves utilizing a toplevel xdgshell. By setting the x, y, width, and height of the dock and preventing it from being moved, we can establish the foundation for the panel.

To address the secondary behavior of the dock, where windows cannot overlap or go beyond its bottom (in the case of docking it to the top of the screen), we reserve a specific section of the screen that corresponds to the occupied area of the dock. The compositor then enforces this restriction by disallowing any windows from extending into this reserved space.

However, there is a significant challenge with QtWayland: it lacks the capability to set a xdgshell’s geometry (x, y). Consequently, this limitation renders QtWayland unsuitable for creating a fully functional and comprehensive compositor. Attempts to manually position windows using the XDG Shell are futile as Qt simply ignores such calls, always returning the window position as QPoint(0, 0).

First 1/2 of what ChatGPT is made up. Second sound like all the more reason for the devs to continue where the Latte dev(s) left off cause I’d bet it won’t have the aforementioned issue.

First 1/2 of what ChatGPT is made up.

Are you saying that the information I posted is incorrect, or are you just saying that ChatGPT “makes things up in general”? I’m not sure what you mean, and it’s important for me to understand the context of your statement. It could lead me to think that my understanding of a complex topic is wrong when it might actually be correct.

Pretty damn sure you’ve seen the articles. ChatGPT is designed to fill in what it doesn’t know by make something up.

Your information is incorrect/mixes up a lot of things. So yeah, don’t use ChatGPT to study topics you don’t understand, it’s going to end poorly

3 Likes

xdg-shell is the protocol used for “regular” application windows. Despite having “shell” in the name it is not suitable for developing Shell/Desktop environment components as in plasmashell. For example it (by design) doesn’t allow windows to position themselves, which is why the Qt API for it doesn’t work on Wayland.

For developing things like panels you need a different protocol that allows to do things regular application windows can’t do. The de-facto standard for this is the layer-shell protocol, which is used in Plasma for the panel and other things. It allows to place your window in a semantic manner, e.g. “Place it on the top screen edge, offset by 20 pixel”. While Qt by default uses xdg-shell for its windows you can make it use layer-shell using layer-shell-qt

2 Likes

I am aware that ChatGPT sometimes produces incorrect information (makes stuff up), but it also gets a lot of things right. Some friends and a couple of bug bounty hunters and I tested ChatGPT by having it generate over 100 C++ classes that consisted of various data types, software design patterns (Observer Pattern, Publisher-Subscriber Pattern, Mediator Pattern, Command Pattern, etc.), algorithms (easing algorithms, grid, list, linear, depth search algorithms, DFS, etc.), and other concepts.

Out of those 100 classes, ChatGPT couldn’t generate functional code for only 3 specific classes. We found that 50% of them had security-related bugs, but those issues were fixed on a second or third pass when we asked it to check the libraries for security vulnerabilities. Additionally, 10% of the generated code needed to be rewritten for performance reasons.

Overall, ChatGPT is really good at the things it understands and performs well, but it can struggle with topics or concepts it isn’t familiar with.

Thank you so much for your response; it is a big help. I also found the following repositories that might be useful:

I’m not entirely sure how useful these repositories are, but they do look promising.

I wanted to demonstrate the usefulness of ChatGPT. Obviously, we have to factor in that not everything AI tells us will be correct, but that’s not really the point. The point is to gather and discover what information is correct, so that we are able to build a more complete picture of whatever it is we are trying to learn. As far as I know, no schools or universities are currently teaching Wayland, and the experts in the field have yet to write any complete and up-to-date books on it. Therefore, non-experts have to rely on any and all information we can discover and learn on our own. Although we could read the Wayland source, that’s not always helpful when we don’t understand the underlying concepts of Wayland. Duplication of efforts happens when one wants or needs to accomplish a task, yet available solutions are too complex or lack proper learning material.

Prompt:
Are you familiar with layer-shell

Response:

Yes, I’m familiar with the term “layer-shell.” Layer-shell is a concept related to graphical user interfaces and window management in the context of Linux desktop environments, such as Wayland.

In traditional X Window System (X11) environments, window managers control how application windows are displayed on the screen. However, with the advent of Wayland, which is a modern display server protocol designed to replace X11, a new approach to window management was introduced.

Layer-shell is an extension of the Wayland protocol that provides a mechanism for applications to specify the stacking order and positioning of their windows in a compositor. A compositor is a component that manages the rendering and positioning of windows on the screen. By using the layer-shell protocol, applications can communicate their window’s stacking behavior directly to the compositor, enabling better control over how the windows are displayed.

The layer-shell protocol introduces the concept of different layers, each with its own properties, and windows can be assigned to specific layers. These layers include:

Background layer: For wallpapers and background content.
Bottom layer: For windows that should be placed below regular windows, such as desktop widgets or panels.
Top layer: For windows that should always be on top of other windows, such as notification pop-ups or the system tray.
Overlay layer: For special full-screen windows that can capture input events.

Using layer-shell, applications can request the compositor to place their windows in the desired layer, which can be useful for implementing various GUI elements and ensuring proper rendering order.

It’s important to note that the layer-shell protocol is specific to Wayland-based desktop environments and is not directly related to the X11 window management system. However, it represents a step forward in terms of modernizing window management in Linux environments and providing more flexible and efficient handling of graphical elements on the screen.

What exactly do you mean by “a custom desktop panel”? Are you referring to a standard Plasma panel? If so, you can position it anywhere you want with no issues on Wayland.

Or are you referring to something you’ve developed as part of a piece of software? If so, there are still ways to do it on Wayland, as @nicolasfella already explained.