+
+ if (et >= 1 && et <= 6) { // Yeah ... just go with it!
+ this->handlers[et] = std::move(func);
+ }
+}
+
+namespace {
+std::pair<bool, AFBClient::EventType> make_event_type(char const *et) {
+ // Event have the form "$API/$EVENT", just try to find the first / and
+ // get on with it.
+ char const *et2 = strchr(et, '/');
+ if (et2) {
+ et = et2 + 1;
+ }
+
+#define ET(N, A) \
+ do { \
+ if (strcasecmp(et, N) == 0) \
+ return std::make_pair<bool, AFBClient::EventType>( \
+ true, CONCAT(AFBClient::Event_, A)); \
+ } while (0)
+
+ ET("activated", Active);
+ ET("deactivated", Inactive);
+ ET("visible", Visible);
+ ET("invisible", Invisible);
+ ET("syncdraw", SyncDraw);
+ ET("flushdraw", FlushDraw);
+#undef ET
+
+ return std::make_pair<bool, AFBClient::EventType>(false,
+ AFBClient::Event_Active);
+}
+} // namespace
+
+void AFBClient::Impl::event(char const *et, char const *label) {
+ TRACE();
+ auto oet = make_event_type(et);
+ if (!oet.first) {
+ fprintf(stderr, "Unknown event type string '%s'\n", et);
+ return;
+ }
+
+ auto i = this->handlers.find(oet.second);
+ if (i != this->handlers.end()) {
+ i->second(label);
+ }