summaryrefslogtreecommitdiffstats
path: root/src/host.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2017-03-18 12:02:05 +0100
committerDavid Robillard <d@drobilla.net>2017-03-18 12:05:15 +0100
commit43a25ed63a9144afe32a4fea520412770394822c (patch)
tree67c7aa044726304b71794f64316ad68d29758325 /src/host.c
parent64a2647d8d81b5c23d22b52cc9e0dd2595270b67 (diff)
downloadsuil-43a25ed63a9144afe32a4fea520412770394822c.tar.gz
suil-43a25ed63a9144afe32a4fea520412770394822c.tar.bz2
suil-43a25ed63a9144afe32a4fea520412770394822c.zip
Add suil_init()
This allows the actual host argc and argv to be passed to QApplication if it is created by Suil (for Qt in non-Qt cases), and initializes X11 threads to fix Qt5 in Gtk2.
Diffstat (limited to 'src/host.c')
-rw-r--r--src/host.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/src/host.c b/src/host.c
index c0e8189..6502543 100644
--- a/src/host.c
+++ b/src/host.c
@@ -1,5 +1,6 @@
/*
- Copyright 2011-2015 David Robillard <http://drobilla.net>
+ Copyright 2011-2017 David Robillard <http://drobilla.net>
+ Copyright 2017 Stefan Westerfeld <stefan@space.twc.de>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
@@ -16,6 +17,9 @@
#include "./suil_internal.h"
+int suil_argc = 0;
+char** suil_argv = NULL;
+
SUIL_API
SuilHost*
suil_host_new(SuilPortWriteFunc write_func,
@@ -28,6 +32,8 @@ suil_host_new(SuilPortWriteFunc write_func,
host->index_func = index_func;
host->subscribe_func = subscribe_func;
host->unsubscribe_func = unsubscribe_func;
+ host->argc = suil_argc;
+ host->argv = suil_argv;
return host;
}
@@ -50,3 +56,33 @@ suil_host_free(SuilHost* host)
free(host);
}
}
+
+static void
+suil_load_init_module(const char* module_name)
+{
+ void* const lib = suil_open_module(module_name);
+ if (!lib) {
+ return;
+ }
+
+ SuilVoidFunc init_func = (SuilVoidFunc)suil_dlfunc(lib, "suil_host_init");
+ if (init_func) {
+ (*init_func)();
+ } else {
+ SUIL_ERRORF("Corrupt init module %s\n", module_name);
+ }
+
+ dlclose(lib);
+}
+
+SUIL_API
+void
+suil_init(int* argc, char*** argv, SuilArg key, ...)
+{
+ suil_argc = argc ? *argc : 0;
+ suil_argv = argv ? *argv : NULL;
+
+#if SUIL_WITH_X11
+ suil_load_init_module("suil_x11");
+#endif
+}