mirror of
https://github.com/fergalmoran/flameshot.git
synced 2025-12-22 09:51:06 +00:00
Fixed an issue where the magnifier did not account for hiDPI on retina screens (#2187)
This commit is contained in:
@@ -200,11 +200,26 @@ void ColorGrabWidget::updateWidget()
|
|||||||
float zoom = m_extraZoomActive ? ZOOM2 : ZOOM1;
|
float zoom = m_extraZoomActive ? ZOOM2 : ZOOM1;
|
||||||
// Set window size and move its center to the mouse cursor
|
// Set window size and move its center to the mouse cursor
|
||||||
QRect rect(0, 0, width, width);
|
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());
|
rect.moveCenter(cursorPos());
|
||||||
setGeometry(rect);
|
setGeometry(rect);
|
||||||
// Store a pixmap containing the zoomed-in section around the cursor
|
// Store a pixmap containing the zoomed-in section around the cursor
|
||||||
QRect sourceRect(0, 0, width / zoom, width / zoom);
|
QRect sourceRect(0, 0, width / zoom, width / zoom);
|
||||||
sourceRect.moveCenter(rect.center());
|
sourceRect.moveCenter(adjustedCursorPos);
|
||||||
m_previewImage = m_pixmap->copy(sourceRect).toImage();
|
m_previewImage = m_pixmap->copy(sourceRect).toImage();
|
||||||
// Repaint
|
// Repaint
|
||||||
update();
|
update();
|
||||||
|
|||||||
Reference in New Issue
Block a user