Skip to content

Commit

Permalink
input: Displays take precendence over workspaces
Browse files Browse the repository at this point in the history
  • Loading branch information
Drakulix committed Nov 20, 2023
1 parent 59581f7 commit 18a8692
Showing 1 changed file with 71 additions and 96 deletions.
167 changes: 71 additions & 96 deletions src/input/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1404,6 +1404,29 @@ impl State {
Ok(None) => {
seat.set_active_output(&next_output);
}
_ => {}
}
} else {
match (direction, self.common.config.workspace.workspace_layout) {
(Direction::Left, WorkspaceLayout::Horizontal)
| (Direction::Up, WorkspaceLayout::Vertical) => self.handle_action(
Action::PreviousWorkspace,
seat,
serial,
time,
pattern,
Some(direction),
),
(Direction::Right, WorkspaceLayout::Horizontal)
| (Direction::Down, WorkspaceLayout::Vertical) => self.handle_action(
Action::NextWorkspace,
seat,
serial,
time,
pattern,
Some(direction),
),

_ => {}
}
}
Expand Down Expand Up @@ -1516,6 +1539,29 @@ impl State {
ptr.frame(self);
}
}
} else {
match (direction, self.common.config.workspace.workspace_layout) {
(Direction::Left, WorkspaceLayout::Horizontal)
| (Direction::Up, WorkspaceLayout::Vertical) => self.handle_action(
Action::MoveToPreviousWorkspace,
seat,
serial,
time,
pattern,
Some(direction),
),
(Direction::Right, WorkspaceLayout::Horizontal)
| (Direction::Down, WorkspaceLayout::Vertical) => self.handle_action(
Action::MoveToNextWorkspace,
seat,
serial,
time,
pattern,
Some(direction),
),

_ => {}
}
}
}
x @ Action::MoveToNextOutput | x @ Action::SendToNextOutput => {
Expand Down Expand Up @@ -1602,54 +1648,23 @@ impl State {

match result {
FocusResult::None => {
match (focus, self.common.config.workspace.workspace_layout) {
(FocusDirection::Left, WorkspaceLayout::Horizontal)
| (FocusDirection::Up, WorkspaceLayout::Vertical) => self
.handle_action(
Action::PreviousWorkspace,
seat,
serial,
time,
pattern,
direction,
),
(FocusDirection::Right, WorkspaceLayout::Horizontal)
| (FocusDirection::Down, WorkspaceLayout::Vertical) => self
.handle_action(
Action::NextWorkspace,
seat,
serial,
time,
pattern,
direction,
),
(FocusDirection::Left, WorkspaceLayout::Vertical)
| (FocusDirection::Up, WorkspaceLayout::Horizontal) => {
if let Some(inferred) = pattern.inferred_direction() {
self.handle_action(
Action::SwitchOutput(inferred),
seat,
serial,
time,
pattern,
direction,
)
}
}
(FocusDirection::Right, WorkspaceLayout::Vertical)
| (FocusDirection::Down, WorkspaceLayout::Horizontal) => {
if let Some(inferred) = pattern.inferred_direction() {
self.handle_action(
Action::SwitchOutput(inferred),
seat,
serial,
time,
pattern,
direction,
)
}
}
_ => {}
let dir = match focus {
FocusDirection::Down => Some(Direction::Down),
FocusDirection::Up => Some(Direction::Up),
FocusDirection::Left => Some(Direction::Left),
FocusDirection::Right => Some(Direction::Right),
_ => None,
};

if let Some(direction) = dir {
self.handle_action(
Action::SwitchOutput(direction),
seat,
serial,
time,
pattern,
Some(direction),
)
}
}
FocusResult::Handled => {}
Expand All @@ -1663,54 +1678,14 @@ impl State {
let workspace = self.common.shell.active_space_mut(&current_output);

match workspace.move_current_element(direction, seat) {
MoveResult::MoveFurther(_move_further) => {
match (direction, self.common.config.workspace.workspace_layout) {
(Direction::Left, WorkspaceLayout::Horizontal)
| (Direction::Up, WorkspaceLayout::Vertical) => self.handle_action(
Action::MoveToPreviousWorkspace,
seat,
serial,
time,
pattern,
Some(direction),
),
(Direction::Right, WorkspaceLayout::Horizontal)
| (Direction::Down, WorkspaceLayout::Vertical) => self.handle_action(
Action::MoveToNextWorkspace,
seat,
serial,
time,
pattern,
Some(direction),
),
(Direction::Left, WorkspaceLayout::Vertical)
| (Direction::Up, WorkspaceLayout::Horizontal) => {
if let Some(inferred) = pattern.inferred_direction() {
self.handle_action(
Action::MoveToOutput(inferred),
seat,
serial,
time,
pattern,
Some(direction),
)
}
}
(Direction::Right, WorkspaceLayout::Vertical)
| (Direction::Down, WorkspaceLayout::Horizontal) => {
if let Some(inferred) = pattern.inferred_direction() {
self.handle_action(
Action::MoveToOutput(inferred),
seat,
serial,
time,
pattern,
Some(direction),
)
}
}
}
}
MoveResult::MoveFurther(_move_further) => self.handle_action(
Action::MoveToOutput(direction),
seat,
serial,
time,
pattern,
Some(direction),
),
MoveResult::ShiftFocus(shift) => {
Common::set_focus(self, Some(&shift), seat, None);
}
Expand Down

0 comments on commit 18a8692

Please sign in to comment.