Add hack to make Orca + Shift + A work better
Browse files at this commitcfc01b895c0c7cbb9692852488675cc46693bd2aParent: 4e609f91 changed file +37 -6
- src/input/mod.rs +37 -6
src/input/mod.rsmodified+37 -6
| @@ -420,18 +420,49 @@ impl State { | |||
| 420 | serial, | 420 | serial, |
| 421 | time, | 421 | time, |
| 422 | |this, mods, keysym| { | 422 | |this, mods, keysym| { |
| 423 | + let key_code = event.key_code(); | ||
| 424 | + let modified = keysym.modified_sym(); | ||
| 425 | + let raw = keysym.raw_latin_sym_or_raw_current_sym(); | ||
| 426 | + let modifiers = modifiers_from_state(*mods); | ||
| 427 | + | ||
| 423 | // After updating XKB state from accessibility-grabbed keys, return right away and | 428 | // After updating XKB state from accessibility-grabbed keys, return right away and |
| 424 | // don't handle them. | 429 | // don't handle them. |
| 425 | #[cfg(feature = "dbus")] | 430 | #[cfg(feature = "dbus")] |
| 426 | if block != KbMonBlock::Pass { | 431 | if block != KbMonBlock::Pass { |
| 427 | - return FilterResult::Intercept(None); | 432 | + // HACK: there's a slight problem with this code. Here we filter out keys |
| 433 | + // consumed by accessibility from getting sent to the Wayland client. However, | ||
| 434 | + // the Wayland client can still receive these keys from the wl_keyboard | ||
| 435 | + // enter/modifiers events. In particular, this can easily happen when opening | ||
| 436 | + // the Orca actions menu with Orca + Shift + A: in most cases, when this menu | ||
| 437 | + // opens, Shift is still held down, so the menu receives it in | ||
| 438 | + // wl_keyboard.enter/modifiers. Then the menu won't react to Enter presses | ||
| 439 | + // until the user taps Shift again to "release" it (since the initial Shift | ||
| 440 | + // release will be intercepted here). | ||
| 441 | + // | ||
| 442 | + // I don't think there's any good way of dealing with this apart from keeping a | ||
| 443 | + // separate xkb state for accessibility, so that we can track the pressed | ||
| 444 | + // modifiers without accidentally leaking them to wl_keyboard.enter. So for now | ||
| 445 | + // let's forward modifier releases to the clients here to deal with the most | ||
| 446 | + // common case. | ||
| 447 | + if !pressed | ||
| 448 | + && matches!( | ||
| 449 | + modified, | ||
| 450 | + Keysym::Shift_L | ||
| 451 | + | Keysym::Shift_R | ||
| 452 | + | Keysym::Control_L | ||
| 453 | + | Keysym::Control_R | ||
| 454 | + | Keysym::Super_L | ||
| 455 | + | Keysym::Super_R | ||
| 456 | + | Keysym::Alt_L | ||
| 457 | + | Keysym::Alt_R | ||
| 458 | + ) | ||
| 459 | + { | ||
| 460 | + return FilterResult::Forward; | ||
| 461 | + } else { | ||
| 462 | + return FilterResult::Intercept(None); | ||
| 463 | + } | ||
| 428 | } | 464 | } |
| 429 | 465 | ||
| 430 | - let key_code = event.key_code(); | ||
| 431 | - let modified = keysym.modified_sym(); | ||
| 432 | - let raw = keysym.raw_latin_sym_or_raw_current_sym(); | ||
| 433 | - let modifiers = modifiers_from_state(*mods); | ||
| 434 | - | ||
| 435 | if this.niri.exit_confirm_dialog.is_open() && pressed { | 466 | if this.niri.exit_confirm_dialog.is_open() && pressed { |
| 436 | if raw == Some(Keysym::Return) { | 467 | if raw == Some(Keysym::Return) { |
| 437 | info!("quitting after confirming exit dialog"); | 468 | info!("quitting after confirming exit dialog"); |