[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdegraphics/ksnapshot
From: Maks Orlovich <mo002j () mail ! rochester ! edu>
Date: 2003-02-06 3:27:58
[Download RAW message or body]
CVS commit by orlovich:
- Handle XShaped windows when taking single-window screenshots - clears the \
masked-away areas with black. Fixes weird random stuff showing up around the \
"bubble" when taking screenshots with the Keramik KWin deco. (#47893)
CCMAIL: 47893-done@bugs.kde.org
A configure.in.in 1.1
M +45 -2 ksnapshot.cpp 1.54
M +1 -0 ksnapshot.h 1.21
--- kdegraphics/ksnapshot/ksnapshot.cpp #1.53:1.54
@@ -52,4 +52,11 @@
#include <X11/Xlib.h>
#include <X11/Xatom.h>
+
+#include <config.h>
+
+#ifdef HAVE_X11_EXTENSIONS_SHAPE_H
+#include <X11/extensions/shape.h>
+#endif
+
#include <kglobal.h>
@@ -69,4 +76,10 @@ KSnapshot::KSnapshot(QWidget *parent, co
KStartupInfo::appStarted();
+#ifdef HAVE_X11_EXTENSIONS_SHAPE_H
+ int tmp1, tmp2;
+ //Check whether the extension is available
+ haveXShape = XShapeQueryExtension( qt_xdisplay(), &tmp1, &tmp2 );
+#endif
+
grabber->show();
grabber->grabMouse( waitCursor );
@@ -359,4 +372,34 @@ void KSnapshot::performGrab()
snapshot = QPixmap::grabWindow( qt_xrootwin(), x, y, w, h );
+
+#ifdef HAVE_X11_EXTENSIONS_SHAPE_H
+ //No XShape - no work.
+ if (haveXShape) {
+ //As the first step, get the mask from XShape.
+ int count, order;
+ XRectangle* rects = XShapeGetRectangles( qt_xdisplay(), child,
+ ShapeBounding, &count, &order);
+ if (rects) {
+ //Create a region from the rectangles the window contents.
+ QRegion contents;
+ for (int pos = 0; pos < count; pos++)
+ contents += QRegion(rects[pos].x, rects[pos].y,
+ rects[pos].width, rects[pos].height);
+ XFree(rects);
+
+ //Create the bounding box.
+ QRegion bbox(0, 0, snapshot.width(), snapshot.height());
+
+ //Get the masked away are
+ QRegion maskedAway = bbox - contents;
+ QMemArray<QRect> maskedAwayRects = maskedAway.rects();
+
+ QPainter p(&snapshot);
+ for (int pos = 0; pos < maskedAwayRects.count(); pos++)
+ p.fillRect(maskedAwayRects[pos], Qt::black);
+ p.end();
+ }
+ }
+#endif
}
else {
--- kdegraphics/ksnapshot/ksnapshot.h #1.20:1.21
@@ -92,4 +92,5 @@ private:
QString filename;
bool modified;
+ bool haveXShape;
};
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic