X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fwindow_manager.cpp;h=24b6f30d2b3e10babab3660dbec49b16ef576bb9;hb=c1d85371b1eb693128cf9553c356ea77e609d9a3;hp=b35c767d2567f9e2dde0749deeef28e2cf5cd690;hpb=99b6f4d2fcd421d3a760a88a67e511fb6fc98068;p=apps%2Fagl-service-windowmanager.git diff --git a/src/window_manager.cpp b/src/window_manager.cpp index b35c767..24b6f30 100644 --- a/src/window_manager.cpp +++ b/src/window_manager.cpp @@ -19,7 +19,6 @@ #include "window_manager.hpp" #include "json_helper.hpp" -#include "wm_config.hpp" #include "applist.hpp" extern "C" @@ -30,7 +29,7 @@ extern "C" namespace wm { -static const unsigned kTimeOut = 3000000UL; /* 3s */ +static const uint64_t kTimeOut = 3ULL; /* 3s */ /* DrawingArea name used by "{layout}.{area}" */ const char kNameLayoutNormal[] = "normal"; @@ -51,6 +50,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; @@ -157,7 +157,6 @@ WindowManager::WindowManager(wl::display *d) int WindowManager::init() { - int ret; if (!this->display->ok()) { return -1; @@ -204,12 +203,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; @@ -222,8 +221,7 @@ int WindowManager::init() // Third level objects this->display->roundtrip(); - ret = init_layers(); - return ret; + return init_layers(); } int WindowManager::dispatch_pending_events() @@ -257,7 +255,7 @@ result WindowManager::api_request_surface(char const *appid, char const *dr HMI_DEBUG("wm", "%s is not registered in layers.json, then fallback as normal app", role); if (!lid) { - return Err("Drawing name does not match any role, Fallback is disabled"); + return Err("Drawing name does not match any role, fallback is disabled"); } } @@ -311,7 +309,7 @@ char const *WindowManager::api_request_surface(char const *appid, char const *dr HMI_DEBUG("wm", "%s is not registered in layers.json, then fallback as normal app", role); if (!lid) { - return "Drawing name does not match any role, Fallback is disabled"; + return "Drawing name does not match any role, fallback is disabled"; } } @@ -485,10 +483,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 @@ -500,6 +497,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); } @@ -586,6 +584,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) { @@ -602,7 +602,9 @@ void WindowManager::surface_created(uint32_t surface_id) void WindowManager::surface_removed(uint32_t surface_id) { - HMI_DEBUG("wm", "surface_id is %u", surface_id); + HMI_DEBUG("wm", "Delete surface_id %u", surface_id); + this->id_alloc.remove_id(surface_id); + this->layers.remove_surface(surface_id); g_app_list.removeSurface(surface_id); } @@ -658,7 +660,17 @@ void WindowManager::startTransitionWrapper(std::vector &actions) std::string appid = g_app_list.getAppID(*surface_id, act.role, &found); if (!found) { - goto error; + if (TaskVisible::INVISIBLE == act.visible) + { + // App is killed, so do not set this action + continue; + } + else + { + HMI_SEQ_ERROR(req_num, "appid which is visible is not found"); + ret = WMError::FAIL; + goto error; + } } act.appid = appid; } @@ -666,6 +678,7 @@ void WindowManager::startTransitionWrapper(std::vector &actions) ret = g_app_list.setAction(req_num, act); if (ret != WMError::SUCCESS) { + HMI_SEQ_ERROR(req_num, "Setting action is failed"); goto error; } } @@ -680,6 +693,7 @@ void WindowManager::startTransitionWrapper(std::vector &actions) } else { + HMI_SEQ_ERROR(req_num, "Transition state is failed"); goto error; } } @@ -743,27 +757,32 @@ int WindowManager::init_layers() return -1; } - WMConfig wm_config; - wm_config.loadConfigs(); - auto &c = this->controller; auto &o = this->outputs.front(); auto &s = c->screens.begin()->second; auto &layers = c->layers; - this->layers.loadAreaDb(); - const compositor::rect base = this->layers.getAreaSize("fullscreen"); - - const std::string aspect_setting = wm_config.getConfigAspect(); - const compositor::rect scale_rect = - this->layers.getScaleDestRect(o->width, o->height, aspect_setting); - // Write output dimensions to ivi controller... c->output_size = compositor::size{uint32_t(o->width), uint32_t(o->height)}; 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(); @@ -773,11 +792,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, scale_rect.w, scale_rect.h); + c->layer_create(i.second.layer_id, dp_bg.width(), dp_bg.height()); auto &l = layers[i.second.layer_id]; - l->set_source_rectangle(0, 0, base.w, base.h); - l->set_destination_rectangle( - scale_rect.x, scale_rect.y, scale_rect.w, scale_rect.h); + 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()); @@ -788,6 +805,9 @@ int WindowManager::init_layers() this->layout_commit(); + c->scale = static_cast(dp_bg.height()) / css_bg.h; + this->layers.setupArea(c->scale); + return 0; } @@ -1160,6 +1180,7 @@ WMError WindowManager::doEndDraw(unsigned req_num) //this->lm_enddraw(act.role.c_str()); } } + this->layout_commit(); HMI_SEQ_INFO(req_num, "emit flushDraw"); @@ -1258,17 +1279,22 @@ void WindowManager::emitScreenUpdated(unsigned req_num) { HMI_DEBUG("wm", "afb_event_push failed: %m"); } - json_object_put(jarray); } void WindowManager::setTimer() { + struct timespec ts; + if (clock_gettime(CLOCK_BOOTTIME, &ts) != 0) { + HMI_ERROR("wm", "Could't set time (clock_gettime() returns with error"); + return; + } + HMI_SEQ_DEBUG(g_app_list.currentRequestNumber(), "Timer set activate"); if (g_timer_ev_src == nullptr) { // firsttime set into sd_event int ret = sd_event_add_time(afb_daemon_get_event_loop(), &g_timer_ev_src, - CLOCK_REALTIME, time(NULL) * (1000000UL) + kTimeOut, 1, processTimerHandler, this); + CLOCK_BOOTTIME, (uint64_t)(ts.tv_sec + kTimeOut) * 1000000ULL, 1, processTimerHandler, this); if (ret < 0) { HMI_ERROR("wm", "Could't set timer"); @@ -1277,7 +1303,7 @@ void WindowManager::setTimer() else { // update timer limitation after second time - sd_event_source_set_time(g_timer_ev_src, time(NULL) * (1000000UL) + kTimeOut); + sd_event_source_set_time(g_timer_ev_src, (uint64_t)(ts.tv_sec + kTimeOut) * 1000000ULL); sd_event_source_set_enabled(g_timer_ev_src, SD_EVENT_ONESHOT); } } @@ -1510,12 +1536,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*/,