Skip to content

Commit

Permalink
layout: Preserve the Tile when moving across workspaces
Browse files Browse the repository at this point in the history
  • Loading branch information
YaLTeR committed Dec 22, 2024
1 parent 4ff4bfb commit b6101ea
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 24 deletions.
6 changes: 6 additions & 0 deletions src/layout/floating.rs
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,9 @@ impl<W: LayoutElement> FloatingSpace<W> {

let win_size = Size::from((win_width, win_height));
win.request_size_once(win_size, animate);

// Store it right away so pending resizes are not lost when moving across floating spaces.
tile.set_floating_window_size(win_size);
}

pub fn set_window_height(&mut self, id: Option<&W::Id>, change: SizeChange, animate: bool) {
Expand Down Expand Up @@ -636,6 +639,9 @@ impl<W: LayoutElement> FloatingSpace<W> {

let win_size = Size::from((win_width, win_height));
win.request_size_once(win_size, animate);

// Store it right away so pending resizes are not lost when moving across floating spaces.
tile.set_floating_window_size(win_size);
}

fn focus_directional(
Expand Down
60 changes: 36 additions & 24 deletions src/layout/monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -530,14 +530,18 @@ impl<W: LayoutElement> Monitor<W> {
return;
};

self.add_window(
new_idx,
removed.tile.into_window(),
true,
removed.width,
removed.is_full_width,
removed.is_floating,
);
if removed.is_floating {
self.add_floating_tile(new_idx, removed.tile, None, true);
} else {
self.add_tile(
new_idx,
None,
removed.tile,
true,
removed.width,
removed.is_full_width,
);
}
}

pub fn move_to_workspace_down(&mut self) {
Expand All @@ -553,14 +557,18 @@ impl<W: LayoutElement> Monitor<W> {
return;
};

self.add_window(
new_idx,
removed.tile.into_window(),
true,
removed.width,
removed.is_full_width,
removed.is_floating,
);
if removed.is_floating {
self.add_floating_tile(new_idx, removed.tile, None, true);
} else {
self.add_tile(
new_idx,
None,
removed.tile,
true,
removed.width,
removed.is_full_width,
);
}
}

pub fn move_to_workspace(&mut self, window: Option<&W::Id>, idx: usize) {
Expand Down Expand Up @@ -592,14 +600,18 @@ impl<W: LayoutElement> Monitor<W> {
return;
};

self.add_window(
new_idx,
removed.tile.into_window(),
activate,
removed.width,
removed.is_full_width,
removed.is_floating,
);
if removed.is_floating {
self.add_floating_tile(new_idx, removed.tile, None, activate);
} else {
self.add_tile(
new_idx,
None,
removed.tile,
activate,
removed.width,
removed.is_full_width,
);
}

if self.workspace_switch.is_none() {
self.clean_up_workspaces();
Expand Down

0 comments on commit b6101ea

Please sign in to comment.