Skip to content

Commit

Permalink
Add ToggleMaximized key binding action
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisnc authored Feb 27, 2022
1 parent 13b6248 commit 00383ae
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 9 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -28,7 +29,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

### Added

- Option `font.builtin_box_drawing` to disable the built-in font for drawing box characters
- Option `font.builtin_box_drawing` to disable the built-in font for drawing box characters

### Changed

Expand Down
3 changes: 3 additions & 0 deletions alacritty/src/config/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ pub enum Action {
/// Toggle fullscreen.
ToggleFullscreen,

/// Toggle maximized.
ToggleMaximized,

/// Toggle simple fullscreen on macOS.
#[cfg(target_os = "macos")]
ToggleSimpleFullscreen,
Expand Down
2 changes: 1 addition & 1 deletion alacritty/src/display/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
18 changes: 11 additions & 7 deletions alacritty/src/display/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}
Expand All @@ -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 {
Expand All @@ -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);
}

Expand All @@ -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());

Expand Down
1 change: 1 addition & 0 deletions alacritty/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down

0 comments on commit 00383ae

Please sign in to comment.