From 4e70264247f9314f24a2b32189766c96596bd451 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 27 Apr 2014 00:43:14 +0000 Subject: Support new UI show/hide interface in console version. git-svn-id: http://svn.drobilla.net/lad/trunk/jalv@5377 a436a847-0d15-0410-975c-d299462d15a1 --- NEWS | 3 ++- src/jalv.c | 4 +++- src/jalv_console.c | 46 +++++++++++++++++++++++++++++++++++----------- src/jalv_internal.h | 1 + 4 files changed, 41 insertions(+), 13 deletions(-) diff --git a/NEWS b/NEWS index a282ae6..2034552 100644 --- a/NEWS +++ b/NEWS @@ -5,8 +5,9 @@ jalv (1.4.5) unstable; * Update for latest LV2 Atom Object simplifications * Set port pretty names via new Jack metadata API * Add support for data-access extension (based on patch by Filipe Coelho) + * Support new UI show/hide interface in console version - -- David Robillard Sat, 26 Apr 2014 13:50:14 -0400 + -- David Robillard Sat, 26 Apr 2014 20:33:45 -0400 jalv (1.4.4) stable; diff --git a/src/jalv.c b/src/jalv.c index 50a818a..9fd7288 100644 --- a/src/jalv.c +++ b/src/jalv.c @@ -1013,9 +1013,9 @@ main(int argc, char** argv) /* Get a plugin UI */ const char* native_ui_type_uri = jalv_native_ui_type(&jalv); + jalv.uis = lilv_plugin_get_uis(jalv.plugin); if (!jalv.opts.generic_ui && native_ui_type_uri) { const LilvNode* native_ui_type = lilv_new_uri(jalv.world, native_ui_type_uri); - jalv.uis = lilv_plugin_get_uis(jalv.plugin); LILV_FOREACH(uis, u, jalv.uis) { const LilvUI* this_ui = lilv_uis_get(jalv.uis, u); if (lilv_ui_is_supported(this_ui, @@ -1027,6 +1027,8 @@ main(int argc, char** argv) break; } } + } else if (!jalv.opts.generic_ui && jalv.opts.show_ui) { + jalv.ui = lilv_uis_get(jalv.uis, lilv_uis_begin(jalv.uis)); } /* Create ringbuffers for UI if necessary */ diff --git a/src/jalv_console.c b/src/jalv_console.c index b75bb3c..c13880b 100644 --- a/src/jalv_console.c +++ b/src/jalv_console.c @@ -14,13 +14,18 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include +#define _XOPEN_SOURCE 500 + #include #include +#include +#include #include "jalv_config.h" #include "jalv_internal.h" +#include "lv2/lv2plug.in/ns/extensions/ui/ui.h" + static int print_usage(const char* name, bool error) { @@ -28,6 +33,7 @@ print_usage(const char* name, bool error) fprintf(os, "Usage: %s [OPTION...] PLUGIN_URI\n", name); fprintf(os, "Run an LV2 plugin as a Jack application.\n"); fprintf(os, " -h Display this help and exit\n"); + fprintf(os, " -s Show non-embedded UI if possible\n"); fprintf(os, " -u UUID UUID for Jack session restoration\n"); fprintf(os, " -l DIR Load state from save directory\n"); fprintf(os, " -d DIR Dump plugin <=> UI communication\n"); @@ -61,6 +67,8 @@ jalv_init(int* argc, char*** argv, JalvOptions* opts) for (; a < *argc && (*argv)[a][0] == '-'; ++a) { if ((*argv)[a][1] == 'h') { return print_usage((*argv)[0], true); + } else if ((*argv)[a][1] == 's') { + opts->show_ui = true; } else if ((*argv)[a][1] == 'u') { if (++a == *argc) { fprintf(stderr, "Missing argument for -u\n"); @@ -108,16 +116,32 @@ jalv_native_ui_type(Jalv* jalv) int jalv_open_ui(Jalv* jalv) { -#ifdef JALV_JACK_SESSION - printf("\nPress Ctrl-C to quit: "); - fflush(stdout); -#else - printf("\nPress enter to quit: "); - fflush(stdout); - getc(stdin); - zix_sem_post(jalv->done); -#endif - printf("\n"); + const LV2UI_Idle_Interface* idle_iface = NULL; + const LV2UI_Show_Interface* show_iface = NULL; + if (jalv->ui && jalv->opts.show_ui) { + jalv_ui_instantiate(jalv, jalv_native_ui_type(jalv), NULL); + idle_iface = (const LV2UI_Idle_Interface*) + suil_instance_extension_data(jalv->ui_instance, LV2_UI__idleInterface); + show_iface = (LV2UI_Show_Interface*) + suil_instance_extension_data(jalv->ui_instance, LV2_UI__showInterface); + } + + if (show_iface && idle_iface) { + show_iface->show(suil_instance_get_handle(jalv->ui_instance)); + + // Drive idle interface until interrupted + while (!zix_sem_try_wait(jalv->done)) { + if (idle_iface->idle(suil_instance_get_handle(jalv->ui_instance))) { + break; + } + usleep(33333); + } + + show_iface->hide(suil_instance_get_handle(jalv->ui_instance)); + + // Caller waits on the done sem, so increment it again to exit + zix_sem_post(jalv->done); + } return 0; } diff --git a/src/jalv_internal.h b/src/jalv_internal.h index 4531ee6..47a210d 100644 --- a/src/jalv_internal.h +++ b/src/jalv_internal.h @@ -94,6 +94,7 @@ typedef struct { int generic_ui; ///< Use generic UI iff true int show_hidden; ///< Show controls for notOnGUI ports int no_menu; ///< Hide menu iff true + int show_ui; ///< Show non-embedded UI } JalvOptions; typedef struct { -- cgit v1.2.1