Search code examples
c++x11xlib

How to watch any window movements with xlib?


How do I track move event for all the windows? Like if user moves window "Pluma" my daemon would receive window name and new coordinates.

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

I tried tracking it like this, but it does not work...


Solution

  • You need t select SubstructureNotify mask on the root window first:

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

    This way you are telling X server "I'm interested in root window childrens move/resize/delete/create events"