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
*
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);
}
#include "hs-proxy.h"
const char _afm_main[] = "afm-main";
+const char _windowmanager[] = "windowmanager";
+const char _event[] = "event";
/**
{
struct json_object *args = json_object_new_string(id.c_str());
api_call(request->api, _afm_main, __FUNCTION__, args);
+}
+
+/**
+ * subscribe windowmanager event
+ *
+ * #### Parameters
+ * - api : the api serving the request
+ * - event : windowmanager event
+ *
+ * #### Return
+ * None
+ *
+ */
+void HS_WmProxy::subscribe(afb_api_t api, EventType event)
+{
+ struct json_object* push_obj = json_object_new_object();
+ json_object_object_add(push_obj, _event, json_object_new_int(event));
+ api_call(api, _windowmanager, "wm_subscribe", push_obj);
}
\ No newline at end of file
void start(afb_req_t request, const std::string &id);
};
+class HS_WmProxy {
+public:
+ HS_WmProxy() = default;
+ ~HS_WmProxy() = default;
+
+ enum EventType
+ {
+ Event_Val_Min = 0,
+
+ Event_Active = Event_Val_Min,
+ Event_Inactive,
+
+ Event_Visible,
+ Event_Invisible,
+
+ Event_SyncDraw,
+ Event_FlushDraw,
+
+ Event_ScreenUpdated,
+
+ Event_Error,
+
+ Event_Val_Max = Event_Error,
+ };
+
+ // asynchronous call, reply in callback function
+ void subscribe(afb_api_t api, EventType event);
+};
+
#endif // HOMESCREEN_PROXY_H
\ No newline at end of file