mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-24 02:01:18 +07:00
Fix move-window-to-workspace panic when wrong monitor is active
This commit is contained in:
+32
-5
@@ -1904,9 +1904,22 @@ impl<W: LayoutElement> Layout<W> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let monitor = if let Some(window) = window {
|
||||||
|
match &mut self.monitor_set {
|
||||||
|
MonitorSet::Normal { monitors, .. } => monitors
|
||||||
|
.iter_mut()
|
||||||
|
.find(|mon| mon.has_window(window))
|
||||||
|
.unwrap(),
|
||||||
|
MonitorSet::NoOutputs { .. } => {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
let Some(monitor) = self.active_monitor() else {
|
let Some(monitor) = self.active_monitor() else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
monitor
|
||||||
|
};
|
||||||
monitor.move_to_workspace(window, idx);
|
monitor.move_to_workspace(window, idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4935,11 +4948,7 @@ mod tests {
|
|||||||
window_id,
|
window_id,
|
||||||
workspace_idx,
|
workspace_idx,
|
||||||
} => {
|
} => {
|
||||||
let window_id = window_id.filter(|id| {
|
let window_id = window_id.filter(|id| layout.has_window(id));
|
||||||
layout
|
|
||||||
.active_monitor()
|
|
||||||
.map_or(false, |mon| mon.has_window(id))
|
|
||||||
});
|
|
||||||
layout.move_to_workspace(window_id.as_ref(), workspace_idx);
|
layout.move_to_workspace(window_id.as_ref(), workspace_idx);
|
||||||
}
|
}
|
||||||
Op::MoveColumnToWorkspaceDown => layout.move_column_to_workspace_down(),
|
Op::MoveColumnToWorkspaceDown => layout.move_column_to_workspace_down(),
|
||||||
@@ -6708,6 +6717,24 @@ mod tests {
|
|||||||
check_ops(&ops);
|
check_ops(&ops);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn move_window_to_workspace_with_different_active_output() {
|
||||||
|
let ops = [
|
||||||
|
Op::AddOutput(0),
|
||||||
|
Op::AddOutput(1),
|
||||||
|
Op::AddWindow {
|
||||||
|
params: TestWindowParams::new(0),
|
||||||
|
},
|
||||||
|
Op::FocusOutput(1),
|
||||||
|
Op::MoveWindowToWorkspace {
|
||||||
|
window_id: Some(0),
|
||||||
|
workspace_idx: 2,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
check_ops(&ops);
|
||||||
|
}
|
||||||
|
|
||||||
fn parent_id_causes_loop(layout: &Layout<TestWindow>, id: usize, mut parent_id: usize) -> bool {
|
fn parent_id_causes_loop(layout: &Layout<TestWindow>, id: usize, mut parent_id: usize) -> bool {
|
||||||
if parent_id == id {
|
if parent_id == id {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user