+#if 0
+ m_appSurfaces.removeAt(m_appSurfaces.indexOf(id));
+ ilm_surfaceRemoveNotification(id);
+
+ ilm_commitChanges();
+#endif
+ }
+ }
+ if (ILM_LAYER == object)
+ {
+ //qDebug("Layer.. we don't care...");
+ }
+}
+
+void WindowManager::notificationFunc_static(ilmObjectType object,
+ t_ilm_uint id,
+ t_ilm_bool created,
+ void* user_data)
+{
+ 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)
+{
+ qDebug("-=[surfaceCallbackFunction_non_static]=-");
+ qDebug("surfaceCallbackFunction_non_static changes for surface %d", 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");
+ /* add surface to layer for the application */
+
+ ilmErrorTypes result;
+ pid_t pid = surfaceProperties->creatorPid;
+
+ QMap<pid_t, t_ilm_layer>::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();
+ }
+}
+
+void WindowManager::surfaceCallbackFunction_static(t_ilm_surface surface,
+ struct ilmSurfaceProperties* surfaceProperties,
+ t_ilm_notification_mask mask)
+
+{
+ static_cast<WindowManager*>(WindowManager::myThis)->surfaceCallbackFunction_non_static(surface, surfaceProperties, mask);
+}
+#endif
+
+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]=-");
+ m_layouts.append(Layout(layoutId, layoutName, surfaceAreas));
+
+ qDebug("addLayout %d %s, size %d",
+ layoutId,
+ layoutName.toStdString().c_str(),
+ surfaceAreas.size());
+
+ dumpScene();
+
+ 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<Layout>::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<Layout> WindowManager::getAllLayouts()
+{
+ qDebug("-=[getAllLayouts]=-");
+
+ return m_layouts;
+}
+
+#if 0
+QList<int> WindowManager::getAllSurfacesOfProcess(int pid)
+{
+ QList<int> result;
+#ifdef HAVE_IVI_LAYERMANAGEMENT_API
+ struct ilmSurfaceProperties surfaceProperties;
+
+ for (int i = 0; i < m_appSurfaces.size(); ++i)
+ {
+ ilm_getPropertiesOfSurface(m_appSurfaces.at(i), &surfaceProperties);
+ if (pid == surfaceProperties.creatorPid)
+ {
+ result.append(m_appSurfaces.at(i));
+ }
+ }
+#endif
+ return result;
+}
+#endif
+
+QList<int> WindowManager::getAvailableLayouts(int numberOfAppSurfaces)
+{
+ qDebug("-=[getAvailableLayouts]=-");
+ QList<Layout>::const_iterator i = m_layouts.begin();
+
+ QList<int> result;
+ while (i != m_layouts.constEnd())
+ {
+ if (i->layoutAreas.size() == numberOfAppSurfaces)
+ {
+ result.append(i->id);