From 71842f07bdc566498f503b1924e959278eec2ead Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Thu, 12 Dec 2024 09:06:02 +0300 Subject: Make interactive move keep in the same layout (floating/tiling) --- src/layout/mod.rs | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'src/layout/mod.rs') diff --git a/src/layout/mod.rs b/src/layout/mod.rs index 916b6b41..772b7610 100644 --- a/src/layout/mod.rs +++ b/src/layout/mod.rs @@ -327,6 +327,8 @@ struct InteractiveMoveData { pub(self) width: ColumnWidth, /// Whether the window column was full-width. pub(self) is_full_width: bool, + /// Whether the window targets the floating layout. + pub(self) is_floating: bool, /// Pointer location within the visual window geometry as ratio from geometry size. /// /// This helps the pointer remain inside the window as it resizes. @@ -2451,6 +2453,12 @@ impl Layout { return; } + // No insert hint when targeting floating. + if move_.is_floating { + self.interactive_move = Some(InteractiveMoveState::Moving(move_)); + return; + } + let _span = tracy_client::span!("Layout::update_insert_hint::update"); if let Some(mon) = self.monitor_for_output_mut(&move_.output) { @@ -2661,6 +2669,7 @@ impl Layout { pub fn toggle_window_floating(&mut self, window: Option<&W::Id>) { if let Some(InteractiveMoveState::Moving(move_)) = &mut self.interactive_move { if window.is_none() || window == Some(move_.tile.window().id()) { + move_.is_floating = !move_.is_floating; return; } } @@ -3193,7 +3202,7 @@ impl Layout { mut tile, width, is_full_width, - is_floating: _, + is_floating, } = self.remove_window(window, Transaction::new()).unwrap(); tile.stop_move_animations(); @@ -3242,6 +3251,7 @@ impl Layout { pointer_pos_within_output, width, is_full_width, + is_floating, pointer_ratio_within_window, }; @@ -3345,14 +3355,25 @@ impl Layout { .position(|ws| ws.id() == ws_id) .unwrap(); - let ws = &mut mon.workspaces[ws_idx]; - let position = ws.get_insert_position(move_.pointer_pos_within_output - offset); + let position = if move_.is_floating { + InsertPosition::Floating + } else { + let ws = &mut mon.workspaces[ws_idx]; + ws.get_insert_position(move_.pointer_pos_within_output - offset) + }; + (mon, ws_idx, position, offset) } else { let mon = &mut monitors[*active_monitor_idx]; // No point in trying to use the pointer position on the wrong output. let (ws, offset) = mon.workspaces_with_render_positions().next().unwrap(); - let position = ws.get_insert_position(Point::from((0., 0.))); + + let position = if move_.is_floating { + InsertPosition::Floating + } else { + ws.get_insert_position(Point::from((0., 0.))) + }; + let ws_id = ws.id(); let ws_idx = mon .workspaces -- cgit