diff options
Diffstat (limited to 'alacritty/src/config')
-rw-r--r-- | alacritty/src/config/bindings.rs | 31 | ||||
-rw-r--r-- | alacritty/src/config/window.rs | 3 |
2 files changed, 19 insertions, 15 deletions
diff --git a/alacritty/src/config/bindings.rs b/alacritty/src/config/bindings.rs index 71278fd7..914d25ff 100644 --- a/alacritty/src/config/bindings.rs +++ b/alacritty/src/config/bindings.rs @@ -8,8 +8,9 @@ use serde::{Deserialize, Deserializer}; use toml::Value as SerdeValue; use winit::event::MouseButton; use winit::keyboard::Key::*; -use winit::keyboard::{Key, KeyCode, KeyLocation, ModifiersState}; -use winit::platform::scancode::KeyCodeExtScancode; +use winit::keyboard::NamedKey::*; +use winit::keyboard::{Key, KeyCode, KeyLocation, ModifiersState, NamedKey, PhysicalKey}; +use winit::platform::scancode::PhysicalKeyExtScancode; use alacritty_config_derive::{ConfigDeserialize, SerdeReplace}; @@ -418,7 +419,7 @@ macro_rules! trigger { BindingKey::Keycode { key: Character($key.into()), location: KeyLocation::Standard } }}; (KeyBinding, $key:expr,) => {{ - BindingKey::Keycode { key: $key, location: KeyLocation::Standard } + BindingKey::Keycode { key: Named($key), location: KeyLocation::Standard } }}; ($ty:ident, $key:expr,) => {{ $key @@ -716,7 +717,7 @@ pub fn platform_key_bindings() -> Vec<KeyBinding> { #[derive(Clone, Debug, Eq, PartialEq, Hash)] pub enum BindingKey { - Scancode(KeyCode), + Scancode(PhysicalKey), Keycode { key: Key, location: KeyLocation }, } @@ -727,7 +728,7 @@ impl<'a> Deserialize<'a> for BindingKey { { let value = SerdeValue::deserialize(deserializer)?; match u32::deserialize(value.clone()) { - Ok(scancode) => Ok(BindingKey::Scancode(KeyCode::from_scancode(scancode))), + Ok(scancode) => Ok(BindingKey::Scancode(PhysicalKey::from_scancode(scancode))), Err(_) => { let keycode = String::deserialize(value.clone()).map_err(D::Error::custom)?; let (key, location) = if keycode.chars().count() == 1 { @@ -735,15 +736,15 @@ impl<'a> Deserialize<'a> for BindingKey { } else { // Translate legacy winit codes into their modern counterparts. match keycode.as_str() { - "Up" => (Key::ArrowUp, KeyLocation::Standard), - "Back" => (Key::Backspace, KeyLocation::Standard), - "Down" => (Key::ArrowDown, KeyLocation::Standard), - "Left" => (Key::ArrowLeft, KeyLocation::Standard), - "Right" => (Key::ArrowRight, KeyLocation::Standard), + "Up" => (Key::Named(ArrowUp), KeyLocation::Standard), + "Back" => (Key::Named(Backspace), KeyLocation::Standard), + "Down" => (Key::Named(ArrowDown), KeyLocation::Standard), + "Left" => (Key::Named(ArrowLeft), KeyLocation::Standard), + "Right" => (Key::Named(ArrowRight), KeyLocation::Standard), "At" => (Key::Character("@".into()), KeyLocation::Standard), "Colon" => (Key::Character(":".into()), KeyLocation::Standard), "Period" => (Key::Character(".".into()), KeyLocation::Standard), - "Return" => (Key::Enter, KeyLocation::Standard), + "Return" => (Key::Named(Enter), KeyLocation::Standard), "LBracket" => (Key::Character("[".into()), KeyLocation::Standard), "RBracket" => (Key::Character("]".into()), KeyLocation::Standard), "Semicolon" => (Key::Character(";".into()), KeyLocation::Standard), @@ -766,7 +767,7 @@ impl<'a> Deserialize<'a> for BindingKey { "Key0" => (Key::Character("0".into()), KeyLocation::Standard), // Special case numpad. - "NumpadEnter" => (Key::Enter, KeyLocation::Numpad), + "NumpadEnter" => (Key::Named(Enter), KeyLocation::Numpad), "NumpadAdd" => (Key::Character("+".into()), KeyLocation::Numpad), "NumpadComma" => (Key::Character(",".into()), KeyLocation::Numpad), "NumpadDivide" => (Key::Character("/".into()), KeyLocation::Numpad), @@ -783,10 +784,14 @@ impl<'a> Deserialize<'a> for BindingKey { "Numpad8" => (Key::Character("8".into()), KeyLocation::Numpad), "Numpad9" => (Key::Character("9".into()), KeyLocation::Numpad), "Numpad0" => (Key::Character("0".into()), KeyLocation::Numpad), - _ => ( + _ if keycode.starts_with("Dead") => ( Key::deserialize(value).map_err(D::Error::custom)?, KeyLocation::Standard, ), + _ => ( + Key::Named(NamedKey::deserialize(value).map_err(D::Error::custom)?), + KeyLocation::Standard, + ), } }; diff --git a/alacritty/src/config/window.rs b/alacritty/src/config/window.rs index 4b63c3e9..9d40b5ad 100644 --- a/alacritty/src/config/window.rs +++ b/alacritty/src/config/window.rs @@ -1,5 +1,4 @@ use std::fmt::{self, Formatter}; -use std::os::raw::c_ulong; use log::{error, warn}; use serde::de::{self, MapAccess, Visitor}; @@ -31,7 +30,7 @@ pub struct WindowConfig { /// XEmbed parent. #[config(skip)] - pub embed: Option<c_ulong>, + pub embed: Option<u32>, /// System decorations theme variant. pub decorations_theme_variant: Option<Theme>, |