From b84aa18ecf8c2f11bcf5d74bc3b9158409f586dd Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Mon, 16 Aug 2021 21:31:57 +0200 Subject: [PATCH] Only reset coordinates when resizing This was the original idea. I though that to be extra safe, maybe we can do this all the time. And while that does work fine, most of the time, it does cause a lot of other fun issues especially when plugins fully redraw themselves that way. --- CHANGELOG.md | 8 ++++---- src/wine-host/editor.cpp | 29 ++++++++++++----------------- 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5dae7ba6..09b63639 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,10 +23,10 @@ Versioning](https://semver.org/spec/v2.0.0.html). ### Changed - Yabridge's Wine window embedding now takes more measures to make sure that the - plugin draws itself properly in the top left corner of the window. This is - needed for some buggy plugins that draw window based on absolute screen - coordinates, instead of their positioning within the parent window, like the - _Soundtoys_ plugins and older _PSPaudioware_ plugins. + plugin draws itself properly in the top left corner of the window when windows + are being resized. This is needed for some buggy plugins that draw window + based on absolute screen coordinates, instead of their positioning within the + parent window, like the _Soundtoys_ plugins and older _PSPaudioware_ plugins. ### Fixed diff --git a/src/wine-host/editor.cpp b/src/wine-host/editor.cpp index 657369eb..bb3332bb 100644 --- a/src/wine-host/editor.cpp +++ b/src/wine-host/editor.cpp @@ -440,6 +440,18 @@ void Editor::resize(uint16_t width, uint16_t height) { value_mask, values.data()); xcb_flush(x11_connection.get()); + // Before lying to Wine about the window's coordinates, we do need to make + // sure that the window is actually placed at (0, 0) coordinates. Otherwise + // some plugins that rely on screen coordinates, like the Soundtoys plugins + // and older PSPaudioware plugins, will draw their GUI at the wrong + // location. + logger.log_editor_trace([]() { + return "DEBUG: Resetting Wine window position back to (0, 0)"; + }); + SetWindowPos(win32_window.handle, nullptr, 0, 0, 0, 0, + SWP_NOSIZE | SWP_NOREDRAW | SWP_NOACTIVATE | SWP_NOCOPYBITS | + SWP_NOOWNERZORDER | SWP_DEFERERASE); + // Make sure that after the resize the screen coordinates always match up // properly. Without this Soundtoys Crystallizer might appear choppy or skip // a frame during their resize animation (which somehow calls @@ -715,23 +727,6 @@ void Editor::fix_local_coordinates() const { return; } - // Before lying to Wine about the window's coordinates, we do need to make - // sure that the window is actually placed at (0, 0) coordinates. Otherwise - // some plugins that rely on screen coordinates, like the Soundtoys plugins - // and older PSPaudioware plugins, will draw their GUI at the wrong - // location. In case we have multiple `ConfiguratioNotify` events in a row, - // we'll only need to do this once. - RECT current_pos{}; - if (GetWindowRect(win32_window.handle, ¤t_pos) || - current_pos.left != 0 || current_pos.top != 0) { - logger.log_editor_trace([]() { - return "DEBUG: Resetting Wine window position back to (0, 0)"; - }); - SetWindowPos(win32_window.handle, nullptr, 0, 0, 0, 0, - SWP_NOSIZE | SWP_NOREDRAW | SWP_NOACTIVATE | - SWP_NOCOPYBITS | SWP_NOOWNERZORDER | SWP_DEFERERASE); - } - // We're purposely not using XEmbed here. This has the consequence that wine // still thinks that any X and Y coordinates are relative to the x11 window // root instead of the parent window provided by the DAW, causing all sorts