Change size (0, 0) if layer turns invisible
[apps/agl-service-windowmanager.git] / src / wm_layer_control.cpp
index 1d591f0..0632085 100644 (file)
@@ -23,7 +23,7 @@
 
 #define LC_AREA_PATH "/etc/areas.db"
 #define LC_LAYER_SETTING_PATH "/etc/layers_setting.json"
-#define LC_DEFAULT_AREA "normal.full"
+#define LC_DEFAULT_AREA "fullscreen"
 
 using std::string;
 using std::vector;
@@ -122,7 +122,7 @@ void LayerControl::createNewLayer(unsigned id)
     HMI_INFO("create new ID :%d", id);
     struct rect rct = this->area2size[LC_DEFAULT_AREA];
     ilm_layerCreateWithDimension(&id, rct.w, rct.h);
-    ilm_layerSetSourceRectangle(id, rct.x, rct.y, rct.w, rct.h);
+    //ilm_layerSetSourceRectangle(id, rct.x, rct.y, rct.w, rct.h);
     //ilm_layerSetDestinationRectangle(id, rct.x, rct.y, rct.w, rct.h);
     ilm_layerSetOpacity(id, 1.0);
     ilm_layerSetVisibility(id, ILM_FALSE);
@@ -406,7 +406,6 @@ void LayerControl::dispatchCreateEvent(ilmObjectType object, unsigned id, bool c
                 return;
             this->cb.surfaceCreated(sp.creatorPid, id);
             ilm_surfaceAddNotification(id, surfaceCallback_static);
-            ilm_surfaceSetSourceRectangle(id, 0, 0, sp.origSourceWidth, sp.origSourceHeight);
             ilm_surfaceSetVisibility(id, ILM_TRUE);
         }
         else
@@ -463,6 +462,9 @@ void LayerControl::dispatchPropertyChangeEvent(unsigned id,
     }
     if (ILM_NOTIFICATION_CONFIGURED & mask)
     {
+        HMI_DEBUG("surface %d available", id);
+        ilm_surfaceSetSourceRectangle(id, 0, 0, sprop->origSourceWidth, sprop->origSourceHeight);
+        ilm_surfaceSetDestinationRectangle(id, 0, 0, sprop->origSourceWidth, sprop->origSourceHeight);
         /* qDebug("ILM_NOTIFICATION_CONFIGURED");
         qDebug("  surfaceProperties %d", surface);
         qDebug("    surfaceProperties.origSourceWidth: %d", surfaceProperties->origSourceWidth);
@@ -557,17 +559,19 @@ WMError LayerControl::makeVisible(const shared_ptr<WMClient> client)
     // Don't check here the client is not nullptr
     unsigned layer = client->layerID();
 
-    for(auto& wm_layer : this->wm_layers)
+    ilm_layerSetVisibility(layer, ILM_TRUE);
+
+    /* for(auto& wm_layer : this->wm_layers)
     {
         if(wm_layer->hasLayerID(layer))
         {
             LayerState ls = wm_layer->getLayerState();
             ls.addLayer(layer);;
         }
-    }
+    } */
 
     // Move foreground from back ground layer
-    for(auto& wm_layer : this->wm_layers)
+    /* for(auto& wm_layer : this->wm_layers)
     {
         if(wm_layer->layerName() == "BackGroundLayer")
         {
@@ -578,7 +582,7 @@ WMError LayerControl::makeVisible(const shared_ptr<WMClient> client)
             }
             break;
         }
-    }
+    } */
 
     return ret;
 }
@@ -586,32 +590,75 @@ WMError LayerControl::makeVisible(const shared_ptr<WMClient> client)
 WMError LayerControl::makeInvisible(const shared_ptr<WMClient> client)
 {
     WMError ret = WMError::SUCCESS;
-    // Don't check here the client is not nullptr
-    unsigned layer = client->layerID();
+    unsigned layer = client->layerID(); // Don't check here the client is not nullptr
+
+    /* bool mv_ok = this->mvBackGround(client);
+
+    if(!mv_ok)
+    {
+        ilm_layerSetVisibility(layer, ILM_FALSE);
+    } */
+
+    ilm_layerSetDestinationRectangle(layer, 0, 0, 0, 0);
 
-    for(auto& wm_layer : this->wm_layers)
+    /* for(auto& wm_layer : this->wm_layers)
     {
         if(wm_layer->hasLayerID(layer))
         {
             LayerState ls = wm_layer->getLayerState();
             ls.removeLayer(layer);;
         }
-    }
+    } */
 
-    // Move foreground from back ground layer
-    for(auto& wm_layer : this->wm_layers)
+
+
+    return ret;
+}
+
+/* bool LayerControl::mvBackGround(const shared_ptr<WMClient> client)
+{
+    bool ret = false;
+
+    // Move background from foreground layer
+    auto bg = this->getWMLayer("BackGroundLayer");
+    if(bg != nullptr)
     {
-        if(wm_layer->layerName() == "BackGroundLayer")
+        unsigned layer = client->layerID();
+        if(bg->hasRole(client->role()))
         {
-            if(wm_layer->hasRole(client->role()))
-            {
-                LayerState ls = wm_layer->getLayerState();
-                ls.addLayer(layer);
-            }
-            break;
+            LayerState bg_ls = bg->getLayerState();
+            bg_ls.addLayer(layer);
+            auto wm_layer = this->getWMLayer(layer);
+            LayerState ls = wm_layer->getLayerState();
+            ls.removeLayer(layer);
         }
+        ret = true;
     }
+    return ret;
+}
 
+bool LayerControl::mvForeGround(const shared_ptr<WMClient> client)
+{
+    bool ret = false;
+
+    // Move foreground from foreground layer
+    auto bg = this->getWMLayer("BackGroundLayer");
+    if(bg != nullptr)
+    {
+        unsigned layer = client->layerID();
+        if(bg->hasRole(client->role()))
+        {
+            LayerState bg_ls = bg->getLayerState();
+            bg_ls.removeLayer(layer);
+            auto wm_layer = this->getWMLayer(layer);
+            LayerState ls = wm_layer->getLayerState();
+            ls.addLayer(layer);
+        }
+        ret = true;
+    }
     return ret;
 }
+
+*/
+
 } // namespace wm
\ No newline at end of file