1
0
Fork 0
forked from wry/wry

all: use let chains

This commit is contained in:
Julian Orth 2025-07-01 11:20:48 +02:00
parent 3d5d146d65
commit 286857971a
89 changed files with 1516 additions and 1574 deletions

View file

@ -593,12 +593,12 @@ impl ContainerNode {
if let Some(op) = &seat_state.op {
match op.kind {
SeatOpKind::Move => {
if let CursorType::Seat(_) = id {
if self.state.ui_drag_threshold_reached((x, y), (op.x, op.y)) {
let node = op.child.node.clone();
drop(seats);
seat.start_tile_drag(&node);
}
if let CursorType::Seat(_) = id
&& self.state.ui_drag_threshold_reached((x, y), (op.x, op.y))
{
let node = op.child.node.clone();
drop(seats);
seat.start_tile_drag(&node);
}
}
SeatOpKind::Resize {
@ -1004,13 +1004,14 @@ impl ContainerNode {
pub fn move_child(self: Rc<Self>, child: Rc<dyn ToplevelNode>, direction: Direction) {
// CASE 1: This is the only child of the container. Replace the container by the child.
if self.num_children.get() == 1 {
if let Some(parent) = self.toplevel_data.parent.get() {
if !self.toplevel_data.is_fullscreen.get() && parent.cnode_accepts_child(&*child) {
parent.cnode_replace_child(self.deref(), child.clone());
self.toplevel_data.parent.take();
self.child_nodes.borrow_mut().clear();
self.tl_destroy();
}
if let Some(parent) = self.toplevel_data.parent.get()
&& !self.toplevel_data.is_fullscreen.get()
&& parent.cnode_accepts_child(&*child)
{
parent.cnode_replace_child(self.deref(), child.clone());
self.toplevel_data.parent.take();
self.child_nodes.borrow_mut().clear();
self.tl_destroy();
}
return;
}
@ -1028,17 +1029,17 @@ impl ContainerNode {
false => cc.next(),
};
if let Some(neighbor) = neighbor {
if let Some(cn) = neighbor.node.clone().node_into_container() {
if cn.cnode_accepts_child(&*child) {
if let Some(mc) = self.mono_child.get() {
if mc.node.node_id() == child.node_id() {
self.activate_child2(&neighbor, true);
}
}
self.cnode_remove_child2(&*child, true);
cn.insert_child(child, direction);
return;
if let Some(cn) = neighbor.node.clone().node_into_container()
&& cn.cnode_accepts_child(&*child)
{
if let Some(mc) = self.mono_child.get()
&& mc.node.node_id() == child.node_id()
{
self.activate_child2(&neighbor, true);
}
self.cnode_remove_child2(&*child, true);
cn.insert_child(child, direction);
return;
}
match prev {
true => neighbor.prepend_existing(&cc),
@ -1118,11 +1119,11 @@ impl ContainerNode {
let rect = Rect::new(0, 0, width, height).unwrap();
node.content.set(rect);
node.position_content();
if let Some(mono) = self.mono_child.get() {
if mono.node.node_id() == node.node.node_id() {
let body = self.mono_body.get();
self.mono_content.set(rect.at_point(body.x1(), body.y1()));
}
if let Some(mono) = self.mono_child.get()
&& mono.node.node_id() == node.node.node_id()
{
let body = self.mono_body.get();
self.mono_content.set(rect.at_point(body.x1(), body.y1()));
}
}
@ -1154,10 +1155,8 @@ impl ContainerNode {
if set || propagate {
self.toplevel_data.set_wants_attention(set);
}
if propagate {
if let Some(parent) = self.toplevel_data.parent.get() {
parent.cnode_child_attention_request_changed(self, set);
}
if propagate && let Some(parent) = self.toplevel_data.parent.get() {
parent.cnode_child_attention_request_changed(self, set);
}
}
@ -1751,10 +1750,10 @@ impl Node for ContainerNode {
) {
let id = CursorType::TabletTool(tool.id);
self.pointer_move(tool.seat(), id, tool.cursor(), x, y, false);
if let Some(changes) = changes {
if let Some(pressed) = changes.down {
self.button(id, tool.seat(), time_usec, pressed, BTN_LEFT);
}
if let Some(changes) = changes
&& let Some(pressed) = changes.down
{
self.button(id, tool.seat(), time_usec, pressed, BTN_LEFT);
}
}
@ -2047,14 +2046,13 @@ impl ContainingNode for ContainerNode {
if bottom_outside {
y2 = new_y2.map(|v| v.max(y1.unwrap_or(pos.y1()) + th + 1));
}
if (x1.is_some() && x1 != Some(pos.x1()))
if ((x1.is_some() && x1 != Some(pos.x1()))
|| (x2.is_some() && x2 != Some(pos.x2()))
|| (y1.is_some() && y1 != Some(pos.y1()))
|| (y2.is_some() && y2 != Some(pos.y2()))
|| (y2.is_some() && y2 != Some(pos.y2())))
&& let Some(parent) = self.toplevel_data.parent.get()
{
if let Some(parent) = self.toplevel_data.parent.get() {
parent.cnode_resize_child(&*self, x1, y1, x2, y2);
}
parent.cnode_resize_child(&*self, x1, y1, x2, y2);
}
}

View file

@ -426,10 +426,8 @@ impl FloatNode {
if update_visible {
self.stacked_set_visible(ws.float_visible());
}
if update_pinned {
if let Some(pl) = &*self.pinned_link.borrow_mut() {
ws.output.get().pinned.add_last_existing(pl);
}
if update_pinned && let Some(pl) = &*self.pinned_link.borrow_mut() {
ws.output.get().pinned.add_last_existing(pl);
}
}
@ -588,10 +586,10 @@ impl FloatNode {
if !pressed {
return;
}
if cursor_data.op_type == OpType::Move {
if let Some(tl) = self.child.get() {
tl.node_do_focus(seat, Direction::Unspecified);
}
if cursor_data.op_type == OpType::Move
&& let Some(tl) = self.child.get()
{
tl.node_do_focus(seat, Direction::Unspecified);
}
if cursor_data.double_click_state.click(
&self.state,
@ -600,12 +598,11 @@ impl FloatNode {
cursor_data.y,
) && cursor_data.op_type == OpType::Move
&& !is_icon_press
&& let Some(tl) = self.child.get()
{
if let Some(tl) = self.child.get() {
drop(cursors);
toplevel_set_floating(&self.state, tl, false);
return;
}
drop(cursors);
toplevel_set_floating(&self.state, tl, false);
return;
}
cursor_data.op_active = true;
let pos = self.position.get();
@ -830,16 +827,16 @@ impl Node for FloatNode {
y: Fixed,
) {
self.pointer_move(CursorType::TabletTool(tool.id), tool.cursor(), x, y, false);
if let Some(changes) = changes {
if let Some(pressed) = changes.down {
self.button(
CursorType::TabletTool(tool.id),
tool.cursor(),
tool.seat(),
time_usec,
pressed,
);
}
if let Some(changes) = changes
&& let Some(pressed) = changes.down
{
self.button(
CursorType::TabletTool(tool.id),
tool.cursor(),
tool.seat(),
time_usec,
pressed,
);
}
}

View file

@ -1367,15 +1367,15 @@ impl Node for OutputNode {
usecase: FindTreeUsecase,
) -> FindTreeResult {
if self.state.lock.locked.get() {
if usecase != FindTreeUsecase::SelectToplevel {
if let Some(ls) = self.lock_surface.get() {
tree.push(FoundNode {
node: ls.clone(),
x,
y,
});
return ls.node_find_tree_at(x, y, tree, usecase);
}
if usecase != FindTreeUsecase::SelectToplevel
&& let Some(ls) = self.lock_surface.get()
{
tree.push(FoundNode {
node: ls.clone(),
x,
y,
});
return ls.node_find_tree_at(x, y, tree, usecase);
}
return FindTreeResult::AcceptsInput;
}

View file

@ -444,10 +444,11 @@ impl ToplevelData {
return;
}
self.changed_properties.set(props | change);
if props.is_none() && change.is_some() {
if let Some(node) = self.slf.upgrade() {
mgr.changed(node);
}
if props.is_none()
&& change.is_some()
&& let Some(node) = self.slf.upgrade()
{
mgr.changed(node);
}
}
@ -878,10 +879,10 @@ pub fn default_tile_drag_bounds<T: ToplevelNodeBase + ?Sized>(t: &T, split: Cont
}
pub fn toplevel_parent_container(tl: &dyn ToplevelNode) -> Option<Rc<ContainerNode>> {
if let Some(parent) = tl.tl_data().parent.get() {
if let Some(container) = parent.node_into_container() {
return Some(container);
}
if let Some(parent) = tl.tl_data().parent.get()
&& let Some(container) = parent.node_into_container()
{
return Some(container);
}
None
}

View file

@ -228,10 +228,10 @@ impl WorkspaceNode {
} else {
node.tl_set_visible(false);
}
if let Some(surface) = node.tl_scanout_surface() {
if let Some(fb) = self.output.get().global.connector.connector.drm_feedback() {
surface.send_feedback(&fb);
}
if let Some(surface) = node.tl_scanout_surface()
&& let Some(fb) = self.output.get().global.connector.connector.drm_feedback()
{
surface.send_feedback(&fb);
}
self.output.get().update_presentation_type();
}
@ -242,10 +242,10 @@ impl WorkspaceNode {
if self.visible.get() {
self.output.get().fullscreen_changed();
}
if let Some(surface) = node.tl_scanout_surface() {
if let Some(fb) = surface.client.state.drm_feedback.get() {
surface.send_feedback(&fb);
}
if let Some(surface) = node.tl_scanout_surface()
&& let Some(fb) = surface.client.state.drm_feedback.get()
{
surface.send_feedback(&fb);
}
self.output.get().update_presentation_type();
}
@ -376,36 +376,36 @@ impl Node for WorkspaceNode {
impl ContainingNode for WorkspaceNode {
fn cnode_replace_child(self: Rc<Self>, old: &dyn Node, new: Rc<dyn ToplevelNode>) {
if let Some(container) = self.container.get() {
if container.node_id() == old.node_id() {
let new = match new.node_into_container() {
Some(c) => c,
_ => {
log::error!("cnode_replace_child called with non-container new");
return;
}
};
self.set_container(&new);
return;
}
if let Some(container) = self.container.get()
&& container.node_id() == old.node_id()
{
let new = match new.node_into_container() {
Some(c) => c,
_ => {
log::error!("cnode_replace_child called with non-container new");
return;
}
};
self.set_container(&new);
return;
}
log::error!("Trying to replace child that's not a child");
}
fn cnode_remove_child2(self: Rc<Self>, child: &dyn Node, _preserve_focus: bool) {
if let Some(container) = self.container.get() {
if container.node_id() == child.node_id() {
self.discard_child_properties(&*container);
self.container.set(None);
self.state.damage(self.position.get());
return;
}
if let Some(container) = self.container.get()
&& container.node_id() == child.node_id()
{
self.discard_child_properties(&*container);
self.container.set(None);
self.state.damage(self.position.get());
return;
}
if let Some(fs) = self.fullscreen.get() {
if fs.node_id() == child.node_id() {
self.remove_fullscreen_node();
return;
}
if let Some(fs) = self.fullscreen.get()
&& fs.node_id() == child.node_id()
{
self.remove_fullscreen_node();
return;
}
log::error!("Trying to remove child that's not a child");
}
@ -436,10 +436,10 @@ pub fn move_ws_to_output(
config: WsMoveConfig,
) {
let source = ws.output.get();
if let Some(visible) = source.workspace.get() {
if visible.id == ws.id {
source.workspace.take();
}
if let Some(visible) = source.workspace.get()
&& visible.id == ws.id
{
source.workspace.take();
}
let mut new_source_ws = None;
if !config.source_is_destroyed && !source.is_dummy && source.workspace.is_none() {
@ -459,11 +459,11 @@ pub fn move_ws_to_output(
}
ws.set_output(&target);
'link: {
if let Some(before) = config.before {
if let Some(link) = &*before.output_link.borrow() {
link.prepend_existing(ws);
break 'link;
}
if let Some(before) = config.before
&& let Some(link) = &*before.output_link.borrow()
{
link.prepend_existing(ws);
break 'link;
}
target.workspaces.add_last_existing(&ws);
}