Window change event?

László Monda laci at
Mon Aug 5 13:48:12 PDT 2013

On Sun, Aug 4, 2013 at 5:16 PM, Thomas Lübking
<thomas.luebking at> wrote:
> On Sonntag, 4. August 2013 16:08:08 CEST, László Monda wrote:
>> I'm writing an application that has to be aware of the current window.
>> So far I've extracted the relevant code from xprop and put it into
>> .  (I screwed up
>> The above solution would work but it'd involve polling the info of the
>> current window from time to time which is not very efficient.
>> Wondering whether there's a way to register a callback for a "window
>> change" event.  That'd be so much more efficient.  Ideally I'm looking
>> for a way to do this in a window manager independent manner.
> XSelectInput(dpy, root, PropertyChangeMask );
> You'll then receive "PropertyNotify" type events (google for "X11 event
> handler" w/o quotes - you'll find examples for main event loop
> implementations) from the root window.
> Then you've to check whether it's the correct property.
> Notice:
> I didn't check what you're actually trying to do, but this is different from
> selecting input of FocusChangeMask on each interesting window and receive
> FocusIn/Out events.
> Focus and Active window do not necessarily have to go along each other (and
> also clients grabbing the keyboard might actually receive keyboard events)

Thank you very much Thomas, looks like a good starting point for me.
I'll be looking into XSelectInput().

> Cheers,
> Thomas
> _______________________________________________
> xorg at X.Org support
> Archives:
> Info:
> Your subscription address: laci at

László Monda <>

More information about the xorg mailing list