From 4c660614d449726142480fcfe5058825a6b2ba4a Mon Sep 17 00:00:00 2001 From: Hernan Martinez Date: Sat, 14 Oct 2023 01:05:43 -0600 Subject: [PATCH 1/4] Add dpiAwareness option to manifest that matches the default one Qt 6 tries to use --- data/stellarium.exe.manifest | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/data/stellarium.exe.manifest b/data/stellarium.exe.manifest index f2c00e1618eed..ddc8f49194e31 100644 --- a/data/stellarium.exe.manifest +++ b/data/stellarium.exe.manifest @@ -41,8 +41,9 @@ - + true + PerMonitorV2 From 491aa73201cee9012cf5980f3d9352ba6952de20 Mon Sep 17 00:00:00 2001 From: Hernan Martinez Date: Sat, 14 Oct 2023 01:50:36 -0600 Subject: [PATCH 2/4] Add glPhysicalWindowHasBeenResized() SLOT --- src/core/StelApp.cpp | 13 ++++++++++++- src/core/StelApp.hpp | 5 ++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/core/StelApp.cpp b/src/core/StelApp.cpp index 101f8d677ca29..c395b55a5a4f9 100644 --- a/src/core/StelApp.cpp +++ b/src/core/StelApp.cpp @@ -1067,7 +1067,7 @@ void StelApp::draw() } /************************************************************************* - Call this when the size of the GL window has changed + Call this when the virtual size of the GL window has changed *************************************************************************/ void StelApp::glWindowHasBeenResized(const QRectF& rect) { @@ -1091,6 +1091,17 @@ void StelApp::glWindowHasBeenResized(const QRectF& rect) #endif } +/************************************************************************* + Call this when the physical size of the GL window has changed +*************************************************************************/ +void StelApp::glPhysicalWindowHasBeenResized(const QRectF& rect) +{ +#ifdef ENABLE_SPOUT + if (spoutSender) + spoutSender->resize(static_cast(rect.width()),static_cast(rect.height())); +#endif +} + // Handle mouse clics void StelApp::handleClick(QMouseEvent* inputEvent) { diff --git a/src/core/StelApp.hpp b/src/core/StelApp.hpp index c8d46f7d0e85f..39a610198046f 100644 --- a/src/core/StelApp.hpp +++ b/src/core/StelApp.hpp @@ -264,9 +264,12 @@ class StelApp : public QObject /////////////////////////////////////////////////////////////////////////// // Scriptable methods public slots: - //! Call this when the size of the GL window has changed. + //! Call this when the virtual size of the GL window has changed. void glWindowHasBeenResized(const QRectF &rect); + //! Call this when the physical size of the GL window has changed. + void glPhysicalWindowHasBeenResized(const QRectF &rect); + //! Set flag for activating night vision mode. void setVisionModeNight(bool); //! Get flag for activating night vision mode. From c907e819633f7eaa5c3e5309d22995c09d60d1b7 Mon Sep 17 00:00:00 2001 From: Hernan Martinez Date: Sat, 14 Oct 2023 02:16:17 -0600 Subject: [PATCH 3/4] Use physical dimensions when sending Spout data --- src/StelMainView.cpp | 21 +++++++++++++++++++++ src/StelMainView.hpp | 2 ++ 2 files changed, 23 insertions(+) diff --git a/src/StelMainView.cpp b/src/StelMainView.cpp index 4a7d468ec46d6..fa9ff6980c5e0 100644 --- a/src/StelMainView.cpp +++ b/src/StelMainView.cpp @@ -929,8 +929,14 @@ void StelMainView::init() stelApp->init(configuration); //this makes sure the app knows how large the window is connect(stelScene,SIGNAL(sceneRectChanged(QRectF)),stelApp,SLOT(glWindowHasBeenResized(QRectF))); + QObject::connect(stelScene, &StelGraphicsScene::sceneRectChanged, [&](const QRectF& rect) + { + stelApp->glPhysicalWindowHasBeenResized(getPhysicalSize(rect)); + }); + //also immediately set the current values stelApp->glWindowHasBeenResized(stelScene->sceneRect()); + stelApp->glPhysicalWindowHasBeenResized(getPhysicalSize(stelScene->sceneRect())); StelActionMgr *actionMgr = stelApp->getStelActionManager(); actionMgr->addAction("actionSave_Screenshot_Global", N_("Miscellaneous"), N_("Save screenshot"), this, "saveScreenShot()", "Ctrl+S"); @@ -1346,6 +1352,21 @@ void StelMainView::processOpenGLdiagnosticsAndWarnings(QSettings *conf, QOpenGLC #endif } +// Get physical dimensions given the virtual dimensions for the screen where this window is located. +QRectF StelMainView::getPhysicalSize(const QRectF& virtualRect) const +{ + auto window = this->window(); + if(window) + { + auto pixelRatio = window->devicePixelRatio(); + QRectF newRect(virtualRect.x(), virtualRect.y(), virtualRect.width() * pixelRatio, virtualRect.height() * pixelRatio); + return newRect; + } + + // If the platform does not support getting the QWindow backing instance of this QWidget + return virtualRect; +} + // Debug info about OpenGL capabilities. void StelMainView::dumpOpenGLdiagnostics() const { diff --git a/src/StelMainView.hpp b/src/StelMainView.hpp index 38cf919c007a1..b457e02594905 100644 --- a/src/StelMainView.hpp +++ b/src/StelMainView.hpp @@ -301,6 +301,8 @@ private slots: //! Startup diagnostics, providing test for various circumstances of bad OS/OpenGL driver combinations //! to provide feedback to the user about bad OpenGL drivers. void processOpenGLdiagnosticsAndWarnings(QSettings *conf, QOpenGLContext* context) const; + //! Get physical dimensions given the virtual dimensions for the screen where this window is located. + QRectF getPhysicalSize(const QRectF& virtualRect) const; //! The StelMainView singleton static StelMainView* singleton; From d2cc9c8b8e420a0f3ffeee0fa008dd66f2811d58 Mon Sep 17 00:00:00 2001 From: Hernan Martinez Date: Sat, 14 Oct 2023 02:43:44 -0600 Subject: [PATCH 4/4] Only call glPhysicalWindowHasBeenResized() is SPOUT if enabled --- src/StelMainView.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/StelMainView.cpp b/src/StelMainView.cpp index fa9ff6980c5e0..3650434d3fc08 100644 --- a/src/StelMainView.cpp +++ b/src/StelMainView.cpp @@ -929,14 +929,18 @@ void StelMainView::init() stelApp->init(configuration); //this makes sure the app knows how large the window is connect(stelScene,SIGNAL(sceneRectChanged(QRectF)),stelApp,SLOT(glWindowHasBeenResized(QRectF))); +#ifdef ENABLE_SPOUT QObject::connect(stelScene, &StelGraphicsScene::sceneRectChanged, [&](const QRectF& rect) { stelApp->glPhysicalWindowHasBeenResized(getPhysicalSize(rect)); }); +#endif //also immediately set the current values stelApp->glWindowHasBeenResized(stelScene->sceneRect()); +#ifdef ENABLE_SPOUT stelApp->glPhysicalWindowHasBeenResized(getPhysicalSize(stelScene->sceneRect())); +#endif StelActionMgr *actionMgr = stelApp->getStelActionManager(); actionMgr->addAction("actionSave_Screenshot_Global", N_("Miscellaneous"), N_("Save screenshot"), this, "saveScreenShot()", "Ctrl+S");