From fc450421c966ac31feb448db4841c3b5657b647c Mon Sep 17 00:00:00 2001 From: Ruslan Kabatsayev Date: Tue, 5 Dec 2023 02:06:54 +0400 Subject: [PATCH] Use the correct screen when making a screenshot Current code picks a screen based only on the size of the scene, ignoring the position of the window. Asking the widget for its screen is the proper way of doing this. --- src/StelMainView.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/StelMainView.cpp b/src/StelMainView.cpp index 3650434d3fc08..f31aed0f2d5e6 100644 --- a/src/StelMainView.cpp +++ b/src/StelMainView.cpp @@ -1667,7 +1667,8 @@ void StelMainView::doScreenshot(void) // HiDPI screens interfere, and the viewing angle has to be maintained. // First, image size: glWidget->makeCurrent(); - const auto pixelRatio = QOpenGLContext::currentContext()->screen()->devicePixelRatio(); + const auto screen = QOpenGLContext::currentContext()->screen(); + const auto pixelRatio = screen->devicePixelRatio(); int physImgWidth = std::lround(stelScene->width() * pixelRatio); int physImgHeight = std::lround(stelScene->height() * pixelRatio); bool nightModeWasEnabled=nightModeEffect->isEnabled(); @@ -1739,7 +1740,7 @@ void StelMainView::doScreenshot(void) sParams.viewportXywh[3] = virtImgHeight; // Configure a helper value to allow some modules to tweak their output sizes. Currently used by StarMgr, maybe solve font issues? - customScreenshotMagnification=static_cast(virtImgHeight)/static_cast(qApp->screenAt(QPoint(stelScene->width()*0.5, stelScene->height()*0.5))->geometry().height()); + customScreenshotMagnification=static_cast(virtImgHeight)/static_cast(screen->geometry().height()); sParams.viewportCenter.set(0.0+(0.5+pParams.viewportCenterOffset.v[0])*virtImgWidth, 0.0+(0.5+pParams.viewportCenterOffset.v[1])*virtImgHeight); sParams.viewportFovDiameter = qMin(virtImgWidth,virtImgHeight);