From 78e3daf5f82b5870e998faf0e1efeaa048730976 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Sat, 26 Apr 2025 13:23:57 +0300 Subject: overview: Activate window upon dropping from interactive move --- src/layout/mod.rs | 18 +++++++++--------- src/layout/monitor.rs | 22 +++++++++++++++++++--- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/src/layout/mod.rs b/src/layout/mod.rs index c9ddfbaa..e62380b2 100644 --- a/src/layout/mod.rs +++ b/src/layout/mod.rs @@ -3543,6 +3543,7 @@ impl Layout { column_idx: None, }, activate, + true, removed.width, removed.is_full_width, removed.is_floating, @@ -4392,11 +4393,7 @@ impl Layout { } // Dragging in the overview shouldn't switch the workspace and so on. - let activate = if self.overview_open { - ActivateWindow::No - } else { - ActivateWindow::Yes - }; + let allow_to_activate_workspace = !self.overview_open; match &mut self.monitor_set { MonitorSet::Normal { @@ -4489,7 +4486,8 @@ impl Layout { id: ws_id, column_idx: Some(column_idx), }, - activate, + ActivateWindow::Yes, + allow_to_activate_workspace, move_.width, move_.is_full_width, false, @@ -4501,7 +4499,8 @@ impl Layout { column_idx, Some(tile_idx), move_.tile, - activate == ActivateWindow::Yes, + true, + allow_to_activate_workspace, ); } InsertPosition::Floating => { @@ -4543,7 +4542,8 @@ impl Layout { id: ws_id, column_idx: None, }, - activate, + ActivateWindow::Yes, + allow_to_activate_workspace, move_.width, move_.is_full_width, true, @@ -4578,7 +4578,7 @@ impl Layout { ws.add_tile( move_.tile, WorkspaceAddWindowTarget::Auto, - activate, + ActivateWindow::Yes, move_.width, move_.is_full_width, move_.is_floating, diff --git a/src/layout/monitor.rs b/src/layout/monitor.rs index 67f3dc77..fc7b53a5 100644 --- a/src/layout/monitor.rs +++ b/src/layout/monitor.rs @@ -439,7 +439,15 @@ impl Monitor { // monitor. So we can use any workspace, not necessarily the exact target workspace. let tile = self.workspaces[0].make_tile(window); - self.add_tile(tile, target, activate, width, is_full_width, is_floating); + self.add_tile( + tile, + target, + activate, + true, + width, + is_full_width, + is_floating, + ); } pub fn add_column(&mut self, mut workspace_idx: usize, column: Column, activate: bool) { @@ -465,11 +473,14 @@ impl Monitor { } } + #[allow(clippy::too_many_arguments)] pub fn add_tile( &mut self, tile: Tile, target: MonitorAddWindowTarget, activate: ActivateWindow, + // FIXME: Refactor ActivateWindow enum to make this better. + allow_to_activate_workspace: bool, width: ColumnWidth, is_full_width: bool, is_floating: bool, @@ -516,7 +527,7 @@ impl Monitor { workspace_idx += 1; } - if activate.map_smart(|| false) { + if allow_to_activate_workspace && activate.map_smart(|| false) { self.activate_workspace(workspace_idx); } } @@ -528,6 +539,8 @@ impl Monitor { tile_idx: Option, tile: Tile, activate: bool, + // FIXME: Refactor ActivateWindow enum to make this better. + allow_to_activate_workspace: bool, ) { let workspace = &mut self.workspaces[workspace_idx]; @@ -541,7 +554,7 @@ impl Monitor { // Since we're adding window to an existing column, the workspace isn't empty, and // therefore cannot be the last one, so we never need to insert a new empty workspace. - if activate { + if allow_to_activate_workspace && activate { self.activate_workspace(workspace_idx); } } @@ -631,6 +644,7 @@ impl Monitor { column_idx: None, }, ActivateWindow::Yes, + true, removed.width, removed.is_full_width, removed.is_floating, @@ -658,6 +672,7 @@ impl Monitor { column_idx: None, }, ActivateWindow::Yes, + true, removed.width, removed.is_full_width, removed.is_floating, @@ -712,6 +727,7 @@ impl Monitor { } else { ActivateWindow::No }, + true, removed.width, removed.is_full_width, removed.is_floating, -- cgit