Enable to get area size from area name
authorKazumasa Mitsunari <knimitz@witz-inc.co.jp>
Sun, 17 Jun 2018 09:23:32 +0000 (18:23 +0900)
committerKazumasa Mitsunari <knimitz@witz-inc.co.jp>
Sun, 17 Jun 2018 09:36:20 +0000 (18:36 +0900)
Change-Id: I79b45c5abd4d0ef9bf74d03fb99536108ea3ea40
Signed-off-by: Kazumasa Mitsunari <knimitz@witz-inc.co.jp>
src/app.cpp
src/layers.cpp
src/layers.hpp

index 2482d37..2d82e95 100644 (file)
@@ -314,6 +314,8 @@ int App::init_layers()
 
     this->layout_commit();
 
+    this->layers.setupArea(o->width, o->height);
+
     return 0;
 }
 
@@ -1255,10 +1257,10 @@ void App::emit_syncdraw(char const *label, char const *area, int x, int y, int w
 
 void App::emit_syncdraw(const std::string &role, const std::string &area)
 {
-    int x = 0, y = 0, w = 0, h = 0;
+    compositor::rect rect = this->layers.getAreaSize(area);
     //this->lm_get_area_info(area, &x, &y, &w, &h);
     this->send_event(kListEventName[Event_SyncDraw],
-        role.c_str(), area.c_str(), x, y, w, h);
+        role.c_str(), area.c_str(), rect.x, rect.y, rect.w, rect.h);
 }
 
 void App::emit_flushdraw(char const *label)
index af8d89e..0431fee 100644 (file)
@@ -194,4 +194,57 @@ json layer_map::to_json() const
       return j;
 }
 
+void layer_map::setupArea(int output_w, int output_h)
+{
+    compositor::rect rct;
+    // setup normal.full
+    std::string area = "normal.full";
+    std::string role = "Fallback";
+    auto l_id = this->get_layer_id(role);
+    auto l = this->get_layer(*l_id);
+    rct = l->rect;
+    if(rct.w < 0)
+        rct.w = output_w + 1 + rct.w;
+    if(rct.h < 0)
+        rct.h = output_h + 1 + rct.h;
+    this->area2size[area] = rct;
+
+    // setup split.main
+    area = "split.main";
+    rct.h = rct.h / 2;
+    this->area2size[area] = rct;
+
+    // setup split.sub
+    area = "split.sub";
+    rct.y = rct.y + rct.h;
+    this->area2size[area] = rct;
+
+    // setup homescreen
+    area = "fullscreen";
+    role = "HomeScreen";
+    rct = compositor::full_rect;
+    if (rct.w <= 0)
+        rct.w = output_w + rct.w;
+    if (rct.h <= 0)
+        rct.h = output_h + rct.h;
+    this->area2size[area] = rct;
+
+    // setup onscreen
+    area = "onscreen";
+    role = "OnScreen";
+    auto ons_id = this->get_layer_id(role);
+    auto l_ons = this->get_layer(*ons_id);
+    rct = l_ons->rect;
+    if (rct.w < 0)
+        rct.w = output_w + 1 + rct.w;
+    if (rct.h < 0)
+        rct.h = output_h + 1 + rct.h;
+    this->area2size[area] = rct;
+}
+
+compositor::rect layer_map::getAreaSize(const std::string &area)
+{
+    return area2size[area];
+}
+
 } // namespace wm
index 5479c3a..c01d45e 100644 (file)
@@ -117,6 +117,11 @@ struct layer_map
     }
 
     json to_json() const;
+    void setupArea(int output_w, int output_h);
+    compositor::rect getAreaSize(const std::string &area);
+
+  private:
+    std::unordered_map<std::string, compositor::rect> area2size;
 };
 
 struct result<struct layer_map> to_layer_map(nlohmann::json const &j);