Move the editor handling back to Vst2Bridge

Since we can have multiple editors in Vst3Bridge.
This commit is contained in:
Robbert van der Helm
2020-12-19 19:56:49 +01:00
parent b422f6fd42
commit a724b378fe
8 changed files with 62 additions and 38 deletions
-21
View File
@@ -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();
}
}
+6 -17
View File
@@ -16,7 +16,9 @@
#pragma once
#include "../editor.h"
#include "../boost-fix.h"
#include <boost/filesystem.hpp>
/**
* 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> editor;
};
+1
View File
@@ -27,6 +27,7 @@
#include <thread>
#include "../common/logging/common.h"
#include "../utils.h"
#include "common.h"
/**
+21
View File
@@ -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,
+11
View File
@@ -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<Win32Thread> 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> 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
+17
View File
@@ -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);
}
+4
View File
@@ -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
+2
View File
@@ -14,6 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#pragma once
// Use the native version of xcb
#pragma push_macro("_WIN32")
#undef _WIN32