actions: Remember previous workspace on extended action
This commit is contained in:
parent
d76f372c29
commit
1a019280f3
2 changed files with 99 additions and 21 deletions
|
|
@ -221,7 +221,7 @@ impl State {
|
||||||
time,
|
time,
|
||||||
pattern,
|
pattern,
|
||||||
direction,
|
direction,
|
||||||
false,
|
true,
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -267,7 +267,7 @@ impl State {
|
||||||
time,
|
time,
|
||||||
pattern,
|
pattern,
|
||||||
direction,
|
direction,
|
||||||
false,
|
true,
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -401,7 +401,7 @@ impl State {
|
||||||
time,
|
time,
|
||||||
pattern,
|
pattern,
|
||||||
direction,
|
direction,
|
||||||
false,
|
true,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -484,7 +484,7 @@ impl State {
|
||||||
time,
|
time,
|
||||||
pattern,
|
pattern,
|
||||||
direction,
|
direction,
|
||||||
false,
|
true,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -514,14 +514,35 @@ impl State {
|
||||||
let next_output = shell.next_output(¤t_output, direction).cloned();
|
let next_output = shell.next_output(¤t_output, direction).cloned();
|
||||||
|
|
||||||
if let Some(next_output) = next_output {
|
if let Some(next_output) = next_output {
|
||||||
let idx = shell.workspaces.active_num(&next_output).1;
|
let res = {
|
||||||
let res = shell.activate(
|
let mut workspace_guard = self.common.workspace_state.update();
|
||||||
&next_output,
|
if propagate {
|
||||||
idx,
|
if let Some((serial, prev_output, prev_idx)) =
|
||||||
WorkspaceDelta::new_shortcut(),
|
shell.previous_workspace_idx.take()
|
||||||
&mut self.common.workspace_state.update(),
|
{
|
||||||
);
|
if seat.last_modifier_change().is_some_and(|s| s == serial)
|
||||||
seat.set_active_output(&next_output);
|
&& prev_output == current_output
|
||||||
|
{
|
||||||
|
let _ = shell.activate(
|
||||||
|
¤t_output,
|
||||||
|
prev_idx,
|
||||||
|
WorkspaceDelta::new_shortcut(),
|
||||||
|
&mut workspace_guard,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let idx = shell.workspaces.active_num(&next_output).1;
|
||||||
|
let res = shell.activate(
|
||||||
|
&next_output,
|
||||||
|
idx,
|
||||||
|
WorkspaceDelta::new_shortcut(),
|
||||||
|
&mut workspace_guard,
|
||||||
|
);
|
||||||
|
seat.set_active_output(&next_output);
|
||||||
|
res
|
||||||
|
};
|
||||||
|
|
||||||
if let Ok(Some(new_pos)) = res {
|
if let Ok(Some(new_pos)) = res {
|
||||||
let new_target = shell
|
let new_target = shell
|
||||||
|
|
@ -585,14 +606,34 @@ impl State {
|
||||||
let next_output = shell.next_output(&focused_output, direction).cloned();
|
let next_output = shell.next_output(&focused_output, direction).cloned();
|
||||||
|
|
||||||
if let Some(next_output) = next_output {
|
if let Some(next_output) = next_output {
|
||||||
let res = shell.move_current_window(
|
let res = {
|
||||||
seat,
|
let mut workspace_guard = self.common.workspace_state.update();
|
||||||
&focused_output,
|
let res = shell.move_current_window(
|
||||||
(&next_output, None),
|
seat,
|
||||||
is_move_action,
|
&focused_output,
|
||||||
Some(direction),
|
(&next_output, None),
|
||||||
&mut self.common.workspace_state.update(),
|
is_move_action,
|
||||||
);
|
Some(direction),
|
||||||
|
&mut workspace_guard,
|
||||||
|
);
|
||||||
|
|
||||||
|
if is_move_action && propagate {
|
||||||
|
if let Some((_, prev_output, prev_idx)) =
|
||||||
|
shell.previous_workspace_idx.take()
|
||||||
|
{
|
||||||
|
if prev_output == focused_output {
|
||||||
|
let _ = shell.activate(
|
||||||
|
&focused_output,
|
||||||
|
prev_idx,
|
||||||
|
WorkspaceDelta::new_shortcut(),
|
||||||
|
&mut workspace_guard,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
res
|
||||||
|
};
|
||||||
|
|
||||||
if let Ok(Some((target, new_pos))) = res {
|
if let Ok(Some((target, new_pos))) = res {
|
||||||
std::mem::drop(shell);
|
std::mem::drop(shell);
|
||||||
Shell::set_focus(self, Some(&target), seat, None, is_move_action);
|
Shell::set_focus(self, Some(&target), seat, None, is_move_action);
|
||||||
|
|
@ -659,6 +700,24 @@ impl State {
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(direction) = dir {
|
if let Some(direction) = dir {
|
||||||
|
if let Some(last_mod_serial) = seat.last_modifier_change() {
|
||||||
|
let mut shell = self.common.shell.write().unwrap();
|
||||||
|
if !shell
|
||||||
|
.previous_workspace_idx
|
||||||
|
.as_ref()
|
||||||
|
.is_some_and(|(serial, _, _)| *serial == last_mod_serial)
|
||||||
|
{
|
||||||
|
let current_output = seat.active_output();
|
||||||
|
let workspace_idx =
|
||||||
|
shell.workspaces.active_num(¤t_output).1;
|
||||||
|
shell.previous_workspace_idx = Some((
|
||||||
|
last_mod_serial,
|
||||||
|
current_output.downgrade(),
|
||||||
|
workspace_idx,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let action = match (
|
let action = match (
|
||||||
direction,
|
direction,
|
||||||
self.common.config.cosmic_conf.workspaces.workspace_layout,
|
self.common.config.cosmic_conf.workspaces.workspace_layout,
|
||||||
|
|
@ -701,6 +760,23 @@ impl State {
|
||||||
.move_current_element(direction, seat);
|
.move_current_element(direction, seat);
|
||||||
match res {
|
match res {
|
||||||
MoveResult::MoveFurther(_move_further) => {
|
MoveResult::MoveFurther(_move_further) => {
|
||||||
|
if let Some(last_mod_serial) = seat.last_modifier_change() {
|
||||||
|
let mut shell = self.common.shell.write().unwrap();
|
||||||
|
if !shell
|
||||||
|
.previous_workspace_idx
|
||||||
|
.as_ref()
|
||||||
|
.is_some_and(|(serial, _, _)| *serial == last_mod_serial)
|
||||||
|
{
|
||||||
|
let current_output = seat.active_output();
|
||||||
|
let workspace_idx = shell.workspaces.active_num(¤t_output).1;
|
||||||
|
shell.previous_workspace_idx = Some((
|
||||||
|
last_mod_serial,
|
||||||
|
current_output.downgrade(),
|
||||||
|
workspace_idx,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let action = match (
|
let action = match (
|
||||||
direction,
|
direction,
|
||||||
self.common.config.cosmic_conf.workspaces.workspace_layout,
|
self.common.config.cosmic_conf.workspaces.workspace_layout,
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ use smithay::{
|
||||||
},
|
},
|
||||||
Seat,
|
Seat,
|
||||||
},
|
},
|
||||||
output::Output,
|
output::{Output, WeakOutput},
|
||||||
reexports::{
|
reexports::{
|
||||||
wayland_protocols::ext::{
|
wayland_protocols::ext::{
|
||||||
session_lock::v1::server::ext_session_lock_v1::ExtSessionLockV1,
|
session_lock::v1::server::ext_session_lock_v1::ExtSessionLockV1,
|
||||||
|
|
@ -257,6 +257,7 @@ pub struct Shell {
|
||||||
pub override_redirect_windows: Vec<X11Surface>,
|
pub override_redirect_windows: Vec<X11Surface>,
|
||||||
pub session_lock: Option<SessionLock>,
|
pub session_lock: Option<SessionLock>,
|
||||||
pub seats: Seats,
|
pub seats: Seats,
|
||||||
|
pub previous_workspace_idx: Option<(Serial, WeakOutput, usize)>,
|
||||||
|
|
||||||
theme: cosmic::Theme,
|
theme: cosmic::Theme,
|
||||||
pub active_hint: bool,
|
pub active_hint: bool,
|
||||||
|
|
@ -1344,6 +1345,7 @@ impl Shell {
|
||||||
pending_activations: HashMap::new(),
|
pending_activations: HashMap::new(),
|
||||||
override_redirect_windows: Vec::new(),
|
override_redirect_windows: Vec::new(),
|
||||||
session_lock: None,
|
session_lock: None,
|
||||||
|
previous_workspace_idx: None,
|
||||||
|
|
||||||
theme,
|
theme,
|
||||||
active_hint: config.cosmic_conf.active_hint,
|
active_hint: config.cosmic_conf.active_hint,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue