From dd8c90f87463d370c3076e13b7c6cc0e27c0d2f5 Mon Sep 17 00:00:00 2001 From: "Bocklage, Jens" Date: Tue, 8 Nov 2016 19:46:21 +0100 Subject: [PATCH] -Make the SampleNav app yellow. -Preparation for the new ApplicationFramework binding. The App Framework provides more information. --Adding afm D-Bus-interface introspection --Updating the AppInfo datatype to hold the new data: The application info consists of: string id; string version; int width; int height; string name; string description; string shortname; string author; string iconPath; -When pressing the AppLauncher Button or the Settings Button, the app layer is hidden. --Therefore, shideLayer and showLayer is introduced in the WindowManager API -If an application does not create its surface instantly, the HomeScreen retries to show the surface related to the pid. -New WindowManager function deleteLayoutById -Implement the complete HomeScreen API in the libhomescreen Signed-off-by: Bocklage, Jens --- HomeScreen/src/applauncherwidget.cpp | 34 +++--- HomeScreen/src/applauncherwidget.h | 3 +- HomeScreen/src/controlbarwidget.cpp | 2 + HomeScreen/src/controlbarwidget.h | 2 + HomeScreen/src/layouthandler.cpp | 143 ++++++++++++++++------- HomeScreen/src/layouthandler.h | 11 +- HomeScreen/src/main.cpp | 3 + HomeScreen/src/mainwindow.cpp | 2 + SampleHomeScreenInterfaceApp/src/sampleclass.cpp | 11 +- SampleHomeScreenInterfaceApp/src/sampleclass.hpp | 3 + WindowManager/src/windowmanager.cpp | 74 ++++++++++++ WindowManager/src/windowmanager.hpp | 3 + interfaces/appframework.xml | 49 ++++++-- interfaces/include/afm_user_daemon.hpp | 21 ++++ interfaces/include/appframework.hpp | 40 +++---- interfaces/include/windowmanager.hpp | 1 + interfaces/interfaces.pro | 1 + interfaces/src/appframework.cpp | 63 +++++----- interfaces/windowmanager.xml | 33 ++++++ libhomescreen/include/libhomescreen.hpp | 4 + libhomescreen/src/libhomescreen.cpp | 60 ++++++++++ 21 files changed, 431 insertions(+), 132 deletions(-) create mode 100644 interfaces/include/afm_user_daemon.hpp diff --git a/HomeScreen/src/applauncherwidget.cpp b/HomeScreen/src/applauncherwidget.cpp index 3d47d93..2cd5b17 100644 --- a/HomeScreen/src/applauncherwidget.cpp +++ b/HomeScreen/src/applauncherwidget.cpp @@ -27,18 +27,18 @@ AppLauncherWidget::AppLauncherWidget(QWidget *parent) : QWidget(parent), mp_ui(new Ui::AppLauncherWidget), - mp_appList(new QList()), + m_appList(), mp_appTable(0), mp_dBusAppFrameworkProxy() { mp_ui->setupUi(this); - AppInfo ai; + /*AppInfo ai; for (int i = 0; i < 100; ++i) { ai.setName("test" + QString::number(i)); mp_appList->append(ai); - } + }*/ qDebug("D-Bus: connect to org.agl.homescreenappframeworkbinder /AppFramework"); mp_dBusAppFrameworkProxy = new org::agl::appframework("org.agl.homescreenappframeworkbinder", @@ -54,7 +54,6 @@ AppLauncherWidget::~AppLauncherWidget() { delete mp_appTable; } - delete mp_appList; delete mp_ui; } @@ -101,12 +100,11 @@ void AppLauncherWidget::populateAppList() int i; - QStringList apps = mp_dBusAppFrameworkProxy->getAvailableAppNames(); - mp_appList->clear(); + m_appList = mp_dBusAppFrameworkProxy->getAvailableApps(); - mp_appTable->setRowCount((apps.size() + (APP_LIST_COLUMN_COUNT - 1)) / APP_LIST_COLUMN_COUNT); + mp_appTable->setRowCount((m_appList.size() + (APP_LIST_COLUMN_COUNT - 1)) / APP_LIST_COLUMN_COUNT); - if (apps.size() >= (9 * APP_LIST_COLUMN_COUNT)) + if (m_appList.size() >= (9 * APP_LIST_COLUMN_COUNT)) { mp_appTable->resize(1000, 1920 - 40 - 40 - 60 - 60); } @@ -122,19 +120,11 @@ void AppLauncherWidget::populateAppList() mp_appTable->horizontalHeader()->resizeSection(i, 190); } - AppInfo ai; - for (i = 0; i < apps.size(); ++i) - { - qDebug("new app: %s", apps.at(i).toStdString().c_str()); - ai.setName(apps.at(i)); - mp_appList->append(ai); - } - - for (i = 0; i < mp_appList->size(); i++) + for (i = 0; i < m_appList.size(); i++) { mp_appTable->setItem(i / APP_LIST_COLUMN_COUNT, i % APP_LIST_COLUMN_COUNT, - new QTableWidgetItem(mp_appList->at(i).getName())); + new QTableWidgetItem(m_appList.at(i).name)); mp_appTable->item(i / APP_LIST_COLUMN_COUNT, i % APP_LIST_COLUMN_COUNT)->setFlags(Qt::ItemIsEnabled); mp_appTable->item(i / APP_LIST_COLUMN_COUNT, @@ -144,13 +134,15 @@ void AppLauncherWidget::populateAppList() void AppLauncherWidget::on_tableView_clicked(int row, int col) { - if (mp_appList->size() > row * APP_LIST_COLUMN_COUNT + col) + if (m_appList.size() > row * APP_LIST_COLUMN_COUNT + col) { - int pid = mp_dBusAppFrameworkProxy->launchApp(mp_appList->at(row * APP_LIST_COLUMN_COUNT + col).getName()); - qDebug("%d, %d: start app %s", row, col, mp_appList->at(row * APP_LIST_COLUMN_COUNT + col).getName().toStdString().c_str()); + int pid = mp_dBusAppFrameworkProxy->launchApp(m_appList.at(row * APP_LIST_COLUMN_COUNT + col).id); + qDebug("%d, %d: start app %s", row, col, m_appList.at(row * APP_LIST_COLUMN_COUNT + col).id.toStdString().c_str()); qDebug("pid: %d", pid); // the new app wants to be visible by default newRequestsToBeVisibleApp(pid); + + showAppLayer(); } } diff --git a/HomeScreen/src/applauncherwidget.h b/HomeScreen/src/applauncherwidget.h index a58148e..d6bc615 100644 --- a/HomeScreen/src/applauncherwidget.h +++ b/HomeScreen/src/applauncherwidget.h @@ -45,10 +45,11 @@ private slots: signals: void newRequestsToBeVisibleApp(int pid); + void showAppLayer(); private: Ui::AppLauncherWidget *mp_ui; - QList *mp_appList; + QList m_appList; QTableWidget *mp_appTable; org::agl::appframework *mp_dBusAppFrameworkProxy; }; diff --git a/HomeScreen/src/controlbarwidget.cpp b/HomeScreen/src/controlbarwidget.cpp index c061a4c..486378b 100644 --- a/HomeScreen/src/controlbarwidget.cpp +++ b/HomeScreen/src/controlbarwidget.cpp @@ -69,11 +69,13 @@ void ControlBarWidget::updateColorScheme() void ControlBarWidget::on_pushButton_home_clicked() { + hideAppLayer(); homeButtonPressed(); } void ControlBarWidget::on_pushButton_settings_clicked() { + hideAppLayer(); settingsButtonPressed(); } diff --git a/HomeScreen/src/controlbarwidget.h b/HomeScreen/src/controlbarwidget.h index a8bd91c..e47d2ba 100644 --- a/HomeScreen/src/controlbarwidget.h +++ b/HomeScreen/src/controlbarwidget.h @@ -34,6 +34,8 @@ public: public slots: void updateColorScheme(); signals: + void hideAppLayer(); + void settingsButtonPressed(); void homeButtonPressed(); diff --git a/HomeScreen/src/layouthandler.cpp b/HomeScreen/src/layouthandler.cpp index 35304e6..11dd2cb 100644 --- a/HomeScreen/src/layouthandler.cpp +++ b/HomeScreen/src/layouthandler.cpp @@ -1,7 +1,9 @@ #include "layouthandler.h" +#include LayoutHandler::LayoutHandler(QObject *parent) : QObject(parent), + m_secondsTimerId(-1), mp_dBusWindowManagerProxy(0), mp_dBusPopupProxy(0), m_visibleSurfaces(), @@ -112,65 +114,109 @@ void LayoutHandler::setUpLayouts() mp_dBusWindowManagerProxy->addLayout(3, "side by side", surfaceAreas); } +void LayoutHandler::showAppLayer() +{ + mp_dBusWindowManagerProxy->showLayer(1); //1==app layer +} + +void LayoutHandler::hideAppLayer() +{ + mp_dBusWindowManagerProxy->hideLayer(1); //1==app layer +} + void LayoutHandler::makeMeVisible(int pid) { qDebug("makeMeVisible %d", pid); - QList allSurfaces = mp_dBusWindowManagerProxy->getAllSurfacesOfProcess(pid); - qSort(allSurfaces); + m_requestsToBeVisiblePids.append(pid); - if (0 != allSurfaces.size()) + // callback every second + if (-1 != m_secondsTimerId) { - m_requestsToBeVisibleSurfaces.append(allSurfaces.at(0)); - - qDebug("m_visibleSurfaces %d", m_visibleSurfaces.size()); - qDebug("m_invisibleSurfaces %d", m_invisibleSurfaces.size()); - qDebug("m_requestsToBeVisibleSurfaces %d", m_requestsToBeVisibleSurfaces.size()); - - QList availableLayouts = mp_dBusWindowManagerProxy->getAvailableLayouts(m_visibleSurfaces.size() + m_requestsToBeVisibleSurfaces.size()); - if (0 == availableLayouts.size()) - { - // no layout fits the need! - // replace the last app - qDebug("no layout fits the need!"); - qDebug("replace the last surface"); + killTimer(m_secondsTimerId); + m_secondsTimerId = -1; + } + m_secondsTimerId = startTimer(1000); +} - m_invisibleSurfaces.append(m_visibleSurfaces.last()); - m_visibleSurfaces.removeLast(); +void LayoutHandler::checkToDoQueue() +{ + if ((-1 != m_secondsTimerId) && (0 == m_requestsToBeVisiblePids.size())) + { + killTimer(m_secondsTimerId); + m_secondsTimerId = -1; + } - m_visibleSurfaces.append(m_requestsToBeVisibleSurfaces); - m_requestsToBeVisibleSurfaces.clear(); + if (0 != m_requestsToBeVisiblePids.size()) + { + int pid = m_requestsToBeVisiblePids.at(0); + qDebug("pid %d wants to be visible", pid); - for (int i = 0; i < m_visibleSurfaces.size(); ++i) - { - mp_dBusWindowManagerProxy->setSurfaceToLayoutArea(m_visibleSurfaces.at(i), i); - } - } - if (1 == availableLayouts.size()) + QList allSurfaces; + allSurfaces = mp_dBusWindowManagerProxy->getAllSurfacesOfProcess(pid); + if (0 == allSurfaces.size()) { - // 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); - } + qDebug("no surfaces for pid %d. retrying!", pid); } - if (1 < availableLayouts.size()) + else { - // more than one layout possible! Ask user. - qDebug("more than one layout possible! Ask user."); + m_requestsToBeVisiblePids.removeAt(0); + qSort(allSurfaces); - QStringList choices; - for (int i = 0; i < availableLayouts.size(); ++i) + if (0 != allSurfaces.size()) { - choices.append(mp_dBusWindowManagerProxy->getLayoutName(availableLayouts.at(i))); + m_requestsToBeVisibleSurfaces.append(allSurfaces.at(0)); + + qDebug("m_visibleSurfaces %d", m_visibleSurfaces.size()); + qDebug("m_invisibleSurfaces %d", m_invisibleSurfaces.size()); + qDebug("m_requestsToBeVisibleSurfaces %d", m_requestsToBeVisibleSurfaces.size()); + + QList availableLayouts = mp_dBusWindowManagerProxy->getAvailableLayouts(m_visibleSurfaces.size() + m_requestsToBeVisibleSurfaces.size()); + if (0 == availableLayouts.size()) + { + // no layout fits the need! + // replace the last app + qDebug("no layout fits the need!"); + qDebug("replace the last surface"); + + m_invisibleSurfaces.append(m_visibleSurfaces.last()); + m_visibleSurfaces.removeLast(); + + m_visibleSurfaces.append(m_requestsToBeVisibleSurfaces); + m_requestsToBeVisibleSurfaces.clear(); + + for (int i = 0; i < m_visibleSurfaces.size(); ++i) + { + 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(); + + 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."); + + QStringList choices; + for (int i = 0; i < availableLayouts.size(); ++i) + { + choices.append(mp_dBusWindowManagerProxy->getLayoutName(availableLayouts.at(i))); + } + + mp_dBusPopupProxy->showPopupComboBox("Select Layout", choices); + } } - - mp_dBusPopupProxy->showPopupComboBox("Select Layout", choices); } } } @@ -225,3 +271,12 @@ void LayoutHandler::setLayoutByName(QString layoutName) mp_dBusWindowManagerProxy->setSurfaceToLayoutArea(i, i); } } + +void LayoutHandler::timerEvent(QTimerEvent *e) +{ + if (e->timerId() == m_secondsTimerId) + { + checkToDoQueue(); + } +} + diff --git a/HomeScreen/src/layouthandler.h b/HomeScreen/src/layouthandler.h index 1ba270b..7487be5 100644 --- a/HomeScreen/src/layouthandler.h +++ b/HomeScreen/src/layouthandler.h @@ -17,22 +17,29 @@ public: signals: public slots: + void showAppLayer(); + void hideAppLayer(); void makeMeVisible(int pid); - +private: + void checkToDoQueue(); +public slots: QList requestGetAllSurfacesOfProcess(int pid); int requestGetSurfaceStatus(int surfaceId); void requestRenderSurfaceToArea(int surfaceId, const QRect &renderArea); void requestSurfaceIdToFullScreen(int surfaceId); void setLayoutByName(QString layoutName); +protected: + void timerEvent(QTimerEvent *e); private: + int m_secondsTimerId; org::agl::windowmanager *mp_dBusWindowManagerProxy; org::agl::popup *mp_dBusPopupProxy; + QList m_requestsToBeVisiblePids; QList m_visibleSurfaces; QList m_invisibleSurfaces; QList m_requestsToBeVisibleSurfaces; - }; #endif // LAYOUTHANDLER_H diff --git a/HomeScreen/src/main.cpp b/HomeScreen/src/main.cpp index f1f5a22..4d626d9 100644 --- a/HomeScreen/src/main.cpp +++ b/HomeScreen/src/main.cpp @@ -40,6 +40,9 @@ int main(int argc, char *argv[]) qDebug("%s, v%s", QCoreApplication::applicationName().toStdString().c_str(), QCoreApplication::applicationVersion().toStdString().c_str()); + qDBusRegisterMetaType(); + qDBusRegisterMetaType >(); + MainWindow w; w.show(); #ifdef __arm__ diff --git a/HomeScreen/src/mainwindow.cpp b/HomeScreen/src/mainwindow.cpp index f4891b3..e1a8371 100644 --- a/HomeScreen/src/mainwindow.cpp +++ b/HomeScreen/src/mainwindow.cpp @@ -86,8 +86,10 @@ MainWindow::MainWindow(QWidget *parent) : QObject::connect(mp_controlBarWidget, SIGNAL(settingsButtonPressed()), mp_settingsWidget, SLOT(raise())); QObject::connect(mp_controlBarWidget, SIGNAL(homeButtonPressed()), mp_applauncherwidget, SLOT(raise())); + QObject::connect(mp_controlBarWidget, SIGNAL(hideAppLayer()), mp_layoutHandler, SLOT(hideAppLayer())); QObject::connect(mp_applauncherwidget, SIGNAL(newRequestsToBeVisibleApp(int)), mp_layoutHandler, SLOT(makeMeVisible(int))); + QObject::connect(mp_applauncherwidget, SIGNAL(showAppLayer()), mp_layoutHandler, SLOT(showAppLayer())); // apply color scheme diff --git a/SampleHomeScreenInterfaceApp/src/sampleclass.cpp b/SampleHomeScreenInterfaceApp/src/sampleclass.cpp index 6a46f2b..f4c1c83 100644 --- a/SampleHomeScreenInterfaceApp/src/sampleclass.cpp +++ b/SampleHomeScreenInterfaceApp/src/sampleclass.cpp @@ -11,10 +11,14 @@ SampleClass::~SampleClass() delete mp_libHomeScreen; } +std::list SampleClass::getAllSurfacesOfProcess(int pid) +{ + return mp_libHomeScreen->getAllSurfacesOfProcess(pid); +} sRectangle SampleClass::getLayoutRenderAreaForSurfaceId(int surfaceId) { - mp_libHomeScreen->getLayoutRenderAreaForSurfaceId(surfaceId); + return mp_libHomeScreen->getLayoutRenderAreaForSurfaceId(surfaceId); } void SampleClass::hardKeyPressed(int key) @@ -22,6 +26,11 @@ void SampleClass::hardKeyPressed(int key) mp_libHomeScreen->hardKeyPressed(key); } +int SampleClass::getSurfaceStatus(int surfaceId) +{ + return mp_libHomeScreen->getSurfaceStatus(surfaceId); +} + void SampleClass::renderSurfaceToArea(int surfaceId, const sRectangle &renderArea) { mp_libHomeScreen->renderSurfaceToArea(surfaceId, renderArea); diff --git a/SampleHomeScreenInterfaceApp/src/sampleclass.hpp b/SampleHomeScreenInterfaceApp/src/sampleclass.hpp index acffcf6..f5a5d13 100644 --- a/SampleHomeScreenInterfaceApp/src/sampleclass.hpp +++ b/SampleHomeScreenInterfaceApp/src/sampleclass.hpp @@ -2,6 +2,7 @@ #define SAMPLECLASS_HPP #include "libhomescreen.hpp" +#include class SampleClass { @@ -9,7 +10,9 @@ public: SampleClass(); ~SampleClass(); + std::list getAllSurfacesOfProcess(int pid); sRectangle getLayoutRenderAreaForSurfaceId(int surfaceId); + int getSurfaceStatus(int surfaceId); void hardKeyPressed(int key); void renderSurfaceToArea(int surfaceId, const sRectangle &renderArea); void requestSurfaceIdToFullScreen(int surfaceId); diff --git a/WindowManager/src/windowmanager.cpp b/WindowManager/src/windowmanager.cpp index ed38c49..48f8d38 100644 --- a/WindowManager/src/windowmanager.cpp +++ b/WindowManager/src/windowmanager.cpp @@ -413,6 +413,37 @@ int WindowManager::addLayout(int layoutId, const QString &layoutName, const QLis 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::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 WindowManager::getAllLayouts() { qDebug("-=[getAllLayouts]=-"); @@ -483,6 +514,27 @@ QString WindowManager::getLayoutName(int layoutId) return result; } +void WindowManager::hideLayer(int layer) +{ + qDebug("-=[hideLayer]=-"); + qDebug("layer %d", layer); + +#ifdef __arm__ + if (0 == layer) + { + ilm_layerSetVisibility(WINDOWMANAGER_LAYER_POPUP, ILM_FALSE); + } + if (1 == layer) + { + ilm_layerSetVisibility(WINDOWMANAGER_LAYER_APPLICATIONS, ILM_FALSE); + } + if (2 == layer) + { + ilm_layerSetVisibility(WINDOWMANAGER_LAYER_HOMESCREEN, ILM_FALSE); + } + ilm_commitChanges(); +#endif +} int WindowManager::setLayoutById(int layoutId) { @@ -536,3 +588,25 @@ int WindowManager::setSurfaceToLayoutArea(int surfaceId, int layoutAreaId) return result; } + +void WindowManager::showLayer(int layer) +{ + qDebug("-=[showLayer]=-"); + qDebug("layer %d", layer); + +#ifdef __arm__ + if (0 == layer) + { + ilm_layerSetVisibility(WINDOWMANAGER_LAYER_POPUP, ILM_TRUE); + } + if (1 == layer) + { + ilm_layerSetVisibility(WINDOWMANAGER_LAYER_APPLICATIONS, ILM_TRUE); + } + if (2 == layer) + { + ilm_layerSetVisibility(WINDOWMANAGER_LAYER_HOMESCREEN, ILM_TRUE); + } + ilm_commitChanges(); +#endif +} diff --git a/WindowManager/src/windowmanager.hpp b/WindowManager/src/windowmanager.hpp index 6c11760..5b0a552 100644 --- a/WindowManager/src/windowmanager.hpp +++ b/WindowManager/src/windowmanager.hpp @@ -92,14 +92,17 @@ public: // PROPERTIES public Q_SLOTS: // METHODS int addLayout(int layoutId, const QString &layoutName, const QList &surfaceAreas); + int deleteLayoutById(int layoutId); QList getAllLayouts(); QList getAllSurfacesOfProcess(int pid); QList getAvailableLayouts(int numberOfAppSurfaces); QList getAvailableSurfaces(); QString getLayoutName(int layoutId); + void hideLayer(int layer); int setLayoutById(int layoutId); int setLayoutByName(const QString &layoutName); int setSurfaceToLayoutArea(int surfaceId, int layoutAreaId); + void showLayer(int layer); }; diff --git a/interfaces/appframework.xml b/interfaces/appframework.xml index 1324386..e2c088e 100644 --- a/interfaces/appframework.xml +++ b/interfaces/appframework.xml @@ -13,14 +13,45 @@ See the License for the specific language governing permissions and limitations under the License. --> - - - - - - - - - + + + + + + + + + + + + + diff --git a/interfaces/include/afm_user_daemon.hpp b/interfaces/include/afm_user_daemon.hpp new file mode 100644 index 0000000..256292b --- /dev/null +++ b/interfaces/include/afm_user_daemon.hpp @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2016 Mentor Graphics Development (Deutschland) GmbH + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AFM_USER_DAEMON_HPP +#define AFM_USER_DAEMON_HPP + + +#endif // AFM_USER_DAEMON_HPP diff --git a/interfaces/include/appframework.hpp b/interfaces/include/appframework.hpp index d95cd9d..d4abefb 100644 --- a/interfaces/include/appframework.hpp +++ b/interfaces/include/appframework.hpp @@ -17,38 +17,32 @@ #ifndef APPFRAMEWORK_HPP #define APPFRAMEWORK_HPP -#include #include -#include -class AppInfo : public QObject +class AppInfo { - Q_OBJECT public: - explicit AppInfo(QObject *parent = 0); - AppInfo(const AppInfo &other); - AppInfo& operator=(const AppInfo &other); - ~AppInfo(); + AppInfo(); + virtual ~AppInfo(); - //register Message with the Qt type system - static void registerMetaType(); - - friend QDBusArgument &operator<<(QDBusArgument &argument, const AppInfo &appInfo); - friend const QDBusArgument &operator>>(const QDBusArgument &argument, AppInfo &appInfo); - - void setName(const QString name) {this->name = name;} - QString getName() const {return name;} - void setIconPath(const QString iconPath) {this->iconPath = iconPath;} - QString getIconPath() const {return iconPath;} - void setDescription(const QString description) {this->description = description;} - QString getDescription() const {return description;} - -private: + QString id; + QString version; + int width; + int height; QString name; - QString iconPath; QString description; + QString shortname; + QString author; + QString iconPath; + + void read(const QJsonObject &json); + + friend QDBusArgument &operator <<(QDBusArgument &argument, const AppInfo &mAppInfo); + friend const QDBusArgument &operator >>(const QDBusArgument &argument, AppInfo &mAppInfo); }; + Q_DECLARE_METATYPE(AppInfo) +Q_DECLARE_METATYPE(QList) #endif // APPFRAMEWORK_HPP diff --git a/interfaces/include/windowmanager.hpp b/interfaces/include/windowmanager.hpp index 45c7c6e..ebab2d7 100644 --- a/interfaces/include/windowmanager.hpp +++ b/interfaces/include/windowmanager.hpp @@ -24,6 +24,7 @@ #define WINDOWMANAGER_ERROR_NAME_ALREADY_DEFINED 2 #define WINDOWMANAGER_ERROR_ID_NOT_FOUND 3 #define WINDOWMANAGER_ERROR_NAME_NOT_FOUND 4 +#define WINDOWMANAGER_ERROR_ID_IN_USE 5 class SimplePoint { diff --git a/interfaces/interfaces.pro b/interfaces/interfaces.pro index bd3fa39..1dad460 100644 --- a/interfaces/interfaces.pro +++ b/interfaces/interfaces.pro @@ -28,6 +28,7 @@ SOURCES += src/appframework.cpp \ XMLSOURCES = \ appframework.xml \ + afm_user_daemon.xml \ daynightmode.xml \ homescreen.xml \ inputevent.xml \ diff --git a/interfaces/src/appframework.cpp b/interfaces/src/appframework.cpp index afd6114..40515d5 100644 --- a/interfaces/src/appframework.cpp +++ b/interfaces/src/appframework.cpp @@ -16,56 +16,57 @@ #include "include/appframework.hpp" -AppInfo::AppInfo(QObject *parent) : - QObject(parent) -{ -} - -AppInfo::AppInfo(const AppInfo &other) : - QObject(other.parent()), - name(other.getName()), - iconPath(other.getIconPath()), - description(other.getDescription()) -{ -} -AppInfo& AppInfo::operator=(const AppInfo &other) +AppInfo::AppInfo() { - setParent(other.parent()); - name = other.getName(); - iconPath = other.getIconPath(); - description = other.getDescription(); - - return *this; } AppInfo::~AppInfo() { } -void AppInfo::registerMetaType() +void AppInfo::read(const QJsonObject &json) { - qRegisterMetaType("AppInfo"); - qDBusRegisterMetaType(); + id = json["id"].toString(); + version = json["id"].toString(); + width = json["id"].toInt(); + height = json["id"].toInt(); + name = json["id"].toString(); + description = json["id"].toString(); + shortname = json["id"].toString(); + author = json["id"].toString(); + iconPath = json["id"].toString(); } - -// Marshall the MyStructure data into a D-Bus argument -QDBusArgument &operator<<(QDBusArgument &argument, const AppInfo &appInfo) +QDBusArgument &operator <<(QDBusArgument &argument, const AppInfo &mAppInfo) { argument.beginStructure(); - argument << appInfo.name << appInfo.iconPath << appInfo.description; + argument << mAppInfo.id; + argument << mAppInfo.version; + argument << mAppInfo.width; + argument << mAppInfo.height; + argument << mAppInfo.name; + argument << mAppInfo.description; + argument << mAppInfo.shortname; + argument << mAppInfo.author; + argument << mAppInfo.iconPath; argument.endStructure(); - qDebug("appInfo.name:<< %s", appInfo.name.toStdString().c_str()); + return argument; } -// Retrieve the MyStructure data from the D-Bus argument -const QDBusArgument &operator>>(const QDBusArgument &argument, AppInfo &appInfo) +const QDBusArgument &operator >>(const QDBusArgument &argument, AppInfo &mAppInfo) { argument.beginStructure(); - argument >> appInfo.name >> appInfo.iconPath >> appInfo.description; + argument >> mAppInfo.id; + argument >> mAppInfo.version; + argument >> mAppInfo.width; + argument >> mAppInfo.height; + argument >> mAppInfo.name; + argument >> mAppInfo.description; + argument >> mAppInfo.shortname; + argument >> mAppInfo.author; + argument >> mAppInfo.iconPath; argument.endStructure(); - qDebug("appInfo.name:>> %s", appInfo.name.toStdString().c_str()); return argument; } diff --git a/interfaces/windowmanager.xml b/interfaces/windowmanager.xml index c15ca2c..a4be58f 100644 --- a/interfaces/windowmanager.xml +++ b/interfaces/windowmanager.xml @@ -39,6 +39,18 @@ + + + + + + + + + + + + + diff --git a/libhomescreen/include/libhomescreen.hpp b/libhomescreen/include/libhomescreen.hpp index db6ca2d..c028617 100644 --- a/libhomescreen/include/libhomescreen.hpp +++ b/libhomescreen/include/libhomescreen.hpp @@ -1,6 +1,8 @@ #ifndef LIBHOMESCREEN_HPP #define LIBHOMESCREEN_HPP +#include + // forward declarations struct _LibHomeScreenHomescreen; typedef struct _LibHomeScreenHomescreen LibHomeScreenHomescreen; @@ -20,7 +22,9 @@ public: ~LibHomeScreen(); // these are representing the D-Bus methods: + std::list getAllSurfacesOfProcess(int pid); sRectangle getLayoutRenderAreaForSurfaceId(int surfaceId); + int getSurfaceStatus(int surfaceId); void hardKeyPressed(int key); void renderSurfaceToArea(int surfaceId, const sRectangle &renderArea); void requestSurfaceIdToFullScreen(int surfaceId); diff --git a/libhomescreen/src/libhomescreen.cpp b/libhomescreen/src/libhomescreen.cpp index 39af1c3..03e95d6 100644 --- a/libhomescreen/src/libhomescreen.cpp +++ b/libhomescreen/src/libhomescreen.cpp @@ -29,6 +29,44 @@ LibHomeScreen::~LibHomeScreen() g_object_unref(mp_libHomeScreenHomescreen_Proxy); } +std::list LibHomeScreen::getAllSurfacesOfProcess(int pid) +{ + std::list result; + + GError *err = NULL; + + GVariant *out_surfaceIds; + + lib_home_screen_homescreen_call_get_all_surfaces_of_process_sync( + mp_libHomeScreenHomescreen_Proxy, + pid, + &out_surfaceIds, + NULL, + &err); + + if (NULL != err) + { + fprintf(stderr, "Unable to call getAllSurfacesOfProcess: %s\n", err->message); + } + + + GVariant *element; + GVariantIter iter; + int i; + + if (g_variant_iter_init(&iter, out_surfaceIds)) + { + while ((element = g_variant_iter_next_value(&iter)) != NULL) + { + g_variant_get(element, "i", &i); + result.push_back(i); + g_variant_unref(element); + } + } + + return result; +} + sRectangle LibHomeScreen::getLayoutRenderAreaForSurfaceId(int surfaceId) { sRectangle result; @@ -53,6 +91,28 @@ sRectangle LibHomeScreen::getLayoutRenderAreaForSurfaceId(int surfaceId) return result; } +int LibHomeScreen::getSurfaceStatus(int surfaceId) +{ + int result; + GError *err = NULL; + + GVariant *out_renderArea; + + lib_home_screen_homescreen_call_get_surface_status_sync( + mp_libHomeScreenHomescreen_Proxy, + surfaceId, + &result, + NULL, + &err); + + if (NULL != err) + { + fprintf(stderr, "Unable to call getSurfaceStatus: %s\n", err->message); + } + + return result; +} + void LibHomeScreen::hardKeyPressed(int key) { GError *err = NULL; -- 2.16.6