Fix Pick Screen Color with multiple monitors

QScreen::grabWindow expects screen coordinates, not global ones, use
QScreen::geometry() to compute them.

Fixes: QTBUG-99472
Pick-to: 6.2 6.3
Change-Id: Ic4b99577b8cb394e6cd0a2d3f554bb3ec8250afa
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Zhang Hao <zhanghao@uniontech.com>
bb10
Fawzi Mohamed 2022-01-04 10:06:57 +01:00
parent cfca4188f9
commit da6c8b2fc6
1 changed files with 3 additions and 1 deletions

View File

@ -1566,7 +1566,9 @@ QColor QColorDialogPrivate::grabScreenColor(const QPoint &p)
QScreen *screen = QGuiApplication::screenAt(p);
if (!screen)
screen = QGuiApplication::primaryScreen();
const QPixmap pixmap = screen->grabWindow(0, p.x(), p.y(), 1, 1);
const QRect screenRect = screen->geometry();
const QPixmap pixmap =
screen->grabWindow(0, p.x() - screenRect.x(), p.y() - screenRect.y(), 1, 1);
const QImage i = pixmap.toImage();
return i.pixel(0, 0);
}