wzrd

An ICCCM & EWMH compliant X11 reparenting, dynamic window manager, written in Rust
git clone git://git.deurzen.net/wzrd
Log | Files | Refs | LICENSE

commit 73b99ab613ae22e836a58d3b7f96ad4749c4d180
parent 60d1daa699d6e343889eeb26b0ba4ee463836ebe
Author: deurzen <m.deurzen@tum.de>
Date:   Sat, 13 Mar 2021 16:41:17 +0100

reformats code

Diffstat:
Mrustfmt.toml | 2+-
Msrc/core/binding.rs | 3+--
Msrc/core/client.rs | 9+++------
Msrc/core/cycle.rs | 42+++++++++++-------------------------------
Msrc/core/main.rs | 3+--
Msrc/core/model.rs | 271++++++++++++++++++++++++++-----------------------------------------------------
Msrc/core/stack.rs | 6++----
Msrc/core/util.rs | 14+++-----------
Msrc/core/workspace.rs | 4+---
Msrc/core/zone.rs | 89++++++++++++++++++-------------------------------------------------------------
Msrc/winsys/common.rs | 27+++++++++------------------
Msrc/winsys/screen.rs | 24++++++------------------
Msrc/winsys/xdata/xconnection.rs | 571++++++++++++++++++++++++++++++-------------------------------------------------
13 files changed, 363 insertions(+), 702 deletions(-)

