From 1d481d828e5c4df270f61554985c542b463294c6 Mon Sep 17 00:00:00 2001 From: zheng_wenlong Date: Tue, 4 Dec 2018 10:44:34 +0900 Subject: change with wm event --- app/main.cpp | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/app/main.cpp b/app/main.cpp index aff9999..4faf42e 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -36,6 +36,8 @@ int main(int argc, char* argv[]) { // return app.exec(); QString role = QString("Video"); + bool isVisible = false; + bool isRestrict = false; QGuiApplication app(argc, argv); app.setApplicationName("VideoPlayer"); @@ -122,20 +124,40 @@ int main(int argc, char* argv[]) { } }); + qwm->set_event_handler( + QLibWindowmanager::Event_Visible, + [&isVisible](json_object* object) { + qDebug() << "Surface Video got Event_Visible!"; + isVisible = true; + }); + + qwm->set_event_handler( + QLibWindowmanager::Event_Invisible, + [&isVisible](json_object* object) { + qDebug() << "Surface Video got Event_Invisible!"; + isVisible = true; + }); + // Set the event handler for Event_Restriction which will allocate or // release restriction area for homescreen qwm->set_event_handler( - QLibWindowmanager::Event_LightstatusBrakeOff, - [hs, &area](json_object* object) { - qDebug() << "Event_LightstatusBrakeOff!"; - hs->allocateRestriction(area.toStdString().c_str()); + QLibWindowmanager::Event_CarRun, + [hs, &area, &isVisible, &isRestrict](json_object* object) { + qDebug() << "Surface Video got Event_CarRun!"; + if(isVisible){ + hs->allocateRestriction(area.toStdString().c_str()); + isRestrict = true; + } }); qwm->set_event_handler( - QLibWindowmanager::Event_LightstatusBrakeOn, - [hs, &area](json_object* object) { - qDebug() << "Event_LightstatusBrakeOn!"; - hs->releaseRestriction(area.toStdString().c_str()); + QLibWindowmanager::Event_CarStop, + [hs, &area, &isRestrict](json_object* object) { + qDebug() << "Surface Video got Event_CarStop!"; + if(isRestrict){ + hs->releaseRestriction(area.toStdString().c_str()); + isRestrict = false; + } }); QQuickWindow* window = qobject_cast(root); -- cgit 1.2.3-korg