mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-10 04:30:12 +02:00
Split X11 and Win32 event handling
X11 events should always be handled since it's thread safe and they don't block.
This commit is contained in:
@@ -152,7 +152,8 @@ void Vst2Bridge::handle_dispatch_single() {
|
|||||||
plugin, std::bind(&Vst2Bridge::dispatch_wrapper,
|
plugin, std::bind(&Vst2Bridge::dispatch_wrapper,
|
||||||
this, _1, _2, _3, _4, _5, _6)));
|
this, _1, _2, _3, _4, _5, _6)));
|
||||||
|
|
||||||
pump_message_loop();
|
handle_win32_events();
|
||||||
|
handle_x11_events();
|
||||||
}
|
}
|
||||||
} catch (const boost::system::system_error&) {
|
} catch (const boost::system::system_error&) {
|
||||||
// The plugin has cut off communications, so we can shut down this host
|
// The plugin has cut off communications, so we can shut down this host
|
||||||
|
|||||||
@@ -126,10 +126,11 @@ class Vst2Bridge {
|
|||||||
plugin, opcode, index, value, data, option);
|
plugin, opcode, index, value, data, option);
|
||||||
|
|
||||||
dispatch_result.set_value(result);
|
dispatch_result.set_value(result);
|
||||||
|
|
||||||
if (!message_loop_blocked()) {
|
if (!message_loop_blocked()) {
|
||||||
pump_message_loop();
|
handle_win32_events();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handle_x11_events();
|
||||||
});
|
});
|
||||||
|
|
||||||
return dispatch_result.get_future().get();
|
return dispatch_result.get_future().get();
|
||||||
|
|||||||
@@ -87,9 +87,9 @@ Editor::Editor(const std::string& window_class_name,
|
|||||||
// The Win32 API will block the `DispatchMessage` call when opening e.g. a
|
// The Win32 API will block the `DispatchMessage` call when opening e.g. a
|
||||||
// dropdown, but it will still allow timers to be run so the GUI can still
|
// dropdown, but it will still allow timers to be run so the GUI can still
|
||||||
// update in the background. Because of this we send `effEditIdle` to the
|
// update in the background. Because of this we send `effEditIdle` to the
|
||||||
// plugin on a timer. The refresh rate is purposely fairly low since we
|
// plugin on a timer. The refresh rate is purposely fairly low since the
|
||||||
// we'll also trigger this manually in `Editor::handle_events()` whenever
|
// host will call `effEditIdle()` explicitely when the plugin is not busy.
|
||||||
// the plugin is not busy.
|
// TODO: Add a `KillTimer()` now that we are hosting multiple plugins
|
||||||
SetTimer(win32_handle.get(), idle_timer_id, 100, nullptr);
|
SetTimer(win32_handle.get(), idle_timer_id, 100, nullptr);
|
||||||
|
|
||||||
// We need to tell the Wine window it has been moved whenever the window
|
// We need to tell the Wine window it has been moved whenever the window
|
||||||
@@ -137,7 +137,7 @@ void Editor::send_idle_event() {
|
|||||||
plugin->dispatcher(plugin, effEditIdle, 0, 0, nullptr, 0);
|
plugin->dispatcher(plugin, effEditIdle, 0, 0, nullptr, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Editor::handle_events() {
|
void Editor::handle_win32_events() {
|
||||||
MSG msg;
|
MSG msg;
|
||||||
|
|
||||||
// The null value for the second argument is needed to handle interaction
|
// The null value for the second argument is needed to handle interaction
|
||||||
@@ -158,8 +158,9 @@ void Editor::handle_events() {
|
|||||||
TranslateMessage(&msg);
|
TranslateMessage(&msg);
|
||||||
DispatchMessage(&msg);
|
DispatchMessage(&msg);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Handle X11 events
|
void Editor::handle_x11_events() {
|
||||||
// TODO: Initiating drag-and-drop in Serum _sometimes_ causes the GUI to
|
// TODO: Initiating drag-and-drop in Serum _sometimes_ causes the GUI to
|
||||||
// update while dragging while other times it does not. From all the
|
// update while dragging while other times it does not. From all the
|
||||||
// plugins I've tested this only happens in Serum though.
|
// plugins I've tested this only happens in Serum though.
|
||||||
@@ -195,6 +196,8 @@ void Editor::handle_events() {
|
|||||||
// We can't directly use the `event.x` and `event.y` coordinates
|
// We can't directly use the `event.x` and `event.y` coordinates
|
||||||
// because the parent window may also be embedded inside another
|
// because the parent window may also be embedded inside another
|
||||||
// window.
|
// window.
|
||||||
|
// TODO: With plugin groups this has to be done any time the
|
||||||
|
// mouse cursor enters the window on a FOCUS_IN event
|
||||||
const auto translate_cookie = xcb_translate_coordinates(
|
const auto translate_cookie = xcb_translate_coordinates(
|
||||||
x11_connection.get(), parent_window, root, 0, 0);
|
x11_connection.get(), parent_window, root, 0, 0);
|
||||||
const xcb_translate_coordinates_reply_t*
|
const xcb_translate_coordinates_reply_t*
|
||||||
|
|||||||
@@ -101,11 +101,16 @@ class Editor {
|
|||||||
void send_idle_event();
|
void send_idle_event();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pump messages from the editor GUI's event loop until all events are
|
* Pump messages from the editor loop loop until all events are process.
|
||||||
* process. Must be run from the same thread the GUI was created in because
|
* Must be run from the same thread the GUI was created in because of Win32
|
||||||
* of Win32 limitations.
|
* limitations.
|
||||||
*/
|
*/
|
||||||
void handle_events();
|
void handle_win32_events();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle X11 events sent to the window our editor is embedded in.
|
||||||
|
*/
|
||||||
|
void handle_x11_events();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user