diff options
Diffstat (limited to 'src/libwindowmanager.cpp')
-rw-r--r-- | src/libwindowmanager.cpp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/libwindowmanager.cpp b/src/libwindowmanager.cpp index 4a9b951..18cde43 100644 --- a/src/libwindowmanager.cpp +++ b/src/libwindowmanager.cpp @@ -67,6 +67,7 @@ class LibWindowmanager::Impl { // WM API int requestSurface(json_object *object); + int requestSurfaceXDG(json_object *object); int activateSurface(json_object *object); int deactivateSurface(json_object *object); int endDraw(json_object *object); @@ -291,6 +292,52 @@ int LibWindowmanager::Impl::requestSurface(json_object *object) { return rc; } +int LibWindowmanager::Impl::requestSurfaceXDG(json_object *object) { + TRACE(); + HMI_DEBUG("libwm", "called"); + + json_object *val; + const char *tmp_label; + if (json_object_object_get_ex(object, this->kKeyDrawingName, &val)) { + tmp_label = json_object_get_string(val); + } + else { + HMI_DEBUG("libwm", "Not found key \"%s\"", this->kKeyDrawingName); + return -EINVAL; + } + + // DrawingName in "object" is overwrited in api_call("RequestSurface") + // So it is neccesary to copy it. + const char *label = std::string(tmp_label).c_str(); + + if (this->labels.find(label) != this->labels.end()) { + HMI_ERROR("libwm", "Surface label already known!"); + return -EINVAL; + } + + // Store application name first + // because it may not return from setenv + HMI_DEBUG("libwm", "Insert application name: %s\n", label); + this->labels.insert(this->labels.end(), label); + + /* send the request */ + int rc = this->api_call("RequestSurfaceXDG", object, [](bool ok, json_object *j) { + if (!ok) { + HMI_ERROR("libwm", "Could not get surface ID from WM: %s", + j != nullptr ? json_object_to_json_string_ext( + j, JSON_C_TO_STRING_PRETTY) + : "no-info"); + } + }); + + if (rc != 0) { + HMI_ERROR("libwm", "Erase application name: %s", label); + this->labels.erase(label); + } + + return rc; +} + int LibWindowmanager::Impl::activateSurface(json_object *object) { TRACE(); HMI_DEBUG("libwm", "called"); @@ -513,6 +560,10 @@ int LibWindowmanager::requestSurface(json_object *object) { return this->d->requestSurface(object); } +int LibWindowmanager::requestSurfaceXDG(json_object *object) { + return this->d->requestSurfaceXDG(object); +} + int LibWindowmanager::activateSurface(json_object *object) { return this->d->activateSurface(object); } |