summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2013-03-19 03:11:19 +0000
committerDavid Robillard <d@drobilla.net>2013-03-19 03:11:19 +0000
commite77cc9a1956a1ce74d2d784ab4cfcaddf89ff3d7 (patch)
treeb351b977ed1652cfd34acf3ff5542b06a772256f /src
parente969ce910f4336c3db042aaa26fea810495b7400 (diff)
downloadsuil-e77cc9a1956a1ce74d2d784ab4cfcaddf89ff3d7.tar.gz
suil-e77cc9a1956a1ce74d2d784ab4cfcaddf89ff3d7.tar.bz2
suil-e77cc9a1956a1ce74d2d784ab4cfcaddf89ff3d7.zip
Add support for UI idle interface.
git-svn-id: http://svn.drobilla.net/lad/trunk/suil@5091 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/x11_in_gtk2.c49
-rw-r--r--src/x11_in_qt4.cpp50
2 files changed, 90 insertions, 9 deletions
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;
}