Implement toggle full screen mechanism.
authorBocklage, Jens <Jens_Bocklage@mentor.com>
Wed, 26 Oct 2016 13:53:34 +0000 (15:53 +0200)
committerBocklage, Jens <Jens_Bocklage@mentor.com>
Wed, 26 Oct 2016 13:53:34 +0000 (15:53 +0200)
Signed-off-by: Bocklage, Jens <Jens_Bocklage@mentor.com>
12 files changed:
HomeScreen/src/homescreencontrolinterface.cpp
HomeScreen/src/homescreencontrolinterface.h
HomeScreen/src/layouthandler.cpp
HomeScreen/src/layouthandler.h
HomeScreen/src/mainwindow.cpp
HomeScreenSimulator/resources/mainwindow.ui
HomeScreenSimulator/src/mainwindow.cpp
HomeScreenSimulator/src/mainwindow.h
WindowManager/src/windowmanager.cpp
WindowManager/src/windowmanager.hpp
interfaces/homescreen.xml
interfaces/windowmanager.xml

index 45c3cbd..057e742 100644 (file)
@@ -42,7 +42,8 @@ void HomeScreenControlInterface::hardKeyPressed(int key)
     }
 }
 
-void HomeScreenControlInterface::setToFullscreen(int pid)
+void HomeScreenControlInterface::toggleFullScreen()
 {
-    qDebug("setToFullscreen %d", pid);
+    qDebug("toggleFullScreen");
+    newRequestsToggleFullscreen();
 }
index e406686..e341758 100644 (file)
@@ -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;
index cb21018..81bc106 100644 (file)
@@ -36,6 +36,8 @@ void LayoutHandler::setUpLayouts()
     qDebug("setUpLayouts");
     QList<SimpleRect> 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
index cc5b59b..c9ca1bf 100644 (file)
@@ -18,6 +18,7 @@ signals:
 
 public slots:
     void makeMeVisible(int pid);
+    void toggleFullscreen();
     void setLayoutByName(QString layoutName);
 
 private:
index 31ba8d0..c15cca5 100644 (file)
@@ -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)));
 }
index 6c6e7d0..dcdf2e7 100644 (file)
@@ -39,7 +39,7 @@
      <widget class="QPushButton" name="pushButton_Update">
       <property name="geometry">
        <rect>
-        <x>20</x>
+        <x>30</x>
         <y>380</y>
         <width>211</width>
         <height>27</height>
       </property>
      </widget>
     </widget>
+    <widget class="QWidget" name="tab_FullScreen">
+     <attribute name="title">
+      <string>FullScreen</string>
+     </attribute>
+     <widget class="QPushButton" name="pushButton_ToggleFullScreen">
+      <property name="geometry">
+       <rect>
+        <x>80</x>
+        <y>50</y>
+        <width>161</width>
+        <height>27</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>Toggle full screen</string>
+      </property>
+     </widget>
+    </widget>
     <widget class="QWidget" name="tab_FutureFeatures">
      <attribute name="title">
       <string>Future features</string>
index 743c854..272adfc 100644 (file)
@@ -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();
+}
index 702a338..ca368f0 100644 (file)
@@ -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
index dea17a1..ce59fa0 100644 (file)
@@ -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<SimpleRect> &surfaceAreas)
+int WindowManager::addLayout(int layoutId, const QString &layoutName, bool isFullScreen, int associatedFullScreenLayout, const QList<SimpleRect> &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<int> 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]=-");
index 2a76a32..ef19f4e 100644 (file)
@@ -49,6 +49,8 @@ private:
     WindowmanagerAdaptor *mp_windowManagerAdaptor;
     QMap<int, QList<SimpleRect> > m_layouts;
     QMap<int, QString> m_layoutNames;
+    QMap<int, bool> m_layoutFullScreen;
+    QMap<int, int> 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<SimpleRect> &surfaceAreas);
+    int addLayout(int layoutId, const QString &layoutName, bool isFullScreen, int associatedFullScreenLayout, const QList<SimpleRect> &surfaceAreas);
+    int getAssociatedFullScreenLayout(int layoutId);
     QList<int> getAvailableLayouts(int numberOfAppSurfaces);
     QList<SimplePoint> 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);
index 3eb66d0..1a9d7f9 100644 (file)
@@ -17,8 +17,7 @@
     <method name="hardKeyPressed">
       <arg name="key" type="i" direction="in"/> <!-- using the inputevent.hpp InputEvent::HardKey type -->
     </method>
-    <method name="setToFullscreen">
-      <arg name="pid" type="i" direction="in"/>
+    <method name="toggleFullScreen">
     </method>
   </interface>
 </node>
index c86c8e7..5aac541 100644 (file)
       <method name="addLayout">
         <arg name="layoutId" type="i" direction="in"/>
         <arg name="layoutName" type="s" direction="in"/>
+        <arg name="isFullScreen" type="b" direction="in"/>
+        <arg name="associatedFullScreenLayout" type="i" direction="in"/>
         <arg name="surfaceAreas" type="a(iiii)" direction="in"/>
-        <annotation name="org.qtproject.QtDBus.QtTypeName.In2" value="QList&lt;SimpleRect&gt;"/>
+        <annotation name="org.qtproject.QtDBus.QtTypeName.In4" value="QList&lt;SimpleRect&gt;"/>
         <arg name="error" type="i" direction="out"/>
       </method>
       <method name="getAvailableLayouts">
         <arg name="layoutIds" type="ai" direction="out"/>
         <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QList&lt;int&gt;"/>
       </method>
+      <method name="isLayoutFullScreen">
+        <arg name="layoutId" type="i" direction="in"/>
+        <arg name="fullScreen" type="b" direction="out"/>
+      </method>
+      <method name="getAssociatedFullScreenLayout">
+        <arg name="layoutId" type="i" direction="in"/>
+        <arg name="associatedFullScreenLayout" type="i" direction="out"/>
+      </method>
       <method name="setLayoutById">
         <arg name="layoutId" type="i" direction="in"/>
       </method>