diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2011-08-23 07:00:48 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2011-08-23 07:00:48 (GMT) |
commit | 092cd760d5fddf9640a310214fe01929f0fff3a8 (patch) | |
tree | 2c8b8b0e6462981fc92011b384358ad9a28f3450 /src | |
parent | dd675dc4706dff26bf154686f158f6c252727bcc (diff) | |
parent | c5f46907fbc0354aacc4bc4a6f5ab97c8b656d1a (diff) | |
download | Qt-092cd760d5fddf9640a310214fe01929f0fff3a8.zip Qt-092cd760d5fddf9640a310214fe01929f0fff3a8.tar.gz Qt-092cd760d5fddf9640a310214fe01929f0fff3a8.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7-integrationv4.7.4
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1:
Fix problem with grabWindow on Mac OS X 10.6 with Cocoa
don't crash when destroying children
Fix compile issue with Mac OS X 10.5
Fix QPixmap::grabWindow() on Mac OS X Lion
Update 4.7.4 changes
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/image/qpixmap_mac.cpp | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/src/gui/image/qpixmap_mac.cpp b/src/gui/image/qpixmap_mac.cpp index 6872cfa..3afc724 100644 --- a/src/gui/image/qpixmap_mac.cpp +++ b/src/gui/image/qpixmap_mac.cpp @@ -840,7 +840,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()) @@ -916,7 +942,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) { |