aboutsummaryrefslogtreecommitdiffstats
path: root/src/applist.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/applist.cpp')
-rw-r--r--src/applist.cpp53
1 files changed, 34 insertions, 19 deletions
diff --git a/src/applist.cpp b/src/applist.cpp
index 06c1d86..7249130 100644
--- a/src/applist.cpp
+++ b/src/applist.cpp
@@ -62,9 +62,13 @@ bool AppList::contains(const string &appid) const
void AppList::removeSurface(unsigned surface_id){
// This function may be very slow
+ this->clientDump();
+ for (int i = 0; i < 1000; i++)
+ ;
bool ret = false;
for (auto &x : this->app2client)
{
+ HMI_DEBUG("wm", "app: %s", x.second->appID());
ret = x.second->removeSurfaceIfExist(surface_id);
if(ret){
HMI_DEBUG("wm", "remove surface %d from Client %s finish", surface_id, x.second->appID().c_str());
@@ -98,16 +102,18 @@ WMError AppList::popFloatingSurface(unsigned pid, unsigned *surface)
{
WMError ret = WMError::NO_ENTRY;
- for (auto itr = this->floating_surfaces.begin(); itr != this->floating_surfaces.end(); ++itr)
- {
- if(pid == itr->pid){
- *surface = itr->surface_id;
- itr = this->floating_surfaces.erase(itr);
- ret = WMError::SUCCESS;
- HMI_DEBUG("wm", "Erase surface %d", *surface);
- break;
- }
- }
+ auto rmv_begin = 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;
+ }
+ });
+ this->floating_surfaces.erase(rmv_begin, this->floating_surfaces.end());
return ret;
}
@@ -125,19 +131,17 @@ void AppList::addFloatingSurface(unsigned surface, unsigned pid)
{
struct FloatingSurface fsurface{surface, pid};
this->floating_surfaces.push_back(fsurface);
+ this->dumpFloatingSurfaces();
}
void AppList::removeFloatingSurface(unsigned surface)
{
- for (auto itr = this->floating_surfaces.begin(); itr != this->floating_surfaces.end(); ++itr)
- {
- if (surface == itr->surface_id)
- {
- HMI_DEBUG("wm", "Erase surface %d", itr->surface_id);
- itr = this->floating_surfaces.erase(itr);
- break;
- }
- }
+ this->dumpFloatingSurfaces();
+ auto rmv_begin = std::remove_if(this->floating_surfaces.begin(), this->floating_surfaces.end(),
+ [surface](FloatingSurface x) {
+ return x.surface_id == surface;
+ });
+ this->floating_surfaces.erase(rmv_begin, this->floating_surfaces.end());
}
WMError AppList::appendRole(const std::string &id, const std::string &role, unsigned surface)
@@ -368,4 +372,15 @@ void AppList::reqDump()
}
DUMP("======= req dump end =====\n");
}
+
+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 \ No newline at end of file