summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@qt.io>2020-04-21 10:20:28 +0200
committerAndy Shaw <andy.shaw@qt.io>2020-04-26 20:09:51 +0200
commit7c7b09dbac7d1921efb305cb7843b88a5247f17e (patch)
tree92bbace5b413a0c7962874fa47a1406a95ded7a7
parent9e83d268d6e0bd492fafad823a47cef57b7916c5 (diff)
Cocoa: If the grabRect is null then add in a null image for the area
If it is null then it has nothing to grab, so a null QImage and QRect is added to the lists so that there is still a representation in some form for that display. This additionally ensures that it does take up space for the display in the final image too. Fixes: QTBUG-63086 Change-Id: I6e80ecc1170642025f6930e2211017c114e25c16 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
-rw-r--r--src/plugins/platforms/cocoa/qcocoascreen.mm11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoascreen.mm b/src/plugins/platforms/cocoa/qcocoascreen.mm
index e4dd4cf6c6..6a3172fb19 100644
--- a/src/plugins/platforms/cocoa/qcocoascreen.mm
+++ b/src/plugins/platforms/cocoa/qcocoascreen.mm
@@ -614,7 +614,11 @@ QPixmap QCocoaScreen::grabWindow(WId view, int x, int y, int width, int height)
QRect windowRect;
for (uint i = 0; i < displayCount; ++i) {
QRect displayBounds = QRectF::fromCGRect(CGDisplayBounds(displays[i])).toRect();
- windowRect = windowRect.united(displayBounds);
+ // Only include the screen if it is positioned past the x/y position
+ if ((displayBounds.x() >= x || displayBounds.right() > x) &&
+ (displayBounds.y() >= y || displayBounds.bottom() > y)) {
+ windowRect = windowRect.united(displayBounds);
+ }
}
if (grabRect.width() < 0)
grabRect.setWidth(windowRect.width());
@@ -631,6 +635,11 @@ QPixmap QCocoaScreen::grabWindow(WId view, int x, int y, int width, int height)
auto display = displays[i];
QRect displayBounds = QRectF::fromCGRect(CGDisplayBounds(display)).toRect();
QRect grabBounds = displayBounds.intersected(grabRect);
+ if (grabBounds.isNull()) {
+ destinations.append(QRect());
+ images.append(QImage());
+ continue;
+ }
QRect displayLocalGrabBounds = QRect(QPoint(grabBounds.topLeft() - displayBounds.topLeft()), grabBounds.size());
QImage displayImage = qt_mac_toQImage(QCFType<CGImageRef>(CGDisplayCreateImageForRect(display, displayLocalGrabBounds.toCGRect())));
displayImage.setDevicePixelRatio(displayImage.size().width() / displayLocalGrabBounds.size().width());