diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/x11_in_gtk2.c | 44 | ||||
-rw-r--r-- | src/x11_in_qt4.cpp | 8 |
2 files changed, 41 insertions, 11 deletions
diff --git a/src/x11_in_gtk2.c b/src/x11_in_gtk2.c index e2d9cea..57a9194 100644 --- a/src/x11_in_gtk2.c +++ b/src/x11_in_gtk2.c @@ -21,6 +21,11 @@ #include "./suil_internal.h" +#ifdef HAVE_LV2_1_4_3 +# include "lv2/lv2plug.in/ns/ext/options/options.h" +# include "lv2/lv2plug.in/ns/ext/urid/urid.h" +#endif + #define SUIL_TYPE_X11_WRAPPER (suil_x11_wrapper_get_type()) #define SUIL_X11_WRAPPER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SUIL_TYPE_X11_WRAPPER, SuilX11Wrapper)) @@ -32,9 +37,10 @@ struct _SuilX11Wrapper { GtkPlug* plug; SuilWrapper* wrapper; SuilInstance* instance; -#ifdef HAVE_LV2_1_4_1 +#ifdef HAVE_LV2_1_4_3 const LV2UI_Idle_Interface* idle_iface; guint idle_id; + guint idle_ms; #endif }; @@ -51,7 +57,7 @@ on_plug_removed(GtkSocket* sock, gpointer data) { SuilX11Wrapper* const self = SUIL_X11_WRAPPER(sock); -#ifdef HAVE_LV2_1_4_1 +#ifdef HAVE_LV2_1_4_3 if (self->idle_id) { g_source_remove(self->idle_id); self->idle_id = 0; @@ -162,8 +168,9 @@ suil_x11_wrapper_init(SuilX11Wrapper* self) self->plug = GTK_PLUG(gtk_plug_new(0)); self->wrapper = NULL; self->instance = NULL; -#ifdef HAVE_LV2_1_4_1 +#ifdef HAVE_LV2_1_4_3 self->idle_iface = NULL; + self->idle_ms = 1000 / 30; // 30 Hz default #endif } @@ -174,7 +181,7 @@ wrapper_resize(LV2UI_Feature_Handle handle, int width, int height) return 0; } -#ifdef HAVE_LV2_1_4_1 +#ifdef HAVE_LV2_1_4_3 static gboolean suil_x11_wrapper_idle(void* data) { @@ -196,12 +203,13 @@ wrapper_wrap(SuilWrapper* wrapper, wrap->wrapper = wrapper; wrap->instance = instance; -#ifdef HAVE_LV2_1_4_1 +#ifdef HAVE_LV2_1_4_3 const LV2UI_Idle_Interface* idle_iface = suil_instance_extension_data( instance, LV2_UI__idleInterface); if (idle_iface) { wrap->idle_iface = idle_iface; - wrap->idle_id = g_timeout_add(1000/30, suil_x11_wrapper_idle, wrap); + wrap->idle_id = g_timeout_add( + wrap->idle_ms, suil_x11_wrapper_idle, wrap); } #endif @@ -250,8 +258,30 @@ suil_wrapper_new(SuilHost* host, suil_add_feature(features, &n_features, LV2_UI__resize, &wrapper->resize); -#ifdef HAVE_LV2_1_4_1 +#ifdef HAVE_LV2_1_4_3 suil_add_feature(features, &n_features, LV2_UI__idleInterface, NULL); + + // Scan for URID map and options + LV2_URID_Map* map = NULL; + LV2_Options_Option* options = NULL; + for (LV2_Feature** f = *features; *f && (!map || !options); ++f) { + if (!strcmp((*f)->URI, LV2_OPTIONS__options)) { + options = (*f)->data; + } else if (!strcmp((*f)->URI, LV2_URID__map)) { + map = (*f)->data; + } + } + + if (map && options) { + // Set UI update rate if given + LV2_URID ui_updateRate = map->map(map->handle, LV2_UI__updateRate); + for (LV2_Options_Option* o = options; o->key; ++o) { + if (o->key == ui_updateRate) { + wrap->idle_ms = 1000.0f / *(float*)o->value; + break; + } + } + } #endif return wrapper; diff --git a/src/x11_in_qt4.cpp b/src/x11_in_qt4.cpp index bd079ab..33a2e18 100644 --- a/src/x11_in_qt4.cpp +++ b/src/x11_in_qt4.cpp @@ -21,7 +21,7 @@ #include "./suil_config.h" #include "./suil_internal.h" -#ifndef HAVE_LV2_1_4_1 +#ifndef HAVE_LV2_1_4_3 typedef struct _LV2UI_Idle_Interface LV2UI_Idle_Interface; #endif @@ -40,7 +40,7 @@ public: , _ui_timer(0) {} -#ifdef HAVE_LV2_1_4_1 +#ifdef HAVE_LV2_1_4_3 void showEvent(QShowEvent* event) { if (_idle_iface && _ui_timer == 0) { _ui_timer = this->startTimer(30); @@ -68,7 +68,7 @@ wrapper_wrap(SuilWrapper* wrapper, SuilInstance* instance) { const LV2UI_Idle_Interface* idle_iface = NULL; -#ifdef HAVE_LV2_1_4_1 +#ifdef HAVE_LV2_1_4_3 idle_iface = (const LV2UI_Idle_Interface*)suil_instance_extension_data( instance, LV2_UI__idleInterface); #endif @@ -113,7 +113,7 @@ suil_wrapper_new(SuilHost* host, suil_add_feature(features, &n_features, LV2_UI__resize, &wrapper->resize); -#ifdef HAVE_LV2_1_4_1 +#ifdef HAVE_LV2_1_4_3 suil_add_feature(features, &n_features, LV2_UI__idleInterface, NULL); #endif |