summaryrefslogtreecommitdiffstats
path: root/src/x11_in_qt4.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/x11_in_qt4.cpp')
-rw-r--r--src/x11_in_qt4.cpp50
1 files changed, 48 insertions, 2 deletions
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;
}