From ce74675b0ebc23e9bf547b9315450fd74d7ae49c Mon Sep 17 00:00:00 2001 From: Victoria Brekenfeld Date: Fri, 26 Jan 2024 18:47:59 +0000 Subject: [PATCH] shell: Handle tiling_enabled for previous_state better --- src/shell/grabs/moving.rs | 45 +++++++++++++++++++++------------------ src/shell/mod.rs | 14 ++++++------ src/shell/workspace.rs | 6 +++--- 3 files changed, 34 insertions(+), 31 deletions(-) diff --git a/src/shell/grabs/moving.rs b/src/shell/grabs/moving.rs index d7ae34ca..e8545b68 100644 --- a/src/shell/grabs/moving.rs +++ b/src/shell/grabs/moving.rs @@ -546,27 +546,6 @@ impl Drop for MoveGrab { } match previous { - ManagedLayer::Tiling => { - let (window, location) = state - .common - .shell - .active_space_mut(&output) - .tiling_layer - .drop_window(grab_state.window); - Some((window, location.to_global(&output))) - } - ManagedLayer::Floating => { - grab_state.window.set_geometry(Rectangle::from_loc_and_size( - window_location, - grab_state.window.geometry().size.as_global(), - )); - let workspace = state.common.shell.active_space_mut(&output); - let (window, location) = workspace.floating_layer.drop_window( - grab_state.window, - window_location.to_local(&workspace.output), - ); - Some((window, location.to_global(&output))) - } ManagedLayer::Sticky => { grab_state.window.set_geometry(Rectangle::from_loc_and_size( window_location, @@ -579,6 +558,30 @@ impl Drop for MoveGrab { Some((window, location.to_global(&output))) } + ManagedLayer::Tiling if state + .common + .shell + .active_space(&output).tiling_enabled => { + let (window, location) = state + .common + .shell + .active_space_mut(&output) + .tiling_layer + .drop_window(grab_state.window); + Some((window, location.to_global(&output))) + } + _ => { + grab_state.window.set_geometry(Rectangle::from_loc_and_size( + window_location, + grab_state.window.geometry().size.as_global(), + )); + let workspace = state.common.shell.active_space_mut(&output); + let (window, location) = workspace.floating_layer.drop_window( + grab_state.window, + window_location.to_local(&workspace.output), + ); + Some((window, location.to_global(&output))) + } } } else { None diff --git a/src/shell/mod.rs b/src/shell/mod.rs index 2cfa1cbe..2cc44baf 100644 --- a/src/shell/mod.rs +++ b/src/shell/mod.rs @@ -1605,12 +1605,12 @@ impl Shell { .sticky_layer .map(mapped, None) } - ManagedLayer::Floating => new_workspace.floating_layer.map(mapped, None), - ManagedLayer::Tiling => { + ManagedLayer::Tiling if new_workspace.tiling_enabled => { new_workspace .tiling_layer .map(mapped, Option::>::None, None) } + _ => new_workspace.floating_layer.map(mapped, None), }; } @@ -1949,7 +1949,7 @@ impl Shell { .space_for_handle_mut(to) .unwrap(); // checked above let focus_stack = seat.map(|seat| to_workspace.focus_stack.get(&seat)); - if window_state.layer == ManagedLayer::Floating { + if window_state.layer == ManagedLayer::Floating || !to_workspace.tiling_enabled { to_workspace.floating_layer.map(mapped.clone(), None); } else { to_workspace.tiling_layer.map( @@ -2934,16 +2934,16 @@ impl Shell { .take() .unwrap_or(ManagedLayer::Floating) { - ManagedLayer::Floating => { - workspace.floating_layer.map(mapped.clone(), geometry.loc) - } - ManagedLayer::Tiling => { + ManagedLayer::Tiling if workspace.tiling_enabled => { let focus_stack = workspace.focus_stack.get(seat); workspace .tiling_layer .map(mapped.clone(), Some(focus_stack.iter()), None); } ManagedLayer::Sticky => unreachable!(), + _ => { + workspace.floating_layer.map(mapped.clone(), geometry.loc) + } } } } diff --git a/src/shell/workspace.rs b/src/shell/workspace.rs index daecb0f7..a9b8e090 100644 --- a/src/shell/workspace.rs +++ b/src/shell/workspace.rs @@ -444,7 +444,7 @@ impl Workspace { let mut state = elem.maximized_state.lock().unwrap(); if let Some(state) = state.take() { match state.original_layer { - ManagedLayer::Tiling => { + ManagedLayer::Tiling if self.tiling_enabled => { // should still be mapped in tiling self.floating_layer.unmap(&elem); elem.output_enter(&self.output, elem.bbox()); @@ -456,7 +456,8 @@ impl Workspace { .element_geometry(&elem) .map(|geo| geo.size.as_logical()) } - ManagedLayer::Floating => { + ManagedLayer::Sticky => unreachable!(), + _ => { elem.set_maximized(false); self.floating_layer.map_internal( elem.clone(), @@ -466,7 +467,6 @@ impl Workspace { ); Some(state.original_geometry.size.as_logical()) } - ManagedLayer::Sticky => unreachable!(), } } else { None