On Wayland, fix Window::request_inner_size during resize

The user may change the size during the on-going resize, meaning that
the size will desync with winit's internal loop which breaks viewporter
setup with fractional scaling.

Links: https://github.com/alacritty/alacritty/issues/7474
This commit is contained in:
Kirill Chibisov 2023-12-29 21:28:06 +04:00 committed by GitHub
parent ad1843aea6
commit 8f6de4ef4b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 50 additions and 59 deletions

View file

@ -33,9 +33,9 @@ use crate::dpi::{LogicalPosition, LogicalSize, PhysicalSize, Size};
use crate::error::{ExternalError, NotSupportedError};
use crate::event::WindowEvent;
use crate::platform_impl::wayland::event_loop::sink::EventSink;
use crate::platform_impl::wayland::make_wid;
use crate::platform_impl::wayland::types::cursor::{CustomCursor, SelectedCursor};
use crate::platform_impl::wayland::types::kwin_blur::KWinBlurManager;
use crate::platform_impl::wayland::{logical_to_physical_rounded, make_wid};
use crate::platform_impl::WindowId;
use crate::window::{CursorGrabMode, CursorIcon, ImePurpose, ResizeDirection, Theme};
@ -262,7 +262,7 @@ impl WindowState {
shm: &Shm,
subcompositor: &Option<Arc<SubcompositorState>>,
event_sink: &mut EventSink,
) -> Option<LogicalSize<u32>> {
) -> bool {
// NOTE: when using fractional scaling or wl_compositor@v6 the scaling
// should be delivered before the first configure, thus apply it to
// properly scale the physical sizes provided by the users.
@ -374,9 +374,9 @@ impl WindowState {
if state_change_requires_resize || new_size != self.inner_size() {
self.resize(new_size);
Some(new_size)
true
} else {
None
false
}
}
@ -656,7 +656,7 @@ impl WindowState {
self.resize(inner_size.to_logical(self.scale_factor()))
}
self.inner_size().to_physical(self.scale_factor())
logical_to_physical_rounded(self.inner_size(), self.scale_factor())
}
/// Resize the window to the new inner size.