Different X11 Window IDs for OpenGL and X11 Events

I’m trying to write ‘fraps for linux’, and I’ve gotten quite far, it
works, I can capture, save and replay the video. I enable the capturing
on a per-window basis, just in case an application has more than one
drawable (or a FBO or whatever). I hook glXSwapBuffers() and all the
X*Event() functions. When the user presses a magic key combination, I
setup the capturing for the given Display and Window (dpy and

And here lies the problem. SDL opens two connections to the server (I
can handle that, by comparing the DefaultRootWindow() …) but it also
creates two different windows, one for the events and one for opengl
(that’s what I can’t handle).

Any suggestions how I could work around this problem? I could have a new
magic key combination that would override the capturing and enable it on
whatever new window that the user calls glXSwapBuffers() on, but I hope
there is a better solution.