mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-23 02:05:33 +07:00
Preserve tile when moving across monitors
This commit is contained in:
+19
-47
@@ -794,40 +794,6 @@ impl<W: LayoutElement> Layout<W> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: pos
|
|
||||||
pub fn add_window_by_idx(
|
|
||||||
&mut self,
|
|
||||||
monitor_idx: usize,
|
|
||||||
workspace_idx: usize,
|
|
||||||
window: W,
|
|
||||||
activate: bool,
|
|
||||||
width: ColumnWidth,
|
|
||||||
is_full_width: bool,
|
|
||||||
is_floating: bool,
|
|
||||||
) {
|
|
||||||
let MonitorSet::Normal {
|
|
||||||
monitors,
|
|
||||||
active_monitor_idx,
|
|
||||||
..
|
|
||||||
} = &mut self.monitor_set
|
|
||||||
else {
|
|
||||||
panic!()
|
|
||||||
};
|
|
||||||
|
|
||||||
monitors[monitor_idx].add_window(
|
|
||||||
workspace_idx,
|
|
||||||
window,
|
|
||||||
activate,
|
|
||||||
width,
|
|
||||||
is_full_width,
|
|
||||||
is_floating,
|
|
||||||
);
|
|
||||||
|
|
||||||
if activate {
|
|
||||||
*active_monitor_idx = monitor_idx;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Adds a new window to the layout on a specific workspace.
|
/// Adds a new window to the layout on a specific workspace.
|
||||||
pub fn add_window_to_named_workspace(
|
pub fn add_window_to_named_workspace(
|
||||||
&mut self,
|
&mut self,
|
||||||
@@ -2839,7 +2805,7 @@ impl<W: LayoutElement> Layout<W> {
|
|||||||
|
|
||||||
let ws = &mut mon.workspaces[ws_idx];
|
let ws = &mut mon.workspaces[ws_idx];
|
||||||
let transaction = Transaction::new();
|
let transaction = Transaction::new();
|
||||||
let removed = if let Some(window) = window {
|
let mut removed = if let Some(window) = window {
|
||||||
ws.remove_tile(window, transaction)
|
ws.remove_tile(window, transaction)
|
||||||
} else if let Some(removed) = ws.remove_active_tile(transaction) {
|
} else if let Some(removed) = ws.remove_active_tile(transaction) {
|
||||||
removed
|
removed
|
||||||
@@ -2847,19 +2813,25 @@ impl<W: LayoutElement> Layout<W> {
|
|||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
self.add_window_by_idx(
|
removed.tile.stop_move_animations();
|
||||||
new_idx,
|
|
||||||
workspace_idx,
|
let mon = &mut monitors[new_idx];
|
||||||
removed.tile.into_window(),
|
if removed.is_floating {
|
||||||
activate,
|
mon.add_floating_tile(workspace_idx, removed.tile, activate);
|
||||||
removed.width,
|
} else {
|
||||||
removed.is_full_width,
|
mon.add_tile(
|
||||||
removed.is_floating,
|
workspace_idx,
|
||||||
);
|
None,
|
||||||
|
removed.tile,
|
||||||
|
activate,
|
||||||
|
removed.width,
|
||||||
|
removed.is_full_width,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if activate {
|
||||||
|
*active_monitor_idx = new_idx;
|
||||||
|
}
|
||||||
|
|
||||||
let MonitorSet::Normal { monitors, .. } = &mut self.monitor_set else {
|
|
||||||
unreachable!()
|
|
||||||
};
|
|
||||||
let mon = &mut monitors[mon_idx];
|
let mon = &mut monitors[mon_idx];
|
||||||
if mon.workspace_switch.is_none() {
|
if mon.workspace_switch.is_none() {
|
||||||
monitors[mon_idx].clean_up_workspaces();
|
monitors[mon_idx].clean_up_workspaces();
|
||||||
|
|||||||
@@ -408,10 +408,6 @@ impl<W: LayoutElement> Tile<W> {
|
|||||||
&mut self.window
|
&mut self.window
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn into_window(self) -> W {
|
|
||||||
self.window
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn is_fullscreen(&self) -> bool {
|
pub fn is_fullscreen(&self) -> bool {
|
||||||
self.is_fullscreen
|
self.is_fullscreen
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user