aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKazumasa Mitsunari <knimitz@witz-inc.co.jp>2019-03-13 18:02:37 +0900
committerKazumasa Mitsunari <knimitz@witz-inc.co.jp>2019-03-14 13:01:46 +0900
commit464f20cc2a960052233c4e2cbc2bd7dd3876b7f7 (patch)
tree6a5f93a935ac932c7188081a5854156f14239c24 /src
parentd4b18f9152860b4fd8746e5098a75ad56dba1c7f (diff)
Fix xdg-runcher doesn't show up
xdg-runcher calls "subscribe" before requestSurface, then windowmanager reject it because WMClient object is not created yet. This patch changes to register WMClient if it is not created when App calls "subscribe". Application doesn't need to care about the order of "requestSurface" and "subscribe". Bug-AGL: SPEC-2218 Change-Id: Ia82ff939dfdb2bbfd377bd50fd3d4b844451cd3b Signed-off-by: Kazumasa Mitsunari <knimitz@witz-inc.co.jp>
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.cpp10
-rw-r--r--src/wm_client.hpp2
6 files changed, 86 insertions, 22 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 4fcab5f..1e3a926 100644
--- a/src/window_manager.cpp
+++ b/src/window_manager.cpp
@@ -167,21 +167,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, role);
}
+ 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(role);
+ }
// generate surface ID for ivi-shell application
auto rname = this->id_alloc.lookup(role);
@@ -224,21 +228,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, role);
}
+ 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(role);
+ }
auto rname = this->id_alloc.lookup(role);
@@ -501,11 +509,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;
}
@@ -699,6 +711,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 eac6576..4c2c49b 100644
--- a/src/window_manager.hpp
+++ b/src/window_manager.hpp
@@ -134,7 +134,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 d3f0364..4bccb8c 100644
--- a/src/wm_client.cpp
+++ b/src/wm_client.cpp
@@ -120,11 +120,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 17d2221..7df4dea 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);
void activate();