New layer management in WindowManager. Three layers are created. One for the HomeScre...
authorBocklage, Jens <Jens_Bocklage@mentor.com>
Wed, 2 Nov 2016 15:23:58 +0000 (16:23 +0100)
committerBocklage, Jens <Jens_Bocklage@mentor.com>
Wed, 2 Nov 2016 15:23:58 +0000 (16:23 +0100)
Signed-off-by: Bocklage, Jens <Jens_Bocklage@mentor.com>
HomeScreen/src/layouthandler.cpp
HomeScreen/src/layouthandler.h
HomeScreen/src/main.cpp
WindowManager/src/main.cpp
WindowManager/src/windowmanager.cpp
WindowManager/src/windowmanager.hpp
interfaces/homescreen.xml
interfaces/include/windowmanager.hpp
interfaces/src/windowmanager.cpp
interfaces/windowmanager.xml
test/commandlinetests.txt

index 81bc106..3bfe533 100644 (file)
@@ -4,14 +4,16 @@ LayoutHandler::LayoutHandler(QObject *parent) :
     QObject(parent),
     mp_dBusWindowManagerProxy(0),
     mp_dBusPopupProxy(0),
     QObject(parent),
     mp_dBusWindowManagerProxy(0),
     mp_dBusPopupProxy(0),
