X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Frunxdg.cpp;h=e4ec1c932d8b6d0fea8cc2e24942cee80da0edab;hb=f7ac2f42c22b8324cc30b50dc255f85df406765a;hp=3ff942c1bdd196c2ef7372e21cce12598c79b4bd;hpb=7508882ed8fc512d608585147e2520a9341401df;p=staging%2Fxdg-launcher.git diff --git a/src/runxdg.cpp b/src/runxdg.cpp index 3ff942c..e4ec1c9 100644 --- a/src/runxdg.cpp +++ b/src/runxdg.cpp @@ -35,6 +35,7 @@ #include "runxdg.hpp" #define RUNXDG_CONFIG "runxdg.toml" +#define AREA_NORMAL_FULL "normal.full" void fatal(const char* format, ...) { @@ -83,7 +84,8 @@ void RunXDG::notify_ivi_control_cb (ilmObjectType object, t_ilm_uint id, m_launcher->register_surfpid(surf_pid); if (m_launcher->m_rid && surf_pid == m_launcher->find_surfpid_by_rid(m_launcher->m_rid)) { - setup_surface(id); + m_ivi_id = id; + setup_surface(); } m_surfaces[surf_pid] = id; } else if (object == ILM_LAYER) { @@ -279,29 +281,30 @@ int RunXDG::init_wm (void) return -1; } - std::function< void(json_object*) > h_active = [](json_object* object) { + std::function< void(json_object*) > h_active = [this](json_object* object) { AGL_DEBUG("Got Event_Active"); }; - std::function< void(json_object*) > h_inactive = [](json_object* object) { + std::function< void(json_object*) > h_inactive = [this](json_object* object) { AGL_DEBUG("Got Event_Inactive"); }; - std::function< void(json_object*) > h_visible = [](json_object* object) { + std::function< void(json_object*) > h_visible = [this](json_object* object) { AGL_DEBUG("Got Event_Visible"); + t_ilm_surface s_ids[1] = { this->m_ivi_id }; + ilm_setInputFocus(s_ids, 1, ILM_INPUT_DEVICE_KEYBOARD, ILM_TRUE); }; - std::function< void(json_object*) > h_invisible = [](json_object* object) { + std::function< void(json_object*) > h_invisible = [this](json_object* object) { AGL_DEBUG("Got Event_Invisible"); + t_ilm_surface s_ids[1] = { this->m_ivi_id }; + ilm_setInputFocus(s_ids, 1, ILM_INPUT_DEVICE_KEYBOARD, ILM_FALSE); }; std::function< void(json_object*) > h_syncdraw = [this](json_object* object) { AGL_DEBUG("Got Event_SyncDraw"); - json_object* obj = json_object_new_object(); - json_object_object_add(obj, this->m_wm->kKeyDrawingName, - json_object_new_string(this->m_role.c_str())); - this->m_wm->endDraw(obj); + this->m_wm->endDraw(this->m_role.c_str()); }; std::function< void(json_object*) > h_flushdraw= [](json_object* object) { @@ -327,28 +330,10 @@ int RunXDG::init_hs (void) } std::function< void(json_object*) > handler = [this] (json_object* object) { - json_object *val; - - if (json_object_object_get_ex(object, "application_name", &val)) { - const char *name = json_object_get_string(val); - - AGL_DEBUG("Event_TapShortcut <%s>", name); - - if (strcmp(name, this->m_role.c_str()) == 0) { - // check app exist and re-launch if needed - AGL_DEBUG("Activesurface %s ", this->m_role.c_str()); - - json_object *obj = json_object_new_object(); - json_object_object_add(obj, this->m_wm->kKeyDrawingName, - json_object_new_string(this->m_role.c_str())); - json_object_object_add(obj, this->m_wm->kKeyDrawingArea, - json_object_new_string("normal.full")); - - this->m_wm->activateSurface(obj); - } - } + AGL_DEBUG("Activesurface %s ", this->m_role.c_str()); + this->m_wm->activateWindow(this->m_role.c_str(), AREA_NORMAL_FULL); }; - m_hs->set_event_handler(LibHomeScreen::Event_TapShortcut, handler); + m_hs->set_event_handler(LibHomeScreen::Event_ShowWindow, handler); std::function< void(json_object*) > h_default= [](json_object* object) { const char *j_str = json_object_to_json_string(object); @@ -471,31 +456,19 @@ RunXDG::RunXDG (int port, const char* token, const char* id) AGL_DEBUG("RunXDG created."); } -void RunXDG::setup_surface (int id) +void RunXDG::setup_surface (void) { - std::string sid = std::to_string(id); + std::string sid = std::to_string(m_ivi_id); // This surface is mine, register pair app_name and ivi id. - json_object *obj = json_object_new_object(); - json_object_object_add(obj, m_wm->kKeyDrawingName, - json_object_new_string(m_role.c_str())); - json_object_object_add(obj, m_wm->kKeyIviId, - json_object_new_string(sid.c_str())); - - AGL_DEBUG("requestSurfaceXDG(%s,%s)", m_role.c_str(), sid.c_str()); - m_wm->requestSurfaceXDG(obj); + AGL_DEBUG("requestSurfaceXDG(%s,%d)", m_role.c_str(), m_ivi_id); + m_wm->requestSurfaceXDG(this->m_role.c_str(), (unsigned int)m_ivi_id); if (m_pending_create) { // Recovering 1st time tap_shortcut is dropped because // the application has not been run yet (1st time launch) m_pending_create = false; - - json_object *obj = json_object_new_object(); - json_object_object_add(obj, m_wm->kKeyDrawingName, - json_object_new_string(m_role.c_str())); - json_object_object_add(obj, m_wm->kKeyDrawingArea, - json_object_new_string("normal.full")); - m_wm->activateSurface(obj); + m_wm->activateWindow(this->m_role.c_str(), AREA_NORMAL_FULL); } } @@ -588,6 +561,8 @@ void RunXDG::start (void) AGL_DEBUG("waiting for notification: surafce created"); m_pending_create = true; + ilm_commitChanges(); + // in case, target app has already run if (m_launcher->m_rid) { pid_t surf_pid = m_launcher->find_surfpid_by_rid(m_launcher->m_rid); @@ -599,10 +574,13 @@ void RunXDG::start (void) int id = itr->second; AGL_DEBUG("surface %d for <%s> already exists", id, m_role.c_str()); - setup_surface(id); + m_ivi_id = id; + setup_surface(); } } } + + ilm_commitChanges(); m_launcher->loop(e_flag); }