Add an option to disable VST3 content scaling

This might be necessary when using a HiDPI screen as plugin GUIs often
don't scale correctly under Wine.
This commit is contained in:
Robbert van der Helm
2021-01-14 17:36:00 +01:00
parent 07e84c78b3
commit 5dcedbace5
6 changed files with 52 additions and 12 deletions
+6
View File
@@ -113,6 +113,12 @@ Configuration::Configuration(const fs::path& config_path,
} else {
invalid_options.push_back(key);
}
} else if (key == "vst3_no_scaling") {
if (const auto parsed_value = value.as_boolean()) {
vst3_no_scaling = parsed_value->get();
} else {
invalid_options.push_back(key);
}
} else {
unknown_options.push_back(key);
}
+10
View File
@@ -122,6 +122,15 @@ class Configuration {
*/
std::optional<float> frame_rate;
/**
* Disable `IPlugViewContentScaleSupport::setContentScaleFactor()`. Wine
* does not properly implement DPI scaling, so without this option plugins
* using GDI+ would draw their editor GUIs at the normal size even though
* their window would actually be scaled. That would result in giant black
* borders at the top and the right of the window.
*/
bool vst3_no_scaling = false;
/**
* The name of the plugin group that should be used for the plugin this
* configuration object was created for. If not set, then the plugin should
@@ -165,6 +174,7 @@ class Configuration {
s.value1b(editor_xembed);
s.ext(frame_rate, bitsery::ext::StdOptional(),
[](S& s, auto& v) { s.value4b(v); });
s.value1b(vst3_no_scaling);
s.ext(group, bitsery::ext::StdOptional(),
[](S& s, auto& v) { s.text1b(v, 4096); });
+3
View File
@@ -171,6 +171,9 @@ class PluginBridge {
<< *config.frame_rate << " fps";
other_options.push_back(option.str());
}
if (config.vst3_no_scaling) {
other_options.push_back("vst3: no GUI scaling");
}
if (!other_options.empty()) {
init_msg << join_quoted_strings(other_options) << std::endl;
} else {
+20 -9
View File
@@ -742,15 +742,26 @@ void Vst3Bridge::run() {
[&](YaPlugViewContentScaleSupport::SetContentScaleFactor& request)
-> YaPlugViewContentScaleSupport::SetContentScaleFactor::
Response {
return main_context
.run_in_context<tresult>([&]() {
return object_instances[request
.owner_instance_id]
.plug_view_instance
->plug_view_content_scale_support
->setContentScaleFactor(request.factor);
})
.get();
if (config.vst3_no_scaling) {
std::cerr << "The host requested the editor GUI to "
"be scaled by a factor of "
<< request.factor
<< ", but the 'vst3_no_scale' option is "
"enabled. Ignoring the request."
<< std::endl;
return Steinberg::kResultFalse;
} else {
return main_context
.run_in_context<tresult>([&]() {
return object_instances
[request.owner_instance_id]
.plug_view_instance
->plug_view_content_scale_support
->setContentScaleFactor(
request.factor);
})
.get();
}
},
[&](YaPluginBase::Initialize& request)
-> YaPluginBase::Initialize::Response {