X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fapplist.cpp;h=159b30db25d38bfcef78deda20bcf185190367dc;hb=5c74a62af029d1138416a76a6d44d1711ce97ff6;hp=a5ae9f000e56bfaa13632921f04fe85d391dbb8f;hpb=847dde9621cef9b9a44eda95c63c0fe3f528468d;p=apps%2Fagl-service-windowmanager-2017.git diff --git a/src/applist.cpp b/src/applist.cpp index a5ae9f0..159b30d 100644 --- a/src/applist.cpp +++ b/src/applist.cpp @@ -65,7 +65,7 @@ AppList::~AppList() {} * @attention This function should be called once for the app * Caller should take care not to be called more than once. */ -void AppList::addClient(const std::string &appid, unsigned layer, unsigned surface, const std::string &role) +void AppList::addClient(const string &appid, unsigned layer, unsigned surface, const string &role) { std::lock_guard lock(this->mtx); shared_ptr client = std::make_shared(appid, layer, surface, role); @@ -164,7 +164,7 @@ string AppList::getAppID(unsigned surface, const string& role, bool* found) cons *found = false; for (const auto &x : this->app2client) { - if(x.second->surfaceID(role) == surface){ + if(x.second->surfaceID() == surface){ *found = true; return x.second->appID(); } @@ -172,6 +172,76 @@ string AppList::getAppID(unsigned surface, const string& role, bool* found) cons return string(""); } +WMError AppList::popFloatingSurface(unsigned pid, unsigned *surface) +{ + WMError ret = WMError::NO_ENTRY; + + auto fwd_itr = std::remove_if(this->floating_surfaces.begin(), this->floating_surfaces.end(), + [pid, surface, &ret](FloatingSurface x) { + if(pid == x.pid){ + *surface = x.surface_id; + ret = WMError::SUCCESS; + return true; + } + else{ + return false; + } + }); + if (fwd_itr != this->floating_surfaces.cend()) + { + HMI_INFO("wm", "pop floating surface: %d", *surface); + } + this->floating_surfaces.erase(fwd_itr, this->floating_surfaces.end()); + return ret; +} + +// =================== Floating(Temporary) surface/client API =================== + +WMError AppList::popFloatingSurface(const string &appid, unsigned *surface) +{ + HMI_ERROR("wm", "This function is not implemented"); + return WMError::SUCCESS; +} + +void AppList::addFloatingClient(const string &appid, unsigned layer, const string &role) +{ +} + +void AppList::addFloatingSurface(const string &appid, unsigned surface, unsigned pid) +{ + struct FloatingSurface fsurface{appid, surface, pid}; + this->floating_surfaces.push_back(fsurface); + this->dumpFloatingSurfaces(); +} + +void AppList::removeFloatingSurface(unsigned surface) +{ + this->dumpFloatingSurfaces(); + auto fwd_itr = std::remove_if( + this->floating_surfaces.begin(), this->floating_surfaces.end(), + [surface](FloatingSurface x) { + return x.surface_id == surface; + }); + if(fwd_itr != this->floating_surfaces.cend()){ + HMI_INFO("wm", "remove floating surface: %d", surface); + } + this->floating_surfaces.erase(fwd_itr, this->floating_surfaces.end()); +} + +WMError AppList::appendRole(const string &id, const string &role, unsigned surface) +{ + WMError wm_err = WMError::NO_ENTRY; + HMI_ERROR("wm", "This function is disabled"); + /* if (this->contains(id)) + { + auto x = this->lookUpClient(id); + x->addSurface(role, surface); + wm_err = WMError::SUCCESS; + } */ + return wm_err; +} + + // =================== Request Date container API =================== /** @@ -523,4 +593,15 @@ void AppList::reqDump() } DUMP("======= req dump end ====="); } + +void AppList::dumpFloatingSurfaces() +{ + DUMP("======= floating surface dump ====="); + for (const auto &x : this->floating_surfaces) + { + DUMP("surface : %d, pid : %d", x.surface_id, x.pid); + } + DUMP("======= floating surface dump end =====\n"); +} + } // namespace wm