diff --git a/src/widgets/panel/colorgrabwidget.cpp b/src/widgets/panel/colorgrabwidget.cpp index 59a56ef320..1d817528a2 100644 --- a/src/widgets/panel/colorgrabwidget.cpp +++ b/src/widgets/panel/colorgrabwidget.cpp @@ -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();