From 2cfca47d568502a5d10c07caf60b38cc505d3f5e Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Mon, 7 Oct 2013 10:40:35 +0200 Subject: [PATCH] Fix QScreen::grabWindow for multiple screens on Mac MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/plugins/platforms/cocoa/qcocoaintegration.mm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index 8ce72e08b5..2e42b9acda 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -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 h = (height < 0 ? bounds.size.height : height) * devicePixelRatio(); QRect displayRect = QRect(x, y, w, h); + displayRect = displayRect.translated(qRound(-bounds.origin.x), qRound(-bounds.origin.y)); QCFType image = CGDisplayCreateImageForRect(displays[i], CGRectMake(displayRect.x(), displayRect.y(), displayRect.width(), displayRect.height())); QPixmap pix(w, h); @@ -209,7 +210,7 @@ QPixmap QCocoaScreen::grabWindow(WId window, int x, int y, int width, int height CGContextRelease(ctx); QPainter painter(&windowPixmap); - painter.drawPixmap(bounds.origin.x, bounds.origin.y, pix); + painter.drawPixmap(0, 0, pix); } return windowPixmap; }