From fbef37b924394e4d1f079bf6802c75179ccfc12f Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sun, 27 Dec 2020 15:08:01 +0100 Subject: [PATCH] Disable blitting on window position changes This slightly reduces flickering because redraws are now a bit faster. --- CHANGELOG.md | 3 +++ src/wine-host/editor.cpp | 17 +++++++++++++++-- src/wine-host/editor.h | 12 ++++++------ 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c910094..452db89a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,9 @@ TODO: Add an updates screenshot with some fancy VST3-only plugins to the readme - `libyabridge.so` is now called `libyabridge-vst2.so`. If you're using yabridgectl then nothing changes here. **To avoid any confusion in the future, please remove the old `libyabridge.so` file before upgrading.** +- Slightly increased resposniveness when resizing plugin GUIs by preventing + unnecessary blitting. This also reduces flickering with plugins that don't do + double buffering. - VST2 editor idle events are now handled slightly differently. This should result in even more responsive GUIs and I have not come across any plugins where this caused issues, but please let me know if it does break anything for diff --git a/src/wine-host/editor.cpp b/src/wine-host/editor.cpp index ceb441f5..af22697a 100644 --- a/src/wine-host/editor.cpp +++ b/src/wine-host/editor.cpp @@ -97,8 +97,8 @@ WindowClass::~WindowClass() { Editor::Editor(const Configuration& config, const std::string& window_class_name, const size_t parent_window_handle) - : x11_connection(xcb_connect(nullptr, nullptr), xcb_disconnect), - use_xembed(config.editor_xembed), + : use_xembed(config.editor_xembed), + x11_connection(xcb_connect(nullptr, nullptr), xcb_disconnect), client_area(get_maximum_screen_dimensions(*x11_connection)), window_class(window_class_name), // Create a window without any decoratiosn for easy embedding. The @@ -540,6 +540,19 @@ LRESULT CALLBACK window_proc(HWND handle, SetWindowLongPtr(handle, GWLP_USERDATA, reinterpret_cast(editor)); } break; + // Setting `SWP_NOCOPYBITS` somewhat reduces flickering on + // `fix_local_coordinates()` calls with plugins that don't do double + // buffering since it speeds up the redrawing process. + case WM_WINDOWPOSCHANGING: { + auto editor = reinterpret_cast( + GetWindowLongPtr(handle, GWLP_USERDATA)); + if (!editor || editor->use_xembed) { + break; + } + + WINDOWPOS* info = reinterpret_cast(lParam); + info->flags |= SWP_NOCOPYBITS | SWP_DEFERERASE; + } break; // In case the WM does not support the EWMH active window property, // we'll fall back to grabbing focus when the user clicks on the window // by listening to the generated `WM_PARENTNOTIFY` messages. Otherwise diff --git a/src/wine-host/editor.h b/src/wine-host/editor.h index 0d428f8c..0ffce84e 100644 --- a/src/wine-host/editor.h +++ b/src/wine-host/editor.h @@ -151,6 +151,12 @@ class Editor { */ void set_input_focus(bool grab) const; + /** + * 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. + */ + const bool use_xembed; + private: /** * Returns `true` if the currently active window (as per @@ -185,12 +191,6 @@ class Editor { */ std::unique_ptr x11_connection; - /** - * 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. - */ - const bool use_xembed; - /** * The Wine window's client area, or the maximum size of that window. This * will be set to a size that's large enough to be able to enter full screen