Remove floating surfaces when activate surface
[apps/agl-service-windowmanager.git] / src / app.cpp
index 69930a2..64a1835 100644 (file)
@@ -36,7 +36,7 @@
 #include <regex>
 #include <thread>
 
-#include "wm-client.hpp"
+#include "wm_client.hpp"
 
 
 extern "C"
@@ -872,6 +872,11 @@ void App::api_activate_surface(char const *appid, char const *drawing_name, char
 
     auto client = app_list->lookUpClient(id);
 
+    unsigned srfc = client->surfaceID(role);
+    if(srfc != INVALID_SURFACE_ID){
+        // remove floating surface
+        app_list->removeFloatingSurface(client->surfaceID(role));
+    }
     /*
    * Queueing Phase
    */
@@ -1117,6 +1122,10 @@ void App::send_event(char const *evname, char const *label, char const *area,
  */
 void App::surface_created(uint32_t surface_id)
 {
+    // For set role function
+    HMI_DEBUG("wm", "Get surface pid");
+    this->controller->get_surface_properties(surface_id);
+
     auto layer_id = this->layers.get_layer_id(surface_id);
     if (!layer_id)
     {
@@ -1151,6 +1160,12 @@ void App::surface_removed(uint32_t surface_id)
     app_list->removeSurface(surface_id);
 }
 
+void App::surface_properties(unsigned surface_id, unsigned pid)
+{
+    HMI_DEBUG("wm", "get surface properties");
+    this->app_list->addFloatingSurface(surface_id, pid);
+}
+
 void App::emit_activated(char const *label)
 {
     this->send_event(kListEventName[Event_Active], label);
@@ -1305,12 +1320,12 @@ bool App::api_set_role(char const *appid, char const *drawing_name, unsigned pid
     if(0 != pid){
         // search floating surfaceID from pid if pid is designated.
         // It is not good that application request with its pid
-        wm_err = app_list->lookUpFloatingSurface(pid, &surface);
+        wm_err = app_list->popFloatingSurface(pid, &surface);
     }
     else{
         // get floating surface with appid. If WM queries appid from pid,
         // WM can bind surface and role with appid(not implemented yet)
-        //wm_err = app_list->lookUpFloatingSurface(id);
+        //wm_err = app_list->popFloatingSurface(id);
     }
     if(wm_err != WMError::SUCCESS){
         HMI_ERROR("wm", "No floating surface for app: %s", id.c_str());
@@ -1561,6 +1576,11 @@ void controller_hooks::surface_removed(uint32_t surface_id)
     this->app->surface_removed(surface_id);
 }
 
+void controller_hooks::surface_properties(uint32_t surface_id, uint32_t pid)
+{
+    this->app->surface_properties(surface_id, pid);
+}
+
 void controller_hooks::surface_visibility(uint32_t /*surface_id*/,
                                           uint32_t /*v*/) {}