From cf8cd699e91df40c3f9070019f7c561432b4b4dd Mon Sep 17 00:00:00 2001 From: "Bocklage, Jens" Date: Fri, 30 Sep 2016 14:31:09 +0200 Subject: [PATCH] Implementing app launch and app surface control workflow. Using WindowManager to control layer and surfaces (ongoing). Defining three layouts. Adding combobox selection feature to popup widget. Known issue: IVI-shell is currently disabled in AGL due to issues (porting to Yocto 2.1.1). Signed-off-by: Bocklage, Jens --- HomeScreen/HomeScreen.pro | 6 +- HomeScreen/README.md | 18 +- HomeScreen/resources/popupwidget.ui | 10 + HomeScreen/src/applauncherwidget.cpp | 23 +- HomeScreen/src/applauncherwidget.h | 7 +- HomeScreen/src/controlbarwidget.cpp | 4 +- HomeScreen/src/homescreencontrolinterface.cpp | 6 + HomeScreen/src/homescreencontrolinterface.h | 4 +- HomeScreen/src/layouthandler.cpp | 180 +++++++++++ HomeScreen/src/layouthandler.h | 33 ++ HomeScreen/src/main.cpp | 9 +- HomeScreen/src/mainwindow.cpp | 21 +- HomeScreen/src/mainwindow.h | 6 +- HomeScreen/src/popupwidget.cpp | 20 +- HomeScreen/src/popupwidget.h | 5 + HomeScreenAppFrameworkBinderTizen/README.md | 6 + HomeScreenAppFrameworkBinderTizen/src/main.cpp | 2 +- HomeScreenSimulator/README.md | 6 + HomeScreenSimulator/resources/mainwindow.ui | 13 + HomeScreenSimulator/src/main.cpp | 3 +- HomeScreenSimulator/src/mainwindow.cpp | 10 + HomeScreenSimulator/src/mainwindow.h | 2 + InputEventManager/README.md | 6 + InputEventManager/src/main.cpp | 2 +- README.md | 96 +++++- SampleAppTimeDate/README.md | 6 + SampleAppTimeDate/src/main.cpp | 2 +- WindowManager/README.md | 6 + WindowManager/WindowManager.pro | 10 +- WindowManager/src/main.cpp | 14 +- WindowManager/src/windowmanager.cpp | 413 ++++++++++++++++--------- WindowManager/src/windowmanager.hpp | 53 +++- interfaces/README.md | 6 + interfaces/homescreen.xml | 3 + interfaces/include/windowmanager.hpp | 59 ++++ interfaces/interfaces.pro | 11 +- interfaces/popup.xml | 4 + interfaces/src/appframework.cpp | 16 + interfaces/src/windowmanager.cpp | 77 +++++ interfaces/windowmanager.xml | 52 ++++ 40 files changed, 1039 insertions(+), 191 deletions(-) create mode 100644 HomeScreen/src/layouthandler.cpp create mode 100644 HomeScreen/src/layouthandler.h create mode 100644 interfaces/include/windowmanager.hpp create mode 100644 interfaces/src/windowmanager.cpp create mode 100644 interfaces/windowmanager.xml diff --git a/HomeScreen/HomeScreen.pro b/HomeScreen/HomeScreen.pro index 458db51..e73539e 100644 --- a/HomeScreen/HomeScreen.pro +++ b/HomeScreen/HomeScreen.pro @@ -27,7 +27,8 @@ SOURCES += \ src/controlbarwidget.cpp \ src/statusbarwidget.cpp \ src/applauncherwidget.cpp \ - src/homescreencontrolinterface.cpp + src/homescreencontrolinterface.cpp \ + src/layouthandler.cpp HEADERS += \ ../interfaces/appframework.h \ @@ -40,7 +41,8 @@ HEADERS += \ src/controlbarwidget.h \ src/statusbarwidget.h \ src/applauncherwidget.h \ - src/homescreencontrolinterface.h + src/homescreencontrolinterface.h \ + src/layouthandler.h INCLUDEPATH += $$OUT_PWD/../interfaces INCLUDEPATH += ../interfaces/ diff --git a/HomeScreen/README.md b/HomeScreen/README.md index 7ebc287..01deabb 100644 --- a/HomeScreen/README.md +++ b/HomeScreen/README.md @@ -9,6 +9,19 @@ https://gerrit.automotivelinux.org/gerrit/#/admin/projects/staging/HomeScreen AGL repo for bitbake recipe: https://gerrit.automotivelinux.org/gerrit/#/admin/projects/AGL/meta-agl-demo/recipes-demo-hmi/HomeScreen/HomeScreen_?.bb +v0.3.0 +09/30/2016 + +#new features +- app launcher improved +- added first popup combobox selection feature +-- used for selecting layouts +- implemented 3 layouts +-- one app +-- top on bottom +-- side by side +- first interaction with WindowManager + v0.2.0 08/05/2016 @@ -67,13 +80,16 @@ v0.0.1 - define and implement control bar D-Bus-interface - many settings have to be read from the system somewhere during app startup. This is not available right now - interaction with application manager +-- done for TIZEN - interaction with wayland compositor +-- first version of WindowManager implemented - define and implement input device event handler - replace my HMI design with the official AGL design (graphics/icons...) - implement example HMI layouts +-- three layouts implemented - fix font issues on target - more documentation ;) -- add animations +- add animations (?) - much more... Thanks to Umar Irshad for his free iconset available here: diff --git a/HomeScreen/resources/popupwidget.ui b/HomeScreen/resources/popupwidget.ui index a982adf..4eb8a8b 100644 --- a/HomeScreen/resources/popupwidget.ui +++ b/HomeScreen/resources/popupwidget.ui @@ -84,6 +84,16 @@ border-image: url(:/images/transparency.png); true + + + + 90 + 90 + 211 + 27 + + + diff --git a/HomeScreen/src/applauncherwidget.cpp b/HomeScreen/src/applauncherwidget.cpp index 94dd357..18c373b 100644 --- a/HomeScreen/src/applauncherwidget.cpp +++ b/HomeScreen/src/applauncherwidget.cpp @@ -18,6 +18,9 @@ #include "ui_applauncherwidget.h" #include #include +#ifdef __i386__ + #include +#endif #define APP_LIST_COLUMN_COUNT 5 @@ -42,8 +45,6 @@ AppLauncherWidget::AppLauncherWidget(QWidget *parent) : "/AppFramework", QDBusConnection::sessionBus(), 0); - - populateAppList(); } AppLauncherWidget::~AppLauncherWidget() @@ -99,7 +100,13 @@ void AppLauncherWidget::populateAppList() int i; +#ifdef __arm__ QStringList apps = mp_dBusAppFrameworkProxy->getAvailableAppNames(); +#endif +#ifdef __i386__ + QStringList apps; + apps.append(QString("/usr/bin/gnome-terminal")); +#endif mp_appList->clear(); mp_appTable->setRowCount((apps.size() + (APP_LIST_COLUMN_COUNT - 1)) / APP_LIST_COLUMN_COUNT); @@ -138,16 +145,24 @@ void AppLauncherWidget::populateAppList() mp_appTable->item(i / APP_LIST_COLUMN_COUNT, i % APP_LIST_COLUMN_COUNT)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter); } - - } void AppLauncherWidget::on_tableView_clicked(int row, int col) { if (mp_appList->size() > row * APP_LIST_COLUMN_COUNT + col) { +#ifdef __arm__ int pid = mp_dBusAppFrameworkProxy->launchApp(mp_appList->at(row * APP_LIST_COLUMN_COUNT + col).getName()); +#endif +#ifdef __i386__ + QProcess *myProcess = new QProcess(); + myProcess->start(mp_appList->at(row * APP_LIST_COLUMN_COUNT + col).getName(), NULL); + int pid = myProcess->pid(); +#endif qDebug("%d, %d: start app %s", row, col, mp_appList->at(row * APP_LIST_COLUMN_COUNT + col).getName().toStdString().c_str()); qDebug("pid: %d", pid); + + // the new app wants to be visible by default + newRequestsToBeVisibleApp(pid); } } diff --git a/HomeScreen/src/applauncherwidget.h b/HomeScreen/src/applauncherwidget.h index 943f6d5..a58148e 100644 --- a/HomeScreen/src/applauncherwidget.h +++ b/HomeScreen/src/applauncherwidget.h @@ -34,18 +34,23 @@ class AppLauncherWidget : public QWidget public: explicit AppLauncherWidget(QWidget *parent = 0); ~AppLauncherWidget(); + + void populateAppList(); + public slots: void updateColorScheme(); private slots: void on_tableView_clicked(int row, int col); +signals: + void newRequestsToBeVisibleApp(int pid); + private: Ui::AppLauncherWidget *mp_ui; QList *mp_appList; QTableWidget *mp_appTable; org::agl::appframework *mp_dBusAppFrameworkProxy; - void populateAppList(); }; #endif // APPLAUNCHERWIDGET_H diff --git a/HomeScreen/src/controlbarwidget.cpp b/HomeScreen/src/controlbarwidget.cpp index 2cce30b..cafbb7b 100644 --- a/HomeScreen/src/controlbarwidget.cpp +++ b/HomeScreen/src/controlbarwidget.cpp @@ -64,12 +64,12 @@ void ControlBarWidget::updateColorScheme() void ControlBarWidget::on_pushButton_Settings_clicked() { - emit settingsButtonPressed(); + settingsButtonPressed(); } void ControlBarWidget::on_pushButton_Home_clicked() { - emit homeButtonPressed(); + homeButtonPressed(); } void ControlBarWidget::on_pushButton_Nav_clicked() diff --git a/HomeScreen/src/homescreencontrolinterface.cpp b/HomeScreen/src/homescreencontrolinterface.cpp index defc202..45c3cbd 100644 --- a/HomeScreen/src/homescreencontrolinterface.cpp +++ b/HomeScreen/src/homescreencontrolinterface.cpp @@ -34,9 +34,15 @@ void HomeScreenControlInterface::hardKeyPressed(int key) qDebug("hardKeyPressed NAV key pressed!"); pid = mp_dBusAppFrameworkProxy->launchApp("demoapp"); qDebug("pid: %d", pid); + newRequestsToBeVisibleApp(pid); break; default: qDebug("hardKeyPressed %d", key); break; } } + +void HomeScreenControlInterface::setToFullscreen(int pid) +{ + qDebug("setToFullscreen %d", pid); +} diff --git a/HomeScreen/src/homescreencontrolinterface.h b/HomeScreen/src/homescreencontrolinterface.h index 3480d30..e406686 100644 --- a/HomeScreen/src/homescreencontrolinterface.h +++ b/HomeScreen/src/homescreencontrolinterface.h @@ -16,11 +16,13 @@ public: signals: -public slots: +signals: + void newRequestsToBeVisibleApp(int pid); //from homescreen_adapter.h public Q_SLOTS: // METHODS void hardKeyPressed(int key); + void setToFullscreen(int pid); private: HomescreenAdaptor *mp_homeScreenAdaptor; diff --git a/HomeScreen/src/layouthandler.cpp b/HomeScreen/src/layouthandler.cpp new file mode 100644 index 0000000..a4d0f91 --- /dev/null +++ b/HomeScreen/src/layouthandler.cpp @@ -0,0 +1,180 @@ +#include "layouthandler.h" + +LayoutHandler::LayoutHandler(QObject *parent) : + QObject(parent), + mp_dBusWindowManagerProxy(0), + mp_dBusPopupProxy(0), + m_visibleApps(), + m_invisibleApps(), + m_requestsToBeVisibleApps() +{ + qDBusRegisterMetaType(); + qDBusRegisterMetaType >(); + qDBusRegisterMetaType(); + qDBusRegisterMetaType >(); + + qDebug("D-Bus: connect to org.agl.windowmanager /windowmanager"); + mp_dBusWindowManagerProxy = new org::agl::windowmanager("org.agl.windowmanager", + "/windowmanager", + QDBusConnection::sessionBus(), + 0); + qDebug("D-Bus: connect to org.agl.homescreen /Popup"); + mp_dBusPopupProxy = new org::agl::popup("org.agl.homescreen", + "/Popup", + QDBusConnection::sessionBus(), + 0); +} + +LayoutHandler::~LayoutHandler() +{ + delete mp_dBusPopupProxy; + delete mp_dBusWindowManagerProxy; +} + +void LayoutHandler::setUpLayers() +{ + qDebug("setUpLayers"); + QList surfaceAreas; + SimpleRect surfaceArea; + + const int SCREEN_WIDTH = 1080; + const int SCREEN_HEIGHT = 1080; + + const int STATUSBAR_HEIGHT = 60; + const int STATUSBAR_WIDTH = SCREEN_WIDTH; + const int STATUSBAR_X = 0; + const int STATUSBAR_Y = 0; + const int CONTROLBAR_HEIGHT = 60; + const int CONTROLBAR_WIDTH = SCREEN_WIDTH; + const int CONTROLBAR_X = 0; + const int CONTROLBAR_Y = SCREEN_HEIGHT - CONTROLBAR_HEIGHT; + + + // layout 1: + // one app surface, statusbar, control bar + surfaceArea.x = 0; + surfaceArea.y = STATUSBAR_HEIGHT; + surfaceArea.width = SCREEN_WIDTH; + surfaceArea.height = SCREEN_HEIGHT - STATUSBAR_HEIGHT - CONTROLBAR_HEIGHT; + + surfaceAreas.append(surfaceArea); + + mp_dBusWindowManagerProxy->addLayout(1, "one app", surfaceAreas); + + + surfaceAreas.clear(); + + // layout 2: + // two app surfaces (one on top of the other), statusbar, control bar + + // top surface + surfaceArea.x = 0; + surfaceArea.y = STATUSBAR_HEIGHT; + surfaceArea.width = SCREEN_WIDTH; + surfaceArea.height = (SCREEN_HEIGHT - STATUSBAR_HEIGHT - CONTROLBAR_HEIGHT) / 2; + + surfaceAreas.append(surfaceArea); + + // bottom surface + surfaceArea.x = 0; + surfaceArea.y = STATUSBAR_HEIGHT / 2; + surfaceArea.width = SCREEN_WIDTH; + surfaceArea.height = (SCREEN_HEIGHT - STATUSBAR_HEIGHT - CONTROLBAR_HEIGHT) / 2; + + surfaceAreas.append(surfaceArea); + + mp_dBusWindowManagerProxy->addLayout(2, "top on bottom", surfaceAreas); + + + surfaceAreas.clear(); + + // layout 3: + // two app surfaces (one besides the other), statusbar, control bar + + // left surface + surfaceArea.x = 0; + surfaceArea.y = STATUSBAR_HEIGHT; + surfaceArea.width = SCREEN_WIDTH / 2; + surfaceArea.height = SCREEN_HEIGHT - STATUSBAR_HEIGHT - CONTROLBAR_HEIGHT; + + surfaceAreas.append(surfaceArea); + + // right surface + surfaceArea.x = SCREEN_WIDTH / 2; + surfaceArea.y = STATUSBAR_HEIGHT; + surfaceArea.width = SCREEN_WIDTH / 2; + surfaceArea.height = SCREEN_HEIGHT - STATUSBAR_HEIGHT - CONTROLBAR_HEIGHT; + + surfaceAreas.append(surfaceArea); + + mp_dBusWindowManagerProxy->addLayout(3, "side by side", surfaceAreas); + +} + +void LayoutHandler::makeMeVisible(int pid) +{ + qDebug("makeMeVisible %d", pid); + m_requestsToBeVisibleApps.append(pid); + + qDebug("m_visibleApps %d", m_visibleApps.size()); + qDebug("m_invisibleApps %d", m_invisibleApps.size()); + qDebug("m_requestsToBeVisibleApps %d", m_requestsToBeVisibleApps.size()); + + QList availableLayouts = mp_dBusWindowManagerProxy->getAvailableLayouts(m_visibleApps.size() + m_requestsToBeVisibleApps.size()); + if (0 == availableLayouts.size()) + { + // no layout fits the need! + // replace the last app + qDebug("no layout fits the need!"); + qDebug("replace the last app"); + + m_invisibleApps.append(m_visibleApps.last()); + m_visibleApps.removeLast(); + + for (int i = 0; i < m_visibleApps.size(); ++i) + { + mp_dBusWindowManagerProxy->setSurfaceToLayoutArea(i, i); + } + } + if (1 == availableLayouts.size()) + { + // switch to new layout + qDebug("switch to new layout %d", availableLayouts.at(0)); + m_visibleApps.append(m_requestsToBeVisibleApps); + m_requestsToBeVisibleApps.clear(); + + mp_dBusWindowManagerProxy->setLayoutById(availableLayouts.at(0)); + for (int i = 0; i < m_visibleApps.size(); ++i) + { + mp_dBusWindowManagerProxy->setSurfaceToLayoutArea(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); + + } +} + +void LayoutHandler::setLayoutByName(QString layoutName) +{ + // switch to new layout + qDebug("setLayout: switch to new layout %s", layoutName.toStdString().c_str()); + m_visibleApps.append(m_requestsToBeVisibleApps); + m_requestsToBeVisibleApps.clear(); + + mp_dBusWindowManagerProxy->setLayoutByName(layoutName); + for (int i = 0; i < m_visibleApps.size(); ++i) + { + mp_dBusWindowManagerProxy->setSurfaceToLayoutArea(i, i); + } +} diff --git a/HomeScreen/src/layouthandler.h b/HomeScreen/src/layouthandler.h new file mode 100644 index 0000000..62e4fb5 --- /dev/null +++ b/HomeScreen/src/layouthandler.h @@ -0,0 +1,33 @@ +#ifndef LAYOUTHANDLER_H +#define LAYOUTHANDLER_H + +#include +#include "windowmanager_proxy.h" +#include "popup_proxy.h" + +class LayoutHandler : public QObject +{ + Q_OBJECT +public: + explicit LayoutHandler(QObject *parent = 0); + ~LayoutHandler(); + + void setUpLayers(); + +signals: + +public slots: + void makeMeVisible(int pid); + void setLayoutByName(QString layoutName); + +private: + org::agl::windowmanager *mp_dBusWindowManagerProxy; + org::agl::popup *mp_dBusPopupProxy; + + QList m_visibleApps; + QList m_invisibleApps; + QList m_requestsToBeVisibleApps; + +}; + +#endif // LAYOUTHANDLER_H diff --git a/HomeScreen/src/main.cpp b/HomeScreen/src/main.cpp index cc552f2..264468b 100644 --- a/HomeScreen/src/main.cpp +++ b/HomeScreen/src/main.cpp @@ -17,7 +17,8 @@ #include "mainwindow.h" #include #include -#include +//#include +#include int main(int argc, char *argv[]) { @@ -36,7 +37,11 @@ int main(int argc, char *argv[]) QCoreApplication::setOrganizationDomain("LinuxFoundation"); QCoreApplication::setOrganizationName("AutomotiveGradeLinux"); QCoreApplication::setApplicationName("HomeScreen"); - QCoreApplication::setApplicationVersion("0.2.0"); + QCoreApplication::setApplicationVersion("0.3.0"); + + QSurfaceFormat format; + format.setDepthBufferSize(16); + format.setStencilBufferSize(8); MainWindow w; w.show(); diff --git a/HomeScreen/src/mainwindow.cpp b/HomeScreen/src/mainwindow.cpp index 174f750..87558aa 100644 --- a/HomeScreen/src/mainwindow.cpp +++ b/HomeScreen/src/mainwindow.cpp @@ -26,6 +26,7 @@ MainWindow::MainWindow(QWidget *parent) : mp_settingsWidget(0), mp_applauncherwidget(0), mp_popupWidget(0), + mp_layoutHandler(new LayoutHandler()), mp_dBusDayNightModeProxy(0), mp_homeScreenControlInterface(0) { @@ -68,6 +69,7 @@ MainWindow::MainWindow(QWidget *parent) : // apply layout mp_applauncherwidget->move(0, 60); + mp_popupWidget = new PopupWidget(); mp_controlBarWidget->raise(); // apply layout @@ -83,6 +85,8 @@ 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_applauncherwidget, SIGNAL(newRequestsToBeVisibleApp(int)), mp_layoutHandler, SLOT(makeMeVisible(int))); + // apply color scheme updateColorScheme(); mp_statusBarWidget->updateColorScheme(); @@ -94,7 +98,13 @@ MainWindow::MainWindow(QWidget *parent) : // this is only useful during development and will be removed later setWindowIcon(QIcon(":/icons/home_day.png")); + mp_applauncherwidget->populateAppList(); + mp_layoutHandler->setUpLayers(); + mp_homeScreenControlInterface = new HomeScreenControlInterface(this); + QObject::connect(mp_homeScreenControlInterface, SIGNAL(newRequestsToBeVisibleApp(int)), mp_layoutHandler, SLOT(makeMeVisible(int))); + + QObject::connect(mp_popupWidget, SIGNAL(comboBoxResult(QString)), mp_layoutHandler, SLOT(setLayoutByName(QString))); } MainWindow::~MainWindow() @@ -102,6 +112,9 @@ MainWindow::~MainWindow() delete mp_homeScreenControlInterface; delete mp_dBusDayNightModeProxy; + + delete mp_layoutHandler; + delete mp_popupWidget; delete mp_applauncherwidget; delete mp_settingsWidget; @@ -151,11 +164,3 @@ void MainWindow::changeEvent(QEvent* event) QMainWindow::changeEvent(event); } -void MainWindow::on_pushButton_clicked() -{ - // start app - QProcess process; - QString file = "vlc"; - process.startDetached(file); - // manage ivi shell -} diff --git a/HomeScreen/src/mainwindow.h b/HomeScreen/src/mainwindow.h index cb2243e..d94546a 100644 --- a/HomeScreen/src/mainwindow.h +++ b/HomeScreen/src/mainwindow.h @@ -28,6 +28,8 @@ #include "applauncherwidget.h" #include "popupwidget.h" +#include "layouthandler.h" + namespace Ui { class MainWindow; @@ -53,8 +55,6 @@ protected: // called when the translator loaded a new language set void changeEvent(QEvent* event); -private slots: - void on_pushButton_clicked(); private: Ui::MainWindow *mp_ui; @@ -67,6 +67,8 @@ private: AppLauncherWidget *mp_applauncherwidget; PopupWidget *mp_popupWidget; + LayoutHandler *mp_layoutHandler; + org::agl::daynightmode *mp_dBusDayNightModeProxy; HomeScreenControlInterface *mp_homeScreenControlInterface; diff --git a/HomeScreen/src/popupwidget.cpp b/HomeScreen/src/popupwidget.cpp index 0a27dff..919bea0 100644 --- a/HomeScreen/src/popupwidget.cpp +++ b/HomeScreen/src/popupwidget.cpp @@ -21,7 +21,8 @@ PopupWidget::PopupWidget(QWidget *parent) : QWidget(parent), mp_ui(new Ui::PopupWidget), - mp_popupAdaptor(0) + mp_popupAdaptor(0), + m_sendComboBoxChoice(false) { // publish dbus popup interface mp_popupAdaptor = new PopupAdaptor((QObject*)this); @@ -60,6 +61,18 @@ void PopupWidget::updateColorScheme() void PopupWidget::showPopup(int /*type*/, const QString &text) { + m_sendComboBoxChoice = false; + mp_ui->comboBox->hide(); + this->show(); + this->raise(); + mp_ui->label_Text->setText(text); +} + +void PopupWidget::showPopupComboBox(const QString &text, const QStringList &choices) +{ + m_sendComboBoxChoice = true; + mp_ui->comboBox->addItems(choices); + mp_ui->comboBox->show(); this->show(); this->raise(); mp_ui->label_Text->setText(text); @@ -67,5 +80,10 @@ void PopupWidget::showPopup(int /*type*/, const QString &text) void PopupWidget::on_pushButton_OK_clicked() { + if (m_sendComboBoxChoice) + { + comboBoxResult(mp_ui->comboBox->currentText()); + m_sendComboBoxChoice = false; + } this->close(); } diff --git a/HomeScreen/src/popupwidget.h b/HomeScreen/src/popupwidget.h index 7a73b92..eaf41de 100644 --- a/HomeScreen/src/popupwidget.h +++ b/HomeScreen/src/popupwidget.h @@ -38,14 +38,19 @@ public slots: // from popup_adapter.h public Q_SLOTS: // METHODS void showPopup(int /*type*/, const QString &text); + void showPopupComboBox(const QString &text, const QStringList &choices); private slots: void on_pushButton_OK_clicked(); +signals: + void comboBoxResult(QString choice); + private: Ui::PopupWidget *mp_ui; PopupAdaptor *mp_popupAdaptor; + bool m_sendComboBoxChoice; // for showPupupFor LayoutSelection //QList m_pushButtons; }; diff --git a/HomeScreenAppFrameworkBinderTizen/README.md b/HomeScreenAppFrameworkBinderTizen/README.md index 17d181c..7a28ada 100644 --- a/HomeScreenAppFrameworkBinderTizen/README.md +++ b/HomeScreenAppFrameworkBinderTizen/README.md @@ -9,6 +9,12 @@ https://gerrit.automotivelinux.org/gerrit/#/admin/projects/staging/HomeScreen AGL repo for bitbake recipe: https://gerrit.automotivelinux.org/gerrit/#/admin/projects/AGL/meta-agl-demo/recipes-demo-hmi/HomeScreen/HomeScreen_?.bb +v0.3.0 +09/30/2016 + +#changes +- updated version number + v0.2.0 08/05/2016 diff --git a/HomeScreenAppFrameworkBinderTizen/src/main.cpp b/HomeScreenAppFrameworkBinderTizen/src/main.cpp index 2f7d3a8..f2168d0 100644 --- a/HomeScreenAppFrameworkBinderTizen/src/main.cpp +++ b/HomeScreenAppFrameworkBinderTizen/src/main.cpp @@ -27,7 +27,7 @@ int main(int argc, char *argv[]) QCoreApplication::setOrganizationDomain("LinuxFoundation"); QCoreApplication::setOrganizationName("AutomotiveGradeLinux"); QCoreApplication::setApplicationName("HomeScreenAppFrameworkBinderTizen"); - QCoreApplication::setApplicationVersion("0.2.0"); + QCoreApplication::setApplicationVersion("0.3.0"); HomeScreenAppFrameworkBinderTizen *tdp = new HomeScreenAppFrameworkBinderTizen(); diff --git a/HomeScreenSimulator/README.md b/HomeScreenSimulator/README.md index 0a10780..2f4bd17 100644 --- a/HomeScreenSimulator/README.md +++ b/HomeScreenSimulator/README.md @@ -9,6 +9,12 @@ https://gerrit.automotivelinux.org/gerrit/#/admin/projects/staging/HomeScreen AGL repo for bitbake recipe: https://gerrit.automotivelinux.org/gerrit/#/admin/projects/AGL/meta-agl-demo/recipes-demo-hmi/HomeScreen/HomeScreen_?.bb +v0.3.0 +09/30/2016 + +#changes +- added popup choice example + v0.2.0 08/05/2016 diff --git a/HomeScreenSimulator/resources/mainwindow.ui b/HomeScreenSimulator/resources/mainwindow.ui index 289c237..1915a24 100644 --- a/HomeScreenSimulator/resources/mainwindow.ui +++ b/HomeScreenSimulator/resources/mainwindow.ui @@ -113,6 +113,19 @@ "Hello World" Example + + + + 230 + 380 + 191 + 27 + + + + ComboBox Example + + diff --git a/HomeScreenSimulator/src/main.cpp b/HomeScreenSimulator/src/main.cpp index 5a165f8..00c7ac2 100644 --- a/HomeScreenSimulator/src/main.cpp +++ b/HomeScreenSimulator/src/main.cpp @@ -36,12 +36,11 @@ int main(int argc, char *argv[]) QCoreApplication::setOrganizationDomain("LinuxFoundation"); QCoreApplication::setOrganizationName("AutomotiveGradeLinux"); QCoreApplication::setApplicationName("HomeScreenSimulator"); - QCoreApplication::setApplicationVersion("0.2.0"); + QCoreApplication::setApplicationVersion("0.3.0"); MainWindow w; w.show(); - // start input and system settings simulator on developer PCs #ifdef __arm__ qDebug("Running on ARM architecture"); #endif diff --git a/HomeScreenSimulator/src/mainwindow.cpp b/HomeScreenSimulator/src/mainwindow.cpp index 74c02d7..d670154 100644 --- a/HomeScreenSimulator/src/mainwindow.cpp +++ b/HomeScreenSimulator/src/mainwindow.cpp @@ -149,3 +149,13 @@ void MainWindow::on_pushButton_PopupExample_clicked() { mp_dBusPopupProxy->showPopup(0, "Hello Popup!\nNice to see you!"); } + +void MainWindow::on_pushButton_comboBoxExample_clicked() +{ + QStringList choices; + choices.append("Item1"); + choices.append("Item2"); + choices.append("Item3"); + choices.append("Item4"); + mp_dBusPopupProxy->showPopupComboBox("Make your choice!", choices); +} diff --git a/HomeScreenSimulator/src/mainwindow.h b/HomeScreenSimulator/src/mainwindow.h index 7c2f19b..dd412a3 100644 --- a/HomeScreenSimulator/src/mainwindow.h +++ b/HomeScreenSimulator/src/mainwindow.h @@ -57,6 +57,8 @@ private slots: void on_pushButton_PopupExample_clicked(); + void on_pushButton_comboBoxExample_clicked(); + private: Ui::MainWindow *mp_ui; DaynightmodeAdaptor *mp_dBusDayNightModeAdapter; diff --git a/InputEventManager/README.md b/InputEventManager/README.md index 078305d..d7dcf55 100644 --- a/InputEventManager/README.md +++ b/InputEventManager/README.md @@ -9,6 +9,12 @@ https://gerrit.automotivelinux.org/gerrit/#/admin/projects/staging/HomeScreen AGL repo for bitbake recipe: https://gerrit.automotivelinux.org/gerrit/#/admin/projects/AGL/meta-agl-demo/recipes-demo-hmi/HomeScreen/HomeScreen_?.bb +v0.3.0 +09/30/2016 + +#changes +- updated version number + v0.2.0 08/05/2016 diff --git a/InputEventManager/src/main.cpp b/InputEventManager/src/main.cpp index 4862dbd..1025bc3 100644 --- a/InputEventManager/src/main.cpp +++ b/InputEventManager/src/main.cpp @@ -25,7 +25,7 @@ int main(int argc, char *argv[]) QCoreApplication::setOrganizationDomain("LinuxFoundation"); QCoreApplication::setOrganizationName("AutomotiveGradeLinux"); QCoreApplication::setApplicationName("InputEventManager"); - QCoreApplication::setApplicationVersion("0.2.0"); + QCoreApplication::setApplicationVersion("0.3.0"); InputEventManager *inputEventManager = new InputEventManager(); diff --git a/README.md b/README.md index 1cf76a1..945957f 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,10 @@ This project contains: HomeScreen: AGL Home Screen reference implementation HomeScreenSimulator: AGL Home Screen Simulator for development +InputEventManager: AGL Input event manager interfaces: library with the D-Bus interfaces SampleAppTimeDate: AGL Sample Application for Home Screen Statusbar - +HomeScreenAppFrameworkBinderTizen: Binder for the TIZEN application framework AGL repo for source code: https://gerrit.automotivelinux.org/gerrit/#/admin/projects/staging/HomeScreen @@ -12,3 +13,96 @@ https://gerrit.automotivelinux.org/gerrit/#/admin/projects/staging/HomeScreen AGL repo for bitbake recipe: https://gerrit.automotivelinux.org/gerrit/#/admin/projects/AGL/meta-agl-demo/recipes-demo-hmi/HomeScreen/HomeScreen_?.bb + +Instructions for running on porter board +---------------------------------------- + +Add "HomeScreen" to your image recipe. +Right now, HomeScreen depends on the TIZEN application manager, because the HomeScreenAppFrameworkBinderTizen makes use of it. +So also add this to your image recipe: +" + tizen-platform-wrapper \ + tizen-platform-config \ + xdgmime \ + libdlog \ + dlogutil \ + libiri \ + \ + smack \ + libprivilege-control \ + libslp-db-util \ + \ + vconf \ + capi-base-common \ + ail \ + \ + sensor \ + libsf-common \ + \ + iniparser \ + app-svc \ + heynoti \ + notification \ + app-core-efl \ + app-core-common \ + capi-system-info \ + \ + pkgmgr-info \ + librua \ + bundle \ + app-checker \ + \ + libcom-core \ + privacy-manager-server \ + pkgmgr \ + pkgmgr-info \ + pkgmgr-info-parser \ + aul \ + aul-test \ + \ + dlt-daemon \ + dlt-daemon-systemd \ + \ + amhelloworld \ + pkgmgr-first-setup-service \ +" + + +All "HomeScreen" applications can be found in /opt/AGL/HomeScreen. + +Make sure, weston is using the IVI shell extension: + +/etc/xdg/weston/weston.ini: + +[core] +shell=ivi-shell.so + +[ivi-shell] +ivi-module=ivi-controller.so +ivi-shell-user-interface=/usr/lib/weston/weston-ivi-shell-user-interface + +[output] +name=HDMI-A-1 +transform=270 + + + +If you want to use the TIZEN application manager to launch apps, you need to execute HomeScreen app with the user "aglglobalapp": + +Therefore you need to change the owner of the weston socket: + +chown aglglobalapp:aglglobalapp /tmp/wayland-0 + +P.S.: the path may also something likle /run/user/0, depending on the XDG_RUNTIME_DIR. + +If not already stared, launch D-Bus: +export `dbus-launch` + +Now you can start the HomeScreen apps: +cd /opt/AGL/HomeScreen +./WindowManager & +./InputEventManager & +./HomeScreenAppFrameworkBinderTizen & +./HomeScreen & + + diff --git a/SampleAppTimeDate/README.md b/SampleAppTimeDate/README.md index 7d37899..441751b 100644 --- a/SampleAppTimeDate/README.md +++ b/SampleAppTimeDate/README.md @@ -9,6 +9,12 @@ https://gerrit.automotivelinux.org/gerrit/#/admin/projects/staging/HomeScreen AGL repo for bitbake recipe: https://gerrit.automotivelinux.org/gerrit/#/admin/projects/AGL/meta-agl-demo/recipes-demo-hmi/HomeScreen/HomeScreen_?.bb +v0.3.0 +09/30/2016 + +#changes +- updated version number + v0.2.0 08/05/2016 diff --git a/SampleAppTimeDate/src/main.cpp b/SampleAppTimeDate/src/main.cpp index 5be8431..6c0d83c 100644 --- a/SampleAppTimeDate/src/main.cpp +++ b/SampleAppTimeDate/src/main.cpp @@ -9,7 +9,7 @@ int main(int argc, char *argv[]) QCoreApplication::setOrganizationDomain("LinuxFoundation"); QCoreApplication::setOrganizationName("AutomotiveGradeLinux"); QCoreApplication::setApplicationName("SampleAppTimeDate"); - QCoreApplication::setApplicationVersion("0.2.0"); + QCoreApplication::setApplicationVersion("0.3.0"); TimeDateProvider *tdp = new TimeDateProvider(); tdp->start(); diff --git a/WindowManager/README.md b/WindowManager/README.md index 64cf50b..135dbd2 100644 --- a/WindowManager/README.md +++ b/WindowManager/README.md @@ -9,6 +9,12 @@ https://gerrit.automotivelinux.org/gerrit/#/admin/projects/staging/HomeScreen AGL repo for bitbake recipe: https://gerrit.automotivelinux.org/gerrit/#/admin/projects/AGL/meta-agl-demo/recipes-demo-hmi/HomeScreen/HomeScreen_?.bb +v0.3.0 +09/30/2016 + +#changes +- implementation ongoing + v0.2.0 08/05/2016 diff --git a/WindowManager/WindowManager.pro b/WindowManager/WindowManager.pro index 74dfb3a..58ce08a 100644 --- a/WindowManager/WindowManager.pro +++ b/WindowManager/WindowManager.pro @@ -19,8 +19,6 @@ TARGET = WindowManager CONFIG += console CONFIG -= app_bundle -TEMPLATE = app - SOURCES += src/main.cpp \ src/windowmanager.cpp @@ -31,15 +29,12 @@ HEADERS += \ INCLUDEPATH += $$OUT_PWD/../interfaces INCLUDEPATH += ../interfaces/ -#LIBS += -L$$OUT_PWD/../interfaces -linterfaces +LIBS += -L$$OUT_PWD/../interfaces -linterfaces contains(QT_ARCH, arm.*) { LIBS += -lilmControl -lilmCommon } -#contains(QT_ARCH, arm.*) { -# LIBS += -lpkgmgr-info -# LIBS += -laul -#} +FORMS += OTHER_FILES += \ README.md @@ -48,3 +43,4 @@ OTHER_FILES += \ QMAKE_CLEAN += -r \ $$OUT_PWD/WindowManager \ $$OUT_PWD/Makefile + diff --git a/WindowManager/src/main.cpp b/WindowManager/src/main.cpp index 14e0e00..333d864 100644 --- a/WindowManager/src/main.cpp +++ b/WindowManager/src/main.cpp @@ -25,9 +25,21 @@ int main(int argc, char *argv[]) QCoreApplication::setOrganizationDomain("LinuxFoundation"); QCoreApplication::setOrganizationName("AutomotiveGradeLinux"); QCoreApplication::setApplicationName("WindowManager"); - QCoreApplication::setApplicationVersion("0.2.0"); + QCoreApplication::setApplicationVersion("0.3.0"); + + qDBusRegisterMetaType(); + qDBusRegisterMetaType >(); + qDBusRegisterMetaType(); + qDBusRegisterMetaType >(); WindowManager *windowManager = new WindowManager(); +#ifdef __arm__ + qDebug("Running on ARM architecture"); +#endif +#ifdef __i386__ + qDebug("Running on x86 architecture"); +#endif + return a.exec(); } diff --git a/WindowManager/src/windowmanager.cpp b/WindowManager/src/windowmanager.cpp index dcab2f4..d35db9b 100644 --- a/WindowManager/src/windowmanager.cpp +++ b/WindowManager/src/windowmanager.cpp @@ -15,178 +15,147 @@ */ #include "windowmanager.hpp" +#include +#include ////////////////////////////////////////// // THIS IS STILL UNDER HEAVY DEVELOPMENT! // DO NOT JUDGE THE SOURCE CODE :) ////////////////////////////////////////// +void* WindowManager::myThis = 0; WindowManager::WindowManager(QObject *parent) : - QObject(parent) + QObject(parent), + m_layouts(), + m_layoutNames(), + m_currentLayout(-1) { qDebug("WindowManager"); -#ifdef __arm__ - ilmErrorTypes err; - if (true)//!ilm_isInitialized()) ...crashes... - { - err = ilm_init(); - qDebug("ilm_init = %d", err); - } + // publish windowmanager interface + mp_windowManagerAdaptor = new WindowmanagerAdaptor((QObject*)this); + QDBusConnection dbus = QDBusConnection::sessionBus(); + dbus.registerObject("/windowmanager", this); + dbus.registerService("org.agl.windowmanager"); - t_ilm_uint screenID = 0; - t_ilm_uint width; - t_ilm_uint height; - - err = ilm_getScreenResolution(screenID, &width, &height); - qDebug("ilm_getScreenResolution = %d", err); - qDebug("pWidth %d, pHeight %d", width, height); +#ifdef __arm__ + mp_processLayers = new QList; + mp_surfaces = new QMap; + ilmErrorTypes err; - t_ilm_layer layerId = 42; // does not matter - err = ilm_layerCreateWithDimension(&layerId, width, height); - qDebug("ilm_layerCreateWithDimension = %d", err); - qDebug("layerId = %d", layerId); + err = ilm_init(); + qDebug("ilm_init = %d", err); - err = ilm_layerSetVisibility(layerId, true); - qDebug("ilm_layerSetVisibility = %d", err); + myThis = this; + err = ilm_registerNotification(WindowManager::notificationFunc_static, this); - ilm_commitChanges(); - err = ilm_displaySetRenderOrder(screenID, &layerId, 1); - qDebug("ilm_displaySetRenderOrder = %d", err); +#endif +} - ilm_commitChanges(); +WindowManager::~WindowManager() +{ + delete mp_windowManagerAdaptor; +#ifdef __arm__ + delete mp_surfaces; - err = ilm_layerSetSourceRectangle(layerId, 0, 0, width, height); - qDebug("ilm_layerSetSourceRectangle = %d", err); - err = ilm_layerSetDestinationRectangle(layerId, 0, 0, width, height); - qDebug("layerSetDestinationRectangle = %d", err); + ilm_destroy(); +#endif +} - ilm_commitChanges(); +void WindowManager::dumpScene() +{ + qDebug("\n"); + qDebug("current layout : %d", m_currentLayout); + qDebug("available layouts: %d", m_layouts.size()); + QMap >::iterator i = m_layouts.begin(); - t_ilm_float opacity = 1.0; + QList result; + while (i != m_layouts.constEnd()) + { + qDebug("--[id: %d]--[%s]--", i.key(), m_layoutNames.find(i.key()).value().toStdString().c_str()); + qDebug(" %d surface areas", i.value().size()); + for (int j = 0; j < i.value().size(); ++j) + { + qDebug(" -area %d", j); + qDebug(" -x : %d", i.value().at(j).x); + qDebug(" -y : %d", i.value().at(j).y); + qDebug(" -width : %d", i.value().at(j).width); + qDebug(" -height: %d", i.value().at(j).height); + } - err = ilm_layerSetOpacity(layerId, opacity); - qDebug("ilm_layerSetOpacity = %d", err); + ++i; + } +} - t_ilm_int length; - t_ilm_surface* pArray; +#ifdef __arm__ - err = ilm_getSurfaceIDs(&length, &pArray); - qDebug("ilm_getSurfaceIDs = %d", err); - qDebug("length %d pArray[0] %d", length, pArray[0]); +void WindowManager::createNewLayer(int layerId) +{ + ilmErrorTypes err; - if (length > 0) - { - t_ilm_surface surfaceId = pArray[0]; + t_ilm_uint screenID = 0; + t_ilm_uint width; + t_ilm_uint height; - err = ilm_layerAddSurface(layerId, surfaceId); - qDebug("ilm_layerAddSurface = %d", err); + err = ilm_getScreenResolution(screenID, &width, &height); - t_ilm_bool visibility; - err = ilm_surfaceGetVisibility(surfaceId, &visibility); - qDebug("ilm_surfaceGetVisibility = %d", err); - qDebug("visibility %d", visibility); + t_ilm_layer newLayerId = layerId; + err = ilm_layerCreateWithDimension(&newLayerId, width, height); + qDebug("ilm_layerCreateWithDimension = %d", err); + qDebug("layerIdWallpaper = %d", newLayerId); - err = ilm_surfaceSetVisibility(surfaceId, true); - qDebug("ilm_surfaceSetVisibility = %d", err); + err = ilm_layerSetVisibility(newLayerId, true); + qDebug("ilm_layerSetVisibility = %d", err); - err = ilm_surfaceSetOpacity(surfaceId, opacity); - qDebug("ilm_surfaceSetOpacity = %d", err); + t_ilm_float opacity = 1.0; + err = ilm_layerSetOpacity(newLayerId, opacity); - err = ilm_surfaceSetSourceRectangle(surfaceId, 0, 0, 200, 200); - qDebug("ilm_surfaceSetSourceRectangle = %d", err); - err = ilm_surfaceSetDestinationRectangle(surfaceId, 0, 0, 200, 200); - qDebug("surfaceSetDestinationRectangle = %d", err); + ilm_commitChanges(); +} +void WindowManager::addSurfaceToLayer(int surfaceId, int layerId) +{ + t_ilm_int length; + t_ilm_layer* pArray; + ilm_getLayerIDs(&length, &pArray); + bool layerFound(false); + for (int i = 0; i< length; ++i) + { + if (layerId == pArray[i]) + { + layerFound = true; + } } - ilm_commitChanges(); + if (!layerFound) + { + createNewLayer(layerId); + } - struct ilmScreenProperties screenProperties; - struct ilmLayerProperties layerProperties; struct ilmSurfaceProperties surfaceProperties; + ilm_getPropertiesOfSurface(surfaceId, &surfaceProperties); + qDebug(" origSourceWidth : %d", surfaceProperties.origSourceWidth); + qDebug(" origSourceHeight: %d", surfaceProperties.origSourceHeight); - err = ilm_getPropertiesOfScreen(0, &screenProperties); - qDebug("ilm_getPropertiesOfScreen = %d", err); - err = ilm_getPropertiesOfLayer(layerId, &layerProperties); - qDebug("ilm_getPropertiesOfLayer = %d", err); - err = ilm_getPropertiesOfSurface(pArray[0], &surfaceProperties); - qDebug("ilm_getPropertiesOfSurface = %d", err); - - - qDebug("screen"); - qDebug("t_ilm_uint %d", screenProperties.layerCount); /*!< number of layers displayed on the screen */ - //qDebug("t_ilm_layer* %d", screenProperties.layerIds[0]); /*!< array of layer ids */ - qDebug("t_ilm_uint %d", screenProperties.harwareLayerCount); /*!< number of hardware layers */ - qDebug("t_ilm_uint %d", screenProperties.screenWidth); /*!< width value of screen in pixels */ - qDebug("t_ilm_uint %d", screenProperties.screenHeight); /*!< height value of screen in pixels */ - - qDebug("layer"); - qDebug("t_ilm_float %f", layerProperties.opacity); /*!< opacity value of the layer */ - qDebug("t_ilm_uint %d", layerProperties.sourceX); /*!< x source position value of the layer */ - qDebug("t_ilm_uint %d", layerProperties.sourceY); /*!< y source position value of the layer */ - qDebug("t_ilm_uint %d", layerProperties.sourceWidth); /*!< source width value of the layer */ - qDebug("t_ilm_uint %d", layerProperties.sourceHeight); /*!< source height value of the layer */ - qDebug("t_ilm_uint %d", layerProperties.origSourceWidth); /*!< original source width value of the layer */ - qDebug("t_ilm_uint %d", layerProperties.origSourceHeight); /*!< original source height value of the layer */ - qDebug("t_ilm_uint %d", layerProperties.destX); /*!< x destination position value of the layer */ - qDebug("t_ilm_uint %d", layerProperties.destY); /*!< y desitination position value of the layer */ - qDebug("t_ilm_uint %d", layerProperties.destWidth); /*!< destination width value of the layer */ - qDebug("t_ilm_uint %d", layerProperties.destHeight); /*!< destination height value of the layer */ - qDebug("ilmOrientation%d", layerProperties.orientation); /*!< orientation value of the layer */ - qDebug("t_ilm_bool %d", layerProperties.visibility); /*!< visibility value of the layer */ - qDebug("t_ilm_uint %d", layerProperties.type); /*!< type of layer */ - qDebug("t_ilm_int %d", layerProperties.creatorPid); /*!< process id of application that created this layer */ - - qDebug("surface"); - qDebug("t_ilm_float %f", surfaceProperties.opacity); /*!< opacity value of the surface */ - qDebug("t_ilm_uint %d", surfaceProperties.sourceX); /*!< x source position value of the surface */ - qDebug("t_ilm_uint %d", surfaceProperties.sourceY); /*!< y source position value of the surface */ - qDebug("t_ilm_uint %d", surfaceProperties.sourceWidth); /*!< source width value of the surface */ - qDebug("t_ilm_uint %d", surfaceProperties.sourceHeight); /*!< source height value of the surface */ - qDebug("t_ilm_uint %d", surfaceProperties.origSourceWidth); /*!< original source width value of the surface */ - qDebug("t_ilm_uint %d", surfaceProperties.origSourceHeight); /*!< original source height value of the surface */ - qDebug("t_ilm_uint %d", surfaceProperties.destX); /*!< x destination position value of the surface */ - qDebug("t_ilm_uint %d", surfaceProperties.destY); /*!< y desitination position value of the surface */ - qDebug("t_ilm_uint %d", surfaceProperties.destWidth); /*!< destination width value of the surface */ - qDebug("t_ilm_uint %d", surfaceProperties.destHeight); /*!< destination height value of the surface */ - qDebug("ilmOrientation %d", surfaceProperties.orientation); /*!< orientation value of the surface */ - qDebug("t_ilm_bool %d", surfaceProperties.visibility); /*!< visibility value of the surface */ - qDebug("t_ilm_uint %d", surfaceProperties.frameCounter); /*!< already rendered frames of surface */ - qDebug("t_ilm_uint %d", surfaceProperties.drawCounter); /*!< content updates of surface */ - qDebug("t_ilm_uint %d", surfaceProperties.updateCounter); /*!< content updates of surface */ - qDebug("t_ilm_uint %d", surfaceProperties.pixelformat); /*!< pixel format of surface */ - qDebug("t_ilm_uint %d", surfaceProperties.nativeSurface); /*!< native surface handle of surface */ - qDebug("t_ilm_int %d", surfaceProperties.creatorPid); /*!< process id of application that created this surface */ - qDebug("ilmInputDevice %d", surfaceProperties.focus); /*!< bitmask of every type of device that this surface has focus in */ + ilm_surfaceSetDestinationRectangle(surfaceId, 0, 0, surfaceProperties.origSourceWidth, surfaceProperties.origSourceHeight); + ilm_surfaceSetSourceRectangle(surfaceId, 0, 0, surfaceProperties.origSourceWidth, surfaceProperties.origSourceHeight); + ilm_surfaceSetOpacity(surfaceId, 1.0); + ilm_surfaceSetVisibility(surfaceId, true); - err = ilm_registerNotification(WindowManager::notificationFunc_static, this); -#endif -} + ilm_layerAddSurface(layerId, surfaceId); -WindowManager::~WindowManager() -{ -#ifdef __arm__ - ilmErrorTypes err; - if (ilm_isInitialized()) - { - err = ilm_destroy(); - qDebug("ilm_destroy = %d", err); - } -#endif + ilm_commitChanges(); } -#ifdef __arm__ void WindowManager::notificationFunc_non_static(ilmObjectType object, t_ilm_uint id, t_ilm_bool created) { - qDebug("notificationFunc_non_static"); if (ILM_SURFACE == object) { struct ilmSurfaceProperties surfaceProperties; @@ -194,53 +163,74 @@ void WindowManager::notificationFunc_non_static(ilmObjectType object, if (created) { qDebug("Surface created, ID: %d", id); - - ilm_layerAddSurface(42 /*always use layer 42 for now*/, id); - ilm_surfaceSetOpacity(id, 1.0); - ilm_surfaceSetVisibility(id, true); ilm_getPropertiesOfSurface(id, &surfaceProperties); - ilm_surfaceSetSourceRectangle(id, 0, 0, surfaceProperties.origSourceWidth, surfaceProperties.origSourceHeight); + qDebug(" origSourceWidth : %d", surfaceProperties.origSourceWidth); + qDebug(" origSourceHeight: %d", surfaceProperties.origSourceHeight); + + addSurfaceToLayer(id, surfaceProperties.creatorPid); + + t_ilm_int length; + t_ilm_surface* pArray; + ilm_getSurfaceIDs(&length, &pArray); + ilm_layerSetRenderOrder(42, pArray, length); ilm_commitChanges(); + + SurfaceInfo surfaceInfo; + surfaceInfo.pid = surfaceProperties.creatorPid; + QString procInfoFileName = QString("/proc/") + QString::number(surfaceInfo.pid) + QString("/comm"); + QFile procInfo(procInfoFileName); + if (procInfo.open(QIODevice::ReadOnly)) + { + QTextStream in(&procInfo); + surfaceInfo.processName = in.readLine(); + qDebug("surface id %d, pid %d: %s", id, surfaceInfo.pid, surfaceInfo.processName.toStdString().c_str()); + } + + mp_surfaces->insert(id, surfaceInfo); + ilm_surfaceAddNotification(id, surfaceCallbackFunction_static); } else { qDebug("Surface destroyed, ID: %d", id); + mp_surfaces->erase(mp_surfaces->find(id)); + ilm_surfaceRemoveNotification(id); } + // rearrange surfaces on screen t_ilm_uint screenID = 0; t_ilm_uint width; t_ilm_uint height; ilm_getScreenResolution(screenID, &width, &height); - t_ilm_int length; - t_ilm_surface* pArray; - - ilm_getSurfaceIDs(&length, &pArray); - qDebug("length %d", length); - + qDebug("%d surfaces to show", mp_surfaces->count()); - for (int i = 0; i < length; ++i) + QMap::const_iterator i = mp_surfaces->constBegin(); + int counter(0); + while (i != mp_surfaces->constEnd()) { - //ilm_getPropertiesOfSurface(pArray[i], &surfaceProperties); - qDebug("place surface %d at x: %f, y: %f, width: %f, height: %f", - pArray[i], - i * (width / (1.0 * length)), + qDebug("place surface %d at x: %f, y: %d, width: %f, height: %d", + i.key(), + counter * (width / (1.0 * mp_surfaces->count())), 0, - width / (1.0 * length), + width / (1.0 * mp_surfaces->count()), height); - ilm_surfaceSetDestinationRectangle(pArray[(int)i], - i * (width / (1.0 * length)), + ilm_surfaceSetDestinationRectangle(i.key(), + counter * (width / (1.0 * mp_surfaces->count())), 0, - width / (1.0 * length), + width / (1.0 * mp_surfaces->count()), height); + + ++i; + ++counter; } + ilm_commitChanges(); } if (ILM_LAYER == object) { - qDebug("Layer.. we don't care..."); + //qDebug("Layer.. we don't care..."); } } @@ -249,7 +239,132 @@ void WindowManager::notificationFunc_static(ilmObjectType object, t_ilm_bool created, void* user_data) { - qDebug("notificationFunc_static"); - static_cast(user_data)->notificationFunc_non_static(object, id, created); + static_cast(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 changes for surface %d", surface); + if (ILM_NOTIFICATION_VISIBILITY & mask) + { + qDebug("ILM_NOTIFICATION_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"); + } +} + +void WindowManager::surfaceCallbackFunction_static(t_ilm_surface surface, + struct ilmSurfaceProperties* surfaceProperties, + t_ilm_notification_mask mask) + +{ + static_cast(WindowManager::myThis)->surfaceCallbackFunction_non_static(surface, surfaceProperties, mask); } #endif + +int WindowManager::addLayout(int layoutId, const QString &layoutName, const QList &surfaceAreas) +{ + m_layouts.insert(layoutId, surfaceAreas); + m_layoutNames.insert(layoutId, layoutName); + qDebug("addLayout %d %s, size %d", layoutId, layoutName.toStdString().c_str(), surfaceAreas.size()); + + dumpScene(); + + return true; +} + +QList WindowManager::getAvailableLayouts(int numberOfAppSurfaces) +{ + QMap >::iterator i = m_layouts.begin(); + + QList result; + while (i != m_layouts.constEnd()) + { + if (i.value().size() == numberOfAppSurfaces) + { + result.append(i.key()); + } + + ++i; + } + + return result; +} + +// maybe not needed anymore +QList WindowManager::getAvailableSurfaces() +{ + QList points; + SimplePoint point; + point.x = 1; + point.y = 2; + points.append(point); + point.x = 11; + point.y = 22; + points.append(point); + point.x = 111; + point.y = 222; + points.append(point); + + return points; +} + +int WindowManager::getLayout() +{ + return m_currentLayout; +} + +QString WindowManager::getLayoutName(int layoutId) +{ + return m_layoutNames.find(layoutId).value(); +} + +void WindowManager::setLayoutById(int layoutId) +{ + m_currentLayout = layoutId; + + dumpScene(); +} + +void WindowManager::setLayoutByName(const QString &layoutName) +{ + QMap::iterator i = m_layoutNames.begin(); + while (i != m_layoutNames.constEnd()) + { + if (i.value() == layoutName) + { + m_currentLayout = i.key(); + } + ++i; + } + + dumpScene(); +} + +void WindowManager::setSurfaceToLayoutArea(int surfaceId, int layoutAreaId) +{ + dumpScene(); +} diff --git a/WindowManager/src/windowmanager.hpp b/WindowManager/src/windowmanager.hpp index ee779aa..8fb716d 100644 --- a/WindowManager/src/windowmanager.hpp +++ b/WindowManager/src/windowmanager.hpp @@ -18,7 +18,17 @@ #define WINDOWMANAGER_HPP #include +#include +#include +#include "windowmanager_adapter.h" + + +typedef struct +{ + int pid; + QString processName; +} SurfaceInfo; #ifdef __arm__ extern "C" { @@ -26,19 +36,37 @@ extern "C" { } #endif - class WindowManager : public QObject { Q_OBJECT + public: explicit WindowManager(QObject *parent = 0); + QMutex callbackMutex; + ~WindowManager(); private: + WindowmanagerAdaptor *mp_windowManagerAdaptor; + QMap > m_layouts; + QMap m_layoutNames; + int m_currentLayout; + void dumpScene(); +#ifdef __arm__ + void createNewLayer(int layerId); + void addSurfaceToLayer(int surfaceId, int layerId); + + QMap *mp_surfaces; + /* one layer per pid is created + where the surfaces are added that are created by the process */ + QList *mp_processLayers; +#endif public: + static void* myThis; #ifdef __arm__ + // for general notifications void notificationFunc_non_static(ilmObjectType object, t_ilm_uint id, t_ilm_bool created); @@ -46,9 +74,32 @@ public: t_ilm_uint id, t_ilm_bool created, void* user_data); + + + // for surface notifications + void surfaceCallbackFunction_non_static(t_ilm_surface surface, + struct ilmSurfaceProperties* surfaceProperties, + t_ilm_notification_mask mask); + static void surfaceCallbackFunction_static(t_ilm_surface surface, + struct ilmSurfaceProperties* surfaceProperties, + t_ilm_notification_mask mask); + #endif public slots: + +// from windowmanager_adapter.h +public Q_SLOTS: // METHODS + int addLayout(int layoutId, const QString &layoutName, const QList &surfaceAreas); + QList getAvailableLayouts(int numberOfAppSurfaces); + QList getAvailableSurfaces(); + int getLayout(); + QString getLayoutName(int layoutId); + void setLayoutById(int layoutId); + void setLayoutByName(const QString &layoutName); + void setSurfaceToLayoutArea(int surfaceId, int layoutAreaId); + }; + #endif // WINDOWMANAGER_HPP diff --git a/interfaces/README.md b/interfaces/README.md index 0d11315..c669548 100644 --- a/interfaces/README.md +++ b/interfaces/README.md @@ -9,6 +9,12 @@ https://gerrit.automotivelinux.org/gerrit/#/admin/projects/staging/HomeScreen AGL repo for bitbake recipe: https://gerrit.automotivelinux.org/gerrit/#/admin/projects/AGL/meta-agl-demo/recipes-demo-hmi/HomeScreen/HomeScreen_?.bb +v0.3.0 +09/30/2016 + +#changes +- interface definition ongoing + v0.1.1 07/06/2016 diff --git a/interfaces/homescreen.xml b/interfaces/homescreen.xml index 55f4305..3eb66d0 100644 --- a/interfaces/homescreen.xml +++ b/interfaces/homescreen.xml @@ -17,6 +17,9 @@ + + + diff --git a/interfaces/include/windowmanager.hpp b/interfaces/include/windowmanager.hpp new file mode 100644 index 0000000..b587b70 --- /dev/null +++ b/interfaces/include/windowmanager.hpp @@ -0,0 +1,59 @@ +/* + * 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 WINDOWMANAGER_H +#define WINDOWMANAGER_H + +#include + +class SimplePoint +{ +public: + SimplePoint(); + virtual ~SimplePoint(); + + int x; + int y; + + friend QDBusArgument &operator <<(QDBusArgument &argument, const SimplePoint &mSimplePoint); + friend const QDBusArgument &operator >>(const QDBusArgument &argument, SimplePoint &mSimplePoint); +}; + + +class SimpleRect +{ +public: + SimpleRect(); + virtual ~SimpleRect(); + + int x; + int y; + int width; + int height; + + friend QDBusArgument &operator <<(QDBusArgument &argument, const SimpleRect &mSimpleRect); + friend const QDBusArgument &operator >>(const QDBusArgument &argument, SimpleRect &mSimpleRect); +}; + + +Q_DECLARE_METATYPE(SimplePoint) +Q_DECLARE_METATYPE(QList) + +Q_DECLARE_METATYPE(SimpleRect) +Q_DECLARE_METATYPE(QList) + + +#endif // WINDOWMANAGER_H diff --git a/interfaces/interfaces.pro b/interfaces/interfaces.pro index 75b4412..d776564 100644 --- a/interfaces/interfaces.pro +++ b/interfaces/interfaces.pro @@ -21,8 +21,12 @@ TEMPLATE = lib CONFIG += staticlib TARGET = interfaces -HEADERS += include/appframework.hpp -SOURCES += src/appframework.cpp +HEADERS += \ + include/appframework.hpp \ + include/windowmanager.hpp + +SOURCES += src/appframework.cpp \ + src/windowmanager.cpp XMLSOURCES = \ appframework.xml \ @@ -30,7 +34,8 @@ XMLSOURCES = \ homescreen.xml \ inputevent.xml \ popup.xml \ - statusbar.xml + statusbar.xml \ + windowmanager.xml gen_adapter_cpp.input = XMLSOURCES gen_adapter_cpp.commands = \ diff --git a/interfaces/popup.xml b/interfaces/popup.xml index 0ec8db3..c144f84 100644 --- a/interfaces/popup.xml +++ b/interfaces/popup.xml @@ -18,5 +18,9 @@ + + + + diff --git a/interfaces/src/appframework.cpp b/interfaces/src/appframework.cpp index 3a5ebda..afd6114 100644 --- a/interfaces/src/appframework.cpp +++ b/interfaces/src/appframework.cpp @@ -1,3 +1,19 @@ +/* + * 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. + */ + #include "include/appframework.hpp" AppInfo::AppInfo(QObject *parent) : diff --git a/interfaces/src/windowmanager.cpp b/interfaces/src/windowmanager.cpp new file mode 100644 index 0000000..12f425e --- /dev/null +++ b/interfaces/src/windowmanager.cpp @@ -0,0 +1,77 @@ +/* + * 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. + */ + +#include "include/windowmanager.hpp" + +SimplePoint::SimplePoint() +{ +} + +SimplePoint::~SimplePoint() +{ +} + + +SimpleRect::SimpleRect() +{ +} + +SimpleRect::~SimpleRect() +{ +} + +QDBusArgument &operator <<(QDBusArgument &argument, const SimplePoint &mSimplePoint) +{ + argument.beginStructure(); + argument << mSimplePoint.x; + argument << mSimplePoint.y; + argument.endStructure(); + + return argument; +} + +const QDBusArgument &operator >>(const QDBusArgument &argument, SimplePoint &mSimplePoint) +{ + argument.beginStructure(); + argument >> mSimplePoint.x; + argument >> mSimplePoint.y; + argument.endStructure(); + return argument; +} + +QDBusArgument &operator <<(QDBusArgument &argument, const SimpleRect &mSimpleRect) +{ + argument.beginStructure(); + argument << mSimpleRect.x; + argument << mSimpleRect.y; + argument << mSimpleRect.width; + argument << mSimpleRect.height; + argument.endStructure(); + + return argument; +} + +const QDBusArgument &operator >>(const QDBusArgument &argument, SimpleRect &mSimpleRect) +{ + argument.beginStructure(); + argument >> mSimpleRect.x; + argument >> mSimpleRect.y; + argument >> mSimpleRect.width; + argument >> mSimpleRect.height; + argument.endStructure(); + return argument; +} + diff --git a/interfaces/windowmanager.xml b/interfaces/windowmanager.xml new file mode 100644 index 0000000..9c1e7fe --- /dev/null +++ b/interfaces/windowmanager.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- 2.16.6