Hi Stellarium developers,

I need to configure on which screen Stellarium starts so I put together
the following patch. I haven't found what is the patch submitting
procedure, so feel free to point me to the right place.

Thanks.
-Michal

>From 18ffd58bb373fff49e5fbc66ffa92ba9d806df9b Mon Sep 17 00:00:00 2001
From: Michal Sojka <sojk...@fel.cvut.cz>
Date: Thu, 5 Feb 2015 21:53:26 +0100
Subject: [PATCH] Allow to configure startup screen in multiscreen setups

On multi-screen setups, Stellarium always starts on primary screen. This
patch adds a configuration-file option to configure the screen where
Stellarium appears. This option is only effective if fullscreen=true. In
windowed mode, the used screen depends on screen_x and screen_y options.

This was tested on Linux and Windows on top of 0.13.2 and it compiles
with the current HEAD.
---
 data/default_config.ini.cmake   |  1 +
 src/StelMainView.cpp            | 16 +++++++++++++++-
 src/gui/ConfigurationDialog.cpp |  5 +++++
 3 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/data/default_config.ini.cmake b/data/default_config.ini.cmake
index 1334a18..834e8db 100644
--- a/data/default_config.ini.cmake
+++ b/data/default_config.ini.cmake
@@ -10,6 +10,7 @@ TimeZoneConfiguration               = true
 
 [video]
 fullscreen                          = true
+fullscreen_num                      = 0
 screen_w                            = 1024
 screen_h                            = 768
 screen_x                            = 0
diff --git a/src/StelMainView.cpp b/src/StelMainView.cpp
index b798af8..f808e70 100644
--- a/src/StelMainView.cpp
+++ b/src/StelMainView.cpp
@@ -38,6 +38,8 @@
 #else
 #include <QGLWidget>
 #endif
+#include <QApplication>
+#include <QDesktopWidget>
 #include <QGuiApplication>
 #include <QFileInfo>
 #include <QIcon>
@@ -457,7 +459,7 @@ void StelMainView::init(QSettings* conf)
        qmlRegisterType<StelGuiItem>("Stellarium", 1, 0, "StelGui");
        rootContext()->setContextProperty("stelApp", stelApp);  
        setSource(QUrl("qrc:/qml/main.qml"));
-       
+
        QSize size = glWidget->windowHandle()->screen()->size();
        size = QSize(conf->value("video/screen_w", size.width()).toInt(),
                     conf->value("video/screen_h", size.height()).toInt());
@@ -469,6 +471,18 @@ void StelMainView::init(QSettings* conf)
 
        if (fullscreen)
        {
+               int screen = conf->value("video/fullscreen_num", 0).toInt();
+
+               QDesktopWidget *desktop = QApplication::desktop();
+               if (screen < 0 || screen >= desktop->screenCount())
+               {
+                       qWarning() << "WARNING: screen" << screen << "not 
found";
+                       screen = 0;
+               }
+
+               QRect screenGeom = desktop->screenGeometry(screen);
+               move(QPoint(screenGeom.x(), screenGeom.y()));
+               resize(screenGeom.width(), screenGeom.height());
                setFullScreen(true);
        }
        else
diff --git a/src/gui/ConfigurationDialog.cpp b/src/gui/ConfigurationDialog.cpp
index 3cb1ef6..f9554da 100644
--- a/src/gui/ConfigurationDialog.cpp
+++ b/src/gui/ConfigurationDialog.cpp
@@ -65,6 +65,7 @@
 #include <QFileDialog>
 #include <QComboBox>
 #include <QDir>
+#include <QDesktopWidget>
 
 ConfigurationDialog::ConfigurationDialog(StelGui* agui, QObject* parent)
        : StelDialog(parent)
@@ -718,6 +719,10 @@ void ConfigurationDialog::saveCurrentViewOptions()
                conf->setValue("video/screen_x", mainWindow.x());
                conf->setValue("video/screen_y", mainWindow.y());
        }
+       else
+       {
+               conf->setValue("video/fullscreen_num", 
qApp->desktop()->screenNumber(&StelMainView::getInstance()));
+       }
 
        // clear the restore defaults flag if it is set.
        conf->setValue("main/restore_defaults", false);
-- 
2.1.4


------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Stellarium-pubdevel mailing list
Stellarium-pubdevel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stellarium-pubdevel

Reply via email to