Use "outer" positions in all window-related operations
This commit is contained in:
parent
f2c9b6b2ff
commit
a0acaba866
2 changed files with 17 additions and 2 deletions
|
|
@ -508,10 +508,25 @@ where
|
||||||
|
|
||||||
log::info!("Window attributes for id `{id:#?}`: {window_attributes:#?}");
|
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
|
let window = event_loop
|
||||||
.create_window(window_attributes)
|
.create_window(window_attributes)
|
||||||
.expect("Create window");
|
.expect("Create window");
|
||||||
|
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
if let Some(position) = position {
|
||||||
|
window.set_outer_position(position);
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
{
|
{
|
||||||
use winit::platform::web::WindowExtWebSys;
|
use winit::platform::web::WindowExtWebSys;
|
||||||
|
|
@ -1310,7 +1325,7 @@ fn run_action<P, C>(
|
||||||
if let Some(window) = window_manager.get(id) {
|
if let Some(window) = window_manager.get(id) {
|
||||||
let position = window
|
let position = window
|
||||||
.raw
|
.raw
|
||||||
.inner_position()
|
.outer_position()
|
||||||
.map(|position| {
|
.map(|position| {
|
||||||
let position = position
|
let position = position
|
||||||
.to_logical::<f32>(window.raw.scale_factor());
|
.to_logical::<f32>(window.raw.scale_factor());
|
||||||
|
|
|
||||||
|
|
@ -165,7 +165,7 @@ where
|
||||||
{
|
{
|
||||||
pub fn position(&self) -> Option<Point> {
|
pub fn position(&self) -> Option<Point> {
|
||||||
self.raw
|
self.raw
|
||||||
.inner_position()
|
.outer_position()
|
||||||
.ok()
|
.ok()
|
||||||
.map(|position| position.to_logical(self.raw.scale_factor()))
|
.map(|position| position.to_logical(self.raw.scale_factor()))
|
||||||
.map(|position| Point {
|
.map(|position| Point {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue