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>
This commit is contained in:
parent
9e83d268d6
commit
7c7b09dbac
@ -614,8 +614,12 @@ 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();
|
||||
// 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());
|
||||
if (grabRect.height() < 0)
|
||||
@ -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());
|
||||
|
Loading…
Reference in New Issue
Block a user