From a35f4590d560bb18e13df6da0b3be2fdeb50d1ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20G=C3=BCnzler?= Date: Wed, 20 Dec 2017 20:12:32 +0100 Subject: [PATCH] Add new window section to config Move/rename borderless into window_config as decorations --- src/config.rs | 36 ++++++++++++++++++++++++++++-------- src/display.rs | 2 +- src/window.rs | 6 ++++-- 3 files changed, 33 insertions(+), 11 deletions(-) diff --git a/src/config.rs b/src/config.rs index a22c1653..69f32179 100644 --- a/src/config.rs +++ b/src/config.rs @@ -209,6 +209,25 @@ impl Default for Alpha { } } +#[derive(Debug, Deserialize)] +pub struct WindowConfig { + decorations: bool, +} + +impl WindowConfig { + pub fn decorations(&self) -> bool { + self.decorations + } +} + +impl Default for WindowConfig { + fn default() -> Self { + WindowConfig{ + decorations: true, + } + } +} + /// Top-level config type #[derive(Debug, Deserialize)] pub struct Config { @@ -247,9 +266,9 @@ pub struct Config { #[serde(default)] background_opacity: Alpha, - /// Should draw window without borders + /// Window configuration #[serde(default)] - borderless: bool, + window: WindowConfig, /// Keybindings #[serde(default="default_key_bindings")] @@ -341,7 +360,7 @@ impl Default for Config { cursor_style: Default::default(), live_config_reload: true, padding: default_padding(), - borderless: false, + window: Default::default(), } } } @@ -1110,11 +1129,6 @@ impl Config { self.background_opacity } - #[inline] - pub fn borderless(&self) -> bool { - self.borderless - } - pub fn key_bindings(&self) -> &[KeyBinding] { &self.key_bindings[..] } @@ -1152,6 +1166,12 @@ impl Config { self.dimensions } + /// Get window config + #[inline] + pub fn window(&self) -> &WindowConfig { + &self.window + } + /// Get visual bell config #[inline] pub fn visual_bell(&self) -> &VisualBellConfig { diff --git a/src/display.rs b/src/display.rs index f0d2a3d0..bfd62c32 100644 --- a/src/display.rs +++ b/src/display.rs @@ -137,7 +137,7 @@ impl Display { let render_timer = config.render_timer(); // Create the window where Alacritty will be displayed - let mut window = Window::new(&options.title, config.borderless())?; + let mut window = Window::new(&options.title, config.window())?; // get window properties for initializing the other subsystems let mut viewport_size = window.inner_size_pixels() diff --git a/src/window.rs b/src/window.rs index 5dfcdcd6..60048774 100644 --- a/src/window.rs +++ b/src/window.rs @@ -19,6 +19,8 @@ use gl; use glutin::{self, EventsLoop, WindowBuilder, Event, MouseCursor, CursorState, ControlFlow, ContextBuilder}; use glutin::GlContext; +use config::WindowConfig; + /// Window errors #[derive(Debug)] pub enum Error { @@ -184,7 +186,7 @@ impl Window { /// This creates a window and fully initializes a window. pub fn new( title: &str, - borderless: bool + window_config: &WindowConfig, ) -> Result { let event_loop = EventsLoop::new(); @@ -192,7 +194,7 @@ impl Window { let window = WindowBuilder::new() .with_title(title) .with_transparency(true) - .with_decorations(!borderless); + .with_decorations(window_config.decorations()); let context = ContextBuilder::new() .with_vsync(true); let window = ::glutin::GlWindow::new(window, context, &event_loop)?;