summaryrefslogtreecommitdiffstats
path: root/src/x11_in_gtk2.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-12-10 04:40:00 +0000
committerDavid Robillard <d@drobilla.net>2011-12-10 04:40:00 +0000
commitc545e17c4d3d1f0bf791e9112d2873de01c06e51 (patch)
tree3cb5257796cf59d78d024c6525894ce122a08c60 /src/x11_in_gtk2.c
parent5810fec09eee8491744482b882a635ab8e3d7e78 (diff)
downloadsuil-c545e17c4d3d1f0bf791e9112d2873de01c06e51.tar.gz
suil-c545e17c4d3d1f0bf791e9112d2873de01c06e51.tar.bz2
suil-c545e17c4d3d1f0bf791e9112d2873de01c06e51.zip
Rework module interface to support modules that need to pass features.
Pass experimental parent window ID feature for embedding X11 UIs with events working. git-svn-id: http://svn.drobilla.net/lad/trunk/suil@3851 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/x11_in_gtk2.c')
-rw-r--r--src/x11_in_gtk2.c76
1 files changed, 50 insertions, 26 deletions
diff --git a/src/x11_in_gtk2.c b/src/x11_in_gtk2.c
index 29d8b3a..12508e6 100644
--- a/src/x11_in_gtk2.c
+++ b/src/x11_in_gtk2.c
@@ -14,23 +14,14 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <gtk/gtk.h>
+#include <string.h>
+#include <gtk/gtk.h>
//#include <gdk/gdkx.h>
//#include <X11/Xlib.h>
#include "suil_internal.h"
-SUIL_API
-int
-suil_wrap_init(SuilHost* host,
- const char* host_type_uri,
- const char* ui_type_uri,
- const LV2_Feature* const* features)
-{
- return 0;
-}
-
#define SUIL_TYPE_X11_WRAPPER (suil_x11_wrapper_get_type())
#define SUIL_X11_WRAPPER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SUIL_TYPE_X11_WRAPPER, SuilX11Wrapper))
@@ -41,7 +32,6 @@ struct _SuilX11Wrapper {
GtkSocket socket;
GtkPlug* plug;
SuilInstance* instance;
- int id;
};
struct _SuilX11WrapperClass {
@@ -70,8 +60,7 @@ static void
suil_x11_wrapper_init(SuilX11Wrapper* self)
{
self->instance = NULL;
- self->plug = NULL;
- self->id = 0;
+ self->plug = GTK_PLUG(gtk_plug_new(0));
}
static void
@@ -89,27 +78,62 @@ suil_x11_wrapper_realize(GtkWidget* w, gpointer data)
printf("WIDTH: %d HEIGHT: %d\n", attr.width, attr.height);
*/
- gtk_socket_add_id(socket, wrap->id);
+ gtk_socket_add_id(socket, gtk_plug_get_id(wrap->plug));
+ gtk_widget_show_all(GTK_WIDGET(wrap->plug));
}
-SUIL_API
-int
-suil_wrap(const char* host_type_uri,
- const char* ui_type_uri,
- SuilInstance* instance)
+static int
+wrapper_wrap(SuilWrapper* wrapper,
+ SuilInstance* instance)
{
- SuilX11Wrapper* const wrap = SUIL_X11_WRAPPER(
- g_object_new(SUIL_TYPE_X11_WRAPPER, NULL));
+ SuilX11Wrapper* const wrap = SUIL_X11_WRAPPER(wrapper->impl);
- wrap->instance = instance;
- wrap->id = (intptr_t)instance->ui_widget;
+ instance->host_widget = GTK_WIDGET(wrap);
+ wrap->instance = instance;
g_signal_connect_after(G_OBJECT(wrap),
"realize",
G_CALLBACK(suil_x11_wrapper_realize),
NULL);
- instance->host_widget = GTK_WIDGET(wrap);
-
return 0;
}
+
+static void
+wrapper_free(SuilWrapper* wrapper)
+{
+ free(wrapper->features);
+ free(wrapper);
+}
+
+SUIL_API
+SuilWrapper*
+suil_wrapper_new(SuilHost* host,
+ const char* host_type_uri,
+ const char* ui_type_uri,
+ const LV2_Feature* const* features)
+{
+ SuilWrapper* wrapper = (SuilWrapper*)malloc(sizeof(SuilWrapper));
+ wrapper->wrap = wrapper_wrap;
+ wrapper->free = wrapper_free;
+
+ unsigned n_features = 0;
+ for (; features[n_features]; ++n_features) {}
+
+ SuilX11Wrapper* const wrap = SUIL_X11_WRAPPER(
+ g_object_new(SUIL_TYPE_X11_WRAPPER, NULL));
+
+ wrapper->impl = wrap;
+
+ wrapper->features = (LV2_Feature**)malloc(
+ sizeof(LV2_Feature) * (n_features + 1));
+ memcpy(wrapper->features, features, sizeof(LV2_Feature) * n_features);
+
+ LV2_Feature* parent_feature = (LV2_Feature*)malloc(sizeof(LV2_Feature));
+ parent_feature->URI = "http://example.org/winid";
+ parent_feature->data = (void*)(intptr_t)gtk_plug_get_id(wrap->plug);
+
+ wrapper->features[n_features] = parent_feature;
+
+ return wrapper;
+}