Add app parameter to set display id
[staging/HomeScreen.git] / WindowManager / src / main.cpp
1 /*
2  * Copyright (C) 2016 Mentor Graphics Development (Deutschland) GmbH
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include <QCoreApplication>
18 #include <QCommandLineParser>
19 #include "windowmanager.hpp"
20
21 int main(int argc, char *argv[])
22 {
23     QCoreApplication a(argc, argv);
24
25     QCoreApplication::setOrganizationDomain("LinuxFoundation");
26     QCoreApplication::setOrganizationName("AutomotiveGradeLinux");
27     QCoreApplication::setApplicationName("WindowManager");
28     QCoreApplication::setApplicationVersion("0.7.0");
29
30     QCommandLineParser parser;
31     parser.setApplicationDescription("AGL WindowManager - see wwww... for more details");
32     parser.addHelpOption();
33     parser.addVersionOption();
34     QCommandLineOption displayOption(QStringList() << "d" << "display-id",
35         QCoreApplication::translate("main", "The display with this <id> to manage. Default=0"),
36         QCoreApplication::translate("main", "id"));
37     parser.addOption(displayOption);
38     parser.process(a);
39
40     int displayId = 0;
41     if (parser.isSet(displayOption))
42     {
43         displayId = parser.value(displayOption).toInt();
44     }
45     qDebug() << "Using display" << displayId;
46
47     qDBusRegisterMetaType<SimplePoint>();
48     qDBusRegisterMetaType<QList<SimplePoint> >();
49     qDBusRegisterMetaType<LayoutArea>();
50     qDBusRegisterMetaType<QList<LayoutArea> >();
51     qDBusRegisterMetaType<Layout>();
52     qDBusRegisterMetaType<QList<Layout> >();
53
54     WindowManager *windowManager = new WindowManager(displayId);
55     windowManager->start();
56
57 #ifdef __arm__
58     qDebug("Running on ARM architecture");
59 #endif
60 #ifdef __i386__
61     qDebug("Running on x86 architecture");
62 #endif
63
64     return a.exec();
65 }