Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/canoe/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,35 @@ impl Context {

/// Focus a window
pub fn focus(&mut self, window_id: WindowId) {
// Unfullscreen any fullscreen window when switching to a different window.
// We cannot rely on self.focused_window here because focus_preview (used
// during alt-tab) may have already changed it.
let fullscreen_ids: Vec<WindowId> = self
.windows
.iter()
.filter_map(|(&id, w)| {
if id != window_id
&& !matches!(w.borrow().fullscreen, super::window::FullscreenState::None)
{
Some(id)
} else {
None
}
})
.collect();
if !fullscreen_ids.is_empty() {
for fs_id in &fullscreen_ids {
if let Some(window) = self.windows.get(fs_id) {
let mut w = window.borrow_mut();
w.exit_fullscreen();
w.pending_unfullscreen_restore = true;
}
}
if let Some(ref rwm) = self.rwm {
rwm.manage_dirty();
}
}

// Move to front of focus stack
self.focus_stack.retain(|&id| id != window_id);
self.focus_stack.insert(0, window_id);
Expand Down