Add app parameter to set display id
authorBocklage, Jens <Jens_Bocklage@mentor.com>
Fri, 16 Dec 2016 14:18:34 +0000 (15:18 +0100)
committerBocklage, Jens <Jens_Bocklage@mentor.com>
Fri, 16 Dec 2016 14:18:34 +0000 (15:18 +0100)
On systems with more then one display, you may want
to set the display that will be managed.
The default display is 0.

Signed-off-by: Bocklage, Jens <Jens_Bocklage@mentor.com>
WindowManager/src/main.cpp
WindowManager/src/windowmanager.cpp
WindowManager/src/windowmanager.hpp

index 4f3874d..5af8be1 100644 (file)
  */
 
 #include <QCoreApplication>
+#include <QCommandLineParser>
 #include "windowmanager.hpp"
 
 int main(int argc, char *argv[])
 {
     QCoreApplication a(argc, argv);
 
-    // used for application settings (QSettings)
     QCoreApplication::setOrganizationDomain("LinuxFoundation");
     QCoreApplication::setOrganizationName("AutomotiveGradeLinux");
     QCoreApplication::setApplicationName("WindowManager");
-    QCoreApplication::setApplicationVersion("0.6.0");
+    QCoreApplication::setApplicationVersion("0.7.0");
 
-    qDebug("%s, v%s", QCoreApplication::applicationName().toStdString().c_str(), QCoreApplication::applicationVersion().toStdString().c_str());
+    QCommandLineParser parser;
+    parser.setApplicationDescription("AGL WindowManager - see wwww... for more details");
+    parser.addHelpOption();
+    parser.addVersionOption();
+    QCommandLineOption displayOption(QStringList() << "d" << "display-id",
+        QCoreApplication::translate("main", "The display with this <id> to manage. Default=0"),
+        QCoreApplication::translate("main", "id"));
+    parser.addOption(displayOption);
+    parser.process(a);
+
+    int displayId = 0;
+    if (parser.isSet(displayOption))
+    {
+        displayId = parser.value(displayOption).toInt();
+    }
+    qDebug() << "Using display" << displayId;
 
     qDBusRegisterMetaType<SimplePoint>();
     qDBusRegisterMetaType<QList<SimplePoint> >();
@@ -36,7 +51,7 @@ int main(int argc, char *argv[])
     qDBusRegisterMetaType<Layout>();
     qDBusRegisterMetaType<QList<Layout> >();
 
-    WindowManager *windowManager = new WindowManager();
+    WindowManager *windowManager = new WindowManager(displayId);
     windowManager->start();
 
 #ifdef __arm__
index 101f5b3..38889c7 100644 (file)
 
 void* WindowManager::myThis = 0;
 
-WindowManager::WindowManager(QObject *parent) :
+WindowManager::WindowManager(int displayId, QObject *parent) :
     QObject(parent),
     m_layouts(),
     //    m_appSurfaces(),
     mp_layoutAreaToSurfaceIdAssignment(0),
     m_currentLayout(-1),
-    m_screenId(0), // use screen "0"
+    m_screenId(displayId),
     m_screenWidth(0),
     m_screenHeight(0)
 #ifdef HAVE_IVI_LAYERMANAGEMENT_API
index 5cc536b..d2c9c9b 100644 (file)
@@ -32,7 +32,7 @@ class WindowManager : public QObject
     Q_OBJECT
 
 public:
-    explicit WindowManager(QObject *parent = 0);
+    explicit WindowManager(int displayId, QObject *parent = 0);
     ~WindowManager();
 
     void start();