chore: clippy

This commit is contained in:
Vukašin Vojinović 2025-10-16 13:50:32 +02:00 committed by Victoria Brekenfeld
parent 3b70bc0265
commit 0847247c33
77 changed files with 865 additions and 1029 deletions

View file

@ -241,10 +241,7 @@ impl CosmicMapped {
}
pub fn focus_window(&self, window: &CosmicSurface) {
match &self.element {
CosmicMappedInternal::Stack(stack) => stack.set_active(window),
_ => {}
}
if let CosmicMappedInternal::Stack(stack) = &self.element { stack.set_active(window) }
}
pub fn has_surface(&self, surface: &WlSurface, surface_type: WindowSurfaceType) -> bool {
@ -446,7 +443,7 @@ impl CosmicMapped {
pub fn set_bounds(&self, size: impl Into<Option<Size<i32, Logical>>>) {
let size = size.into();
for (surface, _) in self.windows() {
surface.set_bounds(size.clone())
surface.set_bounds(size)
}
}
@ -508,24 +505,21 @@ impl CosmicMapped {
(output, overlap): (&Output, Rectangle<i32, Logical>),
theme: cosmic::Theme,
) {
match &self.element {
CosmicMappedInternal::Window(window) => {
let surface = window.surface();
let activated = surface.is_activated(true);
let handle = window.loop_handle();
if let CosmicMappedInternal::Window(window) = &self.element {
let surface = window.surface();
let activated = surface.is_activated(true);
let handle = window.loop_handle();
let stack = CosmicStack::new(std::iter::once(surface), handle, theme);
if let Some(geo) = self.last_geometry.lock().unwrap().clone() {
stack.set_geometry(geo.to_global(&output));
}
stack.output_enter(output, overlap);
stack.set_activate(activated);
stack.active().send_configure();
stack.refresh();
self.element = CosmicMappedInternal::Stack(stack);
let stack = CosmicStack::new(std::iter::once(surface), handle, theme);
if let Some(geo) = *self.last_geometry.lock().unwrap() {
stack.set_geometry(geo.to_global(output));
}
_ => {}
stack.output_enter(output, overlap);
stack.set_activate(activated);
stack.active().send_configure();
stack.refresh();
self.element = CosmicMappedInternal::Stack(stack);
}
}
@ -540,8 +534,8 @@ impl CosmicMapped {
surface.set_tiled(false);
let window = CosmicWindow::new(surface, handle, theme);
if let Some(geo) = self.last_geometry.lock().unwrap().clone() {
window.set_geometry(geo.to_global(&output));
if let Some(geo) = *self.last_geometry.lock().unwrap() {
window.set_geometry(geo.to_global(output));
}
window.output_enter(output, overlap);
window.set_activate(self.is_activated(true));
@ -843,7 +837,7 @@ impl CosmicMapped {
pub fn ssd_height(&self, pending: bool) -> Option<i32> {
match &self.element {
CosmicMappedInternal::Window(w) => (!w.surface().is_decorated(pending))
.then(|| crate::shell::element::window::SSD_HEIGHT),
.then_some(crate::shell::element::window::SSD_HEIGHT),
CosmicMappedInternal::Stack(_) => Some(crate::shell::element::stack::TAB_HEIGHT),
_ => unreachable!(),
}

View file

@ -180,7 +180,7 @@ impl CosmicStack {
*prev_idx = last_mod_serial.map(|s| (s, p.active.load(Ordering::SeqCst)));
}
if let Some(mut geo) = p.geometry.lock().unwrap().clone() {
if let Some(mut geo) = *p.geometry.lock().unwrap() {
geo.loc.y += TAB_HEIGHT;
geo.size.h -= TAB_HEIGHT;
window.set_geometry(geo, TAB_HEIGHT as u32);
@ -210,7 +210,7 @@ impl CosmicStack {
let mut windows = p.windows.lock().unwrap();
if windows.len() == 1 {
p.override_alive.store(false, Ordering::SeqCst);
let window = windows.get(0).unwrap();
let window = windows.first().unwrap();
window.try_force_undecorated(false);
window.set_tiled(false);
return;
@ -238,7 +238,7 @@ impl CosmicStack {
let mut windows = p.windows.lock().unwrap();
if windows.len() == 1 {
p.override_alive.store(false, Ordering::SeqCst);
let window = windows.get(0).unwrap();
let window = windows.first().unwrap();
window.try_force_undecorated(false);
window.set_tiled(false);
return Some(window.clone());
@ -545,10 +545,9 @@ impl CosmicStack {
pub fn pending_size(&self) -> Option<Size<i32, Logical>> {
self.0.with_program(|p| {
p.geometry
(*p.geometry
.lock()
.unwrap()
.clone()
.unwrap())
.map(|geo| geo.size.as_logical())
})
}
@ -1466,17 +1465,11 @@ impl PointerTarget<State> for CosmicStack {
}
fn axis(&self, seat: &Seat<State>, data: &mut State, frame: AxisFrame) {
match self.0.with_program(|p| p.current_focus()) {
Some(Focus::Header) => PointerTarget::axis(&self.0, seat, data, frame),
_ => {}
}
if let Some(Focus::Header) = self.0.with_program(|p| p.current_focus()) { PointerTarget::axis(&self.0, seat, data, frame) }
}
fn frame(&self, seat: &Seat<State>, data: &mut State) {
match self.0.with_program(|p| p.current_focus()) {
Some(Focus::Header) => PointerTarget::frame(&self.0, seat, data),
_ => {}
}
if let Some(Focus::Header) = self.0.with_program(|p| p.current_focus()) { PointerTarget::frame(&self.0, seat, data) }
}
fn leave(&self, seat: &Seat<State>, data: &mut State, serial: Serial, time: u32) {
@ -1607,7 +1600,7 @@ impl TouchTarget<State> for CosmicStack {
}
fn up(&self, seat: &Seat<State>, data: &mut State, event: &UpEvent, seq: Serial) {
TouchTarget::up(&self.0, seat, data, &event, seq)
TouchTarget::up(&self.0, seat, data, event, seq)
}
fn motion(&self, seat: &Seat<State>, data: &mut State, event: &TouchMotionEvent, seq: Serial) {

View file

@ -239,7 +239,7 @@ pub(super) struct TabInternal<'a, Message: TabMessage> {
right_click_message: Option<Message>,
}
impl<'a, Message> Widget<Message, cosmic::Theme, cosmic::Renderer> for TabInternal<'a, Message>
impl<Message> Widget<Message, cosmic::Theme, cosmic::Renderer> for TabInternal<'_, Message>
where
Message: TabMessage,
{

View file

@ -125,7 +125,7 @@ impl Offset {
const SCROLL_ANIMATION_DURATION: Duration = Duration::from_millis(200);
const TAB_ANIMATION_DURATION: Duration = Duration::from_millis(150);
impl<'a, Message> Tabs<'a, Message>
impl<Message> Tabs<'_, Message>
where
Message: TabMessage + 'static,
{
@ -308,7 +308,7 @@ impl State {
}
}
impl<'a, Message> Widget<Message, cosmic::Theme, cosmic::Renderer> for Tabs<'a, Message>
impl<Message> Widget<Message, cosmic::Theme, cosmic::Renderer> for Tabs<'_, Message>
where
Message: TabMessage,
{

View file

@ -81,14 +81,13 @@ impl From<X11Surface> for CosmicSurface {
impl PartialEq<WlSurface> for CosmicSurface {
fn eq(&self, other: &WlSurface) -> bool {
self.wl_surface().map_or(false, |s| &*s == other)
self.wl_surface().is_some_and(|s| &*s == other)
}
}
impl PartialEq<ToplevelSurface> for CosmicSurface {
fn eq(&self, other: &ToplevelSurface) -> bool {
self.wl_surface()
.map_or(false, |s| &*s == other.wl_surface())
self.wl_surface().is_some_and(|s| &*s == other.wl_surface())
}
}
@ -280,7 +279,7 @@ impl CosmicSurface {
WindowSurface::Wayland(toplevel) => {
if enable {
let previous_decoration_state =
toplevel.current_state().decoration_mode.clone();
toplevel.current_state().decoration_mode;
if PreferredDecorationMode::is_unset(&self.0) {
PreferredDecorationMode::update(&self.0, previous_decoration_state);
}
@ -639,10 +638,8 @@ impl CosmicSurface {
return false;
};
if surface_type.contains(WindowSurfaceType::TOPLEVEL) {
if *toplevel == *surface {
return true;
}
if surface_type.contains(WindowSurfaceType::TOPLEVEL) && *toplevel == *surface {
return true;
}
if surface_type.contains(WindowSurfaceType::SUBSURFACE) {

View file

@ -252,7 +252,7 @@ impl CosmicWindow {
let geo = p.window.geometry();
let point_i32 = relative_pos.to_i32_round::<i32>();
let ssd_height = has_ssd.then_some(SSD_HEIGHT).unwrap_or(0);
let ssd_height = if has_ssd { SSD_HEIGHT } else { 0 };
if (point_i32.x - geo.loc.x >= -RESIZE_BORDER && point_i32.x - geo.loc.x < 0)
|| (point_i32.y - geo.loc.y >= -RESIZE_BORDER && point_i32.y - geo.loc.y < 0)
@ -708,7 +708,7 @@ impl PointerTarget<State> for CosmicWindow {
if has_ssd || p.is_tiled(false) {
let Some(next) = Focus::under(
&p.window,
has_ssd.then_some(SSD_HEIGHT).unwrap_or(0),
if has_ssd { SSD_HEIGHT } else { 0 },
event.location,
) else {
return;
@ -734,7 +734,7 @@ impl PointerTarget<State> for CosmicWindow {
if has_ssd || p.is_tiled(false) {
let Some(next) = Focus::under(
&p.window,
has_ssd.then_some(SSD_HEIGHT).unwrap_or(0),
if has_ssd { SSD_HEIGHT } else { 0 },
event.location,
) else {
return;
@ -804,17 +804,11 @@ impl PointerTarget<State> for CosmicWindow {
}
fn axis(&self, seat: &Seat<State>, data: &mut State, frame: AxisFrame) {
match self.0.with_program(|p| p.current_focus()) {
Some(Focus::Header) => PointerTarget::axis(&self.0, seat, data, frame),
_ => {}
}
if let Some(Focus::Header) = self.0.with_program(|p| p.current_focus()) { PointerTarget::axis(&self.0, seat, data, frame) }
}
fn frame(&self, seat: &Seat<State>, data: &mut State) {
match self.0.with_program(|p| p.current_focus()) {
Some(Focus::Header) => PointerTarget::frame(&self.0, seat, data),
_ => {}
}
if let Some(Focus::Header) = self.0.with_program(|p| p.current_focus()) { PointerTarget::frame(&self.0, seat, data) }
}
fn leave(&self, seat: &Seat<State>, data: &mut State, serial: Serial, time: u32) {
@ -901,7 +895,7 @@ impl TouchTarget<State> for CosmicWindow {
}
fn up(&self, seat: &Seat<State>, data: &mut State, event: &UpEvent, seq: Serial) {
TouchTarget::up(&self.0, seat, data, &event, seq)
TouchTarget::up(&self.0, seat, data, event, seq)
}
fn motion(&self, seat: &Seat<State>, data: &mut State, event: &TouchMotionEvent, seq: Serial) {