diff options
author | Bocklage, Jens <Jens_Bocklage@mentor.com> | 2016-11-03 20:23:10 +0100 |
---|---|---|
committer | Bocklage, Jens <Jens_Bocklage@mentor.com> | 2016-11-03 20:23:10 +0100 |
commit | ec688535558c31989e7da221b858328b2e0766c8 (patch) | |
tree | 4ca00a485bdb4ecd8aebe87398e324510400b4c0 /libhomescreen | |
parent | 6656309e1ddf27c3e62fe5d599bee2beeddcbff1 (diff) |
New concept of dynamically placing surfaces in static defined layout areas.v0.4.0
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>
Diffstat (limited to 'libhomescreen')
-rw-r--r-- | libhomescreen/include/libhomescreen.hpp | 12 | ||||
-rw-r--r-- | libhomescreen/src/libhomescreen.cpp | 57 |
2 files changed, 65 insertions, 4 deletions
diff --git a/libhomescreen/include/libhomescreen.hpp b/libhomescreen/include/libhomescreen.hpp index f92e190..db6ca2d 100644 --- a/libhomescreen/include/libhomescreen.hpp +++ b/libhomescreen/include/libhomescreen.hpp @@ -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; diff --git a/libhomescreen/src/libhomescreen.cpp b/libhomescreen/src/libhomescreen.cpp index 978a42c..39af1c3 100644 --- a/libhomescreen/src/libhomescreen.cpp +++ b/libhomescreen/src/libhomescreen.cpp @@ -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); } } |