try to use afb_api_event_handler_add
[apps/agl-service-homescreen.git] / src / homescreen.cpp
index c02f62b..7b78c1a 100644 (file)
@@ -537,6 +537,13 @@ static int preinit(afb_api_t api)
    return 0;
 }
 
+const char _wm_screenUpdated[] = "windowmanager/screenUpdated";
+static void callback(void *closure, const char *event, struct json_object *args, afb_api_t api)
+{
+       afb_api_verbose(api, 5, NULL, __LINE__, __FUNCTION__, "the handler received the event %s(%s)",
+               event, json_object_get_string(args));
+}
+
 /**
  * homescreen binding init function
  *
@@ -564,6 +571,10 @@ static int init(afb_api_t api)
         return -1;
     }
 
+    HS_WmProxy wm;
+    wm.subscribe(api, HS_WmProxy::Event_ScreenUpdated);
+    afb_api_event_handler_add(api, _wm_screenUpdated, callback, nullptr);
+
     return g_hs_instance->init(api);
 }