summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-06-28 16:17:10 +0900
committerKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-06-28 16:35:32 +0900
commit6373ce04e2d6c6ae77246bcf7560447b3daaed3d (patch)
treef95658ac64f5df813c7abf1b6a4e788f710c6880
parent3e58f01b27b293717ce081ea094294890843eb06 (diff)
Add signal when the displayed application changed
Add new signal "screen_updated" to Window Manager. This is emitted when application size or visibility is changed, the application ids are notified to subscribers. There are some applications such like HomeScreen, which needs the visibility of other applications turns on, so add new event. The key is "ids" and data is application id which is written in config.xml for each application. This signal format is here: ON-EVENT windowmanager/screen_updated: { "event":"windowmanager\/screen_updated", "data":{ "ids":[ "navigation", "hvac" ] }, "jtype":"afb-event" } Bug-AGL: SPEC-1532 Change-Id: I6c1f263be00d4b496e0e0f77dd88b6118489772f Signed-off-by: Kazumasa Mitsunari <knimitz@witz-inc.co.jp>
-rw-r--r--src/window_manager.cpp32
-rw-r--r--src/window_manager.hpp5
2 files changed, 37 insertions, 0 deletions
diff --git a/src/window_manager.cpp b/src/window_manager.cpp
index 28ef868..fcc0906 100644
--- a/src/window_manager.cpp
+++ b/src/window_manager.cpp
@@ -50,6 +50,7 @@ const char kKeyWidthPixel[] = "width_pixel";
const char kKeyHeightPixel[] = "height_pixel";
const char kKeyWidthMm[] = "width_mm";
const char kKeyHeightMm[] = "height_mm";
+const char kKeyIds[] = "ids";
static sd_event_source *g_timer_ev_src = nullptr;
static AppList g_app_list;
@@ -414,6 +415,7 @@ void WindowManager::api_enddraw(char const *appid, char const *drawing_name)
{
//this->emit_error();
}
+ this->emitScreenUpdated(current_req);
HMI_SEQ_INFO(current_req, "Finish request status: %s", errorDescription(ret));
g_app_list.removeRequest(current_req);
@@ -1363,6 +1365,36 @@ WMError WindowManager::changeCurrentState(unsigned req_num)
return WMError::SUCCESS;
}
+void WindowManager::emitScreenUpdated(unsigned req_num)
+{
+ // Get visible apps
+ HMI_SEQ_DEBUG(req_num, "emit screen updated");
+ bool found = false;
+ auto actions = g_app_list.getActions(req_num, &found);
+
+ // create json object
+ json_object *j = json_object_new_object();
+ json_object *jarray = json_object_new_array();
+
+ for(const auto& action: actions)
+ {
+ if(action.visible != TaskVisible::INVISIBLE)
+ {
+ json_object_array_add(jarray, json_object_new_string(action.appid.c_str()));
+ }
+ }
+ json_object_object_add(j, kKeyIds, jarray);
+ HMI_SEQ_INFO(req_num, "Visible app: %s", json_object_get_string(j));
+
+ int ret = afb_event_push(
+ this->map_afb_event[kListEventName[Event_ScreenUpdated]], j);
+ if (ret != 0)
+ {
+ HMI_DEBUG("wm", "afb_event_push failed: %m");
+ }
+ json_object_put(jarray);
+}
+
void WindowManager::setTimer()
{
HMI_SEQ_DEBUG(g_app_list.currentRequestNumber(), "Timer set activate");
diff --git a/src/window_manager.hpp b/src/window_manager.hpp
index 00a798c..b5b1c4d 100644
--- a/src/window_manager.hpp
+++ b/src/window_manager.hpp
@@ -64,6 +64,7 @@ extern const char kKeyWidthPixel[];
extern const char kKeyHeightPixel[];
extern const char kKeyWidthMm[];
extern const char kKeyHeightMm[];
+extern const char kKeyIds[];
struct id_allocator
{
@@ -152,6 +153,8 @@ class WindowManager
Event_SyncDraw,
Event_FlushDraw,
+ Event_ScreenUpdated,
+
Event_Error,
Event_Val_Max = Event_Error,
@@ -164,6 +167,7 @@ class WindowManager
"invisible",
"syncdraw",
"flushdraw",
+ "screen_updated",
"error"};
struct controller_hooks chooks;
@@ -255,6 +259,7 @@ class WindowManager
WMError visibilityChange(const WMAction &action);
WMError setSurfaceSize(unsigned surface, const std::string& area);
WMError changeCurrentState(unsigned req_num);
+ void emitScreenUpdated(unsigned req_num);
void setTimer();
void stopTimer();