GNOME Bugzilla – Bug 429347
Dogtail's utils.screenshot() not working properly on exported display
Last modified: 2011-02-07 06:10:52 UTC
Please describe the problem: When an application is running on the same host but is shown on another display using Dogtail's utils.screenshot() function produces pure black images. However using other procedural API (e.g. click("Next")) is working fine. Steps to reproduce: 1. Start a second GNOME session on the same machine. 2. $ export DISPLAY=:0 ## we are running at :1.0 3. $ python Python 2.4.3 (#1, Dec 11 2006, 11:39:03) [GCC 4.1.1 20061130 (Red Hat 4.1.1-43)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from dogtail.utils import * Creating logfile at /tmp/dogtail/logs/log_20070413-151513_debug ... >>> screenshot() GTK Accessibility Module initialized Screenshot taken: /tmp/dogtail/screenshot_20070413-151517.png '/tmp/dogtail/screenshot_20070413-151517.png' >>> Ctrl+D 4. Open the image with EOG. It is black. Actual results: The produced screenshot is pure black color. Expected results: The produced screenshot must show the applications visible on user's desktop. Does this happen every time? yes Other information:
Sorry, I thought I had commented on this. I can't reproduce this problem...
I can reproduce the problem. Here is some information about packages versions: dogtail-0.6.1-2.el5 gtk2-2.10.4-16.el5 pygtk2-2.10.1-8.el5 What other info do you need? Can you make screenshots on exported display?
The above rpm versions are on RHEL 5 Below is on clean install on Fedora 7: dogtail-0.6.1-1.fc7 pyspi-0.6.1-3.fc7 gtk2-2.10.13-1.fc7 pygtk2-2.10.4-2.fc7
(In reply to comment #1) > Sorry, I thought I had commented on this. I can't reproduce this problem... > 1. Log in to your GNOME session. This is DISPLAY=:0 2. press Ctrl+alt+F1 to go to the text console 3. log in with your username (no root) 4. type: startx -- :1 (which start a second GNOME session here) 5. open gnome-terminal and type: $ export DISPLAY=:0 ## we are running at :1.0 $ python >>> from dogtail.utils import screenshot() >>> screenshot() GTK Accessibility Module initialized Screenshot taken: /tmp/dogtail/screenshot_20070413-151517.png '/tmp/dogtail/screenshot_20070413-151517.png' >>> Ctrl+D 6. Now press Ctrl+Alt+F7 to return to the previous GNOME session (:0) 7. Open the image with EOG (or other image viewer). 8. Resulting image is black. Additional info: - it's not necessary to start a second GNOME session. You may skip step #4, the result is the same. - I have a script starting Xvnc on :1 and a Dogtail script which succeeded in taking the screenshot. I will investigate further.
Created attachment 100838 [details] shows that screenshot() works Steps to reproduce it working: 1) run Xvnc :1 2) export DISPLAY=:1 3) run some application 4) dogtail.utils.screenshot()
OK, I'm not sure why I was unable to reproduce this before, but I can now. Here's the code in question: import gtk.gdk import gobject rootWindow = gtk.gdk.get_default_root_window() geometry = rootWindow.get_geometry() pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, geometry[2], \ geometry[3]) gtk.gdk.Pixbuf.get_from_drawable(pixbuf, rootWindow, \ rootWindow.get_colormap(), 0, 0, 0, 0, geometry[2], geometry[3]) # gtk.gdk.Pixbuf.save() needs 'jpeg' and not 'jpg' if fileExt == 'jpg': fileExt = 'jpeg' try: pixbuf.save(path, fileExt) except gobject.GError: raise ValueError, "Failed to save screenshot in %s format" % fileExt It seems like since the root window has the correct dimensions (at least in my case), that everything would be fine. But for some reason gtk.gdk.Pixbuf.get_from_drawable() isn't doing anything - it's leaving the pixbuf blank.
Ugh, I wonder if this is our problem: http://www.moeraki.com/pygtkreference/pygtk2reference/class-gdkpixbuf.html#method-gdkpixbuf--get-from-drawable "If src is a window, and the window is off the screen, then there is no image data in the obscured/offscreen regions to be placed in the pixbuf."
I think they are referring to window's coordinates off the screen, especially bottom right corner. I think this might be interesting too: "The gtk.gdk.get_default_root_window() function returns the root gtk.gdk.Window (the parent window that all other windows are inside) for the default display and screen." ^^^^^^^^^^^^^^^^^^^^^^^^^^ But i might get it wrong. -- mb
What would the default be other than $DISPLAY?
btw, when reproducing this I didn't even start a second session; I just used my already-running one.
(In reply to comment #10) > btw, when reproducing this I didn't even start a second session; I just used my > already-running one. > So you skipped sstep #4 in comment #4, right? Something interesting: The working script in comment #5 has the following properties: The process that starts X server (Xvnc) also exports display and runs the application and the Dogtail script. All sub-processes have the same parent. In the non working reproducer X has already been started from init, and the Dogtail script is started from another terminal. I think they don't have the same parent. Not sure if that helps or is relevant. I'm not a GTK guy so that's pretty much what I can do.
dogtail development has been stalled and it has been unmaintained for a few years now. Maintainers don't have future development plan so i am closing bugs as WONTFIX. Please feel free to reopen the bugs in future if anyone takes the responsibility for active development.