chore: Formatting updates
This commit is contained in:
parent
ac889f609d
commit
4ee2763139
9 changed files with 170 additions and 80 deletions
|
|
@ -199,7 +199,9 @@ impl CosmicMapped {
|
|||
|
||||
pub fn has_surface(&self, surface: &WlSurface, surface_type: WindowSurfaceType) -> bool {
|
||||
self.windows().any(|(w, _)| {
|
||||
let Some(toplevel ) = w.wl_surface() else { return false };
|
||||
let Some(toplevel) = w.wl_surface() else {
|
||||
return false;
|
||||
};
|
||||
|
||||
if surface_type.contains(WindowSurfaceType::TOPLEVEL) {
|
||||
if toplevel == *surface {
|
||||
|
|
|
|||
|
|
@ -193,7 +193,9 @@ impl CosmicStack {
|
|||
return;
|
||||
}
|
||||
|
||||
let Some(idx) = windows.iter().position(|w| w == window) else { return };
|
||||
let Some(idx) = windows.iter().position(|w| w == window) else {
|
||||
return;
|
||||
};
|
||||
let window = windows.remove(idx);
|
||||
window.try_force_undecorated(false);
|
||||
window.set_tiled(false);
|
||||
|
|
@ -619,13 +621,7 @@ impl Program for CosmicStackInternal {
|
|||
|
||||
fn view(&self) -> CosmicElement<'_, Self::Message> {
|
||||
let windows = self.windows.lock().unwrap();
|
||||
let Some(width) = self
|
||||
.geometry
|
||||
.lock()
|
||||
.unwrap()
|
||||
.as_ref()
|
||||
.map(|r| r.size.w)
|
||||
else {
|
||||
let Some(width) = self.geometry.lock().unwrap().as_ref().map(|r| r.size.w) else {
|
||||
return iced_widget::row(Vec::new()).into();
|
||||
};
|
||||
let active = self.active.load(Ordering::SeqCst);
|
||||
|
|
|
|||
|
|
@ -722,13 +722,24 @@ where
|
|||
let changes = if unknown_keys {
|
||||
Some(Difference::NewOrRemoved)
|
||||
} else {
|
||||
current_state.iter().filter_map(|(a_id, a_bounds)| {
|
||||
let Some(b_bounds) = last_state.get(a_id) else { return Some(Difference::Movement) };
|
||||
(a_bounds != b_bounds).then(|| if a_bounds.position() != b_bounds.position() { Difference::Movement } else { Difference::Focus })
|
||||
}).fold(None, |a, b| match (a, b) {
|
||||
(None | Some(Difference::Movement), x) => Some(x),
|
||||
(a, _) => a,
|
||||
})
|
||||
current_state
|
||||
.iter()
|
||||
.filter_map(|(a_id, a_bounds)| {
|
||||
let Some(b_bounds) = last_state.get(a_id) else {
|
||||
return Some(Difference::Movement);
|
||||
};
|
||||
(a_bounds != b_bounds).then(|| {
|
||||
if a_bounds.position() != b_bounds.position() {
|
||||
Difference::Movement
|
||||
} else {
|
||||
Difference::Focus
|
||||
}
|
||||
})
|
||||
})
|
||||
.fold(None, |a, b| match (a, b) {
|
||||
(None | Some(Difference::Movement), x) => Some(x),
|
||||
(a, _) => a,
|
||||
})
|
||||
};
|
||||
|
||||
if unknown_keys || changes.is_some() {
|
||||
|
|
|
|||
|
|
@ -260,11 +260,19 @@ impl FloatingLayout {
|
|||
edge: ResizeEdge,
|
||||
amount: i32,
|
||||
) -> bool {
|
||||
let Some(toplevel) = focused.toplevel() else { return false };
|
||||
let Some(mapped) = self.space.elements().find(|m| m.has_surface(&toplevel, WindowSurfaceType::TOPLEVEL)) else { return false };
|
||||
let Some(toplevel) = focused.toplevel() else {
|
||||
return false;
|
||||
};
|
||||
let Some(mapped) = self
|
||||
.space
|
||||
.elements()
|
||||
.find(|m| m.has_surface(&toplevel, WindowSurfaceType::TOPLEVEL))
|
||||
else {
|
||||
return false;
|
||||
};
|
||||
|
||||
let Some(original_geo) = self.space.element_geometry(mapped) else {
|
||||
return false // we don't have that window
|
||||
return false; // we don't have that window
|
||||
};
|
||||
let mut geo = original_geo.clone();
|
||||
|
||||
|
|
@ -297,13 +305,18 @@ impl FloatingLayout {
|
|||
}
|
||||
}
|
||||
|
||||
let Some(bounding_box) = self.space.outputs()
|
||||
let Some(bounding_box) = self
|
||||
.space
|
||||
.outputs()
|
||||
.map(|o| self.space.output_geometry(o).unwrap())
|
||||
.filter(|output_geo| output_geo.overlaps(geo))
|
||||
.fold(None, |res, output_geo| match res {
|
||||
None => Some(output_geo),
|
||||
Some(other) => Some(other.merge(output_geo)),
|
||||
}) else { return true };
|
||||
})
|
||||
else {
|
||||
return true;
|
||||
};
|
||||
|
||||
let (min_size, max_size) = (mapped.min_size(), mapped.max_size());
|
||||
let min_width = min_size.map(|s| s.w).unwrap_or(360);
|
||||
|
|
|
|||
|
|
@ -737,9 +737,13 @@ impl TilingLayout {
|
|||
let queue = self.queues.get_mut(&output).unwrap();
|
||||
let mut tree = queue.trees.back().unwrap().0.copy_clone();
|
||||
|
||||
let Some(target) = seat.get_keyboard().unwrap().current_focus() else { return MoveResult::Done };
|
||||
let Some((node_id, data)) = TilingLayout::currently_focused_node(&mut tree, &seat.active_output(), target) else {
|
||||
return MoveResult::Done
|
||||
let Some(target) = seat.get_keyboard().unwrap().current_focus() else {
|
||||
return MoveResult::Done;
|
||||
};
|
||||
let Some((node_id, data)) =
|
||||
TilingLayout::currently_focused_node(&mut tree, &seat.active_output(), target)
|
||||
else {
|
||||
return MoveResult::Done;
|
||||
};
|
||||
|
||||
// stacks may handle movement internally
|
||||
|
|
@ -783,13 +787,16 @@ impl TilingLayout {
|
|||
let Some(og_parent) = tree.get(&node_id).unwrap().parent().cloned() else {
|
||||
return match data {
|
||||
FocusedNodeData::Window(window) => MoveResult::MoveFurther(window.into()),
|
||||
FocusedNodeData::Group(focus_stack, alive) => MoveResult::MoveFurther(WindowGroup {
|
||||
node: node_id,
|
||||
output: output.downgrade(),
|
||||
alive,
|
||||
focus_stack,
|
||||
}.into()),
|
||||
}
|
||||
FocusedNodeData::Group(focus_stack, alive) => MoveResult::MoveFurther(
|
||||
WindowGroup {
|
||||
node: node_id,
|
||||
output: output.downgrade(),
|
||||
alive,
|
||||
focus_stack,
|
||||
}
|
||||
.into(),
|
||||
),
|
||||
};
|
||||
};
|
||||
let og_idx = tree
|
||||
.children_ids(&og_parent)
|
||||
|
|
@ -1059,11 +1066,19 @@ impl TilingLayout {
|
|||
let output = seat.active_output();
|
||||
let tree = &self.queues.get(&output).unwrap().trees.back().unwrap().0;
|
||||
|
||||
let Some(target) = seat.get_keyboard().unwrap().current_focus() else { return FocusResult::None };
|
||||
let Some(focused) = TilingLayout::currently_focused_node(tree, &seat.active_output(), target).or_else(|| {
|
||||
TilingLayout::last_active_window(tree, focus_stack)
|
||||
.map(|(id, mapped)| (id, FocusedNodeData::Window(mapped)))
|
||||
}) else { return FocusResult::None };
|
||||
let Some(target) = seat.get_keyboard().unwrap().current_focus() else {
|
||||
return FocusResult::None;
|
||||
};
|
||||
let Some(focused) =
|
||||
TilingLayout::currently_focused_node(tree, &seat.active_output(), target).or_else(
|
||||
|| {
|
||||
TilingLayout::last_active_window(tree, focus_stack)
|
||||
.map(|(id, mapped)| (id, FocusedNodeData::Window(mapped)))
|
||||
},
|
||||
)
|
||||
else {
|
||||
return FocusResult::None;
|
||||
};
|
||||
|
||||
let (last_node_id, data) = focused;
|
||||
|
||||
|
|
@ -1248,10 +1263,14 @@ impl TilingLayout {
|
|||
seat: &Seat<State>,
|
||||
) {
|
||||
let output = seat.active_output();
|
||||
let Some(queue) = self.queues.get_mut(&output) else { return };
|
||||
let Some(queue) = self.queues.get_mut(&output) else {
|
||||
return;
|
||||
};
|
||||
let mut tree = queue.trees.back().unwrap().0.copy_clone();
|
||||
|
||||
let Some(target) = seat.get_keyboard().unwrap().current_focus() else { return };
|
||||
let Some(target) = seat.get_keyboard().unwrap().current_focus() else {
|
||||
return;
|
||||
};
|
||||
if let Some((last_active, _)) =
|
||||
TilingLayout::currently_focused_node(&tree, &seat.active_output(), target)
|
||||
{
|
||||
|
|
@ -1293,10 +1312,14 @@ impl TilingLayout {
|
|||
|
||||
pub fn toggle_stacking<'a>(&mut self, seat: &Seat<State>, mut focus_stack: FocusStackMut) {
|
||||
let output = seat.active_output();
|
||||
let Some(queue) = self.queues.get_mut(&output) else { return };
|
||||
let Some(queue) = self.queues.get_mut(&output) else {
|
||||
return;
|
||||
};
|
||||
let mut tree = queue.trees.back().unwrap().0.copy_clone();
|
||||
|
||||
let Some(target) = seat.get_keyboard().unwrap().current_focus() else { return };
|
||||
let Some(target) = seat.get_keyboard().unwrap().current_focus() else {
|
||||
return;
|
||||
};
|
||||
if let Some((last_active, last_active_data)) =
|
||||
TilingLayout::currently_focused_node(&tree, &seat.active_output(), target)
|
||||
{
|
||||
|
|
@ -1409,7 +1432,9 @@ impl TilingLayout {
|
|||
}
|
||||
|
||||
pub fn recalculate(&mut self, output: &Output) {
|
||||
let Some(queue) = self.queues.get_mut(output) else { return };
|
||||
let Some(queue) = self.queues.get_mut(output) else {
|
||||
return;
|
||||
};
|
||||
let mut tree = queue.trees.back().unwrap().0.copy_clone();
|
||||
let blocker = TilingLayout::update_positions(&output, &mut tree, self.gaps);
|
||||
queue.push_tree(tree, ANIMATION_DURATION, blocker);
|
||||
|
|
@ -1553,16 +1578,22 @@ impl TilingLayout {
|
|||
let Some((output, mut node_id)) = self.queues.iter().find_map(|(output, queue)| {
|
||||
let tree = &queue.trees.back().unwrap().0;
|
||||
let root_id = tree.root_node_id()?;
|
||||
let id = match TilingLayout::currently_focused_node(tree, &output.output, focused.clone()) {
|
||||
Some((_id, FocusedNodeData::Window(mapped))) => // we need to make sure the id belongs to this tree..
|
||||
tree.traverse_pre_order_ids(root_id)
|
||||
.unwrap()
|
||||
.find(|id| tree.get(id).unwrap().data().is_mapped(Some(&mapped))),
|
||||
Some((id, FocusedNodeData::Group(_, _))) => Some(id), // in this case the output was already matched, so the id is to be trusted
|
||||
_ => None,
|
||||
};
|
||||
let id =
|
||||
match TilingLayout::currently_focused_node(tree, &output.output, focused.clone()) {
|
||||
Some((_id, FocusedNodeData::Window(mapped))) =>
|
||||
// we need to make sure the id belongs to this tree..
|
||||
{
|
||||
tree.traverse_pre_order_ids(root_id)
|
||||
.unwrap()
|
||||
.find(|id| tree.get(id).unwrap().data().is_mapped(Some(&mapped)))
|
||||
}
|
||||
Some((id, FocusedNodeData::Group(_, _))) => Some(id), // in this case the output was already matched, so the id is to be trusted
|
||||
_ => None,
|
||||
};
|
||||
id.map(|id| (output.output.clone(), id))
|
||||
}) else { return false };
|
||||
}) else {
|
||||
return false;
|
||||
};
|
||||
|
||||
let queue = self.queues.get_mut(&output).unwrap();
|
||||
let mut tree = queue.trees.back().unwrap().0.copy_clone();
|
||||
|
|
@ -1585,7 +1616,13 @@ impl TilingLayout {
|
|||
.unwrap();
|
||||
let Some(other_idx) = (match edges {
|
||||
x if x.intersects(ResizeEdge::TOP_LEFT) => node_idx.checked_sub(1),
|
||||
_ => if tree.children_ids(&group_id).unwrap().count() - 1 > node_idx { Some(node_idx + 1) } else { None },
|
||||
_ => {
|
||||
if tree.children_ids(&group_id).unwrap().count() - 1 > node_idx {
|
||||
Some(node_idx + 1)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}) else {
|
||||
node_id = group_id.clone();
|
||||
continue;
|
||||
|
|
@ -1791,7 +1828,9 @@ impl TilingLayout {
|
|||
match tree.get_mut(window_id).unwrap().data_mut() {
|
||||
Data::Mapped { mapped, .. } => {
|
||||
mapped.convert_to_stack(std::iter::once((output, mapped.bbox())));
|
||||
let Some(stack) = mapped.stack_ref_mut() else { unreachable!() };
|
||||
let Some(stack) = mapped.stack_ref_mut() else {
|
||||
unreachable!()
|
||||
};
|
||||
for surface in window.windows().map(|s| s.0) {
|
||||
stack.add_window(surface, None);
|
||||
}
|
||||
|
|
@ -2456,7 +2495,9 @@ impl TilingLayout {
|
|||
.children_ids(&res_id)
|
||||
.unwrap()
|
||||
.position(|node| {
|
||||
let Some(geo) = geometries.get(node) else { return false };
|
||||
let Some(geo) = geometries.get(node) else {
|
||||
return false;
|
||||
};
|
||||
match orientation {
|
||||
Orientation::Vertical => location.x < geo.loc.x,
|
||||
Orientation::Horizontal => location.y < geo.loc.y,
|
||||
|
|
|
|||
|
|
@ -1442,8 +1442,12 @@ impl Shell {
|
|||
let from_workspace = state.common.shell.workspaces.active_mut(from_output);
|
||||
let maybe_window = from_workspace.focus_stack.get(seat).last().cloned();
|
||||
|
||||
let Some(mapped) = maybe_window else { return Ok(None); };
|
||||
let Some(window_state) = from_workspace.unmap(&mapped) else { return Ok(None); };
|
||||
let Some(mapped) = maybe_window else {
|
||||
return Ok(None);
|
||||
};
|
||||
let Some(window_state) = from_workspace.unmap(&mapped) else {
|
||||
return Ok(None);
|
||||
};
|
||||
|
||||
for (toplevel, _) in mapped.windows() {
|
||||
state
|
||||
|
|
@ -1610,7 +1614,9 @@ impl Shell {
|
|||
pub fn resize(&mut self, seat: &Seat<State>, direction: ResizeDirection, edge: ResizeEdge) {
|
||||
let output = seat.active_output();
|
||||
let (_, idx) = self.workspaces.active_num(&output);
|
||||
let Some(focused) = seat.get_keyboard().unwrap().current_focus() else { return };
|
||||
let Some(focused) = seat.get_keyboard().unwrap().current_focus() else {
|
||||
return;
|
||||
};
|
||||
|
||||
if let Some(workspace) = self.workspaces.get_mut(idx, &output) {
|
||||
let amount = (self
|
||||
|
|
@ -1632,12 +1638,16 @@ impl Shell {
|
|||
{
|
||||
let workspace = self.workspaces.get(idx, &output).unwrap();
|
||||
if old_direction == direction && old_edge == edge {
|
||||
let Some(toplevel) = old_focused.toplevel() else { return };
|
||||
let Some(toplevel) = old_focused.toplevel() else {
|
||||
return;
|
||||
};
|
||||
let Some(mapped) = workspace
|
||||
.mapped()
|
||||
.find(|m| m.has_surface(&toplevel, WindowSurfaceType::TOPLEVEL))
|
||||
.cloned()
|
||||
else { return };
|
||||
else {
|
||||
return;
|
||||
};
|
||||
let mut resize_state = mapped.resize_state.lock().unwrap();
|
||||
if let Some(ResizeState::Resizing(data)) = *resize_state {
|
||||
*resize_state = Some(ResizeState::WaitingForCommit(data));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue