summaryrefslogtreecommitdiff
path: root/src/event.rs
diff options
context:
space:
mode:
authoracheronfail <acheronfail@gmail.com>2019-04-24 05:05:47 +1000
committerChristian Duerr <chrisduerr@users.noreply.github.com>2019-04-23 19:05:47 +0000
commite9813031f6e308984cb5547aa1049839cb75745f (patch)
treec8e6286c98f4f42b6e170e477baa6b1f949b83ef /src/event.rs
parentb0efa9d105b53211d8df094238c7eb8324e93566 (diff)
downloadalacritty-e9813031f6e308984cb5547aa1049839cb75745f.tar.gz
alacritty-e9813031f6e308984cb5547aa1049839cb75745f.zip
Add fullscreen support
Fixes #34. Fixes #2012.
Diffstat (limited to 'src/event.rs')
-rw-r--r--src/event.rs43
1 files changed, 36 insertions, 7 deletions
diff --git a/src/event.rs b/src/event.rs
index ffedce2d..1f3e9ca5 100644
--- a/src/event.rs
+++ b/src/event.rs
@@ -188,25 +188,41 @@ impl<'a, N: Notify + 'a> input::ActionContext for ActionContext<'a, N> {
Err(_) => warn!("Unable to start new Alacritty process: {} {:?}", alacritty, args),
}
}
+
+ fn toggle_fullscreen(&mut self) {
+ self.window_changes.toggle_fullscreen();
+ }
+
+ #[cfg(target_os = "macos")]
+ fn toggle_simple_fullscreen(&mut self) {
+ self.window_changes.toggle_simple_fullscreen()
+ }
}
/// The ActionContext can't really have direct access to the Window
/// with the current design. Event handlers that want to change the
/// window must set these flags instead. The processor will trigger
/// the actual changes.
+#[derive(Default)]
pub struct WindowChanges {
pub hide: bool,
+ pub toggle_fullscreen: bool,
+ #[cfg(target_os = "macos")]
+ pub toggle_simple_fullscreen: bool,
}
impl WindowChanges {
fn clear(&mut self) {
- self.hide = false;
+ *self = WindowChanges::default();
+ }
+
+ fn toggle_fullscreen(&mut self) {
+ self.toggle_fullscreen = !self.toggle_fullscreen;
}
-}
-impl Default for WindowChanges {
- fn default() -> WindowChanges {
- WindowChanges { hide: false }
+ #[cfg(target_os = "macos")]
+ fn toggle_simple_fullscreen(&mut self) {
+ self.toggle_simple_fullscreen = !self.toggle_simple_fullscreen;
}
}
@@ -281,6 +297,8 @@ pub struct Processor<N> {
window_changes: WindowChanges,
save_to_clipboard: bool,
alt_send_esc: bool,
+ is_fullscreen: bool,
+ is_simple_fullscreen: bool,
}
/// Notify that the terminal was resized
@@ -326,6 +344,8 @@ impl<N: Notify> Processor<N> {
window_changes: Default::default(),
save_to_clipboard: config.selection().save_to_clipboard,
alt_send_esc: config.alt_send_esc(),
+ is_fullscreen: false,
+ is_simple_fullscreen: false,
}
}
@@ -546,8 +566,17 @@ impl<N: Notify> Processor<N> {
window.hide();
}
- if self.window_changes.hide {
- window.hide();
+ #[cfg(target_os = "macos")]
+ {
+ if self.window_changes.toggle_simple_fullscreen && !self.is_fullscreen {
+ window.set_simple_fullscreen(!self.is_simple_fullscreen);
+ self.is_simple_fullscreen = !self.is_simple_fullscreen;
+ }
+ }
+
+ if self.window_changes.toggle_fullscreen && !self.is_simple_fullscreen {
+ window.set_fullscreen(!self.is_fullscreen);
+ self.is_fullscreen = !self.is_fullscreen;
}
self.window_changes.clear();