X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fapp.cpp;h=05f8b6497b090b9fbda7254fc6d3bd0ddcda6f93;hb=f509e0a79eef109e77532b9e391f07609e296b87;hp=d5fa3b45ea0d6e245fb679065ced4ccd815cef1e;hpb=76a933a557531b92d2802c4fbae8205bb8d68faf;p=apps%2Fagl-service-windowmanager.git diff --git a/src/app.cpp b/src/app.cpp index d5fa3b4..05f8b64 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -95,12 +95,18 @@ struct result load_layer_map(char const *filename) { namespace rm { App *context; -static void eventHandler(json_object* json_out) { - context->updateWindowResource(json_out); +static void onStateTransitioned(json_object* json_out) { + context->updateWindowResources(json_out); +} + +static void onError(json_object* json_out) { + HMI_DEBUG("wm", "error message from PolicyManager:%s", + json_object_get_string(json_out)); } } // namespace rm -void App::updateWindowResource(json_object* json_out) { + +void App::updateCarStates(json_object* json_out) { // Check parking brake state json_object* json_parking_brake; if (!json_object_object_get_ex(json_out, "parking_brake", &json_parking_brake)) { @@ -238,7 +244,9 @@ void App::updateWindowResource(json_object* json_out) { return; } } +} +void App::updateLayers(json_object* json_out) { // Get displayed roles from current layout json_object* json_layers; if (!json_object_object_get_ex(json_out, "layers", &json_layers)) { @@ -320,6 +328,13 @@ void App::updateWindowResource(json_object* json_out) { } } +void App::updateWindowResources(json_object* json_out) { + // Update car states + this->updateCarStates(json_out); + + // Update layers + this->updateLayers(json_out); +} /** * App Impl @@ -379,8 +394,8 @@ int App::init() { // Register callback to PolicyManager PolicyManager::CallbackTable callback; - callback.onStateTransitioned = rm::eventHandler; - callback.onError = nullptr; + callback.onStateTransitioned = rm::onStateTransitioned; + callback.onError = rm::onError; this->pm_.registerCallback(callback); // Initialize LayoutManager @@ -620,10 +635,12 @@ void App::api_enddraw(char const *drawing_name) { for (unsigned i = 0, iend = this->pending_end_draw.size(); i < iend; i++) { auto n = this->lookup_name(this->pending_end_draw[i]); + int surface_id = this->pending_end_draw[i]; + if (n && *n == role) { std::swap(this->pending_end_draw[i], this->pending_end_draw[iend - 1]); this->pending_end_draw.resize(iend - 1); - this->activate(this->pending_end_draw[i]); + this->activate(surface_id); this->emit_flushdraw(drawing_name); } } @@ -813,9 +830,6 @@ result App::api_request_surface(char const *drawing_name) { HMI_DEBUG("wm", "Set main_surface id to %u", id); } - // Set map of (role, surface_id) - this->role2surfaceid_[role] = id; - // Set map of (role, drawing_name) this->role2drawingname_[role] = std::string(drawing_name); @@ -1047,22 +1061,21 @@ void App::setSurfaceSize(const char* role, const char* area) { compositor::rect size = this->lm_.getAreaSize(area); // Set destination to the display rectangle - int surface_id = this->role2surfaceid_[role]; - - if (!this->controller->surface_exists(surface_id)) { + auto const &surface_id = this->lookup_id(role); + if (!this->controller->surface_exists(*surface_id)) { // Block until all pending request are processed by wayland display server // because waiting for the surface of new app is created this->display->roundtrip(); } - auto &s = this->controller->surfaces[surface_id]; + auto &s = this->controller->surfaces[*surface_id]; s->set_destination_rectangle(size.x, size.y, size.w, size.h); this->layout_commit(); // Update area information - this->area_info[surface_id].x = size.x; - this->area_info[surface_id].y = size.y; - this->area_info[surface_id].w = size.w; - this->area_info[surface_id].h = size.h; + this->area_info[*surface_id].x = size.x; + this->area_info[*surface_id].y = size.y; + this->area_info[*surface_id].w = size.w; + this->area_info[*surface_id].h = size.h; HMI_DEBUG("wm", "Surface rect { %d, %d, %d, %d }", size.x, size.y, size.w, size.h); @@ -1072,7 +1085,7 @@ void App::setSurfaceSize(const char* role, const char* area) { size.x, size.y, size.w, size.h); // Enqueue flushDraw event - this->enqueue_flushdraw(surface_id); + this->enqueue_flushdraw(*surface_id); } void App::setAccelPedalPos(double val) {