aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-05-22 19:42:21 +0900
committerYuta Doi <yuta-d@witz-inc.co.jp>2018-05-25 17:11:25 +0900
commited980b8cbb972accac00107922bea1dca0678d2a (patch)
tree2c009e94c7d989cbae4cc6757c1710fe06a1ad53 /src
parent74c30fd86597fb6b5d13a83dea3341b9bb9e903e (diff)
Add new event
Add "screen_updated" event. This means new application is visible from the user. key ... "id" value ... application_id Change-Id: I548ba30f882d126d538b44281afa36625a1325e4 Signed-off-by: Kazumasa Mitsunari <knimitz@witz-inc.co.jp>
Diffstat (limited to 'src')
-rw-r--r--src/app.cpp21
-rw-r--r--src/app.hpp11
-rw-r--r--src/main.cpp3
3 files changed, 30 insertions, 5 deletions
diff --git a/src/app.cpp b/src/app.cpp
index e9af748..faca413 100644
--- a/src/app.cpp
+++ b/src/app.cpp
@@ -58,6 +58,7 @@ const char kKeyWidthPixel[] = "width_pixel";
const char kKeyHeightPixel[] = "height_pixel";
const char kKeyWidthMm[] = "width_mm";
const char kKeyHeightMm[] = "height_mm";
+const char kKeyAppID[] = "id";
namespace {
@@ -543,7 +544,7 @@ void App::check_flushdraw(int surface_id) {
}
}
-void App::api_enddraw(char const *drawing_name) {
+void App::api_enddraw(char const *appid, char const *drawing_name) {
for (unsigned i = 0, iend = this->pending_end_draw.size(); i < iend; i++) {
auto n = this->lookup_name(this->pending_end_draw[i]);
if (n && *n == drawing_name) {
@@ -551,6 +552,7 @@ void App::api_enddraw(char const *drawing_name) {
this->pending_end_draw.resize(iend - 1);
this->activate(this->pending_end_draw[i]);
this->emit_flushdraw(drawing_name);
+ this->emitScreenUpdated(appid);
}
}
}
@@ -668,6 +670,18 @@ void App::emit_invisible(char const *label) {
return emit_visible(label, false);
}
+void App::__send_event_temporary_extend(char const *evname, char const *appid) {
+ HMI_DEBUG("wm", "send event %s: %s", evname, appid);
+
+ json_object *j = json_object_new_object();
+ json_object_object_add(j, kKeyAppID, json_object_new_string(appid));
+
+ int ret = afb_event_push(this->map_afb_event[evname], j);
+ if (ret != 0) {
+ HMI_DEBUG("wm", "afb_event_push failed: %m");
+ }
+}
+
void App::emit_visible(char const *label) { return emit_visible(label, true); }
void App::emitHeadlampOff() {
@@ -710,6 +724,11 @@ void App::emitCarRun() {
this->send_event(kListEventName[Event_CarRun]);
}
+void App::emitScreenUpdated(char const* appid) {
+ // Send ScreenUpdated event for applications which calls wmsubscribe
+ this->__send_event_temporary_extend(kListEventName[Event_ScreenUpdated], appid);
+}
+
result<int> App::api_request_surface(char const *drawing_name) {
auto lid = this->layers.get_layer_id(std::string(drawing_name));
if (!lid) {
diff --git a/src/app.hpp b/src/app.hpp
index 2cc6fa8..dca112e 100644
--- a/src/app.hpp
+++ b/src/app.hpp
@@ -65,7 +65,7 @@ extern const char kKeyWidthPixel[];
extern const char kKeyHeightPixel[];
extern const char kKeyWidthMm[];
extern const char kKeyHeightMm[];
-
+extern const char kKeyAppID[];
struct id_allocator {
unsigned next = 1;
@@ -166,7 +166,9 @@ struct App {
Event_CarStop,
Event_CarRun,
- Event_Val_Max = Event_CarRun,
+ Event_ScreenUpdated,
+
+ Event_Val_Max = Event_ScreenUpdated,
};
const std::vector<const char *> kListEventName{
@@ -184,6 +186,7 @@ struct App {
"lightstatus_brake_on",
"car_stop",
"car_run",
+ "screen_updated",
};
struct controller_hooks chooks;
@@ -235,7 +238,7 @@ struct App {
char const *api_request_surface(char const *drawing_name, char const *ivi_id);
void allocateWindowResource(char const *event, char const *drawing_name,
char const *drawing_area, const reply_func &reply);
- void api_enddraw(char const *drawing_name);
+ void api_enddraw(char const* appid, char const *drawing_name);
result<json_object *> api_get_display_info();
result<json_object *> api_get_area_info(char const *drawing_name);
result<json_object *> api_get_car_info(char const *label);
@@ -243,6 +246,7 @@ struct App {
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_temporary_extend(char const *evname, char const *appid);
// Events from the compositor we are interested in
void surface_created(uint32_t surface_id);
@@ -297,6 +301,7 @@ private:
void emitLightstatusBrakeOn();
void emitCarStop();
void emitCarRun();
+ void emitScreenUpdated(char const *appid);
void activate(int id);
void deactivate(int id);
diff --git a/src/main.cpp b/src/main.cpp
index 52a2ed4..63db741 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -373,8 +373,9 @@ void windowmanager_enddraw(afb_req req) noexcept {
return;
}
afb_req_success(req, NULL, "success");
+ char* appid = afb_req_get_application_id(req);
- g_afb_instance->app.api_enddraw(a_drawing_name);
+ g_afb_instance->app.api_enddraw(appid, a_drawing_name);
} catch (std::exception &e) {
HMI_WARNING("wm", "failed", "Uncaught exception while calling enddraw: %s", e.what());