From a1e2228477ece6cd9f48481e69c15ec6887c443b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 13 Apr 2015 13:46:48 +0200 Subject: [PATCH] Create event_command callback --- ui/drivers/ui_cocoatouch.m | 11 +++++++++++ ui/drivers/ui_null.c | 7 +++++++ ui/drivers/ui_qt.c | 13 +++++++++++++ ui/ui_companion_driver.h | 3 +++ 4 files changed, 34 insertions(+) diff --git a/ui/drivers/ui_cocoatouch.m b/ui/drivers/ui_cocoatouch.m index 46e5572958..d8c7cd6d17 100644 --- a/ui/drivers/ui_cocoatouch.m +++ b/ui/drivers/ui_cocoatouch.m @@ -90,11 +90,22 @@ static void *ui_companion_cocoatouch_init(void) return handle; } +static void ui_companion_cocoatouch_event_command(void *data, unsigned cmd) +{ + ui_companion_cocoatouch_t *handle = (ui_companion_cocoatouch_t*)data; + + if (!handle) + return; + + event_command(cmd); +} + const ui_companion_driver_t ui_companion_cocoatouch = { ui_companion_cocoatouch_init, ui_companion_cocoatouch_deinit, ui_companion_cocoatouch_iterate, ui_companion_cocoatouch_toggle, + ui_companion_cocoatouch_event_command, ui_companion_cocoatouch_notify_content_loaded, "cocoatouch", }; diff --git a/ui/drivers/ui_null.c b/ui/drivers/ui_null.c index 49332a9ad3..42c57de77e 100644 --- a/ui/drivers/ui_null.c +++ b/ui/drivers/ui_null.c @@ -63,11 +63,18 @@ static void ui_companion_null_toggle(void *data) (void)data; } +static void ui_companion_null_event_command(void *data, unsigned cmd) +{ + (void)data; + (void)cmd; +} + const ui_companion_driver_t ui_companion_null = { ui_companion_null_init, ui_companion_null_deinit, ui_companion_null_iterate, ui_companion_null_toggle, + ui_companion_null_event_command, ui_companion_null_notify_content_loaded, "null", }; diff --git a/ui/drivers/ui_qt.c b/ui/drivers/ui_qt.c index 0b2b1ba611..e376fd27e6 100644 --- a/ui/drivers/ui_qt.c +++ b/ui/drivers/ui_qt.c @@ -102,11 +102,24 @@ static void ui_companion_qt_toggle(void *data) ui_companion_qt_init(); } +static void ui_companion_qt_event_command(void *data, unsigned cmd) +{ + ui_companion_qt_t *handle = (ui_companion_qt_t*)data; + + if (!handle) + return; + + slock_lock(handle->lock); + event_command(cmd); + slock_unlock(handle->lock); +} + const ui_companion_driver_t ui_companion_qt = { ui_companion_qt_init, ui_companion_qt_deinit, ui_companion_qt_iterate, ui_companion_qt_toggle, + ui_companion_qt_event_command, ui_companion_qt_notify_content_loaded, "qt", }; diff --git a/ui/ui_companion_driver.h b/ui/ui_companion_driver.h index 7c02dd0cad..f80572b51f 100644 --- a/ui/ui_companion_driver.h +++ b/ui/ui_companion_driver.h @@ -24,6 +24,8 @@ #include "../config.h" #endif +#include "../command_event.h" + #ifdef __cplusplus extern "C" { #endif @@ -34,6 +36,7 @@ typedef struct ui_companion_driver void (*deinit)(void *data); int (*iterate)(void *data, unsigned action); void (*toggle)(void *data); + void (*event_command)(void *data, unsigned action); void (*notify_content_loaded)(void *data); const char *ident;