Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
6.2.1
-
None
-
Tested on Windows 10 with dual-screen.
-
-
da6c8b2fc6 (qt/qtbase/dev) da6c8b2fc6 (qt/tqtc-qtbase/dev) 90e5e565f0 (qt/qtbase/6.3) 90e5e565f0 (qt/tqtc-qtbase/6.3) 22f682d620 (qt/qtbase/6.2) 22f682d620 (qt/tqtc-qtbase/6.2)
Description
The "Pick Screen Color" button in QColorDialog permits scanning the colors of the entire screen to pick one of them. But it's not possible to scan colors from a secondary screen (dual-screen, multi-screen...).
The error probably lies in this method:
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 QImage i = pixmap.toImage(); return i.pixel(0, 0); }
Suggested fix:
QColor QColorDialogPrivate::grabScreenColor(const QPoint &p) { QPoint localCursorPos = p; QScreen *screen = QGuiApplication::screenAt(p); if (!screen) screen = QGuiApplication::primaryScreen(); if (screen != QGuiApplication::primaryScreen()) { const QRect screenRect = screen->geometry(); localCursorPos.setX(localCursorPos.x() - screenRect.x()); localCursorPos.setY(localCursorPos.y() - screenRect.y()); } const QPixmap pixmap = screen->grabWindow(0, localCursorPos.x(), localCursorPos.y(), 1, 1); const QImage i = pixmap.toImage(); return i.pixel(0, 0); }
Also, note that the cursor flickers when it moves on the secondary screen. No fix suggestion for that part. Might be somehow related to https://bugreports.qt.io/browse/QTBUG-43448
Attachments
Issue Links
- is cloned by
-
QTBUG-94748 QScreen::grabWindow(0, ...) isn't working on second display
- Open