aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/app.cpp23
-rw-r--r--src/app.hpp6
-rw-r--r--src/main.cpp12
3 files changed, 39 insertions, 2 deletions
diff --git a/src/app.cpp b/src/app.cpp
index 76668cc..53a1a86 100644
--- a/src/app.cpp
+++ b/src/app.cpp
@@ -352,7 +352,6 @@ char const *App::activate_surface(uint32_t surface_id) {
/// // XXX: I am not sure I even need 5 elements...
/// this->last_active.resize(std::min(int(this->last_active.size()), 5));
-
// no error
return nullptr;
}
@@ -441,6 +440,22 @@ void App::surface_removed(uint32_t surface_id) {
});
}
+void App::emit_activated(char const *label) {
+ this->api.send_event("activated", json_object_new_string(label));
+}
+
+void App::emit_deactivated(char const *label) {
+ this->api.send_event("deactivated", json_object_new_string(label));
+}
+
+void App::emit_syncdraw(char const *label) {
+ this->api.send_event("syncdraw", json_object_new_string(label));
+}
+
+void App::emit_visible(char const *label, bool is_visible) {
+ this->api.send_event(is_visible ? "visible" : "invisible", json_object_new_string(label));
+}
+
result<int> App::request_surface(char const *drawing_name) {
auto lid = this->layers.get_layer_id(std::string(drawing_name));
if (!lid) {
@@ -475,7 +490,11 @@ char const *App::activate_surface(char const *drawing_name) {
if (osid) {
logdebug("ativate surface with name %s and id %u", drawing_name,
osid.value());
- return this->activate_surface(osid.value());
+ auto ret = this->activate_surface(osid.value());
+ if (!ret) {
+ this->emit_activated(drawing_name);
+ }
+ return ret;
}
logerror("surface %s unknown", drawing_name);
diff --git a/src/app.hpp b/src/app.hpp
index ac2eca6..da614a0 100644
--- a/src/app.hpp
+++ b/src/app.hpp
@@ -155,6 +155,12 @@ struct App {
// Events from the compositor we are interested in
void surface_created(uint32_t surface_id);
void surface_removed(uint32_t surface_id);
+
+ // TMC WM Events to clients
+ void emit_activated(char const *label);
+ void emit_deactivated(char const *label);
+ void emit_syncdraw(char const *label);
+ void emit_visible(char const *label, bool is_visible);
};
} // namespace wm
diff --git a/src/main.cpp b/src/main.cpp
index bea9f11..a768347 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -127,5 +127,17 @@ int binding_init() noexcept {
#include "afb_binding_glue.inl"
+// XXX implement send_event right here...
+namespace wm {
+void binding_api::send_event(char const *evname, json_object *payload) {
+ logdebug("%s: %s(%s)", __func__, evname, json_object_to_json_string(payload));
+ afb_event ev = afb_daemon_make_event(evname);
+ int ret = afb_event_broadcast(ev, payload);
+ if (ret != 0) {
+ logdebug("afb_event_broadcast failed: %m");
+ }
+}
+}
+
extern "C" const struct afb_binding_v2 afbBindingV2 = {
"winman", nullptr, nullptr, winman_verbs, nullptr, binding_init, nullptr, 1};