aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/libhomescreen.hpp2
-rw-r--r--sample/simple-egl/src/simple-egl.cpp57
-rw-r--r--sample/template/main.cpp45
-rw-r--r--sample/template/wmhandler.cpp5
-rw-r--r--src/libhomescreen.cpp14
5 files changed, 84 insertions, 39 deletions
diff --git a/include/libhomescreen.hpp b/include/libhomescreen.hpp
index 5720368..9034dc8 100644
--- a/include/libhomescreen.hpp
+++ b/include/libhomescreen.hpp
@@ -38,7 +38,7 @@ public:
LibHomeScreen(const LibHomeScreen &) = delete;
LibHomeScreen &operator=(const LibHomeScreen &) = delete;
- using handler_func = std::function<void(const char*)>;
+ using handler_func = std::function<void(json_object*)>;
enum EventType {
Event_TapShortcut = 1,
diff --git a/sample/simple-egl/src/simple-egl.cpp b/sample/simple-egl/src/simple-egl.cpp
index 173d728..399101f 100644
--- a/sample/simple-egl/src/simple-egl.cpp
+++ b/sample/simple-egl/src/simple-egl.cpp
@@ -572,34 +572,53 @@ 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);
});
@@ -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);
});
@@ -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
diff --git a/sample/template/main.cpp b/sample/template/main.cpp
index 589d314..831df41 100644
--- a/sample/template/main.cpp
+++ b/sample/template/main.cpp
@@ -90,29 +90,47 @@ int main(int argc, char *argv[])
}
// Application should call requestSurface at first
- if (wm->requestSurface(myname.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) {
exit(EXIT_FAILURE);
}
// Set event handlers for each event
- 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));
fprintf(stderr, "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));
fprintf(stderr, "Surface %s got deactivated!\n", label);
});
- wm->set_event_handler(LibWindowmanager::Event_Visible, [](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));
fprintf(stderr, "Surface %s got visible!\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));
fprintf(stderr, "Surface %s got invisible!\n", label);
});
- wm->set_event_handler(LibWindowmanager::Event_SyncDraw, [wm](char const *label) {
- fprintf(stderr, "Surface %s got syncDraw!\n", 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));
+ fprintf(stderr, "Surface %s got syncDraw!\n", label);
// Application should call LibWindowmanager::endDraw() in SyncDraw handler
- wm->endDraw(label);
+ 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));
fprintf(stderr, "Surface %s got flushDraw!\n", label);
});
@@ -127,11 +145,16 @@ int main(int argc, char *argv[])
hs->init(port, token.c_str());
// Set event handler
- hs->set_event_handler(LibHomeScreen::Event_TapShortcut, [wm](const char* appname) {
+ hs->set_event_handler(LibHomeScreen::Event_TapShortcut, [wm](json_object *object) {
+ const char *appname = json_object_get_string(
+ json_object_object_get(object, "application_name"));
if(myname == appname) {
qDebug("Surface %s got tapShortcut\n", appname);
// Application should call LibWindowmanager::endDraw() in TapShortcut handler
- wm->activateSurface(myname.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);
}
});
diff --git a/sample/template/wmhandler.cpp b/sample/template/wmhandler.cpp
index 761915f..83af256 100644
--- a/sample/template/wmhandler.cpp
+++ b/sample/template/wmhandler.cpp
@@ -25,7 +25,10 @@ void WmHandler::init(LibWindowmanager *p_wm, std::string applabel)
}
void WmHandler::slotActivateSurface() {
- mp_wm->activateSurface(m_applabel.c_str());
+ json_object *obj = json_object_new_object();
+ json_object_object_add(obj, wm->kKeyDrawingName, json_object_new_string(m_applabel.c_str()));
+ json_object_object_add(obj, wm->kKeyDrawingArea, json_object_new_string("normal.full"));
+ mp_wm->activateSurface(obj);
}
WmHandler::WmHandler(QObject *parent)
diff --git a/src/libhomescreen.cpp b/src/libhomescreen.cpp
index 42ab8b1..2f3ef44 100644
--- a/src/libhomescreen.cpp
+++ b/src/libhomescreen.cpp
@@ -441,25 +441,15 @@ void LibHomeScreen::on_event(void *closure, const char *event, struct afb_wsj1_m
if (strcasecmp(event_only, LibHomeScreen::event_list[0].c_str()) == 0) {
auto i = this->handlers.find(Event_TapShortcut);
-
- struct json_object *json_application_name = json_object_object_get(json_data, "application_name");
- const char* application_name = json_object_get_string(json_application_name);
-
if ( i != this->handlers.end() ) {
- i->second(application_name);
+ i->second(json_data);
}
}
else if (strcasecmp(event_only, LibHomeScreen::event_list[1].c_str()) == 0) {
-
auto i = this->handlers.find(Event_OnScreenMessage);
-
- struct json_object *json_display_message = json_object_object_get(json_data, "display_message");
- const char* display_message = json_object_get_string(json_display_message);
-
if ( i != this->handlers.end() ) {
- i->second(display_message);
+ i->second(json_data);
}
-
}
json_object_put(ev_contents);