X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=WindowManager%2Fsrc%2Fwindowmanager.cpp;h=101f5b39c1b141c85e476ecb95116ac7b88ffa3f;hb=36f4818cb31b406715ec0d52a2075611ec6fcdff;hp=3c5c8817a54da462a7861dd90db7596e49606d02;hpb=2044d95f928fa42beaa00f9cb30816b1f6f63552;p=staging%2FHomeScreen.git diff --git a/WindowManager/src/windowmanager.cpp b/WindowManager/src/windowmanager.cpp index 3c5c881..101f5b3 100644 --- a/WindowManager/src/windowmanager.cpp +++ b/WindowManager/src/windowmanager.cpp @@ -15,8 +15,7 @@ */ #include "windowmanager.hpp" -#include -#include + ////////////////////////////////////////// // THIS IS STILL UNDER HEAVY DEVELOPMENT! @@ -32,60 +31,102 @@ #define WINDOWMANAGER_LAYER_APPLICATIONS 102 #define WINDOWMANAGER_LAYER_HOMESCREEN 103 -#define WINDOWMANAGER_LAYER_NUM 3 +#define WINDOWMANAGER_LAYER_NUM 4 + +#define WINDOWMANAGER_LAYER_ID_SHIFT 22 // the HomeScreen app has to have the surface id 1000 #define WINDOWMANAGER_HOMESCREEN_MAIN_SURFACE_ID 1000 - void* WindowManager::myThis = 0; WindowManager::WindowManager(QObject *parent) : QObject(parent), m_layouts(), - m_surfaces(), + // m_appSurfaces(), mp_layoutAreaToSurfaceIdAssignment(0), - m_currentLayout(-1) + m_currentLayout(-1), + m_screenId(0), // use screen "0" + m_screenWidth(0), + m_screenHeight(0) +#ifdef HAVE_IVI_LAYERMANAGEMENT_API + , + m_appLayers(), + m_pending_to_show(-1) +#endif { - qDebug("-=[WindowManager]=-"); - // publish windowmanager interface - mp_windowManagerAdaptor = new WindowmanagerAdaptor((QObject*)this); +#ifdef HAVE_IVI_LAYERMANAGEMENT_API + m_showLayers = new t_ilm_layer[WINDOWMANAGER_LAYER_NUM]; - QDBusConnection dbus = QDBusConnection::sessionBus(); - dbus.registerObject("/windowmanager", this); - dbus.registerService("org.agl.windowmanager"); + m_showLayers[0] = 0; /* POPUP is not shown by default */ + m_showLayers[1] = 0; /* HOMESCREEN_OVERLAY is not shown by default */ + m_showLayers[2] = 0; /* APPLICATIONS is not shown by default */ + m_showLayers[3] = WINDOWMANAGER_LAYER_HOMESCREEN; /* HOMESCREEN is shwon by default */ + +#endif + qDebug("-=[WindowManager]=-"); } void WindowManager::start() { qDebug("-=[start]=-"); mp_layoutAreaToSurfaceIdAssignment = new QMap; -#ifdef __arm__ +#ifdef HAVE_IVI_LAYERMANAGEMENT_API ilmErrorTypes err; err = ilm_init(); qDebug("ilm_init = %d", err); + if(ILM_SUCCESS != err) + { + qDebug("failed! Exiting!"); + exit(-1); + } myThis = this; - err = ilm_registerNotification(WindowManager::notificationFunc_static, this); + + ilm_getScreenResolution(m_screenId, &m_screenWidth, &m_screenHeight); createNewLayer(WINDOWMANAGER_LAYER_POPUP); createNewLayer(WINDOWMANAGER_LAYER_HOMESCREEN_OVERLAY); - createNewLayer(WINDOWMANAGER_LAYER_APPLICATIONS); +// createNewLayer(WINDOWMANAGER_LAYER_APPLICATIONS); createNewLayer(WINDOWMANAGER_LAYER_HOMESCREEN); + + ilm_registerNotification(WindowManager::notificationFunc_static, this); #endif + + QDBusConnection dbus = QDBusConnection::sessionBus(); + dbus.registerObject("/windowmanager", this); + dbus.registerService("org.agl.windowmanager"); + + // publish windowmanager interface + mp_windowManagerAdaptor = new WindowmanagerAdaptor((QObject*)this); } WindowManager::~WindowManager() { qDebug("-=[~WindowManager]=-"); delete mp_windowManagerAdaptor; -#ifdef __arm__ +#ifdef HAVE_IVI_LAYERMANAGEMENT_API ilm_destroy(); #endif delete mp_layoutAreaToSurfaceIdAssignment; } +#ifdef HAVE_IVI_LAYERMANAGEMENT_API +int WindowManager::getLayerRenderOrder(t_ilm_layer id_array[]) +{ + int i, j; + + for (i = WINDOWMANAGER_LAYER_NUM - 1, j = 0; i >= 0; i--, j++) { + if (m_showLayers[i] != 0) { + id_array[j] = m_showLayers[i]; + } + } + + return j; +} +#endif + void WindowManager::dumpScene() { qDebug("\n"); @@ -110,90 +151,114 @@ void WindowManager::dumpScene() } } -#ifdef __arm__ +#ifdef HAVE_IVI_LAYERMANAGEMENT_API void WindowManager::createNewLayer(int layerId) { qDebug("-=[createNewLayer]=-"); - qDebug("layerId %d", layerId); - - t_ilm_uint screenID = 0; - t_ilm_uint width; - t_ilm_uint height; - - ilm_getScreenResolution(screenID, &width, &height); + qDebug(" layerId %d", layerId); t_ilm_layer newLayerId = layerId; - ilm_layerCreateWithDimension(&newLayerId, width, height); + ilm_layerCreateWithDimension(&newLayerId, m_screenWidth, m_screenHeight); ilm_layerSetOpacity(newLayerId, 1.0); ilm_layerSetVisibility(newLayerId, ILM_TRUE); ilm_layerSetSourceRectangle(newLayerId, 0, 0, - width, - height); + m_screenWidth, + m_screenHeight); ilm_layerSetDestinationRectangle(newLayerId, 0, 0, - width, - height); + m_screenWidth, + m_screenHeight); ilm_commitChanges(); } +t_ilm_layer WindowManager::getAppLayerID(pid_t pid) +{ + t_ilm_layer layer_id; + +// layer_id = pid + (WINDOWMANAGER_LAYER_APPLICATIONS << WINDOWMANAGER_LAYER_ID_SHIFT); + layer_id = pid + (WINDOWMANAGER_LAYER_APPLICATIONS * 100000); /* for debug */ + + return layer_id; +} + +void WindowManager::addSurfaceToAppLayer(int surfaceId) +{ + struct ilmSurfaceProperties surfaceProperties; + t_ilm_layer layer_id; + int found = 0; + pid_t pid; + + qDebug("-=[addSurfaceToAppLayer]=-"); + qDebug(" surfaceId %d", surfaceId); + + ilm_getPropertiesOfSurface(surfaceId, &surfaceProperties); + pid = surfaceProperties.creatorPid; + + if (pid < 0) { + /* No process */ + qDebug("addSurfaceToAppLayer(%d) got pid == -1", surfaceId); + return; + } + + QMap::const_iterator i = m_appLayers.find(pid); + if (i == m_appLayers.end()) { + qDebug("No layer found, create new for app(pid=%d)", pid); + + /* not found, create new one */ + t_ilm_layer layer_id = getAppLayerID(pid); + + createNewLayer(layer_id); + m_appLayers.insert(pid, layer_id); + } +} + void WindowManager::addSurfaceToLayer(int surfaceId, int layerId) { qDebug("-=[addSurfaceToLayer]=-"); - qDebug("surfaceId %d", surfaceId); - qDebug("layerId %d", layerId); + qDebug(" surfaceId %d", surfaceId); + qDebug(" layerId %d", layerId); if (layerId == WINDOWMANAGER_LAYER_HOMESCREEN) { struct ilmSurfaceProperties surfaceProperties; ilm_getPropertiesOfSurface(surfaceId, &surfaceProperties); - qDebug("sourceX %d", surfaceProperties.sourceX); - qDebug("sourceY %d", surfaceProperties.sourceY); - qDebug("sourceWidth %d", surfaceProperties.sourceWidth); - qDebug("sourceHeight %d", surfaceProperties.sourceHeight); - // homescreen app always fullscreen in the back - t_ilm_uint screenID = 0; - t_ilm_uint width; - t_ilm_uint height; - - ilm_getScreenResolution(screenID, &width, &height); - - ilm_surfaceSetDestinationRectangle(surfaceId, 0, 0, width, height); - ilm_surfaceSetSourceRectangle(surfaceId, 0, 0, width, height); + ilm_surfaceSetDestinationRectangle(surfaceId, 0, 0, m_screenWidth, m_screenHeight); + //ilm_surfaceSetSourceRectangle(surfaceId, 0, 0, m_screenWidth, m_screenHeight); ilm_surfaceSetOpacity(surfaceId, 1.0); ilm_surfaceSetVisibility(surfaceId, ILM_TRUE); ilm_layerAddSurface(layerId, surfaceId); } - +#if 0 if (layerId == WINDOWMANAGER_LAYER_APPLICATIONS) { struct ilmSurfaceProperties surfaceProperties; ilm_getPropertiesOfSurface(surfaceId, &surfaceProperties); - ilm_surfaceSetDestinationRectangle(surfaceId, 0, 0, surfaceProperties.origSourceWidth, surfaceProperties.origSourceHeight); - ilm_surfaceSetSourceRectangle(surfaceId, 0, 0, surfaceProperties.origSourceWidth, surfaceProperties.origSourceHeight); - ilm_surfaceSetOpacity(surfaceId, 0.0); - ilm_surfaceSetVisibility(surfaceId, ILM_FALSE); + //ilm_surfaceSetDestinationRectangle(surfaceId, 0, 0, surfaceProperties.origSourceWidth, surfaceProperties.origSourceHeight); + //ilm_surfaceSetSourceRectangle(surfaceId, 0, 0, surfaceProperties.origSourceWidth, surfaceProperties.origSourceHeight); + //ilm_surfaceSetOpacity(surfaceId, 0.0); + //ilm_surfaceSetVisibility(surfaceId, ILM_FALSE); ilm_layerAddSurface(layerId, surfaceId); } - +#endif if (layerId == WINDOWMANAGER_LAYER_HOMESCREEN_OVERLAY) { struct ilmSurfaceProperties surfaceProperties; ilm_getPropertiesOfSurface(surfaceId, &surfaceProperties); - ilm_surfaceSetDestinationRectangle(surfaceId, 0, 0, surfaceProperties.origSourceWidth, surfaceProperties.origSourceHeight); - ilm_surfaceSetSourceRectangle(surfaceId, 0, 0, surfaceProperties.origSourceWidth, surfaceProperties.origSourceHeight); - ilm_surfaceSetOpacity(surfaceId, 0.5); - ilm_surfaceSetVisibility(surfaceId, ILM_TRUE); + //ilm_surfaceSetDestinationRectangle(surfaceId, 0, 0, surfaceProperties.origSourceWidth, surfaceProperties.origSourceHeight); + //ilm_surfaceSetSourceRectangle(surfaceId, 0, 0, surfaceProperties.origSourceWidth, surfaceProperties.origSourceHeight); + //ilm_surfaceSetOpacity(surfaceId, 0.5); + //ilm_surfaceSetVisibility(surfaceId, ILM_TRUE); ilm_layerAddSurface(layerId, surfaceId); } @@ -203,10 +268,10 @@ void WindowManager::addSurfaceToLayer(int surfaceId, int layerId) struct ilmSurfaceProperties surfaceProperties; ilm_getPropertiesOfSurface(surfaceId, &surfaceProperties); - ilm_surfaceSetDestinationRectangle(surfaceId, 0, 0, surfaceProperties.origSourceWidth, surfaceProperties.origSourceHeight); - ilm_surfaceSetSourceRectangle(surfaceId, 0, 0, surfaceProperties.origSourceWidth, surfaceProperties.origSourceHeight); - ilm_surfaceSetOpacity(surfaceId, 0.0); - ilm_surfaceSetVisibility(surfaceId, ILM_FALSE); + //ilm_surfaceSetDestinationRectangle(surfaceId, 0, 0, surfaceProperties.origSourceWidth, surfaceProperties.origSourceHeight); + //ilm_surfaceSetSourceRectangle(surfaceId, 0, 0, surfaceProperties.origSourceWidth, surfaceProperties.origSourceHeight); + //ilm_surfaceSetOpacity(surfaceId, 0.0); + //ilm_surfaceSetVisibility(surfaceId, ILM_FALSE); ilm_layerAddSurface(layerId, surfaceId); } @@ -220,15 +285,17 @@ void WindowManager::updateScreen() { qDebug("-=[updateScreen]=-"); -#ifdef __arm__ +#if 0 +//#ifdef HAVE_IVI_LAYERMANAGEMENT_API if (-1 != m_currentLayout) { - // hide all surfaces - for (int i = 0; i < m_surfaces.size(); ++i) + for (int i = 0; i < m_appSurfaces.size(); ++i) { - ilm_surfaceSetVisibility(m_surfaces.at(i), ILM_FALSE); - ilm_surfaceSetOpacity(m_surfaces.at(i), 0.0); + ilm_layerRemoveSurface(WINDOWMANAGER_LAYER_APPLICATIONS, m_appSurfaces.at(i)); + //ilm_surfaceSetVisibility(m_appSurfaces.at(i), ILM_FALSE); + //ilm_surfaceSetOpacity(m_appSurfaces.at(i), 0.0); + ilm_commitChanges(); } // find the current used layout @@ -251,6 +318,8 @@ void WindowManager::updateScreen() int surfaceToShow = mp_layoutAreaToSurfaceIdAssignment->find(j).value(); qDebug(" surface no. %d: %d", j, surfaceToShow); + addSurfaceToLayer(surfaceToShow, WINDOWMANAGER_LAYER_APPLICATIONS); + ilm_surfaceSetVisibility(surfaceToShow, ILM_TRUE); ilm_surfaceSetOpacity(surfaceToShow, 1.0); @@ -265,25 +334,40 @@ void WindowManager::updateScreen() currentLayout.layoutAreas[j].y, currentLayout.layoutAreas[j].width, currentLayout.layoutAreas[j].height); + ilm_commitChanges(); } - - ilm_commitChanges(); } - t_ilm_layer renderOrder[WINDOWMANAGER_LAYER_NUM]; - renderOrder[0] = WINDOWMANAGER_LAYER_HOMESCREEN; - renderOrder[1] = WINDOWMANAGER_LAYER_APPLICATIONS; - renderOrder[2] = WINDOWMANAGER_LAYER_HOMESCREEN_OVERLAY; - renderOrder[3] = WINDOWMANAGER_LAYER_POPUP; - - ilm_displaySetRenderOrder(0, renderOrder, WINDOWMANAGER_LAYER_NUM); - + // layer surface render order + t_ilm_int length; + t_ilm_surface* pArray; + ilm_getSurfaceIDsOnLayer(WINDOWMANAGER_LAYER_HOMESCREEN, &length, &pArray); + ilm_layerSetRenderOrder(WINDOWMANAGER_LAYER_HOMESCREEN, pArray, length); ilm_commitChanges(); - + ilm_getSurfaceIDsOnLayer(WINDOWMANAGER_LAYER_APPLICATIONS, &length, &pArray); + ilm_layerSetRenderOrder(WINDOWMANAGER_LAYER_APPLICATIONS, pArray, length); + ilm_commitChanges(); + ilm_getSurfaceIDsOnLayer(WINDOWMANAGER_LAYER_HOMESCREEN_OVERLAY, &length, &pArray); + ilm_layerSetRenderOrder(WINDOWMANAGER_LAYER_HOMESCREEN_OVERLAY, pArray, length); + ilm_commitChanges(); + ilm_getSurfaceIDsOnLayer(WINDOWMANAGER_LAYER_POPUP, &length, &pArray); + ilm_layerSetRenderOrder(WINDOWMANAGER_LAYER_POPUP, pArray, length); + ilm_commitChanges(); +#endif +#ifdef HAVE_IVI_LAYERMANAGEMENT_API + if (m_pending_to_show != -1) { + showAppLayer(m_pending_to_show); + } else { + // display layer render order + t_ilm_layer renderOrder[WINDOWMANAGER_LAYER_NUM]; + int num_layers = getLayerRenderOrder(renderOrder); + ilm_displaySetRenderOrder(m_screenId, renderOrder, num_layers); + ilm_commitChanges(); + } #endif } -#ifdef __arm__ +#ifdef HAVE_IVI_LAYERMANAGEMENT_API void WindowManager::notificationFunc_non_static(ilmObjectType object, t_ilm_uint id, t_ilm_bool created) @@ -309,9 +393,9 @@ void WindowManager::notificationFunc_non_static(ilmObjectType object, } else { - addSurfaceToLayer(id, WINDOWMANAGER_LAYER_APPLICATIONS); - - m_surfaces.append(id); + addSurfaceToAppLayer(id); + //addSurfaceToLayer(id, WINDOWMANAGER_LAYER_APPLICATIONS); + //m_appSurfaces.append(id); } ilm_surfaceAddNotification(id, surfaceCallbackFunction_static); @@ -320,10 +404,12 @@ void WindowManager::notificationFunc_non_static(ilmObjectType object, else { qDebug("Surface destroyed, ID: %d", id); - m_surfaces.removeAt(m_surfaces.indexOf(id)); +#if 0 + m_appSurfaces.removeAt(m_appSurfaces.indexOf(id)); ilm_surfaceRemoveNotification(id); ilm_commitChanges(); +#endif } } if (ILM_LAYER == object) @@ -349,7 +435,7 @@ void WindowManager::surfaceCallbackFunction_non_static(t_ilm_surface surface, if (ILM_NOTIFICATION_VISIBILITY & mask) { qDebug("ILM_NOTIFICATION_VISIBILITY"); - surfaceVisibilityChanged(surface, surfaceProperties.visibility); + surfaceVisibilityChanged(surface, surfaceProperties->visibility); } if (ILM_NOTIFICATION_OPACITY & mask) { @@ -370,15 +456,69 @@ void WindowManager::surfaceCallbackFunction_non_static(t_ilm_surface surface, if (ILM_NOTIFICATION_CONTENT_AVAILABLE & mask) { qDebug("ILM_NOTIFICATION_CONTENT_AVAILABLE"); - updateScreen(); + /* add surface to layer for the application */ + + ilmErrorTypes result; + pid_t pid = surfaceProperties->creatorPid; + + QMap::const_iterator i = m_appLayers.find(pid); + if (i != m_appLayers.end()) { + t_ilm_layer layer_id = m_appLayers.value(pid); + + result = ilm_layerAddSurface(layer_id, surface); + + if (result != ILM_SUCCESS) { + qDebug("ilm_layerAddSurface(%d,%d) failed.", layer_id, surface); + } + + /* Dirty hack! cut & paste from HomeScreen/src/layouthandler.cpp */ + const int SCREEN_WIDTH = 1080; + const int SCREEN_HEIGHT = 1920; + + const int TOPAREA_HEIGHT = 218; + const int TOPAREA_WIDTH = SCREEN_WIDTH; + const int TOPAREA_X = 0; + const int TOPAREA_Y = 0; + const int MEDIAAREA_HEIGHT = 215; + const int MEDIAAREA_WIDTH = SCREEN_WIDTH; + const int MEDIAAREA_X = 0; + const int MEDIAAREA_Y = SCREEN_HEIGHT - MEDIAAREA_HEIGHT; + + ilm_surfaceSetDestinationRectangle(surface, + 0, + TOPAREA_HEIGHT, + SCREEN_WIDTH, + SCREEN_HEIGHT - TOPAREA_HEIGHT - MEDIAAREA_HEIGHT); + + ilm_commitChanges(); + } else { + qDebug("No layer for application(pid=%d)", surfaceProperties->creatorPid); + } } if (ILM_NOTIFICATION_CONTENT_REMOVED & mask) { qDebug("ILM_NOTIFICATION_CONTENT_REMOVED"); + + /* application being down */ + m_appLayers.remove(surfaceProperties->creatorPid); + + updateScreen(); } 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); + + ilm_surfaceSetSourceRectangle(surface, + 0, + 0, + surfaceProperties->origSourceWidth, + surfaceProperties->origSourceHeight); + + ilm_surfaceSetVisibility(surface, ILM_TRUE); + updateScreen(); } } @@ -469,23 +609,25 @@ QList WindowManager::getAllLayouts() return m_layouts; } +#if 0 QList WindowManager::getAllSurfacesOfProcess(int pid) { QList result; -#ifdef __arm__ +#ifdef HAVE_IVI_LAYERMANAGEMENT_API struct ilmSurfaceProperties surfaceProperties; - for (int i = 0; i < m_surfaces.size(); ++i) + for (int i = 0; i < m_appSurfaces.size(); ++i) { - ilm_getPropertiesOfSurface(m_surfaces.at(i), &surfaceProperties); + ilm_getPropertiesOfSurface(m_appSurfaces.at(i), &surfaceProperties); if (pid == surfaceProperties.creatorPid) { - result.append(m_surfaces.at(i)); + result.append(m_appSurfaces.at(i)); } } #endif return result; } +#endif QList WindowManager::getAvailableLayouts(int numberOfAppSurfaces) { @@ -506,12 +648,14 @@ QList WindowManager::getAvailableLayouts(int numberOfAppSurfaces) return result; } +#if 0 QList WindowManager::getAvailableSurfaces() { qDebug("-=[getAvailableSurfaces]=-"); - return m_surfaces; + return m_appSurfaces; } +#endif QString WindowManager::getLayoutName(int layoutId) { @@ -537,24 +681,26 @@ void WindowManager::hideLayer(int layer) qDebug("-=[hideLayer]=-"); qDebug("layer %d", layer); -#ifdef __arm__ - if (0 == layer) - { - ilm_layerSetVisibility(WINDOWMANAGER_LAYER_POPUP, ILM_FALSE); - } - if (1 == layer) - { - ilm_layerSetVisibility(WINDOWMANAGER_LAYER_HOMESCREEN_OVERLAY, ILM_FALSE); - } - if (2 == layer) - { - ilm_layerSetVisibility(WINDOWMANAGER_LAYER_APPLICATIONS, ILM_FALSE); - } - if (3 == layer) - { - ilm_layerSetVisibility(WINDOWMANAGER_LAYER_HOMESCREEN, ILM_FALSE); +#ifdef HAVE_IVI_LAYERMANAGEMENT_API + // POPUP=0, HOMESCREEN_OVERLAY=1, APPS=2, HOMESCREEN=3 + if (layer >= 0 && layer < WINDOWMANAGER_LAYER_NUM) { + /* hide target layer */ + m_showLayers[layer] = 0; + + if (layer == WINDOWMANAGER_LAYER_APPLICATIONS) { + /* clear pending flag */ + m_pending_to_show = -1; + } else if (m_pending_to_show != -1) { + /* there is a pending application to show */ + showAppLayer(m_pending_to_show); + return; + } + + t_ilm_layer renderOrder[WINDOWMANAGER_LAYER_NUM]; + int num_layers = getLayerRenderOrder(renderOrder); + ilm_displaySetRenderOrder(m_screenId, renderOrder, num_layers); + ilm_commitChanges(); } - ilm_commitChanges(); #endif } @@ -616,23 +762,58 @@ void WindowManager::showLayer(int layer) qDebug("-=[showLayer]=-"); qDebug("layer %d", layer); -#ifdef __arm__ - if (0 == layer) - { - ilm_layerSetVisibility(WINDOWMANAGER_LAYER_POPUP, ILM_TRUE); - } - if (1 == layer) - { - ilm_layerSetVisibility(WINDOWMANAGER_LAYER_HOMESCREEN_OVERLAY, ILM_TRUE); +#ifdef HAVE_IVI_LAYERMANAGEMENT_API + // POPUP=0, HOMESCREEN_OVERLAY=1, APPS=2, HOMESCREEN=3 + if (layer >= 0 && layer < WINDOWMANAGER_LAYER_NUM) { + static const int layer_id_array[] = { + WINDOWMANAGER_LAYER_POPUP, + WINDOWMANAGER_LAYER_HOMESCREEN_OVERLAY, + WINDOWMANAGER_LAYER_APPLICATIONS, + WINDOWMANAGER_LAYER_HOMESCREEN, + }; + + m_showLayers[layer] = layer_id_array[layer]; + + t_ilm_layer renderOrder[WINDOWMANAGER_LAYER_NUM]; + int num_layers = getLayerRenderOrder(renderOrder); + ilm_displaySetRenderOrder(m_screenId, renderOrder, num_layers); + ilm_commitChanges(); } - if (2 == layer) - { - ilm_layerSetVisibility(WINDOWMANAGER_LAYER_APPLICATIONS, ILM_TRUE); +#endif +} + +void WindowManager::showAppLayer(int pid) +{ + qDebug("-=[showAppLayer]=-"); + qDebug("pid %d", pid); + + if (pid == -1) { + /* nothing to show */ + return; } - if (3 == layer) - { - ilm_layerSetVisibility(WINDOWMANAGER_LAYER_HOMESCREEN, ILM_TRUE); +#ifdef HAVE_IVI_LAYERMANAGEMENT_API + + /* clear pending flag */ + m_pending_to_show = -1; + + /* search layer id for application to show */ + QMap::const_iterator i = m_appLayers.find(pid); + + if (i != m_appLayers.end()) { + m_showLayers[2] = m_appLayers.value(pid); + qDebug("Found layer(%d) to show for app(pid=%d)", m_showLayers[2], pid); + } else { + /* Probably app layer hasn't been made yet */ + m_pending_to_show = pid; + /* hide current app once, back to default screen */ + m_showLayers[2] = 0; + + qDebug("No layer to show for app(pid=%d)", pid); } + t_ilm_layer renderOrder[WINDOWMANAGER_LAYER_NUM]; + + int num_layers = getLayerRenderOrder(renderOrder); + ilm_displaySetRenderOrder(m_screenId, renderOrder, num_layers); ilm_commitChanges(); #endif }