aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-08-10 13:14:14 +0900
committerKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-08-10 13:14:14 +0900
commit69bcb135b8785c76320e103be1ed92e860352e73 (patch)
tree038526ece14d8e8cc44dd618b14b5f2ccc07b2e4
parent38255dcda8e7e9462ed3b16ebe39c638bc9b349f (diff)
Move the process when an app is ternminated
Change-Id: Iac943acfab5f32332aab6c0e5ca0fead4a577b02 Signed-off-by: Kazumasa Mitsunari <knimitz@witz-inc.co.jp>
-rw-r--r--src/main.cpp40
-rw-r--r--src/window_manager.cpp30
-rw-r--r--src/window_manager.hpp12
3 files changed, 46 insertions, 36 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 261df8b..e1351be 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -29,17 +29,6 @@ extern "C"
#include <systemd/sd-event.h>
}
-typedef struct WMClientCtxt
-{
- std::string name;
- std::string role;
- WMClientCtxt(const char *appName, const char* appRole)
- {
- name = appName;
- role = appRole;
- }
-} WMClientCtxt;
-
struct afb_instance
{
std::unique_ptr<wl::display> display;
@@ -178,45 +167,24 @@ int binding_init() noexcept
static void cbRemoveClientCtxt(void *data)
{
- WMClientCtxt *ctxt = (WMClientCtxt *)data;
+ wm::WMClientCtxt *ctxt = (wm::WMClientCtxt *)data;
if (ctxt == nullptr)
{
return;
}
HMI_DEBUG("wm", "remove app %s", ctxt->name.c_str());
- // Lookup surfaceID and remove it because App is dead.
- auto pSid = g_afb_instance->wmgr.id_alloc.lookup(ctxt->role.c_str());
- if (pSid)
- {
- auto sid = *pSid;
- auto o_state = *g_afb_instance->wmgr.layers.get_layout_state(sid);
- if (o_state != nullptr)
- {
- if (o_state->main == sid)
- {
- o_state->main = -1;
- }
- else if (o_state->sub == sid)
- {
- o_state->sub = -1;
- }
- }
- g_afb_instance->wmgr.id_alloc.remove_id(sid);
- g_afb_instance->wmgr.layers.remove_surface(sid);
- HMI_DEBUG("wm", "delete surfaceID %d", sid);
- }
- g_afb_instance->wmgr.removeClient(ctxt->name);
+ g_afb_instance->wmgr.onApplicationTerminated(*ctxt);
delete ctxt;
}
static void createSecurityContext(afb_req req, const char* appid, const char* role)
{
- WMClientCtxt *ctxt = (WMClientCtxt *)afb_req_context_get(req);
+ wm::WMClientCtxt *ctxt = (wm::WMClientCtxt *)afb_req_context_get(req);
if (!ctxt)
{
// Create Security Context at first time
const char *new_role = g_afb_instance->wmgr.convertRoleOldToNew(role);
- WMClientCtxt *ctxt = new WMClientCtxt(appid, new_role);
+ wm::WMClientCtxt *ctxt = new wm::WMClientCtxt(appid, new_role);
HMI_DEBUG("wm", "create session for %s", ctxt->name.c_str());
afb_req_session_set_LOA(req, 1);
afb_req_context_set(req, ctxt, cbRemoveClientCtxt);
diff --git a/src/window_manager.cpp b/src/window_manager.cpp
index aa42d82..aa9a459 100644
--- a/src/window_manager.cpp
+++ b/src/window_manager.cpp
@@ -620,6 +620,36 @@ void WindowManager::timerHandler()
this->processNextRequest();
}
+void WindowManager::onApplicationTerminated(const WMClientCtxt& ctxt)
+{
+ if(!g_app_list.contains(ctxt.name))
+ {
+ return;
+ }
+ auto client = g_app_list.lookUpClient(ctxt.name);
+ unsigned sid = client->surfaceID(ctxt.role);
+ if (sid != 0)
+ {
+ // update state
+ auto o_state = *this->layers.get_layout_state(sid);
+ if (o_state != nullptr)
+ {
+ if (o_state->main == sid)
+ {
+ o_state->main = -1;
+ }
+ else if (o_state->sub == sid)
+ {
+ o_state->sub = -1;
+ }
+ }
+ this->id_alloc.remove_id(sid);
+ this->layers.remove_surface(sid);
+ HMI_DEBUG("wm", "delete surfaceID %d", sid);
+ }
+ g_app_list.removeClient(ctxt.name);
+}
+
/*
******* Private Functions *******
*/
diff --git a/src/window_manager.hpp b/src/window_manager.hpp
index 2358c5a..a820aa5 100644
--- a/src/window_manager.hpp
+++ b/src/window_manager.hpp
@@ -68,6 +68,17 @@ extern const char kKeyHeightMm[];
extern const char kKeyScale[];
extern const char kKeyIds[];
+typedef struct WMClientCtxt
+{
+ std::string name;
+ std::string role;
+ WMClientCtxt(const char *appName, const char* appRole)
+ {
+ name = appName;
+ role = appRole;
+ }
+} WMClientCtxt;
+
struct id_allocator
{
unsigned next = 1;
@@ -229,6 +240,7 @@ class WindowManager
const char* convertRoleOldToNew(char const *role);
// Do not use this function
void timerHandler();
+ void onApplicationTerminated(const WMClientCtxt& ctxt);
private:
bool pop_pending_events();