Add `Minimize` binding action

Fixes #2534.
This commit is contained in:
Kirill Chibisov 2020-01-05 04:54:14 +03:00 committed by Christian Duerr
parent 1cfb0740bc
commit 0cc68da04f
5 changed files with 20 additions and 6 deletions

View File

@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- /Applications symlink into OS X DMG for easier installation
- Colored emojis on Linux/BSD
- Value `randr` for `WINIT_HIDPI_FACTOR`, to ignore `Xft.dpi` and scale based on screen dimensions
- `Minimize` key binding action, bound to `cmd + m` on macOS
### Changed

View File

@ -65,14 +65,14 @@
# Window title
#title: Alacritty
# Window class (Linux only):
# Window class (Linux/BSD only):
#class:
# Application instance name
#instance: Alacritty
# General application class
#general: Alacritty
# GTK theme variant (Linux only)
# GTK theme variant (Linux/BSD only)
#
# Override the variant of the GTK theme. Commonly supported values are `dark` and `light`.
# Set this to `None` to use the default theme variant.
@ -107,7 +107,7 @@
#
# Default:
# - (macOS) Menlo
# - (Linux) monospace
# - (Linux/BSD) monospace
# - (Windows) Consolas
#family: monospace
@ -324,7 +324,7 @@
#
# Default:
# - (macOS) /bin/bash --login
# - (Linux) user login shell
# - (Linux/BSD) user login shell
# - (Windows) powershell
#shell:
# program: /bin/bash
@ -396,7 +396,7 @@
#
# Default:
# - (macOS) open
# - (Linux) xdg-open
# - (Linux/BSD) xdg-open
# - (Windows) explorer
#launcher:
# program: xdg-open
@ -482,6 +482,7 @@
# - ScrollToBottom
# - ClearHistory
# - Hide
# - Minimize
# - Quit
# - ToggleFullscreen
# - SpawnNewInstance
@ -530,7 +531,7 @@
# be mapped to the `ReceiveChar` action. Alternatively, you can use `None` for
# a no-op if you do not wish to receive input characters for that binding.
#key_bindings:
# (Windows/Linux only)
# (Windows, Linux, and BSD only)
#- { key: V, mods: Control|Shift, action: Paste }
#- { key: C, mods: Control|Shift, action: Copy }
#- { key: Insert, mods: Shift, action: PasteSelection }
@ -539,6 +540,8 @@
#- { key: Add, mods: Control, action: IncreaseFontSize }
#- { key: Subtract, mods: Control, action: DecreaseFontSize }
#- { key: Minus, mods: Control, action: DecreaseFontSize }
# (Windows only)
#- { key: Return, mods: Alt, action: ToggleFullscreen }
# (macOS only)
@ -551,6 +554,7 @@
#- { key: V, mods: Command, action: Paste }
#- { key: C, mods: Command, action: Copy }
#- { key: H, mods: Command, action: Hide }
#- { key: M, mods: Command, action: Minimize }
#- { key: Q, mods: Command, action: Quit }
#- { key: W, mods: Command, action: Quit }
#- { key: F, mods: Command|Control, action: ToggleFullscreen }

View File

@ -167,6 +167,9 @@ pub enum Action {
/// Hide the Alacritty window.
Hide,
/// Minimize the Alacritty window.
Minimize,
/// Quit Alacritty.
Quit,
@ -430,6 +433,7 @@ pub fn platform_key_bindings() -> Vec<KeyBinding> {
Key::V, ModifiersState::LOGO; Action::Paste;
Key::C, ModifiersState::LOGO; Action::Copy;
Key::H, ModifiersState::LOGO; Action::Hide;
Key::M, ModifiersState::LOGO; Action::Minimize;
Key::Q, ModifiersState::LOGO; Action::Quit;
Key::W, ModifiersState::LOGO; Action::Quit;
)

View File

@ -137,6 +137,7 @@ impl<T: EventListener> Execute<T> for Action {
#[cfg(target_os = "macos")]
Action::ToggleSimpleFullscreen => ctx.window_mut().toggle_simple_fullscreen(),
Action::Hide => ctx.window().set_visible(false),
Action::Minimize => ctx.window().set_minimized(true),
Action::Quit => ctx.terminal_mut().exit(),
Action::IncreaseFontSize => ctx.change_font_size(FONT_SIZE_STEP),
Action::DecreaseFontSize => ctx.change_font_size(FONT_SIZE_STEP * -1.),

View File

@ -319,6 +319,10 @@ impl Window {
self.window().set_maximized(maximized);
}
pub fn set_minimized(&self, minimized: bool) {
self.window().set_minimized(minimized);
}
/// Toggle the window's fullscreen state
pub fn toggle_fullscreen(&mut self) {
self.set_fullscreen(self.window().fullscreen().is_none());