Skip to content

Commit

Permalink
Send a Resized event after ScaleFactorChanged
Browse files Browse the repository at this point in the history
  • Loading branch information
nixpulvis committed Nov 6, 2023
1 parent e921055 commit b926337
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/platform_impl/macos/app_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,21 +329,27 @@ impl Handler {
) {
if let Some(ref mut callback) = *self.callback.lock().unwrap() {
let new_inner_size = Arc::new(Mutex::new(suggested_size));
let event = Event::WindowEvent {
let scale_factor_changed_event = Event::WindowEvent {
window_id: WindowId(window.id()),
event: WindowEvent::ScaleFactorChanged {
scale_factor,
inner_size_writer: InnerSizeWriter::new(Arc::downgrade(&new_inner_size)),
},
};

callback.handle_nonuser_event(event);
callback.handle_nonuser_event(scale_factor_changed_event);

let physical_size = *new_inner_size.lock().unwrap();
drop(new_inner_size);
let logical_size = physical_size.to_logical(scale_factor);
let size = NSSize::new(logical_size.width, logical_size.height);
window.setContentSize(size);

let resized_event = Event::WindowEvent {
window_id: WindowId(window.id()),
event: WindowEvent::Resized(physical_size),
};
callback.handle_nonuser_event(resized_event);
}
}
}
Expand Down

0 comments on commit b926337

Please sign in to comment.