aboutsummaryrefslogtreecommitdiffstats
path: root/sample/simple-egl
diff options
context:
space:
mode:
authorzheng_wenlong <wenlong_zheng@nexty-ele.com>2017-10-23 14:46:17 +0900
committerZheng Wenlong <wenlong_zheng@nexty-ele.com>2017-10-30 04:26:09 +0000
commiteabd10ffe2f9cb5c31262ad3152b037eb2286857 (patch)
treef8885ee5a8990a9fe9bdc88d03c96e48989f06dd /sample/simple-egl
parent06a2777ce769346ba85aee9f38ccb237a2d72915 (diff)
Modify function argument from char to json
Change libhomescreen event api from char to json. Also modify samples who use this. BUG-AGL: SPEC-992 Change-Id: Id3986d413f9494019f6b175488dd73de226ba020 Signed-off-by: zheng_wenlong <wenlong_zheng@nexty-ele.com>
Diffstat (limited to 'sample/simple-egl')
-rw-r--r--sample/simple-egl/src/simple-egl.cpp65
1 files changed, 47 insertions, 18 deletions
diff --git a/sample/simple-egl/src/simple-egl.cpp b/sample/simple-egl/src/simple-egl.cpp
index 4494ac8..cfa349c 100644
--- a/sample/simple-egl/src/simple-egl.cpp
+++ b/sample/simple-egl/src/simple-egl.cpp
@@ -572,42 +572,61 @@ init_wm(LibWindowmanager *wm)
return -1;
}
- if (wm->requestSurface(app_name.c_str()) != 0) {
+ json_object *obj = json_object_new_object();
+ json_object_object_add(obj, wm->kKeyDrawingName, json_object_new_string(app_name.c_str()));
+ if (wm->requestSurface(obj) != 0) {
debug_out("************** [SIMPLE EGL] [WM SIMPLE >>>>] wm request surface failed \n");
return -1;
}
- wm->set_event_handler(LibWindowmanager::Event_Active, [](char const *label) {
+ wm->set_event_handler(LibWindowmanager::Event_Active, [wm](json_object *object) {
+ const char *label = json_object_get_string(
+ json_object_object_get(object, wm->kKeyDrawingName));
debug_out("************** [SIMPLE EGL] [WM SIMPLE >>>>] Surface %s got activated! \n", label);
});
- wm->set_event_handler(LibWindowmanager::Event_Inactive, [](char const *label) {
+ wm->set_event_handler(LibWindowmanager::Event_Inactive, [wm](json_object *object) {
+ const char *label = json_object_get_string(
+ json_object_object_get(object, wm->kKeyDrawingName));
debug_out("************** [SIMPLE EGL] [WM SIMPLE >>>>] Surface %s got inactivated!\n", label);
});
- wm->set_event_handler(LibWindowmanager::Event_Visible, [wm](char const *label) {
+ wm->set_event_handler(LibWindowmanager::Event_Visible, [wm](json_object *object) {
+ const char *label = json_object_get_string(
+ json_object_object_get(object, wm->kKeyDrawingName));
debug_out("************** [SIMPLE EGL] [WM SIMPLE >>>>] Surface %s got visibled!\n", label);
});
- wm->set_event_handler(LibWindowmanager::Event_Invisible, [](char const *label) {
+ wm->set_event_handler(LibWindowmanager::Event_Invisible, [wm](json_object *object) {
+ const char *label = json_object_get_string(
+ json_object_object_get(object, wm->kKeyDrawingName));
debug_out("************** [SIMPLE EGL] [WM SIMPLE >>>>] Surface %s got invisibled!\n", label);
});
- wm->set_event_handler(LibWindowmanager::Event_SyncDraw, [wm](char const *label) {
+ wm->set_event_handler(LibWindowmanager::Event_SyncDraw, [wm](json_object *object) {
+ const char *label = json_object_get_string(
+ json_object_object_get(object, wm->kKeyDrawingName));
+ const char *area = json_object_get_string(
+ json_object_object_get(object, wm->kKeyDrawingArea));
debug_out("************** [SIMPLE EGL] [WM SIMPLE >>>>] Surface %s got syncdraw!\n", label);
debug_out("************** [SIMPLE EGL] [WM SIMPLE >>>>] try to endDraw %s \n", app_name.c_str());
- wm->endDraw(app_name.c_str());
- });
+ json_object *obj = json_object_new_object();
+ json_object_object_add(obj, wm->kKeyDrawingName, json_object_new_string(app_name.c_str()));
+
+ wm->endDraw(obj);
+ });
- wm->set_event_handler(LibWindowmanager::Event_FlushDraw, [](char const *label) {
+ wm->set_event_handler(LibWindowmanager::Event_FlushDraw, [wm](json_object *object) {
+ const char *label = json_object_get_string(
+ json_object_object_get(object, wm->kKeyDrawingName));
debug_out("************** [SIMPLE EGL] [WM SIMPLE >>>>] Surface %s got flushdraw! \n", label);
});
do
{
surfaceIdStr = getenv("QT_IVI_SURFACE_ID");
- } while (surfaceIdStr == NULL);
-
+ } while (surfaceIdStr == NULL);
+
g_id_ivisurf = atoi(surfaceIdStr);
debug_out("************** [SIMPLE EGL] [WM SIMPLE >>>>] IVI_SURFACE_ID: %d \n", g_id_ivisurf);
@@ -622,16 +641,23 @@ init_hs(LibHomeScreen* hs){
return -1;
}
- hs->set_event_handler(LibHomeScreen::Event_TapShortcut, [](const char* application_name){
+ hs->set_event_handler(LibHomeScreen::Event_TapShortcut, [](json_object *object){
+ const char *application_name = json_object_get_string(
+ json_object_object_get(object, "application_name"));
debug_out("************** [SIMPLE EGL] [HS SIMPLE >>>>] Event_TapShortcut application_name = %s \n", application_name);
if(strcmp(application_name, app_name.c_str()) == 0)
{
debug_out("************** [SIMPLE EGL] [HS SIMPLE] try to activesurface %s \n", app_name.c_str());
- wm->activateSurface(app_name.c_str());
+ json_object *obj = json_object_new_object();
+ json_object_object_add(obj, wm->kKeyDrawingName, json_object_new_string(app_name.c_str()));
+ json_object_object_add(obj, wm->kKeyDrawingArea, json_object_new_string("normal.full"));
+ wm->activateSurface(obj);
}
});
- hs->set_event_handler(LibHomeScreen::Event_OnScreenMessage, [](const char* display_message){
+ hs->set_event_handler(LibHomeScreen::Event_OnScreenMessage, [](json_object *object){
+ const char *display_message = json_object_get_string(
+ json_object_object_get(object, "display_message"));
debug_out("************** [SIMPLE EGL] [HS SIMPLE >>>>] Event_OnScreenMessage display_message = %s \n", display_message);
});
@@ -642,7 +668,7 @@ int
main(int argc, char **argv)
{
struct sigaction sigint;
- struct window window = { 0 };
+ struct window window = { 0 };
struct display display = { 0 };
if(getenv("ENABLE_DEMO_DEBUG"))
@@ -706,7 +732,7 @@ main(int argc, char **argv)
create_surface(&window);
init_gl(&window);
-
+
//Ctrl+C
sigint.sa_handler = signal_int;
sigemptyset(&sigint.sa_mask);
@@ -714,8 +740,11 @@ main(int argc, char **argv)
sigaction(SIGINT, &sigint, NULL);
eglSwapBuffers(display.egl.dpy, window.egl_surface);
- wm->activateSurface(app_name.c_str());
-
+ json_object *obj = json_object_new_object();
+ json_object_object_add(obj, wm->kKeyDrawingName, json_object_new_string(app_name.c_str()));
+ json_object_object_add(obj, wm->kKeyDrawingArea, json_object_new_string("normal.full"));
+ wm->activateSurface(obj);
+
/* The mainloop here is a little subtle. Redrawing will cause
* EGL to read events so we can just call
* wl_display_dispatch_pending() to handle any events that got