drawing on the X11 root window with Qt5

René J. V. Bertin rjvbertin at gmail.com
Tue Mar 7 10:48:05 UTC 2017


Hello,

May I ask a question not directly related to Plasma but that hopefully concerns 
a trick used in some Plasma component?

Basically, is it still possible to get a QWidget corresponding to the X11 root 
window and draw on it as on any other QWidget, and if so, how does one do that?
A few pointers to relevant Plasma code should already help a lot.

The Qt4 approach I found that works is something like

class Foo : public QWidget
{
public:
    Foo(WId id)
        : QWidget()
    {
        if (id) {
            create(id, false, true);
        }
    }
};

where Foo(QX11Info::appScreen()) would correspond to a subclassed QWidget that 
displays on the root window.

The suggested replacement method using 
QWidget::fromWindowContainer(QWindow::fromWinId(id)) doesn't allow subclassing 
but I also cannot get it to work. I get 2 standard windows when I pass in the 
root window WId, plus paintEngine errors that don't come from my own code. It 
probably doesn't help that it's been a long time since I coded for X11 and I 
never used the XCB APIs.

Thanks,
R.



More information about the Plasma-devel mailing list