mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-06 19:40:10 +02:00
Handle absolute ConfigureNotify events for parent window
For VST2 in Ardour, it seems Ardour is doing its own WM/wrapper window thing too. In this case, the plugin gets absolute ConfigureNotify events that are already in the root coordinate space, so just use those coordinates and ignore the host window. Also fix the dimensions, which should always be those of the parent window, not the host window. If the parent is the host window, still track its geometry separately, and just don't add in the host window dimensions in this case either.
This commit is contained in:
committed by
Robbert van der Helm
parent
dd36bb3d3b
commit
2e1dcb2316
+33
-10
@@ -265,6 +265,7 @@ Editor::Editor(MainContext& main_context,
|
||||
wrapper_window_size_(initial_size.value_or(Size(128, 128))),
|
||||
host_window_config_({}),
|
||||
parent_window_config_({}),
|
||||
parent_window_config_abs_(false),
|
||||
// Create a window without any decoratiosn for easy embedding. The
|
||||
// combination of `WS_EX_TOOLWINDOW` and `WS_POPUP` causes the window to
|
||||
// be drawn without any decorations (making resizes behave as you'd
|
||||
@@ -497,7 +498,12 @@ void Editor::handle_x11_events() noexcept {
|
||||
generic_event.get());
|
||||
logger_.log_editor_trace([&]() {
|
||||
return "DEBUG: ConfigureNotify for window " +
|
||||
std::to_string(event->window);
|
||||
std::to_string(event->window) + " : " +
|
||||
std::to_string(event->width) + "x" +
|
||||
std::to_string(event->height) + "+" +
|
||||
std::to_string(event->x) + "+" +
|
||||
std::to_string(event->y) +
|
||||
(is_synthetic_event ? " (synthetic)" : "");
|
||||
});
|
||||
|
||||
// If the host window is different from the parent window
|
||||
@@ -507,12 +513,17 @@ void Editor::handle_x11_events() noexcept {
|
||||
// the window manager, while the parent window might receive
|
||||
// position changes relative to the host window when it is a
|
||||
// child window.
|
||||
//
|
||||
// For VST2 plugins in Ardour, there seems to be an
|
||||
// intermediate wrapper window. However, this window
|
||||
// receives synthetic (absolute) ConfigureNotify events, so
|
||||
// in this case we keep track of its position directly.
|
||||
if (event->window == host_window_ && is_synthetic_event) {
|
||||
host_window_config_ = *event;
|
||||
}
|
||||
if (event->window == parent_window_ &&
|
||||
host_window_ != parent_window_ && !is_synthetic_event) {
|
||||
if (event->window == parent_window_) {
|
||||
parent_window_config_ = *event;
|
||||
parent_window_config_abs_ = is_synthetic_event;
|
||||
}
|
||||
|
||||
// Window managers are expected to send ConfigureNotify to
|
||||
@@ -528,13 +539,25 @@ void Editor::handle_x11_events() noexcept {
|
||||
translated_event.response_type = XCB_CONFIGURE_NOTIFY;
|
||||
translated_event.event = wine_window_;
|
||||
translated_event.window = wine_window_;
|
||||
translated_event.width = event->width;
|
||||
translated_event.height = event->height;
|
||||
translated_event.x =
|
||||
host_window_config_.x + parent_window_config_.x;
|
||||
translated_event.y =
|
||||
host_window_config_.y + parent_window_config_.y;
|
||||
|
||||
translated_event.width = parent_window_config_.width;
|
||||
translated_event.height = parent_window_config_.height;
|
||||
translated_event.x = parent_window_config_.x;
|
||||
translated_event.y = parent_window_config_.y;
|
||||
if (!parent_window_config_abs_ &&
|
||||
parent_window_ != host_window_) {
|
||||
translated_event.x += host_window_config_.x;
|
||||
translated_event.y += host_window_config_.y;
|
||||
}
|
||||
logger_.log_editor_trace([&]() {
|
||||
return "DEBUG: Translated coords: " +
|
||||
std::to_string(translated_event.window) +
|
||||
" : " +
|
||||
std::to_string(translated_event.width) +
|
||||
"x" +
|
||||
std::to_string(translated_event.height) +
|
||||
"+" + std::to_string(translated_event.x) +
|
||||
"+" + std::to_string(translated_event.y);
|
||||
});
|
||||
xcb_send_event(
|
||||
x11_connection_.get(), false, wine_window_,
|
||||
XCB_EVENT_MASK_STRUCTURE_NOTIFY |
|
||||
|
||||
@@ -343,6 +343,7 @@ class Editor {
|
||||
*/
|
||||
xcb_configure_notify_event_t host_window_config_;
|
||||
xcb_configure_notify_event_t parent_window_config_;
|
||||
bool parent_window_config_abs_;
|
||||
|
||||
/**
|
||||
* The handle for the window created through Wine that the plugin uses to
|
||||
|
||||
Reference in New Issue
Block a user