aboutsummaryrefslogtreecommitdiffstats
path: root/src/aglextras/hmi/aglwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/aglextras/hmi/aglwindow.cpp')
-rw-r--r--src/aglextras/hmi/aglwindow.cpp106
1 files changed, 106 insertions, 0 deletions
diff --git a/src/aglextras/hmi/aglwindow.cpp b/src/aglextras/hmi/aglwindow.cpp
new file mode 100644
index 0000000..f1f55e6
--- /dev/null
+++ b/src/aglextras/hmi/aglwindow.cpp
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
+ * Copyright (C) 2017 The Qt Company Ltd.
+ * Copyright (c) 2017 Panasonic 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 "aglwindow.h"
+#include "aglwindow_p.h"
+
+#include <QtQuick/QQuickWindow>
+#include <QtQml/QQmlApplicationEngine>
+
+QT_BEGIN_NAMESPACE
+
+AGLWindowPrivate::AGLWindowPrivate (AGLWindow*)
+{
+ ;
+}
+
+AGLWindowPrivate::~AGLWindowPrivate (void)
+{
+ ;
+}
+
+void AGLWindow::activate_surface (void)
+{
+ qDebug("Disconnect!! SLOT activate_surface()");
+ QLibWindowmanager::disconnect(d_ptr->loading);
+
+ activateSurface(QString(d_ptr->layout));
+}
+
+void AGLWindow::attach (QQmlApplicationEngine* engine)
+{
+ if (d_ptr->binding) {
+ QQuickWindow *window = qobject_cast<QQuickWindow *>(engine->rootObjects().first());
+
+ qDebug("Connect!! frameSapped! (activate_surface())");
+ d_ptr->loading = QLibWindowmanager::connect(window, SIGNAL(frameSwapped()),
+ this, SLOT(activate_surface()));
+ }
+}
+
+AGLWindow::AGLWindow (const QString& layout, int port, QString secret)
+ : QLibWindowmanager(nullptr),
+ d_ptr(new AGLWindowPrivate(this))
+
+{
+ if (port == -1) {
+ qDebug("This is not AGL binding application");
+ return;
+ }
+
+ if (QLibWindowmanager::init(port, secret) != 0 ||
+ LibHomeScreen::init(port, secret.toStdString().c_str()) != 0) {
+ qDebug("Cannot get binding API");
+ return;
+ }
+
+ d_ptr->layout = layout;
+
+ // Request a surface as described in layers.json windowmanager’s file
+ if (requestSurface(d_ptr->layout) != 0) {
+ qDebug("Cannot get surface for %s", qPrintable(d_ptr->layout));
+ return;
+ }
+
+ d_ptr->binding = true;
+
+ // Create an event callback against an event type. Here a lambda is called when SyncDraw event occurs
+ QLibWindowmanager::set_event_handler (
+ QLibWindowmanager::Event_SyncDraw,
+ [this](json_object*) {
+ qDebug("Surface got syncDraw!\n");
+ endDraw(d_ptr->layout);
+ }
+ );
+
+ // Set the event handler for Event_TapShortcut which will activate the surface for windowmanager
+ LibHomeScreen::set_event_handler (
+ LibHomeScreen::Event_TapShortcut,
+ [this](json_object* object) {
+ json_object *jo_app_name = nullptr;
+ if(json_object_object_get_ex(object, "application_name", &jo_app_name)) {
+ QString name(QLatin1String(json_object_get_string(jo_app_name)));
+ if(d_ptr->layout == name) {
+ qDebug("Surface %s got tapShortcut\n", qPrintable(name));
+ activateSurface(d_ptr->layout);
+ }
+ }
+ }
+ );
+}
+
+QT_END_NAMESPACE