From dedff393720e725c4a4ee7c230d2799aa795f101 Mon Sep 17 00:00:00 2001 From: Stefano D'Angelo Date: Tue, 28 May 2024 14:30:22 +0200 Subject: [PATCH] gui fixes, vst3 checkSizeConstraints --- templates/vst3/src/vst3.c | 13 ++++++++++++- test/plugin_ui.h | 5 +++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/templates/vst3/src/vst3.c b/templates/vst3/src/vst3.c index e44fe9c..956fa06 100644 --- a/templates/vst3/src/vst3.c +++ b/templates/vst3/src/vst3.c @@ -1197,8 +1197,19 @@ static Steinberg_tresult plugViewCheckSizeConstraint(void* thisInterface, struct (void)rect; TRACE("plugView chekSizeContraint %p\n", thisInterface); - //TODO +# if DATA_UI_USER_RESIZABLE + return Steinberg_kResultTrue; +# else +# ifdef __linux__ + plugView *v = (plugView *)((char *)thisInterface - offsetof(plugView, vtblIPlugView)); + + XWindowAttributes attr; + XGetWindowAttributes(v->display, (Window)(*((char **)v->ui)), &attr); + rect->right = rect->left + attr.width; + rect->bottom = rect->top + attr.height; +# endif return Steinberg_kResultFalse; +# endif } # ifdef __linux__ diff --git a/test/plugin_ui.h b/test/plugin_ui.h index a4c1999..034c9df 100644 --- a/test/plugin_ui.h +++ b/test/plugin_ui.h @@ -196,6 +196,7 @@ static plugin_ui *plugin_ui_create(char has_parent, void *parent, plugin_ui_call instance->view = puglNewView(instance->world); puglSetSizeHint(instance->view, PUGL_DEFAULT_SIZE, WIDTH, HEIGHT); puglSetViewHint(instance->view, PUGL_RESIZABLE, PUGL_TRUE); + puglSetHandle(instance->view, instance); puglSetBackend(instance->view, puglCairoBackend()); PuglRect frame = { 0, 0, WIDTH, HEIGHT }; puglSetFrame(instance->view, frame); @@ -207,10 +208,10 @@ static plugin_ui *plugin_ui_create(char has_parent, void *parent, plugin_ui_call puglFreeWorld(instance->world); return NULL; } - puglShow(instance->view, PUGL_SHOW_RAISE); - puglSetHandle(instance->view, instance); instance->widget = (void *)puglGetNativeView(instance->view); instance->cbs = *cbs; + puglSetFrame(instance->view, frame); // Intentionally duplicated because of ardour/lv2/mac strange event order call + puglShow(instance->view, PUGL_SHOW_RAISE); // Cocoa calls events at this so it's better this happens late return instance; }