Skip to content

Commit

Permalink
Fix screenshot capture.
Browse files Browse the repository at this point in the history
  • Loading branch information
karliss committed Apr 13, 2021
1 parent c1c96de commit 2231d59
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/widgets/ColorPicker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,12 @@ QColor ColorPicker::getColorAtMouse()
#else
QPoint pos = QCursor::pos();
auto screen = QGuiApplication::screenAt(pos);
auto window = QGuiApplication::topLevelAt(QCursor::pos());
if (screen && window) {
const QPixmap pixmap = screen->grabWindow(window->winId(), QCursor::pos().x(), QCursor::pos().y(), 1, 1);
if (!screen) {
screen = QGuiApplication::primaryScreen();
}
if (screen) {
auto screenRelativePos = pos - screen->geometry().topLeft();
const QPixmap pixmap = screen->grabWindow(0, screenRelativePos.x(), screenRelativePos.y(), 1, 1);
return QColor(pixmap.toImage().pixel(0, 0));
}
return QColorConstants::Red;
Expand Down

0 comments on commit 2231d59

Please sign in to comment.