chore(rustfmt): use nightly (#2325)

Stable rustfmt lacks a lot of features resulting in worse formatted
code, thus use nightly formatter.
This commit is contained in:
Kirill Chibisov 2024-04-26 19:11:44 +04:00 committed by GitHub
parent 7006c7ceca
commit 7b0c7b6cb2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
154 changed files with 3439 additions and 5891 deletions

View file

@ -226,13 +226,10 @@ impl WindowState {
&self,
callback: F,
) {
self.pointers
.iter()
.filter_map(Weak::upgrade)
.for_each(|pointer| {
let data = pointer.pointer().winit_data();
callback(pointer.as_ref(), data);
})
self.pointers.iter().filter_map(Weak::upgrade).for_each(|pointer| {
let data = pointer.pointer().winit_data();
callback(pointer.as_ref(), data);
})
}
/// Get the current state of the frame callback.
@ -257,7 +254,7 @@ impl WindowState {
FrameCallbackState::None | FrameCallbackState::Received => {
self.frame_callback_state = FrameCallbackState::Requested;
surface.frame(&self.queue_handle, surface.clone());
}
},
FrameCallbackState::Requested => (),
}
}
@ -297,11 +294,11 @@ impl WindowState {
// Hide the frame if we were asked to not decorate.
frame.set_hidden(!self.decorate);
self.frame = Some(frame);
}
},
Err(err) => {
warn!("Failed to create client side decorations frame: {err}");
self.csd_fails = true;
}
},
}
} else if configure.decoration_mode == DecorationMode::Server {
// Drop the frame for server side decorations to save resources.
@ -320,8 +317,8 @@ impl WindowState {
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),
},
(..) if stateless => (self.stateless_size, true),
_ => (self.size, true),
}
} else {
@ -335,10 +332,8 @@ impl WindowState {
// Apply configure bounds only when compositor let the user decide what size to pick.
if constrain {
let bounds = self.inner_size_bounds(&configure);
new_size.width = bounds
.0
.map(|bound_w| new_size.width.min(bound_w.get()))
.unwrap_or(new_size.width);
new_size.width =
bounds.0.map(|bound_w| new_size.width.min(bound_w.get())).unwrap_or(new_size.width);
new_size.height = bounds
.1
.map(|bound_h| new_size.height.min(bound_h.get()))
@ -346,10 +341,7 @@ impl WindowState {
}
let new_state = configure.state;
let old_state = self
.last_configure
.as_ref()
.map(|configure| configure.state);
let old_state = self.last_configure.as_ref().map(|configure| configure.state);
let state_change_requires_resize = old_state
.map(|old_state| {
@ -387,10 +379,7 @@ impl WindowState {
configure_bounds.0.unwrap_or(NonZeroU32::new(1).unwrap()),
configure_bounds.1.unwrap_or(NonZeroU32::new(1).unwrap()),
);
(
configure_bounds.0.and(width),
configure_bounds.1.and(height),
)
(configure_bounds.0.and(width), configure_bounds.1.and(height))
} else {
configure_bounds
}
@ -460,7 +449,7 @@ impl WindowState {
_ => return None,
};
self.window.resize(seat, serial, edge);
}
},
FrameAction::ShowMenu(x, y) => self.window.show_window_menu(seat, serial, (x, y)),
_ => (),
};
@ -643,12 +632,7 @@ impl WindowState {
/// Try to resize the window when the user can do so.
pub fn request_inner_size(&mut self, inner_size: Size) -> PhysicalSize<u32> {
if self
.last_configure
.as_ref()
.map(Self::is_stateless)
.unwrap_or(true)
{
if self.last_configure.as_ref().map(Self::is_stateless).unwrap_or(true) {
self.resize(inner_size.to_logical(self.scale_factor()))
}
@ -674,10 +658,7 @@ impl WindowState {
);
}
(
frame.location(),
frame.add_borders(self.size.width, self.size.height).into(),
)
(frame.location(), frame.add_borders(self.size.width, self.size.height).into())
} else {
((0, 0), self.size)
};
@ -724,16 +705,12 @@ impl WindowState {
/// Set the custom cursor icon.
pub(crate) fn set_custom_cursor(&mut self, cursor: RootCustomCursor) {
let cursor = match cursor {
RootCustomCursor {
inner: PlatformCustomCursor::Wayland(cursor),
} => cursor.0,
RootCustomCursor { inner: PlatformCustomCursor::Wayland(cursor) } => cursor.0,
#[cfg(x11_platform)]
RootCustomCursor {
inner: PlatformCustomCursor::X(_),
} => {
RootCustomCursor { inner: PlatformCustomCursor::X(_) } => {
tracing::error!("passed a X11 cursor to Wayland backend");
return;
}
},
};
let cursor = {
@ -752,11 +729,7 @@ impl WindowState {
self.apply_on_pointer(|pointer, _| {
let surface = pointer.surface();
let scale = surface
.data::<SurfaceData>()
.unwrap()
.surface_data()
.scale_factor();
let scale = surface.data::<SurfaceData>().unwrap().surface_data().scale_factor();
surface.set_buffer_scale(scale);
surface.attach(Some(cursor.buffer.wl_buffer()), 0, 0);
@ -864,7 +837,7 @@ impl WindowState {
}),
CursorGrabMode::Locked => {
self.apply_on_pointer(|_, data| data.unlock_pointer());
}
},
}
let surface = self.window.wl_surface();
@ -879,7 +852,7 @@ impl WindowState {
}),
CursorGrabMode::None => {
// Current lock/confine was already removed.
}
},
}
Ok(())
@ -902,11 +875,9 @@ impl WindowState {
// Position can be set only for locked cursor.
if self.cursor_grab_mode.current_grab_mode != CursorGrabMode::Locked {
return Err(ExternalError::Os(os_error!(
crate::platform_impl::OsError::Misc(
"cursor position can be set only for locked cursor."
)
)));
return Err(ExternalError::Os(os_error!(crate::platform_impl::OsError::Misc(
"cursor position can be set only for locked cursor."
))));
}
self.apply_on_pointer(|_, data| {
@ -929,9 +900,7 @@ impl WindowState {
for pointer in self.pointers.iter().filter_map(|pointer| pointer.upgrade()) {
let latest_enter_serial = pointer.pointer().winit_data().latest_enter_serial();
pointer
.pointer()
.set_cursor(latest_enter_serial, None, 0, 0);
pointer.pointer().set_cursor(latest_enter_serial, None, 0, 0);
}
}
}
@ -945,19 +914,12 @@ impl WindowState {
self.decorate = decorate;
match self
.last_configure
.as_ref()
.map(|configure| configure.decoration_mode)
{
match self.last_configure.as_ref().map(|configure| configure.decoration_mode) {
Some(DecorationMode::Server) if !self.decorate => {
// To disable decorations we should request client and hide the frame.
self.window
.request_decoration_mode(Some(DecorationMode::Client))
}
_ if self.decorate => self
.window
.request_decoration_mode(Some(DecorationMode::Server)),
self.window.request_decoration_mode(Some(DecorationMode::Client))
},
_ if self.decorate => self.window.request_decoration_mode(Some(DecorationMode::Server)),
_ => (),
}
@ -1054,10 +1016,7 @@ impl WindowState {
info!("Blur manager unavailable, unable to change blur")
}
} else if !blurred && self.blur.is_some() {
self.blur_manager
.as_ref()
.unwrap()
.unset(self.window.wl_surface());
self.blur_manager.as_ref().unwrap().unset(self.window.wl_surface());
self.blur.take().unwrap().release();
}
}
@ -1146,10 +1105,7 @@ struct GrabState {
impl GrabState {
fn new() -> Self {
Self {
user_grab_mode: CursorGrabMode::None,
current_grab_mode: CursorGrabMode::None,
}
Self { user_grab_mode: CursorGrabMode::None, current_grab_mode: CursorGrabMode::None }
}
}