Work around resizing bug in Surge XT/CJE

This commit is contained in:
Robbert van der Helm
2022-10-09 14:22:02 +02:00
parent 3134d7a0b0
commit 4df2b389a0
5 changed files with 69 additions and 13 deletions
+23 -5
View File
@@ -508,15 +508,23 @@ void ClapBridge::run() {
[&, plugin = instance.plugin.get(),
gui = instance.extensions.gui,
&editor = instance.editor]() {
assert(editor);
// HACK: We need to resize the editor window before
// setting the size on the plugin. Surge XT and
// presumably other CLAP JUCE Extensions plugins
// will request a resize to the same size that was
// just set. This causes a resize loop, so we'll
// try to prevent resizes to the same size.
const Size old_size = editor->size();
editor->resize(request.width, request.height);
if (gui->set_size(plugin, request.width,
request.height)) {
// Also resize the editor window. We do the same
// thing when the plugin requests a resize.
assert(editor);
editor->resize(request.width, request.height);
return true;
} else {
editor->resize(old_size.width, old_size.height);
return false;
}
});
@@ -745,6 +753,16 @@ bool ClapBridge::maybe_resize_editor(size_t instance_id,
}
}
std::optional<Size> ClapBridge::editor_size(size_t instance_id) {
const auto& [instance, _] = get_instance(instance_id);
if (instance.editor) {
return instance.editor->size();
} else {
return std::nullopt;
}
}
void ClapBridge::close_sockets() {
sockets_.close();
}