Update wm_client
[apps/agl-service-windowmanager.git] / src / wm_client.cpp
index 4aecbf4..3bc2d31 100644 (file)
@@ -71,6 +71,23 @@ WMClient::WMClient(const string &appid, const string &role)
     }
 }
 
+WMClient::WMClient(const string &appid, unsigned layer,
+    const string& layer_name, unsigned surface, const string &role)
+    : id(appid), layer(layer), wm_layer_name(layer_name),
+      role2surface(0)
+{
+    role2surface[role] = surface;
+    for (auto x : kWMEvents)
+    {
+#if GTEST_ENABLED
+        string ev = x;
+#else
+        afb_event ev = afb_daemon_make_event(x.c_str());
+#endif
+        evname2afb_event[x] = ev;
+    }
+}
+
 string WMClient::appID() const
 {
     return this->id;
@@ -97,6 +114,11 @@ std::string WMClient::role(unsigned surface) const
     return std::string("");
 }
 
+string WMClient::role() const
+{
+    return this->main_role;
+}
+
 unsigned WMClient::layerID() const
 {
     return this->layer;
@@ -114,23 +136,13 @@ const string& WMClient::getWMLayerName()
 
 void WMClient::setRole(const string& role)
 {
+    this->role_list.clear();
     this->role_list.push_back(role);
 }
 
-/**
- * Set layerID the client belongs to
- *
- * This function set layerID the client belongs to.
- * But this function may not used because the layer should be fixed at constructor.
- * So this function will be used to change layer by some reasons.
- *
- * @param     unsigned[in] layerID
- * @return    None
- * @attention WMClient can't have multiple layer
- */
-void WMClient::registerLayer(unsigned layer)
+void WMClient::appendRole(const string& role)
 {
-    this->layer = layer;
+    this->role_list.push_back(role);
 }
 
 /**
@@ -160,6 +172,11 @@ bool WMClient::addSurface(const string &role, unsigned surface)
 bool WMClient::removeSurfaceIfExist(unsigned surface)
 {
     bool ret = false;
+    if(surface == this->surface)
+    {
+        this->surface = INVALID_SURFACE_ID;
+        return true;
+    }
     for (auto &x : this->role2surface)
     {
         if (surface == x.second)