2 * Copyright (C) 2016, 2017 Mentor Graphics Development (Deutschland) GmbH
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "windowmanager.hpp"
20 //////////////////////////////////////////
21 // THIS IS STILL UNDER HEAVY DEVELOPMENT!
22 // DO NOT JUDGE THE SOURCE CODE :)
23 //////////////////////////////////////////
25 // three layers will be defined. The HomeScreen will be placed
26 // full screen in the background.
27 // On top all applications in one layer.
28 // On top of that, the popup layer.
29 #define WINDOWMANAGER_LAYER_POPUP 100
30 #define WINDOWMANAGER_LAYER_HOMESCREEN_OVERLAY 101
31 #define WINDOWMANAGER_LAYER_APPLICATIONS 102
32 #define WINDOWMANAGER_LAYER_HOMESCREEN 103
34 #define WINDOWMANAGER_LAYER_NUM 4
36 #define WINDOWMANAGER_SURFACE_ID_SHIFT 22
38 // the HomeScreen app has to have the surface id 4194304
39 #define WINDOWMANAGER_HOMESCREEN_MAIN_SURFACE_ID (1 << WINDOWMANAGER_SURFACE_ID_SHIFT)
41 // Quick hack for scaling layer to fit non-FHD(1920x1080) screen
42 // * source rect of layer should be 1920x1080
43 // * destination rect of layer should fit physical display resolution
44 // * source rect of surface shoud be based on 1920x1080
45 // * destination rect of surface should be based on 1920x1080
46 #define WINDOWMANAGER_HOMESCREEN_WIDTH 1080
47 #define WINDOWMANAGER_HOMESCREEN_HEIGHT 1920
49 void* WindowManager::myThis = 0;
51 WindowManager::WindowManager(int displayId, QObject *parent) :
54 mp_layoutAreaToSurfaceIdAssignment(0),
56 m_screenId(displayId),
59 #ifdef HAVE_IVI_LAYERMANAGEMENT_API
66 #ifdef HAVE_IVI_LAYERMANAGEMENT_API
67 m_showLayers = new t_ilm_layer[WINDOWMANAGER_LAYER_NUM];
69 m_showLayers[0] = 0; /* POPUP is not shown by default */
70 m_showLayers[1] = 0; /* HOMESCREEN_OVERLAY is not shown by default */
71 m_showLayers[2] = 0; /* APPLICATIONS is not shown by default */
72 m_showLayers[3] = WINDOWMANAGER_LAYER_HOMESCREEN; /* HOMESCREEN is shwon by default */
75 qDebug("-=[WindowManager]=-");
78 void WindowManager::start()
80 qDebug("-=[start]=-");
81 mp_layoutAreaToSurfaceIdAssignment = new QMap<int, unsigned int>;
82 #ifdef HAVE_IVI_LAYERMANAGEMENT_API
86 qDebug("ilm_init = %d", err);
87 if(ILM_SUCCESS != err)
89 qDebug("failed! Exiting!");
95 ilm_getScreenResolution(m_screenId, &m_screenWidth, &m_screenHeight);
97 createNewLayer(WINDOWMANAGER_LAYER_POPUP);
98 createNewLayer(WINDOWMANAGER_LAYER_HOMESCREEN_OVERLAY);
99 createNewLayer(WINDOWMANAGER_LAYER_HOMESCREEN);
101 ilm_registerNotification(WindowManager::notificationFunc_static, this);
104 QDBusConnection dbus = QDBusConnection::sessionBus();
105 dbus.registerObject("/windowmanager", this);
106 dbus.registerService("org.agl.windowmanager");
108 // publish windowmanager interface
109 mp_windowManagerAdaptor = new WindowmanagerAdaptor((QObject*)this);
112 WindowManager::~WindowManager()
114 qDebug("-=[~WindowManager]=-");
115 delete mp_windowManagerAdaptor;
116 #ifdef HAVE_IVI_LAYERMANAGEMENT_API
119 delete mp_layoutAreaToSurfaceIdAssignment;
122 #ifdef HAVE_IVI_LAYERMANAGEMENT_API
123 int WindowManager::getLayerRenderOrder(t_ilm_layer id_array[])
127 for (i = WINDOWMANAGER_LAYER_NUM - 1, j = 0; i >= 0; i--) {
128 if (m_showLayers[i] != 0) {
129 id_array[j++] = m_showLayers[i];
137 void WindowManager::dumpScene()
140 qDebug("current layout : %d", m_currentLayout);
141 qDebug("available layouts: %d", m_layouts.size());
142 QList<Layout>::const_iterator i = m_layouts.begin();
144 while (i != m_layouts.constEnd())
146 qDebug("--[id: %d]--[%s]--", i->id, i->name.toStdString().c_str());
147 qDebug(" %d surface areas", i->layoutAreas.size());
148 for (int j = 0; j < i->layoutAreas.size(); ++j)
150 qDebug(" -area %d", j);
151 qDebug(" -x : %d", i->layoutAreas.at(j).x);
152 qDebug(" -y : %d", i->layoutAreas.at(j).y);
153 qDebug(" -width : %d", i->layoutAreas.at(j).width);
154 qDebug(" -height: %d", i->layoutAreas.at(j).height);
161 #ifdef HAVE_IVI_LAYERMANAGEMENT_API
163 void WindowManager::createNewLayer(int layerId)
165 qDebug("-=[createNewLayer]=-");
166 qDebug(" layerId %d", layerId);
168 t_ilm_layer newLayerId = layerId;
169 ilm_layerCreateWithDimension(&newLayerId,
170 WINDOWMANAGER_HOMESCREEN_WIDTH,
171 WINDOWMANAGER_HOMESCREEN_HEIGHT);
173 ilm_layerSetSourceRectangle(newLayerId,
176 WINDOWMANAGER_HOMESCREEN_WIDTH,
177 WINDOWMANAGER_HOMESCREEN_HEIGHT);
178 ilm_layerSetDestinationRectangle(newLayerId,
184 ilm_layerSetOpacity(newLayerId, 1.0);
185 ilm_layerSetVisibility(newLayerId, ILM_TRUE);
189 t_ilm_layer WindowManager::getAppLayerID(pid_t pid)
191 t_ilm_layer layer_id;
193 // layer_id = pid + (WINDOWMANAGER_LAYER_APPLICATIONS << WINDOWMANAGER_LAYER_ID_SHIFT);
194 layer_id = pid + (WINDOWMANAGER_LAYER_APPLICATIONS * 100000); /* for debug */
199 void WindowManager::addSurface(t_ilm_surface surfaceId)
201 struct ilmSurfaceProperties surfaceProperties;
204 ilm_getPropertiesOfSurface(surfaceId, &surfaceProperties);
205 pid = surfaceProperties.creatorPid;
207 QMap<pid_t, t_ilm_surface>::const_iterator i = m_appSurfaces.find(pid);
208 if (i != m_appSurfaces.end() && i.value() == 0) {
209 /* Only the 1st surface is handled by Window Manager */
210 qDebug("This surface (%d) is 1st one for app (%d)", surfaceId, pid);
211 /* update surface id */
212 m_appSurfaces.insert(pid, surfaceId);
214 /* this surface should be handled by WindowManager */
215 ilm_surfaceAddNotification(surfaceId, surfaceCallbackFunction_static);
220 t_ilm_layer WindowManager::addSurfaceToAppLayer(pid_t pid, int surfaceId)
222 struct ilmSurfaceProperties surfaceProperties;
223 t_ilm_layer layer_id;
226 qDebug("-=[addSurfaceToAppLayer]=-");
227 qDebug(" surfaceId %d", surfaceId);
232 QMap<pid_t, t_ilm_layer>::const_iterator i = m_appLayers.find(pid);
233 if (i == m_appLayers.end()) {
234 qDebug("No layer found, create new for app(pid=%d)", pid);
236 /* not found, create new one */
237 layer_id = getAppLayerID(pid);
239 createNewLayer(layer_id);
240 m_appLayers.insert(pid, layer_id);
242 layer_id = i.value();
248 void WindowManager::addSurfaceToLayer(int surfaceId, int layerId)
250 qDebug("-=[addSurfaceToLayer]=-");
251 qDebug(" surfaceId %d", surfaceId);
252 qDebug(" layerId %d", layerId);
254 if (layerId == WINDOWMANAGER_LAYER_HOMESCREEN)
256 ilm_layerAddSurface(layerId, surfaceId);
258 else if (layerId == WINDOWMANAGER_LAYER_HOMESCREEN_OVERLAY)
260 struct ilmSurfaceProperties surfaceProperties;
261 ilm_getPropertiesOfSurface(surfaceId, &surfaceProperties);
263 //ilm_surfaceSetDestinationRectangle(surfaceId, 0, 0, surfaceProperties.origSourceWidth, surfaceProperties.origSourceHeight);
264 //ilm_surfaceSetSourceRectangle(surfaceId, 0, 0, surfaceProperties.origSourceWidth, surfaceProperties.origSourceHeight);
265 //ilm_surfaceSetOpacity(surfaceId, 0.5);
266 //ilm_surfaceSetVisibility(surfaceId, ILM_TRUE);
268 ilm_layerAddSurface(layerId, surfaceId);
270 else if (layerId == WINDOWMANAGER_LAYER_POPUP)
272 struct ilmSurfaceProperties surfaceProperties;
273 ilm_getPropertiesOfSurface(surfaceId, &surfaceProperties);
275 //ilm_surfaceSetDestinationRectangle(surfaceId, 0, 0, surfaceProperties.origSourceWidth, surfaceProperties.origSourceHeight);
276 //ilm_surfaceSetSourceRectangle(surfaceId, 0, 0, surfaceProperties.origSourceWidth, surfaceProperties.origSourceHeight);
277 //ilm_surfaceSetOpacity(surfaceId, 0.0);
278 //ilm_surfaceSetVisibility(surfaceId, ILM_FALSE);
280 ilm_layerAddSurface(layerId, surfaceId);
288 void WindowManager::configureHomeScreenMainSurface(t_ilm_surface surface, t_ilm_int width, t_ilm_int height)
290 // homescreen app always fullscreen in the back
291 ilm_surfaceSetDestinationRectangle(surface, 0, 0,
292 WINDOWMANAGER_HOMESCREEN_WIDTH,
293 WINDOWMANAGER_HOMESCREEN_HEIGHT);
294 ilm_surfaceSetSourceRectangle(surface, 0, 0, width, height);
295 ilm_surfaceSetOpacity(surface, 1.0);
296 ilm_surfaceSetVisibility(surface, ILM_TRUE);
301 void WindowManager::configureAppSurface(pid_t pid, t_ilm_surface surface, t_ilm_int width, t_ilm_int height)
303 /* Dirty hack! cut & paste from HomeScreen/src/layouthandler.cpp */
304 const int SCREEN_WIDTH = 1080;
305 const int SCREEN_HEIGHT = 1920;
307 const int TOPAREA_HEIGHT = 218;
308 const int TOPAREA_WIDTH = SCREEN_WIDTH;
309 const int TOPAREA_X = 0;
310 const int TOPAREA_Y = 0;
311 const int MEDIAAREA_HEIGHT = 215;
312 const int MEDIAAREA_WIDTH = SCREEN_WIDTH;
313 const int MEDIAAREA_X = 0;
314 const int MEDIAAREA_Y = SCREEN_HEIGHT - MEDIAAREA_HEIGHT;
316 ilm_surfaceSetDestinationRectangle(surface,
320 SCREEN_HEIGHT - TOPAREA_HEIGHT - MEDIAAREA_HEIGHT);
321 ilm_surfaceSetSourceRectangle(surface, 0, 0, width, height);
322 ilm_surfaceSetOpacity(surface, 1.0);
323 ilm_surfaceSetVisibility(surface, ILM_TRUE); /* Hack to avoid blank screen when switch apps */
329 void WindowManager::updateScreen()
331 qDebug("-=[updateScreen]=-");
334 //#ifdef HAVE_IVI_LAYERMANAGEMENT_API
335 if (-1 != m_currentLayout)
338 for (int i = 0; i < m_appSurfaces.size(); ++i)
340 ilm_layerRemoveSurface(WINDOWMANAGER_LAYER_APPLICATIONS, m_appSurfaces.at(i));
341 //ilm_surfaceSetVisibility(m_appSurfaces.at(i), ILM_FALSE);
342 //ilm_surfaceSetOpacity(m_appSurfaces.at(i), 0.0);
346 // find the current used layout
347 QList<Layout>::const_iterator ci = m_layouts.begin();
349 Layout currentLayout;
350 while (ci != m_layouts.constEnd())
352 if (ci->id == m_currentLayout)
360 qDebug("show %d apps", mp_layoutAreaToSurfaceIdAssignment->size());
361 for (int j = 0; j < mp_layoutAreaToSurfaceIdAssignment->size(); ++j)
363 int surfaceToShow = mp_layoutAreaToSurfaceIdAssignment->find(j).value();
364 qDebug(" surface no. %d: %d", j, surfaceToShow);
366 addSurfaceToLayer(surfaceToShow, WINDOWMANAGER_LAYER_APPLICATIONS);
368 ilm_surfaceSetVisibility(surfaceToShow, ILM_TRUE);
369 ilm_surfaceSetOpacity(surfaceToShow, 1.0);
371 qDebug(" layout area %d", j);
372 qDebug(" x: %d", currentLayout.layoutAreas[j].x);
373 qDebug(" y: %d", currentLayout.layoutAreas[j].y);
374 qDebug(" w: %d", currentLayout.layoutAreas[j].width);
375 qDebug(" h: %d", currentLayout.layoutAreas[j].height);
377 ilm_surfaceSetDestinationRectangle(surfaceToShow,
378 currentLayout.layoutAreas[j].x,
379 currentLayout.layoutAreas[j].y,
380 currentLayout.layoutAreas[j].width,
381 currentLayout.layoutAreas[j].height);
386 // layer surface render order
388 t_ilm_surface* pArray;
389 ilm_getSurfaceIDsOnLayer(WINDOWMANAGER_LAYER_HOMESCREEN, &length, &pArray);
390 ilm_layerSetRenderOrder(WINDOWMANAGER_LAYER_HOMESCREEN, pArray, length);
392 ilm_getSurfaceIDsOnLayer(WINDOWMANAGER_LAYER_APPLICATIONS, &length, &pArray);
393 ilm_layerSetRenderOrder(WINDOWMANAGER_LAYER_APPLICATIONS, pArray, length);
395 ilm_getSurfaceIDsOnLayer(WINDOWMANAGER_LAYER_HOMESCREEN_OVERLAY, &length, &pArray);
396 ilm_layerSetRenderOrder(WINDOWMANAGER_LAYER_HOMESCREEN_OVERLAY, pArray, length);
398 ilm_getSurfaceIDsOnLayer(WINDOWMANAGER_LAYER_POPUP, &length, &pArray);
399 ilm_layerSetRenderOrder(WINDOWMANAGER_LAYER_POPUP, pArray, length);
402 #ifdef HAVE_IVI_LAYERMANAGEMENT_API
403 if (m_pending_to_show != -1) {
404 qDebug("show pending app (%d)", m_pending_to_show);
405 showAppLayer(m_pending_to_show);
407 // display layer render order
408 t_ilm_layer renderOrder[WINDOWMANAGER_LAYER_NUM];
409 int num_layers = getLayerRenderOrder(renderOrder);
411 qDebug("Screen render order %d, %d layers", m_screenId, num_layers);
412 ilm_displaySetRenderOrder(m_screenId, renderOrder, num_layers);
418 #ifdef HAVE_IVI_LAYERMANAGEMENT_API
419 void WindowManager::notificationFunc_non_static(ilmObjectType object,
423 qDebug("-=[notificationFunc_non_static]=-");
424 qDebug("Notification from weston!");
425 if (ILM_SURFACE == object)
427 struct ilmSurfaceProperties surfaceProperties;
431 if (WINDOWMANAGER_HOMESCREEN_MAIN_SURFACE_ID == id)
433 ilm_surfaceAddNotification(id, surfaceCallbackFunction_static);
443 qDebug("Surface destroyed, ID: %d", id);
445 m_appSurfaces.removeAt(m_appSurfaces.indexOf(id));
446 ilm_surfaceRemoveNotification(id);
452 if (ILM_LAYER == object)
454 //qDebug("Layer.. we don't care...");
458 void WindowManager::notificationFunc_static(ilmObjectType object,
463 static_cast<WindowManager*>(WindowManager::myThis)->notificationFunc_non_static(object, id, created);
466 void WindowManager::surfaceCallbackFunction_non_static(t_ilm_surface surface,
467 struct ilmSurfaceProperties* surfaceProperties,
468 t_ilm_notification_mask mask)
470 qDebug("-=[surfaceCallbackFunction_non_static]=-");
471 qDebug("surfaceCallbackFunction_non_static changes for surface %d", surface);
472 if (ILM_NOTIFICATION_VISIBILITY & mask)
474 qDebug("ILM_NOTIFICATION_VISIBILITY");
475 surfaceVisibilityChanged(surface, surfaceProperties->visibility);
478 if (ILM_NOTIFICATION_OPACITY & mask)
480 qDebug("ILM_NOTIFICATION_OPACITY");
482 if (ILM_NOTIFICATION_ORIENTATION & mask)
484 qDebug("ILM_NOTIFICATION_ORIENTATION");
486 if (ILM_NOTIFICATION_SOURCE_RECT & mask)
488 qDebug("ILM_NOTIFICATION_SOURCE_RECT");
490 if (ILM_NOTIFICATION_DEST_RECT & mask)
492 qDebug("ILM_NOTIFICATION_DEST_RECT");
494 if (ILM_NOTIFICATION_CONTENT_AVAILABLE & mask)
496 qDebug("ILM_NOTIFICATION_CONTENT_AVAILABLE");
498 if (ILM_NOTIFICATION_CONTENT_REMOVED & mask)
500 qDebug("ILM_NOTIFICATION_CONTENT_REMOVED");
502 /* application being down */
503 m_appLayers.remove(surfaceProperties->creatorPid);
505 if (ILM_NOTIFICATION_CONFIGURED & mask)
507 qDebug("ILM_NOTIFICATION_CONFIGURED");
508 qDebug(" surfaceProperties %d", surface);
509 qDebug(" surfaceProperties.origSourceWidth: %d", surfaceProperties->origSourceWidth);
510 qDebug(" surfaceProperties.origSourceHeight: %d", surfaceProperties->origSourceHeight);
512 if (surface == WINDOWMANAGER_HOMESCREEN_MAIN_SURFACE_ID) {
513 addSurfaceToLayer(surface, WINDOWMANAGER_LAYER_HOMESCREEN);
514 configureHomeScreenMainSurface(surface, surfaceProperties->origSourceWidth, surfaceProperties->origSourceHeight);
516 ilmErrorTypes result;
517 pid_t pid = surfaceProperties->creatorPid;
518 t_ilm_layer layer = addSurfaceToAppLayer(pid, surface);
521 configureAppSurface(pid, surface,
522 surfaceProperties->origSourceWidth,
523 surfaceProperties->origSourceHeight);
525 result = ilm_layerAddSurface(layer, surface);
526 if (result != ILM_SUCCESS) {
527 qDebug("ilm_layerAddSurface(%d,%d) failed.", layer, surface);
536 void WindowManager::surfaceCallbackFunction_static(t_ilm_surface surface,
537 struct ilmSurfaceProperties* surfaceProperties,
538 t_ilm_notification_mask mask)
541 static_cast<WindowManager*>(WindowManager::myThis)->surfaceCallbackFunction_non_static(surface, surfaceProperties, mask);
545 int WindowManager::layoutId() const
547 return m_currentLayout;
550 QString WindowManager::layoutName() const
552 QList<Layout>::const_iterator i = m_layouts.begin();
554 QString result = "not found";
555 while (i != m_layouts.constEnd())
557 if (i->id == m_currentLayout)
569 int WindowManager::addLayout(int layoutId, const QString &layoutName, const QList<LayoutArea> &surfaceAreas)
571 qDebug("-=[addLayout]=-");
572 m_layouts.append(Layout(layoutId, layoutName, surfaceAreas));
574 qDebug("addLayout %d %s, size %d",
576 layoutName.toStdString().c_str(),
577 surfaceAreas.size());
581 return WINDOWMANAGER_NO_ERROR;
584 int WindowManager::deleteLayoutById(int layoutId)
586 qDebug("-=[deleteLayoutById]=-");
587 qDebug("layoutId: %d", layoutId);
588 int result = WINDOWMANAGER_NO_ERROR;
590 if (m_currentLayout == layoutId)
592 result = WINDOWMANAGER_ERROR_ID_IN_USE;
596 QList<Layout>::iterator i = m_layouts.begin();
597 result = WINDOWMANAGER_ERROR_ID_IN_USE;
598 while (i != m_layouts.constEnd())
600 if (i->id == layoutId)
603 result = WINDOWMANAGER_NO_ERROR;
615 QList<Layout> WindowManager::getAllLayouts()
617 qDebug("-=[getAllLayouts]=-");
623 QList<int> WindowManager::getAllSurfacesOfProcess(int pid)
626 #ifdef HAVE_IVI_LAYERMANAGEMENT_API
627 struct ilmSurfaceProperties surfaceProperties;
629 for (int i = 0; i < m_appSurfaces.size(); ++i)
631 ilm_getPropertiesOfSurface(m_appSurfaces.at(i), &surfaceProperties);
632 if (pid == surfaceProperties.creatorPid)
634 result.append(m_appSurfaces.at(i));
642 QList<int> WindowManager::getAvailableLayouts(int numberOfAppSurfaces)
644 qDebug("-=[getAvailableLayouts]=-");
645 QList<Layout>::const_iterator i = m_layouts.begin();
648 while (i != m_layouts.constEnd())
650 if (i->layoutAreas.size() == numberOfAppSurfaces)
652 result.append(i->id);
662 QList<int> WindowManager::getAvailableSurfaces()
664 qDebug("-=[getAvailableSurfaces]=-");
666 return m_appSurfaces;
670 QString WindowManager::getLayoutName(int layoutId)
672 qDebug("-=[getLayoutName]=-");
673 QList<Layout>::const_iterator i = m_layouts.begin();
675 QString result = "not found";
676 while (i != m_layouts.constEnd())
678 if (i->id == layoutId)
689 void WindowManager::hideLayer(int layer)
691 qDebug("-=[hideLayer]=-");
692 qDebug("layer %d", layer);
694 #ifdef HAVE_IVI_LAYERMANAGEMENT_API
695 // POPUP=0, HOMESCREEN_OVERLAY=1, APPS=2, HOMESCREEN=3
696 if (layer >= 0 && layer < WINDOWMANAGER_LAYER_NUM) {
697 /* hide target layer */
698 m_showLayers[layer] = 0;
700 /* clear pending flag */
701 m_pending_to_show = -1;
704 t_ilm_layer renderOrder[WINDOWMANAGER_LAYER_NUM];
705 int num_layers = getLayerRenderOrder(renderOrder);
706 ilm_displaySetRenderOrder(m_screenId, renderOrder, num_layers);
712 int WindowManager::setLayoutById(int layoutId)
714 qDebug("-=[setLayoutById]=-");
715 int result = WINDOWMANAGER_NO_ERROR;
716 m_currentLayout = layoutId;
718 mp_layoutAreaToSurfaceIdAssignment->clear();
725 int WindowManager::setLayoutByName(const QString &layoutName)
727 qDebug("-=[setLayoutByName]=-");
728 int result = WINDOWMANAGER_NO_ERROR;
730 QList<Layout>::const_iterator i = m_layouts.begin();
732 while (i != m_layouts.constEnd())
734 if (i->name == layoutName)
736 m_currentLayout = i->id;
738 mp_layoutAreaToSurfaceIdAssignment->clear();
749 int WindowManager::setSurfaceToLayoutArea(int surfaceId, int layoutAreaId)
751 qDebug("-=[setSurfaceToLayoutArea]=-");
752 int result = WINDOWMANAGER_NO_ERROR;
754 qDebug("surfaceId %d", surfaceId);
755 qDebug("layoutAreaId %d", layoutAreaId);
756 mp_layoutAreaToSurfaceIdAssignment->insert(layoutAreaId, surfaceId);
765 void WindowManager::showLayer(int layer)
767 qDebug("-=[showLayer]=-");
768 qDebug("layer %d", layer);
770 #ifdef HAVE_IVI_LAYERMANAGEMENT_API
771 // POPUP=0, HOMESCREEN_OVERLAY=1, APPS=2, HOMESCREEN=3
772 if (layer >= 0 && layer < WINDOWMANAGER_LAYER_NUM) {
773 static const int layer_id_array[] = {
774 WINDOWMANAGER_LAYER_POPUP,
775 WINDOWMANAGER_LAYER_HOMESCREEN_OVERLAY,
776 WINDOWMANAGER_LAYER_APPLICATIONS,
777 WINDOWMANAGER_LAYER_HOMESCREEN,
780 m_showLayers[layer] = layer_id_array[layer];
782 t_ilm_layer renderOrder[WINDOWMANAGER_LAYER_NUM];
783 int num_layers = getLayerRenderOrder(renderOrder);
784 ilm_displaySetRenderOrder(m_screenId, renderOrder, num_layers);
790 void WindowManager::showAppLayer(int pid)
792 qDebug("-=[showAppLayer]=-");
793 qDebug("pid %d", pid);
796 /* nothing to show */
799 #ifdef HAVE_IVI_LAYERMANAGEMENT_API
800 /* clear pending flag */
801 m_pending_to_show = -1;
803 /* search layer id for application to show */
804 QMap<pid_t, t_ilm_layer>::const_iterator i = m_appLayers.find(pid);
805 QMap<pid_t, t_ilm_surface>::const_iterator j = m_appSurfaces.find(pid);
807 if (i != m_appLayers.end()) {
808 m_showLayers[2] = i.value();
809 qDebug("Found layer(%d) to show for app(pid=%d)", m_showLayers[2], pid);
811 /* check if this app is registered */
812 if (j == m_appSurfaces.end()) {
813 qDebug("New app %d", pid);
814 m_appSurfaces.insert(pid, 0); /* register pid only so far */
817 /* Probably app layer hasn't been made yet */
818 m_pending_to_show = pid;
819 /* hide current app once, back to default screen */
821 qDebug("No layer to show for app(pid=%d)", pid);
823 t_ilm_layer renderOrder[WINDOWMANAGER_LAYER_NUM];
825 int num_layers = getLayerRenderOrder(renderOrder);
826 ilm_displaySetRenderOrder(m_screenId, renderOrder, num_layers);