Skip to content

Commit aab3a06

Browse files
add action for floating panes
1 parent 16bbe35 commit aab3a06

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

zellij-server/src/panes/floating_panes/mod.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,13 @@ impl FloatingPanes {
635635
}
636636
}
637637

638+
pub fn focus_last_pane(&mut self, client_id: ClientId) {
639+
if let Some(pane_id) = self.active_panes.get_last(&client_id).copied() {
640+
self.focus_pane(pane_id, client_id);
641+
self.set_force_render();
642+
}
643+
}
644+
638645
pub fn move_active_pane_down(&mut self, client_id: ClientId) {
639646
if let Some(active_pane_id) = self.active_panes.get(&client_id) {
640647
self.move_pane_down(*active_pane_id);
@@ -829,6 +836,11 @@ impl FloatingPanes {
829836
self.set_force_render();
830837
}
831838
pub fn focus_pane(&mut self, pane_id: PaneId, client_id: ClientId) {
839+
if let Some(focused_pane) = self.active_panes.get(&client_id) {
840+
if pane_id != *focused_pane {
841+
self.active_panes.set_last_pane(client_id, *focused_pane);
842+
}
843+
}
832844
let pane_is_selectable = self
833845
.panes
834846
.get(&pane_id)

zellij-server/src/tab/mod.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3000,7 +3000,10 @@ impl Tab {
30003000
if !self.has_selectable_panes() {
30013001
return;
30023002
}
3003-
if self.tiled_panes.fullscreen_is_active() {
3003+
if self.floating_panes.panes_are_visible() {
3004+
self.floating_panes.focus_last_pane(client_id);
3005+
}
3006+
else if self.tiled_panes.fullscreen_is_active() {
30043007
self.switch_last_pane_fullscreen(client_id);
30053008
return;
30063009
}
@@ -4999,7 +5002,11 @@ impl Tab {
49995002
.with_context(err_context)?;
50005003
self.floating_panes.add_pane(pane_id, pane);
50015004
if should_focus_new_pane {
5002-
self.floating_panes.focus_pane_for_all_clients(pane_id);
5005+
if let Some(client_id) = client_id {
5006+
self.floating_panes.focus_pane(pane_id, client_id);
5007+
} else {
5008+
self.floating_panes.focus_pane_for_all_clients(pane_id);
5009+
}
50035010
}
50045011
}
50055012
if self.auto_layout && !self.swap_layouts.is_floating_damaged() {

0 commit comments

Comments
 (0)