#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;
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);
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 *******
*/
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;
const char* convertRoleOldToNew(char const *role);
// Do not use this function
void timerHandler();
+ void onApplicationTerminated(const WMClientCtxt& ctxt);
private:
bool pop_pending_events();