From c0eafc85fd4453292463f69646209d39dc0e9327 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sun, 12 Apr 2020 19:42:12 +0200 Subject: [PATCH] Re-introduce window resizing while draggin --- src/wine-host/editor.cpp | 18 ++++++++++++++---- src/wine-host/editor.h | 8 ++++++++ src/wine-host/plugin-bridge.cpp | 11 +++++++++++ 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/wine-host/editor.cpp b/src/wine-host/editor.cpp index bc353f55..5a2c23dd 100644 --- a/src/wine-host/editor.cpp +++ b/src/wine-host/editor.cpp @@ -48,6 +48,16 @@ HWND Editor::open(AEffect* effect) { return win32_handle->get(); } +bool Editor::resize(const int width, const int height) { + if (!win32_handle.has_value()) { + return false; + } + + SetWindowPos(win32_handle->get(), HWND_TOP, 0, 0, width, height, 0); + + return true; +} + void Editor::close() { // RAII will destroy the window and tiemrs for us win32_handle = std::nullopt; @@ -129,10 +139,6 @@ void Editor::handle_events() { break; } - // The client area of the Win32 window doesn't expand - // automatically - SetWindowPos(win32_handle->get(), HWND_TOP, 0, 0, - event.width, event.height, 0); // We're purposely not using XEmbed. This has the // consequence that wine still thinks that any X and Y @@ -156,6 +162,10 @@ void Editor::handle_events() { XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY, reinterpret_cast(&translated_event)); xcb_flush(x11_connection.get()); + + // The client area of the Win32 window doesn't expand + // automatically + resize(event.width, event.height); } break; } free(generic_event); diff --git a/src/wine-host/editor.h b/src/wine-host/editor.h index 14651cae..43d9dbf4 100644 --- a/src/wine-host/editor.h +++ b/src/wine-host/editor.h @@ -57,6 +57,14 @@ class Editor { void close(); + /** + * Resize the window to match the given size, if open. + * + * @return Whether the resizing was succesful. Will return false if the + * editor isn't open. + */ + bool resize(const int width, const int height); + /** * Embed the (open) window into a parent window. * diff --git a/src/wine-host/plugin-bridge.cpp b/src/wine-host/plugin-bridge.cpp index ea0c8716..13b4ff0e 100644 --- a/src/wine-host/plugin-bridge.cpp +++ b/src/wine-host/plugin-bridge.cpp @@ -298,6 +298,17 @@ class HostCallbackDataConverter : DefaultDataConverter { case audioMasterGetTime: return WantsVstTimeInfo{}; break; + case audioMasterSizeWindow: + // Plugins use this opcode to indicate that their editor should + // be resized. This is handled implicitly when handling the + // ConfigureNotify X11 events but handling this here as well + // makes the resizing look much smoother. + // TODO: Check if this actually makes drag resizing feel better, + // otherwise just remove this + editor.resize(value, index); + + return DefaultDataConverter::read(opcode, index, value, data); + break; case audioMasterIOChanged: // This is a helpful event that indicates that the VST plugin's // `AEffect` struct has changed. Writing these results back is