shell: Add helper for moving workspaces
This commit is contained in:
parent
b6cb945406
commit
248ced83db
1 changed files with 34 additions and 31 deletions
|
|
@ -241,6 +241,27 @@ fn create_workspace(
|
||||||
Workspace::new(workspace_handle, output.clone(), tiling, theme.clone())
|
Workspace::new(workspace_handle, output.clone(), tiling, theme.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn move_workspace_to_group(
|
||||||
|
workspace: &mut Workspace,
|
||||||
|
group: &WorkspaceGroupHandle,
|
||||||
|
workspace_state: &mut WorkspaceUpdateGuard<'_, State>,
|
||||||
|
toplevel_info_state: &mut ToplevelInfoState<State, CosmicSurface>,
|
||||||
|
) {
|
||||||
|
let old_workspace_handle = workspace.handle;
|
||||||
|
workspace.handle = workspace_state.create_workspace(group).unwrap();
|
||||||
|
workspace_state.set_workspace_capabilities(
|
||||||
|
&workspace.handle,
|
||||||
|
[WorkspaceCapabilities::Activate].into_iter(),
|
||||||
|
);
|
||||||
|
for window in workspace.mapped() {
|
||||||
|
for (surface, _) in window.windows() {
|
||||||
|
toplevel_info_state.toplevel_leave_workspace(&surface, &old_workspace_handle);
|
||||||
|
toplevel_info_state.toplevel_enter_workspace(&surface, &workspace.handle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
workspace_state.remove_workspace(old_workspace_handle);
|
||||||
|
}
|
||||||
|
|
||||||
impl WorkspaceSet {
|
impl WorkspaceSet {
|
||||||
fn new(
|
fn new(
|
||||||
state: &mut WorkspaceUpdateGuard<'_, State>,
|
state: &mut WorkspaceUpdateGuard<'_, State>,
|
||||||
|
|
@ -509,6 +530,7 @@ impl Workspaces {
|
||||||
output: &Output,
|
output: &Output,
|
||||||
workspace_state: &mut WorkspaceUpdateGuard<'_, State>,
|
workspace_state: &mut WorkspaceUpdateGuard<'_, State>,
|
||||||
toplevel_info_state: &mut ToplevelInfoState<State, CosmicSurface>,
|
toplevel_info_state: &mut ToplevelInfoState<State, CosmicSurface>,
|
||||||
|
xdg_activation_state: &XdgActivationState,
|
||||||
) {
|
) {
|
||||||
if self.sets.contains_key(output) {
|
if self.sets.contains_key(output) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -546,20 +568,12 @@ impl Workspaces {
|
||||||
{
|
{
|
||||||
let set = self.sets.get_mut(output).unwrap();
|
let set = self.sets.get_mut(output).unwrap();
|
||||||
for workspace in &mut moved_workspaces {
|
for workspace in &mut moved_workspaces {
|
||||||
workspace_state.remove_workspace(workspace.handle);
|
move_workspace_to_group(
|
||||||
let old_workspace_handle = workspace.handle;
|
workspace,
|
||||||
workspace.handle = workspace_state.create_workspace(&set.group).unwrap();
|
&set.group,
|
||||||
workspace_state.set_workspace_capabilities(
|
workspace_state,
|
||||||
&workspace.handle,
|
toplevel_info_state,
|
||||||
[WorkspaceCapabilities::Activate].into_iter(),
|
|
||||||
);
|
);
|
||||||
for window in workspace.mapped() {
|
|
||||||
for (surface, _) in window.windows() {
|
|
||||||
toplevel_info_state
|
|
||||||
.toplevel_leave_workspace(&surface, &old_workspace_handle);
|
|
||||||
toplevel_info_state.toplevel_enter_workspace(&surface, &workspace.handle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
set.workspaces.extend(moved_workspaces);
|
set.workspaces.extend(moved_workspaces);
|
||||||
for workspace in &mut set.workspaces {
|
for workspace in &mut set.workspaces {
|
||||||
|
|
@ -604,24 +618,12 @@ impl Workspaces {
|
||||||
let workspace_group = new_set.group;
|
let workspace_group = new_set.group;
|
||||||
for mut workspace in set.workspaces {
|
for mut workspace in set.workspaces {
|
||||||
// update workspace protocol state
|
// update workspace protocol state
|
||||||
workspace_state.remove_workspace(workspace.handle);
|
move_workspace_to_group(
|
||||||
let workspace_handle =
|
&mut workspace,
|
||||||
workspace_state.create_workspace(&workspace_group).unwrap();
|
&workspace_group,
|
||||||
workspace_state.set_workspace_capabilities(
|
workspace_state,
|
||||||
&workspace_handle,
|
toplevel_info_state,
|
||||||
[WorkspaceCapabilities::Activate].into_iter(),
|
);
|
||||||
);
|
|
||||||
let old_workspace_handle = workspace.handle;
|
|
||||||
workspace.handle = workspace_handle;
|
|
||||||
|
|
||||||
for window in workspace.mapped() {
|
|
||||||
for (surface, _) in window.windows() {
|
|
||||||
toplevel_info_state
|
|
||||||
.toplevel_leave_workspace(&surface, &old_workspace_handle);
|
|
||||||
toplevel_info_state
|
|
||||||
.toplevel_enter_workspace(&surface, &workspace.handle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// update mapping
|
// update mapping
|
||||||
workspace.set_output(&new_output, toplevel_info_state);
|
workspace.set_output(&new_output, toplevel_info_state);
|
||||||
|
|
@ -980,6 +982,7 @@ impl Shell {
|
||||||
output,
|
output,
|
||||||
&mut self.workspace_state.update(),
|
&mut self.workspace_state.update(),
|
||||||
&mut self.toplevel_info_state,
|
&mut self.toplevel_info_state,
|
||||||
|
&self.xdg_activation_state,
|
||||||
);
|
);
|
||||||
self.refresh(); // fixes indicies of any moved workspaces
|
self.refresh(); // fixes indicies of any moved workspaces
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue