aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-05-29 17:35:53 +0900
committerKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-05-29 17:35:53 +0900
commit39f0040a8518bf10ba96f2888a37f65faa3ede3d (patch)
tree876ed06d6da56bb5b83812ca29c2a7cdce643d7f
parent73d2a3437d332f239413a50dd745289b16de97ae (diff)
pull out layout manager task
Change-Id: I2c256dc2095607a31306786964421442fba4ae4b Signed-off-by: Kazumasa Mitsunari <knimitz@witz-inc.co.jp>
-rw-r--r--src/app.cpp86
-rw-r--r--src/app.hpp10
2 files changed, 71 insertions, 25 deletions
diff --git a/src/app.cpp b/src/app.cpp
index 7f20825..5021c05 100644
--- a/src/app.cpp
+++ b/src/app.cpp
@@ -434,13 +434,36 @@ void App::stop_timer(){
}
}
-bool App::do_allocate_window_resource(unsigned req_num)
+bool App::lm_release(const struct WMAction &action)
+{
+ return true;
+}
+
+bool App::lm_layout_change(const struct WMAction &action)
+{
+ const char *msg = this->check_surface_exist(action.role.c_str());
+
+ /*
+ lm_.updateLayout(action);
+ TODO: emit syncDraw with application*/
+ if (msg)
+ {
+ HMI_SEQ_DEBUG(app_list.currentSequenceNumber(), msg);
+ //app_list.removeRequest(req_num);
+ return false;
+ }
+ this->lm_layout_change(action.role.c_str());
+ return true;
+}
+
+bool App::do_transition(unsigned req_num)
{
/*
* Check Policy
*/
- // get current trigger
+ // get current trigger
auto trigger = app_list.getRequest(req_num);
+ bool is_activate = true;
/* get new status from Policy Manager
@@ -458,28 +481,47 @@ bool App::do_allocate_window_resource(unsigned req_num)
} */
HMI_SEQ_NOTICE(req_num, "ATM, Policy manager does't exist, then set WMAction as is");
- bool ret = app_list.setAction(req_num, trigger.appid, trigger.role, trigger.area);
-
+ if (TASK_RELEASE == trigger.task)
+ {
+ is_activate = false;
+ }
+ bool ret = app_list.setAction(req_num, trigger.appid, trigger.role, trigger.area, is_activate);
app_list.req_dump();
- /*
- lm_.updateLayout(jobj);
- TODO: emit syncDraw with application
+ if(!ret){
+ HMI_SEQ_ERROR(req_num, "Failed to set action");
+ return ret;
+ }
- client->emit_syncdraw(role); */
+ /*client->emit_syncdraw(role); */
// layer manager task
- const char *msg = this->check_surface_exist(req_num, trigger.appid.c_str());
-
- if (msg)
+ for (const auto &y : app_list.getActions(req_num))
{
- HMI_SEQ_DEBUG(req_num, msg);
- app_list.removeRequest(req_num);
- return false;
+ // do_task(y); but current we can't do this
+ if (y.visible)
+ {
+ ret = lm_layout_change(y);
+ if(!ret){
+ HMI_SEQ_ERROR(req_num, "Failed layout change: %s", y.appid.c_str());
+ app_list.removeRequest(req_num);
+ break;
+ // TODO: if transition fails, what should we do?
+ }
+ }
+ else{
+ ret = lm_release(y);
+ if (!ret)
+ {
+ HMI_SEQ_ERROR(req_num, "Failed release resource: %s", y.appid.c_str());
+ app_list.removeRequest(req_num);
+ break;
+ // TODO: if transition fails, what should we do?
+ }
+ }
}
- this->lm_layout_change(req_num, trigger.appid.c_str());
- if (ret && (msg == nullptr)) {
+ if (ret) {
this->set_timer();
} else {
//this->emit_error(request_seq, 0 /*error_num*/, "error happens"); // test
@@ -487,7 +529,7 @@ bool App::do_allocate_window_resource(unsigned req_num)
return ret;
}
-void App::lm_layout_change(unsigned req_num, const char* drawing_name)
+void App::lm_layout_change(const char* drawing_name)
{
auto const &surface_id = this->lookup_id(drawing_name);
auto layer_id = this->layers.get_layer_id(*surface_id);
@@ -632,7 +674,7 @@ void App::lm_layout_change(unsigned req_num, const char* drawing_name)
}
}
-const char* App::check_surface_exist(unsigned req_num, const char* drawing_name)
+const char* App::check_surface_exist(const char* drawing_name)
{
auto const &surface_id = this->lookup_id(drawing_name);
if (!surface_id)
@@ -716,10 +758,10 @@ void App::api_activate_surface(char const *appid, char const *drawing_name, char
/*
* Do allocate tasks
*/
- bool ret = this->do_allocate_window_resource(new_req);
+ bool ret = this->do_transition(new_req);
if(!ret){
- HMI_SEQ_ERROR(new_req, "failed to do_allocate_window_resource");
+ HMI_SEQ_ERROR(new_req, "failed to do_transition");
//this->emit_error()
}
}
@@ -770,7 +812,7 @@ void App::api_deactivate_surface(char const *appid, char const *drawing_name, co
/*
* Do allocate tasks
*/
- //bool ret = this->do_allocate_window_resource(new_req);
+ //bool ret = this->do_transition(new_req);
auto const &surface_id = this->lookup_id(drawing_name);
if (!surface_id)
@@ -926,7 +968,7 @@ void App::process_request()
{
unsigned req = app_list.currentSequenceNumber();
HMI_SEQ_DEBUG(req, "Do next request");
- do_allocate_window_resource(req);
+ do_transition(req);
}
void App::api_enddraw(char const *appid, char const *drawing_name)
diff --git a/src/app.hpp b/src/app.hpp
index 5f6ec83..1904245 100644
--- a/src/app.hpp
+++ b/src/app.hpp
@@ -32,6 +32,7 @@
#include "result.hpp"
#include "wayland_ivi_wm.hpp"
#include "hmi-debug.h"
+#include "request.hpp"
namespace wl {
struct display;
@@ -243,12 +244,13 @@ struct App {
void emit_invisible(char const *label);
void emit_visible(char const *label);
- bool do_allocate_window_resource(unsigned sequence_number);
+ bool do_transition(unsigned sequence_number);
+
void do_enddraw(unsigned sequence_number);
void process_request();
void set_timer();
void stop_timer();
- const char *check_surface_exist(unsigned req_num, const char *drawing_name);
+ const char *check_surface_exist(const char *drawing_name);
void activate(int id);
void deactivate(int id);
@@ -261,7 +263,9 @@ struct App {
// The following function is temporary.
// Then will be removed when layermanager is finished
- void lm_layout_change(unsigned req_num, const char* drawing_name);
+ void lm_layout_change(const char* drawing_name);
+ bool lm_layout_change(const struct WMAction &action);
+ bool lm_release(const struct WMAction &action);
void lm_enddraw(const char* drawing_name);
};