From: Bocklage, Jens Date: Wed, 26 Oct 2016 13:53:34 +0000 (+0200) Subject: Implement toggle full screen mechanism. X-Git-Tag: v0.4.0~6 X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?p=staging%2FHomeScreen.git;a=commitdiff_plain;h=d19555c038f6f1f89f08f12c88908d84b32b1bbf Implement toggle full screen mechanism. Signed-off-by: Bocklage, Jens --- diff --git a/HomeScreen/src/homescreencontrolinterface.cpp b/HomeScreen/src/homescreencontrolinterface.cpp index 45c3cbd..057e742 100644 --- a/HomeScreen/src/homescreencontrolinterface.cpp +++ b/HomeScreen/src/homescreencontrolinterface.cpp @@ -42,7 +42,8 @@ void HomeScreenControlInterface::hardKeyPressed(int key) } } -void HomeScreenControlInterface::setToFullscreen(int pid) +void HomeScreenControlInterface::toggleFullScreen() { - qDebug("setToFullscreen %d", pid); + qDebug("toggleFullScreen"); + newRequestsToggleFullscreen(); } diff --git a/HomeScreen/src/homescreencontrolinterface.h b/HomeScreen/src/homescreencontrolinterface.h index e406686..e341758 100644 --- a/HomeScreen/src/homescreencontrolinterface.h +++ b/HomeScreen/src/homescreencontrolinterface.h @@ -18,11 +18,12 @@ signals: signals: void newRequestsToBeVisibleApp(int pid); + void newRequestsToggleFullscreen(); //from homescreen_adapter.h public Q_SLOTS: // METHODS void hardKeyPressed(int key); - void setToFullscreen(int pid); + void toggleFullScreen(); private: HomescreenAdaptor *mp_homeScreenAdaptor; diff --git a/HomeScreen/src/layouthandler.cpp b/HomeScreen/src/layouthandler.cpp index cb21018..81bc106 100644 --- a/HomeScreen/src/layouthandler.cpp +++ b/HomeScreen/src/layouthandler.cpp @@ -36,6 +36,8 @@ void LayoutHandler::setUpLayouts() qDebug("setUpLayouts"); QList surfaceAreas; SimpleRect surfaceArea; + bool isFullScreen; + int associatedFullScreenLayout; const int SCREEN_WIDTH = 1080; const int SCREEN_HEIGHT = 1920; @@ -59,7 +61,10 @@ void LayoutHandler::setUpLayouts() surfaceAreas.append(surfaceArea); - mp_dBusWindowManagerProxy->addLayout(1, "one app", surfaceAreas); + isFullScreen = false; + associatedFullScreenLayout = 4; + + mp_dBusWindowManagerProxy->addLayout(1, "one app", isFullScreen, associatedFullScreenLayout, surfaceAreas); surfaceAreas.clear(); @@ -83,7 +88,10 @@ void LayoutHandler::setUpLayouts() surfaceAreas.append(surfaceArea); - mp_dBusWindowManagerProxy->addLayout(2, "top on bottom", surfaceAreas); + isFullScreen = false; + associatedFullScreenLayout = -1; + + mp_dBusWindowManagerProxy->addLayout(2, "top on bottom", isFullScreen, associatedFullScreenLayout, surfaceAreas); surfaceAreas.clear(); @@ -107,7 +115,30 @@ void LayoutHandler::setUpLayouts() surfaceAreas.append(surfaceArea); - mp_dBusWindowManagerProxy->addLayout(3, "side by side", surfaceAreas); + isFullScreen = false; + associatedFullScreenLayout = -1; + + mp_dBusWindowManagerProxy->addLayout(3, "side by side", isFullScreen, associatedFullScreenLayout, surfaceAreas); + + + surfaceAreas.clear(); + + // layout 4: + // one app surface full screen, no statusbar, no control bar + surfaceArea.x = 0; + surfaceArea.y = 0; + surfaceArea.width = SCREEN_WIDTH; + surfaceArea.height = SCREEN_HEIGHT; + + surfaceAreas.append(surfaceArea); + + isFullScreen = true; + associatedFullScreenLayout = 1; + + mp_dBusWindowManagerProxy->addLayout(4, "one app full screen", isFullScreen, associatedFullScreenLayout, surfaceAreas); + + + surfaceAreas.clear(); } @@ -136,7 +167,7 @@ void LayoutHandler::makeMeVisible(int pid) for (int i = 0; i < m_visibleApps.size(); ++i) { - mp_dBusWindowManagerProxy->setPidToLayoutArea(i, i); + mp_dBusWindowManagerProxy->setPidToLayoutArea(m_visibleApps.at(i), i); } } if (1 == availableLayouts.size()) @@ -149,7 +180,7 @@ void LayoutHandler::makeMeVisible(int pid) mp_dBusWindowManagerProxy->setLayoutById(availableLayouts.at(0)); for (int i = 0; i < m_visibleApps.size(); ++i) { - mp_dBusWindowManagerProxy->setPidToLayoutArea(i, i); + mp_dBusWindowManagerProxy->setPidToLayoutArea(m_visibleApps.at(i), i); } } if (1 < availableLayouts.size()) @@ -168,6 +199,25 @@ void LayoutHandler::makeMeVisible(int pid) } } +void LayoutHandler::toggleFullscreen() +{ + qDebug("toggleFullscreen"); + int currentLayout = mp_dBusWindowManagerProxy->getLayout(); + int associatedFullScreenLayout = mp_dBusWindowManagerProxy->getAssociatedFullScreenLayout(currentLayout); + if (-1 != associatedFullScreenLayout) + { + mp_dBusWindowManagerProxy->setLayoutById(associatedFullScreenLayout); + for (int i = 0; i < m_visibleApps.size(); ++i) + { + mp_dBusWindowManagerProxy->setPidToLayoutArea(m_visibleApps.at(i), i); + } + } + else + { + qDebug("no associatedFullScreenLayout. Cannot switch to full screen."); + } +} + void LayoutHandler::setLayoutByName(QString layoutName) { // switch to new layout diff --git a/HomeScreen/src/layouthandler.h b/HomeScreen/src/layouthandler.h index cc5b59b..c9ca1bf 100644 --- a/HomeScreen/src/layouthandler.h +++ b/HomeScreen/src/layouthandler.h @@ -18,6 +18,7 @@ signals: public slots: void makeMeVisible(int pid); + void toggleFullscreen(); void setLayoutByName(QString layoutName); private: diff --git a/HomeScreen/src/mainwindow.cpp b/HomeScreen/src/mainwindow.cpp index 31ba8d0..c15cca5 100644 --- a/HomeScreen/src/mainwindow.cpp +++ b/HomeScreen/src/mainwindow.cpp @@ -100,6 +100,7 @@ MainWindow::MainWindow(QWidget *parent) : mp_homeScreenControlInterface = new HomeScreenControlInterface(this); QObject::connect(mp_homeScreenControlInterface, SIGNAL(newRequestsToBeVisibleApp(int)), mp_layoutHandler, SLOT(makeMeVisible(int))); + QObject::connect(mp_homeScreenControlInterface, SIGNAL(newRequestsToggleFullscreen()), mp_layoutHandler, SLOT(toggleFullscreen())); QObject::connect(mp_popupWidget, SIGNAL(comboBoxResult(QString)), mp_layoutHandler, SLOT(setLayoutByName(QString))); } diff --git a/HomeScreenSimulator/resources/mainwindow.ui b/HomeScreenSimulator/resources/mainwindow.ui index 6c6e7d0..dcdf2e7 100644 --- a/HomeScreenSimulator/resources/mainwindow.ui +++ b/HomeScreenSimulator/resources/mainwindow.ui @@ -39,7 +39,7 @@ - 20 + 30 380 211 27 @@ -214,6 +214,24 @@ + + + FullScreen + + + + + 80 + 50 + 161 + 27 + + + + Toggle full screen + + + Future features diff --git a/HomeScreenSimulator/src/mainwindow.cpp b/HomeScreenSimulator/src/mainwindow.cpp index 743c854..272adfc 100644 --- a/HomeScreenSimulator/src/mainwindow.cpp +++ b/HomeScreenSimulator/src/mainwindow.cpp @@ -23,7 +23,8 @@ MainWindow::MainWindow(QWidget *parent) : mp_dBusDayNightModeAdapter(0), mp_dBusStatusBarProxy(0), mp_dBusPopupProxy(0), - mp_dBusProximityProxy(0) + mp_dBusProximityProxy(0), + mp_dBusHomeScreenProxy(0) { mp_ui->setupUi(this); @@ -48,6 +49,11 @@ MainWindow::MainWindow(QWidget *parent) : "/Proximity", QDBusConnection::sessionBus(), 0); + mp_dBusHomeScreenProxy = new org::agl::homescreen("org.agl.homescreen", + "/HomeScreen", + QDBusConnection::sessionBus(), + 0); + QSettings settings; this->move(settings.value("homescreensimulator/pos").toPoint()); mp_ui->radioButton_DayMode->setChecked(settings.value("homescreensimulator/daymode", true).toBool()); // if nothing is stored, use "true" @@ -61,6 +67,7 @@ MainWindow::~MainWindow() settings.setValue("homescreensimulator/daymode", mp_ui->radioButton_DayMode->isChecked()); settings.setValue("homescreensimulator/nightmode", mp_ui->radioButton_NightMode->isChecked()); + delete mp_dBusHomeScreenProxy; delete mp_dBusProximityProxy; delete mp_dBusPopupProxy; delete mp_dBusStatusBarProxy; @@ -170,3 +177,8 @@ void MainWindow::on_checkBox_ObjectDetected_clicked() { mp_dBusProximityProxy->setObjectDetected(Qt::Checked == mp_ui->checkBox_ObjectDetected->checkState()); } + +void MainWindow::on_pushButton_ToggleFullScreen_clicked() +{ + mp_dBusHomeScreenProxy->toggleFullScreen(); +} diff --git a/HomeScreenSimulator/src/mainwindow.h b/HomeScreenSimulator/src/mainwindow.h index 702a338..ca368f0 100644 --- a/HomeScreenSimulator/src/mainwindow.h +++ b/HomeScreenSimulator/src/mainwindow.h @@ -24,6 +24,7 @@ #include "statusbar_proxy.h" #include "popup_proxy.h" #include "proximity_proxy.h" +#include "homescreen_proxy.h" namespace Ui { class MainWindow; @@ -62,12 +63,15 @@ private slots: void on_checkBox_ObjectDetected_clicked(); + void on_pushButton_ToggleFullScreen_clicked(); + private: Ui::MainWindow *mp_ui; DaynightmodeAdaptor *mp_dBusDayNightModeAdapter; org::agl::statusbar *mp_dBusStatusBarProxy; org::agl::popup *mp_dBusPopupProxy; org::agl::proximity *mp_dBusProximityProxy; + org::agl::homescreen *mp_dBusHomeScreenProxy; }; #endif // MAINWINDOW_H diff --git a/WindowManager/src/windowmanager.cpp b/WindowManager/src/windowmanager.cpp index dea17a1..ce59fa0 100644 --- a/WindowManager/src/windowmanager.cpp +++ b/WindowManager/src/windowmanager.cpp @@ -29,6 +29,8 @@ WindowManager::WindowManager(QObject *parent) : QObject(parent), m_layouts(), m_layoutNames(), + m_layoutFullScreen(), + m_layoutFullScreenAssociated(), m_currentLayout(-1), m_homeScreenPid(-1), #ifdef __arm__ @@ -369,18 +371,31 @@ void WindowManager::surfaceCallbackFunction_static(t_ilm_surface surface, } #endif -int WindowManager::addLayout(int layoutId, const QString &layoutName, const QList &surfaceAreas) +int WindowManager::addLayout(int layoutId, const QString &layoutName, bool isFullScreen, int associatedFullScreenLayout, const QList &surfaceAreas) { qDebug("-=[addLayout]=-"); m_layouts.insert(layoutId, surfaceAreas); m_layoutNames.insert(layoutId, layoutName); - qDebug("addLayout %d %s, size %d", layoutId, layoutName.toStdString().c_str(), surfaceAreas.size()); + m_layoutFullScreen.insert(layoutId, isFullScreen); + m_layoutFullScreenAssociated.insert(layoutId, associatedFullScreenLayout); + qDebug("addLayout %d %s %s, %d, size %d", + layoutId, + layoutName.toStdString().c_str(), + isFullScreen ? "true" : "false", + associatedFullScreenLayout, + surfaceAreas.size()); dumpScene(); return true; } +int WindowManager::getAssociatedFullScreenLayout(int layoutId) +{ + qDebug("-=[getAssociatedFullScreenLayout]=-"); + return m_layoutFullScreenAssociated.find(layoutId).value(); +} + QList WindowManager::getAvailableLayouts(int numberOfAppSurfaces) { qDebug("-=[getAvailableLayouts]=-"); @@ -431,6 +446,12 @@ QString WindowManager::getLayoutName(int layoutId) return m_layoutNames.find(layoutId).value(); } +bool WindowManager::isLayoutFullScreen(int layoutId) +{ + qDebug("-=[isLayoutFullScreen]=-"); + return m_layoutFullScreen.find(layoutId).value(); +} + void WindowManager::setLayoutById(int layoutId) { qDebug("-=[setLayoutById]=-"); diff --git a/WindowManager/src/windowmanager.hpp b/WindowManager/src/windowmanager.hpp index 2a76a32..ef19f4e 100644 --- a/WindowManager/src/windowmanager.hpp +++ b/WindowManager/src/windowmanager.hpp @@ -49,6 +49,8 @@ private: WindowmanagerAdaptor *mp_windowManagerAdaptor; QMap > m_layouts; QMap m_layoutNames; + QMap m_layoutFullScreen; + QMap m_layoutFullScreenAssociated; int m_currentLayout; void dumpScene(); int m_homeScreenPid; @@ -95,11 +97,13 @@ public slots: // from windowmanager_adapter.h public Q_SLOTS: // METHODS - int addLayout(int layoutId, const QString &layoutName, const QList &surfaceAreas); + int addLayout(int layoutId, const QString &layoutName, bool isFullScreen, int associatedFullScreenLayout, const QList &surfaceAreas); + int getAssociatedFullScreenLayout(int layoutId); QList getAvailableLayouts(int numberOfAppSurfaces); QList getAvailableSurfaces(); int getLayout(); QString getLayoutName(int layoutId); + bool isLayoutFullScreen(int layoutId); void setLayoutById(int layoutId); void setLayoutByName(const QString &layoutName); void setPidToLayoutArea(int pid, int layoutAreaId); diff --git a/interfaces/homescreen.xml b/interfaces/homescreen.xml index 3eb66d0..1a9d7f9 100644 --- a/interfaces/homescreen.xml +++ b/interfaces/homescreen.xml @@ -17,8 +17,7 @@ - - + diff --git a/interfaces/windowmanager.xml b/interfaces/windowmanager.xml index c86c8e7..5aac541 100644 --- a/interfaces/windowmanager.xml +++ b/interfaces/windowmanager.xml @@ -17,8 +17,10 @@ + + - + @@ -26,6 +28,14 @@ + + + + + + + +