Skip to content

Commit

Permalink
shell: Handle tiling_enabled for previous_state better
Browse files Browse the repository at this point in the history
  • Loading branch information
Drakulix committed Jan 26, 2024
1 parent 9da41d4 commit 8804a7c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 24 deletions.
31 changes: 17 additions & 14 deletions src/shell/grabs/moving.rs
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,22 @@ impl Drop for MoveGrab {
}

match previous {
ManagedLayer::Tiling => {
ManagedLayer::Sticky => {
grab_state.window.set_geometry(Rectangle::from_loc_and_size(
window_location,
grab_state.window.geometry().size.as_global(),
));
let set = state.common.shell.workspaces.sets.get_mut(&output).unwrap();
let (window, location) = set
.sticky_layer
.drop_window(grab_state.window, window_location.to_local(&output));

Some((window, location.to_global(&output)))
}
ManagedLayer::Tiling if state
.common
.shell
.active_space(&output).tiling_enabled => {
let (window, location) = state
.common
.shell
Expand All @@ -555,7 +570,7 @@ impl Drop for MoveGrab {
.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(),
Expand All @@ -567,18 +582,6 @@ impl Drop for MoveGrab {
);
Some((window, location.to_global(&output)))
}
ManagedLayer::Sticky => {
grab_state.window.set_geometry(Rectangle::from_loc_and_size(
window_location,
grab_state.window.geometry().size.as_global(),
));
let set = state.common.shell.workspaces.sets.get_mut(&output).unwrap();
let (window, location) = set
.sticky_layer
.drop_window(grab_state.window, window_location.to_local(&output));

Some((window, location.to_global(&output)))
}
}
} else {
None
Expand Down
14 changes: 7 additions & 7 deletions src/shell/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
};
}

Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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)
}
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/shell/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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(),
Expand All @@ -466,7 +467,6 @@ impl Workspace {
);
Some(state.original_geometry.size.as_logical())
}
ManagedLayer::Sticky => unreachable!(),
}
} else {
None
Expand Down

0 comments on commit 8804a7c

Please sign in to comment.