diff options
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | src/x11_in_gtk2.c | 49 | ||||
-rw-r--r-- | src/x11_in_qt4.cpp | 50 | ||||
-rw-r--r-- | wscript | 6 |
4 files changed, 95 insertions, 11 deletions
@@ -2,6 +2,7 @@ suil (0.6.13) unstable; * Print system error message if module fails to load * Lower dependency from Gtk 2.24 introduced in 0.6.12 + * Add support for new LV2 idle interface -- David Robillard <d@drobilla.net> Sun, 24 Feb 2013 12:02:41 -0500 diff --git a/src/x11_in_gtk2.c b/src/x11_in_gtk2.c index 60cb4e8..87cfa04 100644 --- a/src/x11_in_gtk2.c +++ b/src/x11_in_gtk2.c @@ -28,10 +28,13 @@ typedef struct _SuilX11Wrapper SuilX11Wrapper; typedef struct _SuilX11WrapperClass SuilX11WrapperClass; struct _SuilX11Wrapper { - GtkSocket socket; - GtkPlug* plug; - SuilWrapper* wrapper; - SuilInstance* instance; + GtkSocket socket; + GtkPlug* plug; + SuilWrapper* wrapper; + SuilInstance* instance; +#ifdef HAVE_NEW_LV2 + const LV2UI_Idle_Interface* idle_iface; +#endif }; struct _SuilX11WrapperClass { @@ -47,6 +50,10 @@ on_plug_removed(GtkSocket* sock, gpointer data) { SuilX11Wrapper* const self = SUIL_X11_WRAPPER(sock); +#ifdef HAVE_NEW_LV2 + g_idle_remove_by_data(self); +#endif + if (self->instance->handle) { self->instance->descriptor->cleanup(self->instance->handle); self->instance->handle = NULL; @@ -148,9 +155,12 @@ suil_x11_wrapper_class_init(SuilX11WrapperClass* klass) static void suil_x11_wrapper_init(SuilX11Wrapper* self) { - self->plug = GTK_PLUG(gtk_plug_new(0)); - self->wrapper = NULL; - self->instance = NULL; + self->plug = GTK_PLUG(gtk_plug_new(0)); + self->wrapper = NULL; + self->instance = NULL; +#ifdef HAVE_NEW_LV2 + self->idle_iface = NULL; +#endif } static int @@ -160,6 +170,18 @@ wrapper_resize(LV2UI_Feature_Handle handle, int width, int height) return 0; } +#ifdef HAVE_NEW_LV2 +static gboolean +suil_x11_wrapper_idle(void* data) +{ + SuilX11Wrapper* const wrap = SUIL_X11_WRAPPER(data); + + wrap->idle_iface->idle(wrap->instance->handle); + + return TRUE; // Continue calling +} +#endif + static int wrapper_wrap(SuilWrapper* wrapper, SuilInstance* instance) @@ -170,6 +192,15 @@ wrapper_wrap(SuilWrapper* wrapper, wrap->wrapper = wrapper; wrap->instance = instance; +#ifdef HAVE_NEW_LV2 + const LV2UI_Idle_Interface* idle_iface = suil_instance_extension_data( + instance, LV2_UI__idleInterface); + if (idle_iface) { + wrap->idle_iface = idle_iface; + g_idle_add(suil_x11_wrapper_idle, wrap); + } +#endif + g_signal_connect(G_OBJECT(wrap), "plug-removed", G_CALLBACK(on_plug_removed), @@ -215,5 +246,9 @@ suil_wrapper_new(SuilHost* host, suil_add_feature(features, &n_features, LV2_UI__resize, &wrapper->resize); +#ifdef HAVE_NEW_LV2 + suil_add_feature(features, &n_features, LV2_UI__idleInterface, NULL); +#endif + return wrapper; } diff --git a/src/x11_in_qt4.cpp b/src/x11_in_qt4.cpp index a39ba28..916b384 100644 --- a/src/x11_in_qt4.cpp +++ b/src/x11_in_qt4.cpp @@ -14,20 +14,62 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include <QTimerEvent> #include <QX11EmbedContainer> #undef signals #include "./suil_config.h" #include "./suil_internal.h" +#ifndef HAVE_NEW_LV2 +typedef struct _LV2UI_Idle_Interface LV2UI_Idle_Interface; +#endif + extern "C" { +class SuilQX11Container : public QX11EmbedContainer +{ +public: + SuilQX11Container(SuilInstance* instance, + const LV2UI_Idle_Interface* idle_iface) + : QX11EmbedContainer() + , _instance(instance) + , _idle_iface(idle_iface) + , _ui_timer(0) + {} + +#ifdef HAVE_NEW_LV2 + void showEvent(QShowEvent* event) { + if (_idle_iface) { + _ui_timer = this->startTimer(30); + } + QX11EmbedContainer::showEvent(event); + } + + void timerEvent(QTimerEvent* event) { + if (event->timerId() == _ui_timer && _idle_iface) { + _idle_iface->idle(_instance->handle); + } + } +#endif + + SuilInstance* _instance; + const LV2UI_Idle_Interface* _idle_iface; + int _ui_timer; +}; + static int wrapper_wrap(SuilWrapper* wrapper, SuilInstance* instance) { - QX11EmbedWidget* const ew = (QX11EmbedWidget*)wrapper->impl; - QX11EmbedContainer* const wrap = new QX11EmbedContainer(); + const LV2UI_Idle_Interface* idle_iface = NULL; +#ifdef HAVE_NEW_LV2 + idle_iface = (const LV2UI_Idle_Interface*)suil_instance_extension_data( + instance, LV2_UI__idleInterface); +#endif + + QX11EmbedWidget* const ew = (QX11EmbedWidget*)wrapper->impl; + SuilQX11Container* const wrap = new SuilQX11Container(instance, idle_iface); ew->embedInto(wrap->winId()); @@ -68,6 +110,10 @@ suil_wrapper_new(SuilHost* host, suil_add_feature(features, &n_features, LV2_UI__resize, &wrapper->resize); +#ifdef HAVE_NEW_LV2 + suil_add_feature(features, &n_features, LV2_UI__idleInterface, NULL); +#endif + return wrapper; } @@ -52,6 +52,8 @@ def configure(conf): conf.env.NODELETE_FLAGS = ['-Wl,-z,nodelete'] autowaf.check_pkg(conf, 'lv2', atleast_version='1.0.0', uselib_store='LV2') + autowaf.check_pkg(conf, 'lv2', atleast_version='1.4.1', + uselib_store='NEW_LV2', mandatory=False) autowaf.check_pkg(conf, 'gtk+-2.0', uselib_store='GTK2', atleast_version='2.18.0', mandatory=False) @@ -184,7 +186,7 @@ def build(bld): cflags = cflags, lib = modlib, linkflags = bld.env.NODELETE_FLAGS) - autowaf.use_lib(bld, obj, 'GTK2 GTK2_X11 LV2') + autowaf.use_lib(bld, obj, 'GTK2 GTK2_X11 LV2 NEW_LV2') if bld.is_defined('HAVE_GTK2') and sys.platform == 'win32': obj = bld(features = 'cxx cxxshlib', @@ -207,7 +209,7 @@ def build(bld): install_path = module_dir, cflags = cflags, lib = modlib) - autowaf.use_lib(bld, obj, 'QT4 LV2') + autowaf.use_lib(bld, obj, 'QT4 LV2 NEW_LV2') # Documentation autowaf.build_dox(bld, 'SUIL', SUIL_VERSION, top, out) |