summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcus Fritzsch <marcus_fritzsch@mentor.com>2017-07-07 14:32:25 +0200
committerMarcus Fritzsch <marcus_fritzsch@mentor.com>2017-08-08 17:24:00 +0200
commit8c587d6defaf73c1ddbe50d88f6fdd7360b63507 (patch)
tree1345568a84d706ecd4d6b2c3a3dbd52f534270ea
parent8ff4c8754c52caffbb059ba6bbf4a727c949a7b6 (diff)
main: imeplemented dummy register_surface with reply
Signed-off-by: Marcus Fritzsch <marcus_fritzsch@mentor.com>
-rw-r--r--src/main.cpp39
1 files changed, 38 insertions, 1 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 4adf2f8..ba0ff4e 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -227,6 +227,41 @@ void debug_layers(afb_req req) {
afb_req_success(req, to_json(g_wayland->controller->layers), "layers");
}
+// Dummy register_surface implementation
+void register_surface(afb_req req) {
+ AFB_DEBUG("register_surface");
+
+ auto jo = afb_req_json(req);
+ json_object *jappid;
+ if (! json_object_object_get_ex(jo, "appid", &jappid)) {
+ afb_req_fail(req, "failed", "register_surface needs 'appid' integer argument");
+ return;
+ }
+
+ json_object *jsurfid;
+ if (! json_object_object_get_ex(jo, "surfaceid", &jsurfid)) {
+ afb_req_fail(req, "failed", "register_surface needs 'surfaceid' integer argument");
+ return;
+ }
+
+ int32_t appid = json_object_get_int(jappid);
+ int32_t surfid = json_object_get_int(jsurfid);
+
+ if (appid < 0 || appid > 0xff) {
+ afb_req_fail(req, "failed", "invalid appid");
+ return;
+ }
+
+ if (surfid < 0 || surfid > 0xffff) {
+ afb_req_fail(req, "failed", "invalid surfaceid");
+ return;
+ }
+
+ lognotice("register_surface, got appid %d and surfaceid %d", appid, surfid);
+
+ afb_req_success(req, json_object_new_int((appid << 16) + surfid), "success");
+}
+
#define WRAP(F) \
[](afb_req req) noexcept { \
if (g_wayland == nullptr) { \
@@ -245,7 +280,9 @@ const struct afb_verb_v2 verbs[] = {
{"debug::status", WRAP(debug_status), NULL, NULL, AFB_SESSION_NONE_V2},
{"debug::layers", WRAP(debug_layers), NULL, NULL, AFB_SESSION_NONE_V2},
{"debug::surfaces", WRAP(debug_surfaces), NULL, NULL, AFB_SESSION_NONE_V2},
- {},
+
+ {"register_surface", WRAP(register_surface), NULL, NULL, AFB_SESSION_NONE_V2},
+ {}
};
} // namespace