From ea14033d0641c549e28ca86cb69f65690999036e Mon Sep 17 00:00:00 2001 From: Victoria Brekenfeld Date: Wed, 22 Nov 2023 17:42:11 +0100 Subject: [PATCH] input: Fix stack overflow due to shortcut priorities --- src/input/mod.rs | 77 ++++++++++++++++----------- src/shell/layout/tiling/grabs/swap.rs | 1 + 2 files changed, 47 insertions(+), 31 deletions(-) diff --git a/src/input/mod.rs b/src/input/mod.rs index 0d86e6d0..c71f9d1e 100644 --- a/src/input/mod.rs +++ b/src/input/mod.rs @@ -438,7 +438,7 @@ impl State { let start = Instant::now(); loop_handle.insert_source(Timer::from_duration(Duration::from_millis(200)), move |current, _, state| { let duration = current.duration_since(start).as_millis(); - state.handle_action(action_clone.clone(), &seat_clone, serial, time.overflowing_add(duration as u32).0, key_pattern_clone.clone(), None); + state.handle_action(action_clone.clone(), &seat_clone, serial, time.overflowing_add(duration as u32).0, key_pattern_clone.clone(), None, true); calloop::timer::TimeoutAction::ToDuration(Duration::from_millis(25)) }).ok() } else { None }; @@ -549,7 +549,7 @@ impl State { ) .flatten() { - self.handle_action(action, &seat, serial, time, pattern, None) + self.handle_action(action, &seat, serial, time, pattern, None, true) } } } @@ -1157,6 +1157,7 @@ impl State { time: u32, pattern: KeyPattern, direction: Option, + propagate: bool, ) { // TODO: Detect if started from login manager or tty, and only allow // `Terminate` if it will return to login manager. @@ -1206,6 +1207,16 @@ impl State { .shell .activate(¤t_output, workspace as usize); } + Action::LastWorkspace => { + let current_output = seat.active_output(); + let workspace = self + .common + .shell + .workspaces + .len(¤t_output) + .saturating_sub(1); + let _ = self.common.shell.activate(¤t_output, workspace); + } Action::NextWorkspace => { let current_output = seat.active_output(); let workspace = self @@ -1220,6 +1231,7 @@ impl State { .shell .activate(¤t_output, workspace) .is_err() + && propagate { if let Some(inferred) = pattern.inferred_direction() { self.handle_action( @@ -1229,6 +1241,7 @@ impl State { time, pattern, direction, + false, ) }; } @@ -1247,6 +1260,7 @@ impl State { .shell .activate(¤t_output, workspace) .is_err() + && propagate { if let Some(inferred) = pattern.inferred_direction() { self.handle_action( @@ -1256,20 +1270,11 @@ impl State { time, pattern, direction, + false, ) }; } } - Action::LastWorkspace => { - let current_output = seat.active_output(); - let workspace = self - .common - .shell - .workspaces - .len(¤t_output) - .saturating_sub(1); - let _ = self.common.shell.activate(¤t_output, workspace); - } x @ Action::MoveToWorkspace(_) | x @ Action::SendToWorkspace(_) => { let current_output = seat.active_output(); let follow = matches!(x, Action::MoveToWorkspace(_)); @@ -1287,6 +1292,23 @@ impl State { None, ); } + x @ Action::MoveToLastWorkspace | x @ Action::SendToLastWorkspace => { + let current_output = seat.active_output(); + let workspace = self + .common + .shell + .workspaces + .len(¤t_output) + .saturating_sub(1); + let _ = Shell::move_current_window( + self, + seat, + ¤t_output, + (¤t_output, Some(workspace as usize)), + matches!(x, Action::MoveToLastWorkspace), + None, + ); + } x @ Action::MoveToNextWorkspace | x @ Action::SendToNextWorkspace => { let current_output = seat.active_output(); let workspace = self @@ -1305,6 +1327,7 @@ impl State { direction, ) .is_err() + && propagate { if let Some(inferred) = pattern.inferred_direction() { self.handle_action( @@ -1318,6 +1341,7 @@ impl State { time, pattern, direction, + false, ) } } @@ -1341,6 +1365,7 @@ impl State { direction, ) .is_err() + && propagate { if let Some(inferred) = pattern.inferred_direction() { self.handle_action( @@ -1354,27 +1379,11 @@ impl State { time, pattern, direction, + false, ) } } } - x @ Action::MoveToLastWorkspace | x @ Action::SendToLastWorkspace => { - let current_output = seat.active_output(); - let workspace = self - .common - .shell - .workspaces - .len(¤t_output) - .saturating_sub(1); - let _ = Shell::move_current_window( - self, - seat, - ¤t_output, - (¤t_output, Some(workspace as usize)), - matches!(x, Action::MoveToLastWorkspace), - None, - ); - } Action::SwitchOutput(direction) => { let current_output = seat.active_output(); let next_output = self @@ -1406,7 +1415,7 @@ impl State { } _ => {} } - } else { + } else if propagate { match (direction, self.common.config.workspace.workspace_layout) { (Direction::Left, WorkspaceLayout::Horizontal) | (Direction::Up, WorkspaceLayout::Vertical) => self.handle_action( @@ -1416,6 +1425,7 @@ impl State { time, pattern, Some(direction), + false, ), (Direction::Right, WorkspaceLayout::Horizontal) | (Direction::Down, WorkspaceLayout::Vertical) => self.handle_action( @@ -1425,6 +1435,7 @@ impl State { time, pattern, Some(direction), + false, ), _ => {} @@ -1539,7 +1550,7 @@ impl State { ptr.frame(self); } } - } else { + } else if propagate { match (direction, self.common.config.workspace.workspace_layout) { (Direction::Left, WorkspaceLayout::Horizontal) | (Direction::Up, WorkspaceLayout::Vertical) => self.handle_action( @@ -1549,6 +1560,7 @@ impl State { time, pattern, Some(direction), + false, ), (Direction::Right, WorkspaceLayout::Horizontal) | (Direction::Down, WorkspaceLayout::Vertical) => self.handle_action( @@ -1558,6 +1570,7 @@ impl State { time, pattern, Some(direction), + false, ), _ => {} @@ -1714,6 +1727,7 @@ impl State { time, pattern, Some(direction), + true, ) } } @@ -1735,6 +1749,7 @@ impl State { time, pattern, Some(direction), + true, ), MoveResult::ShiftFocus(shift) => { Common::set_focus(self, Some(&shift), seat, None); diff --git a/src/shell/layout/tiling/grabs/swap.rs b/src/shell/layout/tiling/grabs/swap.rs index 25a4748a..9a84fca0 100644 --- a/src/shell/layout/tiling/grabs/swap.rs +++ b/src/shell/layout/tiling/grabs/swap.rs @@ -74,6 +74,7 @@ impl KeyboardGrab for SwapWindowGrab { key: Some(Keysym::new(keycode)), }, None, + true, ); }