-    m_visibleApps(),
-    m_invisibleApps(),
-    m_requestsToBeVisibleApps()
+    m_visibleSurfaces(),
+    m_invisibleSurfaces(),
+    m_requestsToBeVisibleSurfaces()
 {
     qDBusRegisterMetaType<SimplePoint>();
     qDBusRegisterMetaType<QList<SimplePoint> >();
 {
     qDBusRegisterMetaType<SimplePoint>();
     qDBusRegisterMetaType<QList<SimplePoint> >();
-    qDBusRegisterMetaType<SimpleRect>();
-    qDBusRegisterMetaType<QList<SimpleRect> >();
+    qDBusRegisterMetaType<LayoutArea>();
+    qDBusRegisterMetaType<QList<LayoutArea> >();
+    qDBusRegisterMetaType<Layout>();
+    qDBusRegisterMetaType<QList<Layout> >();
 
     qDebug("D-Bus: connect to org.agl.windowmanager /windowmanager");
     mp_dBusWindowManagerProxy = new org::agl::windowmanager("org.agl.windowmanager",
 
     qDebug("D-Bus: connect to org.agl.windowmanager /windowmanager");
     mp_dBusWindowManagerProxy = new org::agl::windowmanager("org.agl.windowmanager",
@@ -34,10 +36,8 @@ LayoutHandler::~LayoutHandler()
 void LayoutHandler::setUpLayouts()
 {
     qDebug("setUpLayouts");
 void LayoutHandler::setUpLayouts()
 {
     qDebug("setUpLayouts");
-    QList<SimpleRect> surfaceAreas;
-    SimpleRect surfaceArea;
-    bool isFullScreen;
-    int associatedFullScreenLayout;
+    QList<LayoutArea> surfaceAreas;
+    LayoutArea surfaceArea;
 
     const int SCREEN_WIDTH = 1080;
     const int SCREEN_HEIGHT = 1920;
 
     const int SCREEN_WIDTH = 1080;
     const int SCREEN_HEIGHT = 1920;
@@ -61,10 +61,7 @@ void LayoutHandler::setUpLayouts()
 
     surfaceAreas.append(surfaceArea);
 
 
     surfaceAreas.append(surfaceArea);
 
-    isFullScreen = false;
-    associatedFullScreenLayout = 4;
-
-    mp_dBusWindowManagerProxy->addLayout(1, "one app", isFullScreen, associatedFullScreenLayout, surfaceAreas);
+    mp_dBusWindowManagerProxy->addLayout(1, "one app", surfaceAreas);
 
 
     surfaceAreas.clear();
 
 
     surfaceAreas.clear();
@@ -88,10 +85,7 @@ void LayoutHandler::setUpLayouts()
 
     surfaceAreas.append(surfaceArea);
 
 
     surfaceAreas.append(surfaceArea);
 
-    isFullScreen = false;
-    associatedFullScreenLayout = -1;
-
-    mp_dBusWindowManagerProxy->addLayout(2, "top on bottom", isFullScreen, associatedFullScreenLayout, surfaceAreas);
+    mp_dBusWindowManagerProxy->addLayout(2, "top on bottom", surfaceAreas);
 
 
     surfaceAreas.clear();
 
 
     surfaceAreas.clear();
@@ -115,72 +109,48 @@ void LayoutHandler::setUpLayouts()
 
     surfaceAreas.append(surfaceArea);
 
 
     surfaceAreas.append(surfaceArea);
 
-    isFullScreen = false;
-    associatedFullScreenLayout = -1;
-
-    mp_dBusWindowManagerProxy->addLayout(3, "side by side", isFullScreen, associatedFullScreenLayout, surfaceAreas);
-
-
-    surfaceAreas.clear();
-
-    // layout 4:
-    // one app surface full screen, no statusbar, no control bar
-    surfaceArea.x = 0;
-    surfaceArea.y = 0;
-    surfaceArea.width = SCREEN_WIDTH;
-    surfaceArea.height = SCREEN_HEIGHT;
-
-    surfaceAreas.append(surfaceArea);
-
-    isFullScreen = true;
-    associatedFullScreenLayout = 1;
-
-    mp_dBusWindowManagerProxy->addLayout(4, "one app full screen", isFullScreen, associatedFullScreenLayout, surfaceAreas);
-
-
-    surfaceAreas.clear();
-
+    mp_dBusWindowManagerProxy->addLayout(3, "side by side", surfaceAreas);
 }
 
 }
 
-void LayoutHandler::makeMeVisible(int pid)
+void LayoutHandler::makeMeVisible(int surfaceId)
 {
 {
-    qDebug("makeMeVisible %d", pid);
-    m_requestsToBeVisibleApps.append(pid);
+    qDebug("makeMeVisible %d", surfaceId);
+    m_requestsToBeVisibleSurfaces.append(surfaceId);
 
 
-    qDebug("m_visibleApps %d", m_visibleApps.size());
-    qDebug("m_invisibleApps %d", m_invisibleApps.size());
-    qDebug("m_requestsToBeVisibleApps %d", m_requestsToBeVisibleApps.size());
+    qDebug("m_visibleSurfaces %d", m_visibleSurfaces.size());
+    qDebug("m_invisibleSurfaces %d", m_invisibleSurfaces.size());
+    qDebug("m_requestsToBeVisibleSurfaces %d", m_requestsToBeVisibleSurfaces.size());
 
 
-    QList<int> availableLayouts = mp_dBusWindowManagerProxy->getAvailableLayouts(m_visibleApps.size() + m_requestsToBeVisibleApps.size());
+    QList<int> availableLayouts = mp_dBusWindowManagerProxy->getAvailableLayouts(m_visibleSurfaces.size() + m_requestsToBeVisibleSurfaces.size());
     if (0 == availableLayouts.size())
     {
         // no layout fits the need!
         // replace the last app
         qDebug("no layout fits the need!");
     if (0 == availableLayouts.size())
     {
         // no layout fits the need!
         // replace the last app
         qDebug("no layout fits the need!");
-        qDebug("replace the last app");
+        qDebug("replace the last surface");
 
 
-        m_invisibleApps.append(m_visibleApps.last());
-        m_visibleApps.removeLast();
+        m_invisibleSurfaces.append(m_visibleSurfaces.last());
+        m_visibleSurfaces.removeLast();
 
 
-        m_visibleApps.append(m_requestsToBeVisibleApps);
-        m_requestsToBeVisibleApps.clear();
+        m_visibleSurfaces.append(m_requestsToBeVisibleSurfaces);
+        m_requestsToBeVisibleSurfaces.clear();
 
 
-        for (int i = 0; i < m_visibleApps.size(); ++i)
+        for (int i = 0; i < m_visibleSurfaces.size(); ++i)
         {
         {
-            mp_dBusWindowManagerProxy->setPidToLayoutArea(m_visibleApps.at(i), i);
+            mp_dBusWindowManagerProxy->setSurfaceToLayoutArea(m_visibleSurfaces.at(i), i);
         }
     }
     if (1 == availableLayouts.size())
     {
         // switch to new layout
         qDebug("switch to new layout %d", availableLayouts.at(0));
         }
     }
     if (1 == availableLayouts.size())
     {
         // switch to new layout
         qDebug("switch to new layout %d", availableLayouts.at(0));
-        m_visibleApps.append(m_requestsToBeVisibleApps);
-        m_requestsToBeVisibleApps.clear();
+        m_visibleSurfaces.append(m_requestsToBeVisibleSurfaces);
+        m_requestsToBeVisibleSurfaces.clear();
 
         mp_dBusWindowManagerProxy->setLayoutById(availableLayouts.at(0));
 
         mp_dBusWindowManagerProxy->setLayoutById(availableLayouts.at(0));
-        for (int i = 0; i < m_visibleApps.size(); ++i)
+        for (int i = 0; i < m_visibleSurfaces.size(); ++i)
         {
         {
-            mp_dBusWindowManagerProxy->setPidToLayoutArea(m_visibleApps.at(i), i);
+            mp_dBusWindowManagerProxy->setSurfaceToLayoutArea(m_visibleSurfaces.at(i), i);
         }
     }
     if (1 < availableLayouts.size())
         }
     }
     if (1 < availableLayouts.size())
@@ -202,32 +172,18 @@ void LayoutHandler::makeMeVisible(int pid)
 void LayoutHandler::toggleFullscreen()
 {
     qDebug("toggleFullscreen");
 void LayoutHandler::toggleFullscreen()
 {
     qDebug("toggleFullscreen");
-    int currentLayout = mp_dBusWindowManagerProxy->getLayout();
-    int associatedFullScreenLayout = mp_dBusWindowManagerProxy->getAssociatedFullScreenLayout(currentLayout);
-    if (-1 != associatedFullScreenLayout)
-    {
-        mp_dBusWindowManagerProxy->setLayoutById(associatedFullScreenLayout);
-        for (int i = 0; i < m_visibleApps.size(); ++i)
-        {
-            mp_dBusWindowManagerProxy->setPidToLayoutArea(m_visibleApps.at(i), i);
-        }
-    }
-    else
-    {
-        qDebug("no associatedFullScreenLayout. Cannot switch to full screen.");
-    }
 }
 
 void LayoutHandler::setLayoutByName(QString layoutName)
 {
     // switch to new layout
     qDebug("setLayout: switch to new layout %s", layoutName.toStdString().c_str());
 }
 
 void LayoutHandler::setLayoutByName(QString layoutName)
 {
     // switch to new layout
     qDebug("setLayout: switch to new layout %s", layoutName.toStdString().c_str());
-    m_visibleApps.append(m_requestsToBeVisibleApps);
-    m_requestsToBeVisibleApps.clear();
+    m_visibleSurfaces.append(m_requestsToBeVisibleSurfaces);
+    m_requestsToBeVisibleSurfaces.clear();
 
     mp_dBusWindowManagerProxy->setLayoutByName(layoutName);
 
     mp_dBusWindowManagerProxy->setLayoutByName(layoutName);
-    for (int i = 0; i < m_visibleApps.size(); ++i)
+    for (int i = 0; i < m_visibleSurfaces.size(); ++i)
     {
     {
-        mp_dBusWindowManagerProxy->setPidToLayoutArea(i, i);
+        mp_dBusWindowManagerProxy->setSurfaceToLayoutArea(i, i);
     }
 }
     }
 }
index c9ca1bf..5763d44 100644 (file)
@@ -17,7 +17,7 @@ public:
 signals:
 
 public slots:
 signals:
 
 public slots:
-    void makeMeVisible(int pid);
+    void makeMeVisible(int surfaceId);
     void toggleFullscreen();
     void setLayoutByName(QString layoutName);
 
     void toggleFullscreen();
     void setLayoutByName(QString layoutName);
 
@@ -25,9 +25,9 @@ private:
     org::agl::windowmanager *mp_dBusWindowManagerProxy;
     org::agl::popup *mp_dBusPopupProxy;
 
     org::agl::windowmanager *mp_dBusWindowManagerProxy;
     org::agl::popup *mp_dBusPopupProxy;
 
-    QList<int> m_visibleApps;
-    QList<int> m_invisibleApps;
-    QList<int> m_requestsToBeVisibleApps;
+    QList<int> m_visibleSurfaces;
+    QList<int> m_invisibleSurfaces;
+    QList<int> m_requestsToBeVisibleSurfaces;
 
 };
 
 
 };
 
index 80a063d..a623fff 100644 (file)
@@ -36,7 +36,7 @@ int main(int argc, char *argv[])
     QCoreApplication::setOrganizationDomain("LinuxFoundation");
     QCoreApplication::setOrganizationName("AutomotiveGradeLinux");
     QCoreApplication::setApplicationName("HomeScreen");
     QCoreApplication::setOrganizationDomain("LinuxFoundation");
     QCoreApplication::setOrganizationName("AutomotiveGradeLinux");
     QCoreApplication::setApplicationName("HomeScreen");
-    QCoreApplication::setApplicationVersion("0.3.3");
+    QCoreApplication::setApplicationVersion("0.3.4");
 
     qDebug("%s, v%s", QCoreApplication::applicationName().toStdString().c_str(), QCoreApplication::applicationVersion().toStdString().c_str());
 
 
     qDebug("%s, v%s", QCoreApplication::applicationName().toStdString().c_str(), QCoreApplication::applicationVersion().toStdString().c_str());
 
index 9c6e791..455361c 100644 (file)
@@ -25,14 +25,16 @@ int main(int argc, char *argv[])
     QCoreApplication::setOrganizationDomain("LinuxFoundation");
     QCoreApplication::setOrganizationName("AutomotiveGradeLinux");
     QCoreApplication::setApplicationName("WindowManager");
     QCoreApplication::setOrganizationDomain("LinuxFoundation");
     QCoreApplication::setOrganizationName("AutomotiveGradeLinux");
     QCoreApplication::setApplicationName("WindowManager");
-    QCoreApplication::setApplicationVersion("0.3.0");
+    QCoreApplication::setApplicationVersion("0.3.1");
 
     qDebug("%s, v%s", QCoreApplication::applicationName().toStdString().c_str(), QCoreApplication::applicationVersion().toStdString().c_str());
 
     qDBusRegisterMetaType<SimplePoint>();
     qDBusRegisterMetaType<QList<SimplePoint> >();
 
     qDebug("%s, v%s", QCoreApplication::applicationName().toStdString().c_str(), QCoreApplication::applicationVersion().toStdString().c_str());
 
     qDBusRegisterMetaType<SimplePoint>();
     qDBusRegisterMetaType<QList<SimplePoint> >();
-    qDBusRegisterMetaType<SimpleRect>();
-    qDBusRegisterMetaType<QList<SimpleRect> >();
+    qDBusRegisterMetaType<LayoutArea>();
+    qDBusRegisterMetaType<QList<LayoutArea> >();
+    qDBusRegisterMetaType<Layout>();
+    qDBusRegisterMetaType<QList<Layout> >();
 
     WindowManager *windowManager = new WindowManager();
     windowManager->start();
 
     WindowManager *windowManager = new WindowManager();
     windowManager->start();
index ce59fa0..e4d5610 100644 (file)
 // DO NOT JUDGE THE SOURCE CODE :)
 //////////////////////////////////////////
 
 // DO NOT JUDGE THE SOURCE CODE :)
 //////////////////////////////////////////
 
+// three layers will be defined. The HomeScreen will be placed
+// full screen in the background.
+// 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_NUM 3
+
 void* WindowManager::myThis = 0;
 
 WindowManager::WindowManager(QObject *parent) :
     QObject(parent),
     m_layouts(),
 void* WindowManager::myThis = 0;
 
 WindowManager::WindowManager(QObject *parent) :
     QObject(parent),
     m_layouts(),
-    m_layoutNames(),
-    m_layoutFullScreen(),
-    m_layoutFullScreenAssociated(),
+    m_surfaces(),
+    mp_layoutAreaToSurfaceIdAssignment(0),
     m_currentLayout(-1),
     m_currentLayout(-1),
-    m_homeScreenPid(-1),
-#ifdef __arm__
-    mp_surfaces(0),
-    mp_processLayers(0),
-#endif
-    mp_layoutAreaToPidAssignment(0)
+    m_homeScreenPid(-1)
 {
     qDebug("-=[WindowManager]=-");
 {
     qDebug("-=[WindowManager]=-");
-    qDebug("WindowManager");
     // publish windowmanager interface
     mp_windowManagerAdaptor = new WindowmanagerAdaptor((QObject*)this);
 
     // publish windowmanager interface
     mp_windowManagerAdaptor = new WindowmanagerAdaptor((QObject*)this);
 
@@ -52,11 +55,8 @@ WindowManager::WindowManager(QObject *parent) :
 void WindowManager::start()
 {
     qDebug("-=[start]=-");
 void WindowManager::start()
 {
     qDebug("-=[start]=-");
-    mp_layoutAreaToPidAssignment = new QMap<int, unsigned int>;
+    mp_layoutAreaToSurfaceIdAssignment = new QMap<int, unsigned int>;
 #ifdef __arm__
 #ifdef __arm__
-    mp_processLayers = new QList<int>;
-    mp_surfaces = new QMap<t_ilm_uint, SurfaceInfo>;
-
     ilmErrorTypes err;
 
     err = ilm_init();
     ilmErrorTypes err;
 
     err = ilm_init();
@@ -64,6 +64,10 @@ void WindowManager::start()
 
     myThis = this;
     err =  ilm_registerNotification(WindowManager::notificationFunc_static, this);
 
     myThis = this;
     err =  ilm_registerNotification(WindowManager::notificationFunc_static, this);
+
+    createNewLayer(WINDOWMANAGER_LAYER_POPUP);
+    createNewLayer(WINDOWMANAGER_LAYER_APPLICATIONS);
+    createNewLayer(WINDOWMANAGER_LAYER_HOMESCREEN);
 #endif
 }
 
 #endif
 }
 
@@ -72,12 +76,9 @@ WindowManager::~WindowManager()
     qDebug("-=[~WindowManager]=-");
     delete mp_windowManagerAdaptor;
 #ifdef __arm__
     qDebug("-=[~WindowManager]=-");
     delete mp_windowManagerAdaptor;
 #ifdef __arm__
-    delete mp_surfaces;
-    delete mp_processLayers;
-
     ilm_destroy();
 #endif
     ilm_destroy();
 #endif
-    delete mp_layoutAreaToPidAssignment;
+    delete mp_layoutAreaToSurfaceIdAssignment;
 }
 
 void WindowManager::dumpScene()
 }
 
 void WindowManager::dumpScene()
@@ -85,20 +86,19 @@ void WindowManager::dumpScene()
     qDebug("\n");
     qDebug("current layout   : %d", m_currentLayout);
     qDebug("available layouts: %d", m_layouts.size());
     qDebug("\n");
     qDebug("current layout   : %d", m_currentLayout);
     qDebug("available layouts: %d", m_layouts.size());
-    QMap<int, QList<SimpleRect> >::iterator i = m_layouts.begin();
+    QList<Layout>::const_iterator i = m_layouts.begin();
 
 
-    QList<int> result;
     while (i != m_layouts.constEnd())
     {
     while (i != m_layouts.constEnd())
     {
-        qDebug("--[id: %d]--[%s]--", i.key(), m_layoutNames.find(i.key()).value().toStdString().c_str());
-        qDebug("  %d surface areas", i.value().size());
-        for (int j = 0; j < i.value().size(); ++j)
+        qDebug("--[id: %d]--[%s]--", i->id, i->name.toStdString().c_str());
+        qDebug("  %d surface areas", i->layoutAreas.size());
+        for (int j = 0; j < i->layoutAreas.size(); ++j)
         {
             qDebug("  -area %d", j);
         {
             qDebug("  -area %d", j);
-            qDebug("    -x     : %d", i.value().at(j).x);
-            qDebug("    -y     : %d", i.value().at(j).y);
-            qDebug("    -width : %d", i.value().at(j).width);
-            qDebug("    -height: %d", i.value().at(j).height);
+            qDebug("    -x     : %d", i->layoutAreas.at(j).x);
+            qDebug("    -y     : %d", i->layoutAreas.at(j).y);
+            qDebug("    -width : %d", i->layoutAreas.at(j).width);
+            qDebug("    -height: %d", i->layoutAreas.at(j).height);
         }
 
         ++i;
         }
 
         ++i;
@@ -111,21 +111,27 @@ void WindowManager::createNewLayer(int layerId)
 {
     qDebug("-=[createNewLayer]=-");
     qDebug("layerId %d", layerId);
 {
     qDebug("-=[createNewLayer]=-");
     qDebug("layerId %d", layerId);
-    ilmErrorTypes err;
 
     t_ilm_uint screenID = 0;
     t_ilm_uint width;
     t_ilm_uint height;
 
 
     t_ilm_uint screenID = 0;
     t_ilm_uint width;
     t_ilm_uint height;
 
-    err = ilm_getScreenResolution(screenID, &width, &height);
+    ilm_getScreenResolution(screenID, &width, &height);
 
     t_ilm_layer newLayerId = layerId;
 
     t_ilm_layer newLayerId = layerId;
-    err = ilm_layerCreateWithDimension(&newLayerId, width, height);
-
-    t_ilm_float opacity = 0.0;
-    err =  ilm_layerSetOpacity(newLayerId, opacity);
-
-    ilm_layerSetVisibility(newLayerId, ILM_FALSE);
+    ilm_layerCreateWithDimension(&newLayerId, width, height);
+    ilm_layerSetOpacity(newLayerId, 1.0);
+    ilm_layerSetVisibility(newLayerId, ILM_TRUE);
+    ilm_layerSetSourceRectangle(newLayerId,
+                                    0,
+                                    0,
+                                    width,
+                                    height);
+    ilm_layerSetDestinationRectangle(newLayerId,
+                                    0,
+                                    0,
+                                    width,
+                                    height);
 
     ilm_commitChanges();
 }
 
     ilm_commitChanges();
 }
@@ -135,130 +141,122 @@ void WindowManager::addSurfaceToLayer(int surfaceId, int layerId)
     qDebug("-=[addSurfaceToLayer]=-");
     qDebug("surfaceId %d", surfaceId);
     qDebug("layerId %d", layerId);
     qDebug("-=[addSurfaceToLayer]=-");
     qDebug("surfaceId %d", surfaceId);
     qDebug("layerId %d", layerId);
-    t_ilm_int length;
-    t_ilm_layer* pArray;
 
 
-    ilm_getLayerIDs(&length, &pArray);
-    bool layerFound(false);
-    for (int i = 0; i < length; ++i)
+    if (layerId == WINDOWMANAGER_LAYER_HOMESCREEN)
     {
     {
-        if (layerId == pArray[i])
-        {
-            layerFound = true;
-        }
+        struct ilmSurfaceProperties surfaceProperties;
+        ilm_getPropertiesOfSurface(surfaceId, &surfaceProperties);
+
+        // 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, surfaceProperties.origSourceWidth, surfaceProperties.origSourceHeight);
+        ilm_surfaceSetOpacity(surfaceId, 1.0);
+        ilm_surfaceSetVisibility(surfaceId, ILM_TRUE);
+
+        ilm_layerAddSurface(layerId, surfaceId);
     }
 
     }
 
-    if (!layerFound)
+    if (layerId == WINDOWMANAGER_LAYER_APPLICATIONS)
     {
     {
-        createNewLayer(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_layerAddSurface(layerId, surfaceId);
     }
 
     }
 
-    struct ilmSurfaceProperties surfaceProperties;
-    ilm_getPropertiesOfSurface(surfaceId, &surfaceProperties);
-    //qDebug("  origSourceWidth : %d", surfaceProperties.origSourceWidth);
-    //qDebug("  origSourceHeight: %d", surfaceProperties.origSourceHeight);
-
-    ilm_layerSetSourceRectangle(layerId,
-                                     0,
-                                     0,
-                                     surfaceProperties.origSourceWidth,
-                                     surfaceProperties.origSourceHeight);
-    ilm_commitChanges();
+    if (layerId == WINDOWMANAGER_LAYER_POPUP)
+    {
+        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, 1.0);
-    ilm_surfaceSetVisibility(surfaceId, true);
+        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);
+        ilm_layerAddSurface(layerId, surfaceId);
+    }
 
     ilm_commitChanges();
 }
 
 
     ilm_commitChanges();
 }
 
+#endif
+
 void WindowManager::updateScreen()
 {
     qDebug("-=[updateScreen]=-");
 void WindowManager::updateScreen()
 {
     qDebug("-=[updateScreen]=-");
-    int numberOfLayersToShow = 0;
-
-    QMap<int, QList<SimpleRect> >::iterator i = m_layouts.find(m_currentLayout);
-    if (m_layouts.end() != i)
-    {
-        numberOfLayersToShow += i.value().size();
-        qDebug("the current layout provides %d render areas", i.value().size());
-    }
-    else
-    {
-        qDebug("the current layout provides no render areas!");
-    }
-
 
 
-    t_ilm_layer renderOrder[numberOfLayersToShow];
-    int renderOrderCounter = 0;
-
-    qDebug("show home screen app");
-    if (-1 != m_homeScreenPid)
+    if (-1 != m_currentLayout)
     {
     {
-        renderOrder[renderOrderCounter] = m_homeScreenPid;
-        ++renderOrderCounter;
+#ifdef __arm__
 
 
-        ilm_layerSetVisibility(m_homeScreenPid, ILM_TRUE);
-        t_ilm_float opacity = 1.0;
-        ilm_layerSetOpacity(m_homeScreenPid, opacity);
+        t_ilm_layer renderOrder[WINDOWMANAGER_LAYER_NUM];
+        renderOrder[0] = WINDOWMANAGER_LAYER_HOMESCREEN;
+        renderOrder[1] = WINDOWMANAGER_LAYER_APPLICATIONS;
+        renderOrder[2] = WINDOWMANAGER_LAYER_POPUP;
 
 
-        // homescreen app always fullscreen in the back
-        t_ilm_uint screenID = 0;
-        t_ilm_uint width;
-        t_ilm_uint height;
+        // hide all surfaces
+        for (int i = 0; i < m_surfaces.size(); ++i)
+        {
+            ilm_surfaceSetVisibility(m_surfaces.at(i), ILM_FALSE);
+            ilm_surfaceSetOpacity(m_surfaces.at(i), 0.0);
+        }
 
 
-        ilm_getScreenResolution(screenID, &width, &height);
+        // find the current used layout
+        QList<Layout>::const_iterator ci = m_layouts.begin();
 
 
-        ilm_layerSetDestinationRectangle(m_homeScreenPid,
-                                         0,
-                                         0,
-                                         width,
-                                         height);
-    }
+        Layout currentLayout;
+        while (ci != m_layouts.constEnd())
+        {
+            if (ci->id == m_currentLayout)
+            {
+                currentLayout = *ci;
+            }
 
 
+            ++ci;
+        }
 
 
-    qDebug("show %d apps", numberOfLayersToShow);
-    for (int j = 0; j < numberOfLayersToShow; ++j)
-    {
-        int layerToShow = mp_layoutAreaToPidAssignment->find(j).value();
-        if (layerToShow != m_homeScreenPid)
+        qDebug("show %d apps", mp_layoutAreaToSurfaceIdAssignment->size());
+        for (int j = 0; j < mp_layoutAreaToSurfaceIdAssignment->size(); ++j)
         {
         {
-            qDebug("  app no. %d: %d", j, layerToShow);
-            renderOrder[renderOrderCounter] = layerToShow;
-            ++renderOrderCounter;
+            int surfaceToShow = mp_layoutAreaToSurfaceIdAssignment->find(j).value();
+            qDebug("  surface no. %d: %d", j, surfaceToShow);
 
 
-            ilm_layerSetVisibility(layerToShow, ILM_TRUE);
-            t_ilm_float opacity = 1.0;
-            ilm_layerSetOpacity(layerToShow, opacity);
+            ilm_surfaceSetVisibility(surfaceToShow, ILM_TRUE);
+            ilm_surfaceSetOpacity(surfaceToShow, 1.0);
 
             qDebug("  layout area %d", j);
 
             qDebug("  layout area %d", j);
-            qDebug("    x: %d", m_layouts.find(m_currentLayout).value()[j].x);
-            qDebug("    x: %d", m_layouts.find(m_currentLayout).value()[j].y);
-            qDebug("    w: %d", m_layouts.find(m_currentLayout).value()[j].width);
-            qDebug("    h: %d", m_layouts.find(m_currentLayout).value()[j].height);
-
-            ilm_layerSetDestinationRectangle(layerToShow,
-                                             m_layouts.find(m_currentLayout).value()[j].x,
-                                             m_layouts.find(m_currentLayout).value()[j].y,
-                                             m_layouts.find(m_currentLayout).value()[j].width,
-                                             m_layouts.find(m_currentLayout).value()[j].height);
+            qDebug("    x: %d", currentLayout.layoutAreas[j].x);
+            qDebug("    y: %d", currentLayout.layoutAreas[j].y);
+            qDebug("    w: %d", currentLayout.layoutAreas[j].width);
+            qDebug("    h: %d", currentLayout.layoutAreas[j].height);
+
+            ilm_surfaceSetDestinationRectangle(surfaceToShow,
+                                             currentLayout.layoutAreas[j].x,
+                                             currentLayout.layoutAreas[j].y,
+                                             currentLayout.layoutAreas[j].width,
+                                             currentLayout.layoutAreas[j].height);
         }
         }
-    }
 
 
-    qDebug("renderOrder");
-    for (int j = 0; j < renderOrderCounter; ++j)
-    {
-        qDebug("  %d: %d", j, renderOrder[j]);
-    }
+        ilm_displaySetRenderOrder(0, renderOrder, WINDOWMANAGER_LAYER_NUM);
 
 
-    ilm_displaySetRenderOrder(0, renderOrder, renderOrderCounter);
-
-    ilm_commitChanges();
+        ilm_commitChanges();
+#endif
+    }
 }
 
 }
 
+#ifdef __arm__
 void WindowManager::notificationFunc_non_static(ilmObjectType object,
                                     t_ilm_uint id,
                                     t_ilm_bool created)
 void WindowManager::notificationFunc_non_static(ilmObjectType object,
                                     t_ilm_uint id,
                                     t_ilm_bool created)
@@ -272,42 +270,34 @@ void WindowManager::notificationFunc_non_static(ilmObjectType object,
         if (created)
         {
             qDebug("Surface created, ID: %d", id);
         if (created)
         {
             qDebug("Surface created, ID: %d", id);
-            //qDebug("Surface created, ID: 0x%s", QString(QByteArray::number(id,16)).toStdString().c_str());
             ilm_getPropertiesOfSurface(id, &surfaceProperties);
             qDebug("  origSourceWidth : %d", surfaceProperties.origSourceWidth);
             qDebug("  origSourceHeight: %d", surfaceProperties.origSourceHeight);
             ilm_getPropertiesOfSurface(id, &surfaceProperties);
             qDebug("  origSourceWidth : %d", surfaceProperties.origSourceWidth);
             qDebug("  origSourceHeight: %d", surfaceProperties.origSourceHeight);
-            SurfaceInfo surfaceInfo;
-            surfaceInfo.pid = surfaceProperties.creatorPid;
-            QString procInfoFileName = QString("/proc/") + QString::number(surfaceInfo.pid) + QString("/comm");
-            QFile procInfo(procInfoFileName);
-            if (procInfo.open(QIODevice::ReadOnly))
-            {
-                QTextStream in(&procInfo);
-                surfaceInfo.processName = in.readLine();
-                qDebug("  creator pid %d %s", surfaceInfo.pid, surfaceInfo.processName.toStdString().c_str());
-                addSurfaceToLayer(id, surfaceProperties.creatorPid);
 
 
-                mp_surfaces->insert(id, surfaceInfo);
-                ilm_surfaceAddNotification(id, surfaceCallbackFunction_static);
-
-                ilm_commitChanges();
-
-                if (0 == QString::compare("weston-fullscre", surfaceInfo.processName))
+            if (m_homeScreenPid == surfaceProperties.creatorPid)
+            {
+                if (m_homeScreenSurfaceId != id)
                 {
                     qDebug("HomeScreen app detected");
                 {
                     qDebug("HomeScreen app detected");
-                    m_homeScreenPid = surfaceInfo.pid;
+                    m_homeScreenSurfaceId = id;
+                    addSurfaceToLayer(id, WINDOWMANAGER_LAYER_HOMESCREEN);
                     updateScreen();
                 }
             }
             else
             {
                     updateScreen();
                 }
             }
             else
             {
-                qDebug("no creator pid found. Ignoring surface!");
+                addSurfaceToLayer(id, WINDOWMANAGER_LAYER_APPLICATIONS);
+
+                m_surfaces.append(id);
             }
             }
+            ilm_surfaceAddNotification(id, surfaceCallbackFunction_static);
+
+            ilm_commitChanges();
         }
         else
         {
             qDebug("Surface destroyed, ID: %d", id);
         }
         else
         {
             qDebug("Surface destroyed, ID: %d", id);
-            mp_surfaces->erase(mp_surfaces->find(id));
+            m_surfaces.removeAt(m_surfaces.indexOf(id));
             ilm_surfaceRemoveNotification(id);
 
             ilm_commitChanges();
             ilm_surfaceRemoveNotification(id);
 
             ilm_commitChanges();
@@ -327,9 +317,6 @@ void WindowManager::notificationFunc_static(ilmObjectType object,
     static_cast<WindowManager*>(WindowManager::myThis)->notificationFunc_non_static(object, id, created);
 }
 
     static_cast<WindowManager*>(WindowManager::myThis)->notificationFunc_non_static(object, id, created);
 }
 
-
-
-
 void WindowManager::surfaceCallbackFunction_non_static(t_ilm_surface surface,
                                     struct ilmSurfaceProperties* surfaceProperties,
                                     t_ilm_notification_mask mask)
 void WindowManager::surfaceCallbackFunction_non_static(t_ilm_surface surface,
                                     struct ilmSurfaceProperties* surfaceProperties,
                                     t_ilm_notification_mask mask)
@@ -371,42 +358,101 @@ void WindowManager::surfaceCallbackFunction_static(t_ilm_surface surface,
 }
 #endif
 
 }
 #endif
 
-int WindowManager::addLayout(int layoutId, const QString &layoutName, bool isFullScreen, int associatedFullScreenLayout, const QList<SimpleRect> &surfaceAreas)
+
+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<int>::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;
+}
+
+QString WindowManager::layoutName() const
+{
+    QList<Layout>::const_iterator i = m_layouts.begin();
+
+    QString result = "not found";
+    while (i != m_layouts.constEnd())
+    {
+        if (i->id == m_currentLayout)
+        {
+            result = i->name;
+        }
+
+        ++i;
+    }
+
+    return result;
+}
+
+
+int WindowManager::addLayout(int layoutId, const QString &layoutName, const QList<LayoutArea> &surfaceAreas)
 {
     qDebug("-=[addLayout]=-");
 {
     qDebug("-=[addLayout]=-");
-    m_layouts.insert(layoutId, surfaceAreas);
-    m_layoutNames.insert(layoutId, layoutName);
-    m_layoutFullScreen.insert(layoutId, isFullScreen);
-    m_layoutFullScreenAssociated.insert(layoutId, associatedFullScreenLayout);
-    qDebug("addLayout %d %s %s, %d, size %d",
+    m_layouts.append(Layout(layoutId, layoutName, surfaceAreas));
+
+    qDebug("addLayout %d %s, size %d",
            layoutId,
            layoutName.toStdString().c_str(),
            layoutId,
            layoutName.toStdString().c_str(),
-           isFullScreen ? "true" : "false",
-           associatedFullScreenLayout,
            surfaceAreas.size());
 
     dumpScene();
 
            surfaceAreas.size());
 
     dumpScene();
 
-    return true;
+    return WINDOWMANAGER_NO_ERROR;
 }
 
 }
 
-int WindowManager::getAssociatedFullScreenLayout(int layoutId)
+QList<Layout> WindowManager::getAllLayouts()
 {
 {
-    qDebug("-=[getAssociatedFullScreenLayout]=-");
-    return m_layoutFullScreenAssociated.find(layoutId).value();
+    qDebug("-=[getAllLayouts]=-");
+
+    return m_layouts;
 }
 
 QList<int> WindowManager::getAvailableLayouts(int numberOfAppSurfaces)
 {
     qDebug("-=[getAvailableLayouts]=-");
 }
 
 QList<int> WindowManager::getAvailableLayouts(int numberOfAppSurfaces)
 {
     qDebug("-=[getAvailableLayouts]=-");
-    QMap<int, QList<SimpleRect> >::iterator i = m_layouts.begin();
+    QList<Layout>::const_iterator i = m_layouts.begin();
 
     QList<int> result;
     while (i != m_layouts.constEnd())
     {
 
     QList<int> result;
     while (i != m_layouts.constEnd())
     {
-        if (i.value().size() == numberOfAppSurfaces)
+        if (i->layoutAreas.size() == numberOfAppSurfaces)
         {
         {
-            result.append(i.key());
+            result.append(i->id);
         }
 
         ++i;
         }
 
         ++i;
@@ -415,81 +461,82 @@ QList<int> WindowManager::getAvailableLayouts(int numberOfAppSurfaces)
     return result;
 }
 
     return result;
 }
 
-// maybe not needed anymore
-QList<SimplePoint> WindowManager::getAvailableSurfaces()
+QList<int> WindowManager::getAvailableSurfaces()
 {
     qDebug("-=[getAvailableSurfaces]=-");
 {
     qDebug("-=[getAvailableSurfaces]=-");
-    QList<SimplePoint> points;
-    SimplePoint point;
-    point.x = 1;
-    point.y = 2;
-    points.append(point);
-    point.x = 11;
-    point.y = 22;
-    points.append(point);
-    point.x = 111;
-    point.y = 222;
-    points.append(point);
-
-    return points;
-}
 
 
-int WindowManager::getLayout()
-{
-    qDebug("-=[getLayout]=-");
-    return m_currentLayout;
+    return m_surfaces;
 }
 
 QString WindowManager::getLayoutName(int layoutId)
 {
     qDebug("-=[getLayoutName]=-");
 }
 
 QString WindowManager::getLayoutName(int layoutId)
 {
     qDebug("-=[getLayoutName]=-");
-    return m_layoutNames.find(layoutId).value();
-}
+    QList<Layout>::const_iterator i = m_layouts.begin();
 
 
-bool WindowManager::isLayoutFullScreen(int layoutId)
-{
-    qDebug("-=[isLayoutFullScreen]=-");
-    return m_layoutFullScreen.find(layoutId).value();
+    QString result = "not found";
+    while (i != m_layouts.constEnd())
+    {
+        if (i->id == layoutId)
+        {
+            result = i->name;
+        }
+
+        ++i;
+    }
+
+    return result;
 }
 
 }
 
-void WindowManager::setLayoutById(int layoutId)
+
+int WindowManager::setLayoutById(int layoutId)
 {
     qDebug("-=[setLayoutById]=-");
 {
     qDebug("-=[setLayoutById]=-");
+    int result = WINDOWMANAGER_NO_ERROR;
     m_currentLayout = layoutId;
 
     m_currentLayout = layoutId;
 
-    mp_layoutAreaToPidAssignment->clear();
+    mp_layoutAreaToSurfaceIdAssignment->clear();
 
     dumpScene();
 
     dumpScene();
+
+    return result;
 }
 
 }
 
-void WindowManager::setLayoutByName(const QString &layoutName)
+int WindowManager::setLayoutByName(const QString &layoutName)
 {
     qDebug("-=[setLayoutByName]=-");
 {
     qDebug("-=[setLayoutByName]=-");
-    QMap<int, QString>::iterator i = m_layoutNames.begin();
-    while (i != m_layoutNames.constEnd())
+    int result = WINDOWMANAGER_NO_ERROR;
+
+    QList<Layout>::const_iterator i = m_layouts.begin();
+
+    while (i != m_layouts.constEnd())
     {
     {
-        if (i.value() == layoutName)
+        if (i->name == layoutName)
         {
         {
-            m_currentLayout = i.key();
+            m_currentLayout = i->id;
+
+            mp_layoutAreaToSurfaceIdAssignment->clear();
+
+            dumpScene();
         }
         }
+
         ++i;
     }
 
         ++i;
     }
 
-    mp_layoutAreaToPidAssignment->clear();
-
-    dumpScene();
+    return result;
 }
 
 }
 
-void WindowManager::setPidToLayoutArea(int pid, int layoutAreaId)
+int WindowManager::setSurfaceToLayoutArea(int surfaceId, int layoutAreaId)
 {
 {
-    qDebug("-=[setPidToLayoutArea]=-");
-    qDebug("pid %d", pid);
+    qDebug("-=[setSurfaceToLayoutArea]=-");
+    int result = WINDOWMANAGER_NO_ERROR;
+
+    qDebug("surfaceId %d", surfaceId);
     qDebug("layoutAreaId %d", layoutAreaId);
     qDebug("layoutAreaId %d", layoutAreaId);
-    mp_layoutAreaToPidAssignment->insert(layoutAreaId, pid);
+    mp_layoutAreaToSurfaceIdAssignment->insert(layoutAreaId, surfaceId);
 
 
-#ifdef __arm__
     updateScreen();
     updateScreen();
-#endif
 
     dumpScene();
 
     dumpScene();
+
+    return result;
 }
 }
index ef19f4e..027344b 100644 (file)
 #include "windowmanager_adapter.h"
 
 
 #include "windowmanager_adapter.h"
 
 
-typedef struct
-{
-    int pid;
-    QString processName;
-} SurfaceInfo;
-
 #ifdef __arm__
 extern "C" {
 #include "ilm/ilm_control.h"
 #ifdef __arm__
 extern "C" {
 #include "ilm/ilm_control.h"
@@ -47,27 +41,22 @@ public:
     void start();
 private:
     WindowmanagerAdaptor *mp_windowManagerAdaptor;
     void start();
 private:
     WindowmanagerAdaptor *mp_windowManagerAdaptor;
-    QMap<int, QList<SimpleRect> > m_layouts;
-    QMap<int, QString> m_layoutNames;
-    QMap<int, bool> m_layoutFullScreen;
-    QMap<int, int> m_layoutFullScreenAssociated;
+    QList<Layout> m_layouts;
+    QList<int> m_surfaces;
+    QMap<int, unsigned int> *mp_layoutAreaToSurfaceIdAssignment;
+
     int m_currentLayout;
     int m_currentLayout;
-    void dumpScene();
     int m_homeScreenPid;
     int m_homeScreenPid;
+    int m_homeScreenSurfaceId;
+
+    void dumpScene();
 
 #ifdef __arm__
     void createNewLayer(int layerId);
     void addSurfaceToLayer(int surfaceId, int layerId);
 
 #ifdef __arm__
     void createNewLayer(int layerId);
     void addSurfaceToLayer(int surfaceId, int layerId);
-    void updateScreen();
-
-
-    QMap<t_ilm_uint, SurfaceInfo> *mp_surfaces;
-    /* one layer per pid is created
-    where the surfaces are added that are created by the process */
-    QList<int> *mp_processLayers;
 #endif
 #endif
+    void updateScreen();
 
 
-    QMap<int, unsigned int> *mp_layoutAreaToPidAssignment;
 
 public:
     static void* myThis;
 
 public:
     static void* myThis;
@@ -96,18 +85,26 @@ public slots:
 
 
 // from windowmanager_adapter.h
 
 
 // from windowmanager_adapter.h
+public: // PROPERTIES
+    Q_PROPERTY(int homeScreenPid READ homeScreenPid WRITE setHomeScreenPid)
+    int homeScreenPid() const;
+    void setHomeScreenPid(int value);
+
+    Q_PROPERTY(int layoutId READ layoutId)
+    int layoutId() const;
+
+    Q_PROPERTY(QString layoutName READ layoutName)
+    QString layoutName() const;
+
 public Q_SLOTS: // METHODS
 public Q_SLOTS: // METHODS
-    int addLayout(int layoutId, const QString &layoutName, bool isFullScreen, int associatedFullScreenLayout, const QList<SimpleRect> &surfaceAreas);
-    int getAssociatedFullScreenLayout(int layoutId);
+    int addLayout(int layoutId, const QString &layoutName, const QList<LayoutArea> &surfaceAreas);
+    QList<Layout> getAllLayouts();
     QList<int> getAvailableLayouts(int numberOfAppSurfaces);
     QList<int> getAvailableLayouts(int numberOfAppSurfaces);
-    QList<SimplePoint> getAvailableSurfaces();
-    int getLayout();
+    QList<int> getAvailableSurfaces();
     QString getLayoutName(int layoutId);
     QString getLayoutName(int layoutId);
-    bool isLayoutFullScreen(int layoutId);
-    void setLayoutById(int layoutId);
-    void setLayoutByName(const QString &layoutName);
-    void setPidToLayoutArea(int pid, int layoutAreaId);
-
+    int setLayoutById(int layoutId);
+    int setLayoutByName(const QString &layoutName);
+    int setSurfaceToLayoutArea(int surfaceId, int layoutAreaId);
 };
 
 
 };
 
 
index 023f54b..a405555 100644 (file)
@@ -17,7 +17,7 @@
   org.agl.homescreen:
   @short_description: A generic interface for the HomeScreen app.
 
   org.agl.homescreen:
   @short_description: A generic interface for the HomeScreen app.
 
-  This interface is a collection of methods from drifferent functional areas to control the HomeScreen app.
+  This interface is a collection of methods from different functional areas to control the HomeScreen app.
 -->
   <interface name="org.agl.homescreen">
   <!--
 -->
   <interface name="org.agl.homescreen">
   <!--
index b587b70..45c7c6e 100644 (file)
 
 #include <QtDBus>
 
 
 #include <QtDBus>
 
+#define WINDOWMANAGER_NO_ERROR 0
+#define WINDOWMANAGER_ERROR_ID_ALREADY_DEFINED 1
+#define WINDOWMANAGER_ERROR_NAME_ALREADY_DEFINED 2
+#define WINDOWMANAGER_ERROR_ID_NOT_FOUND 3
+#define WINDOWMANAGER_ERROR_NAME_NOT_FOUND 4
+
 class SimplePoint
 {
 public:
 class SimplePoint
 {
 public:
@@ -33,27 +39,43 @@ public:
 };
 
 
 };
 
 
-class SimpleRect
+class LayoutArea
 {
 public:
 {
 public:
-    SimpleRect();
-    virtual ~SimpleRect();
+    LayoutArea();
+    virtual ~LayoutArea();
 
        int x;
        int y;
        int width;
        int height;
 
 
        int x;
        int y;
        int width;
        int height;
 
-    friend QDBusArgument &operator <<(QDBusArgument &argument, const SimpleRect &mSimpleRect);
-    friend const QDBusArgument &operator >>(const QDBusArgument &argument, SimpleRect &mSimpleRect);
+    friend QDBusArgument &operator <<(QDBusArgument &argument, const LayoutArea &mLayoutArea);
+    friend const QDBusArgument &operator >>(const QDBusArgument &argument, LayoutArea &mLayoutArea);
 };
 
 };
 
+class Layout
+{
+public:
+    Layout();
+    Layout(int layoutId, const QString &layoutName, const QList<LayoutArea> &surfaceAreas);
+    virtual ~Layout();
+
+    int id;
+    QString name;
+    QList<LayoutArea> layoutAreas;
+
+    friend QDBusArgument &operator <<(QDBusArgument &argument, const Layout &mLayout);
+    friend const QDBusArgument &operator >>(const QDBusArgument &argument, Layout &mLayout);
+};
 
 Q_DECLARE_METATYPE(SimplePoint)
 Q_DECLARE_METATYPE(QList<SimplePoint>)
 
 
 Q_DECLARE_METATYPE(SimplePoint)
 Q_DECLARE_METATYPE(QList<SimplePoint>)
 
-Q_DECLARE_METATYPE(SimpleRect)
-Q_DECLARE_METATYPE(QList<SimpleRect>)
+Q_DECLARE_METATYPE(LayoutArea)
+Q_DECLARE_METATYPE(QList<LayoutArea>)
 
 
+Q_DECLARE_METATYPE(Layout)
+Q_DECLARE_METATYPE(QList<Layout>)
 
 #endif // WINDOWMANAGER_H
 
 #endif // WINDOWMANAGER_H
index 12f425e..77820ec 100644 (file)
@@ -25,11 +25,30 @@ SimplePoint::~SimplePoint()
 }
 
 
 }
 
 
-SimpleRect::SimpleRect()
+LayoutArea::LayoutArea()
 {
 }
 
 {
 }
 
-SimpleRect::~SimpleRect()
+LayoutArea::~LayoutArea()
+{
+}
+
+
+Layout::Layout():
+    id(-1),
+    name("N/A"),
+    layoutAreas()
+{
+}
+
+Layout::Layout(int layoutId, const QString &layoutName, const QList<LayoutArea> &surfaceAreas):
+    id(layoutId),
+    name(layoutName),
+    layoutAreas(surfaceAreas)
+{
+}
+
+Layout::~Layout()
 {
 }
 
 {
 }
 
@@ -52,26 +71,46 @@ const QDBusArgument &operator >>(const QDBusArgument &argument, SimplePoint &mSi
        return argument;
 }
 
        return argument;
 }
 
-QDBusArgument &operator <<(QDBusArgument &argument, const SimpleRect &mSimpleRect)
+QDBusArgument &operator <<(QDBusArgument &argument, const LayoutArea &mLayoutArea)
 {
        argument.beginStructure();
 {
        argument.beginStructure();
-       argument << mSimpleRect.x;
-       argument << mSimpleRect.y;
-       argument << mSimpleRect.width;
-       argument << mSimpleRect.height;
+    argument << mLayoutArea.x;
+    argument << mLayoutArea.y;
+    argument << mLayoutArea.width;
+    argument << mLayoutArea.height;
        argument.endStructure();
 
        return argument;
 }
 
        argument.endStructure();
 
        return argument;
 }
 
-const QDBusArgument &operator >>(const QDBusArgument &argument, SimpleRect &mSimpleRect)
+const QDBusArgument &operator >>(const QDBusArgument &argument, LayoutArea &mLayoutArea)
 {
        argument.beginStructure();
 {
        argument.beginStructure();
-    argument >> mSimpleRect.x;
-    argument >> mSimpleRect.y;
-    argument >> mSimpleRect.width;
-    argument >> mSimpleRect.height;
+    argument >> mLayoutArea.x;
+    argument >> mLayoutArea.y;
+    argument >> mLayoutArea.width;
+    argument >> mLayoutArea.height;
        argument.endStructure();
        return argument;
 }
 
        argument.endStructure();
        return argument;
 }
 
+QDBusArgument &operator <<(QDBusArgument &argument, const Layout &mLayout)
+{
+    argument.beginStructure();
+    argument << mLayout.id;
+    argument << mLayout.name;
+    argument << mLayout.layoutAreas;
+    argument.endStructure();
+
+    return argument;
+}
+
+const QDBusArgument &operator >>(const QDBusArgument &argument, Layout &mLayout)
+{
+    argument.beginStructure();
+    argument >> mLayout.id;
+    argument >> mLayout.name;
+    argument >> mLayout.layoutAreas;
+    argument.endStructure();
+    return argument;
+}
index 5aac541..67187ac 100644 (file)
  See the License for the specific language governing permissions and
  limitations under the License. -->
 <node>
  See the License for the specific language governing permissions and
  limitations under the License. -->
 <node>
-  <interface name="org.agl.windowmanager">
-      <method name="addLayout">
-        <arg name="layoutId" type="i" direction="in"/>
-        <arg name="layoutName" type="s" direction="in"/>
-        <arg name="isFullScreen" type="b" direction="in"/>
-        <arg name="associatedFullScreenLayout" type="i" direction="in"/>
-        <arg name="surfaceAreas" type="a(iiii)" direction="in"/>
-        <annotation name="org.qtproject.QtDBus.QtTypeName.In4" value="QList&lt;SimpleRect&gt;"/>
-        <arg name="error" type="i" direction="out"/>
-      </method>
-      <method name="getAvailableLayouts">
-        <arg name="numberOfAppSurfaces" type="i" direction="in"/>
-        <arg name="layoutIds" type="ai" direction="out"/>
-        <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QList&lt;int&gt;"/>
-      </method>
-      <method name="isLayoutFullScreen">
-        <arg name="layoutId" type="i" direction="in"/>
-        <arg name="fullScreen" type="b" direction="out"/>
-      </method>
-      <method name="getAssociatedFullScreenLayout">
-        <arg name="layoutId" type="i" direction="in"/>
-        <arg name="associatedFullScreenLayout" type="i" direction="out"/>
-      </method>
-      <method name="setLayoutById">
-        <arg name="layoutId" type="i" direction="in"/>
-      </method>
-      <method name="setLayoutByName">
-        <arg name="layoutName" type="s" direction="in"/>
-      </method>
-      <method name="getLayout">
-        <arg name="layoutId" type="i" direction="out"/>
-      </method>
-      <method name="setPidToLayoutArea">
-        <arg name="pid" type="i" direction="in"/>
-        <arg name="layoutAreaId" type="i" direction="in"/>
-      </method>
-      <method name="getAvailableSurfaces">
-        <arg name="surfacesAndPids" type="a(ii)" direction="out"/>
-        <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QList&lt;SimplePoint&gt;"/>
-      </method>
-      <method name="getLayoutName">
-        <arg name="layoutId" type="i" direction="in"/>
-        <arg name="layoutName" type="s" direction="out"/>
-      </method>
-  </interface>
+       <!--
+         org.agl.windowmanager:
+         @short_description: A Layout-based interface for the WindowManager.
+
+         A Layout defines a list of surfaces areas.
+       -->
+       <interface name="org.agl.windowmanager">
+               <!--
+                 addLayout:
+                 @layoutId: A unique ID that represents this layout. If the ID is already in use WINDOWMANAGER_ERROR_ID_ALREADY_DEFINED will be returned.
+                 @layoutName: A user readable string for the layout. If the string is already in use WINDOWMANAGER_ERROR_NAME_ALREADY_DEFINED will be returned.
+                 @surfaceAreas: A list of surface areas.
+                 @error: WINDOWMANAGER_NO_ERROR or the first error that occurred.
+
+                 Add a layout definition to the WindowManayer layout database.
+                 The layout database is temoprary and not stored persistently. It has to be recreated by the client after
+                 a WindowManager restart.
+               -->
+               <method name="addLayout">
+                       <arg name="layoutId" type="i" direction="in"/>
+                       <arg name="layoutName" type="s" direction="in"/>
+                       <arg name="surfaceAreas" type="a(iiii)" direction="in"/>
+                       <annotation name="org.qtproject.QtDBus.QtTypeName.In2" value="QList&lt;LayoutArea&gt;"/>
+                       <arg name="error" type="i" direction="out"/>
+               </method>
+
+               <!--
+                 setLayoutById:
+                 @layoutId: The ID of the layout to activate.
+                 @error: WINDOWMANAGER_NO_ERROR or the first error that occurred.
+
+                 Switch to the layout with the given ID.
+               -->
+               <method name="setLayoutById">
+                       <arg name="layoutId" type="i" direction="in"/>
+                       <arg name="error" type="i" direction="out"/>
+               </method>
+               <!--
+                 setLayoutByName:
+                 @layoutName: The name of the layout to activate.
+                 @error: WINDOWMANAGER_NO_ERROR or the first error that occurred.
+
+                 Switch to the layout with the given name.
+               -->
+               <method name="setLayoutByName">
+                       <arg name="layoutName" type="s" direction="in"/>
+                       <arg name="error" type="i" direction="out"/>
+               </method>
+
+               <!--
+                 getLayoutName:
+                 @layoutId: The ID of the requested layout name.
+                 @layoutName: The name of the layout with the given ID.
+
+                 Request the name of the layout with the given ID. This does not set or activate a layout.
+                 It is just returning the name of the given layout.
+               -->
+               <method name="getLayoutName">
+                       <arg name="layoutId" type="i" direction="in"/>
+                       <arg name="layoutName" type="s" direction="out"/>
+               </method>
+
+               <!--
+                 layout:
+                 The current active layout with all its information.
+               -->
+               <property>
+                       <arg name="layout" type="(isa(iiii))" access="read"/>
+                       <annotation name="org.qtproject.QtDBus.QtTypeName" value="Layout"/>
+               </property>
+               <!--
+                 layoutId:
+                 The current active layout id. This property is redundant, since its info is already available
+                 in the property layout. But this property is more lightweight.
+               -->
+               <property name="layoutId" type="i" access="read"/>
+               <!--
+                 layoutName:
+                 The name of the current active layout. This property is redundant, since its info is already available
+                 in the property layout. But this property is more lightweight.
+               -->
+               <property name="layoutName" type="s" access="read"/>
+
+               <!--
+                 getAllLayouts:
+                 @layouts: A list of all layouts.
+
+                 Returns a list of all layouts that were added to the WindowManager.
+               -->
+               <method name="getAllLayouts">
+                       <arg name="layoutIds" type="a(isa(iiii))" direction="out"/>
+                       <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QList&lt;Layout&gt;"/>
+               </method>
+
+               <!--
+                 getAvailableLayouts:
+                 @numberOfAppSurfaces: The ID of the requested layout name.
+                 @layoutIds: A list of layouts that offer the exact requested ammount of surface render areas.
+
+                 Returns a list of layouts that offer the exact requested ammount of surface render areas.
+                 If the list is empty, no layout fits the exact ammount.
+               -->
+               <method name="getAvailableLayouts">
+                       <arg name="numberOfAppSurfaces" type="i" direction="in"/>
+                       <arg name="layoutIds" type="ai" direction="out"/>
+                       <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QList&lt;int&gt;"/>
+               </method>
+
+               <!--
+                 setSurfaceToLayoutArea:
+                 @surfaceId: The ID of the surface that shall be positioned.
+                 @layoutAreaId: The ID of the layout area where the surface shall be rendered.
+                 @error: WINDOWMANAGER_NO_ERROR or the first error that occurred.
+
+                 The surface will be scaled to the size of the layout area.
+                 The surface will be made visible with this call.
+               -->
+               <method name="setSurfaceToLayoutArea">
+                       <arg name="surfaceId" type="i" direction="in"/>
+                       <arg name="layoutAreaId" type="i" direction="in"/>
+                       <arg name="error" type="i" direction="out"/>
+               </method>
+
+               <!--
+                 getAvailableSurfaces:
+                 @surfaceIds: A list of all known surfaceIds except for the surfaces created by the Home Screen app.
+
+                 If no surfaces are available, the returned list is empty.
+               -->
+               <method name="getAvailableSurfaces">
+                       <arg name="surfaceIds" type="a(i)" direction="out"/>
+                       <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QList&lt;int&gt;"/> 
+               </method>
+
+               <!--
+                 homeScreenPid:
+                 The PID of the Home Screen app. The Home Screen app requires a special handling.
+                 It will always be visible in the background. So it will be placed in a special layer at the lowest z-order.
+               -->
+               <property name="homeScreenPid" type="i" access="readwrite"/>
+       </interface>
 </node>
 
 </node>
 
index 86a09cd..81c546e 100644 (file)
@@ -194,6 +194,14 @@ $dbus-send --session --type=method_call --print-reply --dest=org.agl.homescreen
 Interface:
 org.agl.windowmanager
 
 Interface:
 org.agl.windowmanager
 
+
+dbus-send --session --type=method_call --print-reply --dest=org.agl.windowmanager /windowmanager org.freedesktop.DBus.Properties.GetAll string:"org.agl.windowmanager"
+
+dbus-send --session --type=method_call --print-reply --dest=org.agl.windowmanager /windowmanager org.freedesktop.DBus.Properties.Get string:"org.agl.windowmanager" string:"homeScreenPid"
+
+dbus-send --session --type=method_call --print-reply --dest=org.agl.windowmanager /windowmanager org.freedesktop.DBus.Properties.Set string:"org.agl.windowmanager" string:"homeScreenPid" variant:int32:1
+
+
 Method:
       <method name="addLayout">
         <arg name="layoutId" type="i" direction="in"/>
 Method:
       <method name="addLayout">
         <arg name="layoutId" type="i" direction="in"/>