From 430f6e591c056a2eaeb8ec7c25a7597bace8a72c Mon Sep 17 00:00:00 2001 From: Stefano D'Angelo Date: Thu, 30 May 2024 06:46:16 +0200 Subject: [PATCH] fix ui resize in bitwig/linux/vst3 --- templates/vst3/src/vst3.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/templates/vst3/src/vst3.c b/templates/vst3/src/vst3.c index 956fa06..c834df1 100644 --- a/templates/vst3/src/vst3.c +++ b/templates/vst3/src/vst3.c @@ -1149,6 +1149,7 @@ static Steinberg_tresult plugViewGetSize(void* thisInterface, struct Steinberg_V static Steinberg_tresult plugViewOnSize(void* thisInterface, struct Steinberg_ViewRect* newSize) { TRACE("plugView onSize %p\n", thisInterface); plugView *v = (plugView *)((char *)thisInterface - offsetof(plugView, vtblIPlugView)); + // TODO: if not resizable by both user and plugin just return false if (!v->ui) return Steinberg_kResultFalse; # ifdef __linux__ @@ -1216,6 +1217,21 @@ static Steinberg_tresult plugViewCheckSizeConstraint(void* thisInterface, struct static void plugViewOnTimer(void *thisInterface) { TRACE("plugView onTimer %p\n", thisInterface); plugView *v = (plugView *)((char *)thisInterface - offsetof(plugView, vtblIPlugView)); + + // Bitwig doesn't call onSize() as it should, so we compare the editor and parent window and resize if needed + Window w = (Window)(*((char **)v->ui)); + Window root, parent, *children; + unsigned nchildren; + if (XQueryTree(v->display, w, &root, &parent, &children, &nchildren)) { + if (children) + XFree(children); + XWindowAttributes parent_attr, editor_attr; + XGetWindowAttributes(v->display, parent, &parent_attr); + XGetWindowAttributes(v->display, w, &editor_attr); + if (parent_attr.width != editor_attr.width || parent_attr.height != editor_attr.height) + XResizeWindow(v->display, w, parent_attr.width, parent_attr.height); + } + plugin_ui_idle(v->ui); } # endif