diff options
author | acheronfail <acheronfail@gmail.com> | 2019-04-24 05:05:47 +1000 |
---|---|---|
committer | Christian Duerr <chrisduerr@users.noreply.github.com> | 2019-04-23 19:05:47 +0000 |
commit | e9813031f6e308984cb5547aa1049839cb75745f (patch) | |
tree | c8e6286c98f4f42b6e170e477baa6b1f949b83ef /src/config/mod.rs | |
parent | b0efa9d105b53211d8df094238c7eb8324e93566 (diff) | |
download | alacritty-e9813031f6e308984cb5547aa1049839cb75745f.tar.gz alacritty-e9813031f6e308984cb5547aa1049839cb75745f.zip |
Add fullscreen support
Fixes #34.
Fixes #2012.
Diffstat (limited to 'src/config/mod.rs')
-rw-r--r-- | src/config/mod.rs | 45 |
1 files changed, 40 insertions, 5 deletions
diff --git a/src/config/mod.rs b/src/config/mod.rs index 67431e68..4d6026ca 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -318,6 +318,21 @@ impl Default for Alpha { } } +#[derive(Debug, Deserialize, Copy, Clone, PartialEq, Eq)] +pub enum StartupMode { + Windowed, + Maximized, + Fullscreen, + #[cfg(target_os = "macos")] + SimpleFullscreen, +} + +impl Default for StartupMode { + fn default() -> StartupMode { + StartupMode::Windowed + } +} + #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub enum Decorations { Full, @@ -438,9 +453,13 @@ pub struct WindowConfig { #[serde(deserialize_with = "failure_default")] dynamic_padding: bool, - /// Start maximized + /// Startup mode + #[serde(deserialize_with = "failure_default")] + startup_mode: StartupMode, + + /// TODO: DEPRECATED #[serde(deserialize_with = "failure_default")] - start_maximized: bool, + start_maximized: Option<bool>, } impl Default for WindowConfig { @@ -452,6 +471,7 @@ impl Default for WindowConfig { decorations: Default::default(), dynamic_padding: Default::default(), start_maximized: Default::default(), + startup_mode: Default::default(), } } } @@ -482,8 +502,8 @@ impl WindowConfig { self.dynamic_padding } - pub fn start_maximized(&self) -> bool { - self.start_maximized + pub fn startup_mode(&self) -> StartupMode { + self.startup_mode } pub fn position(&self) -> Option<Delta<i32>> { @@ -874,7 +894,7 @@ impl<'a> de::Deserialize<'a> for ActionWrapper { "Paste, Copy, PasteSelection, IncreaseFontSize, DecreaseFontSize, \ ResetFontSize, ScrollPageUp, ScrollPageDown, ScrollLineUp, ScrollLineDown, \ ScrollToTop, ScrollToBottom, ClearHistory, Hide, ClearLogNotice, \ - SpawnNewInstance, None or Quit", + SpawnNewInstance, ToggleFullscreen, ToggleSimpleFullscreen, None or Quit", ) } @@ -900,6 +920,9 @@ impl<'a> de::Deserialize<'a> for ActionWrapper { "Quit" => Action::Quit, "ClearLogNotice" => Action::ClearLogNotice, "SpawnNewInstance" => Action::SpawnNewInstance, + "ToggleFullscreen" => Action::ToggleFullscreen, + #[cfg(target_os = "macos")] + "ToggleSimpleFullscreen" => Action::ToggleSimpleFullscreen, "None" => Action::None, _ => return Err(E::invalid_value(Unexpected::Str(value), &self)), })) @@ -1992,6 +2015,18 @@ impl Config { instead" ); } + + if let Some(start_maximized) = self.window.start_maximized { + warn!( + "Config window.start_maximized is deprecated; please use window.startup_mode \ + instead" + ); + + // While `start_maximized` is deprecated its setting takes precedence. + if start_maximized { + self.window.startup_mode = StartupMode::Maximized; + } + } } } |