New concept of dynamically placing surfaces in static defined layout areas. v0.4.0
authorBocklage, Jens <Jens_Bocklage@mentor.com>
Thu, 3 Nov 2016 19:23:10 +0000 (20:23 +0100)
committerBocklage, Jens <Jens_Bocklage@mentor.com>
Thu, 3 Nov 2016 19:23:10 +0000 (20:23 +0100)
This is useful if an application wants to render more than one surface.
By default, one surface is placed in one layout render area. With the new homescreen.xml
introspection, apps can place their surfaces as they wish (limited to the boundries
of the assigned layou render area!).

The functionality is not fully implemented, but the shared lib already provides the interface.

Signed-off-by: Bocklage, Jens <Jens_Bocklage@mentor.com>
20 files changed:
HomeScreen/src/homescreencontrolinterface.cpp
HomeScreen/src/homescreencontrolinterface.h
HomeScreen/src/layouthandler.cpp
HomeScreen/src/layouthandler.h
HomeScreen/src/main.cpp
HomeScreen/src/mainwindow.cpp
HomeScreenAppFrameworkBinderTizen/src/main.cpp
HomeScreenSimulator/resources/mainwindow.ui
HomeScreenSimulator/src/main.cpp
HomeScreenSimulator/src/mainwindow.cpp
HomeScreenSimulator/src/mainwindow.h
InputEventManager/src/main.cpp
SampleAppTimeDate/src/main.cpp
SampleHomeScreenInterfaceApp/src/main.cpp
SampleHomeScreenInterfaceApp/src/sampleclass.cpp
SampleHomeScreenInterfaceApp/src/sampleclass.hpp
WindowManager/src/main.cpp
interfaces/homescreen.xml
libhomescreen/include/libhomescreen.hpp
libhomescreen/src/libhomescreen.cpp

index 057e742..bc66e53 100644 (file)
@@ -24,6 +24,12 @@ HomeScreenControlInterface::~HomeScreenControlInterface()
     delete mp_homeScreenAdaptor;
 }
 
+QRect HomeScreenControlInterface::getLayoutRenderAreaForSurfaceId(int surfaceId)
+{
+    qDebug("getLayoutRenderAreaForSurfaceId %d", surfaceId);
+    return newRequestGetLayoutRenderAreaForSurfaceId(surfaceId);
+}
+
 void HomeScreenControlInterface::hardKeyPressed(int key)
 {
     int pid = -1;
@@ -42,8 +48,14 @@ void HomeScreenControlInterface::hardKeyPressed(int key)
     }
 }
 
-void HomeScreenControlInterface::toggleFullScreen()
+void HomeScreenControlInterface::renderSurfaceToArea(int surfaceId, const QRect &renderArea)
+{
+    qDebug("requestSurfaceIdToFullScreen %d", surfaceId);
+    newRequestRenderSurfaceToArea(surfaceId, renderArea);
+}
+
+void HomeScreenControlInterface::requestSurfaceIdToFullScreen(int surfaceId)
 {
-    qDebug("toggleFullScreen");
-    newRequestsToggleFullscreen();
+    qDebug("requestSurfaceIdToFullScreen %d", surfaceId);
+    newRequestSurfaceIdToFullScreen(surfaceId);
 }
index e341758..3203088 100644 (file)
@@ -14,16 +14,19 @@ public:
     explicit HomeScreenControlInterface(QObject *parent = 0);
     ~HomeScreenControlInterface();
 
-signals:
-
 signals:
     void newRequestsToBeVisibleApp(int pid);
-    void newRequestsToggleFullscreen();
+
+    QRect newRequestGetLayoutRenderAreaForSurfaceId(int surfaceId);
+    void newRequestRenderSurfaceToArea(int surfaceId, const QRect &renderArea);
+    void newRequestSurfaceIdToFullScreen(int surfaceId);
 
 //from homescreen_adapter.h
 public Q_SLOTS: // METHODS
