From 46a1ee72267c0979e980607098ce4ef00a3db1ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20G=C3=BCnzler?= Date: Sun, 17 Dec 2017 08:23:49 +0100 Subject: [PATCH] Add 'borderless' option Until winit gives us more capabilities in regard to window decorations this implements a simple switch that renders the window without any title bar or border --- src/config.rs | 10 ++++++++++ src/display.rs | 2 +- src/window.rs | 6 ++++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/config.rs b/src/config.rs index 48fcda7a..a22c1653 100644 --- a/src/config.rs +++ b/src/config.rs @@ -247,6 +247,10 @@ pub struct Config { #[serde(default)] background_opacity: Alpha, + /// Should draw window without borders + #[serde(default)] + borderless: bool, + /// Keybindings #[serde(default="default_key_bindings")] key_bindings: Vec, @@ -337,6 +341,7 @@ impl Default for Config { cursor_style: Default::default(), live_config_reload: true, padding: default_padding(), + borderless: false, } } } @@ -1105,6 +1110,11 @@ impl Config { self.background_opacity } + #[inline] + pub fn borderless(&self) -> bool { + self.borderless + } + pub fn key_bindings(&self) -> &[KeyBinding] { &self.key_bindings[..] } diff --git a/src/display.rs b/src/display.rs index 14c5a66d..f0d2a3d0 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)?; + let mut window = Window::new(&options.title, config.borderless())?; // 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 486bd590..5dfcdcd6 100644 --- a/src/window.rs +++ b/src/window.rs @@ -183,14 +183,16 @@ impl Window { /// /// This creates a window and fully initializes a window. pub fn new( - title: &str + title: &str, + borderless: bool ) -> Result { let event_loop = EventsLoop::new(); Window::platform_window_init(); let window = WindowBuilder::new() .with_title(title) - .with_transparency(true); + .with_transparency(true) + .with_decorations(!borderless); let context = ContextBuilder::new() .with_vsync(true); let window = ::glutin::GlWindow::new(window, context, &event_loop)?;