aboutsummaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorzheng_wenlong <wenlong_zheng@nexty-ele.com>2017-09-29 21:06:22 +0900
committerYuta Doi <yuta-d@witz-inc.co.jp>2017-10-09 01:48:59 +0900
commit074d058a7a483a66af7f8c0b928b321ad483f47c (patch)
treeeb89aacd178a7b99850cbdc528976e97d35d37bf /client
parent7204e00b05cab896df48abf6a355be69a0f57f80 (diff)
Add agl-service-windowmanager-2017
Add a new binding agl-service-windowmanager-2017. A image about this see JIRA SPEC-915. [PatchSet2] Use aglwgt make package. [PatchSet3] Modify to wait until wayland compositor starts up. Bug-AGL: SPEC-925 Change-Id: I8729bb71b5e91d5b009a5bab77232d92605c43ea Signed-off-by: zheng_wenlong <wenlong_zheng@nexty-ele.com>
Diffstat (limited to 'client')
-rw-r--r--client/README39
-rw-r--r--client/communication.cpp86
-rw-r--r--client/communication.h64
-rw-r--r--client/extra/WindowManagerSampleApp.qml47
-rw-r--r--client/extra/WindowManagerSampleApp.qml.sample252
-rw-r--r--client/main.cpp99
-rw-r--r--client/main.cpp.sample292
-rw-r--r--client/qlibwindowmanager.cpp56
-rw-r--r--client/qlibwindowmanager.h69
-rw-r--r--client/qmlWindowManagerSampleApp.pro20
-rw-r--r--client/sample.qrc5
11 files changed, 629 insertions, 0 deletions
diff --git a/client/README b/client/README
new file mode 100644
index 0000000..95ab875
--- /dev/null
+++ b/client/README
@@ -0,0 +1,39 @@
+= Example Application for TMC AGL WindowManager Client Lib
+This is a example QML application that uses clients of the TMC WindowManager.
+
+== Dependencies
+* Qt5 + QtQuick (QML) with ivi-shell support
+
+== Build instructions
+Inside of an SDK environment run:
+
+----------------
+qmake
+make
+----------------
+
+* The binary should be installed somewhere in $PATH
+
+== Usage
+Run this application like follows:
+
+----------------
+qmlWindowManagerSampleApp $width $height $appLabel $colorName
+----------------
+
+.Note
+****************
+Depending on your environment you will need to set the following
+environment variable to instruct Qt to use the ivi-shell integration:
+`QT_WAYLAND_SHELL_INTEGRATION=ivi-shell`
+****************
+
+Starts the application with a surface the size $width x $height
+the Surface will request the label "$appLabel" and set its surface
+color "$colorName" e.g. red.
+
+Note, that although the application sets an initial window size, the
+window manager will send events to the application that instruct it to
+set the proper, requested size for the layout.
+
+// vim:set tw=72 ft=asciidoc:
diff --git a/client/communication.cpp b/client/communication.cpp
new file mode 100644
index 0000000..1acfdca
--- /dev/null
+++ b/client/communication.cpp
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "communication.h"
+
+#include <QGuiApplication>
+#include <QDebug>
+
+communication::communication(QObject *parent) : QObject(parent)
+{
+ this->quit = false;
+}
+
+communication::~communication()
+{
+}
+
+void communication::setWidth(const unsigned int &w)
+{
+ this->width = w;
+ emit widthChanged();
+}
+
+void communication::setHeight(const unsigned int &h)
+{
+ this->height = h;
+ emit heightChanged();
+}
+
+void communication::setColor(const QString &c)
+{
+ this->color = c;
+ emit colorChanged();
+}
+
+void communication::setAppName(const QString &a)
+{
+ this->appName = a;
+ emit appNameChanged();
+}
+
+void communication::setQuit(const bool &q)
+{
+ this->quit = q;
+ emit quitChanged();
+ if(q)
+ exit(EXIT_SUCCESS);
+}
+
+unsigned int communication::getWidth() const
+{
+ return this->width;
+}
+
+unsigned int communication::getHeight() const
+{
+ return this->height;
+}
+
+QString communication::getColor() const
+{
+ return this->color;
+}
+
+QString communication::getAppName() const
+{
+ return this->appName;
+}
+
+bool communication::getQuit() const
+{
+ return this->quit;
+}
diff --git a/client/communication.h b/client/communication.h
new file mode 100644
index 0000000..fd3072f
--- /dev/null
+++ b/client/communication.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef COMMUNICATION_H
+#define COMMUNICATION_H
+
+#include <QObject>
+
+class communication : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(unsigned int width WRITE setWidth READ getWidth NOTIFY widthChanged)
+ Q_PROPERTY(unsigned int height WRITE setHeight READ getHeight NOTIFY heightChanged)
+ Q_PROPERTY(QString color READ getColor WRITE setColor NOTIFY colorChanged)
+ Q_PROPERTY(QString appName READ getAppName WRITE setAppName NOTIFY appNameChanged)
+ Q_PROPERTY(bool quit READ getQuit WRITE setQuit NOTIFY quitChanged)
+
+public:
+ explicit communication(QObject *parent = 0);
+ virtual ~communication();
+
+public slots:
+ void setWidth(const unsigned int &);
+ void setHeight(const unsigned int &);
+ void setColor(const QString&);
+ void setAppName(const QString&);
+ void setQuit(const bool&);
+
+ unsigned int getWidth() const;
+ unsigned int getHeight() const;
+ QString getColor() const;
+ QString getAppName() const;
+ bool getQuit() const;
+
+signals:
+ void widthChanged();
+ void heightChanged();
+ void colorChanged();
+ void appNameChanged();
+ void quitChanged();
+
+private:
+ unsigned int width;
+ unsigned int height;
+ QString color;
+ QString appName;
+ bool quit;
+};
+
+#endif // COMMUNICATION_H
diff --git a/client/extra/WindowManagerSampleApp.qml b/client/extra/WindowManagerSampleApp.qml
new file mode 100644
index 0000000..0945af9
--- /dev/null
+++ b/client/extra/WindowManagerSampleApp.qml
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import QtQuick 2.2
+import QtQuick.Window 2.1
+import QtQuick.Layouts 1.1
+
+Window {
+ id: screen
+ width: COMM.width
+ height: COMM.height
+ color: COMM.color
+ flags: Qt.FramelessWindowHint
+ title: COMM.appName
+ opacity: 0.99
+ visible: true
+
+ Timer {
+ id: quitTimer
+ interval: 2000
+ repeat: false
+ triggeredOnStart: false
+ onTriggered: COMM.quit = true
+ }
+
+ Text {
+ id: textArea
+ color: "black"
+ font.bold: true
+ font.pointSize: 90
+ anchors.centerIn: parent
+ text: COMM.appName
+ }
+}
diff --git a/client/extra/WindowManagerSampleApp.qml.sample2 b/client/extra/WindowManagerSampleApp.qml.sample2
new file mode 100644
index 0000000..1ffc071
--- /dev/null
+++ b/client/extra/WindowManagerSampleApp.qml.sample2
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import QtQuick 2.2
+import QtQuick.Window 2.1
+import QtQuick.Layouts 1.1
+
+Window {
+ id: screen
+ width: COMM.width
+ height: COMM.height
+ color: COMM.color
+ flags: Qt.FramelessWindowHint
+ title: COMM.appName
+ opacity: 0.99
+ visible: true
+ signal created
+
+ Timer {
+ id: quitTimer
+ interval: 2000
+ repeat: false
+ triggeredOnStart: false
+ onTriggered: COMM.quit = true
+ }
+
+ Text {
+ id: textArea
+ color: "black"
+ font.bold: true
+ font.pointSize: 90
+ anchors.centerIn: parent
+ text: COMM.appName
+ }
+ onFrameSwapped: {
+ created()
+ }
+
+}
diff --git a/client/main.cpp b/client/main.cpp
new file mode 100644
index 0000000..3dc2e42
--- /dev/null
+++ b/client/main.cpp
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include <QDebug>
+#include <QDir>
+#include <QGuiApplication>
+#include <QQmlApplicationEngine>
+#include <QQmlContext>
+#include <QQuickView>
+#include <QQuickWindow>
+#include "communication.h"
+
+#include "qlibwindowmanager.h"
+
+int main(int argc, char *argv[]) {
+ QGuiApplication app(argc, argv);
+
+ qDebug() << QCoreApplication::arguments();
+
+ if (QCoreApplication::arguments().count() < 5) {
+ qWarning() << "Wrong parameters specified for the application. "
+ "Please restart with correct parameters:"
+ "width, height, name, color [port] [token]:\n\n"
+ "/usr/bin/WindowManagerSampleApp/"
+ "qmlWindowManagerSampleApp width height name color\n";
+ exit(EXIT_FAILURE);
+ }
+
+ QString label = QCoreApplication::arguments().at(3);
+
+ QLibWindowmanager* qwm = new QLibWindowmanager();
+
+ QString token = "wm";
+ int port = 1700;
+ if(QCoreApplication::arguments().count() == 7){
+ bool ok;
+ port = QCoreApplication::arguments().at(5).toInt(&ok);
+ if(ok == false){
+ port = 1700;
+ }
+ else{
+ token = QCoreApplication::arguments().at(6);
+ }
+ }
+ const char* ctoken = token.toLatin1().data();
+ if (qwm->init(port, ctoken) != 0) {
+ exit(EXIT_FAILURE);
+ }
+
+ if (qwm->requestSurface(
+ QCoreApplication::arguments().at(3).toLatin1().data()) != 0) {
+ exit(EXIT_FAILURE);
+ }
+
+ qwm->set_event_handler(QLibWindowmanager::Event_SyncDraw, [qwm](char const *label) {
+ fprintf(stderr, "Surface %s got syncDraw!\n", label);
+ qwm->endDraw(label);
+ });
+ qwm->set_event_handler(QLibWindowmanager::Event_Active, [](char const *label) {
+ fprintf(stderr, "Surface %s got activated!\n", label);
+ });
+ qwm->set_event_handler(QLibWindowmanager::Event_Visible, [](char const *label) {
+ fprintf(stderr, "Surface %s got visible!\n", label);
+ });
+ qwm->set_event_handler(QLibWindowmanager::Event_FlushDraw, [](char const *label) {
+ fprintf(stderr, "Surface %s got flushDraw!\n", label);
+ });
+
+ communication comm;
+ comm.setWidth(QCoreApplication::arguments().at(1).toUInt());
+ comm.setHeight(QCoreApplication::arguments().at(2).toUInt());
+ comm.setAppName(label);
+ comm.setColor(QCoreApplication::arguments().at(4));
+
+ QQmlApplicationEngine engine;
+ engine.rootContext()->setContextProperty("COMM", &comm);
+
+ engine.load(
+ QUrl(QStringLiteral("qrc:/extra/WindowManagerSampleApp.qml")));
+ QObject *root = engine.rootObjects().first();
+ QQuickWindow *window = qobject_cast<QQuickWindow *>(root);
+ QObject::connect(root, SIGNAL(frameSwapped()), qwm, SLOT(slotActivateSurface()));
+
+ return app.exec();
+}
diff --git a/client/main.cpp.sample2 b/client/main.cpp.sample2
new file mode 100644
index 0000000..5d9cc44
--- /dev/null
+++ b/client/main.cpp.sample2
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include <QDebug>
+#include <QDir>
+#include <QGuiApplication>
+#include <QQmlApplicationEngine>
+#include <QQmlContext>
+#include <QQuickView>
+#include <QQuickWindow>
+#include "communication.h"
+
+#include "qlibwindowmanager.h"
+
+int main(int argc, char *argv[]) {
+ QGuiApplication app(argc, argv);
+
+ qDebug() << QCoreApplication::arguments();
+
+ if (QCoreApplication::arguments().count() < 5) {
+ qWarning() << "Wrong parameters specified for the application. "
+ "Please restart with correct parameters:"
+ "width, height, name, color [port] [token]:\n\n"
+ "/usr/bin/WindowManagerSampleApp/"
+ "qmlWindowManagerSampleApp width height name color\n";
+ exit(EXIT_FAILURE);
+ }
+
+ QString label = QCoreApplication::arguments().at(3);
+
+ QLibWindowmanager* qwm = new QLibWindowmanager();
+
+ QString token = "wm";
+ int port = 1700;
+ if(QCoreApplication::arguments().count() == 7){
+ bool ok;
+ port = QCoreApplication::arguments().at(5).toInt(&ok);
+ if(ok == false){
+ port = 1700;
+ }
+ else{
+ token = QCoreApplication::arguments().at(6);
+ }
+ }
+ const char* ctoken = token.toLatin1().data();
+ if (qwm->init(port, ctoken) != 0) {
+ exit(EXIT_FAILURE);
+ }
+
+ if (qwm->requestSurface(
+ QCoreApplication::arguments().at(3).toLatin1().data()) != 0) {
+ exit(EXIT_FAILURE);
+ }
+
+ qwm->set_event_handler(QLibWindowmanager::Event_SyncDraw, [qwm](char const *label) {
+ //qwm->endDraw(label);
+ fprintf(stderr, "Surface %s got syncDraw!\n", label);
+ });
+ qwm->set_event_handler(QLibWindowmanager::Event_Active, [](char const *label) {
+ fprintf(stderr, "Surface %s got activated!\n", label);
+ });
+
+ communication comm;
+ comm.setWidth(QCoreApplication::arguments().at(1).toUInt());
+ comm.setHeight(QCoreApplication::arguments().at(2).toUInt());
+ comm.setAppName(label);
+ comm.setColor(QCoreApplication::arguments().at(4));
+
+ QQmlApplicationEngine engine;
+ engine.rootContext()->setContextProperty("COMM", &comm);
+
+ engine.load(
+ QUrl(QStringLiteral("qrc:/extra/WindowManagerSampleApp.qml")));
+ QObject *root = engine.rootObjects().first();
+ QObject::connect(root, SIGNAL(created()), qwm, SLOT(slotActivateSurface()));
+
+ return app.exec();
+}
diff --git a/client/qlibwindowmanager.cpp b/client/qlibwindowmanager.cpp
new file mode 100644
index 0000000..e69f0ac
--- /dev/null
+++ b/client/qlibwindowmanager.cpp
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "qlibwindowmanager.h"
+#include <unistd.h>
+
+int QLibWindowmanager::init(int port, char const *token) {
+ return this->wm->init(port, token);
+}
+
+int QLibWindowmanager::requestSurface(const char *label) {
+ applabel = label;
+ return this->wm->requestSurface(label);
+}
+
+int QLibWindowmanager::activateSurface(const char *label) {
+ return this->wm->activateSurface(label);
+}
+
+int QLibWindowmanager::deactivateSurface(const char *label) {
+ return this->wm->deactivateSurface(label);
+}
+
+int QLibWindowmanager::endDraw(const char *label) { return this->wm->endDraw(label); }
+
+void QLibWindowmanager::set_event_handler(enum QEventType et,
+ std::function<void(char const *label)> f) {
+ LibWindowmanager::EventType wet = (LibWindowmanager::EventType)et;
+ return this->wm->set_event_handler(wet, std::move(f));
+}
+
+void QLibWindowmanager::slotActivateSurface(){
+ qDebug("%s",__FUNCTION__);
+ this->activateSurface(applabel.c_str());
+}
+
+QLibWindowmanager::QLibWindowmanager(QObject *parent)
+ :QObject(parent)
+{
+ wm = new LibWindowmanager();
+}
+
+QLibWindowmanager::~QLibWindowmanager() { }
diff --git a/client/qlibwindowmanager.h b/client/qlibwindowmanager.h
new file mode 100644
index 0000000..ed86a65
--- /dev/null
+++ b/client/qlibwindowmanager.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef QLIBWINDOWMANAGER_H
+#define QLIBWINDOWMANAGER_H
+#include <libwindowmanager.h>
+#include <functional>
+ #include <QObject>
+ #include <QUrl>
+ #include <QVariant>
+ #include <string>
+ #include <vector>
+
+class QLibWindowmanager : public QObject{
+Q_OBJECT
+public:
+ explicit QLibWindowmanager(QObject *parent = nullptr);
+ ~QLibWindowmanager();
+
+ QLibWindowmanager(const QLibWindowmanager &) = delete;
+ QLibWindowmanager &operator=(const QLibWindowmanager &) = delete;
+
+public:
+ using handler_fun = std::function<void(const char *)>;
+
+ enum QEventType {
+ Event_Active = 1,
+ Event_Inactive,
+
+ Event_Visible,
+ Event_Invisible,
+
+ Event_SyncDraw,
+ Event_FlushDraw,
+ };
+
+ static QLibWindowmanager &instance();
+
+ int init(int port, char const *token);
+
+ // WM API
+ int requestSurface(const char *label);
+ int activateSurface(const char *label);
+ int deactivateSurface(const char *label);
+ int endDraw(const char *label);
+ void set_event_handler(enum QEventType et, handler_fun f);
+
+public slots:
+ void slotActivateSurface();
+
+private:
+ LibWindowmanager* wm;
+ std::string applabel;
+ std::vector<int> surfaceIDs;
+};
+#endif // LIBWINDOWMANAGER_H
diff --git a/client/qmlWindowManagerSampleApp.pro b/client/qmlWindowManagerSampleApp.pro
new file mode 100644
index 0000000..3064d57
--- /dev/null
+++ b/client/qmlWindowManagerSampleApp.pro
@@ -0,0 +1,20 @@
+TEMPLATE = app
+QT += qml quick
+CONFIG += c++11
+
+HEADERS += communication.h qlibwindowmanager.h
+
+SOURCES += main.cpp \
+ communication.cpp qlibwindowmanager.cpp
+RESOURCES += sample.qrc
+
+INCLUDEPATH += $$[QT_SYSROOT]/usr/include/afb
+
+LIBS += -lwindowmanager
+#LIBS += -lsystemd
+LIBS += -lafbwsc
+#LIBS += -ljson-c
+
+target.path = /usr/bin/WindowManagerSampleApp
+
+INSTALLS += target
diff --git a/client/sample.qrc b/client/sample.qrc
new file mode 100644
index 0000000..be79eb6
--- /dev/null
+++ b/client/sample.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/">
+ <file>extra/WindowManagerSampleApp.qml</file>
+ </qresource>
+</RCC>