ksnapshot: Problem with offscreen pieces of windows

Bug #204358 reported by Some Thing
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
KDE Graphics
Unknown
Medium
kdegraphics (Ubuntu)
Triaged
Low
Unassigned

Bug Description

Binary package hint: ksnapshot

Hi!

The problem is in window capturing mode. If the window hangs out from the screen, then ksnapshot bugs in the way that can be seen on the attached image. (Okay, i do that for fun, capturing webpages can be done with Screengrab (https://addons.mozilla.org/en-US/firefox/addon/1146), but it isn't solves ksnapshot's problem.)

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=7.10
DISTRIB_CODENAME=gutsy
DISTRIB_DESCRIPTION="Ubuntu 7.10"

Qt: 3.3.7
KDE: 3.5.8
KSnapshot: 0.7

Revision history for this message
In , Adam Wiggins (hiro) wrote :

Version: 0.7 (using KDE KDE 3.3.1)
Installed from: RedHat RPMs
OS: Linux

My KMix window is about twice the width of my screen. When taking a snapshot (to submit a bug report about it), I ended up with this:

http://dusk.org/~adam/bugzilla/ksnapshot.png

This was using "window under cursor" mode. I was not surprised that it couldn't get the contents of the window that were not visible on screen, but it seems like it should handle this more gracefully - perhaps by clipping the final image, or just filling in the remaining space with black.

Revision history for this message
In , Brad Hards (bradh) wrote :

I don't see garbage (just black sections - probably a change to Qt), but it is still wrong (because we are using QPixmap::grabRegion(), and that has a warning that it isn't safe to grab off screen regions).

I've got a patch that just trims to the current screen size:
--- ksnapshot.cpp 11 Dec 2004 21:40:39 -0000 1.78
+++ ksnapshot.cpp 29 Jan 2005 22:23:59 -0000
@@ -498,8 +498,20 @@ void KSnapshot::performGrab()
                y = newy;
            }
        }

+ XWindowAttributes rootAttributes;
+ if ( XGetWindowAttributes( qt_xdisplay(), root, &rootAttributes ) ) {
+ if ( ( x + w ) > rootAttributes.width ) {
+ // then the window is partly off the screen
+ w = rootAttributes.width - x;
+ }
+ if ( ( y + h ) > rootAttributes.height ) {
+ // then the window is partly off the screen
+ h = rootAttributes.height - y;
+ }
+ }
+
        snapshot = QPixmap::grabWindow( qt_xrootwin(), x, y, w, h );

 #ifdef HAVE_X11_EXTENSIONS_SHAPE_H

Is that OK to commit?

Revision history for this message
In , Brad Hards (bradh) wrote :

That is committed now.

Revision history for this message
Some Thing (something) wrote :
Revision history for this message
Harald Sitter (apachelogger) wrote :

Thank you very much for helping us improving Kubuntu :-)
This issue is caused by KDE itself, therefor it would be very cool if you could report this issue on bugs.kde.org otherwise it might take some time until someone finds the time to do it.

Changed in kdegraphics:
importance: Undecided → Low
status: New → Confirmed
Revision history for this message
Some Thing (something) wrote :

Hmm...
Looks that it was solved a hundred year ago...

http://bugs.kde.org/show_bug.cgi?id=96822

Revision history for this message
Harald Sitter (apachelogger) wrote :

Doesn't look like that on my KDE 4 machine ;-)

Please reopen the KDE bug.

Changed in kdegraphics:
status: New → Unknown
Changed in kdegraphics:
status: Unknown → Fix Released
Revision history for this message
In , Yuriy Kozlov (yuriy-kozlov) wrote :

According to https://bugs.launchpad.net/ubuntu/+source/kdegraphics/+bug/204358 this is still/again a problem in KDE 3.5 and KDE 4.0

Revision history for this message
In , Jonathan Thomas (echidnaman) wrote :

Yes, this still is an issue in KDE 4.1.1. Please reopen the bug.

Revision history for this message
Jonathan Thomas (echidnaman) wrote :

I reopened the upstream bug.

Changed in kdegraphics:
status: Confirmed → Triaged
Revision history for this message
In , Jonathan Thomas (echidnaman) wrote :

Still a problem in KDE 4.1.85, reopening.

Changed in kdegraphics:
status: Fix Released → New
Revision history for this message
In , Jonathan Thomas (echidnaman) wrote :

Here's an adaptation of the patch for KDE 4.3:

Index: kdegraphics-4.2.90/ksnapshot/windowgrabber.cpp
===================================================================
--- kdegraphics-4.2.90.orig/ksnapshot/windowgrabber.cpp 2009-06-12 23:16:28.000000000 -0400
+++ kdegraphics-4.2.90/ksnapshot/windowgrabber.cpp 2009-06-12 23:37:00.000000000 -0400
@@ -140,6 +140,18 @@
 QPixmap grabWindow( Window child, int x, int y, uint w, uint h, uint border,
       QString *title=0, QString *windowClass=0 )
 {
+ XWindowAttributes rootAttributes;
+ if ( XGetWindowAttributes( QX11Info::display(), QX11Info::appRootWindow(), &rootAttributes ) ) {
+ if ( ( x + w ) > rootAttributes.width ) {
+ // then the window is partly off the screen
+ w = rootAttributes.width - x;
+ }
+ if ( ( y + h ) > rootAttributes.height ) {
+ // then the window is partly off the screen
+ h = rootAttributes.height - y;
+ }
+ }
+
     QPixmap pm( QPixmap::grabWindow( QX11Info::appRootWindow(), x, y, w, h ) );

     KWindowInfo winInfo( findRealWindow(child), NET::WMVisibleName, NET::WM2WindowClass );

Changed in kdegraphics:
importance: Unknown → Medium
Revision history for this message
Maarten Bezemer (veger) wrote :

I can confirm this is still an issue on KDE 4.7.4

Revision history for this message
In , Elias Probst (eliasp) wrote :

Can't reproduce this anymore on KDE 4.10 RC1 (4.9.95).
IIRC since KDE 4.5 the window screenshot is grabbed from kwin directly to:
* also include the window decoration's shadow
* create screenshots of windows which are (partially) covered by other windows
* create screenshots of (partially) offscreen windows

It even works when disabling compositing.

I don't know what would happen when using a different WM than kwin, but I don't think that really counts here.

So I'd vote for closing this bug. Any objections?

Revision history for this message
In , Kdebugs-p (kdebugs-p) wrote :

Created attachment 88044
screenshot

Ubuntu 14.04 (KDE 4.13.2)

Revision history for this message
In , Andrew-crouthamel (andrew-crouthamel) wrote :

Hello! Sorry to be the bearer of bad news, but this project has been unmaintained for many years and I will be closing this bug. Spectacle is the replacement for ksnapshot now. Please test again and file a new bug for Spectacle if you still have issues. Thank you!

Changed in kdegraphics:
status: New → Unknown
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.