Call event handler only if event-label matches
[staging/windowmanager.git] / AFBClient.cpp
index 5fadc35..cee49ad 100644 (file)
@@ -44,8 +44,7 @@ class AFBClient::Impl {
     int deactivateSurface(const char *label);
     int endDraw(const char *label);
 
-    void set_event_handler(enum EventType et,
-                           std::function<void(char const *label)> f);
+    void set_event_handler(enum EventType et, handler_fun f);
 
     Impl();
     ~Impl();
@@ -358,8 +357,6 @@ int AFBClient::Impl::endDraw(const char *label) {
 
 void AFBClient::Impl::set_event_handler(
     enum EventType et, std::function<void(char const *)> func) {
-    UNUSED(et);
-    UNUSED(func);
     TRACE();
 
     if (et >= 1 && et <= 6) {  // Yeah ... just go with it!
@@ -406,7 +403,9 @@ void AFBClient::Impl::event(char const *et, char const *label) {
 
     auto i = this->handlers.find(oet.second);
     if (i != this->handlers.end()) {
-        i->second(label);
+        if (this->labels.find(label) != this->labels.end()) {
+            i->second(label);
+        }
     }
 }