+    QRect getLayoutRenderAreaForSurfaceId(int surfaceId);
     void hardKeyPressed(int key);
-    void toggleFullScreen();
+    void renderSurfaceToArea(int surfaceId, const QRect &renderArea);
+    void requestSurfaceIdToFullScreen(int surfaceId);
 
 private:
     HomescreenAdaptor *mp_homeScreenAdaptor;
index 3bfe533..0dac24f 100644 (file)
@@ -169,9 +169,14 @@ void LayoutHandler::makeMeVisible(int surfaceId)
     }
 }
 
-void LayoutHandler::toggleFullscreen()
+void LayoutHandler::requestRenderSurfaceToArea(int surfaceId, const QRect &renderArea)
 {
-    qDebug("toggleFullscreen");
+    qDebug("requestRenderSurfaceToArea %d %d,%d,%d,%d", surfaceId, renderArea.x(), renderArea.y(), renderArea.width(), renderArea.height());
+}
+
+void LayoutHandler::requestSurfaceIdToFullScreen(int surfaceId)
+{
+    qDebug("requestSurfaceIdToFullScreen %d", surfaceId);
 }
 
 void LayoutHandler::setLayoutByName(QString layoutName)
index 5763d44..ee400b7 100644 (file)
@@ -18,7 +18,9 @@ signals:
 
 public slots:
     void makeMeVisible(int surfaceId);
-    void toggleFullscreen();
+
+    void requestRenderSurfaceToArea(int surfaceId, const QRect &renderArea);
+    void requestSurfaceIdToFullScreen(int surfaceId);
     void setLayoutByName(QString layoutName);
 
 private:
index a623fff..f1f5a22 100644 (file)
@@ -36,7 +36,7 @@ int main(int argc, char *argv[])
     QCoreApplication::setOrganizationDomain("LinuxFoundation");
     QCoreApplication::setOrganizationName("AutomotiveGradeLinux");
     QCoreApplication::setApplicationName("HomeScreen");
-    QCoreApplication::setApplicationVersion("0.3.4");
+    QCoreApplication::setApplicationVersion("0.4.0");
 
     qDebug("%s, v%s", QCoreApplication::applicationName().toStdString().c_str(), QCoreApplication::applicationVersion().toStdString().c_str());
 
index c15cca5..f8dfe89 100644 (file)
@@ -89,6 +89,7 @@ MainWindow::MainWindow(QWidget *parent) :
 
     QObject::connect(mp_applauncherwidget, SIGNAL(newRequestsToBeVisibleApp(int)), mp_layoutHandler, SLOT(makeMeVisible(int)));
 
+
     // apply color scheme
     updateColorScheme();
 
@@ -100,7 +101,9 @@ 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_homeScreenControlInterface, SIGNAL(newRequestSurfaceIdToFullScreen(int)), mp_layoutHandler, SLOT(requestSurfaceIdToFullScreen(int)));
+    QObject::connect(mp_homeScreenControlInterface, SIGNAL(newRequestRenderSurfaceToArea(int, QRect)), mp_layoutHandler, SLOT(requestRenderSurfaceToArea(int,QRect)));
+    QObject::connect(mp_homeScreenControlInterface, SIGNAL(newRequestSurfaceIdToFullScreen(int)), mp_layoutHandler, SLOT(requestSurfaceIdToFullScreen(int)));
 
     QObject::connect(mp_popupWidget, SIGNAL(comboBoxResult(QString)), mp_layoutHandler, SLOT(setLayoutByName(QString)));
 }
index f1e1af1..8a3c11c 100644 (file)
@@ -27,7 +27,7 @@ int main(int argc, char *argv[])
     QCoreApplication::setOrganizationDomain("LinuxFoundation");
     QCoreApplication::setOrganizationName("AutomotiveGradeLinux");
     QCoreApplication::setApplicationName("HomeScreenAppFrameworkBinderTizen");
