mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2025-01-23 02:16:33 +11:00
On Wayland, fix rounding issue in resizes
This commit is contained in:
parent
a31f71ee07
commit
a006cd7dc8
2 changed files with 11 additions and 2 deletions
|
@ -12,6 +12,7 @@ And please only add new entries to the top of this list, right below the `# Unre
|
||||||
- On macOS, set resize increments only for live resizes.
|
- On macOS, set resize increments only for live resizes.
|
||||||
- On Wayland, fix rare crash on DPI change
|
- On Wayland, fix rare crash on DPI change
|
||||||
- Web: Added support for `Window::theme`.
|
- Web: Added support for `Window::theme`.
|
||||||
|
- On Wayland, fix rounding issues when doing resize.
|
||||||
|
|
||||||
# 0.28.1
|
# 0.28.1
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ use sctk::environment::Environment;
|
||||||
use sctk::seat::pointer::{ThemeManager, ThemeSpec};
|
use sctk::seat::pointer::{ThemeManager, ThemeSpec};
|
||||||
use sctk::WaylandSource;
|
use sctk::WaylandSource;
|
||||||
|
|
||||||
|
use crate::dpi::{LogicalSize, PhysicalSize};
|
||||||
use crate::event::{Event, StartCause, WindowEvent};
|
use crate::event::{Event, StartCause, WindowEvent};
|
||||||
use crate::event_loop::{ControlFlow, EventLoopWindowTarget as RootEventLoopWindowTarget};
|
use crate::event_loop::{ControlFlow, EventLoopWindowTarget as RootEventLoopWindowTarget};
|
||||||
use crate::platform_impl::platform::sticky_exit_callback;
|
use crate::platform_impl::platform::sticky_exit_callback;
|
||||||
|
@ -385,7 +386,7 @@ impl<T: 'static> EventLoop<T> {
|
||||||
let window_size = window_compositor_update.size.unwrap_or(*size);
|
let window_size = window_compositor_update.size.unwrap_or(*size);
|
||||||
*size = window_size;
|
*size = window_size;
|
||||||
|
|
||||||
window_size.to_physical(scale_factor)
|
logical_to_physical_rounded(window_size, scale_factor)
|
||||||
});
|
});
|
||||||
|
|
||||||
sticky_exit_callback(
|
sticky_exit_callback(
|
||||||
|
@ -430,7 +431,7 @@ impl<T: 'static> EventLoop<T> {
|
||||||
} else {
|
} else {
|
||||||
*window_size = size;
|
*window_size = size;
|
||||||
let scale_factor = window_handle.scale_factor();
|
let scale_factor = window_handle.scale_factor();
|
||||||
let physical_size = size.to_physical(scale_factor);
|
let physical_size = logical_to_physical_rounded(size, scale_factor);
|
||||||
Some(physical_size)
|
Some(physical_size)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -599,3 +600,10 @@ impl<T: 'static> EventLoop<T> {
|
||||||
.map_err(|error| error.into())
|
.map_err(|error| error.into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The default routine does floor, but we need round on Wayland.
|
||||||
|
fn logical_to_physical_rounded(size: LogicalSize<u32>, scale_factor: f64) -> PhysicalSize<u32> {
|
||||||
|
let width = size.width as f64 * scale_factor;
|
||||||
|
let height = size.height as f64 * scale_factor;
|
||||||
|
(width.round(), height.round()).into()
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue