From e1214e23e5a2641d585e47aa064cfcbb8a2b6111 Mon Sep 17 00:00:00 2001 From: Peter Cai Date: Fri, 25 Sep 2020 06:47:38 +0800 Subject: [PATCH] correct position of QScreen geometry on HiDPI multi-headed setup --- src/utils/screengrabber.cpp | 5 ++++- src/widgets/capture/capturewidget.cpp | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/utils/screengrabber.cpp b/src/utils/screengrabber.cpp index a6a35711..03c76657 100644 --- a/src/utils/screengrabber.cpp +++ b/src/utils/screengrabber.cpp @@ -90,7 +90,10 @@ QPixmap ScreenGrabber::grabEntireDesktop(bool& ok) QRect geometry; for (QScreen* const screen : QGuiApplication::screens()) { - geometry = geometry.united(screen->geometry()); + QRect scrRect = screen->geometry(); + scrRect.moveTo(scrRect.x() / screen->devicePixelRatio(), + scrRect.y() / screen->devicePixelRatio()); + geometry = geometry.united(scrRect); } QPixmap p(QApplication::primaryScreen()->grabWindow( diff --git a/src/widgets/capture/capturewidget.cpp b/src/widgets/capture/capturewidget.cpp index edbd33e1..70083e10 100644 --- a/src/widgets/capture/capturewidget.cpp +++ b/src/widgets/capture/capturewidget.cpp @@ -126,6 +126,8 @@ CaptureWidget::CaptureWidget(const uint id, if (m_context.fullscreen) { for (QScreen* const screen : QGuiApplication::screens()) { QRect r = screen->geometry(); + r.moveTo(r.x() / screen->devicePixelRatio(), + r.y() / screen->devicePixelRatio()); #ifdef Q_OS_WIN r.moveTo(r.topLeft() - topLeft); #endif @@ -600,6 +602,10 @@ void CaptureWidget::initPanel() QRect panelRect = rect(); if (m_context.fullscreen) { panelRect = QGuiApplication::primaryScreen()->geometry(); + auto devicePixelRatio = + QGuiApplication::primaryScreen()->devicePixelRatio(); + panelRect.moveTo(panelRect.x() / devicePixelRatio, + panelRect.y() / devicePixelRatio); } ConfigHandler config;