-    QCoreApplication::setApplicationVersion("0.3.0");
+    QCoreApplication::setApplicationVersion("0.4.0");
 
     qDebug("%s, v%s", QCoreApplication::applicationName().toStdString().c_str(), QCoreApplication::applicationVersion().toStdString().c_str());
 
index dcdf2e7..4f7ccf8 100644 (file)
       </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 c4d794c..101eedc 100644 (file)
@@ -36,7 +36,7 @@ int main(int argc, char *argv[])
     QCoreApplication::setOrganizationDomain("LinuxFoundation");
     QCoreApplication::setOrganizationName("AutomotiveGradeLinux");
     QCoreApplication::setApplicationName("HomeScreenSimulator");
-    QCoreApplication::setApplicationVersion("0.3.1");
+    QCoreApplication::setApplicationVersion("0.4.0");
 
     qDebug("%s, v%s", QCoreApplication::applicationName().toStdString().c_str(), QCoreApplication::applicationVersion().toStdString().c_str());
 
index 272adfc..6c0dc2f 100644 (file)
@@ -177,8 +177,3 @@ 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 ca368f0..3b1855c 100644 (file)
@@ -63,8 +63,6 @@ private slots:
 
     void on_checkBox_ObjectDetected_clicked();
 
-    void on_pushButton_ToggleFullScreen_clicked();
-
 private:
     Ui::MainWindow *mp_ui;
     DaynightmodeAdaptor *mp_dBusDayNightModeAdapter;
index 03270db..b609693 100644 (file)
@@ -25,7 +25,7 @@ int main(int argc, char *argv[])
     QCoreApplication::setOrganizationDomain("LinuxFoundation");
     QCoreApplication::setOrganizationName("AutomotiveGradeLinux");
     QCoreApplication::setApplicationName("InputEventManager");
-    QCoreApplication::setApplicationVersion("0.3.0");
+    QCoreApplication::setApplicationVersion("0.4.0");
 
     qDebug("%s, v%s", QCoreApplication::applicationName().toStdString().c_str(), QCoreApplication::applicationVersion().toStdString().c_str());
 
index 7cd51c0..cb23e80 100644 (file)
@@ -9,7 +9,7 @@ int main(int argc, char *argv[])
     QCoreApplication::setOrganizationDomain("LinuxFoundation");
     QCoreApplication::setOrganizationName("AutomotiveGradeLinux");
     QCoreApplication::setApplicationName("SampleAppTimeDate");
-    QCoreApplication::setApplicationVersion("0.3.0");
+    QCoreApplication::setApplicationVersion("0.4.0");
 
     qDebug("%s, v%s", QCoreApplication::applicationName().toStdString().c_str(), QCoreApplication::applicationVersion().toStdString().c_str());
 
index 1e83d80..b9b3efa 100644 (file)
@@ -6,13 +6,25 @@ using namespace std;
 int main()
 {
     cout << "SampleHomeScreenInterfaceApp" << endl;
+    cout << "v0.4.0" << endl;
 
     SampleClass *sampleClass = new SampleClass();
 
+    //sRectangle test = sampleClass->getLayoutRenderAreaForSurfaceId(1);
+
     sampleClass->hardKeyPressed(100);
     sampleClass->hardKeyPressed(101);
     sampleClass->hardKeyPressed(102);
 
+    /*sRectangle renderArea;
+    renderArea.x = 0;
+    renderArea.y = 1;
+    renderArea.width = 12;
+    renderArea.height = 13;
+    sampleClass->renderSurfaceToArea(1, renderArea);*/
+
+    //sampleClass->requestSurfaceIdToFullScreen(1);
+
     delete sampleClass;
 
     return 0;
index 0d373d1..6a46f2b 100644 (file)
@@ -11,12 +11,23 @@ SampleClass::~SampleClass()
     delete mp_libHomeScreen;
 }
 
