Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions src/platform/win/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,9 @@ pub struct BaseviewWindow {
handler: OnceCell<Box<dyn WindowHandler>>,
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<Option<PhysicalSize<u32>>>,

// Things not directly used, but kept so their Drop impl runs when the window is destroyed
_keyboard_hook: Cell<Option<hook::KeyboardHookHandle>>,
_drop_target: Cell<Option<ComObject<DropTarget>>>,
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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));
}
}
}

Expand Down Expand Up @@ -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 {
Expand Down
Loading