X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fwindow_manager.cpp;h=f0258f7775ee970bc36b61bda63e662e5c650672;hb=d2c062959c55c61a4e350f6df480d46d2a8d769c;hp=4db577d1272241c7d3ef972f795d9187c389e517;hpb=4d67209654fe8de3407b513800471fc48c4865fc;p=apps%2Fagl-service-windowmanager.git diff --git a/src/window_manager.cpp b/src/window_manager.cpp index 4db577d..f0258f7 100644 --- a/src/window_manager.cpp +++ b/src/window_manager.cpp @@ -260,7 +260,7 @@ char const *WindowManager::api_request_surface(char const *appid, char const *dr return nullptr; } -bool WindowManager::api_set_role(char const *appid, char const *drawing_name, unsigned pid) +bool WindowManager::api_set_role(char const *appid, char const *drawing_name) { bool ret = false; @@ -296,13 +296,14 @@ bool WindowManager::api_set_role(char const *appid, char const *drawing_name, un this->rolenew2old[role] = s_role; } - for(auto itr = this->tmp_surface2app.begin(); - itr != this->tmp_surface2app.end() ; ++itr) + // for(auto itr = this->tmp_surface2app.begin(); + // itr != this->tmp_surface2app.end() ; ++itr) + // { + for(auto& x : this->tmp_surface2app) { - // const auto& x : this->tmp_surface2app) - if(itr->second.appid == s_appid) + if(x.second.appid == s_appid) { - unsigned surface = itr->first; + unsigned surface = x.first; auto client = g_app_list.lookUpClient(s_appid); client->addSurface(surface); this->tmp_surface2app.erase(surface); @@ -501,6 +502,33 @@ void WindowManager::api_enddraw(char const *appid, char const *drawing_name) } } +bool WindowManager::api_client_set_render_order(char const* appid, const vector& render_order) +{ + bool ret = false; + string id = appid; + auto client = g_app_list.lookUpClient(id); + if(client) + { + client->setRenderOrder(render_order); + } + return ret; +} + +string WindowManager::api_client_attach_service_surface + (const char* appid, const char* dest, const char* service_surface) +{ + string uuid, s_dest = dest; + auto client = g_app_list.lookUpClient(s_dest); + if(!client) + { + HMI_ERROR("Failed to look up destination [%s]", dest); + return uuid; + } + uuid = client->attachTmpServiceSurface(appid, service_surface); + this->tmp_services.emplace_back(TmpService{appid, dest, service_surface, uuid}); + return uuid; +} + result WindowManager::api_get_display_info() { Screen screen = this->lc->getScreenInfo(); @@ -585,6 +613,7 @@ void WindowManager::send_event(char const *evname, char const *label, char const */ void WindowManager::surface_created(unsigned pid, unsigned surface_id) { + // requestSurface if(this->tmp_surface2app.count(surface_id) != 0) { string appid = this->tmp_surface2app[surface_id].appid; @@ -612,7 +641,7 @@ void WindowManager::surface_created(unsigned pid, unsigned surface_id) unsigned ppid = 0; if(!ifs.fail() && std::getline(ifs, str)) { - std::sscanf(str.data(), "%*d %*s %*c %*d %d", &ppid); + std::sscanf(str.data(), "%*d %*s %*c %d", &ppid); HMI_INFO("Retrieve ppid %d", ppid); } else @@ -656,14 +685,40 @@ void WindowManager::surface_created(unsigned pid, unsigned surface_id) } } json_object_put(response); - auto client = g_app_list.lookUpClient(appid); - if(client != nullptr) + + auto elem = std::find_if(this->tmp_services.begin(), this->tmp_services.end(), + [&appid](TmpService& ts){ + return (ts.dest == appid ); + }); + if(elem == this->tmp_services.end()) + { + // attachApp + auto client = g_app_list.lookUpClient(elem->dest); + if(client == nullptr) + { + return; + } + HMI_INFO("Attach surface %d (service %s) to app %s", surface_id, elem->service.c_str(), elem->dest.c_str()); + client->attachServiceSurface(elem->service, surface_id); + } + else { - client->addSurface(surface_id); - this->id_alloc.register_name_id(client->role(), surface_id); + // setRole + auto client = g_app_list.lookUpClient(appid); + if(client != nullptr) + { + client->addSurface(surface_id); + this->id_alloc.register_name_id(client->role(), surface_id); + } + else + { + /* + * Store tmp surface and appid for application + * who requests setRole after creating shell surface + */ + this->tmp_surface2app.emplace(surface_id, TmpClient{appid, ppid}); + } } - struct TmpClient tmp_cl = {appid, ppid}; - this->tmp_surface2app[surface_id] = tmp_cl; /* Store for requestSurfaceXDG */ } }