From 266674a217eddf59fe7c35123590e070f0ccd5cd Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Mon, 13 Apr 2020 13:54:34 +0200 Subject: [PATCH] Get rid of all SetWindowPos() calls This actually resizes the client area, but the experience feels way better if we just leave it at its maximum size. --- src/wine-host/editor.cpp | 29 ++++++++++++++--------------- src/wine-host/editor.h | 8 -------- src/wine-host/plugin-bridge.cpp | 11 ----------- 3 files changed, 14 insertions(+), 34 deletions(-) diff --git a/src/wine-host/editor.cpp b/src/wine-host/editor.cpp index 5a2c23dd..e9f8341f 100644 --- a/src/wine-host/editor.cpp +++ b/src/wine-host/editor.cpp @@ -25,6 +25,10 @@ HWND Editor::open(AEffect* effect) { // combination of `WS_EX_TOOLWINDOW` and `WS_POPUP` causes the window to be // drawn without any decorations (making resizes behave as you'd expect) and // also causes mouse coordinates to be relative to the window itself. + // TODO: The (maximum) client area is now set at 1440p, to prevent + // unnecessary overhead and to support fullscreen windows at 4k + // resolutions we should just use the dimensions of the X11 root + // window instead. win32_handle = std::unique_ptr, decltype(&DestroyWindow)>( CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_ACCEPTFILES, @@ -48,16 +52,6 @@ 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; @@ -139,7 +133,6 @@ void Editor::handle_events() { break; } - // We're purposely not using XEmbed. This has the // consequence that wine still thinks that any X and Y // coordinates are relative to the x11 window root instead @@ -148,6 +141,16 @@ void Editor::handle_events() { // we'll just lie to Wine and tell it that it's located at // the parent window's location. We'll only send the event // instead of actually configuring the window. + // NOTE: We're not actually using `SetWindowPos()` to resize + // the window. The editor's client area will likely + // always be big enough Since we specified the Window + // to be 2560x1440 pixels large at the time of its + // creation. This works because the embedding + // hierarchy is DAW window -> Win32 window (created in + // this class) -> VST plugin window created by the + // plugin itself. This makes the drag-to-resize + // functionality many plugin editors have feel smooth + // and native. xcb_configure_notify_event_t translated_event{}; translated_event.response_type = XCB_CONFIGURE_NOTIFY; translated_event.event = child_window; @@ -162,10 +165,6 @@ 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 43d9dbf4..14651cae 100644 --- a/src/wine-host/editor.h +++ b/src/wine-host/editor.h @@ -57,14 +57,6 @@ 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 13b4ff0e..ea0c8716 100644 --- a/src/wine-host/plugin-bridge.cpp +++ b/src/wine-host/plugin-bridge.cpp @@ -298,17 +298,6 @@ 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