diff --git a/rustfmt.toml b/rustfmt.toml @@ -1,4 +1,4 @@ -max_width = 80 +max_width = 100 fn_args_layout = "vertical" merge_derives = false use_field_init_shorthand = true diff --git a/src/core/binding.rs b/src/core/binding.rs @@ -11,5 +11,4 @@ pub type Action = Box<dyn FnMut(&mut Model)>; pub type MouseEvents = Box<dyn FnMut(&mut Model, Option<Window>)>; pub type KeyEvents = Box<dyn FnMut(&mut Model)>; pub type KeyBindings = HashMap<KeyCode, KeyEvents>; -pub type MouseBindings = - HashMap<(MouseEventKey, MouseShortcut), (MouseEvents, bool)>; +pub type MouseBindings = HashMap<(MouseEventKey, MouseShortcut), (MouseEvents, bool)>; diff --git a/src/core/client.rs b/src/core/client.rs @@ -238,10 +238,8 @@ impl Client { inner_region.pos.x = extents.left as i32; inner_region.pos.y = extents.top as i32; - inner_region.dim.w = - active_region.dim.w - extents.left - extents.right; - inner_region.dim.h = - active_region.dim.h - extents.top - extents.bottom; + inner_region.dim.w = active_region.dim.w - extents.left - extents.right; + inner_region.dim.h = active_region.dim.h - extents.top - extents.bottom; inner_region } else { @@ -429,8 +427,7 @@ impl Client { &mut self, consumer: Window, ) { - if let Some(index) = self.consumers.iter().rposition(|c| *c == consumer) - { + if let Some(index) = self.consumers.iter().rposition(|c| *c == consumer) { self.consumers.remove(index); } } diff --git a/src/core/cycle.rs b/src/core/cycle.rs @@ -97,8 +97,7 @@ where &self, dir: Direction, ) -> bool { - self.index == Util::last_index(self.elements.iter()) - && dir == Direction::Forward + self.index == Util::last_index(self.elements.iter()) && dir == Direction::Forward || self.index == 0 && dir == Direction::Backward } @@ -193,9 +192,7 @@ where }; self.indices.clear(); - for (i, id) in - self.elements.iter().enumerate().map(|(i, e)| (i, e.id())) - { + for (i, id) in self.elements.iter().enumerate().map(|(i, e)| (i, e.id())) { self.indices.insert(id as Ident, i as Index); } } @@ -234,9 +231,7 @@ where ) { match insert_pos { InsertPos::BeforeActive => self.insert(self.index, element), - InsertPos::AfterActive => { - self.insert_at(&InsertPos::AfterIndex(self.index), element) - }, + InsertPos::AfterActive => self.insert_at(&InsertPos::AfterIndex(self.index), element), InsertPos::BeforeIndex(index) => self.insert(*index, element), InsertPos::Front => self.push_front(element), InsertPos::Back => self.push_back(element), @@ -331,9 +326,7 @@ where Selector::AtActive => self.active_element(), Selector::AtIndex(index) => self.elements.get(*index), Selector::First => self.elements.get(0), - Selector::Last => { - self.elements.get(Util::last_index(self.elements.iter())) - }, + Selector::Last => self.elements.get(Util::last_index(self.elements.iter())), Selector::ForCond(f) => self.by(f).map(|(_, e)| e), Selector::AtIdent(id) => { if let Some(index) = self.id_to_index(*id) { @@ -373,18 +366,14 @@ where ) -> Vec<&T> { match sel { Selector::AtActive => self.active_element().into_iter().collect(), - Selector::AtIndex(index) => { - self.elements.get(*index).into_iter().collect() - }, + Selector::AtIndex(index) => self.elements.get(*index).into_iter().collect(), Selector::First => self.elements.get(0).into_iter().collect(), Selector::Last => self .elements .get(Util::last_index(self.elements.iter())) .into_iter() .collect(), - Selector::ForCond(f) => { - self.elements.iter().filter(|e| f(*e)).collect() - }, + Selector::ForCond(f) => self.elements.iter().filter(|e| f(*e)).collect(), Selector::AtIdent(id) => { if let Some(index) = self.id_to_index(*id) { return self.get_all_for(&Selector::AtIndex(index)); @@ -400,21 +389,15 @@ where sel: &Selector<T>, ) -> Vec<&mut T> { match sel { - Selector::AtActive => { - self.active_element_mut().into_iter().collect() - }, - Selector::AtIndex(index) => { - self.elements.get_mut(*index).into_iter().collect() - }, + Selector::AtActive => self.active_element_mut().into_iter().collect(), + Selector::AtIndex(index) => self.elements.get_mut(*index).into_iter().collect(), Selector::First => self.elements.get_mut(0).into_iter().collect(), Selector::Last => self .elements .get_mut(Util::last_index(self.elements.iter())) .into_iter() .collect(), - Selector::ForCond(f) => { - self.elements.iter_mut().filter(|e| f(*e)).collect() - }, + Selector::ForCond(f) => self.elements.iter_mut().filter(|e| f(*e)).collect(), Selector::AtIdent(id) => { if let Some(index) = self.id_to_index(*id) { return self.get_all_for_mut(&Selector::AtIndex(index)); @@ -526,9 +509,7 @@ where sel: &Selector<T>, ) -> Option<T> { let (index, element) = match sel { - Selector::AtActive => { - (self.index, self.elements.remove(self.index)) - }, + Selector::AtActive => (self.index, self.elements.remove(self.index)), Selector::AtIndex(index) => (*index, self.elements.remove(*index)), Selector::AtIdent(id) => { if let Some(index) = self.id_to_index(*id) { @@ -684,8 +665,7 @@ where if let Some(index) = self.index() { if let Some(id) = self.index_to_id(index) { - if let Some(found_index) = stack.iter().rposition(|i| *i == id) - { + if let Some(found_index) = stack.iter().rposition(|i| *i == id) { stack.remove(found_index); } diff --git a/src/core/main.rs b/src/core/main.rs @@ -51,8 +51,7 @@ pub fn main() -> Result<()> { let (mouse_bindings, key_bindings) = init_bindings(); - Model::new(&mut xconn, &key_bindings, &mouse_bindings) - .run(key_bindings, mouse_bindings); + Model::new(&mut xconn, &key_bindings, &mouse_bindings).run(key_bindings, mouse_bindings); Ok(()) } diff --git a/src/core/model.rs b/src/core/model.rs @@ -128,8 +128,7 @@ impl<'a> Model<'a> { info!("initializing window manager"); model.acquire_partitions(); - let workspaces = - ["main", "web", "term", "4", "5", "6", "7", "8", "9", "10"]; + let workspaces = ["main", "web", "term", "4", "5", "6", "7", "8", "9", "10"]; for (i, &workspace_name) in workspaces.iter().enumerate() { let region = model @@ -141,17 +140,12 @@ impl<'a> Model<'a> { let id = model.zone_manager.new_zone( None, - ZoneContent::Layout( - Layout::new(), - Cycle::new(Vec::new(), true), - ), + ZoneContent::Layout(Layout::new(), Cycle::new(Vec::new(), true)), ); - model.workspaces.push_back(Workspace::new( - workspace_name, - i as u32, - id, - )); + model + .workspaces + .push_back(Workspace::new(workspace_name, i as u32, id)); model.zone_manager.zone_mut(id).set_region(region); } @@ -166,10 +160,10 @@ impl<'a> Model<'a> { .keys() .cloned() .collect::<Vec<winsys::input::KeyCode>>(), - &mouse_bindings.keys().into_iter().collect::<Vec<&( - winsys::input::MouseEventKey, - winsys::input::MouseShortcut, - )>>(), + &mouse_bindings + .keys() + .into_iter() + .collect::<Vec<&(winsys::input::MouseEventKey, winsys::input::MouseShortcut)>>(), ); model.conn.top_level_windows().iter().for_each(|&window| { @@ -180,11 +174,7 @@ impl<'a> Model<'a> { if cfg!(not(debug_assertions)) { info!("executing startup scripts"); - Util::spawn_shell(concat!( - "$HOME/.config/", - WM_NAME!(), - "/blocking_autostart" - )); + Util::spawn_shell(concat!("$HOME/.config/", WM_NAME!(), "/blocking_autostart")); Util::spawn_shell(concat!( "$HOME/.config/", WM_NAME!(), @@ -249,8 +239,7 @@ impl<'a> Model<'a> { state, action, on_root, - } => self - .handle_state_request(window, state, action, on_root), + } => self.handle_state_request(window, state, action, on_root), Event::FocusRequest { window, on_root, @@ -269,9 +258,7 @@ impl<'a> Model<'a> { pos, dim, on_root, - } => { - self.handle_placement_request(window, pos, dim, on_root) - }, + } => self.handle_placement_request(window, pos, dim, on_root), Event::GripRequest { window, pos, @@ -283,8 +270,7 @@ impl<'a> Model<'a> { sibling, mode, on_root, - } => self - .handle_restack_request(window, sibling, mode, on_root), + } => self.handle_restack_request(window, sibling, mode, on_root), Event::Property { window, kind, @@ -346,8 +332,7 @@ impl<'a> Model<'a> { // TODO: zone change let region = self.active_screen().placeable_region(); - let placements = - workspace.arrange(&mut self.zone_manager, &self.client_map, region); + let placements = workspace.arrange(&mut self.zone_manager, &self.client_map, region); let (show, hide): (Vec<&Placement>, Vec<&Placement>) = placements .iter() @@ -411,15 +396,14 @@ impl<'a> Model<'a> { }) }); - let (free, regular): (Vec<Window>, Vec<Window>) = - regular.iter().partition(|&&window| { - self.client(window).map_or(true, |client| { - let id = self.zone_manager.client_id(client.window()); - let zone = self.zone_manager.zone(id); + let (free, regular): (Vec<Window>, Vec<Window>) = regular.iter().partition(|&&window| { + self.client(window).map_or(true, |client| { + let id = self.zone_manager.client_id(client.window()); + let zone = self.zone_manager.zone(id); - zone.method() == PlacementMethod::Free || client.is_free() - }) - }); + zone.method() == PlacementMethod::Free || client.is_free() + }) + }); let above = self.stack.layer_windows(StackLayer::Above); let notification = self.stack.layer_windows(StackLayer::Notification); @@ -496,13 +480,11 @@ impl<'a> Model<'a> { return; } - let mut client_list: Vec<&Client> = - self.client_map.values().collect::<Vec<&Client>>(); + let mut client_list: Vec<&Client> = self.client_map.values().collect::<Vec<&Client>>(); client_list.sort_by_key(|&a| a.managed_since()); - let client_list: Vec<Window> = - client_list.iter().map(|client| client.window()).collect(); + let client_list: Vec<Window> = client_list.iter().map(|client| client.window()).collect(); self.conn.update_client_list(&client_list); @@ -694,11 +676,9 @@ impl<'a> Model<'a> { let frame = self.conn.create_frame(geometry); let rules = self.detect_rules(&instance); let hints = self.conn.get_icccm_window_hints(window); - let (_, size_hints) = self.conn.get_icccm_window_size_hints( - window, - Some(MIN_WINDOW_DIM), - &None, - ); + let (_, size_hints) = + self.conn + .get_icccm_window_size_hints(window, Some(MIN_WINDOW_DIM), &None); geometry = if size_hints.is_some() { geometry @@ -721,16 +701,16 @@ impl<'a> Model<'a> { // TODO: MOTIF decorations for old-style applications let context = 0; - let workspace = self.conn.get_window_desktop(window).map_or( - self.active_workspace(), - |d| { + let workspace = self + .conn + .get_window_desktop(window) + .map_or(self.active_workspace(), |d| { if d < self.workspaces.len() { d } else { self.active_workspace() } - }, - ); + }); let mut center = false; @@ -852,12 +832,9 @@ impl<'a> Model<'a> { if let Some(state) = preferred_state { match state { - WindowState::DemandsAttention => self.handle_state_request( - window, - state, - ToggleAction::Add, - false, - ), + WindowState::DemandsAttention => { + self.handle_state_request(window, state, ToggleAction::Add, false) + }, _ => {}, } } @@ -982,9 +959,7 @@ impl<'a> Model<'a> { client: &Client, ) -> bool { (!client.is_fullscreen() || client.is_in_window()) - && (client.is_floating() - || client.is_disowned() - || !client.is_managed()) + && (client.is_floating() || client.is_disowned() || !client.is_managed()) // TODO: zone change // || self // .workspaces @@ -1223,12 +1198,10 @@ impl<'a> Model<'a> { consumer.set_producer(producer_window); if consumer_len == 0 { - let producer_workspace = - self.workspace_mut(producer_workspace_index); + let producer_workspace = self.workspace_mut(producer_workspace_index); if producer_workspace_index == consumer_workspace_index { - producer_workspace - .replace_client(producer_window, consumer_window); + producer_workspace.replace_client(producer_window, consumer_window); } else { producer_workspace.remove_client(producer_window); } @@ -1275,12 +1248,9 @@ impl<'a> Model<'a> { if consumer_len == 0 { producer.set_workspace(consumer_workspace); - if let Some(workspace) = - self.workspaces.get_mut(consumer_workspace) - { + if let Some(workspace) = self.workspaces.get_mut(consumer_workspace) { if workspace.contains(consumer_window) { - workspace - .replace_client(consumer_window, producer_window); + workspace.replace_client(consumer_window, producer_window); } else { workspace.add_client(producer_window, &InsertPos::Back); } @@ -1808,17 +1778,13 @@ impl<'a> Model<'a> { fn focused_client(&self) -> Option<&Client> { self.focus - .or_else(|| { - self.workspace(self.active_workspace()).focused_client() - }) + .or_else(|| self.workspace(self.active_workspace()).focused_client()) .and_then(|id| self.client_map.get(&id)) } fn focused_client_mut(&mut self) -> Option<&mut Client> { self.focus - .or_else(|| { - self.workspace(self.active_workspace()).focused_client() - }) + .or_else(|| self.workspace(self.active_workspace()).focused_client()) .and_then(move |id| self.client_map.get_mut(&id)) } @@ -1961,9 +1927,7 @@ impl<'a> Model<'a> { client.is_managed() && match match_method { MatchMethod::Equals => client.name() == *name, - MatchMethod::Contains => { - client.name().contains(name) - }, + MatchMethod::Contains => client.name().contains(name), } }) .map(|(_, client)| client) @@ -1985,9 +1949,7 @@ impl<'a> Model<'a> { client.is_managed() && match match_method { MatchMethod::Equals => client.class() == *class, - MatchMethod::Contains => { - client.class().contains(class) - }, + MatchMethod::Contains => client.class().contains(class), } }) .map(|(_, client)| client) @@ -2008,12 +1970,8 @@ impl<'a> Model<'a> { .filter(|&(_, client)| { client.is_managed() && match match_method { - MatchMethod::Equals => { - client.instance() == *instance - }, - MatchMethod::Contains => { - client.instance().contains(instance) - }, + MatchMethod::Equals => client.instance() == *instance, + MatchMethod::Contains => client.instance().contains(instance), } }) .map(|(_, client)| client) @@ -2095,8 +2053,7 @@ impl<'a> Model<'a> { ) { if let Some(client) = self.client(window) { let window = client.window(); - let free_region = - self.fullscreen_regions.get(&window).map(|&region| region); + let free_region = self.fullscreen_regions.get(&window).map(|&region| region); info!("disabling fullscreen for client with window {:#0x}", window); @@ -2182,9 +2139,7 @@ impl<'a> Model<'a> { self.conn .set_window_state(window, WindowState::Sticky, false); - if let Some(index) = - self.sticky_clients.iter().position(|&s| s == window) - { + if let Some(index) = self.sticky_clients.iter().position(|&s| s == window) { self.sticky_clients.remove(index); } @@ -2317,15 +2272,13 @@ impl<'a> Model<'a> { match edge { Edge::Left => region.pos.x = placeable_region.pos.x, Edge::Right => { - let x = placeable_region.dim.w as i32 - + placeable_region.pos.x; + let x = placeable_region.dim.w as i32 + placeable_region.pos.x; region.pos.x = std::cmp::max(0, x - region.dim.w as i32) }, Edge::Top => region.pos.y = placeable_region.pos.y, Edge::Bottom => { - let y = placeable_region.dim.h as i32 - + placeable_region.pos.y; + let y = placeable_region.dim.h as i32 + placeable_region.pos.y; region.pos.y = std::cmp::max(0, y - region.dim.h as i32) }, @@ -2413,14 +2366,10 @@ impl<'a> Model<'a> { let mut region = region.without_extents(&frame_extents); - if (width_inc.is_negative() - && -width_inc >= region.dim.w as i32) - || (height_inc.is_negative() - && -height_inc >= region.dim.h as i32) - || (region.dim.w as i32 + width_inc - <= MIN_WINDOW_DIM.w as i32) - || (region.dim.h as i32 + height_inc - <= MIN_WINDOW_DIM.h as i32) + if (width_inc.is_negative() && -width_inc >= region.dim.w as i32) + || (height_inc.is_negative() && -height_inc >= region.dim.h as i32) + || (region.dim.w as i32 + width_inc <= MIN_WINDOW_DIM.w as i32) + || (region.dim.h as i32 + height_inc <= MIN_WINDOW_DIM.h as i32) { return; } @@ -2479,8 +2428,7 @@ impl<'a> Model<'a> { if self.is_free(client) { let frame_extents = client.frame_extents(); let window = client.window(); - let mut region = - (*client.free_region()).without_extents(&frame_extents); + let mut region = (*client.free_region()).without_extents(&frame_extents); info!( "stretching client with window {:#0x} at the {:?} by {}", @@ -2493,10 +2441,8 @@ impl<'a> Model<'a> { return; } - if region.dim.w as i32 + step <= MIN_WINDOW_DIM.w as i32 - { - region.pos.x -= - MIN_WINDOW_DIM.w as i32 - region.dim.w as i32; + if region.dim.w as i32 + step <= MIN_WINDOW_DIM.w as i32 { + region.pos.x -= MIN_WINDOW_DIM.w as i32 - region.dim.w as i32; region.dim.w = MIN_WINDOW_DIM.w; } else { region.pos.x -= step; @@ -2508,8 +2454,7 @@ impl<'a> Model<'a> { return; } - if region.dim.w as i32 + step <= MIN_WINDOW_DIM.w as i32 - { + if region.dim.w as i32 + step <= MIN_WINDOW_DIM.w as i32 { region.dim.w = MIN_WINDOW_DIM.w; } else { region.dim.w = (region.dim.w as i32 + step) as u32; @@ -2520,10 +2465,8 @@ impl<'a> Model<'a> { return; } - if region.dim.h as i32 + step <= MIN_WINDOW_DIM.h as i32 - { - region.pos.y -= - MIN_WINDOW_DIM.h as i32 - region.dim.h as i32; + if region.dim.h as i32 + step <= MIN_WINDOW_DIM.h as i32 { + region.pos.y -= MIN_WINDOW_DIM.h as i32 - region.dim.h as i32; region.dim.h = MIN_WINDOW_DIM.h; } else { region.pos.y -= step; @@ -2535,8 +2478,7 @@ impl<'a> Model<'a> { return; } - if region.dim.h as i32 + step <= MIN_WINDOW_DIM.h as i32 - { + if region.dim.h as i32 + step <= MIN_WINDOW_DIM.h as i32 { region.dim.h = MIN_WINDOW_DIM.h; } else { region.dim.h = (region.dim.h as i32 + step) as u32; @@ -2565,8 +2507,7 @@ impl<'a> Model<'a> { &mut self, window: Window, ) { - if !self.move_buffer.is_occupied() && !self.resize_buffer.is_occupied() - { + if !self.move_buffer.is_occupied() && !self.resize_buffer.is_occupied() { if let Some(client) = self.client(window) { let current_pos = self.conn.get_pointer_position(); let client_region = *client.free_region(); @@ -2597,9 +2538,7 @@ impl<'a> Model<'a> { if let Some(client) = self.client(self.move_buffer.window().unwrap()) { if self.is_free(client) { if let Some(grip_pos) = self.move_buffer.grip_pos() { - if let Some(window_region) = - self.move_buffer.window_region() - { + if let Some(window_region) = self.move_buffer.window_region() { let window = client.window(); let region = Region { pos: window_region.pos + grip_pos.dist(*pos), @@ -2626,19 +2565,14 @@ impl<'a> Model<'a> { &mut self, window: Window, ) { - if !self.move_buffer.is_occupied() && !self.resize_buffer.is_occupied() - { + if !self.move_buffer.is_occupied() && !self.resize_buffer.is_occupied() { if let Some(client) = self.client(window) { let current_pos = self.conn.get_pointer_position(); let client_region = *client.free_region(); let corner = client.free_region().nearest_corner(current_pos); - self.resize_buffer.set( - window, - Grip::Corner(corner), - current_pos, - client_region, - ); + self.resize_buffer + .set(window, Grip::Corner(corner), current_pos, client_region); self.conn.confine_pointer(self.resize_buffer.handle()); } @@ -2702,13 +2636,13 @@ impl<'a> Model<'a> { .with_extents(&frame_extents); if top_grip { - region.pos.y = window_region.pos.y - + (window_region.dim.h as i32 - region.dim.h as i32); + region.pos.y = + window_region.pos.y + (window_region.dim.h as i32 - region.dim.h as i32); } if left_grip { - region.pos.x = window_region.pos.x - + (window_region.dim.w as i32 - region.dim.w as i32); + region.pos.x = + window_region.pos.x + (window_region.dim.w as i32 - region.dim.w as i32); } if region == previous_region { @@ -2899,33 +2833,21 @@ impl<'a> Model<'a> { (geometry.pos.x, geometry.pos.y), (geometry.dim.w, geometry.dim.h), ) { - ((0, 0), (w, h)) - if w == screen.full_region().dim.w => - { - Some((Edge::Top, h)) - }, - ((0, 0), (w, h)) - if h == screen.full_region().dim.h => - { - Some((Edge::Left, w)) - }, - ((0, 0), (w, h)) if w > h => { + ((0, 0), (w, h)) if w == screen.full_region().dim.w => { Some((Edge::Top, h)) }, - ((0, 0), (w, h)) if w < h => { + ((0, 0), (w, h)) if h == screen.full_region().dim.h => { Some((Edge::Left, w)) }, + ((0, 0), (w, h)) if w > h => Some((Edge::Top, h)), + ((0, 0), (w, h)) if w < h => Some((Edge::Left, w)), ((_, y), (_, h)) - if y == screen.full_region().dim.h - as i32 - - h as i32 => + if y == screen.full_region().dim.h as i32 - h as i32 => { Some((Edge::Bottom, h)) }, ((x, _), (w, _)) - if x == screen.full_region().dim.w - as i32 - - w as i32 => + if x == screen.full_region().dim.w as i32 - w as i32 => { Some((Edge::Right, w)) }, @@ -2939,10 +2861,7 @@ impl<'a> Model<'a> { self.conn.unmap_window(window); } else { screen.compute_placeable_region(); - self.apply_layout( - self.active_workspace(), - true, - ); + self.apply_layout(self.active_workspace(), true); } } } @@ -3018,9 +2937,7 @@ impl<'a> Model<'a> { self.apply_layout(active_workspace, true); } - if let Some(index) = - self.unmanaged_windows.iter().position(|&s| s == window) - { + if let Some(index) = self.unmanaged_windows.iter().position(|&s| s == window) { self.unmanaged_windows.remove(index); } @@ -3239,12 +3156,8 @@ impl<'a> Model<'a> { }, dim: if let Some(dim) = dim { Dim { - w: dim.w - + frame_extents.left - + frame_extents.right, - h: dim.h - + frame_extents.top - + frame_extents.bottom, + w: dim.w + frame_extents.left + frame_extents.right, + h: dim.h + frame_extents.top + frame_extents.bottom, } } else { client.free_region().dim @@ -3330,12 +3243,8 @@ impl<'a> Model<'a> { let current_pos = self.conn.get_pointer_position(); let client_region = *client.free_region(); - self.resize_buffer.set( - window, - grip, - current_pos, - client_region, - ); + self.resize_buffer + .set(window, grip, current_pos, client_region); self.conn.confine_pointer(self.resize_buffer.handle()); } @@ -3402,12 +3311,11 @@ impl<'a> Model<'a> { let frame_extents = client.frame_extents(); let mut geometry = geometry.unwrap(); - let (_, size_hints) = - self.conn.get_icccm_window_size_hints( - window, - Some(MIN_WINDOW_DIM), - &client.size_hints(), - ); + let (_, size_hints) = self.conn.get_icccm_window_size_hints( + window, + Some(MIN_WINDOW_DIM), + &client.size_hints(), + ); geometry = if size_hints.is_some() { geometry.with_size_hints(&size_hints) @@ -3423,9 +3331,7 @@ impl<'a> Model<'a> { client.set_size_hints(size_hints); client.set_free_region(&geometry); - if client.is_managed() - && workspace == self.active_workspace() - { + if client.is_managed() && workspace == self.active_workspace() { self.apply_layout(workspace, true); } } @@ -3482,8 +3388,7 @@ impl<'a> Model<'a> { fn handle_screen_change(&mut self) { debug!("SCREEN_CHANGE"); - let workspace = - self.partitions.active_element().unwrap().screen().number(); + let workspace = self.partitions.active_element().unwrap().screen().number(); self.workspaces.activate_for(&Selector::AtIndex(workspace)); } diff --git a/src/core/stack.rs b/src/core/stack.rs @@ -98,8 +98,7 @@ impl StackManager { StackLayer::Notification => &mut self.notification_windows, }; - let index = - layer_windows.iter().position(|&w| w == window).unwrap(); + let index = layer_windows.iter().position(|&w| w == window).unwrap(); layer_windows.remove(index); self.window_layers.remove(&window); @@ -131,8 +130,7 @@ impl StackManager { StackLayer::Notification => &mut self.notification_windows, }; - let index = - layer_windows.iter().position(|&w| w == window).unwrap(); + let index = layer_windows.iter().position(|&w| w == window).unwrap(); layer_windows.remove(index); layer_windows.push(window); diff --git a/src/core/util.rs b/src/core/util.rs @@ -64,12 +64,7 @@ impl Util { delta: T, ) -> T where - T: Ord - + Add<Output = T> - + AddAssign - + Sub<Output = T> - + SubAssign - + Copy, + T: Ord + Add<Output = T> + AddAssign + Sub<Output = T> + SubAssign + Copy, { match change { Change::Inc => { @@ -133,8 +128,7 @@ impl Util { .lines() .flat_map(|l| { let mut words = l.split_whitespace(); - let key_code: u8 = - words.nth(1).unwrap().parse().unwrap(); + let key_code: u8 = words.nth(1).unwrap().parse().unwrap(); words.skip(1).map(move |name| (name.into(), key_code)) }) @@ -182,9 +176,7 @@ impl Util { } } - pub fn parse_mouse_binding( - mouse_binding: impl Into<String> - ) -> Option<MouseShortcut> { + pub fn parse_mouse_binding(mouse_binding: impl Into<String>) -> Option<MouseShortcut> { let s = mouse_binding.into(); let mut constituents: Vec<&str> = s.split('-').collect(); diff --git a/src/core/workspace.rs b/src/core/workspace.rs @@ -226,9 +226,7 @@ impl Workspace { return None; }, ClientSelector::AtIndex(index) => Selector::AtIndex(*index), - ClientSelector::AtIdent(window) => { - Selector::AtIdent(*window as Ident) - }, + ClientSelector::AtIdent(window) => Selector::AtIdent(*window as Ident), ClientSelector::First => Selector::First, ClientSelector::Last => Selector::Last, }; diff --git a/src/core/zone.rs b/src/core/zone.rs @@ -217,9 +217,7 @@ type LayoutFn = fn(&Region, &LayoutData, Vec<bool>) -> Vec<(Disposition, bool)>; #[non_exhaustive] #[repr(u8)] -#[derive( - Debug, Hash, PartialEq, Eq, Clone, Copy, EnumIter, EnumCount, ToString -)] +#[derive(Debug, Hash, PartialEq, Eq, Clone, Copy, EnumIter, EnumCount, ToString)] pub enum LayoutKind { /// Free layouts Float = b'F', @@ -404,10 +402,7 @@ impl LayoutKind { }, #[allow(unreachable_patterns)] - _ => unimplemented!( - "{:?} does not have an associated configuration", - self - ), + _ => unimplemented!("{:?} does not have an associated configuration", self), } } @@ -436,18 +431,15 @@ impl LayoutKind { LayoutKind::Vert => Default::default(), #[allow(unreachable_patterns)] - _ => unimplemented!( - "{:?} does not have associated default data", - self - ), + _ => unimplemented!("{:?} does not have associated default data", self), } } fn func(&self) -> LayoutFn { match *self { // TODO - LayoutKind::Float => |_, _, active_map| { - vec![(Disposition::Unchanged, true); active_map.len()] + LayoutKind::Float => { + |_, _, active_map| vec![(Disposition::Unchanged, true); active_map.len()] }, LayoutKind::SingleFloat => |_, _, active_map| { active_map @@ -487,17 +479,11 @@ impl LayoutKind { let i = i as u32; if i < data.main_count { - let w = - if n_stack == 0 { dim.w } else { div as u32 }; + let w = if n_stack == 0 { dim.w } else { div as u32 }; ( Disposition::Changed( - Region::new( - pos.x, - pos.y + (i * h_main) as i32, - w, - h_main, - ), + Region::new(pos.x, pos.y + (i * h_main) as i32, w, h_main), config.decoration, ), true, @@ -548,8 +534,7 @@ impl LayoutKind { let h_comp = MAX_MAIN_COUNT + 1; let w_ratio: f32 = data.main_factor / 0.95; - let h_ratio: f32 = - (h_comp - data.main_count) as f32 / h_comp as f32; + let h_ratio: f32 = (h_comp - data.main_count) as f32 / h_comp as f32; active_map .iter() @@ -607,12 +592,7 @@ impl LayoutKind { ( Disposition::Changed( - Region::new( - pos.x + i as i32 * w, - pos.y, - cw, - dim.h, - ), + Region::new(pos.x + i as i32 * w, pos.y, cw, dim.h), config.decoration, ), true, @@ -637,10 +617,7 @@ impl LayoutKind { }, #[allow(unreachable_patterns)] - _ => unimplemented!( - "{:?} does not have an associated function", - self - ), + _ => unimplemented!("{:?} does not have an associated function", self), } } } @@ -772,11 +749,7 @@ impl Apply for Layout { ) -> (PlacementMethod, Vec<(Disposition, bool)>) { ( self.kind.config().method, - (self.kind.func())( - region, - &self.data.get(&self.kind).unwrap(), - active_map, - ), + (self.kind.func())(region, &self.data.get(&self.kind).unwrap(), active_map), ) } } @@ -875,8 +848,7 @@ impl ZoneManager { parent: Option<ZoneId>, content: ZoneContent, ) -> ZoneId { - let (id, zone) = - Zone::new(parent, content, Region::new(0, 0, 0, 0), true, true); + let (id, zone) = Zone::new(parent, content, Region::new(0, 0, 0, 0), true, true); if let ZoneContent::Client(window) = &zone.content { self.client_zones.insert(*window, id); @@ -974,8 +946,7 @@ impl ZoneManager { let mut subzones = Vec::new(); zones.iter().for_each(|&zone| { - subzones - .extend(self.gather_subzones(zone, recurse)); + subzones.extend(self.gather_subzones(zone, recurse)); }); zones.extend(subzones); @@ -1073,17 +1044,13 @@ impl ZoneManager { zone_changes.push((id, ZoneChange::Method(method))); }); - placements.extend( - self.arrange_subzones( - id, region, decoration, method, - ), - ); - + placements.extend(self.arrange_subzones(id, region, decoration, method)); placements }, } }, ZoneContent::Layout(layout, zones) => { + let mut subplacements = Vec::new(); let mut placements = vec![Placement { method, kind: PlacementKind::Layout, @@ -1100,8 +1067,6 @@ impl ZoneManager { .collect(), ); - let mut subplacements = Vec::new(); - zones.iter().zip(application.iter()).for_each( |(&id, (disposition, is_visible))| { let zone = self.zone_map.get(&id).unwrap(); @@ -1115,18 +1080,10 @@ impl ZoneManager { ); let (region, decoration) = match disposition { - Disposition::Unchanged => { - (zone.region, zone.decoration) - }, + Disposition::Unchanged => (zone.region, zone.decoration), Disposition::Changed(region, decoration) => { - zone_changes - .push((id, ZoneChange::Region(*region))); - - zone_changes.push(( - id, - ZoneChange::Decoration(*decoration), - )); - + zone_changes.push((id, ZoneChange::Region(*region))); + zone_changes.push((id, ZoneChange::Decoration(*decoration))); zone_changes.push((id, ZoneChange::Method(method))); (*region, *decoration) @@ -1140,12 +1097,7 @@ impl ZoneManager { ); subplacements.iter().for_each(|(id, region, decoration)| { - placements.extend(self.arrange_subzones( - *id, - *region, - *decoration, - method, - )); + placements.extend(self.arrange_subzones(*id, *region, *decoration, method)); }); placements @@ -1200,8 +1152,7 @@ impl std::cmp::PartialEq<Self> for Layout { &self, other: &Self, ) -> bool { - self.kind == other.kind - && self.data.get(&self.kind) == other.data.get(&other.kind) + self.kind == other.kind && self.data.get(&self.kind) == other.data.get(&other.kind) } } diff --git a/src/winsys/common.rs b/src/winsys/common.rs @@ -208,38 +208,29 @@ impl Region { match dists.first().unwrap() { (Corner::TopLeft, _) => { - let (left, _) = self - .split_at_width((self.dim.w as f64 / 2f64).round() as u32); - let (topleft, _) = left - .split_at_height((left.dim.h as f64 / 2f64).round() as u32); + let (left, _) = self.split_at_width((self.dim.w as f64 / 2f64).round() as u32); + let (topleft, _) = left.split_at_height((left.dim.h as f64 / 2f64).round() as u32); Some(Pos::from_center_of_region(topleft)) }, (Corner::TopRight, _) => { - let (_, right) = self - .split_at_width((self.dim.w as f64 / 2f64).round() as u32); + let (_, right) = self.split_at_width((self.dim.w as f64 / 2f64).round() as u32); let (topright, _) = - right.split_at_height( - (right.dim.h as f64 / 2f64).round() as u32 - ); + right.split_at_height((right.dim.h as f64 / 2f64).round() as u32); Some(Pos::from_center_of_region(topright)) }, (Corner::BottomLeft, _) => { - let (left, _) = self - .split_at_width((self.dim.w as f64 / 2f64).round() as u32); - let (_, bottomleft) = left - .split_at_height((left.dim.h as f64 / 2f64).round() as u32); + let (left, _) = self.split_at_width((self.dim.w as f64 / 2f64).round() as u32); + let (_, bottomleft) = + left.split_at_height((left.dim.h as f64 / 2f64).round() as u32); Some(Pos::from_center_of_region(bottomleft)) }, (Corner::BottomRight, _) => { - let (_, right) = self - .split_at_width((self.dim.w as f64 / 2f64).round() as u32); + let (_, right) = self.split_at_width((self.dim.w as f64 / 2f64).round() as u32); let (_, bottomright) = - right.split_at_height( - (right.dim.h as f64 / 2f64).round() as u32 - ); + right.split_at_height((right.dim.h as f64 / 2f64).round() as u32); Some(Pos::from_center_of_region(bottomright)) }, diff --git a/src/winsys/screen.rs b/src/winsys/screen.rs @@ -116,8 +116,7 @@ impl Screen { region.dim.h -= strut.width; } - if let Some(strut) = self.struts.get(&Edge::Bottom).unwrap().last() - { + if let Some(strut) = self.struts.get(&Edge::Bottom).unwrap().last() { region.dim.h -= strut.width; } } @@ -155,11 +154,7 @@ impl Screen { } if let Some(bottom_strut) = struts[3] { - self.add_strut( - Edge::Bottom, - bottom_strut.window, - bottom_strut.width, - ); + self.add_strut(Edge::Bottom, bottom_strut.window, bottom_strut.width); } } @@ -191,29 +186,22 @@ impl Screen { ) -> Option<u32> { match edge { Edge::Left => { - if let Some(strut) = - self.struts.get(&Edge::Left).unwrap().last() - { + if let Some(strut) = self.struts.get(&Edge::Left).unwrap().last() { return Some(strut.width); } }, Edge::Right => { - if let Some(strut) = - self.struts.get(&Edge::Right).unwrap().last() - { + if let Some(strut) = self.struts.get(&Edge::Right).unwrap().last() { return Some(strut.width); } }, Edge::Top => { - if let Some(strut) = self.struts.get(&Edge::Top).unwrap().last() - { + if let Some(strut) = self.struts.get(&Edge::Top).unwrap().last() { return Some(strut.width); } }, Edge::Bottom => { - if let Some(strut) = - self.struts.get(&Edge::Bottom).unwrap().last() - { + if let Some(strut) = self.struts.get(&Edge::Bottom).unwrap().last() { return Some(strut.width); } }, diff --git a/src/winsys/xdata/xconnection.rs b/src/winsys/xdata/xconnection.rs @@ -191,17 +191,14 @@ impl<'a, C: connection::Connection> XConnection<'a, C> { let screen = conn.setup().roots[screen_num].clone(); let root = screen.root; - let aux = xproto::ChangeWindowAttributesAux::default().event_mask( - EventMask::SUBSTRUCTURE_REDIRECT | EventMask::SUBSTRUCTURE_NOTIFY, - ); + let aux = xproto::ChangeWindowAttributesAux::default() + .event_mask(EventMask::SUBSTRUCTURE_REDIRECT | EventMask::SUBSTRUCTURE_NOTIFY); let res = conn.change_window_attributes(screen.root, &aux)?.check(); if let Err(ReplyError::X11Error(err)) = res { if err.error_kind == ErrorKind::Access { - return Err(anyhow!( - "another window manager is already running" - )); + return Err(anyhow!("another window manager is already running")); } else { return Err(anyhow!("unable to set up window manager")); } @@ -212,26 +209,19 @@ impl<'a, C: connection::Connection> XConnection<'a, C> { let type_map: HashMap<Atom, WindowType> = { let mut types = HashMap::with_capacity(10); - types - .insert(atoms._NET_WM_WINDOW_TYPE_DESKTOP, WindowType::Desktop); + types.insert(atoms._NET_WM_WINDOW_TYPE_DESKTOP, WindowType::Desktop); types.insert(atoms._NET_WM_WINDOW_TYPE_DOCK, WindowType::Dock); - types - .insert(atoms._NET_WM_WINDOW_TYPE_TOOLBAR, WindowType::Toolbar); + types.insert(atoms._NET_WM_WINDOW_TYPE_TOOLBAR, WindowType::Toolbar); types.insert(atoms._NET_WM_WINDOW_TYPE_MENU, WindowType::Menu); - types - .insert(atoms._NET_WM_WINDOW_TYPE_UTILITY, WindowType::Utility); + types.insert(atoms._NET_WM_WINDOW_TYPE_UTILITY, WindowType::Utility); types.insert(atoms._NET_WM_WINDOW_TYPE_SPLASH, WindowType::Splash); types.insert(atoms._NET_WM_WINDOW_TYPE_DIALOG, WindowType::Dialog); types.insert( atoms._NET_WM_WINDOW_TYPE_DROPDOWN_MENU, WindowType::DropdownMenu, ); - types.insert( - atoms._NET_WM_WINDOW_TYPE_POPUP_MENU, - WindowType::PopupMenu, - ); - types - .insert(atoms._NET_WM_WINDOW_TYPE_TOOLTIP, WindowType::Tooltip); + types.insert(atoms._NET_WM_WINDOW_TYPE_POPUP_MENU, WindowType::PopupMenu); + types.insert(atoms._NET_WM_WINDOW_TYPE_TOOLTIP, WindowType::Tooltip); types.insert( atoms._NET_WM_WINDOW_TYPE_NOTIFICATION, WindowType::Notification, @@ -255,17 +245,10 @@ impl<'a, C: connection::Connection> XConnection<'a, C> { WindowState::MaximizedHorz, ); states.insert(atoms._NET_WM_STATE_SHADED, WindowState::Shaded); - states.insert( - atoms._NET_WM_STATE_SKIP_TASKBAR, - WindowState::SkipTaskbar, - ); - states - .insert(atoms._NET_WM_STATE_SKIP_PAGER, WindowState::SkipPager); + states.insert(atoms._NET_WM_STATE_SKIP_TASKBAR, WindowState::SkipTaskbar); + states.insert(atoms._NET_WM_STATE_SKIP_PAGER, WindowState::SkipPager); states.insert(atoms._NET_WM_STATE_HIDDEN, WindowState::Hidden); - states.insert( - atoms._NET_WM_STATE_FULLSCREEN, - WindowState::Fullscreen, - ); + states.insert(atoms._NET_WM_STATE_FULLSCREEN, WindowState::Fullscreen); states.insert(atoms._NET_WM_STATE_ABOVE, WindowState::Above); states.insert(atoms._NET_WM_STATE_BELOW, WindowState::Below); states.insert( @@ -291,8 +274,7 @@ impl<'a, C: connection::Connection> XConnection<'a, C> { drop(conn.map_window(check_window)); - let aux = xproto::ConfigureWindowAux::default() - .stack_mode(xproto::StackMode::BELOW); + let aux = xproto::ConfigureWindowAux::default().stack_mode(xproto::StackMode::BELOW); drop(conn.configure_window(check_window, &aux)); @@ -305,25 +287,21 @@ impl<'a, C: connection::Connection> XConnection<'a, C> { )?; let background_gc = conn.generate_id()?; - conn.create_gc( - background_gc, - screen.root, - &xproto::CreateGCAux::default(), - )?; + conn.create_gc(background_gc, screen.root, &xproto::CreateGCAux::default())?; let database = Database::new_from_default(conn).ok(); if let Some(ref database) = database { - drop(CursorHandle::new(conn, screen_num, &database).map( - |cookie| { + drop( + CursorHandle::new(conn, screen_num, &database).map(|cookie| { cookie.reply().map(|reply| { let aux = xproto::ChangeWindowAttributesAux::default() .cursor(reply.load_cursor(conn, "left_ptr").ok()); drop(conn.change_window_attributes(screen.root, &aux)); }) - }, - )); + }), + ); } let root_event_mask: EventMask = EventMask::PROPERTY_CHANGE @@ -333,9 +311,8 @@ impl<'a, C: connection::Connection> XConnection<'a, C> { | EventMask::POINTER_MOTION | EventMask::FOCUS_CHANGE; - let window_event_mask: EventMask = EventMask::PROPERTY_CHANGE - | EventMask::STRUCTURE_NOTIFY - | EventMask::FOCUS_CHANGE; + let window_event_mask: EventMask = + EventMask::PROPERTY_CHANGE | EventMask::STRUCTURE_NOTIFY | EventMask::FOCUS_CHANGE; let frame_event_mask: EventMask = EventMask::STRUCTURE_NOTIFY | EventMask::SUBSTRUCTURE_REDIRECT @@ -344,12 +321,10 @@ impl<'a, C: connection::Connection> XConnection<'a, C> { | EventMask::BUTTON_RELEASE | EventMask::POINTER_MOTION; - let mouse_event_mask: EventMask = EventMask::BUTTON_PRESS - | EventMask::BUTTON_RELEASE - | EventMask::BUTTON_MOTION; + let mouse_event_mask: EventMask = + EventMask::BUTTON_PRESS | EventMask::BUTTON_RELEASE | EventMask::BUTTON_MOTION; - let regrab_event_mask: EventMask = - EventMask::BUTTON_PRESS | EventMask::BUTTON_RELEASE; + let regrab_event_mask: EventMask = EventMask::BUTTON_PRESS | EventMask::BUTTON_RELEASE; Self::init(Self { conn, @@ -438,8 +413,7 @@ impl<'a, C: connection::Connection> XConnection<'a, C> { .map_or(false, |cookie| { cookie.reply().map_or(false, |reply| { reply.value32().map_or(false, |mut window_protocols| { - window_protocols - .any(|protocol| protocols.contains(&protocol)) + window_protocols.any(|protocol| protocols.contains(&protocol)) }) }) }) @@ -494,12 +468,8 @@ impl<'a, C: connection::Connection> XConnection<'a, C> { match state { WindowState::Modal => self.atoms._NET_WM_STATE_MODAL, WindowState::Sticky => self.atoms._NET_WM_STATE_STICKY, - WindowState::MaximizedVert => { - self.atoms._NET_WM_STATE_MAXIMIZED_VERT - }, - WindowState::MaximizedHorz => { - self.atoms._NET_WM_STATE_MAXIMIZED_HORZ - }, + WindowState::MaximizedVert => self.atoms._NET_WM_STATE_MAXIMIZED_VERT, + WindowState::MaximizedHorz => self.atoms._NET_WM_STATE_MAXIMIZED_HORZ, WindowState::Shaded => self.atoms._NET_WM_STATE_SHADED, WindowState::SkipTaskbar => self.atoms._NET_WM_STATE_SKIP_TASKBAR, WindowState::SkipPager => self.atoms._NET_WM_STATE_SKIP_PAGER, @@ -507,9 +477,7 @@ impl<'a, C: connection::Connection> XConnection<'a, C> { WindowState::Fullscreen => self.atoms._NET_WM_STATE_FULLSCREEN, WindowState::Above => self.atoms._NET_WM_STATE_ABOVE, WindowState::Below => self.atoms._NET_WM_STATE_BELOW, - WindowState::DemandsAttention => { - self.atoms._NET_WM_STATE_DEMANDS_ATTENTION - }, + WindowState::DemandsAttention => self.atoms._NET_WM_STATE_DEMANDS_ATTENTION, } } @@ -534,14 +502,10 @@ impl<'a, C: connection::Connection> XConnection<'a, C> { WindowType::Utility => self.atoms._NET_WM_WINDOW_TYPE_UTILITY, WindowType::Splash => self.atoms._NET_WM_WINDOW_TYPE_SPLASH, WindowType::Dialog => self.atoms._NET_WM_WINDOW_TYPE_DIALOG, - WindowType::DropdownMenu => { - self.atoms._NET_WM_WINDOW_TYPE_DROPDOWN_MENU - }, + WindowType::DropdownMenu => self.atoms._NET_WM_WINDOW_TYPE_DROPDOWN_MENU, WindowType::PopupMenu => self.atoms._NET_WM_WINDOW_TYPE_POPUP_MENU, WindowType::Tooltip => self.atoms._NET_WM_WINDOW_TYPE_TOOLTIP, - WindowType::Notification => { - self.atoms._NET_WM_WINDOW_TYPE_NOTIFICATION - }, + WindowType::Notification => self.atoms._NET_WM_WINDOW_TYPE_NOTIFICATION, WindowType::Combo => self.atoms._NET_WM_WINDOW_TYPE_COMBO, WindowType::Dnd => self.atoms._NET_WM_WINDOW_TYPE_DND, WindowType::Normal => self.atoms._NET_WM_WINDOW_TYPE_NORMAL, @@ -580,8 +544,7 @@ impl<'a, C: connection::Connection> XConnection<'a, C> { .map_or(Vec::new(), |cookie| { cookie.reply().map_or(Vec::new(), |reply| { reply.value32().map_or(Vec::new(), |window_states| { - let mut states = - Vec::with_capacity(reply.value_len as usize); + let mut states = Vec::with_capacity(reply.value_len as usize); window_states.for_each(|state| states.push(state)); states }) @@ -606,8 +569,7 @@ impl<'a, C: connection::Connection> XConnection<'a, C> { event: &xproto::ButtonPressEvent, ) -> Option<Event> { Some(Event::Mouse { - event: MouseEvent::from_press_event(&event, self.screen.root) - .ok()?, + event: MouseEvent::from_press_event(&event, self.screen.root).ok()?, }) } @@ -617,8 +579,7 @@ impl<'a, C: connection::Connection> XConnection<'a, C> { event: &xproto::ButtonReleaseEvent, ) -> Option<Event> { Some(Event::Mouse { - event: MouseEvent::from_release_event(&event, self.screen.root) - .ok()?, + event: MouseEvent::from_release_event(&event, self.screen.root).ok()?, }) } @@ -628,8 +589,7 @@ impl<'a, C: connection::Connection> XConnection<'a, C> { event: &xproto::MotionNotifyEvent, ) -> Option<Event> { Some(Event::Mouse { - event: MouseEvent::from_motion_event(&event, self.screen.root) - .ok()?, + event: MouseEvent::from_motion_event(&event, self.screen.root).ok()?, }) } @@ -639,8 +599,7 @@ impl<'a, C: connection::Connection> XConnection<'a, C> { event: &xproto::KeyPressEvent, ) -> Option<Event> { Some(Event::Key { - key_code: KeyCode::from_press_event(&event) - .without_mask(ModMask::M2), + key_code: KeyCode::from_press_event(&event).without_mask(ModMask::M2), }) } @@ -859,9 +818,7 @@ impl<'a, C: connection::Connection> XConnection<'a, C> { event: &xproto::PropertyNotifyEvent, ) -> Option<Event> { if event.state == xproto::Property::NEW_VALUE { - if event.atom == self.atoms.WM_NAME - || event.atom == self.atoms._NET_WM_NAME - { + if event.atom == self.atoms.WM_NAME || event.atom == self.atoms._NET_WM_NAME { return Some(Event::Property { window: event.window, kind: PropertyKind::Name, @@ -886,8 +843,7 @@ impl<'a, C: connection::Connection> XConnection<'a, C> { } } - if event.atom == self.atoms._NET_WM_STRUT - || event.atom == self.atoms._NET_WM_STRUT_PARTIAL + if event.atom == self.atoms._NET_WM_STRUT || event.atom == self.atoms._NET_WM_STRUT_PARTIAL { return Some(Event::Property { window: event.window, @@ -921,8 +877,7 @@ impl<'a, C: connection::Connection> XConnection<'a, C> { for i in 1..=2 { if state.is_none() { if data[i] != 0 { - state = - self.get_window_state_from_atom(data[i] as Atom); + state = self.get_window_state_from_atom(data[i] as Atom); } } } @@ -947,8 +902,7 @@ impl<'a, C: connection::Connection> XConnection<'a, C> { let width = data.get(3); let height = data.get(4); - if x.is_none() || y.is_none() || width.is_none() || height.is_none() - { + if x.is_none() || y.is_none() || width.is_none() || height.is_none() { return None; } @@ -1086,8 +1040,7 @@ impl<'a, C: connection::Connection> Connection for XConnection<'a, C> { } fn connected_outputs(&self) -> Vec<Screen> { - let resources = - randr::get_screen_resources(self.conn, self.check_window); + let resources = randr::get_screen_resources(self.conn, self.check_window); if let Ok(resources) = resources { if let Ok(reply) = resources.reply() { @@ -1139,15 +1092,14 @@ impl<'a, C: connection::Connection> Connection for XConnection<'a, C> { #[inline] fn get_pointer_position(&self) -> Pos { - self.conn.query_pointer(self.screen.root).map_or( - Pos::default(), - |cookie| { + self.conn + .query_pointer(self.screen.root) + .map_or(Pos::default(), |cookie| { cookie.reply().map_or(Pos::default(), |reply| Pos { x: reply.root_x as i32, y: reply.root_y as i32, }) - }, - ) + }) } #[inline] @@ -1172,16 +1124,10 @@ impl<'a, C: connection::Connection> Connection for XConnection<'a, C> { ), }; - drop(self.conn.warp_pointer( - x11rb::NONE, - window, - 0, - 0, - 0, - 0, - pos.x as i16, - pos.y as i16, - )); + drop( + self.conn + .warp_pointer(x11rb::NONE, window, 0, 0, 0, 0, pos.x as i16, pos.y as i16), + ); } #[inline] @@ -1206,16 +1152,10 @@ impl<'a, C: connection::Connection> Connection for XConnection<'a, C> { window: Window, pos: Pos, ) { - drop(self.conn.warp_pointer( - x11rb::NONE, - window, - 0, - 0, - 0, - 0, - pos.x as i16, - pos.y as i16, - )); + drop( + self.conn + .warp_pointer(x11rb::NONE, window, 0, 0, 0, 0, pos.x as i16, pos.y as i16), + ); } #[inline] @@ -1227,8 +1167,7 @@ impl<'a, C: connection::Connection> Connection for XConnection<'a, C> { if let Ok(_) = self.conn.grab_pointer( false, self.screen.root, - u32::from(EventMask::POINTER_MOTION | EventMask::BUTTON_RELEASE) - as u16, + u32::from(EventMask::POINTER_MOTION | EventMask::BUTTON_RELEASE) as u16, xproto::GrabMode::ASYNC, xproto::GrabMode::ASYNC, self.screen.root, @@ -1268,25 +1207,22 @@ impl<'a, C: connection::Connection> Connection for XConnection<'a, C> { } fn cleanup(&self) { - drop(self.conn.ungrab_key( - xproto::Grab::ANY, - self.screen.root, - xproto::ModMask::ANY, - )); + drop( + self.conn + .ungrab_key(xproto::Grab::ANY, self.screen.root, xproto::ModMask::ANY), + ); drop(self.conn.destroy_window(self.check_window)); drop( - self.conn.delete_property( - self.screen.root, - self.atoms._NET_ACTIVE_WINDOW, - ), + self.conn + .delete_property(self.screen.root, self.atoms._NET_ACTIVE_WINDOW), ); - drop(self.conn.delete_property( - self.screen.root, - self.atoms._NET_SUPPORTING_WM_CHECK, - )); + drop( + self.conn + .delete_property(self.screen.root, self.atoms._NET_SUPPORTING_WM_CHECK), + ); drop( self.conn @@ -1387,8 +1323,7 @@ impl<'a, C: connection::Connection> Connection for XConnection<'a, C> { window: Window, focus_follows_mouse: bool, ) { - let aux = xproto::ChangeWindowAttributesAux::default() - .event_mask(self.window_event_mask); + let aux = xproto::ChangeWindowAttributesAux::default().event_mask(self.window_event_mask); drop(self.conn.change_window_attributes(window, &aux)); } @@ -1416,8 +1351,8 @@ impl<'a, C: connection::Connection> Connection for XConnection<'a, C> { &self, window: Window, ) { - let aux = xproto::ChangeWindowAttributesAux::default() - .event_mask(EventMask::STRUCTURE_NOTIFY); + let aux = + xproto::ChangeWindowAttributesAux::default().event_mask(EventMask::STRUCTURE_NOTIFY); drop(self.conn.change_window_attributes(window, &aux)); } @@ -1457,12 +1392,10 @@ impl<'a, C: connection::Connection> Connection for XConnection<'a, C> { parent: Window, pos: Pos, ) { - drop(self.conn.reparent_window( - window, - parent, - pos.x as i16, - pos.y as i16, - )); + drop( + self.conn + .reparent_window(window, parent, pos.x as i16, pos.y as i16), + ); } #[inline] @@ -1471,12 +1404,10 @@ impl<'a, C: connection::Connection> Connection for XConnection<'a, C> { window: Window, pos: Pos, ) { - drop(self.conn.reparent_window( - window, - self.screen.root, - pos.x as i16, - pos.y as i16, - )); + drop( + self.conn + .reparent_window(window, self.screen.root, pos.x as i16, pos.y as i16), + ); } #[inline] @@ -1492,9 +1423,7 @@ impl<'a, C: connection::Connection> Connection for XConnection<'a, C> { &self, window: Window, ) -> bool { - match self - .send_protocol_client_message(window, self.atoms.WM_DELETE_WINDOW) - { + match self.send_protocol_client_message(window, self.atoms.WM_DELETE_WINDOW) { Ok(_) => self.flush(), Err(_) => false, } @@ -1564,11 +1493,10 @@ impl<'a, C: connection::Connection> Connection for XConnection<'a, C> { &self, window: Window, ) { - drop(self.conn.set_input_focus( - xproto::InputFocus::PARENT, - window, - x11rb::CURRENT_TIME, - )); + drop( + self.conn + .set_input_focus(xproto::InputFocus::PARENT, window, x11rb::CURRENT_TIME), + ); drop(self.conn.change_property32( xproto::PropMode::REPLACE, @@ -1585,8 +1513,7 @@ impl<'a, C: connection::Connection> Connection for XConnection<'a, C> { window: Window, sibling: Option<Window>, ) { - let mut aux = xproto::ConfigureWindowAux::default() - .stack_mode(xproto::StackMode::ABOVE); + let mut aux = xproto::ConfigureWindowAux::default().stack_mode(xproto::StackMode::ABOVE); if let Some(sibling) = sibling { aux = aux.sibling(sibling); @@ -1601,8 +1528,7 @@ impl<'a, C: connection::Connection> Connection for XConnection<'a, C> { window: Window, sibling: Option<Window>, ) { - let mut aux = xproto::ConfigureWindowAux::default() - .stack_mode(xproto::StackMode::BELOW); + let mut aux = xproto::ConfigureWindowAux::default().stack_mode(xproto::StackMode::BELOW); if let Some(sibling) = sibling { aux = aux.sibling(sibling); @@ -1651,8 +1577,7 @@ impl<'a, C: connection::Connection> Connection for XConnection<'a, C> { } } - let aux = xproto::ChangeWindowAttributesAux::default() - .event_mask(self.root_event_mask); + let aux = xproto::ChangeWindowAttributesAux::default().event_mask(self.root_event_mask); drop(self.conn.change_window_attributes(self.screen.root, &aux)); @@ -1682,11 +1607,10 @@ impl<'a, C: connection::Connection> Connection for XConnection<'a, C> { &self, window: Window, ) { - drop(self.conn.ungrab_button( - xproto::ButtonIndex::ANY, - window, - xproto::ModMask::ANY, - )); + drop( + self.conn + .ungrab_button(xproto::ButtonIndex::ANY, window, xproto::ModMask::ANY), + ); } #[inline] @@ -1698,10 +1622,8 @@ impl<'a, C: connection::Connection> Connection for XConnection<'a, C> { )); drop( - self.conn.delete_property( - self.screen.root, - self.atoms._NET_ACTIVE_WINDOW, - ), + self.conn + .delete_property(self.screen.root, self.atoms._NET_ACTIVE_WINDOW), ); } @@ -1722,8 +1644,7 @@ impl<'a, C: connection::Connection> Connection for XConnection<'a, C> { window: Window, color: u32, ) { - let aux = - xproto::ChangeWindowAttributesAux::default().border_pixel(color); + let aux = xproto::ChangeWindowAttributesAux::default().border_pixel(color); drop(self.conn.change_window_attributes(window, &aux)); } @@ -1740,14 +1661,15 @@ impl<'a, C: connection::Connection> Connection for XConnection<'a, C> { &xproto::ChangeGCAux::new().foreground(color), )); - drop(self.conn.poly_fill_rectangle(window, self.background_gc, &[ - xproto::Rectangle { - x: 0, - y: 0, - width: geometry.dim.w as u16, - height: geometry.dim.h as u16, - }, - ])); + drop( + self.conn + .poly_fill_rectangle(window, self.background_gc, &[xproto::Rectangle { + x: 0, + y: 0, + width: geometry.dim.w as u16, + height: geometry.dim.h as u16, + }]), + ); } } @@ -1773,12 +1695,10 @@ impl<'a, C: connection::Connection> Connection for XConnection<'a, C> { override_redirect: false, }; - drop(self.conn.send_event( - false, - window, - EventMask::STRUCTURE_NOTIFY, - &event, - )); + drop( + self.conn + .send_event(false, window, EventMask::STRUCTURE_NOTIFY, &event), + ); } } } @@ -1814,8 +1734,7 @@ impl<'a, C: connection::Connection> Connection for XConnection<'a, C> { ) -> Option<Pid> { let id_spec = protocol::res::ClientIdSpec { client: window, - mask: u8::from(protocol::res::ClientIdMask::LOCAL_CLIENT_PID) - as u32, + mask: u8::from(protocol::res::ClientIdMask::LOCAL_CLIENT_PID) as u32, }; protocol::res::query_client_ids(self.conn, &[id_spec]) @@ -1824,9 +1743,7 @@ impl<'a, C: connection::Connection> Connection for XConnection<'a, C> { .and_then(|reply| { for i in reply.ids { if (i.spec.mask - & (u8::from( - protocol::res::ClientIdMask::LOCAL_CLIENT_PID, - )) as u32) + & (u8::from(protocol::res::ClientIdMask::LOCAL_CLIENT_PID)) as u32) != 0 { if i.value.len() > 0 && i.value[0] != 0 { @@ -1844,15 +1761,14 @@ impl<'a, C: connection::Connection> Connection for XConnection<'a, C> { &self, window: Window, ) -> bool { - let do_not_manage = - self.conn - .get_window_attributes(window) - .map_or(false, |cookie| { - cookie.reply().map_or(false, |reply| { - reply.override_redirect - || reply.class == xproto::WindowClass::INPUT_ONLY - }) - }); + let do_not_manage = self + .conn + .get_window_attributes(window) + .map_or(false, |cookie| { + cookie.reply().map_or(false, |reply| { + reply.override_redirect || reply.class == xproto::WindowClass::INPUT_ONLY + }) + }); if do_not_manage { return false; @@ -1882,8 +1798,8 @@ impl<'a, C: connection::Connection> Connection for XConnection<'a, C> { return true; } - let has_float_state = self - .window_is_any_of_state(window, &[self.atoms._NET_WM_STATE_MODAL]); + let has_float_state = + self.window_is_any_of_state(window, &[self.atoms._NET_WM_STATE_MODAL]); if has_float_state { return true; @@ -1896,8 +1812,7 @@ impl<'a, C: connection::Connection> Connection for XConnection<'a, C> { } self.get_window_geometry(window).map_or(false, |geometry| { - let (_, size_hints) = - self.get_icccm_window_size_hints(window, None, &None); + let (_, size_hints) = self.get_icccm_window_size_hints(window, None, &None); size_hints.map_or(false, |size_hints| { size_hints.min_width.map_or(false, |min_width| { size_hints.min_height.map_or(false, |min_height| { @@ -1924,21 +1839,17 @@ impl<'a, C: connection::Connection> Connection for XConnection<'a, C> { .map_or(false, |cookie| { cookie.reply().map_or(false, |reply| { let default_state = properties::WmHintsState::Normal; - let initial_state = - properties::WmHints::get(self.conn, window) - .ok() - .map_or(default_state, |cookie| { - cookie.reply().map_or(default_state, |reply| { - reply - .initial_state - .map_or(default_state, |i| i) - }) - }); + let initial_state = properties::WmHints::get(self.conn, window).ok().map_or( + default_state, + |cookie| { + cookie.reply().map_or(default_state, |reply| { + reply.initial_state.map_or(default_state, |i| i) + }) + }, + ); reply.class != xproto::WindowClass::INPUT_ONLY - && !self.window_is_any_of_state(window, &[self - .atoms - ._NET_WM_STATE_HIDDEN]) + && !self.window_is_any_of_state(window, &[self.atoms._NET_WM_STATE_HIDDEN]) && match initial_state { properties::WmHintsState::Normal => true, _ => false, @@ -1978,12 +1889,8 @@ impl<'a, C: connection::Connection> Connection for XConnection<'a, C> { let wm_hints = properties::WmHints { input: hints.input, initial_state: match hints.initial_state { - Some(IcccmWindowState::Normal) => { - Some(properties::WmHintsState::Normal) - }, - Some(IcccmWindowState::Iconic) => { - Some(properties::WmHintsState::Iconic) - }, + Some(IcccmWindowState::Normal) => Some(properties::WmHintsState::Normal), + Some(IcccmWindowState::Iconic) => Some(properties::WmHintsState::Iconic), _ => None, }, icon_pixmap: None, @@ -2016,9 +1923,9 @@ impl<'a, C: connection::Connection> Connection for XConnection<'a, C> { .map_or(String::from(NO_NAME), |cookie| { cookie.reply().map_or(String::from(NO_NAME), |reply| { std::str::from_utf8( - &reply.value8().map_or(Vec::new(), |value| { - value.collect::<Vec<u8>>() - }), + &reply + .value8() + .map_or(Vec::new(), |value| value.collect::<Vec<u8>>()), ) .map_or(String::from(NO_NAME), |name| name.to_string()) }) @@ -2032,17 +1939,12 @@ impl<'a, C: connection::Connection> Connection for XConnection<'a, C> { ) -> String { const NO_CLASS: &str = "n/a"; - properties::WmClass::get(self.conn, window).map_or( - String::from(NO_CLASS), - |cookie| { - cookie.reply().map_or(String::from(NO_CLASS), |reply| { - std::str::from_utf8(reply.class()) - .map_or(String::from(NO_CLASS), |class| { - String::from(class) - }) - }) - }, - ) + properties::WmClass::get(self.conn, window).map_or(String::from(NO_CLASS), |cookie| { + cookie.reply().map_or(String::from(NO_CLASS), |reply| { + std::str::from_utf8(reply.class()) + .map_or(String::from(NO_CLASS), |class| String::from(class)) + }) + }) } #[inline] @@ -2052,17 +1954,12 @@ impl<'a, C: connection::Connection> Connection for XConnection<'a, C> { ) -> String { const NO_INSTANCE: &str = "n/a"; - properties::WmClass::get(self.conn, window).map_or( - String::from(NO_INSTANCE), - |cookie| { - cookie.reply().map_or(String::from(NO_INSTANCE), |reply| { - std::str::from_utf8(reply.instance()) - .map_or(String::from(NO_INSTANCE), |instance| { - String::from(instance) - }) - }) - }, - ) + properties::WmClass::get(self.conn, window).map_or(String::from(NO_INSTANCE), |cookie| { + cookie.reply().map_or(String::from(NO_INSTANCE), |reply| { + std::str::from_utf8(reply.instance()) + .map_or(String::from(NO_INSTANCE), |instance| String::from(instance)) + }) + }) } #[inline] @@ -2082,8 +1979,7 @@ impl<'a, C: connection::Connection> Connection for XConnection<'a, C> { .ok()? .reply() .map_or(None, |transient_for| { - let transient_for: Vec<u32> = - transient_for.value32()?.collect(); + let transient_for: Vec<u32> = transient_for.value32()?.collect(); if transient_for.is_empty() { None @@ -2110,8 +2006,7 @@ impl<'a, C: connection::Connection> Connection for XConnection<'a, C> { .ok()? .reply() .map_or(None, |client_leader| { - let client_leader: Vec<u32> = - client_leader.value32()?.collect(); + let client_leader: Vec<u32> = client_leader.value32()?.collect(); if client_leader.is_empty() { None @@ -2154,10 +2049,9 @@ impl<'a, C: connection::Connection> Connection for XConnection<'a, C> { min_window_dim: Option<Dim>, current_size_hints: &Option<SizeHints>, ) -> (bool, Option<SizeHints>) { - let size_hints = - properties::WmSizeHints::get_normal_hints(self.conn, window) - .ok() - .map_or(None, |cookie| cookie.reply().ok()); + let size_hints = properties::WmSizeHints::get_normal_hints(self.conn, window) + .ok() + .map_or(None, |cookie| cookie.reply().ok()); if size_hints.is_none() { return (current_size_hints.is_none(), None); @@ -2165,25 +2059,22 @@ impl<'a, C: connection::Connection> Connection for XConnection<'a, C> { let size_hints = size_hints.unwrap(); - let (by_user, pos) = - size_hints.position.map_or((false, None), |(spec, x, y)| { - ( - match spec { - properties::WmSizeHintsSpecification::UserSpecified => { - true - }, - _ => false, - }, - if x > 0 || y > 0 { - Some(Pos { - x, - y, - }) - } else { - None - }, - ) - }); + let (by_user, pos) = size_hints.position.map_or((false, None), |(spec, x, y)| { + ( + match spec { + properties::WmSizeHintsSpecification::UserSpecified => true, + _ => false, + }, + if x > 0 || y > 0 { + Some(Pos { + x, + y, + }) + } else { + None + }, + ) + }); let (sh_min_width, sh_min_height) = size_hints.min_size.map_or((None, None), |(width, height)| { @@ -2277,64 +2168,52 @@ impl<'a, C: connection::Connection> Connection for XConnection<'a, C> { None }; - let (inc_width, inc_height) = size_hints.size_increment.map_or( - (None, None), - |(inc_width, inc_height)| { - ( - if inc_width > 0 && inc_width < 0xFFFF { - Some(inc_width as u32) - } else { - None - }, - if inc_height > 0 && inc_height < 0xFFFF { - Some(inc_height as u32) - } else { - None - }, - ) - }, - ); - - let ((min_ratio, max_ratio), (min_ratio_vulgar, max_ratio_vulgar)) = - size_hints.aspect.map_or( - ((None, None), (None, None)), - |(min_ratio, max_ratio)| { + let (inc_width, inc_height) = + size_hints + .size_increment + .map_or((None, None), |(inc_width, inc_height)| { ( - ( - if min_ratio.numerator > 0 - && min_ratio.denominator > 0 - { - Some( - min_ratio.numerator as f64 - / min_ratio.denominator as f64, - ) - } else { - None - }, - if max_ratio.numerator > 0 - && max_ratio.denominator > 0 - { - Some( - max_ratio.numerator as f64 - / max_ratio.denominator as f64, - ) - } else { - None - }, - ), - ( - Some(Ratio { - numerator: min_ratio.numerator as i32, - denominator: min_ratio.denominator as i32, - }), - Some(Ratio { - numerator: max_ratio.numerator as i32, - denominator: max_ratio.denominator as i32, - }), - ), + if inc_width > 0 && inc_width < 0xFFFF { + Some(inc_width as u32) + } else { + None + }, + if inc_height > 0 && inc_height < 0xFFFF { + Some(inc_height as u32) + } else { + None + }, ) - }, - ); + }); + + let ((min_ratio, max_ratio), (min_ratio_vulgar, max_ratio_vulgar)) = size_hints + .aspect + .map_or(((None, None), (None, None)), |(min_ratio, max_ratio)| { + ( + ( + if min_ratio.numerator > 0 && min_ratio.denominator > 0 { + Some(min_ratio.numerator as f64 / min_ratio.denominator as f64) + } else { + None + }, + if max_ratio.numerator > 0 && max_ratio.denominator > 0 { + Some(max_ratio.numerator as f64 / max_ratio.denominator as f64) + } else { + None + }, + ), + ( + Some(Ratio { + numerator: min_ratio.numerator as i32, + denominator: min_ratio.denominator as i32, + }), + Some(Ratio { + numerator: max_ratio.numerator as i32, + denominator: max_ratio.denominator as i32, + }), + ), + ) + }); let size_hints = Some(SizeHints { by_user, @@ -2560,24 +2439,16 @@ impl<'a, C: connection::Connection> Connection for XConnection<'a, C> { match state { WindowState::Modal => self.atoms._NET_WM_STATE_MODAL, WindowState::Sticky => self.atoms._NET_WM_STATE_STICKY, - WindowState::MaximizedVert => { - self.atoms._NET_WM_STATE_MAXIMIZED_VERT - }, - WindowState::MaximizedHorz => { - self.atoms._NET_WM_STATE_MAXIMIZED_HORZ - }, + WindowState::MaximizedVert => self.atoms._NET_WM_STATE_MAXIMIZED_VERT, + WindowState::MaximizedHorz => self.atoms._NET_WM_STATE_MAXIMIZED_HORZ, WindowState::Shaded => self.atoms._NET_WM_STATE_SHADED, - WindowState::SkipTaskbar => { - self.atoms._NET_WM_STATE_SKIP_TASKBAR - }, + WindowState::SkipTaskbar => self.atoms._NET_WM_STATE_SKIP_TASKBAR, WindowState::SkipPager => self.atoms._NET_WM_STATE_SKIP_PAGER, WindowState::Hidden => self.atoms._NET_WM_STATE_HIDDEN, WindowState::Fullscreen => self.atoms._NET_WM_STATE_FULLSCREEN, WindowState::Above => self.atoms._NET_WM_STATE_ABOVE, WindowState::Below => self.atoms._NET_WM_STATE_BELOW, - WindowState::DemandsAttention => { - self.atoms._NET_WM_STATE_DEMANDS_ATTENTION - }, + WindowState::DemandsAttention => self.atoms._NET_WM_STATE_DEMANDS_ATTENTION, }, on, ); @@ -2872,14 +2743,11 @@ impl<'a, C: connection::Connection> Connection for XConnection<'a, C> { .ok() .and_then(|cookie| cookie.reply().ok()) .map(|types| { - let types: Vec<u32> = types - .value32() - .map_or(Vec::new(), |value| value.collect()); + let types: Vec<u32> = + types.value32().map_or(Vec::new(), |value| value.collect()); for type_ in types { - if let Some(type_) = - self.get_window_type_from_atom(type_) - { + if let Some(type_) = self.get_window_type_from_atom(type_) { window_types.push(type_); } } @@ -2916,14 +2784,11 @@ impl<'a, C: connection::Connection> Connection for XConnection<'a, C> { .ok() .and_then(|cookie| cookie.reply().ok()) .map(|states| { - let states: Vec<u32> = states - .value32() - .map_or(Vec::new(), |value| value.collect()); + let states: Vec<u32> = + states.value32().map_or(Vec::new(), |value| value.collect()); for state in states { - if let Some(state) = - self.get_window_state_from_atom(state) - { + if let Some(state) = self.get_window_state_from_atom(state) { window_states.push(state); } } @@ -2938,9 +2803,7 @@ impl<'a, C: connection::Connection> Connection for XConnection<'a, C> { &self, window: Window, ) -> bool { - self.window_is_any_of_state(window, &[self - .atoms - ._NET_WM_STATE_FULLSCREEN]) + self.window_is_any_of_state(window, &[self.atoms._NET_WM_STATE_FULLSCREEN]) } #[inline] @@ -2964,8 +2827,8 @@ impl<'a, C: connection::Connection> Connection for XConnection<'a, C> { &self, window: Window, ) -> bool { - let has_sticky_state = self - .window_is_any_of_state(window, &[self.atoms._NET_WM_STATE_STICKY]); + let has_sticky_state = + self.window_is_any_of_state(window, &[self.atoms._NET_WM_STATE_STICKY]); if has_sticky_state { return true;