X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fwindow_manager.cpp;h=e785e4b8eb2f96d24a1f76f15fbe225bdb77eeee;hb=1a23bad65e9825a143c716f1e148dc7fcedf028d;hp=862341a1b41c788b42c161b79efc66bebae8bebb;hpb=6bc7a273350721be300423b1509527f336dce50e;p=apps%2Fagl-service-windowmanager-2017.git diff --git a/src/window_manager.cpp b/src/window_manager.cpp index 862341a..e785e4b 100644 --- a/src/window_manager.cpp +++ b/src/window_manager.cpp @@ -37,6 +37,7 @@ const char kNameLayoutSplit[] = "split"; const char kNameAreaFull[] = "full"; const char kNameAreaMain[] = "main"; const char kNameAreaSub[] = "sub"; +const char kNameAreaDefault[] = "normal.full"; /* Key for json obejct */ const char kKeyDrawingName[] = "drawing_name"; @@ -50,6 +51,7 @@ const char kKeyWidthPixel[] = "width_pixel"; const char kKeyHeightPixel[] = "height_pixel"; const char kKeyWidthMm[] = "width_mm"; const char kKeyHeightMm[] = "height_mm"; +const char kKeyScale[] = "scale"; const char kKeyIds[] = "ids"; static sd_event_source *g_timer_ev_src = nullptr; @@ -183,12 +185,12 @@ int WindowManager::init() // This protocol needs the output, so lets just add our mapping here... this->controller->add_proxy_to_id_mapping( - this->outputs.back()->proxy.get(), + this->outputs.front()->proxy.get(), wl_proxy_get_id(reinterpret_cast( - this->outputs.back()->proxy.get()))); + this->outputs.front()->proxy.get()))); // Create screen - this->controller->create_screen(this->outputs.back()->proxy.get()); + this->controller->create_screen(this->outputs.front()->proxy.get()); // Set display to controller this->controller->display = this->display; @@ -460,10 +462,9 @@ void WindowManager::api_enddraw(char const *appid, char const *drawing_name) result WindowManager::api_get_display_info() { - // Check controller - if (!this->controller) + if (!this->display->ok()) { - return Err("ivi_controller global not available"); + return Err("Wayland compositor is not available"); } // Set display info @@ -475,6 +476,7 @@ result WindowManager::api_get_display_info() json_object_object_add(object, kKeyHeightPixel, json_object_new_int(o_size.h)); json_object_object_add(object, kKeyWidthMm, json_object_new_int(p_size.w)); json_object_object_add(object, kKeyHeightMm, json_object_new_int(p_size.h)); + json_object_object_add(object, kKeyScale, json_object_new_double(this->controller->scale)); return Ok(object); } @@ -573,6 +575,8 @@ void WindowManager::send_event(char const *evname, char const *label, char const */ void WindowManager::surface_created(uint32_t surface_id) { + this->controller->get_surface_properties(surface_id, IVI_WM_PARAM_SIZE); + auto layer_id = this->layers.get_layer_id(surface_id); if (!layer_id) { @@ -617,6 +621,70 @@ void WindowManager::timerHandler() this->processNextRequest(); } +void WindowManager::onApplicationTerminated(const WMClientCtxt& ctxt) +{ + if(!g_app_list.contains(ctxt.name)) + { + return; + } + struct LayoutState priv; + bool found = false; + auto client = g_app_list.lookUpClient(ctxt.name); + unsigned sid = client->surfaceID(ctxt.role); + if(sid == 0) { + auto pSid = this->id_alloc.lookup(ctxt.role.c_str()); + if(pSid) { + sid = *pSid; + } + } + // reset state + if(sid != 0) + { + auto o_state = *this->layers.get_layout_state(sid); + if (o_state != nullptr) + { + priv = *o_state; + 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_INFO("wm", "delete surfaceID %d", sid); + } + + // Recovery Phase + if(priv.main == sid) + { + HMI_DEBUG("wm", "go to launcher"); + if(ctxt.role != "launcher") + { + // goto launcher + auto pSid = this->id_alloc.lookup("launcher"); + std::string app = g_app_list.getAppID(*pSid, "launcher", &found); + if(found) + { + this->api_activate_surface(app.c_str(), "launcher", kNameAreaDefault, + [](const char*){}); + } + } + } + else if(priv.main != sid && priv.sub != sid) + { + // re-show top surface + this->deactivate(priv.main); + this->activate(priv.main); + this->layout_commit(); + } + else {} + g_app_list.removeClient(ctxt.name); +} + /* ******* Private Functions ******* */ @@ -665,6 +733,21 @@ int WindowManager::init_layers() c->physical_size = compositor::size{uint32_t(o->physical_width), uint32_t(o->physical_height)}; + + HMI_DEBUG("wm", "SCALING: screen (%dx%d), physical (%dx%d)", + o->width, o->height, o->physical_width, o->physical_height); + + this->layers.loadAreaDb(); + + const compositor::rect css_bg = this->layers.getAreaSize("fullscreen"); + rectangle dp_bg(o->width, o->height); + + dp_bg.set_aspect(static_cast(css_bg.w) / css_bg.h); + dp_bg.fit(o->width, o->height); + dp_bg.center(o->width, o->height); + HMI_DEBUG("wm", "SCALING: CSS BG(%dx%d) -> DDP %dx%d,(%dx%d)", + css_bg.w, css_bg.h, dp_bg.left(), dp_bg.top(), dp_bg.width(), dp_bg.height()); + // Clear scene layers.clear(); @@ -674,9 +757,9 @@ int WindowManager::init_layers() // Quick and dirty setup of layers for (auto const &i : this->layers.mapping) { - c->layer_create(i.second.layer_id, o->width, o->height); + c->layer_create(i.second.layer_id, dp_bg.width(), dp_bg.height()); auto &l = layers[i.second.layer_id]; - l->set_destination_rectangle(0, 0, o->width, o->height); + l->set_destination_rectangle(dp_bg.left(), dp_bg.top(), dp_bg.width(), dp_bg.height()); l->set_visibility(1); HMI_DEBUG("wm", "Setting up layer %s (%d) for surface role match \"%s\"", i.second.name.c_str(), i.second.layer_id, i.second.role.c_str()); @@ -687,8 +770,8 @@ int WindowManager::init_layers() this->layout_commit(); - this->layers.loadAreaDb(); - this->layers.setupArea(o->width, o->height); + c->scale = static_cast(dp_bg.height()) / css_bg.h; + this->layers.setupArea(c->scale); return 0; } @@ -726,8 +809,6 @@ void WindowManager::surface_set_layout(int surface_id, const std::string& area) layer_id); // set destination to the display rectangle - s->set_source_rectangle(0, 0, w, h); - this->layout_commit(); s->set_destination_rectangle(x, y, w, h); // update area information @@ -1276,6 +1357,7 @@ WMError WindowManager::doEndDraw(unsigned req_num) HMI_SEQ_DEBUG(req_num, "visible %s", act.role.c_str()); //this->lm_enddraw(act.role.c_str()); } + this->layout_commit(); // Change current state this->changeCurrentState(req_num); @@ -1755,12 +1837,12 @@ const char* WindowManager::kDefaultOldRoleDb = "{ \ */ void controller_hooks::surface_created(uint32_t surface_id) { - this->app->surface_created(surface_id); + this->wmgr->surface_created(surface_id); } void controller_hooks::surface_removed(uint32_t surface_id) { - this->app->surface_removed(surface_id); + this->wmgr->surface_removed(surface_id); } void controller_hooks::surface_visibility(uint32_t /*surface_id*/,