+
+sRectangle SampleClass::getLayoutRenderAreaForSurfaceId(int surfaceId)
+{
+    mp_libHomeScreen->getLayoutRenderAreaForSurfaceId(surfaceId);
+}
+
 void SampleClass::hardKeyPressed(int key)
 {
     mp_libHomeScreen->hardKeyPressed(key);
 }
 
-void SampleClass::toggleFullScreen()
+void SampleClass::renderSurfaceToArea(int surfaceId, const sRectangle &renderArea)
+{
+    mp_libHomeScreen->renderSurfaceToArea(surfaceId, renderArea);
+}
+
+void SampleClass::requestSurfaceIdToFullScreen(int surfaceId)
 {
-    mp_libHomeScreen->toggleFullScreen();
+    mp_libHomeScreen->requestSurfaceIdToFullScreen(surfaceId);
 }
index aa5f376..acffcf6 100644 (file)
@@ -9,8 +9,10 @@ public:
     SampleClass();
     ~SampleClass();
 
+    sRectangle getLayoutRenderAreaForSurfaceId(int surfaceId);
     void hardKeyPressed(int key);
-    void toggleFullScreen();
+    void renderSurfaceToArea(int surfaceId, const sRectangle &renderArea);
+    void requestSurfaceIdToFullScreen(int surfaceId);
 
 private:
     LibHomeScreen *mp_libHomeScreen;
index 455361c..c0d6d69 100644 (file)
@@ -25,7 +25,7 @@ int main(int argc, char *argv[])
     QCoreApplication::setOrganizationDomain("LinuxFoundation");
     QCoreApplication::setOrganizationName("AutomotiveGradeLinux");
     QCoreApplication::setApplicationName("WindowManager");
-    QCoreApplication::setApplicationVersion("0.3.1");
+    QCoreApplication::setApplicationVersion("0.4.0");
 
     qDebug("%s, v%s", QCoreApplication::applicationName().toStdString().c_str(), QCoreApplication::applicationVersion().toStdString().c_str());
 
index a405555..b317306 100644 (file)
     <method name="hardKeyPressed">
       <arg name="key" type="i" direction="in"/>
     </method>
-    <method name="toggleFullScreen">
+  <!--
+    requestSurfaceIdToFullScreen:
+    @surfaceId: The surface that request to be shown fullscreen.
+
+    This allows an application to set a surface to full screen.
+  -->
+    <method name="requestSurfaceIdToFullScreen">
+      <arg name="surfaceId" type="i" direction="in"/>
+    </method>
+  <!--
+    getLayoutRenderAreaForSurfaceId:
+    @surfaceId: The surface that is requested.
+    @renderArea: The layout render area in which the given surface is located.
+
+    Before an application uses renderSurfaceToArea to render a surface into an area inside a layout area,
+    this method should be used to get the dimension of the layout area, in which the surface
+    currently is positioned.
+  -->
+    <method name="getLayoutRenderAreaForSurfaceId">
+      <arg name="surfaceId" type="i" direction="in"/>
+      <arg name="renderArea" type="(iiii)" direction="out"/>
+      <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QRect"/>
+    </method>
+  <!--
+    renderSurfaceToArea:
+    @surfaceId: The surface that is requested.
+    @renderArea: The render area inside the current layout area.
+
+    This is a special case. In the normal use case, one layout area is always filled completely
+    with one surface. By using this function, an app can request to position a surface in the
+    layout area.
+    Example:
+    If the layout area is 500x500 pixel in size, the normal use case qould be, that a surface
+    is positioned at x=0, y=0 with a width and a size of 500. With this function, an application can position surfaces
+    free in this area.
+    E.g.: Position surface 101 at x=10, y=30, width=300, height=100 and 
+    surface 104 at x=100, y=130, width=30, height=10
+  -->
+    <method name="renderSurfaceToArea">
+      <arg name="surfaceId" type="i" direction="in"/>
+      <arg name="renderArea" type="(iiii)" direction="in"/>
+      <annotation name="org.qtproject.QtDBus.QtTypeName.In1" value="QRect"/>
     </method>
   </interface>
 </node>
