X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=WindowManager%2Fsrc%2Fwindowmanager.cpp;h=0a2a6090eb0f349505582e04efbdb2fc75cce693;hb=7515965e55e112a4228764614bcdd3811ae44dd7;hp=ed38c49138be9861e75d0dc3bc218bb4a1b6a68d;hpb=bf0f33bec5ad705666dff6c821334524c1b81583;p=staging%2FHomeScreen.git diff --git a/WindowManager/src/windowmanager.cpp b/WindowManager/src/windowmanager.cpp index ed38c49..0a2a609 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! @@ -28,62 +27,102 @@ // On top all applications in one layer. // On top of that, the popup layer. #define WINDOWMANAGER_LAYER_POPUP 100 -#define WINDOWMANAGER_LAYER_APPLICATIONS 101 -#define WINDOWMANAGER_LAYER_HOMESCREEN 102 +#define WINDOWMANAGER_LAYER_HOMESCREEN_OVERLAY 101 +#define WINDOWMANAGER_LAYER_APPLICATIONS 102 +#define WINDOWMANAGER_LAYER_HOMESCREEN 103 -#define WINDOWMANAGER_LAYER_NUM 3 +#define WINDOWMANAGER_LAYER_NUM 4 // the HomeScreen app has to have the surface id 1000 #define WINDOWMANAGER_HOMESCREEN_MAIN_SURFACE_ID 1000 - void* WindowManager::myThis = 0; +static const int layer_id_array[] = { + WINDOWMANAGER_LAYER_POPUP, + WINDOWMANAGER_LAYER_HOMESCREEN_OVERLAY, + WINDOWMANAGER_LAYER_APPLICATIONS, + WINDOWMANAGER_LAYER_HOMESCREEN, +}; + 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) { - qDebug("-=[WindowManager]=-"); - // publish windowmanager interface - mp_windowManagerAdaptor = new WindowmanagerAdaptor((QObject*)this); + m_showLayers = new int[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 */ + + 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_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; } +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; +} + void WindowManager::dumpScene() { qDebug("\n"); @@ -108,33 +147,27 @@ 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(); } @@ -142,28 +175,17 @@ void WindowManager::createNewLayer(int layerId) 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); @@ -175,10 +197,23 @@ 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); + } + + 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_layerAddSurface(layerId, surfaceId); } @@ -188,10 +223,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); } @@ -205,15 +240,16 @@ void WindowManager::updateScreen() { qDebug("-=[updateScreen]=-"); -#ifdef __arm__ +#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 @@ -236,6 +272,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); @@ -250,24 +288,36 @@ 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_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(); + // display layer render order + t_ilm_layer renderOrder[WINDOWMANAGER_LAYER_NUM]; + int num_layers = getLayerRenderOrder(renderOrder); + ilm_displaySetRenderOrder(0, renderOrder, num_layers); + ilm_displaySetRenderOrder(1, 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) @@ -293,9 +343,9 @@ void WindowManager::notificationFunc_non_static(ilmObjectType object, } else { - addSurfaceToLayer(id, WINDOWMANAGER_LAYER_APPLICATIONS); + //addSurfaceToLayer(id, WINDOWMANAGER_LAYER_APPLICATIONS); - m_surfaces.append(id); + m_appSurfaces.append(id); } ilm_surfaceAddNotification(id, surfaceCallbackFunction_static); @@ -304,7 +354,7 @@ void WindowManager::notificationFunc_non_static(ilmObjectType object, else { qDebug("Surface destroyed, ID: %d", id); - m_surfaces.removeAt(m_surfaces.indexOf(id)); + m_appSurfaces.removeAt(m_appSurfaces.indexOf(id)); ilm_surfaceRemoveNotification(id); ilm_commitChanges(); @@ -333,6 +383,7 @@ void WindowManager::surfaceCallbackFunction_non_static(t_ilm_surface surface, if (ILM_NOTIFICATION_VISIBILITY & mask) { qDebug("ILM_NOTIFICATION_VISIBILITY"); + surfaceVisibilityChanged(surface, surfaceProperties->visibility); } if (ILM_NOTIFICATION_OPACITY & mask) { @@ -353,6 +404,7 @@ void WindowManager::surfaceCallbackFunction_non_static(t_ilm_surface surface, if (ILM_NOTIFICATION_CONTENT_AVAILABLE & mask) { qDebug("ILM_NOTIFICATION_CONTENT_AVAILABLE"); + //updateScreen(); } if (ILM_NOTIFICATION_CONTENT_REMOVED & mask) { @@ -361,6 +413,17 @@ void WindowManager::surfaceCallbackFunction_non_static(t_ilm_surface surface, 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_commitChanges(); updateScreen(); } } @@ -413,6 +476,37 @@ int WindowManager::addLayout(int layoutId, const QString &layoutName, const QLis return WINDOWMANAGER_NO_ERROR; } +int WindowManager::deleteLayoutById(int layoutId) +{ + qDebug("-=[deleteLayoutById]=-"); + qDebug("layoutId: %d", layoutId); + int result = WINDOWMANAGER_NO_ERROR; + + if (m_currentLayout == layoutId) + { + result = WINDOWMANAGER_ERROR_ID_IN_USE; + } + else + { + QList::iterator i = m_layouts.begin(); + result = WINDOWMANAGER_ERROR_ID_IN_USE; + while (i != m_layouts.constEnd()) + { + if (i->id == layoutId) + { + m_layouts.erase(i); + result = WINDOWMANAGER_NO_ERROR; + break; + } + + ++i; + } + } + + return result; +} + + QList WindowManager::getAllLayouts() { qDebug("-=[getAllLayouts]=-"); @@ -423,15 +517,15 @@ QList WindowManager::getAllLayouts() 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 @@ -461,7 +555,7 @@ QList WindowManager::getAvailableSurfaces() { qDebug("-=[getAvailableSurfaces]=-"); - return m_surfaces; + return m_appSurfaces; } QString WindowManager::getLayoutName(int layoutId) @@ -483,6 +577,24 @@ QString WindowManager::getLayoutName(int layoutId) return result; } +void WindowManager::hideLayer(int layer) +{ + qDebug("-=[hideLayer]=-"); + qDebug("layer %d", layer); + +#ifdef HAVE_IVI_LAYERMANAGEMENT_API + // POPUP=0, HOMESCREEN_OVERLAY=1, APPS=2, HOMESCREEN=3 + if (layer >= 0 && layer < WINDOWMANAGER_LAYER_NUM) { + m_showLayers[layer] = 0; + + t_ilm_layer renderOrder[WINDOWMANAGER_LAYER_NUM]; + int num_layers = getLayerRenderOrder(renderOrder); + ilm_displaySetRenderOrder(0, renderOrder, num_layers); + ilm_displaySetRenderOrder(1, renderOrder, num_layers); + ilm_commitChanges(); + } +#endif +} int WindowManager::setLayoutById(int layoutId) { @@ -536,3 +648,22 @@ int WindowManager::setSurfaceToLayoutArea(int surfaceId, int layoutAreaId) return result; } + +void WindowManager::showLayer(int layer) +{ + qDebug("-=[showLayer]=-"); + qDebug("layer %d", layer); + +#ifdef HAVE_IVI_LAYERMANAGEMENT_API + // POPUP=0, HOMESCREEN_OVERLAY=1, APPS=2, HOMESCREEN=3 + if (layer >= 0 && layer < WINDOWMANAGER_LAYER_NUM) { + m_showLayers[layer] = layer_id_array[layer]; + + t_ilm_layer renderOrder[WINDOWMANAGER_LAYER_NUM]; + int num_layers = getLayerRenderOrder(renderOrder); + ilm_displaySetRenderOrder(0, renderOrder, num_layers); + ilm_displaySetRenderOrder(1, renderOrder, num_layers); + ilm_commitChanges(); + } +#endif +}