Qt/XCB drawing on the root window

René J.V. Bertin rjvbertin at gmail.com
Sun Sep 13 16:32:14 BST 2020


Hi,

I have some old Qt4 code I'm porting to Qt5 that includes this

```
void
MyApplication::renderDone()
{
    QPalette palette = desktop()->palette();
    palette.setBrush(desktop()->backgroundRole(), QBrush(renderer->pixmap()));
    desktop()->setPalette(palette);
    //QApplication::setPalette(palette);
    if (dpy) {
       //XSynchronize(dpy, true);
        XClearWindow(dpy, desktop()->winId());
    }

    renderer->saveCacheFile();
    renderer->cleanup();
// ...
    QTimer::singleShot(1000, this, &MyApplication::quit);
//     quit();
}

main()
{
//....
        // Keep color resources after termination
        XSetCloseDownMode(app.display(), RetainTemporary);
//....
}
```

Some of you may recognise this as part of KDM, and that'd be correct :)

Displayed in a window, `renderer->pixmap()` is identical in Qt4 and Qt5, but only Qt4 gives me an actual image on the X11 root window (tested with the Xephyr nested window server). QDesktopWidget::winID() returns the correct X11 Window so the differences can only be in what the QWidget::setPalette() does behind the scenes and how that trickles down to the underlying Window atom. Or in what it does in addition, like only actually applying the setting before doing some actual painting via the QPA, and then restoring the initial configuration?

I've tried to achieve what I want via Qt calls but have gotten nowhere with that either.

How does one do this sort of thing in Qt5? Clearly some part of the KF5 Plasma code manages to do what I'm trying to do, but which? 

Thanks,
R.


More information about the Plasma-devel mailing list