X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fwm_layer_control.cpp;h=cf82a6b6b343796b71e7f9db502b5038cfd92b77;hb=4449e5dc147527c669fc9d4dd8946e8420a2ca75;hp=30c37f90093e7c0a80f6f10511ca5029b149987e;hpb=92cbe39df7b53208e15bea19e523570be915cf1e;p=apps%2Fagl-service-windowmanager.git diff --git a/src/wm_layer_control.cpp b/src/wm_layer_control.cpp index 30c37f9..cf82a6b 100644 --- a/src/wm_layer_control.cpp +++ b/src/wm_layer_control.cpp @@ -46,14 +46,14 @@ static void surfaceCallback_static(t_ilm_surface surface, struct ilmSurfaceProperties* surface_prop, t_ilm_notification_mask mask) { - g_lc_ctxt->dispatchPropertyChangeEvent(surface, surface_prop, mask); + g_lc_ctxt->dispatchSurfacePropChangeEvent(surface, surface_prop, mask); } static void layerCallback_static(t_ilm_layer layer, struct ilmLayerProperties* layer_prop, t_ilm_notification_mask mask) { - g_lc_ctxt->dispatchPropertyChangeEvent(layer, layer_prop, mask); + g_lc_ctxt->dispatchLayerPropChangeEvent(layer, layer_prop, mask); } LayerControl::LayerControl(const std::string& root) @@ -63,7 +63,7 @@ LayerControl::LayerControl(const std::string& root) // load layers.setting.json WMError ret = this->loadLayerSetting(layer_path); assert(ret == WMError::SUCCESS); - // load area.db + // load areas.json ret = this->loadAreaDb(area_path); assert(ret == WMError::SUCCESS); } @@ -106,7 +106,7 @@ WMError LayerControl::init(const LayerControlCallbacks& cb) if(rc != ILM_SUCCESS) goto lc_init_error; - // Register Callback from ILM + // Register Callback to Window Manager and from ILM this->cb = cb; ilm_registerNotification(createCallback_static, this); @@ -124,7 +124,7 @@ void LayerControl::createNewLayer(unsigned id) struct rect rct = this->area2size[LC_DEFAULT_AREA]; ilm_layerCreateWithDimension(&id, rct.w, rct.h); //ilm_layerSetSourceRectangle(id, rct.x, rct.y, rct.w, rct.h); - //ilm_layerSetDestinationRectangle(id, rct.x, rct.y, rct.w, rct.h); + ilm_layerSetDestinationRectangle(id, this->offset_x, this->offset_y, rct.w, rct.h); ilm_layerSetOpacity(id, 1.0); ilm_layerSetVisibility(id, ILM_FALSE); ilm_commitChanges(); @@ -175,17 +175,14 @@ struct rect LayerControl::getAreaSize(const std::string& area) void LayerControl::setupArea(const rectangle& base_rct, double scaling) { - struct rect rct; this->scaling = scaling; - - rct = this->area2size["normal.full"]; - this->area2size["normalfull"] = rct; - this->area2size["normal"] = rct; + this->offset_x = base_rct.left(); + this->offset_y = base_rct.top(); for (auto &i : this->area2size) { - i.second.x = base_rct.left() + static_cast(scaling * i.second.x + 0.5); - i.second.y = base_rct.top() + static_cast(scaling * i.second.y + 0.5); + i.second.x = static_cast(scaling * i.second.x + 0.5); + i.second.y = static_cast(scaling * i.second.y + 0.5); i.second.w = static_cast(scaling * i.second.w + 0.5); i.second.h = static_cast(scaling * i.second.h + 0.5); @@ -261,6 +258,21 @@ WMError LayerControl::renderLayers() return rc; } +WMError LayerControl::setXDGSurfaceOriginSize(unsigned surface) +{ + WMError ret = WMError::NOT_REGISTERED; + ilmSurfaceProperties prop; + ilmErrorTypes rc = ilm_getPropertiesOfSurface(surface, &prop); + if(rc == ILM_SUCCESS) + { + HMI_INFO("xdg surface info %d, %d", prop.origSourceWidth, prop.origSourceHeight); + ilm_surfaceSetSourceRectangle(surface, 0, 0, prop.origSourceWidth, prop.origSourceHeight); + ret = WMError::SUCCESS; + } + return ret; +} + + void LayerControl::undoUpdate() { for(auto& l : this->wm_layers) @@ -277,7 +289,7 @@ WMError LayerControl::loadLayerSetting(const string &path) int ret = jh::inputJsonFilie(path.c_str(), &json_obj); if (0 > ret) { - HMI_DEBUG("Could not open %s, so use default area information", path.c_str()); + HMI_ERROR("Could not open %s", path.c_str()); return WMError::FAIL; } HMI_INFO("json_obj dump:%s", json_object_get_string(json_obj)); @@ -310,7 +322,7 @@ WMError LayerControl::loadAreaDb(const std::string& path) int ret = jh::inputJsonFilie(path.c_str(), &json_obj); if (0 > ret) { - HMI_DEBUG("Could not open %s, so use default area information", path.c_str()); + HMI_ERROR("Could not open %s", path.c_str()); return WMError::FAIL; } HMI_INFO("json_obj dump:%s", json_object_get_string(json_obj)); @@ -384,17 +396,16 @@ WMError LayerControl::layoutChange(const WMAction& action) return WMError::NOT_REGISTERED; } unsigned layer = action.client->layerID(); + unsigned surface = action.client->surfaceID(); - // Layout Manager - // WMError ret = this->setLayerSize(layer, action.area); auto rect = this->getAreaSize(action.area); HMI_DEBUG("Set layout %d, %d, %d, %d",rect.x, rect.y, rect.w, rect.h); - ilm_layerSetSourceRectangle(layer, 0, 0, rect.w, rect.h); ilm_commitChanges(); - ilm_layerSetDestinationRectangle(layer, rect.x, rect.y, rect.w, rect.h); + ilm_surfaceSetDestinationRectangle(surface, rect.x, rect.y, rect.w, rect.h); ilm_commitChanges(); for(auto &wm_layer: this->wm_layers) { + // Store the state who is assigned to the area if(wm_layer->hasLayerID(layer)) { wm_layer->setAreaToState(action.client->appID(), action.area); @@ -446,7 +457,10 @@ void LayerControl::dispatchCreateEvent(ilmObjectType object, unsigned id, bool c ilmErrorTypes rc; rc = ilm_getPropertiesOfSurface(id, &sp); if(rc != ILM_SUCCESS) + { + HMI_ERROR("Failed to get surface %d property due to %d", id, ilm_getError()); return; + } this->cb.surfaceCreated(sp.creatorPid, id); ilm_surfaceAddNotification(id, surfaceCallback_static); ilm_surfaceSetVisibility(id, ILM_TRUE); @@ -461,138 +475,67 @@ void LayerControl::dispatchCreateEvent(ilmObjectType object, unsigned id, bool c if(created) { ilm_layerAddNotification(id, layerCallback_static); - // this->cb->layerCreated(id); } else { - // this->cb->layerDestroyed(id); // Means Application is dead. + // Ignore here. Nothing to do currently. + // Process of application dead is handled by Window Manager + // from binder notification } } } -void LayerControl::dispatchPropertyChangeEvent(unsigned id, +void LayerControl::dispatchSurfacePropChangeEvent(unsigned id, struct ilmSurfaceProperties* sprop, t_ilm_notification_mask mask) { - pid_t pid = sprop->creatorPid; - HMI_DEBUG("pid : %d", pid); - + /* + ILM_NOTIFICATION_CONTENT_AVAILABLE & ILM_NOTIFICATION_CONTENT_REMOVED + are not handled here, handled in create/destroy event + */ if (ILM_NOTIFICATION_VISIBILITY & mask) { - //this->cb->surfaceVisibilityChanged(id, sprop->visibility); + HMI_DEBUG("surface %d turns visibility %d", id, sprop->visibility); } if (ILM_NOTIFICATION_OPACITY & mask) { - } - if (ILM_NOTIFICATION_ORIENTATION & mask) - { + HMI_DEBUG("surface %d turns opacity %f", id, sprop->opacity); } if (ILM_NOTIFICATION_SOURCE_RECT & mask) { - // this->cb->surfaceSourceRectChanged(id, ) + HMI_DEBUG("surface %d source rect changes", id); } if (ILM_NOTIFICATION_DEST_RECT & mask) { - // this->cb->surfaceSourceRectChanged(id, ) - } - if (ILM_NOTIFICATION_CONTENT_AVAILABLE & mask) - { - } - if (ILM_NOTIFICATION_CONTENT_REMOVED & mask) - { - /* application being down */ - // m_appLayers.remove(pid); + HMI_DEBUG("surface %d dest rect changes", id); } if (ILM_NOTIFICATION_CONFIGURED & mask) { - HMI_DEBUG("surface %d available", id); + HMI_DEBUG("surface %d size %d, %d, %d, %d", id, + sprop->sourceX, sprop->sourceY, sprop->origSourceWidth, sprop->origSourceHeight); ilm_surfaceSetSourceRectangle(id, 0, 0, sprop->origSourceWidth, sprop->origSourceHeight); - ilm_surfaceSetDestinationRectangle(id, 0, 0, sprop->origSourceWidth, sprop->origSourceHeight); - /* qDebug("ILM_NOTIFICATION_CONFIGURED"); - qDebug(" surfaceProperties %d", surface); - qDebug(" surfaceProperties.origSourceWidth: %d", surfaceProperties->origSourceWidth); - qDebug(" surfaceProperties.origSourceHeight: %d", surfaceProperties->origSourceHeight); - - if (surface == WINDOWMANAGER_HOMESCREEN_MAIN_SURFACE_ID) { - addSurfaceToLayer(surface, WINDOWMANAGER_LAYER_HOMESCREEN); - configureHomeScreenMainSurface(surface, surfaceProperties->origSourceWidth, surfaceProperties->origSourceHeight); - } else { - ilmErrorTypes result; - t_ilm_layer layer = addSurfaceToAppLayer(pid, surface); - - if (layer != 0) { - configureAppSurface(surface, - surfaceProperties->origSourceWidth, - surfaceProperties->origSourceHeight); - - result = ilm_layerAddSurface(layer, surface); - if (result != ILM_SUCCESS) { - qDebug("ilm_layerAddSurface(%d,%d) failed.", layer, surface); - } - ilm_commitChanges(); - } - } - updateScreen(); */ } } -void LayerControl::dispatchPropertyChangeEvent(unsigned id, +void LayerControl::dispatchLayerPropChangeEvent(unsigned id, struct ilmLayerProperties* lprop, t_ilm_notification_mask mask) { if (ILM_NOTIFICATION_VISIBILITY & mask) { - //this->cb->layerVisibilityChanged(id, sprop->visibility); + HMI_DEBUG("layer %d turns visibility %d", id, lprop->visibility); } if (ILM_NOTIFICATION_OPACITY & mask) { - } - if (ILM_NOTIFICATION_ORIENTATION & mask) - { + HMI_DEBUG("layer %d turns opacity %f", id, lprop->opacity); } if (ILM_NOTIFICATION_SOURCE_RECT & mask) { - // this->cb->surfaceSourceRectChanged(id, ) + HMI_DEBUG("layer %d source rect changes", id); } if (ILM_NOTIFICATION_DEST_RECT & mask) { - // this->cb->surfaceSourceRectChanged(id, ) - } - if (ILM_NOTIFICATION_CONTENT_AVAILABLE & mask) - { - } - if (ILM_NOTIFICATION_CONTENT_REMOVED & mask) - { - /* application being down */ - // m_appLayers.remove(pid); - } - if (ILM_NOTIFICATION_CONFIGURED & mask) - { - /* qDebug("ILM_NOTIFICATION_CONFIGURED"); - qDebug(" surfaceProperties %d", surface); - qDebug(" surfaceProperties.origSourceWidth: %d", surfaceProperties->origSourceWidth); - qDebug(" surfaceProperties.origSourceHeight: %d", surfaceProperties->origSourceHeight); - - if (surface == WINDOWMANAGER_HOMESCREEN_MAIN_SURFACE_ID) { - addSurfaceToLayer(surface, WINDOWMANAGER_LAYER_HOMESCREEN); - configureHomeScreenMainSurface(surface, surfaceProperties->origSourceWidth, surfaceProperties->origSourceHeight); - } else { - ilmErrorTypes result; - t_ilm_layer layer = addSurfaceToAppLayer(pid, surface); - - if (layer != 0) { - configureAppSurface(surface, - surfaceProperties->origSourceWidth, - surfaceProperties->origSourceHeight); - - result = ilm_layerAddSurface(layer, surface); - if (result != ILM_SUCCESS) { - qDebug("ilm_layerAddSurface(%d,%d) failed.", layer, surface); - } - ilm_commitChanges(); - } - } - updateScreen(); */ + HMI_DEBUG("layer %d dest rect changes", id); } }