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
This commit is contained in:
Robert Günzler 2017-12-17 08:23:49 +01:00 committed by Joe Wilm
parent 6a1bed0a71
commit 16c0e24d8e
3 changed files with 15 additions and 3 deletions

View File

@ -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<KeyBinding>,
@ -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[..]
}

View File

@ -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()

View File

@ -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<Window> {
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)?;