Skip to content

Commit

Permalink
fix: request logical size when autosizing
Browse files Browse the repository at this point in the history
  • Loading branch information
wash2 committed Nov 19, 2024
1 parent d7b189d commit 501d7aa
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions winit/src/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ mod state;
mod window_manager;

pub use runtime::{default, Appearance, DefaultStyle};
use winit::dpi::PhysicalSize;
use winit::event_loop::OwnedDisplayHandle;

use crate::conversion;
Expand Down Expand Up @@ -1557,15 +1558,12 @@ async fn run_instance<'a, P, C>(
if let Some(requested_size) =
clipboard.requested_logical_size.lock().unwrap().take()
{
let requested_physical_size =
winit::dpi::PhysicalSize::new(
(requested_size.width as f64
* window.state.scale_factor())
.ceil() as u32,
(requested_size.height as f64
* window.state.scale_factor())
.ceil() as u32,
let requested_physical_size: PhysicalSize<u32> =
winit::dpi::PhysicalSize::from_logical(
requested_size.cast::<u32>(),
window.state.scale_factor(),
);

let physical_size = window.state.physical_size();
if requested_physical_size.width != physical_size.width
|| requested_physical_size.height
Expand All @@ -1576,8 +1574,8 @@ async fn run_instance<'a, P, C>(
window.resize_enabled = true;
resized = true;
needs_redraw = true;
let s = winit::dpi::Size::Physical(
requested_physical_size,
let s = winit::dpi::Size::Logical(
requested_size.cast(),
);
_ = window.raw.request_surface_size(s);
window.raw.set_min_surface_size(Some(s));
Expand Down

0 comments on commit 501d7aa

Please sign in to comment.