mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-13 20:09:59 +02:00
Add the base for GUI handling
Still need to embed the opened window into the window provided by the host.
This commit is contained in:
+11
-1
@@ -208,7 +208,8 @@ void passthrough_event(boost::asio::local::stream_protocol::socket& socket,
|
||||
},
|
||||
[&](WantsChunkBuffer&) -> void* { return string_buffer.data(); },
|
||||
[&](const WantsVstTimeInfo&) -> void* { return nullptr; },
|
||||
[&](WantsString&) -> void* { return string_buffer.data(); }},
|
||||
[&](WantsString&) -> void* { return string_buffer.data(); },
|
||||
[&](WantsWindowHandle&) -> void* { return string_buffer.data(); }},
|
||||
event.payload);
|
||||
|
||||
const intptr_t return_value = callback(plugin, event.opcode, event.index,
|
||||
@@ -263,6 +264,15 @@ void passthrough_event(boost::asio::local::stream_protocol::socket& socket,
|
||||
},
|
||||
[&](WantsString&) -> EventResposnePayload {
|
||||
return std::string(static_cast<char*>(data));
|
||||
},
|
||||
[&](WantsWindowHandle&) -> EventResposnePayload {
|
||||
// This is a bit of a hack, but I couldn't think of a nicer
|
||||
// way to do this since it's only needed for the
|
||||
// `effEditOpen` event. We override the callback function
|
||||
// to create a Win32 window, pass that to the plugin, and
|
||||
// then write the corresponding X11 window handle to the
|
||||
// data pointer.
|
||||
return *reinterpret_cast<intptr_t*>(data);
|
||||
}},
|
||||
event.payload);
|
||||
|
||||
|
||||
@@ -175,7 +175,8 @@ void Logger::log_event(bool is_dispatch,
|
||||
message << "<writable_buffer>";
|
||||
},
|
||||
[&](const WantsVstTimeInfo&) { message << "<nullptr>"; },
|
||||
[&](const WantsString&) { message << "<writable_string>"; }},
|
||||
[&](const WantsString&) { message << "<writable_string>"; },
|
||||
[&](const WantsWindowHandle&) { message << "<nullptr>"; }},
|
||||
payload);
|
||||
|
||||
message << ")";
|
||||
@@ -209,7 +210,10 @@ void Logger::log_event_response(bool is_dispatch,
|
||||
}
|
||||
},
|
||||
[&](const AEffect&) { message << ", <AEffect_object>"; },
|
||||
[&](const VstTimeInfo&) { message << ", <time_info>"; }},
|
||||
[&](const VstTimeInfo&) { message << ", <time_info>"; },
|
||||
[&](const intptr_t& window_handle) {
|
||||
message << ", window #" << window_handle;
|
||||
}},
|
||||
payload);
|
||||
|
||||
log(message.str());
|
||||
|
||||
+28
-20
@@ -164,6 +164,12 @@ struct WantsVstTimeInfo {};
|
||||
*/
|
||||
struct WantsString {};
|
||||
|
||||
/**
|
||||
* The event handler (the Wine VST host) should create a Winn32 window, pass
|
||||
* that to the plugin, and return an X11 window handle.
|
||||
*/
|
||||
struct WantsWindowHandle {};
|
||||
|
||||
/**
|
||||
* VST events are passed a void pointer that can contain a variety of different
|
||||
* data types depending on the event's opcode. This is typically either:
|
||||
@@ -197,27 +203,27 @@ using EventPayload = std::variant<std::nullptr_t,
|
||||
DynamicVstEvents,
|
||||
WantsChunkBuffer,
|
||||
WantsVstTimeInfo,
|
||||
WantsString>;
|
||||
WantsString,
|
||||
WantsWindowHandle>;
|
||||
|
||||
template <typename S>
|
||||
void serialize(S& s, EventPayload& payload) {
|
||||
s.ext(payload, bitsery::ext::StdVariant{
|
||||
[](S&, std::nullptr_t&) {},
|
||||
[](S& s, std::string& string) {
|
||||
// `binary_buffer_size` and not `max_string_length`
|
||||
// because we also use this to send back large chunk
|
||||
// data
|
||||
s.text1b(string, binary_buffer_size);
|
||||
},
|
||||
[](S& s, AEffect& effect) { s.object(effect); },
|
||||
[](S& s, DynamicVstEvents& events) {
|
||||
s.container(events.events, max_midi_events,
|
||||
[](S& s, VstEvent& event) {
|
||||
s.container1b(event.dump);
|
||||
});
|
||||
},
|
||||
[](S&, WantsChunkBuffer&) {},
|
||||
[](S&, WantsVstTimeInfo&) {}, [](S&, WantsString&) {}});
|
||||
s.ext(payload,
|
||||
bitsery::ext::StdVariant{
|
||||
[](S&, std::nullptr_t&) {},
|
||||
[](S& s, std::string& string) {
|
||||
// `binary_buffer_size` and not `max_string_length` because we
|
||||
// also use this to send back large chunk data
|
||||
s.text1b(string, binary_buffer_size);
|
||||
},
|
||||
[](S& s, AEffect& effect) { s.object(effect); },
|
||||
[](S& s, DynamicVstEvents& events) {
|
||||
s.container(
|
||||
events.events, max_midi_events,
|
||||
[](S& s, VstEvent& event) { s.container1b(event.dump); });
|
||||
},
|
||||
[](S&, WantsChunkBuffer&) {}, [](S&, WantsVstTimeInfo&) {},
|
||||
[](S&, WantsString&) {}, [](S&, WantsWindowHandle&) {}});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -270,9 +276,10 @@ struct Event {
|
||||
* instenad.
|
||||
* - A specific struct in response to an event such as `audioMasterGetTime` or
|
||||
* `audioMasterIOChanged`.
|
||||
* - An X11 window pointer for the editor window.
|
||||
*/
|
||||
using EventResposnePayload =
|
||||
std::variant<std::monostate, std::string, AEffect, VstTimeInfo>;
|
||||
std::variant<std::monostate, std::string, AEffect, VstTimeInfo, intptr_t>;
|
||||
|
||||
template <typename S>
|
||||
void serialize(S& s, EventResposnePayload& payload) {
|
||||
@@ -286,7 +293,8 @@ void serialize(S& s, EventResposnePayload& payload) {
|
||||
s.text1b(string, binary_buffer_size);
|
||||
},
|
||||
[](S& s, AEffect& effect) { s.object(effect); },
|
||||
[](S& s, VstTimeInfo& time_info) { s.object(time_info); }});
|
||||
[](S& s, VstTimeInfo& time_info) { s.object(time_info); },
|
||||
[](S& s, intptr_t& v) { s.value8b(v); }});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user