input: Add SendToWorkspace action

This commit is contained in:
Victoria Brekenfeld 2023-01-24 19:22:00 +01:00
parent 40077f4a5a
commit 5b644b59f7
3 changed files with 29 additions and 11 deletions

View file

@ -851,6 +851,10 @@ pub enum Action {
MoveToNextWorkspace,
MoveToPreviousWorkspace,
MoveToLastWorkspace,
SendToWorkspace(u8),
SendToNextWorkspace,
SendToPreviousWorkspace,
SendToLastWorkspace,
NextOutput,
PreviousOutput,

View file

@ -617,20 +617,23 @@ impl State {
.saturating_sub(1);
let _ = self.common.shell.activate(&current_output, workspace);
}
Action::MoveToWorkspace(key_num) => {
x @ Action::MoveToWorkspace(_) | x @ Action::SendToWorkspace(_) => {
let current_output = seat.active_output();
let workspace = match key_num {
0 => 9,
x => x - 1,
let follow = matches!(x, Action::MoveToWorkspace(_));
let workspace = match x {
Action::MoveToWorkspace(0) | Action::SendToWorkspace(0) => 9,
Action::MoveToWorkspace(x) | Action::SendToWorkspace(x) => x - 1,
_ => unreachable!(),
};
Shell::move_current_window(
self,
seat,
&current_output,
(&current_output, Some(workspace as usize)),
follow,
);
}
Action::MoveToNextWorkspace => {
x @ Action::MoveToNextWorkspace | x @ Action::SendToNextWorkspace => {
let current_output = seat.active_output();
let workspace = self
.common
@ -644,9 +647,10 @@ impl State {
seat,
&current_output,
(&current_output, Some(workspace as usize)),
matches!(x, Action::MoveToNextWorkspace),
);
}
Action::MoveToPreviousWorkspace => {
x @ Action::MoveToPreviousWorkspace | x @ Action::SendToPreviousWorkspace => {
let current_output = seat.active_output();
let workspace = self
.common
@ -660,9 +664,10 @@ impl State {
seat,
&current_output,
(&current_output, Some(workspace as usize)),
matches!(x, Action::MoveToPreviousWorkspace),
);
}
Action::MoveToLastWorkspace => {
x @ Action::MoveToLastWorkspace | x @ Action::SendToLastWorkspace => {
let current_output = seat.active_output();
let workspace = self
.common
@ -675,6 +680,7 @@ impl State {
seat,
&current_output,
(&current_output, Some(workspace as usize)),
matches!(x, Action::MoveToLastWorkspace),
);
}
Action::NextOutput => {
@ -753,6 +759,7 @@ impl State {
seat,
&current_output,
(&next_output, None),
true,
) {
if let Some(ptr) = seat.get_pointer() {
ptr.motion(
@ -786,6 +793,7 @@ impl State {
seat,
&current_output,
(&prev_output, None),
true,
) {
if let Some(ptr) = seat.get_pointer() {
ptr.motion(

View file

@ -1120,6 +1120,7 @@ impl Shell {
seat: &Seat<State>,
from_output: &Output,
to: (&Output, Option<usize>),
follow: bool,
) -> Option<Point<i32, Logical>> {
let (to_output, to_idx) = to;
let to_idx = to_idx.unwrap_or(state.common.shell.workspaces.active_num(to_output));
@ -1157,9 +1158,12 @@ impl Shell {
for mapped in elements.into_iter() {
state.common.shell.update_reactive_popups(&mapped);
}
seat.set_active_output(&to_output);
let new_pos = state.common.shell.activate(to_output, to_idx);
let new_pos = if follow {
seat.set_active_output(&to_output);
state.common.shell.activate(to_output, to_idx)
} else {
None
};
let to_workspace = state
.common
@ -1191,7 +1195,9 @@ impl Shell {
state.common.shell.update_reactive_popups(&mapped);
}
Common::set_focus(state, Some(&KeyboardFocusTarget::from(mapped)), &seat, None);
if follow {
Common::set_focus(state, Some(&KeyboardFocusTarget::from(mapped)), &seat, None);
}
new_pos
}