Completely run effEditIdle from a timer

Although it hasn't shown up, this will get rid of the possibility of
off-thread effEditIdle calls causing issues. And since we need some way
to run call this function while the event loop is running anyways, doing
it entirely from a timer similar to how hosts on Windows would do it
seems like the best solution.
This commit is contained in:
Robbert van der Helm
2021-01-04 15:50:17 +01:00
parent c554b9b4ab
commit 4ec8b01bcc
7 changed files with 109 additions and 15 deletions
+33 -1
View File
@@ -25,6 +25,7 @@
#define WINE_NOWINSOCK
#endif
#include <windows.h>
#include <function2/function2.hpp>
// Use the native version of xcb
#pragma push_macro("_WIN32")
@@ -99,10 +100,16 @@ class Editor {
* editor behaviours.
* @param parent_window_handle The X11 window handle passed by the VST host
* for the editor to embed itself into.
* @param timer_proc A function to run on a timer. This is used for VST2
* plugins to periodically call `effEditIdle` from the message loop
* thread, even when the GUI is blocked.
*
* @see win32_handle
*/
Editor(const Configuration& config, const size_t parent_window_handle);
Editor(
const Configuration& config,
const size_t parent_window_handle,
std::optional<fu2::unique_function<void()>> timer_proc = std::nullopt);
~Editor();
@@ -147,6 +154,14 @@ class Editor {
*/
void set_input_focus(bool grab) const;
/**
* Run the timer proc function passed to the constructor, if one was passed.
*
* @see idle_timer
* @see idle_timer_proc
*/
void maybe_run_timer_proc();
/**
* Whether to use XEmbed instead of yabridge's normal window embedded. Wine
* with XEmbed tends to cause rendering issues, so it's disabled by default.
@@ -236,6 +251,23 @@ class Editor {
#pragma GCC diagnostic pop
/**
* A timer we'll use to periodically run `idle_timer_proc`, if set. Thisi is
* only needed for VST2 plugins, as they expected the host to periodically
* send an idle event. We used to just pass through the calls from the host
* before yabridge 3.x, but doing it ourselves here makes things m much more
* manageable and we'd still need a timer anyways for when the GUI is
* blocked.
*/
Win32Timer idle_timer;
/**
* A function to call when the Win32 timer procs. This is used to
* periodically call `effEditIdle()` for VST2 plugins even if the GUI is
* being blocked.
*/
std::optional<fu2::unique_function<void()>> idle_timer_proc;
/**
* The window handle of the editor window created by the DAW.
*/