2 * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 #include <QGuiApplication>
21 #include <QQmlApplicationEngine>
22 #include <QQmlContext>
24 #include <QQuickWindow>
25 #include "communication.h"
27 #include "qlibwindowmanager.h"
29 int main(int argc, char *argv[]) {
30 QGuiApplication app(argc, argv);
32 qDebug() << QCoreApplication::arguments();
34 if (QCoreApplication::arguments().count() < 5) {
35 qWarning() << "Wrong parameters specified for the application. "
36 "Please restart with correct parameters:"
37 "width, height, name, color [port] [token]:\n\n"
38 "/usr/bin/WindowManagerSampleApp/"
39 "qmlWindowManagerSampleApp width height name color\n";
43 QString label = QCoreApplication::arguments().at(3);
45 QLibWindowmanager* qwm = new QLibWindowmanager();
49 if(QCoreApplication::arguments().count() == 7){
51 port = QCoreApplication::arguments().at(5).toInt(&ok);
56 token = QCoreApplication::arguments().at(6);
59 const char* ctoken = token.toLatin1().data();
60 if (qwm->init(port, ctoken) != 0) {
64 if (qwm->requestSurface(
65 QCoreApplication::arguments().at(3).toLatin1().data()) != 0) {
69 qwm->set_event_handler(QLibWindowmanager::Event_SyncDraw, [qwm](char const *label) {
70 //qwm->endDraw(label);
71 fprintf(stderr, "Surface %s got syncDraw!\n", label);
73 qwm->set_event_handler(QLibWindowmanager::Event_Active, [](char const *label) {
74 fprintf(stderr, "Surface %s got activated!\n", label);
78 comm.setWidth(QCoreApplication::arguments().at(1).toUInt());
79 comm.setHeight(QCoreApplication::arguments().at(2).toUInt());
80 comm.setAppName(label);
81 comm.setColor(QCoreApplication::arguments().at(4));
83 QQmlApplicationEngine engine;
84 engine.rootContext()->setContextProperty("COMM", &comm);
87 QUrl(QStringLiteral("qrc:/extra/WindowManagerSampleApp.qml")));
88 QObject *root = engine.rootObjects().first();
89 QObject::connect(root, SIGNAL(created()), qwm, SLOT(slotActivateSurface()));