mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-06 19:40:10 +02:00
Work around wrong offset in plugin windows
This commit is contained in:
committed by
Robbert van der Helm
parent
cca3189855
commit
44d047e9e2
@@ -417,6 +417,27 @@ void Editor::show() noexcept {
|
||||
ShowWindow(win32_window_.handle_, SW_SHOWNORMAL);
|
||||
}
|
||||
|
||||
std::array<int16_t, 2> Editor::get_parent_window_offset() {
|
||||
|
||||
xcb_generic_error_t* error = nullptr;
|
||||
const xcb_window_t root =
|
||||
get_root_window(*x11_connection_, parent_window_);
|
||||
const xcb_translate_coordinates_cookie_t coord_cookie =
|
||||
xcb_translate_coordinates(x11_connection_.get(), parent_window_, root, 0, 0);
|
||||
const std::unique_ptr<xcb_translate_coordinates_reply_t> coord_reply(
|
||||
xcb_translate_coordinates_reply(x11_connection_.get(), coord_cookie, &error));
|
||||
THROW_X11_ERROR(error);
|
||||
|
||||
logger_.log_editor_trace([&]() {
|
||||
return "DEBUG: Parent window offset " +
|
||||
std::to_string(coord_reply->dst_x) +
|
||||
"x" +
|
||||
std::to_string(coord_reply->dst_y);
|
||||
});
|
||||
return {coord_reply->dst_x, coord_reply->dst_y};
|
||||
}
|
||||
|
||||
|
||||
void Editor::handle_x11_events() noexcept {
|
||||
// NOTE: Ardour will unmap the window instead of closing the editor. When
|
||||
// the window is unmapped `wine_window_` doesn't exist and any X11
|
||||
@@ -454,7 +475,6 @@ void Editor::handle_x11_events() noexcept {
|
||||
", generated from " +
|
||||
std::to_string(event->event);
|
||||
});
|
||||
|
||||
redetect_host_window();
|
||||
|
||||
// If the `editor_force_dnd` option is set, we'll strip
|
||||
@@ -560,6 +580,11 @@ void Editor::handle_x11_events() noexcept {
|
||||
translated_event.x += host_window_config_.x;
|
||||
translated_event.y += host_window_config_.y;
|
||||
}
|
||||
if (!is_synthetic_event) {
|
||||
const std::array<int16_t, 2> offset = get_parent_window_offset();
|
||||
translated_event.x = offset[0];
|
||||
translated_event.y = offset[1];
|
||||
}
|
||||
logger_.log_editor_trace([&]() {
|
||||
return "DEBUG: Translated coords: " +
|
||||
std::to_string(translated_event.window) +
|
||||
|
||||
@@ -311,6 +311,11 @@ class Editor {
|
||||
*/
|
||||
void redetect_host_window() noexcept;
|
||||
|
||||
/**
|
||||
* Get offset of parent window to fix mouse coordinates.
|
||||
*/
|
||||
std::array<int16_t, 2> get_parent_window_offset();
|
||||
|
||||
/**
|
||||
* Reparent `child` to `new_parent`. This includes the flush.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user