1
0
Fork 0
mirror of https://github.com/alacritty/alacritty.git synced 2024-11-25 14:05:41 -05:00

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 /// Top-level config type
#[derive(Debug, Deserialize)] #[derive(Debug, Deserialize)]
pub struct Config { pub struct Config {
@ -247,9 +266,9 @@ pub struct Config {
#[serde(default)] #[serde(default)]
background_opacity: Alpha, background_opacity: Alpha,
/// Should draw window without borders /// Window configuration
#[serde(default)] #[serde(default)]
borderless: bool, window: WindowConfig,
/// Keybindings /// Keybindings
#[serde(default="default_key_bindings")] #[serde(default="default_key_bindings")]
@ -341,7 +360,7 @@ impl Default for Config {
cursor_style: Default::default(), cursor_style: Default::default(),
live_config_reload: true, live_config_reload: true,
padding: default_padding(), padding: default_padding(),
borderless: false, window: Default::default(),
} }
} }
} }
@ -1110,11 +1129,6 @@ impl Config {
self.background_opacity self.background_opacity
} }
#[inline]
pub fn borderless(&self) -> bool {
self.borderless
}
pub fn key_bindings(&self) -> &[KeyBinding] { pub fn key_bindings(&self) -> &[KeyBinding] {
&self.key_bindings[..] &self.key_bindings[..]
} }
@ -1152,6 +1166,12 @@ impl Config {
self.dimensions self.dimensions
} }
/// Get window config
#[inline]
pub fn window(&self) -> &WindowConfig {
&self.window
}
/// Get visual bell config /// Get visual bell config
#[inline] #[inline]
pub fn visual_bell(&self) -> &VisualBellConfig { pub fn visual_bell(&self) -> &VisualBellConfig {

View file

@ -137,7 +137,7 @@ impl Display {
let render_timer = config.render_timer(); let render_timer = config.render_timer();
// Create the window where Alacritty will be displayed // 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 // get window properties for initializing the other subsystems
let mut viewport_size = window.inner_size_pixels() 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::{self, EventsLoop, WindowBuilder, Event, MouseCursor, CursorState, ControlFlow, ContextBuilder};
use glutin::GlContext; use glutin::GlContext;
use config::WindowConfig;
/// Window errors /// Window errors
#[derive(Debug)] #[derive(Debug)]
pub enum Error { pub enum Error {
@ -184,7 +186,7 @@ impl Window {
/// This creates a window and fully initializes a window. /// This creates a window and fully initializes a window.
pub fn new( pub fn new(
title: &str, title: &str,
borderless: bool window_config: &WindowConfig,
) -> Result<Window> { ) -> Result<Window> {
let event_loop = EventsLoop::new(); let event_loop = EventsLoop::new();
@ -192,7 +194,7 @@ impl Window {
let window = WindowBuilder::new() let window = WindowBuilder::new()
.with_title(title) .with_title(title)
.with_transparency(true) .with_transparency(true)
.with_decorations(!borderless); .with_decorations(window_config.decorations());
let context = ContextBuilder::new() let context = ContextBuilder::new()
.with_vsync(true); .with_vsync(true);
let window = ::glutin::GlWindow::new(window, context, &event_loop)?; let window = ::glutin::GlWindow::new(window, context, &event_loop)?;