Fix the manipulation of surface/layer
authorKazumasa Mitsunari <knimitz@witz-inc.co.jp>
Wed, 12 Sep 2018 04:37:18 +0000 (13:37 +0900)
committerKazumasa Mitsunari <knimitz@witz-inc.co.jp>
Wed, 12 Sep 2018 04:37:18 +0000 (13:37 +0900)
* Set offset when creating new layer
* Set surface size not layer when layoutChange

Change-Id: I335e8afa83d2874076d9138d473ce07399aa2e4b
Signed-off-by: Kazumasa Mitsunari <knimitz@witz-inc.co.jp>
src/wm_layer_control.cpp
src/wm_layer_control.hpp

index 31f6c4f..bb3bfc2 100644 (file)
@@ -63,7 +63,7 @@ LayerControl::LayerControl(const std::string& root)
     // load layers.setting.json
     WMError ret = this->loadLayerSetting(layer_path);
     assert(ret == WMError::SUCCESS);
     // load layers.setting.json
     WMError ret = this->loadLayerSetting(layer_path);
     assert(ret == WMError::SUCCESS);
-    // load area.db
+    // load areas.json
     ret = this->loadAreaDb(area_path);
     assert(ret == WMError::SUCCESS);
 }
     ret = this->loadAreaDb(area_path);
     assert(ret == WMError::SUCCESS);
 }
@@ -106,7 +106,7 @@ WMError LayerControl::init(const LayerControlCallbacks& cb)
 
     if(rc != ILM_SUCCESS) goto lc_init_error;
 
 
     if(rc != ILM_SUCCESS) goto lc_init_error;
 
-    // Register Callback from ILM
+    // Register Callback to Window Manager and from ILM
     this->cb = cb;
     ilm_registerNotification(createCallback_static, this);
 
     this->cb = cb;
     ilm_registerNotification(createCallback_static, this);
 
@@ -124,7 +124,7 @@ void LayerControl::createNewLayer(unsigned 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);
     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_layerSetDestinationRectangle(id, rct.x, rct.y, rct.w, rct.h);
+    ilm_layerSetDestinationRectangle(id, this->offset_x, this->offset_y, rct.w, rct.h);
     ilm_layerSetOpacity(id, 1.0);
     ilm_layerSetVisibility(id, ILM_FALSE);
     ilm_commitChanges();
     ilm_layerSetOpacity(id, 1.0);
     ilm_layerSetVisibility(id, ILM_FALSE);
     ilm_commitChanges();
@@ -175,17 +175,14 @@ struct rect LayerControl::getAreaSize(const std::string& area)
 
 void LayerControl::setupArea(const rectangle& base_rct, double scaling)
 {
 
 void LayerControl::setupArea(const rectangle& base_rct, double scaling)
 {
-    struct rect rct;
     this->scaling = scaling;
     this->scaling = scaling;
-
-    rct = this->area2size["normal.full"];
-    this->area2size["normalfull"] = rct;
-    this->area2size["normal"] = rct;
+    this->offset_x = base_rct.left();
+    this->offset_y = base_rct.top();
 
     for (auto &i : this->area2size)
     {
 
     for (auto &i : this->area2size)
     {
-        i.second.x = base_rct.left() + static_cast<int>(scaling * i.second.x + 0.5);
-        i.second.y = base_rct.top() + static_cast<int>(scaling * i.second.y + 0.5);
+        i.second.x = static_cast<int>(scaling * i.second.x + 0.5);
+        i.second.y = static_cast<int>(scaling * i.second.y + 0.5);
         i.second.w = static_cast<int>(scaling * i.second.w + 0.5);
         i.second.h = static_cast<int>(scaling * i.second.h + 0.5);
 
         i.second.w = static_cast<int>(scaling * i.second.w + 0.5);
         i.second.h = static_cast<int>(scaling * i.second.h + 0.5);
 
@@ -384,17 +381,16 @@ WMError LayerControl::layoutChange(const WMAction& action)
         return WMError::NOT_REGISTERED;
     }
     unsigned layer = action.client->layerID();
         return WMError::NOT_REGISTERED;
     }
     unsigned layer = action.client->layerID();
+    unsigned surface = action.client->surfaceID();
 
 
-    // Layout Manager
-    // WMError ret = this->setLayerSize(layer, action.area);
     auto rect = this->getAreaSize(action.area);
     HMI_DEBUG("Set layout %d, %d, %d, %d",rect.x, rect.y, rect.w, rect.h);
     auto rect = this->getAreaSize(action.area);
     HMI_DEBUG("Set layout %d, %d, %d, %d",rect.x, rect.y, rect.w, rect.h);
-    ilm_layerSetSourceRectangle(layer, 0, 0, rect.w, rect.h);
     ilm_commitChanges();
     ilm_commitChanges();
-    ilm_layerSetDestinationRectangle(layer, rect.x, rect.y, rect.w, rect.h);
+    ilm_surfaceSetDestinationRectangle(surface, rect.x, rect.y, rect.w, rect.h);
     ilm_commitChanges();
     for(auto &wm_layer: this->wm_layers)
     {
     ilm_commitChanges();
     for(auto &wm_layer: this->wm_layers)
     {
+        // Store the state who is assigned to the area
         if(wm_layer->hasLayerID(layer))
         {
             wm_layer->setAreaToState(action.client->appID(), action.area);
         if(wm_layer->hasLayerID(layer))
         {
             wm_layer->setAreaToState(action.client->appID(), action.area);
@@ -503,7 +499,6 @@ void LayerControl::dispatchPropertyChangeEvent(unsigned id,
         HMI_DEBUG("surface %d size %d, %d, %d, %d", id,
             sprop->sourceX, sprop->sourceY, sprop->origSourceWidth, sprop->origSourceHeight);
         ilm_surfaceSetSourceRectangle(id, 0, 0, sprop->origSourceWidth, sprop->origSourceHeight);
         HMI_DEBUG("surface %d size %d, %d, %d, %d", id,
             sprop->sourceX, sprop->sourceY, sprop->origSourceWidth, sprop->origSourceHeight);
         ilm_surfaceSetSourceRectangle(id, 0, 0, sprop->origSourceWidth, sprop->origSourceHeight);
-        ilm_surfaceSetDestinationRectangle(id, 0, 0, sprop->origSourceWidth, sprop->origSourceHeight);
     }
 }
 
     }
 }
 
@@ -511,10 +506,6 @@ void LayerControl::dispatchPropertyChangeEvent(unsigned id,
         struct ilmLayerProperties* lprop,
         t_ilm_notification_mask mask)
 {
         struct ilmLayerProperties* lprop,
         t_ilm_notification_mask mask)
 {
-    /*
-      ILM_NOTIFICATION_CONTENT_AVAILABLE & ILM_NOTIFICATION_CONTENT_REMOVED
-      are not handled here, handled in create/destroy event
-     */
     if (ILM_NOTIFICATION_VISIBILITY & mask)
     {
         HMI_DEBUG("layer %d turns visibility %d", id, lprop->visibility);
     if (ILM_NOTIFICATION_VISIBILITY & mask)
     {
         HMI_DEBUG("layer %d turns visibility %d", id, lprop->visibility);
index 7cccfa0..a458f2f 100644 (file)
@@ -100,6 +100,8 @@ class LayerControl
     unsigned screenID;
     struct ilmScreenProperties screen_prop;
     double scaling;
     unsigned screenID;
     struct ilmScreenProperties screen_prop;
     double scaling;
+    int offset_x;
+    int offset_y;
     LayerControlCallbacks cb;
 };
 
     LayerControlCallbacks cb;
 };