Issue extending ofxScreenGrab to linux

Hi! I’m trying to port my application which grabs the pixels under my ofApp window and forwards them via OSC to another program. This program works swell under OSX, but I’m having issues porting this to linux/X11. That app looks something like the app shown here:

http://forum.openframeworks.cc/t/grabbing-from-the-screen-osx
and I implemented it starting with the ofxScreenGrab addon here: https://github.com/genekogan/ofxScreenGrab

I’ve been having some luck using the technique found in “scrot”, which is to use imlib2, and imlib_create_image_from_drawable. imlib2 works w/ the underlying X11 windows, and the “drawable” I’m referencing is the underlying screen.

My issue is that ofGetWindowPositionX() and Y() seem to be returning the location of the top of the titlebar, not the screen location of the upper left of the canvas.

So my questions are:

  • Is there a good way to get access to the X11 Window associated with my application? I for the life of me can’t figure out how to grab it. If so, I think I can use XTranslateCoordinates to compute the actual screen location.
  • Should ofGetWindowPositionX() & Y() actually be returning the position of the canvas and this is a bug? Or am I super confused and just doing it wrong!
  • Any other ideas for screen capture under linux?

If it helps, I’m opening my window with:

ofSetupOpenGL(OUT_W*INIT_MULT, OUT_H*INIT_MULT, OF_WINDOW);

Thanks in advance,
-Scott