return ret;
}
-string api_client_attach_service_surface(const char* appid, const char* dest, const char* service_surface)
+string WindowManager::api_client_attach_service_surface
+ (const char* appid, const char* dest, const char* service_surface)
{
- string uuid = "", s_dest;
- s_dest = dest;
- // uuid = generate_uuid_randam());
+ 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;
}
- //string uuid = client->attachServiceSurface(appid);
+ uuid = client->attachTmpServiceSurface(appid, service_surface);
+ this->tmp_services.emplace_back(TmpService{appid, dest, service_surface, uuid});
+ return uuid;
}
-
result<json_object *> WindowManager::api_get_display_info()
{
Screen screen = this->lc->getScreenInfo();
*/
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;
}
}
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())
{
- client->addSurface(surface_id);
- this->id_alloc.register_name_id(client->role(), surface_id);
+ // 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
{
- /*
- * Store tmp surface and appid for application
- * who requests setRole after creating shell surface
- */
- this->tmp_surface2app.emplace(surface_id, TmpClient{appid, ppid});
+ // 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});
+ }
}
}
}