Bug Fix : set source rectangle x, y is not 0
[apps/agl-service-windowmanager.git] / src / app.cpp
index 4cc4b3d..debbcbd 100644 (file)
@@ -1149,6 +1149,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)
     {
@@ -1161,9 +1165,6 @@ void App::surface_created(uint32_t surface_id)
 
     this->controller->layers[*layer_id]->add_surface(surface_id);
     this->layout_commit();
-    // For set role function
-    HMI_DEBUG("wm", "Get surface pid");
-    this->controller->get_surface_properties(surface_id);
 
     // activate the main_surface right away
     /*if (surface_id == static_cast<unsigned>(this->layers.main_surface)) {
@@ -1384,6 +1385,18 @@ bool App::api_set_role(char const *appid, char const *drawing_name, unsigned pid
     // this surface is already created
     HMI_DEBUG("wm", "surface_id is %u, layer_id is %u", surface, *lid);
 
+    const auto &o_layer = this->layers.get_layer(*lid);
+    auto rect = o_layer.value().rect;
+    if(rect.w < 0)
+    {
+        rect.w = this->controller->output_size.w + 1 + rect.w;
+    }
+    if(rect.h < 0)
+    {
+        rect.h = this->controller->output_size.h + 1 + rect.h;
+    }
+    this->controller->surfaces[surface]->set_source_rectangle(0, 0, rect.w, rect.h);
+
     this->controller->layers[*lid]->add_surface(surface);
     this->layout_commit();