From 4f843a3f37537aa9a3969c7cb33eb429ddeb5ddd Mon Sep 17 00:00:00 2001 From: Romain Forlot Date: Mon, 13 Nov 2017 23:01:57 +0100 Subject: qlibwindowmanager is now outside of the project Change-Id: Ifdabb7a3456ade9449e399a13ec43aac68ded108 Signed-off-by: Romain Forlot Signed-off-by: Scott Murray --- app/app.pro | 7 ++--- app/main.cpp | 15 ++++------ app/qlibwindowmanager.cpp | 74 ----------------------------------------------- app/qlibwindowmanager.h | 72 --------------------------------------------- 4 files changed, 9 insertions(+), 159 deletions(-) delete mode 100644 app/qlibwindowmanager.cpp delete mode 100644 app/qlibwindowmanager.h (limited to 'app') diff --git a/app/app.pro b/app/app.pro index 62d547e..00c9c55 100644 --- a/app/app.pro +++ b/app/app.pro @@ -1,11 +1,10 @@ TARGET = hvac -QT = quickcontrols2 +QT = quickcontrols2 qml -HEADERS = qlibwindowmanager.h -SOURCES = main.cpp qlibwindowmanager.cpp +SOURCES = main.cpp CONFIG += link_pkgconfig -PKGCONFIG += libhomescreen libwindowmanager +PKGCONFIG += libhomescreen libwindowmanager qlibwindowmanager RESOURCES += \ hvac.qrc \ diff --git a/app/main.cpp b/app/main.cpp index 7722a0a..57c731e 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -23,14 +23,13 @@ #include #include #include -#include "qlibwindowmanager.h" +#include int main(int argc, char *argv[]) { - std::string myname = std::string("HVAC"); + QString myname = QString("HVAC"); QGuiApplication app(argc, argv); - app.setApplicationName(myname.c_str()); app.setApplicationVersion(QStringLiteral("0.1.0")); app.setOrganizationDomain(QStringLiteral("automotivelinux.org")); app.setOrganizationName(QStringLiteral("AutomotiveGradeLinux")); @@ -69,29 +68,27 @@ int main(int argc, char *argv[]) exit(EXIT_FAILURE); } // Request a surface as described in layers.json windowmanager’s file - if (qwm->requestSurface(json_object_new_string(myname.c_str())) != 0) { + if (qwm->requestSurface(myname) != 0) { exit(EXIT_FAILURE); } - // Create an event callback against an event type. Here a lambda is called when SyncDraw event occurs + // Create an event callbnewack against an event type. Here a lambda is called when SyncDraw event occurs qwm->set_event_handler(QLibWindowmanager::Event_SyncDraw, [qwm, myname](json_object *object) { fprintf(stderr, "Surface got syncDraw!\n"); - qwm->endDraw(json_object_new_string(myname.c_str())); + qwm->endDraw(myname); }); // HomeScreen hs->init(port, token.c_str()); // Set the event handler for Event_TapShortcut which will activate the surface for windowmanager hs->set_event_handler(LibHomeScreen::Event_TapShortcut, [qwm, myname](json_object *object){ - qDebug("object %s", json_object_to_json_string(object)); json_object *appnameJ = nullptr; if(json_object_object_get_ex(object, "application_name", &appnameJ)) { const char *appname = json_object_get_string(appnameJ); - qDebug("appnameJ %s", json_object_to_json_string(appnameJ)); if(myname == appname) { qDebug("Surface %s got tapShortcut\n", appname); - qwm->activateSurface(json_object_new_string(myname.c_str())); + qwm->activateSurface(myname); } } }); diff --git a/app/qlibwindowmanager.cpp b/app/qlibwindowmanager.cpp deleted file mode 100644 index 7ad69f7..0000000 --- a/app/qlibwindowmanager.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/* - * 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 -#include - -int QLibWindowmanager::init(int port, const QString &token) { - std::string ctoken = token.toStdString(); - return this->wm->init(port, ctoken.c_str()); -} - -int QLibWindowmanager::requestSurface(json_object *label) { - applabel = json_object_get_string(label); - - json_object *obj = json_object_new_object(); - json_object_object_add(obj, wm->kKeyDrawingName, label); - return this->wm->requestSurface(obj); -} - -int QLibWindowmanager::activateSurface(json_object *label) { - json_object *obj = json_object_new_object(); - json_object_object_add(obj, wm->kKeyDrawingName, label); - json_object_object_add(obj, wm->kKeyDrawingArea, json_object_new_string("normal.full")); - - return this->wm->activateSurface(obj); -} - -int QLibWindowmanager::deactivateSurface(json_object *label) { - json_object *obj = json_object_new_object(); - json_object_object_add(obj, wm->kKeyDrawingName, label); - return this->wm->deactivateSurface(obj); -} - -int QLibWindowmanager::endDraw(json_object *label) { - json_object *obj = json_object_new_object(); - json_object_object_add(obj, wm->kKeyDrawingName, label); - return this->wm->endDraw(obj); - } - -void QLibWindowmanager::set_event_handler(enum QEventType et, - handler_fun f) { - LibWindowmanager::EventType wet = (LibWindowmanager::EventType)et; - return this->wm->set_event_handler(wet, std::move(f)); -} - -void QLibWindowmanager::slotActivateSurface(){ - if(!isActive){ - qDebug("Let's show HVAC"); - isActive = true; - this->activateSurface(json_object_new_string(applabel.c_str())); - } -} - -QLibWindowmanager::QLibWindowmanager(QObject *parent) - :QObject(parent), isActive(false) -{ - wm = new LibWindowmanager(); -} - -QLibWindowmanager::~QLibWindowmanager() { } diff --git a/app/qlibwindowmanager.h b/app/qlibwindowmanager.h deleted file mode 100644 index 07f8479..0000000 --- a/app/qlibwindowmanager.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include - -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; - - enum QEventType { - Event_Active = 0, - Event_Inactive, - - Event_Visible, - Event_Invisible, - - Event_SyncDraw, - Event_FlushDraw, - }; - - static QLibWindowmanager &instance(); - - int init(int port, const QString &token); - - // WM API - int requestSurface(json_object *label); - int activateSurface(json_object *label); - int deactivateSurface(json_object *label); - int endDraw(json_object *label); - void set_event_handler(enum QEventType et, handler_fun f); - -public slots: - void slotActivateSurface(); - -private: - LibWindowmanager* wm; - std::string applabel; - std::vector surfaceIDs; - bool isActive; - -}; -#endif // LIBWINDOWMANAGER_H -- cgit 1.2.3-korg