mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-06 19:40:10 +02:00
VST3: Add HiDPI scaling hack
Sometimes the plugin size might be off-by-one due to HiDPI scaling. If so, pretend it's actually the size that was requested, to avoid ending up in an infinite loop.
This commit is contained in:
committed by
Robbert van der Helm
parent
9994043306
commit
b2db9cc0a6
@@ -899,8 +899,22 @@ void Vst3Bridge::run() {
|
||||
get_instance(request.owner_instance_id);
|
||||
std::lock_guard lock(instance.get_size_mutex);
|
||||
|
||||
return instance.plug_view_instance->plug_view->getSize(
|
||||
&size);
|
||||
auto result =
|
||||
instance.plug_view_instance->plug_view->getSize(
|
||||
&size);
|
||||
// HACK: Sometimes, due to HiDPI scaling, plugins might
|
||||
// end up with a size that is off by one pixel
|
||||
// from the requested size. To avoid ending up in
|
||||
// an infinite loop, just return the size that the
|
||||
// host requested in this case.
|
||||
if (result == Steinberg::kResultOk &&
|
||||
abs(size.getWidth() -
|
||||
instance.last_set_size.getWidth()) <= 1 &&
|
||||
abs(size.getHeight() -
|
||||
instance.last_set_size.getHeight()) <= 1) {
|
||||
size = instance.last_set_size;
|
||||
}
|
||||
return result;
|
||||
});
|
||||
|
||||
return YaPlugView::GetSizeResponse{.result = result,
|
||||
@@ -934,6 +948,8 @@ void Vst3Bridge::run() {
|
||||
request.new_size.getHeight());
|
||||
}
|
||||
|
||||
instance.last_set_size = request.new_size;
|
||||
|
||||
return result;
|
||||
});
|
||||
},
|
||||
|
||||
@@ -256,6 +256,14 @@ struct Vst3PluginInstance {
|
||||
* processing.
|
||||
*/
|
||||
std::optional<Steinberg::Vst::ProcessSetup> process_setup;
|
||||
|
||||
/**
|
||||
* The last size that was set with onSize(). We use this to fudge the
|
||||
* return value of getSize() if it is off by one pixel, which can happen
|
||||
* due to HiDPI rounding. Otherwise, DAWs like Ardour might go into an
|
||||
* infinite loop trying to adjust the size to a specific target.
|
||||
*/
|
||||
Steinberg::ViewRect last_set_size;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user