input/actions: Change active workspace / output when migrated
Without this, a workspace moved with the key binding seems to disappear. This seems more consistent with the behavior of other key bindings.
This commit is contained in:
parent
8aa501c0e0
commit
3debae2495
2 changed files with 37 additions and 17 deletions
|
|
@ -669,8 +669,41 @@ impl State {
|
|||
};
|
||||
|
||||
if let Some(next_output) = next_output {
|
||||
self.common
|
||||
.migrate_workspace(&active_output, &next_output, &active);
|
||||
let mut shell = self.common.shell.write();
|
||||
let mut workspace_state = self.common.workspace_state.update();
|
||||
shell.workspaces.migrate_workspace(
|
||||
&active_output,
|
||||
&next_output,
|
||||
&active,
|
||||
&mut workspace_state,
|
||||
);
|
||||
// Activate workspace on new set, and set that output as active
|
||||
if let Some(new_idx) = shell
|
||||
.workspaces
|
||||
.sets
|
||||
.get(&next_output)
|
||||
.and_then(|set| set.workspaces.iter().position(|w| w.handle == active))
|
||||
{
|
||||
let res = shell.activate(
|
||||
&next_output,
|
||||
new_idx,
|
||||
WorkspaceDelta::new_shortcut(),
|
||||
&mut workspace_state,
|
||||
);
|
||||
drop(workspace_state);
|
||||
drop(shell);
|
||||
if res.is_ok() {
|
||||
self.handle_shortcut_action(
|
||||
Action::SwitchOutput(direction),
|
||||
seat,
|
||||
serial,
|
||||
time,
|
||||
pattern,
|
||||
Some(direction),
|
||||
true,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -878,14 +878,14 @@ impl Workspaces {
|
|||
}
|
||||
|
||||
// Move workspace from one output to another, explicitly by the user
|
||||
fn migrate_workspace(
|
||||
pub fn migrate_workspace(
|
||||
&mut self,
|
||||
from: &Output,
|
||||
to: &Output,
|
||||
handle: &WorkspaceHandle,
|
||||
workspace_state: &mut WorkspaceUpdateGuard<'_, State>,
|
||||
) {
|
||||
if !self.sets.contains_key(to) {
|
||||
if !self.sets.contains_key(to) || from == to {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -1354,19 +1354,6 @@ impl Common {
|
|||
self.refresh(); // cleans up excess of workspaces and empty workspaces
|
||||
}
|
||||
|
||||
pub fn migrate_workspace(&mut self, from: &Output, to: &Output, handle: &WorkspaceHandle) {
|
||||
if from == to {
|
||||
return;
|
||||
}
|
||||
|
||||
let mut shell = self.shell.write();
|
||||
shell
|
||||
.workspaces
|
||||
.migrate_workspace(from, to, handle, &mut self.workspace_state.update());
|
||||
|
||||
std::mem::drop(shell);
|
||||
}
|
||||
|
||||
pub fn update_config(&mut self) {
|
||||
let mut shell = self.shell.write();
|
||||
let shell_ref = &mut *shell;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue