如何使用xlib观察任何窗口移动



如何跟踪所有窗口的移动事件?就像用户移动窗口"Pluma"一样,我的守护进程会收到窗口名称和新坐标。

if(XCheckMaskEvent(display, -1, &event))
    {
        if(event.type == ConfigureNotify)
        {
            moved += event.xmotion.x + event.xmotion.y;
            //qDebug << moved;
        }
    }

我试着这样跟踪它,但它不起作用。。。

您不需要首先在根窗口上选择SubstructureNotify掩码:

XSelectInput(display, XDefaultRootWindow(display), SubstructureNotifyMask );

通过这种方式,您可以告诉X服务器"我对根窗口子级的移动/调整大小/删除/创建事件感兴趣"

最新更新