c578b4743d782267f3d23fe916317e4b4b5f63c5
[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
22 void noOutput(QtMsgType, const QMessageLogContext &, const QString &)
23 {
24 }
25
26 int main(int argc, char *argv[])
27 {
28     QCoreApplication a(argc, argv);
29
30     QCoreApplication::setOrganizationDomain("LinuxFoundation");
31     QCoreApplication::setOrganizationName("AutomotiveGradeLinux");
32     QCoreApplication::setApplicationName("WindowManager");
33     QCoreApplication::setApplicationVersion("0.7.0");
34
35     QCommandLineParser parser;
36     parser.setApplicationDescription("AGL WindowManager - see wwww... for more details");
37     parser.addHelpOption();
38     parser.addVersionOption();
39     QCommandLineOption quietOption(QStringList() << "q" << "quiet",
40         QCoreApplication::translate("main", "Be quiet. No outputs."));
41     parser.addOption(quietOption);
42     QCommandLineOption displayOption(QStringList() << "d" << "display-id",
43         QCoreApplication::translate("main", "The display with this <id> to manage. Default=0"),
44         QCoreApplication::translate("main", "id"));
45     parser.addOption(displayOption);
46     parser.process(a);
47
48     if (parser.isSet(quietOption))
49     {
50         qInstallMessageHandler(noOutput);
51     }
52
53     int displayId = 0;
54     if (parser.isSet(displayOption))
55     {
56         displayId = parser.value(displayOption).toInt();
57     }
58     qDebug() << "Using display" << displayId;
59
60     qDBusRegisterMetaType<SimplePoint>();
61     qDBusRegisterMetaType<QList<SimplePoint> >();
62     qDBusRegisterMetaType<LayoutArea>();
63     qDBusRegisterMetaType<QList<LayoutArea> >();
64     qDBusRegisterMetaType<Layout>();
65     qDBusRegisterMetaType<QList<Layout> >();
66
67     WindowManager *windowManager = new WindowManager(displayId);
68     windowManager->start();
69
70 #ifdef __arm__
71     qDebug("Running on ARM architecture");
72 #endif
73 #ifdef __i386__
74     qDebug("Running on x86 architecture");
75 #endif
76
77     return a.exec();
78 }