Fix QScreen::grabWindow for multiple screens on Mac
QScreen::grabWindow() would only with the primary screen on Mac, if you tried to grab a secondary one then it would end up with a blank pixmap. Change-Id: I24f604051835db96286c693f5ed60a2633b6528e Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
This commit is contained in:
parent
ae4c7be67d
commit
2cfca47d56
@ -199,6 +199,7 @@ QPixmap QCocoaScreen::grabWindow(WId window, int x, int y, int width, int height
|
|||||||
int w = (width < 0 ? bounds.size.width : width) * devicePixelRatio();
|
int w = (width < 0 ? bounds.size.width : width) * devicePixelRatio();
|
||||||
int h = (height < 0 ? bounds.size.height : height) * devicePixelRatio();
|
int h = (height < 0 ? bounds.size.height : height) * devicePixelRatio();
|
||||||
QRect displayRect = QRect(x, y, w, h);
|
QRect displayRect = QRect(x, y, w, h);
|
||||||
|
displayRect = displayRect.translated(qRound(-bounds.origin.x), qRound(-bounds.origin.y));
|
||||||
QCFType<CGImageRef> image = CGDisplayCreateImageForRect(displays[i],
|
QCFType<CGImageRef> image = CGDisplayCreateImageForRect(displays[i],
|
||||||
CGRectMake(displayRect.x(), displayRect.y(), displayRect.width(), displayRect.height()));
|
CGRectMake(displayRect.x(), displayRect.y(), displayRect.width(), displayRect.height()));
|
||||||
QPixmap pix(w, h);
|
QPixmap pix(w, h);
|
||||||
@ -209,7 +210,7 @@ QPixmap QCocoaScreen::grabWindow(WId window, int x, int y, int width, int height
|
|||||||
CGContextRelease(ctx);
|
CGContextRelease(ctx);
|
||||||
|
|
||||||
QPainter painter(&windowPixmap);
|
QPainter painter(&windowPixmap);
|
||||||
painter.drawPixmap(bounds.origin.x, bounds.origin.y, pix);
|
painter.drawPixmap(0, 0, pix);
|
||||||
}
|
}
|
||||||
return windowPixmap;
|
return windowPixmap;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user