I am writing a GTK2 widget that shows images of all open windows. These images will update in real time.
To do this, I will use the X11 Damage extension. As far as I understand, the first step is to register an interest in damage events for a given window, like this:
damage = XDamageCreate (dpy, xid, XDamageReportNonEmpty);
How can I connect a signal handler to an X11 damage event? I will also need to pass the widget's structure into this callback function.
It is important that the execution of the rest of my GTK program is not halted while waiting for the events.
Update:
On further research, it would seem that I can respond to X11 events using gdk_window_add_filter
. It seems to respond to many events, but it does not seem to respond to damage events. How can I make it respond to damage events?
Also, how can I prevent the callback function from causing an infinite loop when it updates the images?