shell: Handle tiling_enabled for previous_state better

This commit is contained in:
Victoria Brekenfeld 2024-01-26 18:47:59 +00:00 committed by Victoria Brekenfeld
parent 61a3aa8d79
commit ce74675b0e
3 changed files with 34 additions and 31 deletions

View file

@ -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

View file

@ -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::<std::iter::Empty<_>>::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)
}
}
}
}

View file

@ -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