X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=src%2Fmain.cpp;h=feb2124f445dc0ee5695b017ce4dfb9fadebcb24;hb=587d384f52c624a75eafe2588b728de4cdd53e4f;hp=60f816412b8b832a56ecadbe16ab8796fc28b266;hpb=92a48ccfc61ae0452bc814c3baa4e4c0ce885890;p=apps%2Fagl-service-windowmanager.git diff --git a/src/main.cpp b/src/main.cpp index 60f8164..feb2124 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -18,11 +18,9 @@ #include #include #include -#include -#include "app.hpp" -#include "result.hpp" +#include "../include/json.hpp" +#include "window_manager.hpp" #include "json_helper.hpp" -#include "util.hpp" #include "wayland_ivi_wm.hpp" extern "C" @@ -31,14 +29,16 @@ extern "C" #include } -typedef struct wmClientCtxt +typedef struct WMClientCtxt { std::string name; - wmClientCtxt(const char *appName) + std::string role; + WMClientCtxt(const char *appName, const char* appRole) { name = appName; + role = appRole; } -} wmClientCtxt; +} WMClientCtxt; struct afb_instance { @@ -178,23 +178,35 @@ int binding_init() noexcept static bool checkFirstReq(afb_req req) { - wmClientCtxt *ctxt = (wmClientCtxt *)afb_req_context_get(req); + WMClientCtxt *ctxt = (WMClientCtxt *)afb_req_context_get(req); return (ctxt) ? false : true; } static void cbRemoveClientCtxt(void *data) { - wmClientCtxt *ctxt = (wmClientCtxt *)data; + WMClientCtxt *ctxt = (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->app.id_alloc.lookup(ctxt->name.c_str()); + auto pSid = g_afb_instance->app.id_alloc.lookup(ctxt->role.c_str()); if (pSid) { auto sid = *pSid; + auto o_state = *g_afb_instance->app.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->app.id_alloc.remove_id(sid); g_afb_instance->app.layers.remove_surface(sid); g_afb_instance->app.controller->sprops.erase(sid); @@ -230,7 +242,7 @@ void windowmanager_requestsurface(afb_req req) noexcept bool isFirstReq = checkFirstReq(req); if (!isFirstReq) { - wmClientCtxt *ctxt = (wmClientCtxt *)afb_req_context_get(req); + WMClientCtxt *ctxt = (WMClientCtxt *)afb_req_context_get(req); HMI_DEBUG("wm", "You're %s.", ctxt->name.c_str()); if (ctxt->name != std::string(a_drawing_name)) { @@ -245,7 +257,7 @@ void windowmanager_requestsurface(afb_req req) noexcept if (isFirstReq) { - wmClientCtxt *ctxt = new wmClientCtxt(a_drawing_name); + WMClientCtxt *ctxt = new WMClientCtxt(afb_req_get_application_id(req), a_drawing_name); 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); @@ -362,7 +374,8 @@ void windowmanager_activatesurface(afb_req req) noexcept } catch (std::exception &e) { - HMI_WARNING("wm", "failed", "Uncaught exception while calling activatesurface: %s", e.what()); + HMI_WARNING("wm", "failed: Uncaught exception while calling activatesurface: %s", e.what()); + g_afb_instance->app.exeptionProcessForTransition(); return; } } @@ -402,7 +415,8 @@ void windowmanager_deactivatesurface(afb_req req) noexcept } catch (std::exception &e) { - HMI_WARNING("wm", "Uncaught exception while calling deactivatesurface: %s", e.what()); + HMI_WARNING("wm", "failed: Uncaught exception while calling deactivatesurface: %s", e.what()); + g_afb_instance->app.exeptionProcessForTransition(); return; } } @@ -434,7 +448,8 @@ void windowmanager_enddraw(afb_req req) noexcept } catch (std::exception &e) { - HMI_WARNING("wm", "failed", "Uncaught exception while calling enddraw: %s", e.what()); + HMI_WARNING("wm", "failed: Uncaught exception while calling enddraw: %s", e.what()); + g_afb_instance->app.exeptionProcessForTransition(); return; } }