Remove unused KeycodeSource (#34403)

Release Notes:

- N/A
This commit is contained in:
Conrad Irwin 2025-07-14 11:03:16 -06:00 committed by GitHub
parent eca36c502e
commit 45d0686129
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 57 additions and 85 deletions

View file

@ -707,69 +707,57 @@ pub(super) fn log_cursor_icon_warning(message: impl std::fmt::Display) {
}
#[cfg(any(feature = "wayland", feature = "x11"))]
pub(crate) enum KeycodeSource {
X11,
Wayland,
}
fn guess_ascii(keycode: Keycode, shift: bool) -> Option<char> {
let c = match (keycode.raw(), shift) {
(24, _) => 'q',
(25, _) => 'w',
(26, _) => 'e',
(27, _) => 'r',
(28, _) => 't',
(29, _) => 'y',
(30, _) => 'u',
(31, _) => 'i',
(32, _) => 'o',
(33, _) => 'p',
(34, false) => '[',
(34, true) => '{',
(35, false) => ']',
(35, true) => '}',
(38, _) => 'a',
(39, _) => 's',
(40, _) => 'd',
(41, _) => 'f',
(42, _) => 'g',
(43, _) => 'h',
(44, _) => 'j',
(45, _) => 'k',
(46, _) => 'l',
(47, false) => ';',
(47, true) => ':',
(48, false) => '\'',
(48, true) => '"',
(49, false) => '`',
(49, true) => '~',
(51, false) => '\\',
(51, true) => '|',
(52, _) => 'z',
(53, _) => 'x',
(54, _) => 'c',
(55, _) => 'v',
(56, _) => 'b',
(57, _) => 'n',
(58, _) => 'm',
(59, false) => ',',
(59, true) => '>',
(60, false) => '.',
(60, true) => '<',
(61, false) => '/',
(61, true) => '?',
#[cfg(any(feature = "wayland", feature = "x11"))]
impl KeycodeSource {
fn guess_ascii(&self, keycode: Keycode, shift: bool) -> Option<char> {
// For historical reasons, X11 adds 8 to keycodes.
// Wayland doesn't, but by this point, our own Wayland client
// has added 8 for X11 compatibility.
let raw = keycode.raw() - 8;
let c = match (raw, shift) {
(16, _) => 'q',
(17, _) => 'w',
(18, _) => 'e',
(19, _) => 'r',
(20, _) => 't',
(21, _) => 'y',
(22, _) => 'u',
(23, _) => 'i',
(24, _) => 'o',
(25, _) => 'p',
(26, false) => '[',
(26, true) => '{',
(27, false) => ']',
(27, true) => '}',
(30, _) => 'a',
(31, _) => 's',
(32, _) => 'd',
(33, _) => 'f',
(34, _) => 'g',
(35, _) => 'h',
(36, _) => 'j',
(37, _) => 'k',
(38, _) => 'l',
(39, false) => ';',
(39, true) => ':',
(40, false) => '\'',
(40, true) => '"',
(41, false) => '`',
(41, true) => '~',
(43, false) => '\\',
(43, true) => '|',
(44, _) => 'z',
(45, _) => 'x',
(46, _) => 'c',
(47, _) => 'v',
(48, _) => 'b',
(49, _) => 'n',
(50, _) => 'm',
(51, false) => ',',
(51, true) => '>',
(52, false) => '.',
(52, true) => '<',
(53, false) => '/',
(53, true) => '?',
_ => return None,
};
_ => return None,
};
Some(c)
}
Some(c)
}
#[cfg(any(feature = "wayland", feature = "x11"))]
@ -778,7 +766,6 @@ impl crate::Keystroke {
state: &State,
mut modifiers: crate::Modifiers,
keycode: Keycode,
source: KeycodeSource,
) -> Self {
let key_utf32 = state.key_get_utf32(keycode);
let key_utf8 = state.key_get_utf8(keycode);
@ -840,7 +827,7 @@ impl crate::Keystroke {
let name = xkb::keysym_get_name(key_sym).to_lowercase();
if key_sym.is_keypad_key() {
name.replace("kp_", "")
} else if let Some(key_en) = source.guess_ascii(keycode, modifiers.shift) {
} else if let Some(key_en) = guess_ascii(keycode, modifiers.shift) {
String::from(key_en)
} else {
name