From 729eef0c933831bccfeac6a355bdb410787fbe5f Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Sat, 5 Oct 2019 02:29:26 +0200 Subject: Update to winit/glutin EventLoop 2.0 This takes the latest glutin master to port Alacritty to the EventLoop 2.0 rework. This changes a big part of the event loop handling by pushing the event loop in a separate thread from the renderer and running both in parallel. Fixes #2796. Fixes #2694. Fixes #2643. Fixes #2625. Fixes #2618. Fixes #2601. Fixes #2564. Fixes #2456. Fixes #2438. Fixes #2334. Fixes #2254. Fixes #2217. Fixes #1789. Fixes #1750. Fixes #1125. --- alacritty/src/config/ui_config.rs | 63 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 alacritty/src/config/ui_config.rs (limited to 'alacritty/src/config/ui_config.rs') diff --git a/alacritty/src/config/ui_config.rs b/alacritty/src/config/ui_config.rs new file mode 100644 index 00000000..6230c5bb --- /dev/null +++ b/alacritty/src/config/ui_config.rs @@ -0,0 +1,63 @@ +use serde::{Deserialize, Deserializer}; + +use alacritty_terminal::config::failure_default; + +use crate::config::bindings::{self, Binding, KeyBinding, MouseBinding}; +use crate::config::mouse::Mouse; + +#[derive(Debug, PartialEq, Deserialize)] +pub struct UIConfig { + #[serde(default, deserialize_with = "failure_default")] + pub mouse: Mouse, + + /// Keybindings + #[serde(default = "default_key_bindings", deserialize_with = "deserialize_key_bindings")] + pub key_bindings: Vec, + + /// Bindings for the mouse + #[serde(default = "default_mouse_bindings", deserialize_with = "deserialize_mouse_bindings")] + pub mouse_bindings: Vec, +} + +fn default_key_bindings() -> Vec { + bindings::default_key_bindings() +} + +fn default_mouse_bindings() -> Vec { + bindings::default_mouse_bindings() +} + +fn deserialize_key_bindings<'a, D>(deserializer: D) -> Result, D::Error> +where + D: Deserializer<'a>, +{ + deserialize_bindings(deserializer, bindings::default_key_bindings()) +} + +fn deserialize_mouse_bindings<'a, D>(deserializer: D) -> Result, D::Error> +where + D: Deserializer<'a>, +{ + deserialize_bindings(deserializer, bindings::default_mouse_bindings()) +} + +fn deserialize_bindings<'a, D, T>( + deserializer: D, + mut default: Vec>, +) -> Result>, D::Error> +where + D: Deserializer<'a>, + T: Copy + Eq, + Binding: Deserialize<'a>, +{ + let mut bindings: Vec> = failure_default(deserializer)?; + + // Remove matching default bindings + for binding in bindings.iter() { + default.retain(|b| !b.triggers_match(binding)); + } + + bindings.extend(default); + + Ok(bindings) +} -- cgit