+ /* This is window manager test */
+ std::string token = secret.toStdString();
+
+ if(qwm->init(port,token.c_str()) != 0){
+ exit(EXIT_FAILURE);
+ }
+
+ if (qwm->requestSurface(myname.c_str()) != 0) {
+ exit(EXIT_FAILURE);
+ }
+
+ // prepare to use homescreen
+ hs->init(port, token.c_str());
+
+ hs->set_event_handler(LibHomeScreen::Event_TapShortcut, [qwm](json_object *object){
+ const char *appname = json_object_get_string(
+ json_object_object_get(object, "application_name"));
+ if(myname == appname)
+ {
+ qDebug("[HS]mediaplayer: activateSurface\n");
+ qwm->activateSurface(myname.c_str());
+ }
+ });
+
+ // prepare to use soundmangaer
+ smw = new QLibSoundmanager();
+ smw->init(port, secret);
+ engine.rootContext()->setContextProperty("smw",smw);
+
+ qwm->set_event_handler(QLibWindowmanager::Event_SyncDraw, [smw, qwm](json_object *object) {
+ fprintf(stderr, "[WM]Surface got syncDraw!\n");
+ qwm->endDraw(myname.c_str());
+ // Something to to if needed
+ });
+ qwm->set_event_handler(QLibWindowmanager::Event_FlushDraw, [smw, &engine](json_object *object) {
+ fprintf(stderr, "[WM]Surface got FlushDraw!\n");
+ // Something to to if needed
+ QObject *root = engine.rootObjects().first();
+ int sourceID = root->property("sourceID").toInt();
+ smw->connect(sourceID, "default");
+ });
+ }