*/
#include "windowmanager.hpp"
-#include <wayland-client.h>
-#include <QFile>
+
//////////////////////////////////////////
// THIS IS STILL UNDER HEAVY DEVELOPMENT!
// 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
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);
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;
}
}
-#ifdef __arm__
+#ifdef HAVE_IVI_LAYERMANAGEMENT_API
void WindowManager::createNewLayer(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;
{
qDebug("-=[updateScreen]=-");
-#ifdef __arm__
+#ifdef HAVE_IVI_LAYERMANAGEMENT_API
if (-1 != m_currentLayout)
{
ilm_commitChanges();
}
+ // display layer render order
t_ilm_layer renderOrder[WINDOWMANAGER_LAYER_NUM];
renderOrder[0] = WINDOWMANAGER_LAYER_HOMESCREEN;
renderOrder[1] = WINDOWMANAGER_LAYER_APPLICATIONS;
- renderOrder[2] = WINDOWMANAGER_LAYER_POPUP;
-
+ renderOrder[2] = WINDOWMANAGER_LAYER_HOMESCREEN_OVERLAY;
+ renderOrder[3] = 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_getSurfaceIDsOnLayer(WINDOWMANAGER_LAYER_APPLICATIONS, &length, &pArray);
+ ilm_layerSetRenderOrder(WINDOWMANAGER_LAYER_APPLICATIONS, pArray, length);
+ ilm_getSurfaceIDsOnLayer(WINDOWMANAGER_LAYER_HOMESCREEN_OVERLAY, &length, &pArray);
+ ilm_layerSetRenderOrder(WINDOWMANAGER_LAYER_HOMESCREEN_OVERLAY, pArray, length);
+ ilm_getSurfaceIDsOnLayer(WINDOWMANAGER_LAYER_POPUP, &length, &pArray);
+ ilm_layerSetRenderOrder(WINDOWMANAGER_LAYER_POPUP, pArray, length);
+
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)
if (ILM_NOTIFICATION_VISIBILITY & mask)
{
qDebug("ILM_NOTIFICATION_VISIBILITY");
+ surfaceVisibilityChanged(surface, surfaceProperties->visibility);
}
if (ILM_NOTIFICATION_OPACITY & mask)
{
if (ILM_NOTIFICATION_CONTENT_AVAILABLE & mask)
{
qDebug("ILM_NOTIFICATION_CONTENT_AVAILABLE");
+ updateScreen();
}
if (ILM_NOTIFICATION_CONTENT_REMOVED & mask)
{
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();
}
}
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]=-");
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)
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)
{
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
+}