diff --git a/src/wine-host/bridges/common.cpp b/src/wine-host/bridges/common.cpp index 01bd6359..2aeda267 100644 --- a/src/wine-host/bridges/common.cpp +++ b/src/wine-host/bridges/common.cpp @@ -18,24 +18,3 @@ HostBridge::HostBridge(boost::filesystem::path plugin_path) : plugin_path(plugin_path) {} - -void HostBridge::handle_win32_events() { - if (editor) { - editor->handle_win32_events(); - } else { - MSG msg; - - for (int i = 0; i < max_win32_messages && - PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE); - i++) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - } -} - -void HostBridge::handle_x11_events() { - if (editor) { - editor->handle_x11_events(); - } -} diff --git a/src/wine-host/bridges/common.h b/src/wine-host/bridges/common.h index efefd9ee..d9176725 100644 --- a/src/wine-host/bridges/common.h +++ b/src/wine-host/bridges/common.h @@ -16,7 +16,9 @@ #pragma once -#include "../editor.h" +#include "../boost-fix.h" + +#include /** * The base for the Wine plugin host bridge interface for all plugin types. This @@ -47,7 +49,7 @@ class HostBridge { * Handle X11 events for the editor window if it is open. This can safely be * run from any thread. */ - void handle_x11_events(); + virtual void handle_x11_events() = 0; /** * Run the message loop for this plugin. This is only used for the @@ -63,25 +65,12 @@ class HostBridge { * we have to make sure to always run this loop. The only exception is a in * specific situation that can cause a race condition in some plugins * because of incorrect assumptions made by the plugin. See the dostring for - * `HostBridge::editor` for more information. + * `Vst2Bridge::editor` for more information. */ - void handle_win32_events(); + virtual void handle_win32_events() = 0; /** * The path to the .dll being loaded in the Wine plugin host. */ const boost::filesystem::path plugin_path; - - protected: - /** - * The plugin editor window. Allows embedding the plugin's editor into a - * Wine window, and embedding that Wine window into a window provided by the - * host. Should be empty when the editor is not open. - * - * TODO: This should be moved back to `Vst2Bridge`, `handle_x11_events()`` - * and `handle_win32_events()` should be made pure virtual. A single - * `Vst3Bridge` instance will handle multiple plugin instances because - * of the way VST3 works. - */ - std::optional editor; }; diff --git a/src/wine-host/bridges/group.h b/src/wine-host/bridges/group.h index 47a1c759..f72e4938 100644 --- a/src/wine-host/bridges/group.h +++ b/src/wine-host/bridges/group.h @@ -27,6 +27,7 @@ #include #include "../common/logging/common.h" +#include "../utils.h" #include "common.h" /** diff --git a/src/wine-host/bridges/vst2.cpp b/src/wine-host/bridges/vst2.cpp index 86f58ab9..60b29992 100644 --- a/src/wine-host/bridges/vst2.cpp +++ b/src/wine-host/bridges/vst2.cpp @@ -350,6 +350,27 @@ void Vst2Bridge::run() { }); } +void Vst2Bridge::handle_x11_events() { + if (editor) { + editor->handle_x11_events(); + } +} + +void Vst2Bridge::handle_win32_events() { + if (editor) { + editor->handle_win32_events(); + } else { + MSG msg; + + for (int i = 0; i < max_win32_messages && + PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE); + i++) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + } +} + intptr_t Vst2Bridge::dispatch_wrapper(AEffect* plugin, int opcode, int index, diff --git a/src/wine-host/bridges/vst2.h b/src/wine-host/bridges/vst2.h index c7f68f04..63848d91 100644 --- a/src/wine-host/bridges/vst2.h +++ b/src/wine-host/bridges/vst2.h @@ -29,6 +29,7 @@ #include "../../common/communication/vst2.h" #include "../../common/configuration.h" +#include "../editor.h" #include "../utils.h" #include "common.h" @@ -66,6 +67,9 @@ class Vst2Bridge : public HostBridge { */ void run() override; + void handle_x11_events() override; + void handle_win32_events() override; + /** * Forward the host callback made by the plugin to the host and return the * results. @@ -144,6 +148,13 @@ class Vst2Bridge : public HostBridge { */ Vst2Sockets sockets; + /** + * The plugin editor window. Allows embedding the plugin's editor into a + * Wine window, and embedding that Wine window into a window provided by the + * host. Should be empty when the editor is not open. + */ + std::optional editor; + /** * The MIDI events that have been received **and processed** since the last * call to `processReplacing()`. 99% of plugins make a copy of the MIDI diff --git a/src/wine-host/bridges/vst3.cpp b/src/wine-host/bridges/vst3.cpp index 5a1767d5..fe9bf891 100644 --- a/src/wine-host/bridges/vst3.cpp +++ b/src/wine-host/bridges/vst3.cpp @@ -423,6 +423,23 @@ void Vst3Bridge::run() { }}); } +void Vst3Bridge::handle_x11_events() { + // TODO: Implement editors +} + +void Vst3Bridge::handle_win32_events() { + // TODO: Implement editors + + MSG msg; + + for (int i = 0; + i < max_win32_messages && PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE); + i++) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } +} + size_t Vst3Bridge::generate_instance_id() { return current_instance_id.fetch_add(1); } diff --git a/src/wine-host/bridges/vst3.h b/src/wine-host/bridges/vst3.h index 1a955268..ff734630 100644 --- a/src/wine-host/bridges/vst3.h +++ b/src/wine-host/bridges/vst3.h @@ -22,6 +22,7 @@ #include "../../common/communication/vst3.h" #include "../../common/configuration.h" +#include "../editor.h" #include "common.h" /** @@ -103,6 +104,9 @@ class Vst3Bridge : public HostBridge { */ void run() override; + void handle_x11_events() override; + void handle_win32_events() override; + /** * Send a callback message to the host return the response. This is a * shorthand for `sockets.vst_host_callback.send_message` for use in VST3 diff --git a/src/wine-host/editor.h b/src/wine-host/editor.h index 41ff5f38..c75523c1 100644 --- a/src/wine-host/editor.h +++ b/src/wine-host/editor.h @@ -14,6 +14,8 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . +#pragma once + // Use the native version of xcb #pragma push_macro("_WIN32") #undef _WIN32