X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=WindowManager%2Fsrc%2Fwindowmanager.cpp;h=a03bab677247dd93f7a6d4621b73b9791b841e6a;hb=1977dd5081d4f305f8ff4d394ccde179f43abbeb;hp=e4d56105b3ec33b61cee75d1019cd1fb4e2ce943;hpb=9ca0a50d021a8d6e12cfb8f04671ba3dd389f92d;p=staging%2FHomeScreen.git diff --git a/WindowManager/src/windowmanager.cpp b/WindowManager/src/windowmanager.cpp index e4d5610..a03bab6 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,10 +27,15 @@ // 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 4 + +// the HomeScreen app has to have the surface id 1000 +#define WINDOWMANAGER_HOMESCREEN_MAIN_SURFACE_ID 1000 -#define WINDOWMANAGER_LAYER_NUM 3 void* WindowManager::myThis = 0; @@ -40,42 +44,48 @@ WindowManager::WindowManager(QObject *parent) : m_layouts(), m_surfaces(), mp_layoutAreaToSurfaceIdAssignment(0), - m_currentLayout(-1), - m_homeScreenPid(-1) + m_currentLayout(-1) { qDebug("-=[WindowManager]=-"); - // publish windowmanager interface - mp_windowManagerAdaptor = new WindowmanagerAdaptor((QObject*)this); - - QDBusConnection dbus = QDBusConnection::sessionBus(); - dbus.registerObject("/windowmanager", this); - dbus.registerService("org.agl.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); createNewLayer(WINDOWMANAGER_LAYER_POPUP); + createNewLayer(WINDOWMANAGER_LAYER_HOMESCREEN_OVERLAY); createNewLayer(WINDOWMANAGER_LAYER_APPLICATIONS); createNewLayer(WINDOWMANAGER_LAYER_HOMESCREEN); #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; @@ -105,7 +115,7 @@ void WindowManager::dumpScene() } } -#ifdef __arm__ +#ifdef HAVE_IVI_LAYERMANAGEMENT_API void WindowManager::createNewLayer(int layerId) { @@ -147,6 +157,11 @@ void WindowManager::addSurfaceToLayer(int surfaceId, int layerId) 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; @@ -155,7 +170,7 @@ void WindowManager::addSurfaceToLayer(int surfaceId, int layerId) ilm_getScreenResolution(screenID, &width, &height); ilm_surfaceSetDestinationRectangle(surfaceId, 0, 0, width, height); - ilm_surfaceSetSourceRectangle(surfaceId, 0, 0, surfaceProperties.origSourceWidth, surfaceProperties.origSourceHeight); + ilm_surfaceSetSourceRectangle(surfaceId, 0, 0, width, height); ilm_surfaceSetOpacity(surfaceId, 1.0); ilm_surfaceSetVisibility(surfaceId, ILM_TRUE); @@ -175,6 +190,19 @@ void WindowManager::addSurfaceToLayer(int surfaceId, int layerId) 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); + } + if (layerId == WINDOWMANAGER_LAYER_POPUP) { struct ilmSurfaceProperties surfaceProperties; @@ -197,14 +225,9 @@ void WindowManager::updateScreen() { qDebug("-=[updateScreen]=-"); +#ifdef HAVE_IVI_LAYERMANAGEMENT_API if (-1 != m_currentLayout) { -#ifdef __arm__ - - t_ilm_layer renderOrder[WINDOWMANAGER_LAYER_NUM]; - renderOrder[0] = WINDOWMANAGER_LAYER_HOMESCREEN; - renderOrder[1] = WINDOWMANAGER_LAYER_APPLICATIONS; - renderOrder[2] = WINDOWMANAGER_LAYER_POPUP; // hide all surfaces for (int i = 0; i < m_surfaces.size(); ++i) @@ -249,14 +272,23 @@ void WindowManager::updateScreen() currentLayout.layoutAreas[j].height); } - ilm_displaySetRenderOrder(0, renderOrder, WINDOWMANAGER_LAYER_NUM); - ilm_commitChanges(); -#endif } + + 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); + + 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) @@ -274,15 +306,11 @@ void WindowManager::notificationFunc_non_static(ilmObjectType object, qDebug(" origSourceWidth : %d", surfaceProperties.origSourceWidth); qDebug(" origSourceHeight: %d", surfaceProperties.origSourceHeight); - if (m_homeScreenPid == surfaceProperties.creatorPid) + if (WINDOWMANAGER_HOMESCREEN_MAIN_SURFACE_ID == id) { - if (m_homeScreenSurfaceId != id) - { - qDebug("HomeScreen app detected"); - m_homeScreenSurfaceId = id; - addSurfaceToLayer(id, WINDOWMANAGER_LAYER_HOMESCREEN); - updateScreen(); - } + qDebug("HomeScreen app detected"); + addSurfaceToLayer(id, WINDOWMANAGER_LAYER_HOMESCREEN); + updateScreen(); } else { @@ -326,27 +354,49 @@ 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) { qDebug("ILM_NOTIFICATION_OPACITY"); } - if (ILM_NOTIFICATION_ORIENTATION & mask) { qDebug("ILM_NOTIFICATION_ORIENTATION"); } - if (ILM_NOTIFICATION_SOURCE_RECT & mask) { qDebug("ILM_NOTIFICATION_SOURCE_RECT"); } - if (ILM_NOTIFICATION_DEST_RECT & mask) { qDebug("ILM_NOTIFICATION_DEST_RECT"); } + if (ILM_NOTIFICATION_CONTENT_AVAILABLE & mask) + { + qDebug("ILM_NOTIFICATION_CONTENT_AVAILABLE"); + updateScreen(); + } + if (ILM_NOTIFICATION_CONTENT_REMOVED & mask) + { + qDebug("ILM_NOTIFICATION_CONTENT_REMOVED"); + } + 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(); + } } void WindowManager::surfaceCallbackFunction_static(t_ilm_surface surface, @@ -358,44 +408,6 @@ void WindowManager::surfaceCallbackFunction_static(t_ilm_surface surface, } #endif - -int WindowManager::homeScreenPid() const -{ - return m_homeScreenPid; -} - -void WindowManager::setHomeScreenPid(int value) -{ - m_homeScreenPid = value; -#ifdef __arm__ - // maybe the HomeSceen app has already provided its surface. - // if so, shift it to the correct layer - // find the current used layout - QList::iterator ci = m_surfaces.begin(); - - struct ilmSurfaceProperties surfaceProperties; - bool found = false; - while ((!found) && (ci != m_surfaces.constEnd())) - { - ilm_getPropertiesOfSurface(*ci, &surfaceProperties); - if (m_homeScreenPid == surfaceProperties.creatorPid) - { - qDebug("HomeScreen app detected"); - m_homeScreenSurfaceId = *ci; - addSurfaceToLayer(*ci, WINDOWMANAGER_LAYER_HOMESCREEN); - m_surfaces.erase(ci); - found = true; - updateScreen(); - } - - ++ci; - } -#endif - - updateScreen(); - dumpScene(); -} - int WindowManager::layoutId() const { return m_currentLayout; @@ -435,6 +447,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]=-"); @@ -442,6 +485,24 @@ QList WindowManager::getAllLayouts() return m_layouts; } +QList WindowManager::getAllSurfacesOfProcess(int pid) +{ + QList result; +#ifdef HAVE_IVI_LAYERMANAGEMENT_API + struct ilmSurfaceProperties surfaceProperties; + + for (int i = 0; i < m_surfaces.size(); ++i) + { + ilm_getPropertiesOfSurface(m_surfaces.at(i), &surfaceProperties); + if (pid == surfaceProperties.creatorPid) + { + result.append(m_surfaces.at(i)); + } + } +#endif + return result; +} + QList WindowManager::getAvailableLayouts(int numberOfAppSurfaces) { qDebug("-=[getAvailableLayouts]=-"); @@ -487,6 +548,31 @@ QString WindowManager::getLayoutName(int layoutId) return result; } +void WindowManager::hideLayer(int layer) +{ + qDebug("-=[hideLayer]=-"); + qDebug("layer %d", layer); + +#ifdef HAVE_IVI_LAYERMANAGEMENT_API + 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); + } + ilm_commitChanges(); +#endif +} int WindowManager::setLayoutById(int layoutId) { @@ -540,3 +626,29 @@ 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 + if (0 == layer) + { + ilm_layerSetVisibility(WINDOWMANAGER_LAYER_POPUP, ILM_TRUE); + } + if (1 == layer) + { + ilm_layerSetVisibility(WINDOWMANAGER_LAYER_HOMESCREEN_OVERLAY, ILM_TRUE); + } + if (2 == layer) + { + ilm_layerSetVisibility(WINDOWMANAGER_LAYER_APPLICATIONS, ILM_TRUE); + } + if (3 == layer) + { + ilm_layerSetVisibility(WINDOWMANAGER_LAYER_HOMESCREEN, ILM_TRUE); + } + ilm_commitChanges(); +#endif +}