Add new window section to config

Move/rename borderless into window_config as decorations
This commit is contained in:
Robert Günzler 2017-12-20 20:12:32 +01:00 committed by Joe Wilm
parent f6e5cae0ba
commit a35f4590d5
3 changed files with 33 additions and 11 deletions

View File

@ -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 {

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

View File

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