summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/applist.cpp21
-rw-r--r--src/applist.hpp1
-rw-r--r--src/window_manager.cpp72
-rw-r--r--src/window_manager.hpp2
-rw-r--r--src/wm_client.cpp11
-rw-r--r--src/wm_client.hpp2
-rw-r--r--src/wm_layer.cpp4
7 files changed, 90 insertions, 23 deletions
diff --git a/src/applist.cpp b/src/applist.cpp
index 67980f1..473d687 100644
--- a/src/applist.cpp
+++ b/src/applist.cpp
@@ -82,6 +82,27 @@ void AppList::addClient(const string &appid, unsigned layer, const string &role)
}
/**
+ * Add Client to the list
+ *
+ * This function is overload function.
+ * But this function just register application.
+ * So an application does not have role, surface, layer.
+ * Client need to register role and layer afterward.
+ *
+ * @param string[in] Application id. This will be the key to withdraw the information.
+ * @return None
+ * @attention This function should be called once for the app
+ * Caller should take care not to be called more than once.
+ */
+void AppList::addClient(const string &appid)
+{
+ std::lock_guard<std::mutex> lock(this->mtx);
+ shared_ptr<WMClient> client = std::make_shared<WMClient>(appid, 0, "");
+ this->app2client[appid] = client;
+ this->clientDump();
+}
+
+/**
* Remove WMClient from the list
*
* @param string[in] Application id. This will be the key to withdraw the information.
diff --git a/src/applist.hpp b/src/applist.hpp
index 085504a..0fe3bbd 100644
--- a/src/applist.hpp
+++ b/src/applist.hpp
@@ -45,6 +45,7 @@ class AppList
void addClient(const std::string &appid, unsigned layer,
unsigned surface, const std::string &role);
void addClient(const std::string &appid, unsigned layer, const std::string &role);
+ void addClient(const std::string &appid);
void removeClient(const std::string &appid);
bool contains(const std::string &appid) const;
int countClient() const;
diff --git a/src/window_manager.cpp b/src/window_manager.cpp
index 965c60d..33f19ee 100644
--- a/src/window_manager.cpp
+++ b/src/window_manager.cpp
@@ -174,21 +174,25 @@ result<int> WindowManager::api_request_surface(char const *appid, char const *dr
if(!g_app_list.contains(str_id))
{
- lid = this->lc->getNewLayerID(role);
+ unsigned lid = this->generateLayerForClient(role);
if (lid == 0)
{
- // register drawing_name as fallback and make it displayed.
- lid = this->lc->getNewLayerID(string("fallback"));
- HMI_DEBUG("%s is not registered in layers.json, then fallback as normal app", role.c_str());
- if (lid == 0)
- {
- return Err<int>("Designated role does not match any role, fallback is disabled");
- }
+ return Err<int>("Designated role does not match any role, fallback is disabled");
}
- this->lc->createNewLayer(lid);
// add client into the db
g_app_list.addClient(str_id, lid, drawing_name);
}
+ else
+ {
+ // This case occurs when an client calls "subscribe" before request_surface.
+ // Then application doesn't have layer and role yet.
+ auto client = g_app_list.lookUpClient(str_id);
+ if(client->layerID() == 0)
+ {
+ client->setLayerID(this->generateLayerForClient(role));
+ }
+ client->setRole(drawing_name);
+ }
// generate surface ID for ivi-shell application
auto rname = this->id_alloc.lookup(role);
@@ -238,21 +242,25 @@ char const *WindowManager::api_request_surface(char const *appid, char const *dr
if(!g_app_list.contains(str_id))
{
- unsigned l_id = this->lc->getNewLayerID(role);
+ unsigned l_id = this->generateLayerForClient(role);
if (l_id == 0)
{
- // register drawing_name as fallback and make it displayed.
- l_id = this->lc->getNewLayerID("fallback");
- HMI_DEBUG("%s is not registered in layers.json, then fallback as normal app", role.c_str());
- if (l_id == 0)
- {
- return "Designated role does not match any role, fallback is disabled";
- }
+ return "Designated role does not match any role, fallback is disabled";
}
- this->lc->createNewLayer(l_id);
// add client into the db
g_app_list.addClient(str_id, l_id, drawing_name);
}
+ else
+ {
+ // This case occurs when an client calls "subscribe" before request_surface.
+ // Then application doesn't have layer and role yet.
+ auto client = g_app_list.lookUpClient(str_id);
+ if(client->layerID() == 0)
+ {
+ client->setLayerID(this->generateLayerForClient(role));
+ }
+ client->setRole(drawing_name);
+ }
auto rname = this->id_alloc.lookup(role);
@@ -436,11 +444,15 @@ bool WindowManager::api_subscribe(afb_req_t req, EventType event_id)
{
string id = appid;
free(appid);
- auto client = g_app_list.lookUpClient(id);
- if(client != nullptr)
+ if(!g_app_list.contains(id))
{
- ret = client->subscribe(req, kListEventName[event_id]);
+ g_app_list.addClient(id);
}
+ g_app_list.lookUpClient(id)->subscribe(req, kListEventName[event_id]);
+ }
+ else
+ {
+ HMI_ERROR("appid is not set");
}
return ret;
}
@@ -637,6 +649,24 @@ void WindowManager::processError(WMError error)
this->processNextRequest();
}
+unsigned WindowManager::generateLayerForClient(const string& role)
+{
+ unsigned lid = this->lc->getNewLayerID(role);
+ if (lid == 0)
+ {
+ // register drawing_name as fallback and make it displayed.
+ lid = this->lc->getNewLayerID(string("fallback"));
+ HMI_DEBUG("%s is not registered in layers.json, then fallback as normal app", role.c_str());
+ if (lid == 0)
+ {
+ return lid;
+ }
+ }
+ this->lc->createNewLayer(lid);
+ // add client into the db
+ return lid;
+}
+
WMError WindowManager::setRequest(const string& appid, const string &role, const string &area,
Task task, unsigned* req_num)
{
diff --git a/src/window_manager.hpp b/src/window_manager.hpp
index ccec302..d13d5bb 100644
--- a/src/window_manager.hpp
+++ b/src/window_manager.hpp
@@ -135,7 +135,6 @@ struct TmpClient
unsigned layer;
};
-
class WindowManager
{
public:
@@ -195,6 +194,7 @@ class WindowManager
void processError(WMError error);
private:
+ unsigned generateLayerForClient(const std::string &role);
WMError setRequest(const std::string &appid, const std::string &role, const std::string &area,
Task task, unsigned *req_num);
WMError checkPolicy(unsigned req_num);
diff --git a/src/wm_client.cpp b/src/wm_client.cpp
index da7e626..705bf4d 100644
--- a/src/wm_client.cpp
+++ b/src/wm_client.cpp
@@ -72,6 +72,7 @@ WMClient::WMClient(const string &appid, const string &role)
: id(appid),
layer(0),
is_source_set(false),
+ main_role(role),
role2surface(0),
evname2afb_event(0)
{
@@ -116,11 +117,21 @@ string WMClient::role() const
return this->main_role;
}
+void WMClient::setRole(const string& role)
+{
+ this->main_role = role;
+}
+
unsigned WMClient::layerID() const
{
return this->layer;
}
+void WMClient::setLayerID(unsigned id)
+{
+ this->layer = id;
+}
+
unsigned WMClient::surfaceID() const
{
return this->surface;
diff --git a/src/wm_client.hpp b/src/wm_client.hpp
index 3ffa786..ca4fd3d 100644
--- a/src/wm_client.hpp
+++ b/src/wm_client.hpp
@@ -45,7 +45,9 @@ class WMClient
std::string appID() const;
std::string role() const;
+ void setRole(const std::string& role);
unsigned layerID() const;
+ void setLayerID(unsigned id);
unsigned surfaceID() const;
void registerSurface(unsigned surface);
std::string area() const {return this->app_area;};
diff --git a/src/wm_layer.cpp b/src/wm_layer.cpp
index 66fb0a2..4eceb43 100644
--- a/src/wm_layer.cpp
+++ b/src/wm_layer.cpp
@@ -251,8 +251,10 @@ void WMLayer::dump()
{
DUMP("===== wm layer status =====");
DUMP("Layer :%s", this->name.c_str());
- this->tmp_state.dump();
+ DUMP(" [Current]");
this->state.dump();
+ DUMP(" [To be]");
+ this->tmp_state.dump();
DUMP("===== wm layer status end =====");
}