Skip to content

Commit

Permalink
input: Only capture Escape, if a grab is active
Browse files Browse the repository at this point in the history
  • Loading branch information
Drakulix committed Dec 13, 2023
1 parent 53de98a commit a8b401b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
7 changes: 0 additions & 7 deletions src/config/key_bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,11 +319,4 @@ pub fn add_default_bindings(
output_next.iter().copied(),
Action::MoveToOutput(output_next_dir),
);

insert_binding(
key_bindings,
KeyModifiers::default(),
std::iter::once(Keysym::Escape),
Action::Escape,
);
}
26 changes: 25 additions & 1 deletion src/input/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use crate::{
backend::render::cursor::CursorState,
config::{xkb_config_to_wl, Action, Config, KeyPattern},
config::{xkb_config_to_wl, Action, Config, KeyPattern, KeyModifiers},
shell::{
focus::{target::PointerFocusTarget, FocusDirection},
grabs::{ResizeEdge, SeatMenuGrabState, SeatMoveGrabState},
Expand Down Expand Up @@ -282,6 +282,8 @@ impl State {
let serial = SERIAL_COUNTER.next_serial();
let time = Event::time_msec(&event);
let keyboard = seat.get_keyboard().unwrap();
let pointer = seat.get_pointer().unwrap();
let is_grabbed = keyboard.is_grabbed() || pointer.is_grabbed();
let current_focus = keyboard.current_focus();
if let Some((action, pattern)) = keyboard
.input(
Expand Down Expand Up @@ -452,6 +454,28 @@ impl State {
}
}

// cancel grabs
if is_grabbed
&& handle.modified_sym() == Keysym::Escape
&& state == KeyState::Pressed
&& !modifiers.alt
&& !modifiers.ctrl
&& !modifiers.logo
&& !modifiers.shift
{
userdata
.get::<SupressedKeys>()
.unwrap()
.add(&handle, None);
return FilterResult::Intercept(Some((
Action::Escape,
KeyPattern {
modifiers: KeyModifiers::default(),
key: Some(Keysym::Escape),
}
)));
}

// Skip released events for initially surpressed keys
if state == KeyState::Released {
if let Some(tokens) = userdata.get::<SupressedKeys>().unwrap().filter(&handle) {
Expand Down

0 comments on commit a8b401b

Please sign in to comment.