Improve window manager
[apps/agl-service-windowmanager-2017.git] / src / window_manager.hpp
index c4ad0f5..18182b2 100644 (file)
@@ -66,7 +66,6 @@ extern const char kKeyIds[];
 struct id_allocator
 {
     unsigned next = 1;
-
     // Surfaces that where requested but not yet created
     std::unordered_map<unsigned, std::string> id2name;
     std::unordered_map<std::string, unsigned> name2id;
@@ -218,26 +217,27 @@ class WindowManager
     result<int> api_request_surface(char const *appid, char const *role);
     char const *api_request_surface(char const *appid, char const *role, char const *ivi_id);
     bool api_set_role(char const *appid, char const *role);
-    void api_activate_surface(char const *appid, char const *role, char const *drawing_area, const reply_func &reply);
+    void api_activate_window(char const *appid, char const *role, char const *drawing_area, const reply_func &reply);
     void api_activate_surface_for_slave(char const *appid, char const *drawing_name,
                                         char const *drawing_area, const reply_func &reply);
     void api_activate_surface_to_master(char const *appid, char const *drawing_name,
                                         char const *drawing_area, const reply_func &reply);
-    void api_deactivate_surface(char const *appid, char const *role, const reply_func &reply);
+    void api_deactivate_window(char const *appid, char const *role, const reply_func &reply);
     void api_deactivate_surface_for_slave(char const *appid, char const *drawing_name,
                                           const reply_func &reply);
     void api_deactivate_surface_to_master(char const *appid, char const *drawing_name,
                                           const reply_func &reply);
     void api_enddraw(char const *appid, char const *role);
+    int  api_subscribe(afb_req req, int event_id);
     void api_enddraw_for_remote(char const *appid, char const *drawing_name);
     bool api_client_set_render_order(const char *appid, const std::vector<std::string> &render_order);
     std::string api_client_attach_service_surface(const char* appid, const char* dest, const char* service_surface);
     result<json_object *> api_get_display_info();
     result<json_object *> api_get_area_info(char const *role);
     result<json_object *> api_get_car_info(char const *label);
-    void send_event(char const *evname);
-    void send_event(char const *evname, char const *label);
-    void send_event(char const *evname, char const *label, char const *area, int x, int y, int w, int h);
+    void send_event(const std::string& evname);
+    void send_event(const std::string& evname, const std::string& role);
+    void send_event(const std::string& evname, const std::string& role, const std::string& area, int x, int y, int w, int h);
 
     // Events from the compositor we are interested in
     void surface_created(unsigned pid, unsigned surface_id);
@@ -257,37 +257,18 @@ class WindowManager
     std::string searchApp(unsigned pid, unsigned ppid, unsigned surface, json_object* resp);
     void storeSurface(const std::string& appid, unsigned ppid, unsigned surface);
 
-    const std::vector<const char *> kListEventName{
-        "active",
-        "inactive",
-        "visible",
-        "invisible",
-        "syncDraw",
-        "flushDraw",
-        "screenUpdated",
-        "headlampOff",
-        "headlampOn",
-        "parkingBrakeOff",
-        "parkingBrakeOn",
-        "lightstatusBrakeOff",
-        "lightstatusBrakeOn",
-        "carStop",
-        "carRun",
-        "error"};
-    std::map<const char *, struct afb_event> map_afb_event;
-
     WMConnection wmcon;
 
   private:
     // WM Events to clients
-    void emit_activated(char const *label);
-    void emit_deactivated(char const *label);
-    void emit_syncdraw(char const *label, char const *area, int x, int y, int w, int h);
+    void emit_activated(const std::string& role);
+    void emit_deactivated(const std::string& role);
+    void emit_syncdraw(const std::string& role, char const *area, int x, int y, int w, int h);
     void emit_syncdraw(const std::string &role, const std::string &area);
-    void emit_flushdraw(char const *label);
-    void emit_visible(char const *label, bool is_visible);
-    void emit_invisible(char const *label);
-    void emit_visible(char const *label);
+    void emit_flushdraw(const std::string& role);
+    void emit_visible(const std::string& role, bool is_visible);
+    void emit_invisible(const std::string& role);
+    void emit_visible(const std::string& role);
     void emitHeadlampOff();
     void emitHeadlampOn();
     void emitParkingBrakeOff();
@@ -322,6 +303,7 @@ class WindowManager
     const char *check_surface_exist(const char *role);
 
   private:
+    std::map<std::string, struct afb_event> map_afb_event;
     std::unordered_map<std::string, std::string> roleold2new;
     std::unordered_map<std::string, std::string> rolenew2old;
     std::shared_ptr<LayerControl> lc;
@@ -330,12 +312,10 @@ class WindowManager
     CarInfo crr_car_info;
 
     PMWrapper pmw;
+    rect_map area_info;
+    struct id_allocator id_alloc;
 
     // ID allocation and proxy methods for lookup
-    struct id_allocator id_alloc;
-    // Surface are info (x, y, w, h)
-    rect_map area_info;
-    // FOR CES DEMO
     std::unordered_map<unsigned, struct TmpClient> tmp_surface2app;
     std::vector<struct TmpService> tmp_services;
     static const char* kDefaultOldRolesConfig;