Enable automcatic startup of Homescreen app
[staging/HomeScreen.git] / WindowManager / src / windowmanager.cpp
index 3c5c881..a03bab6 100644 (file)
@@ -15,8 +15,7 @@
  */
 
 #include "windowmanager.hpp"
-#include <wayland-client.h>
-#include <QFile>
+
 
 //////////////////////////////////////////
 // THIS IS STILL UNDER HEAVY DEVELOPMENT!
@@ -32,7 +31,7 @@
 #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
@@ -48,23 +47,22 @@ WindowManager::WindowManager(QObject *parent) :
     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<int, unsigned int>;
-#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);
@@ -74,13 +72,20 @@ void WindowManager::start()
     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;
@@ -110,7 +115,7 @@ void WindowManager::dumpScene()
     }
 }
 
-#ifdef __arm__
+#ifdef HAVE_IVI_LAYERMANAGEMENT_API
 
 void WindowManager::createNewLayer(int layerId)
 {
@@ -220,7 +225,7 @@ void WindowManager::updateScreen()
 {
     qDebug("-=[updateScreen]=-");
 
-#ifdef __arm__
+#ifdef HAVE_IVI_LAYERMANAGEMENT_API
     if (-1 != m_currentLayout)
     {
 
@@ -283,7 +288,7 @@ void WindowManager::updateScreen()
 #endif
 }
 
-#ifdef __arm__
+#ifdef HAVE_IVI_LAYERMANAGEMENT_API
 void WindowManager::notificationFunc_non_static(ilmObjectType object,
                                     t_ilm_uint id,
                                     t_ilm_bool created)
@@ -349,7 +354,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)
     {
@@ -379,6 +384,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();
     }
 }
@@ -472,7 +488,7 @@ QList<Layout> WindowManager::getAllLayouts()
 QList<int> WindowManager::getAllSurfacesOfProcess(int pid)
 {
     QList<int> result;
-#ifdef __arm__
+#ifdef HAVE_IVI_LAYERMANAGEMENT_API
     struct ilmSurfaceProperties surfaceProperties;
 
     for (int i = 0; i < m_surfaces.size(); ++i)
@@ -537,7 +553,7 @@ void WindowManager::hideLayer(int layer)
     qDebug("-=[hideLayer]=-");
     qDebug("layer %d", layer);
 
-#ifdef __arm__
+#ifdef HAVE_IVI_LAYERMANAGEMENT_API
     if (0 == layer)
     {
         ilm_layerSetVisibility(WINDOWMANAGER_LAYER_POPUP, ILM_FALSE);
@@ -616,7 +632,7 @@ void WindowManager::showLayer(int layer)
     qDebug("-=[showLayer]=-");
     qDebug("layer %d", layer);
 
-#ifdef __arm__
+#ifdef HAVE_IVI_LAYERMANAGEMENT_API
     if (0 == layer)
     {
         ilm_layerSetVisibility(WINDOWMANAGER_LAYER_POPUP, ILM_TRUE);