From bf0f33bec5ad705666dff6c821334524c1b81583 Mon Sep 17 00:00:00 2001 From: "Bocklage, Jens" Date: Fri, 4 Nov 2016 17:23:02 +0100 Subject: [PATCH] Fix for pid and surface handling. Signed-off-by: Bocklage, Jens --- HomeScreen/src/layouthandler.cpp | 88 ++++++++++++++++++++----------------- HomeScreen/src/layouthandler.h | 2 +- WindowManager/src/windowmanager.cpp | 18 ++++++++ WindowManager/src/windowmanager.hpp | 1 + interfaces/windowmanager.xml | 13 ++++++ 5 files changed, 80 insertions(+), 42 deletions(-) diff --git a/HomeScreen/src/layouthandler.cpp b/HomeScreen/src/layouthandler.cpp index 0dac24f..5f52cd5 100644 --- a/HomeScreen/src/layouthandler.cpp +++ b/HomeScreen/src/layouthandler.cpp @@ -112,60 +112,66 @@ void LayoutHandler::setUpLayouts() mp_dBusWindowManagerProxy->addLayout(3, "side by side", surfaceAreas); } -void LayoutHandler::makeMeVisible(int surfaceId) +void LayoutHandler::makeMeVisible(int pid) { - qDebug("makeMeVisible %d", surfaceId); - m_requestsToBeVisibleSurfaces.append(surfaceId); + qDebug("makeMeVisible %d", pid); - qDebug("m_visibleSurfaces %d", m_visibleSurfaces.size()); - qDebug("m_invisibleSurfaces %d", m_invisibleSurfaces.size()); - qDebug("m_requestsToBeVisibleSurfaces %d", m_requestsToBeVisibleSurfaces.size()); + QList allSurfaces = mp_dBusWindowManagerProxy->getAllSurfacesOfProcess(pid); + qSort(allSurfaces); - QList availableLayouts = mp_dBusWindowManagerProxy->getAvailableLayouts(m_visibleSurfaces.size() + m_requestsToBeVisibleSurfaces.size()); - if (0 == availableLayouts.size()) + if (0 != allSurfaces.size()) { - // no layout fits the need! - // replace the last app - qDebug("no layout fits the need!"); - qDebug("replace the last surface"); + m_requestsToBeVisibleSurfaces.append(allSurfaces.at(0)); - m_invisibleSurfaces.append(m_visibleSurfaces.last()); - m_visibleSurfaces.removeLast(); + qDebug("m_visibleSurfaces %d", m_visibleSurfaces.size()); + qDebug("m_invisibleSurfaces %d", m_invisibleSurfaces.size()); + qDebug("m_requestsToBeVisibleSurfaces %d", m_requestsToBeVisibleSurfaces.size()); - m_visibleSurfaces.append(m_requestsToBeVisibleSurfaces); - m_requestsToBeVisibleSurfaces.clear(); - - for (int i = 0; i < m_visibleSurfaces.size(); ++i) + QList availableLayouts = mp_dBusWindowManagerProxy->getAvailableLayouts(m_visibleSurfaces.size() + m_requestsToBeVisibleSurfaces.size()); + if (0 == availableLayouts.size()) { - 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)); - m_visibleSurfaces.append(m_requestsToBeVisibleSurfaces); - m_requestsToBeVisibleSurfaces.clear(); + // no layout fits the need! + // replace the last app + qDebug("no layout fits the need!"); + qDebug("replace the last surface"); - mp_dBusWindowManagerProxy->setLayoutById(availableLayouts.at(0)); - for (int i = 0; i < m_visibleSurfaces.size(); ++i) - { - mp_dBusWindowManagerProxy->setSurfaceToLayoutArea(m_visibleSurfaces.at(i), i); - } - } - if (1 < availableLayouts.size()) - { - // more than one layout possible! Ask user. - qDebug("more than one layout possible! Ask user."); + m_invisibleSurfaces.append(m_visibleSurfaces.last()); + m_visibleSurfaces.removeLast(); + + m_visibleSurfaces.append(m_requestsToBeVisibleSurfaces); + m_requestsToBeVisibleSurfaces.clear(); - QStringList choices; - for (int i = 0; i < availableLayouts.size(); ++i) + for (int i = 0; i < m_visibleSurfaces.size(); ++i) + { + mp_dBusWindowManagerProxy->setSurfaceToLayoutArea(m_visibleSurfaces.at(i), i); + } + } + if (1 == availableLayouts.size()) { - choices.append(mp_dBusWindowManagerProxy->getLayoutName(availableLayouts.at(i))); + // switch to new layout + qDebug("switch to new layout %d", availableLayouts.at(0)); + m_visibleSurfaces.append(m_requestsToBeVisibleSurfaces); + m_requestsToBeVisibleSurfaces.clear(); + + mp_dBusWindowManagerProxy->setLayoutById(availableLayouts.at(0)); + for (int i = 0; i < m_visibleSurfaces.size(); ++i) + { + mp_dBusWindowManagerProxy->setSurfaceToLayoutArea(m_visibleSurfaces.at(i), i); + } } + if (1 < availableLayouts.size()) + { + // more than one layout possible! Ask user. + qDebug("more than one layout possible! Ask user."); - mp_dBusPopupProxy->showPopupComboBox("Select Layout", choices); + QStringList choices; + for (int i = 0; i < availableLayouts.size(); ++i) + { + choices.append(mp_dBusWindowManagerProxy->getLayoutName(availableLayouts.at(i))); + } + mp_dBusPopupProxy->showPopupComboBox("Select Layout", choices); + } } } diff --git a/HomeScreen/src/layouthandler.h b/HomeScreen/src/layouthandler.h index ee400b7..cc4b7ab 100644 --- a/HomeScreen/src/layouthandler.h +++ b/HomeScreen/src/layouthandler.h @@ -17,7 +17,7 @@ public: signals: public slots: - void makeMeVisible(int surfaceId); + void makeMeVisible(int pid); void requestRenderSurfaceToArea(int surfaceId, const QRect &renderArea); void requestSurfaceIdToFullScreen(int surfaceId); diff --git a/WindowManager/src/windowmanager.cpp b/WindowManager/src/windowmanager.cpp index 765ae4f..ed38c49 100644 --- a/WindowManager/src/windowmanager.cpp +++ b/WindowManager/src/windowmanager.cpp @@ -420,6 +420,24 @@ QList WindowManager::getAllLayouts() return m_layouts; } +QList WindowManager::getAllSurfacesOfProcess(int pid) +{ + QList result; +#ifdef __arm__ + struct ilmSurfaceProperties surfaceProperties; + + for (int i = 0; i < m_surfaces.size(); ++i) + { + ilm_getPropertiesOfSurface(m_surfaces.at(i), &surfaceProperties); + if (pid == surfaceProperties.creatorPid) + { + result.append(m_surfaces.at(i)); + } + } +#endif + return result; +} + QList WindowManager::getAvailableLayouts(int numberOfAppSurfaces) { qDebug("-=[getAvailableLayouts]=-"); diff --git a/WindowManager/src/windowmanager.hpp b/WindowManager/src/windowmanager.hpp index fce5937..6c11760 100644 --- a/WindowManager/src/windowmanager.hpp +++ b/WindowManager/src/windowmanager.hpp @@ -93,6 +93,7 @@ public: // PROPERTIES public Q_SLOTS: // METHODS int addLayout(int layoutId, const QString &layoutName, const QList &surfaceAreas); QList getAllLayouts(); + QList getAllSurfacesOfProcess(int pid); QList getAvailableLayouts(int numberOfAppSurfaces); QList getAvailableSurfaces(); QString getLayoutName(int layoutId); diff --git a/interfaces/windowmanager.xml b/interfaces/windowmanager.xml index 80f2a19..c15ca2c 100644 --- a/interfaces/windowmanager.xml +++ b/interfaces/windowmanager.xml @@ -121,6 +121,19 @@ + + + + + + +