mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-09 20:29:10 +02:00
Implement IPlugView::attached()
This commit is contained in:
@@ -102,7 +102,7 @@ void Vst3Bridge::run() {
|
||||
std::lock_guard lock(object_instances_mutex);
|
||||
|
||||
const size_t instance_id = generate_instance_id();
|
||||
object_instances[instance_id] = std::move(object);
|
||||
object_instances.emplace(instance_id, std::move(object));
|
||||
|
||||
// This is where the magic happens. Here we deduce which
|
||||
// interfaces are supported by this object so we can create
|
||||
@@ -411,6 +411,41 @@ void Vst3Bridge::run() {
|
||||
return object_instances[request.owner_instance_id]
|
||||
.plug_view->isPlatformTypeSupported(type.c_str());
|
||||
},
|
||||
[&](const YaPlugView::Attached& request)
|
||||
-> YaPlugView::Attached::Response {
|
||||
const std::string type =
|
||||
request.type == Steinberg::kPlatformTypeX11EmbedWindowID
|
||||
? Steinberg::kPlatformTypeHWND
|
||||
: request.type;
|
||||
|
||||
// Just like with VST2 plugins, we'll embed a Wine window into
|
||||
// the X11 window provided by the host
|
||||
// TODO: The docs say that we should support XEmbed (and we're
|
||||
// purposely avoiding that because Wine's implementation
|
||||
// doesn't work correctly). Check if this causes issues,
|
||||
// and if it's actually needed (for instance when the host
|
||||
// resizes the window without informing the plugin)
|
||||
const auto x11_handle = static_cast<size_t>(request.parent);
|
||||
const std::string window_class =
|
||||
"yabridge plugin " + sockets.base_dir.string() + " " +
|
||||
std::to_string(request.owner_instance_id);
|
||||
Editor& editor_instance =
|
||||
object_instances[request.owner_instance_id].editor.emplace(
|
||||
config, window_class, x11_handle);
|
||||
|
||||
const tresult result =
|
||||
object_instances[request.owner_instance_id]
|
||||
.plug_view->attached(editor_instance.get_win32_handle(),
|
||||
type.c_str());
|
||||
|
||||
// Get rid of the editor again if the plugin didn't embed itself
|
||||
// in it
|
||||
if (result != Steinberg::kResultOk) {
|
||||
object_instances[request.owner_instance_id].editor.reset();
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
[&](YaPluginBase::Initialize& request)
|
||||
-> YaPluginBase::Initialize::Response {
|
||||
// If we got passed a host context, we'll create a proxy object
|
||||
|
||||
@@ -70,6 +70,12 @@ struct InstanceInterfaces {
|
||||
*/
|
||||
Steinberg::IPtr<Steinberg::IPlugView> plug_view;
|
||||
|
||||
/**
|
||||
* This instance's editor, if it has an open editor. Embedding here works
|
||||
* exactly the same as how it works for VST2 plugins.
|
||||
*/
|
||||
std::optional<Editor> editor;
|
||||
|
||||
// All smart pointers below are created from `component`. They will be null
|
||||
// pointers if `component` did not implement the interface.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user