diff options
author | 2024-12-06 04:28:06 +0100 | |
---|---|---|
committer | 2025-01-06 20:13:51 +0100 | |
commit | a0acaba86650d52e59dd50ac8b6863e26666b90b (patch) | |
tree | 90d5d0c9316fdbd8afe49aa5dfc0874b1e36858a /winit/src/program.rs | |
parent | f2c9b6b2ffc50d67d9789e77cb55eeb2a0ebe470 (diff) | |
download | iced-a0acaba86650d52e59dd50ac8b6863e26666b90b.tar.gz iced-a0acaba86650d52e59dd50ac8b6863e26666b90b.tar.bz2 iced-a0acaba86650d52e59dd50ac8b6863e26666b90b.zip |
Use "outer" positions in all window-related operations
Diffstat (limited to 'winit/src/program.rs')
-rw-r--r-- | winit/src/program.rs | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/winit/src/program.rs b/winit/src/program.rs index 26b713f3..cc19a4e0 100644 --- a/winit/src/program.rs +++ b/winit/src/program.rs @@ -508,10 +508,25 @@ where log::info!("Window attributes for id `{id:#?}`: {window_attributes:#?}"); + // On macOS, the `position` in `WindowAttributes` represents the "inner" + // position of the window; while on other platforms it's the "outer" position. + // We fix the inconsistency on macOS by positioning the window after creation. + #[cfg(target_os = "macos")] + let mut window_attributes = window_attributes; + + #[cfg(target_os = "macos")] + let position = + window_attributes.position.take(); + let window = event_loop .create_window(window_attributes) .expect("Create window"); + #[cfg(target_os = "macos")] + if let Some(position) = position { + window.set_outer_position(position); + } + #[cfg(target_arch = "wasm32")] { use winit::platform::web::WindowExtWebSys; @@ -1310,7 +1325,7 @@ fn run_action<P, C>( if let Some(window) = window_manager.get(id) { let position = window .raw - .inner_position() + .outer_position() .map(|position| { let position = position .to_logical::<f32>(window.raw.scale_factor()); |