From 3eae618a7ff94c9c49a1706e2963145baa9045bf Mon Sep 17 00:00:00 2001 From: Adrien Prokopowicz <6529475+prokopyl@users.noreply.github.com> Date: Wed, 7 Oct 2026 17:37:50 +0200 Subject: [PATCH] Delay parent resize request until after window is shown --- src/platform/win/window.rs | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/platform/win/window.rs b/src/platform/win/window.rs index 66f7c95b..230a0013 100644 --- a/src/platform/win/window.rs +++ b/src/platform/win/window.rs @@ -230,6 +230,9 @@ pub struct BaseviewWindow { handler: OnceCell>, host: Host, + // Workaround some VST3 hosts (e.g. Bitwig) not allowing request_resize before show() occurs + pub host_needs_new_size_notified_on_show: Cell>>, + // Things not directly used, but kept so their Drop impl runs when the window is destroyed _keyboard_hook: Cell>, _drop_target: Cell>>, @@ -267,6 +270,7 @@ impl BaseviewWindow { handler: OnceCell::new(), shared_state, host: init.host, + host_needs_new_size_notified_on_show: None.into(), _drop_target: None.into(), _keyboard_hook: None.into(), @@ -395,19 +399,15 @@ impl WindowImpl for BaseviewWindow { )?; window.resize_and_activate(new_size, dpi, &guard)?; - let _ = self.adapt_host_window_to_size( - previous_size, - WindowSize::from_physical(new_size, dpi.scale_factor()), - ); + self.host_needs_new_size_notified_on_show.set(Some(previous_size)); } else { // If the host queried size before it gave us a parent, this is the one it's been using. let previous_host_size = self.initial_size.to_physical(1.0); let current_size = self.initial_size.to_physical(dpi.scale_factor()); - let _ = self.adapt_host_window_to_size( - previous_host_size, - WindowSize::from_physical(current_size, dpi.scale_factor()), - ); + if previous_host_size != current_size { + self.host_needs_new_size_notified_on_show.set(Some(previous_host_size)); + } } } @@ -676,6 +676,19 @@ unsafe fn wnd_proc_inner( None } + WM_SHOWWINDOW => { + if let Some(previous_size) = window_bv.host_needs_new_size_notified_on_show.take() { + let new_size = window_state.shared.current_size.get(); + let dpi = window_state.shared.current_dpi.get(); + + let _ = window_bv.adapt_host_window_to_size( + previous_size, + WindowSize::from_physical(new_size, dpi.scale_factor()), + ); + } + + None + } WM_DPICHANGED => { let suggested_nc_rect = Rect((lparam as *const RECT).read()); let Some(dpi) = NonZeroU32::new((wparam & 0xFFFF) as u16 as u32) else {