mirror of
https://github.com/alacritty/alacritty.git
synced 2024-11-25 14:05:41 -05:00
Add ToggleMaximized
key binding action
This commit is contained in:
parent
13b6248dd9
commit
00383ae967
5 changed files with 18 additions and 9 deletions
|
@ -15,6 +15,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||
|
||||
- Track and report surface damage information to Wayland compositors
|
||||
- Escape sequence for undercurl, dotted and dashed underlines (`CSI 4 : [3-5] m`)
|
||||
- `ToggleMaximized` key binding action to (un-)maximize the active window, not bound by default
|
||||
|
||||
### Changed
|
||||
|
||||
|
|
|
@ -186,6 +186,9 @@ pub enum Action {
|
|||
/// Toggle fullscreen.
|
||||
ToggleFullscreen,
|
||||
|
||||
/// Toggle maximized.
|
||||
ToggleMaximized,
|
||||
|
||||
/// Toggle simple fullscreen on macOS.
|
||||
#[cfg(target_os = "macos")]
|
||||
ToggleSimpleFullscreen,
|
||||
|
|
|
@ -249,7 +249,7 @@ impl Display {
|
|||
debug!("Estimated cell size: {} x {}", cell_width, cell_height);
|
||||
|
||||
// Spawn the Alacritty window.
|
||||
let mut window = Window::new(
|
||||
let window = Window::new(
|
||||
event_loop,
|
||||
config,
|
||||
identity,
|
||||
|
|
|
@ -235,7 +235,7 @@ impl Window {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_inner_size(&mut self, size: PhysicalSize<u32>) {
|
||||
pub fn set_inner_size(&self, size: PhysicalSize<u32>) {
|
||||
self.window().set_inner_size(size);
|
||||
}
|
||||
|
||||
|
@ -379,7 +379,6 @@ impl Window {
|
|||
self.window().id()
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os = "macos", windows)))]
|
||||
pub fn set_maximized(&self, maximized: bool) {
|
||||
self.window().set_maximized(maximized);
|
||||
}
|
||||
|
@ -389,16 +388,21 @@ impl Window {
|
|||
}
|
||||
|
||||
/// Toggle the window's fullscreen state.
|
||||
pub fn toggle_fullscreen(&mut self) {
|
||||
pub fn toggle_fullscreen(&self) {
|
||||
self.set_fullscreen(self.window().fullscreen().is_none());
|
||||
}
|
||||
|
||||
/// Toggle the window's maximized state.
|
||||
pub fn toggle_maximized(&self) {
|
||||
self.set_maximized(!self.window().is_maximized());
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
pub fn toggle_simple_fullscreen(&mut self) {
|
||||
pub fn toggle_simple_fullscreen(&self) {
|
||||
self.set_simple_fullscreen(!self.window().simple_fullscreen());
|
||||
}
|
||||
|
||||
pub fn set_fullscreen(&mut self, fullscreen: bool) {
|
||||
pub fn set_fullscreen(&self, fullscreen: bool) {
|
||||
if fullscreen {
|
||||
self.window().set_fullscreen(Some(Fullscreen::Borderless(None)));
|
||||
} else {
|
||||
|
@ -407,7 +411,7 @@ impl Window {
|
|||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
pub fn set_simple_fullscreen(&mut self, simple_fullscreen: bool) {
|
||||
pub fn set_simple_fullscreen(&self, simple_fullscreen: bool) {
|
||||
self.window().set_simple_fullscreen(simple_fullscreen);
|
||||
}
|
||||
|
||||
|
@ -417,7 +421,7 @@ impl Window {
|
|||
}
|
||||
|
||||
/// Adjust the IME editor position according to the new location of the cursor.
|
||||
pub fn update_ime_position(&mut self, point: Point, size: &SizeInfo) {
|
||||
pub fn update_ime_position(&self, point: Point, size: &SizeInfo) {
|
||||
let nspot_x = f64::from(size.padding_x() + point.column.0 as f32 * size.cell_width());
|
||||
let nspot_y = f64::from(size.padding_y() + (point.line.0 + 1) as f32 * size.cell_height());
|
||||
|
||||
|
|
|
@ -259,6 +259,7 @@ impl<T: EventListener> Execute<T> for Action {
|
|||
ctx.paste(&text);
|
||||
},
|
||||
Action::ToggleFullscreen => ctx.window().toggle_fullscreen(),
|
||||
Action::ToggleMaximized => ctx.window().toggle_maximized(),
|
||||
#[cfg(target_os = "macos")]
|
||||
Action::ToggleSimpleFullscreen => ctx.window().toggle_simple_fullscreen(),
|
||||
#[cfg(target_os = "macos")]
|
||||
|
|
Loading…
Reference in a new issue