summaryrefslogtreecommitdiffstats
path: root/src/gui/image
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2011-08-25 13:56:52 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2011-08-25 13:56:52 (GMT)
commit8f389d20bc01a355a6a1885b5bd1d30bd2ff0c71 (patch)
tree2b7d2d9d99eb6fa645eeae0add8cece445d15d3d /src/gui/image
parent02e2ff4597a7fe81ecbb4b1ef3c5e4a5ac6b7339 (diff)
parentd54407928be05781ede2358baba2f2f91749cc80 (diff)
downloadQt-8f389d20bc01a355a6a1885b5bd1d30bd2ff0c71.zip
Qt-8f389d20bc01a355a6a1885b5bd1d30bd2ff0c71.tar.gz
Qt-8f389d20bc01a355a6a1885b5bd1d30bd2ff0c71.tar.bz2
Merge branch 'qt-4.8-from-4.7' of scm.dev.nokia.troll.no:qt/qt-integration into master-integration
* 'qt-4.8-from-4.7' of scm.dev.nokia.troll.no:qt/qt-integration: (21 commits) Revert "Avoid calling QInputMethod update when adding or removing QGraphicsItems that don't have focus" Symbian: Not possible to catch RequestSoftwareInputPanel in eventFilter Fix problem with grabWindow on Mac OS X 10.6 with Cocoa Added an additional check to workaround an issue on Windows. don't crash when destroying children Fix compile issue with Mac OS X 10.5 Avoid calling QInputMethod update when adding or removing QGraphicsItems that don't have focus Exact word bubble doesn't disappear when screen is tapped (fix part 2) Fix QPixmap::grabWindow() on Mac OS X Lion Update 4.7.4 changes Exact word bubble doesn't disappear when screen is tapped Make text rendering working outside the gui thread on Symbian. Doc: Clarified the range of return values from QLineF::angle(). Doc: Fixed \since declarations. Doc: Standardized on QtQuick for \since declarations. Doc: Removed whitespace. Modified \since command behavior slightly to handle project and version. Doc: Added a simple introduction to Qt and fixed links. Doc: Added more appropriate links to help reduce confusion. Doc: Removed non-ASCII characters from the documentation. ...
Diffstat (limited to 'src/gui/image')
-rw-r--r--src/gui/image/qpixmap_mac.cpp33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/gui/image/qpixmap_mac.cpp b/src/gui/image/qpixmap_mac.cpp
index bdf1f90..47b6eef 100644
--- a/src/gui/image/qpixmap_mac.cpp
+++ b/src/gui/image/qpixmap_mac.cpp
@@ -851,7 +851,33 @@ static void qt_mac_grabDisplayRect(CGDirectDisplayID display, const QRect &displ
ptrCGLDestroyContext(glContextObj); // and destroy the context
}
+#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6)
// Returns a pixmap containing the screen contents at rect.
+static QPixmap qt_mac_grabScreenRect_10_6(const QRect &rect)
+{
+ const int maxDisplays = 128; // 128 displays should be enough for everyone.
+ CGDirectDisplayID displays[maxDisplays];
+ CGDisplayCount displayCount;
+ const CGRect cgRect = CGRectMake(rect.x(), rect.y(), rect.width(), rect.height());
+ const CGDisplayErr err = CGGetDisplaysWithRect(cgRect, maxDisplays, displays, &displayCount);
+
+ if (err && displayCount == 0)
+ return QPixmap();
+ QPixmap windowPixmap(rect.size());
+ for (uint i = 0; i < displayCount; ++i) {
+ const CGRect bounds = CGDisplayBounds(displays[i]);
+ // Translate to display-local coordinates
+ QRect displayRect = rect.translated(qRound(-bounds.origin.x), qRound(-bounds.origin.y));
+ QCFType<CGImageRef> image = CGDisplayCreateImageForRect(displays[i],
+ CGRectMake(displayRect.x(), displayRect.y(), displayRect.width(), displayRect.height()));
+ QPixmap pix = QPixmap::fromMacCGImageRef(image);
+ QPainter painter(&windowPixmap);
+ painter.drawPixmap(-bounds.origin.x, -bounds.origin.y, pix);
+ }
+ return windowPixmap;
+}
+#endif
+
static QPixmap qt_mac_grabScreenRect(const QRect &rect)
{
if (!resolveOpenGLSymbols())
@@ -927,7 +953,12 @@ QPixmap QPixmap::grabWindow(WId window, int x, int y, int w, int h)
QRect rect(globalCoord.x() + x, globalCoord.y() + y, w, h);
#ifdef QT_MAC_USE_COCOA
- return qt_mac_grabScreenRect(rect);
+#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6)
+ if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_6)
+ return qt_mac_grabScreenRect_10_6(rect);
+ else
+#endif
+ return qt_mac_grabScreenRect(rect);
#else
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4)
if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4) {