Skip to content

Commit

Permalink
Use physical dimensions when sending Spout data
Browse files Browse the repository at this point in the history
  • Loading branch information
hmartinez82 committed Oct 14, 2023
1 parent 491aa73 commit c907e81
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/StelMainView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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
{
Expand Down
2 changes: 2 additions & 0 deletions src/StelMainView.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit c907e81

Please sign in to comment.