summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-03-21 05:35:43 +0000
committerDavid Robillard <d@drobilla.net>2012-03-21 05:35:43 +0000
commit6d02219044cbafc072c0eed93ce65eddc17b0961 (patch)
tree802ef3d693fde3cc89dcb3f13d641e27773b94f4
parente6f61d105c1536f6821977f94927ef70f9bfe7d7 (diff)
downloadsuil-6d02219044cbafc072c0eed93ce65eddc17b0961.tar.gz
suil-6d02219044cbafc072c0eed93ce65eddc17b0961.tar.bz2
suil-6d02219044cbafc072c0eed93ce65eddc17b0961.zip
Implement resize extension automatically at the wrapper level.
git-svn-id: http://svn.drobilla.net/lad/trunk/suil@4095 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--src/instance.c2
-rw-r--r--src/suil_internal.h8
-rw-r--r--src/x11_in_gtk2.c28
-rw-r--r--src/x11_in_qt4.cpp25
-rw-r--r--wscript5
5 files changed, 60 insertions, 8 deletions
diff --git a/src/instance.c b/src/instance.c
index 45c2085..aad12ef 100644
--- a/src/instance.c
+++ b/src/instance.c
@@ -1,5 +1,5 @@
/*
- Copyright 2007-2011 David Robillard <http://drobilla.net>
+ Copyright 2007-2012 David Robillard <http://drobilla.net>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
diff --git a/src/suil_internal.h b/src/suil_internal.h
index 52fa7ee..0f35ab5 100644
--- a/src/suil_internal.h
+++ b/src/suil_internal.h
@@ -1,5 +1,5 @@
/*
- Copyright 2007-2011 David Robillard <http://drobilla.net>
+ Copyright 2007-2012 David Robillard <http://drobilla.net>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
@@ -31,6 +31,9 @@ static inline char* dlerror(void) { return "Unknown error"; }
#endif
#include "lv2/lv2plug.in/ns/extensions/ui/ui.h"
+#ifdef HAVE_LV2_UI_RESIZE
+#include "lv2/lv2plug.in/ns/ext/ui-resize/ui-resize.h"
+#endif
#include "suil/suil.h"
@@ -60,6 +63,9 @@ typedef struct _SuilWrapper {
void* lib;
LV2_Feature** features;
void* impl;
+#ifdef HAVE_LV2_UI_RESIZE
+ LV2_UI_Resize_Feature resize;
+#endif
} SuilWrapper;
struct SuilInstanceImpl {
diff --git a/src/x11_in_gtk2.c b/src/x11_in_gtk2.c
index 4ef06c9..e860322 100644
--- a/src/x11_in_gtk2.c
+++ b/src/x11_in_gtk2.c
@@ -1,5 +1,5 @@
/*
- Copyright 2011 David Robillard <http://drobilla.net>
+ Copyright 2011-2012 David Robillard <http://drobilla.net>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
@@ -71,6 +71,15 @@ suil_x11_wrapper_realize(GtkWidget* w, gpointer data)
gtk_widget_show_all(GTK_WIDGET(wrap->plug));
}
+#ifdef HAVE_LV2_UI_RESIZE
+static int
+wrapper_resize(LV2_UI_Resize_Feature_Data data, int width, int height)
+{
+ gtk_widget_set_size_request(GTK_WIDGET(data), width, height);
+ return 0;
+}
+#endif
+
static int
wrapper_wrap(SuilWrapper* wrapper,
SuilInstance* instance)
@@ -103,8 +112,8 @@ suil_wrapper_new(SuilHost* host,
const LV2_Feature* const* features)
{
SuilWrapper* wrapper = (SuilWrapper*)malloc(sizeof(SuilWrapper));
- wrapper->wrap = wrapper_wrap;
- wrapper->free = wrapper_free;
+ wrapper->wrap = wrapper_wrap;
+ wrapper->free = wrapper_free;
unsigned n_features = 0;
for (; features[n_features]; ++n_features) {}
@@ -115,7 +124,7 @@ suil_wrapper_new(SuilHost* host,
wrapper->impl = wrap;
wrapper->features = (LV2_Feature**)malloc(
- sizeof(LV2_Feature*) * (n_features + 2));
+ sizeof(LV2_Feature*) * (n_features + 3));
memcpy(wrapper->features, features, sizeof(LV2_Feature*) * n_features);
LV2_Feature* parent_feature = (LV2_Feature*)malloc(sizeof(LV2_Feature));
@@ -124,6 +133,17 @@ suil_wrapper_new(SuilHost* host,
wrapper->features[n_features] = parent_feature;
wrapper->features[n_features + 1] = NULL;
+ wrapper->features[n_features + 2] = NULL;
+#ifdef HAVE_LV2_UI_RESIZE
+ wrapper->resize.data = wrap;
+ wrapper->resize.ui_resize = wrapper_resize;
+
+ LV2_Feature* resize_feature = (LV2_Feature*)malloc(sizeof(LV2_Feature));
+ resize_feature->URI = "http://lv2plug.in/ns/ext/ui-resize#UIResize";
+ resize_feature->data = &wrapper->resize;
+ wrapper->features[n_features + 1] = resize_feature;
+#endif
+
return wrapper;
}
diff --git a/src/x11_in_qt4.cpp b/src/x11_in_qt4.cpp
index 23eae5e..aca2146 100644
--- a/src/x11_in_qt4.cpp
+++ b/src/x11_in_qt4.cpp
@@ -1,5 +1,5 @@
/*
- Copyright 2011 David Robillard <http://drobilla.net>
+ Copyright 2011-2012 David Robillard <http://drobilla.net>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
@@ -36,6 +36,16 @@ wrapper_wrap(SuilWrapper* wrapper,
return 0;
}
+#ifdef HAVE_LV2_UI_RESIZE
+static int
+wrapper_resize(LV2_UI_Resize_Feature_Data data, int width, int height)
+{
+ QX11EmbedWidget* const ew = (QX11EmbedWidget*)data;
+ ew->resize(width, height);
+ return 0;
+}
+#endif
+
SUIL_API
SuilWrapper*
suil_wrapper_new(SuilHost* host,
@@ -54,7 +64,7 @@ suil_wrapper_new(SuilHost* host,
wrapper->impl = ew;
wrapper->features = (LV2_Feature**)malloc(
- sizeof(LV2_Feature*) * (n_features + 2));
+ sizeof(LV2_Feature*) * (n_features + 3));
memcpy(wrapper->features, features, sizeof(LV2_Feature*) * n_features);
LV2_Feature* parent_feature = (LV2_Feature*)malloc(sizeof(LV2_Feature));
@@ -63,6 +73,17 @@ suil_wrapper_new(SuilHost* host,
wrapper->features[n_features] = parent_feature;
wrapper->features[n_features + 1] = NULL;
+ wrapper->features[n_features + 2] = NULL;
+
+#ifdef HAVE_LV2_UI_RESIZE
+ wrapper->resize.data = ew;
+ wrapper->resize.ui_resize = wrapper_resize;
+
+ LV2_Feature* resize_feature = (LV2_Feature*)malloc(sizeof(LV2_Feature));
+ resize_feature->URI = "http://lv2plug.in/ns/ext/ui-resize#UIResize";
+ resize_feature->data = &wrapper->resize;
+ wrapper->features[n_features + 1] = resize_feature;
+#endif
return wrapper;
}
diff --git a/wscript b/wscript
index 21cbb1f..75f52ec 100644
--- a/wscript
+++ b/wscript
@@ -43,6 +43,11 @@ def configure(conf):
conf.env.append_unique('CFLAGS', '-std=c99')
autowaf.check_pkg(conf, 'lv2-lv2plug.in-ns-extensions-ui', uselib_store='LV2_UI')
+ autowaf.check_pkg(conf, 'lv2-lv2plug.in-ns-ext-ui-resize',
+ uselib_store='LV2_UI_RESIZE', mandatory=False)
+
+ if conf.env['HAVE_LV2_UI_RESIZE']:
+ autowaf.define(conf, 'HAVE_LV2_UI_RESIZE', 1)
autowaf.check_pkg(conf, 'gtk+-2.0', uselib_store='GTK2',
atleast_version='2.18.0', mandatory=False)