aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-08-08 14:40:56 +0900
committerKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-08-08 14:40:56 +0900
commit4fe7381b8fb96576291c60b6d4367137e0e90f54 (patch)
treeb1358ac74e19ed10f75fc791b52f10d4b6ebcf15
parentf35e79a450b49bd62a529d74980f332c62aa4c6b (diff)
Change WMClient to go to layer model
Change-Id: Iaf764f7386073d68219e7674000079b58af09fbd Signed-off-by: Kazumasa Mitsunari <knimitz@witz-inc.co.jp>
-rw-r--r--src/applist.cpp7
-rw-r--r--src/window_manager.cpp16
-rw-r--r--src/wm_client.cpp169
-rw-r--r--src/wm_client.hpp30
4 files changed, 147 insertions, 75 deletions
diff --git a/src/applist.cpp b/src/applist.cpp
index b06dee8..159b30d 100644
--- a/src/applist.cpp
+++ b/src/applist.cpp
@@ -164,7 +164,7 @@ string AppList::getAppID(unsigned surface, const string& role, bool* found) cons
*found = false;
for (const auto &x : this->app2client)
{
- if(x.second->surfaceID(role) == surface){
+ if(x.second->surfaceID() == surface){
*found = true;
return x.second->appID();
}
@@ -231,12 +231,13 @@ void AppList::removeFloatingSurface(unsigned surface)
WMError AppList::appendRole(const string &id, const string &role, unsigned surface)
{
WMError wm_err = WMError::NO_ENTRY;
- if (this->contains(id))
+ HMI_ERROR("wm", "This function is disabled");
+ /* if (this->contains(id))
{
auto x = this->lookUpClient(id);
x->addSurface(role, surface);
wm_err = WMError::SUCCESS;
- }
+ } */
return wm_err;
}
diff --git a/src/window_manager.cpp b/src/window_manager.cpp
index 0eebbff..beb8eac 100644
--- a/src/window_manager.cpp
+++ b/src/window_manager.cpp
@@ -434,14 +434,14 @@ void WindowManager::api_activate_surface(char const *appid, char const *drawing_
}
auto client = g_app_list.lookUpClient(id);
- unsigned srfc = client->surfaceID(role);
+ unsigned srfc = client->surfaceID();
if(srfc == 0)
{
HMI_ERROR("wm", "role sould be set with surface");
reply("role sould be set with surface");
return;
}
- g_app_list.removeFloatingSurface(client->surfaceID(role));
+ g_app_list.removeFloatingSurface(client->surfaceID());
Task task = Task::TASK_ALLOCATE;
unsigned req_num = 0;
@@ -1239,7 +1239,7 @@ WMError WindowManager::startTransition(unsigned req_num)
if (g_app_list.contains(x.appid))
{
auto client = g_app_list.lookUpClient(x.appid);
- this->deactivate(client->surfaceID(x.role));
+ this->deactivate(client->surfaceID());
}
}
ret = NO_LAYOUT_CHANGE;
@@ -1467,7 +1467,7 @@ WMError WindowManager::layoutChange(const WMAction &action)
return WMError::SUCCESS;
}
auto client = g_app_list.lookUpClient(action.appid);
- unsigned surface = client->surfaceID(action.role);
+ unsigned surface = client->surfaceID();
if (surface == 0)
{
HMI_SEQ_ERROR(g_app_list.currentRequestNumber(),
@@ -1486,7 +1486,7 @@ WMError WindowManager::visibilityChange(const WMAction &action)
return WMError::NOT_REGISTERED;
}
auto client = g_app_list.lookUpClient(action.appid);
- unsigned surface = client->surfaceID(action.role);
+ unsigned surface = client->surfaceID();
if(surface == 0)
{
HMI_SEQ_ERROR(g_app_list.currentRequestNumber(),
@@ -1533,7 +1533,7 @@ WMError WindowManager::changeCurrentState(unsigned req_num)
return WMError::NOT_REGISTERED;
}
auto client = g_app_list.lookUpClient(action.appid);
- auto pCurState = *this->layers.get_layout_state((int)client->surfaceID(action.role));
+ auto pCurState = *this->layers.get_layout_state((int)client->surfaceID());
if(pCurState == nullptr)
{
HMI_SEQ_ERROR(req_num, "Counldn't find current status");
@@ -1547,7 +1547,7 @@ WMError WindowManager::changeCurrentState(unsigned req_num)
for (const auto &action : actions)
{
auto client = g_app_list.lookUpClient(action.appid);
- auto pLayerCurState = *this->layers.get_layout_state((int)client->surfaceID(action.role));
+ auto pLayerCurState = *this->layers.get_layout_state((int)client->surfaceID());
if (pLayerCurState == nullptr)
{
HMI_SEQ_ERROR(req_num, "Counldn't find current status");
@@ -1557,7 +1557,7 @@ WMError WindowManager::changeCurrentState(unsigned req_num)
if (action.visible != TaskVisible::INVISIBLE)
{
- surface = (int)client->surfaceID(action.role);
+ surface = (int)client->surfaceID();
HMI_SEQ_INFO(req_num, "Change %s surface : %d, state visible area : %s",
action.role.c_str(), surface, action.area.c_str());
// visible == true -> layout changes
diff --git a/src/wm_client.cpp b/src/wm_client.cpp
index a9ed547..d4303fd 100644
--- a/src/wm_client.cpp
+++ b/src/wm_client.cpp
@@ -15,6 +15,7 @@
*/
#include <json-c/json.h>
+#include <algorithm>
#include "wm_client.hpp"
#include "hmi-debug.h"
@@ -39,9 +40,9 @@ static const char kKeyErrorDesc[] = "kErrorDescription";
WMClient::WMClient(const string &appid, unsigned layer, unsigned surface, const string &role)
: id(appid), layer(layer),
- role2surface(0)
+ service2surfaces(0)
{
- role2surface[role] = surface;
+ service2surfaces[role] = surface;
for (auto x : kWMEvents)
{
#if GTEST_ENABLED
@@ -49,17 +50,17 @@ WMClient::WMClient(const string &appid, unsigned layer, unsigned surface, const
#else
afb_event ev = afb_daemon_make_event(x.c_str());
#endif
- event2list[x] = ev;
+ evname2afb_event[x] = ev;
}
}
WMClient::WMClient(const string &appid, const string &role)
: id(appid),
layer(0),
- role2surface(0),
- event2list(0)
+ service2surfaces(0),
+ evname2afb_event(0)
{
- role2surface[role] = INVALID_SURFACE_ID;
+ service2surfaces[role] = INVALID_SURFACE_ID;
for (auto x : kWMEvents)
{
#if GTEST_ENABLED
@@ -67,38 +68,27 @@ WMClient::WMClient(const string &appid, const string &role)
#else
afb_event ev = afb_daemon_make_event(x.c_str());
#endif
- event2list[x] = ev;
+ evname2afb_event[x] = ev;
}
}
-WMClient::~WMClient()
-{
-}
+// WMClient::~WMClient()
+// {
+// }
string WMClient::appID() const
{
return this->id;
}
-unsigned WMClient::surfaceID(const string &role) const
+vector<unsigned> WMClient::renderOrder() const
{
- if (0 == this->role2surface.count(role))
- {
- return INVALID_SURFACE_ID;
- }
- return this->role2surface.at(role);
+ return this->surface_render_order;
}
-std::string WMClient::role(unsigned surface) const
+const vector<std::string>& WMClient::roles() const
{
- for(const auto& x : this->role2surface)
- {
- if(x.second == surface)
- {
- return x.first;
- }
- }
- return std::string("");
+ return this->role_list;
}
unsigned WMClient::layerID() const
@@ -106,6 +96,16 @@ unsigned WMClient::layerID() const
return this->layer;
}
+unsigned WMClient::surfaceID() const
+{
+ return this->surface;
+}
+
+void WMClient::setRole(const string& role)
+{
+ this->role_list.push_back(role);
+}
+
/**
* Set layerID the client belongs to
*
@@ -123,7 +123,7 @@ void WMClient::registerLayer(unsigned layer)
}
/**
- * Add the pair of role and surface to the client
+ * Add the pair of name and surface of surface to the client
*
* This function set the pair of role and surface to the client.
* This function is used for the client which has multi surfaces.
@@ -131,57 +131,108 @@ void WMClient::registerLayer(unsigned layer)
* is changed, this function will be changed
* Current Window Manager doesn't use this function.
*
- * @param string[in] role
+ * @param string[in] name
* @param unsigned[in] surface
* @return true
*/
-bool WMClient::addSurface(const string &role, unsigned surface)
+void WMClient::attachServiceSurface(const string &name, unsigned surface)
{
- HMI_DEBUG("wm", "Add role %s with surface %d", role.c_str(), surface);
- if (0 != this->role2surface.count(role))
+ HMI_DEBUG("wm", "Add surface name %s with surface %d", name.c_str(), surface);
+ if (0 != this->service2surfaces.count(name))
{
- HMI_NOTICE("wm", "override surfaceID %d with %d", this->role2surface[role], surface);
+ HMI_NOTICE("wm", "override surfaceID %d with %d", this->service2surfaces[name], surface);
}
- this->role2surface[role] = surface;
- return true;
+ this->service2surfaces[name] = surface;
}
-bool WMClient::removeSurfaceIfExist(unsigned surface)
+void WMClient::removeServiceSurface(const std::string &name)
{
- bool ret = false;
- for (auto &x : this->role2surface)
+ for (auto &x : this->service2surfaces)
{
- if (surface == x.second)
+ if (name == x.first)
{
- HMI_INFO("wm", "Remove surface from client %s: role %s, surface: %d",
- this->id.c_str(), x.first.c_str(), x.second);
- this->role2surface.erase(x.first);
- ret = true;
- break;
+ HMI_INFO("wm", "Remove surface from client %s: service surface name %s, surface: %d",
+ this->id.c_str(), x.first.c_str(), x.second);
+ this->service2surfaces.erase(name);
}
}
- return ret;
+ // re_asign render order
+ this->setRenderOrder(this->surface_render_order);
+}
+
+void WMClient::setArea(const std::string& area)
+{
+ this->area = area;
+ // TODO: implementation
}
-bool WMClient::removeRole(const string &role)
+void WMClient::setRenderOrder()
+{
+ // use private surface_render_order
+}
+
+void WMClient::setRenderOrder(const vector<string> &render_order)
+{
+ // TODO: implement LM
+}
+
+void WMClient::setRenderOrder(const vector<unsigned> &render_order)
+{
+ // TODO implement LM
+}
+
+bool WMClient::removeSurfaceIfExist(unsigned surface)
{
bool ret = false;
- if (this->role2surface.count(role) != 0)
+ auto fwd_itr = std::remove_if(
+ this->surface_render_order.begin(), this->surface_render_order.end(),
+ [surface, &ret](unsigned x) {
+ ret = true;
+ return x == surface;
+ });
+ this->surface_render_order.erase(fwd_itr, this->surface_render_order.end());
+ if(ret)
{
- this->role2surface.erase(role);
- ret = true;
+ for(auto &y : this->service2surfaces)
+ {
+ if(y.second == surface)
+ {
+ HMI_INFO("wm", "Remove surface from client %s: role %s, surface: %d",
+ this->id.c_str(), y.first.c_str(), y.second);
+ this->service2surfaces.erase(y.first);
+ }
+ }
+ if(this->surface == surface)
+ {
+ this->surface = INVALID_SURFACE_ID;
+ // TODO: If main surface vanishes, how do we treat?
+ // Window Manager doesn't know it's means dead or on purpose.
+ // option1: remove service surface and notify to the service.
+ // option2: waiting the application calls deallocate.
+ HMI_INFO("wm", "Main surface vanishes");
+ }
}
return ret;
}
-#ifndef GTEST_ENABLED
+void WMClient::removeRole(const string &role)
+{
+ auto fwd_itr = std::remove_if(
+ this->role_list.begin(), this->role_list.end(),
+ [&role](string x) {
+ return x == role;
+ });
+ this->role_list.erase(fwd_itr, this->role_list.end());
+}
+
+#if GTEST_ENABLED
bool WMClient::subscribe(afb_req req, const string &evname)
{
if(evname != kKeyError){
HMI_DEBUG("wm", "error is only enabeled for now");
return false;
}
- int ret = afb_req_subscribe(req, this->event2list[evname]);
+ int ret = afb_req_subscribe(req, this->evname2afb_event[evname]);
if (ret)
{
HMI_DEBUG("wm", "Failed to subscribe %s", evname.c_str());
@@ -192,7 +243,7 @@ bool WMClient::subscribe(afb_req req, const string &evname)
void WMClient::emitError(WM_CLIENT_ERROR_EVENT ev)
{
- if (!afb_event_is_valid(this->event2list[kKeyError])){
+ if (!afb_event_is_valid(this->evname2afb_event[kKeyError])){
HMI_ERROR("wm", "event err is not valid");
return;
}
@@ -201,7 +252,7 @@ void WMClient::emitError(WM_CLIENT_ERROR_EVENT ev)
json_object_object_add(j, kKeyErrorDesc, json_object_new_string(kErrorDescription[ev].c_str()));
HMI_DEBUG("wm", "error: %d, description:%s", ev, kErrorDescription[ev].c_str());
- int ret = afb_event_push(this->event2list[kKeyError], j);
+ int ret = afb_event_push(this->evname2afb_event[kKeyError], j);
if (ret != 0)
{
HMI_DEBUG("wm", "afb_event_push failed: %m");
@@ -211,12 +262,20 @@ void WMClient::emitError(WM_CLIENT_ERROR_EVENT ev)
void WMClient::dumpInfo()
{
- DUMP("APPID : %s", id.c_str());
- DUMP(" LAYER : %d", layer);
- for (const auto &x : this->role2surface)
+ DUMP("APPID : %s", this->id.c_str());
+ DUMP(" LAYER : %d", this->layer);
+ for (const auto &x : this->role_list)
+ {
+ DUMP(" ROLE : %s , SURFACE : %d", x.c_str());
+ }
+ DUMP(" MAIN SURFACE : %d", this->surface);
+ string ro = "";
+ for (const auto &x : this->surface_render_order)
{
- DUMP(" ROLE : %s , SURFACE : %d", x.first.c_str(), x.second);
+ ro += x;
+ ro += " ,";
}
+ DUMP(" RENDER ORDER : %s", ro.c_str());
}
} // namespace wm \ No newline at end of file
diff --git a/src/wm_client.hpp b/src/wm_client.hpp
index 0d6faeb..0173bb9 100644
--- a/src/wm_client.hpp
+++ b/src/wm_client.hpp
@@ -42,18 +42,26 @@ class WMClient
WMClient(const std::string &appid, unsigned layer,
unsigned surface, const std::string &role);
WMClient(const std::string &appid, const std::string &role);
- virtual ~WMClient();
+ ~WMClient() = default;
std::string appID() const;
- unsigned surfaceID(const std::string &role) const;
unsigned layerID() const;
- std::string role(unsigned surface) const;
+ unsigned surfaceID() const;
+ std::vector<unsigned> renderOrder() const;
+ const std::vector<std::string> &roles() const;
+ void setRole(const std::string& role);
void registerLayer(unsigned layer);
- bool addSurface(const std::string& role, unsigned surface);
+ //bool addSurface(unsigned surface);
+ void attachServiceSurface(const std::string &name, unsigned surface);
+ void removeServiceSurface(const std::string &name);
+ void setRenderOrder();
+ void setRenderOrder(const std::vector<std::string> &render_order);
+ void setRenderOrder(const std::vector<unsigned> &render_order);
+ void setArea(const std::string& area);
bool removeSurfaceIfExist(unsigned surface);
- bool removeRole(const std::string& role);
+ void removeRole(const std::string& role);
-#ifndef GTEST_ENABLED
+#if GTEST_ENABLED
bool subscribe(afb_req req, const std::string &event_name);
void emitError(WM_CLIENT_ERROR_EVENT ev);
#endif
@@ -63,12 +71,16 @@ class WMClient
private:
std::string id;
unsigned layer;
- std::unordered_map<std::string, unsigned> role2surface;
+ std::string area;
+ unsigned surface; // currently, main application has only one surface.
+ std::vector<std::string> role_list;
+ std::vector<unsigned> surface_render_order;
+ std::unordered_map<std::string, unsigned> service2surfaces;
#if GTEST_ENABLED
// This is for unit test. afb_make_event occurs sig11 if call not in afb-binding
- std::unordered_map<std::string, std::string> event2list;
+ std::unordered_map<std::string, std::string> evname2afb_event;
#else
- std::unordered_map<std::string, struct afb_event> event2list;
+ std::unordered_map<std::string, struct afb_event> evname2afb_event;
#endif
};
} // namespace wm