summaryrefslogtreecommitdiffstats
path: root/src/x11_in_qt4.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2013-09-17 03:44:00 +0000
committerDavid Robillard <d@drobilla.net>2013-09-17 03:44:00 +0000
commit7febc273b7f7a3d22558ad68dc934fe036b5a441 (patch)
tree730465ee561d984d4da0d0d92a1d1c0bd6286463 /src/x11_in_qt4.cpp
parent6bc70c7785f5c95a32a210ee1f2cddf0e46cb4a5 (diff)
downloadsuil-7febc273b7f7a3d22558ad68dc934fe036b5a441.tar.gz
suil-7febc273b7f7a3d22558ad68dc934fe036b5a441.tar.bz2
suil-7febc273b7f7a3d22558ad68dc934fe036b5a441.zip
Fix crashes and resizing for X11 in Qt (patch from Rui Nuno Capela).
git-svn-id: http://svn.drobilla.net/lad/trunk/suil@5159 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/x11_in_qt4.cpp')
-rw-r--r--src/x11_in_qt4.cpp41
1 files changed, 36 insertions, 5 deletions
diff --git a/src/x11_in_qt4.cpp b/src/x11_in_qt4.cpp
index ee55207..338ae12 100644
--- a/src/x11_in_qt4.cpp
+++ b/src/x11_in_qt4.cpp
@@ -27,6 +27,11 @@ typedef struct _LV2UI_Idle_Interface LV2UI_Idle_Interface;
extern "C" {
+typedef struct {
+ QX11EmbedContainer* host_widget;
+ QX11EmbedWidget* parent;
+} SuilX11InQt4Wrapper;
+
class SuilQX11Container : public QX11EmbedContainer
{
public:
@@ -45,6 +50,7 @@ public:
if (_idle_iface && _ui_timer == 0) {
_ui_timer = this->startTimer(30);
_widget->embedInto(winId());
+ resize(_widget->size());
}
QX11EmbedContainer::showEvent(event);
}
@@ -63,6 +69,22 @@ public:
int _ui_timer;
};
+static void
+wrapper_free(SuilWrapper* wrapper)
+{
+ SuilX11InQt4Wrapper* impl = (SuilX11InQt4Wrapper*)wrapper->impl;
+
+ if (impl->parent) {
+ delete impl->parent;
+ }
+
+ if (impl->host_widget) {
+ delete impl->host_widget;
+ }
+
+ free(impl);
+}
+
static int
wrapper_wrap(SuilWrapper* wrapper,
SuilInstance* instance)
@@ -73,10 +95,12 @@ wrapper_wrap(SuilWrapper* wrapper,
instance, LV2_UI__idleInterface);
#endif
- QX11EmbedWidget* const w = (QX11EmbedWidget*)wrapper->impl;
- SuilQX11Container* const c = new SuilQX11Container(instance, idle_iface, w);
+ SuilX11InQt4Wrapper* const impl = (SuilX11InQt4Wrapper*)wrapper->impl;
+ QX11EmbedWidget* const ew = impl->parent;
- instance->host_widget = c;
+ impl->host_widget = new SuilQX11Container(instance, idle_iface, ew);
+
+ instance->host_widget = impl->host_widget;
return 0;
}
@@ -97,13 +121,20 @@ suil_wrapper_new(SuilHost* host,
LV2_Feature*** features,
unsigned n_features)
{
+ SuilX11InQt4Wrapper* const impl = (SuilX11InQt4Wrapper*)
+ malloc(sizeof(SuilX11InQt4Wrapper));
+ impl->host_widget = NULL;
+ impl->parent = NULL;
+
SuilWrapper* wrapper = (SuilWrapper*)malloc(sizeof(SuilWrapper));
wrapper->wrap = wrapper_wrap;
- wrapper->free = NULL;
+ wrapper->free = wrapper_free;
QX11EmbedWidget* const ew = new QX11EmbedWidget();
- wrapper->impl = ew;
+ impl->parent = ew;
+
+ wrapper->impl = impl;
wrapper->resize.handle = ew;
wrapper->resize.ui_resize = wrapper_resize;