[Bug 204358] Re: ksnapshot: Problem with offscreen pieces of windows

Bug Watch Updater 204358 at bugs.launchpad.net
Sun Dec 30 18:28:50 UTC 2012


Launchpad has imported 8 comments from the remote bug at
https://bugs.kde.org/show_bug.cgi?id=96822.

If you reply to an imported comment from within Launchpad, your comment
will be sent to the remote bug automatically. Read more about
Launchpad's inter-bugtracker facilities at
https://help.launchpad.net/InterBugTracking.

------------------------------------------------------------------------
On 2005-01-12T08:14:35+00:00 Adam Wiggins 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.

Reply at:
https://bugs.launchpad.net/ubuntu/+source/kdegraphics/+bug/204358/comments/0

------------------------------------------------------------------------
On 2005-01-29T23:33:45+00:00 Brad Hards 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?

Reply at:
https://bugs.launchpad.net/ubuntu/+source/kdegraphics/+bug/204358/comments/1

------------------------------------------------------------------------
On 2005-01-30T10:14:40+00:00 Brad Hards wrote:

That is committed now.

Reply at:
https://bugs.launchpad.net/ubuntu/+source/kdegraphics/+bug/204358/comments/2

------------------------------------------------------------------------
On 2008-07-14T20:28:46+00:00 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

Reply at:
https://bugs.launchpad.net/ubuntu/+source/kdegraphics/+bug/204358/comments/8

------------------------------------------------------------------------
On 2008-09-07T16:51:11+00:00 Jonathan Thomas wrote:

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

Reply at:
https://bugs.launchpad.net/ubuntu/+source/kdegraphics/+bug/204358/comments/9

------------------------------------------------------------------------
On 2009-01-07T15:54:48+00:00 Jonathan Thomas wrote:

Still a problem in KDE 4.1.85, reopening.

Reply at:
https://bugs.launchpad.net/ubuntu/+source/kdegraphics/+bug/204358/comments/11

------------------------------------------------------------------------
On 2009-06-13T22:33:58+00:00 Jonathan Thomas 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 );

Reply at:
https://bugs.launchpad.net/ubuntu/+source/kdegraphics/+bug/204358/comments/12

------------------------------------------------------------------------
On 2012-12-29T20:44:58+00:00 Elias Probst 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?

Reply at:
https://bugs.launchpad.net/ubuntu/+source/kdegraphics/+bug/204358/comments/14

-- 
You received this bug notification because you are a member of Kubuntu
Bugs, which is subscribed to kdegraphics in Ubuntu.
https://bugs.launchpad.net/bugs/204358

Title:
  ksnapshot: Problem with offscreen pieces of windows

To manage notifications about this bug go to:
https://bugs.launchpad.net/kdegraphics/+bug/204358/+subscriptions




More information about the kubuntu-bugs mailing list