diff --git a/winit/src/program.rs b/winit/src/program.rs index 13873edd07..359f2735cb 100644 --- a/winit/src/program.rs +++ b/winit/src/program.rs @@ -538,10 +538,22 @@ 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 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; @@ -1340,7 +1352,7 @@ fn run_action
(
if let Some(window) = window_manager.get(id) {
let position = window
.raw
- .inner_position()
+ .outer_position()
.map(|position| {
let position = position
.to_logical::