Skip to content

Commit

Permalink
toplevel-management: Move window, not whole stack
Browse files Browse the repository at this point in the history
If the window is part of a stack, remove it then map it outside of the
stack, before calling `Shell::move_window.` Somewhat similar to the code
in `Shell::move_request`.

It would be more elegant if `move_window` handled this in some way, but
I can't think of a way to change the API there that would be better than
this.

(Perhaps some of the naming of methods could also be updated, given
"window" in functions like this means a `CosmicMapped`.)

Protocol support for moving workspaces would also be useful, but should
involve a new protocol object representing the stack.

Fixes pop-os/cosmic-workspaces-epoch#41.
  • Loading branch information
ids1024 committed Jan 28, 2025
1 parent 9b3a42d commit 649547d
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions src/wayland/handlers/toplevel_management.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use smithay::{
};

use crate::{
shell::{CosmicSurface, Shell, WorkspaceDelta},
shell::{element::CosmicWindow, CosmicSurface, Shell, WorkspaceDelta},
utils::prelude::*,
wayland::protocols::{
toplevel_info::ToplevelInfoHandler,
Expand Down Expand Up @@ -109,8 +109,28 @@ impl ToplevelManagementHandler for State {
};

let mut shell = self.common.shell.write().unwrap();
if let Some(mapped) = shell.element_for_surface(window).cloned() {
if let Some(from_workspace) = shell.space_for(&mapped) {
if let Some(mut mapped) = shell.element_for_surface(window).cloned() {
if let Some(from_workspace) = shell.space_for_mut(&mapped) {
// If window is part of a stack, remove it and map it outside the stack
if let Some(stack) = mapped.stack_ref() {
stack.remove_window(&window);
mapped = CosmicWindow::new(
window.clone(),
self.common.event_loop_handle.clone(),
self.common.theme.clone(),
)
.into();
if from_workspace.tiling_enabled {
from_workspace.tiling_layer.map(
mapped.clone(),
None::<std::iter::Empty<_>>,
None,
);
} else {
from_workspace.floating_layer.map(mapped.clone(), None);
}
}

let from_handle = from_workspace.handle;
let seat = shell.seats.last_active().clone();
let res = shell.move_window(
Expand Down

0 comments on commit 649547d

Please sign in to comment.