Skip to content

Commit

Permalink
Fixed an issue where the magnifier did not account for hiDPI on retin…
Browse files Browse the repository at this point in the history
…a screens (#2187)
borgmanJeremy authored Dec 24, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent aaf6eeb commit da5d71c
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/widgets/panel/colorgrabwidget.cpp
Original file line number Diff line number Diff line change
@@ -200,11 +200,26 @@ void ColorGrabWidget::updateWidget()
float zoom = m_extraZoomActive ? ZOOM2 : ZOOM1;
// Set window size and move its center to the mouse cursor
QRect rect(0, 0, width, width);

auto realCursorPos = cursorPos();
auto adjustedCursorPos = realCursorPos;

#if defined(Q_OS_MACOS)
QScreen* currentScreen = QGuiAppCurrentScreen().currentScreen();
if (currentScreen) {
adjustedCursorPos =
QPoint((realCursorPos.x() - currentScreen->geometry().x()) *
currentScreen->devicePixelRatio(),
(realCursorPos.y() - currentScreen->geometry().y()) *
currentScreen->devicePixelRatio());
}
#endif

rect.moveCenter(cursorPos());
setGeometry(rect);
// Store a pixmap containing the zoomed-in section around the cursor
QRect sourceRect(0, 0, width / zoom, width / zoom);
sourceRect.moveCenter(rect.center());
sourceRect.moveCenter(adjustedCursorPos);
m_previewImage = m_pixmap->copy(sourceRect).toImage();
// Repaint
update();

0 comments on commit da5d71c

Please sign in to comment.