How to use setScope in layer-shell-qt ? Is it really static?

Hello everyone :slight_smile:

I want to set a window’s scope use the LayerShellQt::window::setScope function in package layer-shell-qt. And here is the source code of setScope:

// layer-shell-qt code
void Window::setScope(const QString &scope)
    d->scope = scope;
    // this is static and must be set before the platform window is created

As the comment, setScope is static. But I don’t think that it’s a static function.

And here is my code:

// my demo code
if (auto layerShellWindow = LayerShellQt::Window::get(window->windowHandle())) {
    qDebug() << "MMMMMM scope is " << layerShellWindow->scope();
    qDebug() << "MMMMMM scope now is " << layerShellWindow->scope();

I can set the scope to “screenlock” successfully. But in KWin, It seems the scope is from another library(maybe wayland or kwayland-server, I’m not sure, only working on this for a few days) , and it seems that it has nothing to do with layer-shell-qt. So in this code of KWin, the scope is always “window”, which is the default scope in layer-shell-qt of class WindowPrivate.

// KWin code
LayerShellV1Client::LayerShellV1Client(LayerSurfaceV1Interface *shellSurface,
                                       AbstractOutput *output,
                                       LayerShellV1Integration *integration)
    : WaylandClient(shellSurface->surface())
    , m_desiredOutput(output)
    , m_integration(integration)
    , m_shellSurface(shellSurface)
    , m_windowType(scopeToType(shellSurface->scope()))

In summary, how to use the setScope function in layer-shell-qt, is there a demo? Or is it wrong?

Thank you all! My respect :slight_smile:

Been working on for a while, I’ve found that the interface setScope(my modified function, not the origin one) and setLayer works when the window is QQuickWindow type, and don’t work when the window is widget type.

Don’t know why, but I would check it out if I got time.

here is the working code:

#include <QApplication>
#include <QQuickView>

#include <KWindowSystem>

#include <LayerShellQt/Shell>

int main(int argc, char *argv[])

    QApplication app(argc, argv);

    QQuickView window;


    if (auto layerShellWindow = LayerShellQt::Window::get(&window)) {


    return app.exec();

NOTICE! You should call setLayer before!

Does anybody know why it’s working for QQuickWindow type but not QWidget type?

Thanks in advance:)