correct position of QScreen geometry on HiDPI multi-headed setup

This commit is contained in:
Peter Cai
2020-09-25 06:47:38 +08:00
committed by borgmanJeremy
parent e298d56f32
commit e1214e23e5
2 changed files with 10 additions and 1 deletions

View File

@@ -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(

View File

@@ -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;