On Wayland, fix resize being sent on focus change

Fixes #3263.
This commit is contained in:
Kirill Chibisov 2023-12-20 18:48:50 +04:00 committed by GitHub
parent cc33212479
commit 04ca85a909
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 18 deletions

View file

@ -27,6 +27,7 @@ Unreleased` header.
- On Windows, fix consecutive calls to `window.set_fullscreen(Some(Fullscreen::Borderless(None)))` resulting in losing previous window state when eventually exiting fullscreen using `window.set_fullscreen(None)`.
- On Web, remove queuing fullscreen request in absence of transient activation.
- On Web, fix setting cursor icon overriding cursor visibility.
- On Wayland, fix resize being sent on focus change.
# 0.29.4

View file

@ -307,7 +307,11 @@ impl WindowHandler for WinitState {
&mut self.events_sink,
);
self.window_compositor_updates[pos].size = Some(new_size);
// NOTE: Only update when the value is `Some` to not override consequent configures with
// the same sizes.
if new_size.is_some() {
self.window_compositor_updates[pos].size = new_size;
}
}
}

View file

@ -262,7 +262,7 @@ impl WindowState {
shm: &Shm,
subcompositor: &Option<Arc<SubcompositorState>>,
event_sink: &mut EventSink,
) -> LogicalSize<u32> {
) -> Option<LogicalSize<u32>> {
// 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.
@ -325,14 +325,9 @@ impl WindowState {
match configure.new_size {
(Some(width), Some(height)) => {
let (width, height) = frame.subtract_borders(width, height);
(
(
width.map(|w| w.get()).unwrap_or(1),
height.map(|h| h.get()).unwrap_or(1),
)
.into(),
false,
)
let width = width.map(|w| w.get()).unwrap_or(1);
let height = height.map(|h| h.get()).unwrap_or(1);
((width, height).into(), false)
}
(_, _) if stateless => (self.stateless_size, true),
_ => (self.size, true),
@ -358,13 +353,27 @@ impl WindowState {
.unwrap_or(new_size.height);
}
// XXX Set the configure before doing a resize.
let new_state = configure.state;
let old_state = self
.last_configure
.as_ref()
.map(|configure| configure.state)
.unwrap_or(XdgWindowState::empty());
let state_change_requires_resize = !new_state
.symmetric_difference(old_state)
.difference(XdgWindowState::ACTIVATED | XdgWindowState::SUSPENDED)
.is_empty();
// NOTE: Set the configure before doing a resize, since we query it during it.
self.last_configure = Some(configure);
// XXX Update the new size right away.
self.resize(new_size);
new_size
if state_change_requires_resize || new_size != self.inner_size() {
self.resize(new_size);
Some(new_size)
} else {
None
}
}
/// Compute the bounds for the inner size of the surface.
@ -970,7 +979,7 @@ impl WindowState {
/// Set the IME position.
pub fn set_ime_cursor_area(&self, position: LogicalPosition<u32>, size: LogicalSize<u32>) {
// XXX This won't fly unless user will have a way to request IME window per seat, since
// FIXME: This won't fly unless user will have a way to request IME window per seat, since
// the ime windows will be overlapping, but winit doesn't expose API to specify for
// which seat we're setting IME position.
let (x, y) = (position.x as i32, position.y as i32);
@ -1001,7 +1010,7 @@ impl WindowState {
pub fn set_scale_factor(&mut self, scale_factor: f64) {
self.scale_factor = scale_factor;
// XXX when fractional scaling is not used update the buffer scale.
// NOTE: When fractional scaling is not used update the buffer scale.
if self.fractional_scale.is_none() {
let _ = self.window.set_buffer_scale(self.scale_factor as _);
}
@ -1149,7 +1158,7 @@ impl From<ResizeDirection> for XdgResizeEdge {
}
}
// XXX rust doesn't allow from `Option`.
// NOTE: Rust doesn't allow `From<Option<Theme>>`.
#[cfg(feature = "sctk-adwaita")]
fn into_sctk_adwaita_config(theme: Option<Theme>) -> sctk_adwaita::FrameConfig {
match theme {