index f92e190..db6ca2d 100644 (file)
@@ -5,6 +5,14 @@
 struct _LibHomeScreenHomescreen;
 typedef struct _LibHomeScreenHomescreen LibHomeScreenHomescreen;
 
+typedef struct
+{
+    int x;
+    int y;
+    int width;
+    int height;
+} sRectangle;
+
 class LibHomeScreen
 {
 public:
@@ -12,8 +20,10 @@ public:
     ~LibHomeScreen();
 
     // these are representing the D-Bus methods:
+    sRectangle getLayoutRenderAreaForSurfaceId(int surfaceId);
     void hardKeyPressed(int key);
-    void toggleFullScreen();
+    void renderSurfaceToArea(int surfaceId, const sRectangle &renderArea);
+    void requestSurfaceIdToFullScreen(int surfaceId);
 
 private:
     LibHomeScreenHomescreen *mp_libHomeScreenHomescreen_Proxy;
index 978a42c..39af1c3 100644 (file)
@@ -1,4 +1,6 @@
+extern "C" {
 #include "homescreen.h" // generated from xml
+}
 #include "include/libhomescreen.hpp"
 
 #include <stdio.h>
@@ -27,6 +29,30 @@ LibHomeScreen::~LibHomeScreen()
     g_object_unref(mp_libHomeScreenHomescreen_Proxy);
 }
 
+sRectangle LibHomeScreen::getLayoutRenderAreaForSurfaceId(int surfaceId)
+{
+    sRectangle result;
+    GError *err = NULL;
+
+    GVariant *out_renderArea;
+
+    lib_home_screen_homescreen_call_get_layout_render_area_for_surface_id_sync(
+                mp_libHomeScreenHomescreen_Proxy,
+                surfaceId,
+                &out_renderArea,
+                NULL,
+                &err);
+
+    if (NULL != err)
+    {
+        fprintf(stderr, "Unable to call getLayoutRenderAreaForSurfaceId: %s\n", err->message);
+    }
+
+    g_variant_get(out_renderArea, "(iiii)", result.x, result.y, result.width, result.height);
+
+    return result;
+}
+
 void LibHomeScreen::hardKeyPressed(int key)
 {
     GError *err = NULL;
@@ -43,17 +69,42 @@ void LibHomeScreen::hardKeyPressed(int key)
     }
 }
 
-void LibHomeScreen::toggleFullScreen()
+void LibHomeScreen::renderSurfaceToArea(int surfaceId, const sRectangle &renderArea)
+{
+    GError *err = NULL;
+
+    GVariant *variant;
+    GVariantBuilder *builder;
+    builder = g_variant_builder_new(G_VARIANT_TYPE("(iiii)"));
+    g_variant_builder_add(builder, "(iiii)", renderArea.x, renderArea.y, renderArea.width, renderArea.height);
+    variant = g_variant_new("(iiii)", builder);
+    g_variant_builder_unref(builder);
+
+    lib_home_screen_homescreen_call_render_surface_to_area_sync(
+                mp_libHomeScreenHomescreen_Proxy,
+                surfaceId,
+                variant,
+                NULL,
+                &err);
+
+    if (NULL != err)
+    {
+        fprintf(stderr, "Unable to call renderSurfaceToArea: %s\n", err->message);
+    }
+}
+
+void LibHomeScreen::requestSurfaceIdToFullScreen(int surfaceId)
 {
     GError *err = NULL;
 
-    lib_home_screen_homescreen_call_toggle_full_screen_sync(
+    lib_home_screen_homescreen_call_request_surface_id_to_full_screen_sync(
                 mp_libHomeScreenHomescreen_Proxy,
+                surfaceId,
                 NULL,
                 &err);
 
     if (NULL != err)
     {
-        fprintf(stderr, "Unable to call toggleFullScreen: %s\n", err->message);
+        fprintf(stderr, "Unable to call requestSurfaceIdToFullScreen: %s\n", err->message);
     }
 }