From 61692b21ad306a7c998c4097c64871faa473b116 Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Thu, 14 Nov 2024 13:19:47 -0800 Subject: [PATCH] Run `cargo format` --- src/backend/kms/device.rs | 4 +- src/shell/grabs/moving.rs | 7 +-- src/shell/layout/floating/mod.rs | 66 ++++++++++++++++++-------- src/shell/layout/tiling/mod.rs | 36 +++++++++----- src/shell/mod.rs | 5 +- src/wayland/protocols/toplevel_info.rs | 5 +- 6 files changed, 80 insertions(+), 43 deletions(-) diff --git a/src/backend/kms/device.rs b/src/backend/kms/device.rs index df3fec77..687e3b89 100644 --- a/src/backend/kms/device.rs +++ b/src/backend/kms/device.rs @@ -307,7 +307,9 @@ impl State { let surface = device.surfaces.remove(&crtc).unwrap(); if surface.output.mirroring().is_none() { // TODO: move up later outputs? - w = w.saturating_sub(surface.output.config().transformed_size().w as u32); + w = w.saturating_sub( + surface.output.config().transformed_size().w as u32, + ); } } diff --git a/src/shell/grabs/moving.rs b/src/shell/grabs/moving.rs index 4d302ec0..5081ead8 100644 --- a/src/shell/grabs/moving.rs +++ b/src/shell/grabs/moving.rs @@ -864,9 +864,10 @@ impl Drop for MoveGrab { let pointer = seat.get_pointer().unwrap(); let current_location = pointer.current_location(); - if let Some((target, offset)) = - mapped.focus_under(current_location - position.as_logical().to_f64(), WindowSurfaceType::ALL) - { + if let Some((target, offset)) = mapped.focus_under( + current_location - position.as_logical().to_f64(), + WindowSurfaceType::ALL, + ) { pointer.motion( state, Some(( diff --git a/src/shell/layout/floating/mod.rs b/src/shell/layout/floating/mod.rs index a3f10355..4507d7ea 100644 --- a/src/shell/layout/floating/mod.rs +++ b/src/shell/layout/floating/mod.rs @@ -732,41 +732,60 @@ impl FloatingLayout { self.space .elements() .rev() - .map(|e| (e, self.space.element_location(e).unwrap() - e.geometry().loc)) + .map(|e| { + ( + e, + self.space.element_location(e).unwrap() - e.geometry().loc, + ) + }) .filter(|(e, render_location)| { let mut bbox = e.bbox(); bbox.loc += *render_location; bbox.to_f64().contains(location.as_logical()) }) .find_map(|(e, render_location)| { - let render_location = render_location - .as_local() - .to_f64(); + let render_location = render_location.as_local().to_f64(); let point = location - render_location; - if e.focus_under(point.as_logical(), WindowSurfaceType::POPUP | WindowSurfaceType::SUBSURFACE).is_some() { + if e.focus_under( + point.as_logical(), + WindowSurfaceType::POPUP | WindowSurfaceType::SUBSURFACE, + ) + .is_some() + { Some(e.clone().into()) } else { None } }) } - - pub fn toplevel_element_under(&self, location: Point) -> Option { + + pub fn toplevel_element_under( + &self, + location: Point, + ) -> Option { self.space .elements() .rev() - .map(|e| (e, self.space.element_location(e).unwrap() - e.geometry().loc)) + .map(|e| { + ( + e, + self.space.element_location(e).unwrap() - e.geometry().loc, + ) + }) .filter(|(e, render_location)| { let mut bbox = e.bbox(); bbox.loc += *render_location; bbox.to_f64().contains(location.as_logical()) }) .find_map(|(e, render_location)| { - let render_location = render_location - .as_local() - .to_f64(); + let render_location = render_location.as_local().to_f64(); let point = location - render_location; - if e.focus_under(point.as_logical(), WindowSurfaceType::TOPLEVEL | WindowSurfaceType::SUBSURFACE).is_some() { + if e.focus_under( + point.as_logical(), + WindowSurfaceType::TOPLEVEL | WindowSurfaceType::SUBSURFACE, + ) + .is_some() + { Some(e.clone().into()) } else { None @@ -781,16 +800,19 @@ impl FloatingLayout { self.space .elements() .rev() - .map(|e| (e, self.space.element_location(e).unwrap() - e.geometry().loc)) + .map(|e| { + ( + e, + self.space.element_location(e).unwrap() - e.geometry().loc, + ) + }) .filter(|(e, render_location)| { let mut bbox = e.bbox(); bbox.loc += *render_location; bbox.to_f64().contains(location.as_logical()) }) .find_map(|(e, render_location)| { - let render_location = render_location - .as_local() - .to_f64(); + let render_location = render_location.as_local().to_f64(); let point = location - render_location; e.focus_under( point.as_logical(), @@ -809,7 +831,12 @@ impl FloatingLayout { self.space .elements() .rev() - .map(|e| (e, self.space.element_location(e).unwrap() - e.geometry().loc)) + .map(|e| { + ( + e, + self.space.element_location(e).unwrap() - e.geometry().loc, + ) + }) .filter(|(e, render_location)| { let mut bbox = e.bbox(); bbox.loc += *render_location; @@ -823,10 +850,7 @@ impl FloatingLayout { WindowSurfaceType::TOPLEVEL | WindowSurfaceType::SUBSURFACE, ) .map(|(surface, surface_offset)| { - ( - surface, - render_location + surface_offset.as_local(), - ) + (surface, render_location + surface_offset.as_local()) }) }) } diff --git a/src/shell/layout/tiling/mod.rs b/src/shell/layout/tiling/mod.rs index c814f304..395a3466 100644 --- a/src/shell/layout/tiling/mod.rs +++ b/src/shell/layout/tiling/mod.rs @@ -3104,8 +3104,11 @@ impl TilingLayout { None } - - pub fn popup_element_under(&self, location_f64: Point) -> Option { + + pub fn popup_element_under( + &self, + location_f64: Point, + ) -> Option { let location = location_f64.to_i32_round(); for (mapped, geo) in self.mapped() { @@ -3113,18 +3116,24 @@ impl TilingLayout { continue; } - if mapped.focus_under( - (location_f64 - geo.loc.to_f64()).as_logical() + mapped.geometry().loc.to_f64(), - WindowSurfaceType::POPUP | WindowSurfaceType::SUBSURFACE, - ).is_some() { + if mapped + .focus_under( + (location_f64 - geo.loc.to_f64()).as_logical() + mapped.geometry().loc.to_f64(), + WindowSurfaceType::POPUP | WindowSurfaceType::SUBSURFACE, + ) + .is_some() + { return Some(mapped.clone().into()); } } None } - - pub fn toplevel_element_under(&self, location_f64: Point) -> Option { + + pub fn toplevel_element_under( + &self, + location_f64: Point, + ) -> Option { let location = location_f64.to_i32_round(); for (mapped, geo) in self.mapped() { @@ -3132,10 +3141,13 @@ impl TilingLayout { continue; } - if mapped.focus_under( - (location_f64 - geo.loc.to_f64()).as_logical() + mapped.geometry().loc.to_f64(), - WindowSurfaceType::TOPLEVEL | WindowSurfaceType::SUBSURFACE, - ).is_some() { + if mapped + .focus_under( + (location_f64 - geo.loc.to_f64()).as_logical() + mapped.geometry().loc.to_f64(), + WindowSurfaceType::TOPLEVEL | WindowSurfaceType::SUBSURFACE, + ) + .is_some() + { return Some(mapped.clone().into()); } } diff --git a/src/shell/mod.rs b/src/shell/mod.rs index e8e422d5..8e52c73c 100644 --- a/src/shell/mod.rs +++ b/src/shell/mod.rs @@ -1960,13 +1960,14 @@ impl Shell { self.pending_windows.retain(|(s, _, _)| s.alive()); } - pub fn update_pointer_position(&mut self, location: Point, output: &Output) { + pub fn update_pointer_position(&mut self, location: Point, output: &Output) { for (o, set) in self.workspaces.sets.iter_mut() { if o == output { set.sticky_layer.update_pointer_position(Some(location)); for (i, workspace) in set.workspaces.iter_mut().enumerate() { if i == set.active { - workspace.update_pointer_position(Some(location), self.overview_mode.clone()); + workspace + .update_pointer_position(Some(location), self.overview_mode.clone()); } else { workspace.update_pointer_position(None, self.overview_mode.clone()); } diff --git a/src/wayland/protocols/toplevel_info.rs b/src/wayland/protocols/toplevel_info.rs index 356d6ccf..a7f3b64d 100644 --- a/src/wayland/protocols/toplevel_info.rs +++ b/src/wayland/protocols/toplevel_info.rs @@ -200,10 +200,7 @@ where .instances .push(instance); } else { - let _ = data_init.init( - cosmic_toplevel, - ToplevelHandleStateInner::empty(), - ); + let _ = data_init.init(cosmic_toplevel, ToplevelHandleStateInner::empty()); error!(?foreign_toplevel, "Toplevel for foreign-toplevel-list not registered for cosmic-toplevel-info."); } }