Skip to content

Commit

Permalink
fix(macos::app_state): fix unwanted deviation when drag around monito…
Browse files Browse the repository at this point in the history
…r boundaries (#923)
  • Loading branch information
BillGoldenWater authored May 7, 2024
1 parent f06843b commit 2d6ad2d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changes/fix-macos-drag-deviation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tao": patch
---

Fix unwanted deviation when dragging window around monitor boundaries on macOS.
13 changes: 7 additions & 6 deletions src/platform_impl/macos/app_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,21 +226,22 @@ impl Handler {
scale_factor: f64,
) {
let mut size = suggested_size.to_physical(scale_factor);
let new_inner_size = &mut size;
let old_size = size.clone();
let event = Event::WindowEvent {
window_id: WindowId(get_window_id(*ns_window)),
event: WindowEvent::ScaleFactorChanged {
scale_factor,
new_inner_size,
new_inner_size: &mut size,
},
};

callback.handle_nonuser_event(event, &mut *self.control_flow.lock().unwrap());

let physical_size = *new_inner_size;
let logical_size = physical_size.to_logical(scale_factor);
let size = NSSize::new(logical_size.width, logical_size.height);
unsafe { NSWindow::setContentSize_(*ns_window, size) };
if old_size != size {
let logical_size = size.to_logical(scale_factor);
let size = NSSize::new(logical_size.width, logical_size.height);
unsafe { NSWindow::setContentSize_(*ns_window, size) };
}
}

fn handle_proxy(&self, proxy: EventProxy, callback: &mut Box<dyn EventHandler + 'static>) {
Expand Down

0 comments on commit 2d6ad2d

Please sign in to comment.