Skip to content

Commit

Permalink
Add 'borderless' option
Browse files Browse the repository at this point in the history
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
  • Loading branch information
robertgzr committed Dec 17, 2017
1 parent 6a1bed0 commit 46a1ee7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
10 changes: 10 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
Expand Down Expand Up @@ -337,6 +341,7 @@ impl Default for Config {
cursor_style: Default::default(),
live_config_reload: true,
padding: default_padding(),
borderless: false,
}
}
}
Expand Down Expand Up @@ -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[..]
}
Expand Down
2 changes: 1 addition & 1 deletion src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 4 additions & 2 deletions src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand Down

0 comments on commit 46a1ee7

Please sign in to comment.