aboutsummaryrefslogtreecommitdiffstats
path: root/src/window_manager.hpp
diff options
context:
space:
mode:
authorzheng_wenlong <wenlong_zheng@nexty-ele.com>2018-10-30 14:36:16 +0900
committerzheng_wenlong <wenlong_zheng@nexty-ele.com>2018-10-30 14:36:16 +0900
commitde492ca32c0cc4eb7e090ba33945eb75a21cc14a (patch)
treec81e48f9fa7199afa87a25781599ed6d963989b1 /src/window_manager.hpp
parent3ae8e9b6a7947b91409b112e1a699385627c5945 (diff)
add source for ces2019
Diffstat (limited to 'src/window_manager.hpp')
-rw-r--r--src/window_manager.hpp209
1 files changed, 133 insertions, 76 deletions
diff --git a/src/window_manager.hpp b/src/window_manager.hpp
index 6cbd355..c4ad0f5 100644
--- a/src/window_manager.hpp
+++ b/src/window_manager.hpp
@@ -14,33 +14,27 @@
* limitations under the License.
*/
-#ifndef TMCAGLWM_APP_HPP
-#define TMCAGLWM_APP_HPP
+#ifndef WINDOW_MANAGER_HPP
+#define WINDOW_MANAGER_HPP
#include <atomic>
#include <memory>
#include <unordered_map>
#include <experimental/optional>
-#include "controller_hooks.hpp"
-#include "layers.hpp"
-#include "layout.hpp"
-#include "wayland_ivi_wm.hpp"
+#include "result.hpp"
#include "pm_wrapper.hpp"
-#include "hmi-debug.h"
+#include "util.hpp"
#include "request.hpp"
#include "wm_error.hpp"
-
-struct json_object;
-
-namespace wl
+#include "wm_layer_control.hpp"
+#include "wm_connection.hpp"
+#include "low_can_client.hpp"
+extern "C"
{
-struct display;
+#include <afb/afb-binding.h>
}
-namespace compositor
-{
-struct controller;
-}
+struct json_object;
namespace wm
{
@@ -88,7 +82,7 @@ struct id_allocator
unsigned sid = this->next++;
this->id2name[sid] = name;
this->name2id[name] = sid;
- HMI_DEBUG("wm", "allocated new id %u with name %s", sid, name.c_str());
+ HMI_DEBUG("allocated new id %u with name %s", sid, name.c_str());
return sid;
}
@@ -97,7 +91,7 @@ struct id_allocator
{
this->id2name[sid] = name;
this->name2id[name] = sid;
- HMI_DEBUG("wm", "register id %u with name %s", sid, name.c_str());
+ HMI_DEBUG("register id %u with name %s", sid, name.c_str());
return;
}
@@ -137,10 +131,46 @@ struct id_allocator
}
};
+struct TmpClient
+{
+ std::string appid;
+ unsigned pid;
+};
+
+struct TmpService
+{
+ std::string appid; // Used to search who create service surface
+ std::string dest; // Used to attach service to destination application
+ std::string service;// The name of service surface
+ std::string uuid; // uuid
+ TmpService(const std::string& app, const std::string& dst,
+ const std::string& svc, const std::string& uuid)
+ : appid(app), dest(dst), service(svc), uuid(uuid) {}
+};
+
+struct CarInfo
+{
+ CarInfo()
+ : parking_brake_stt(true),
+ accel_pedal_stt(false),
+ accel_pedal_pos(0.0),
+ running_stt(false),
+ headlamp_stt(false),
+ lightstatus_brake_stt(true)
+ {};
+
+ bool parking_brake_stt;
+ bool accel_pedal_stt;
+ double accel_pedal_pos;
+ bool running_stt;
+ bool headlamp_stt;
+ bool lightstatus_brake_stt;
+};
+
class WindowManager
{
public:
- typedef std::unordered_map<uint32_t, struct compositor::rect> rect_map;
+ typedef std::unordered_map<uint32_t, struct rect> rect_map;
typedef std::function<void(const char *err_msg)> reply_func;
enum EventType
@@ -158,47 +188,24 @@ class WindowManager
Event_ScreenUpdated,
- Event_Error,
-
- Event_Val_Max = Event_Error,
- };
-
- const std::vector<const char *> kListEventName{
- "active",
- "inactive",
- "visible",
- "invisible",
- "syncDraw",
- "flushDraw",
- "screenUpdated",
- "error"};
-
- struct controller_hooks chooks;
+ Event_HeadlampOff,
+ Event_HeadlampOn,
- // This is the one thing, we do not own.
- struct wl::display *display;
+ Event_ParkingBrakeOff,
+ Event_ParkingBrakeOn,
- std::unique_ptr<struct compositor::controller> controller;
- std::vector<std::unique_ptr<struct wl::output>> outputs;
+ Event_LightstatusBrakeOff,
+ Event_LightstatusBrakeOn,
- // track current layouts separately
- layer_map layers;
+ Event_CarStop,
+ Event_CarRun,
- // ID allocation and proxy methods for lookup
- struct id_allocator id_alloc;
-
- // Set by AFB API when wayland events need to be dispatched
- std::atomic<bool> pending_events;
-
- std::map<const char *, struct afb_event> map_afb_event;
-
- // Surface are info (x, y, w, h)
- rect_map area_info;
+ Event_Error,
- // FOR CES DEMO
- std::vector<int> surface_bg;
+ Event_Val_Max = Event_Error,
+ };
- explicit WindowManager(wl::display *d);
+ explicit WindowManager();
~WindowManager() = default;
WindowManager(WindowManager const &) = delete;
@@ -207,41 +214,71 @@ class WindowManager
WindowManager &operator=(WindowManager &&) = delete;
int init();
- int dispatch_pending_events();
- void set_pending_events();
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_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_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);
+ 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);
- void api_ping();
+ 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);
// Events from the compositor we are interested in
- void surface_created(uint32_t surface_id);
- void surface_removed(uint32_t surface_id);
+ void surface_created(unsigned pid, unsigned surface_id);
+ void surface_removed(unsigned surface_id);
void removeClient(const std::string &appid);
void exceptionProcessForTransition();
const char* convertRoleOldToNew(char const *role);
+ void analyzeReceivedEvent(const char *event, struct json_object *object);
+
// Do not use this function
void timerHandler();
void startTransitionWrapper(std::vector<WMAction> &actions);
void processError(WMError error);
+ void processForRemoteRequest(json_object *data);
+ std::string searchApp(unsigned pid, unsigned ppid, unsigned surface, json_object* resp);
+ void storeSurface(const std::string& appid, unsigned ppid, unsigned surface);
- private:
- bool pop_pending_events();
- optional<int> lookup_id(char const *name);
- optional<std::string> lookup_name(int id);
- int init_layers();
- void surface_set_layout(int surface_id, const std::string& area = "");
- void layout_commit();
+ 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);
@@ -251,39 +288,59 @@ class WindowManager
void emit_visible(char const *label, bool is_visible);
void emit_invisible(char const *label);
void emit_visible(char const *label);
+ void emitHeadlampOff();
+ void emitHeadlampOn();
+ void emitParkingBrakeOff();
+ void emitParkingBrakeOn();
+ void emitLightstatusBrakeOff();
+ void emitLightstatusBrakeOn();
+ void emitCarStop();
+ void emitCarRun();
- void activate(int id);
- void deactivate(int id);
WMError setRequest(const std::string &appid, const std::string &role, const std::string &area,
Task task, unsigned *req_num);
- WMError doTransition(unsigned sequence_number);
+ WMError setRequest(Task task, unsigned* req_num);
+ WMError setRequestForSlave(const std::string& appid, const std::string &role,
+ const std::string &area, Task task, unsigned* req_num);
WMError checkPolicy(unsigned req_num);
+ WMError checkPolicyForSlave(unsigned req_num);
WMError startTransition(unsigned req_num);
+ void transitionCarState(TaskCarState task);
WMError doEndDraw(unsigned req_num);
- WMError layoutChange(const WMAction &action);
- WMError visibilityChange(const WMAction &action);
- WMError setSurfaceSize(unsigned surface, const std::string& area);
void emitScreenUpdated(unsigned req_num);
void setTimer();
void stopTimer();
void processNextRequest();
- int loadOldRoleDb();
+ int loadOldRolesConfigFile();
+
+ Task convertCanSignalToCarStateTask(const char *signal_name);
+ void inputCarStateTask(Task task);
const char *check_surface_exist(const char *role);
private:
- std::unordered_map<std::string, struct compositor::rect> area2size;
std::unordered_map<std::string, std::string> roleold2new;
std::unordered_map<std::string, std::string> rolenew2old;
+ std::shared_ptr<LayerControl> lc;
+
+ LowCanClient lcc;
+ CarInfo crr_car_info;
PMWrapper pmw;
- static const char* kDefaultOldRoleDb;
+ // 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;
};
} // namespace wm
-#endif // TMCAGLWM_APP_HPP
+#endif // WINDOW_MANAGER_HPP