Skip to content

Commit

Permalink
Use WindowEvent::Occluded to hint rendering
Browse files Browse the repository at this point in the history
This should prevent rendering on macOS and X11 to invisible
windows.
  • Loading branch information
trimental committed Aug 11, 2022
1 parent 7d708d5 commit 3763003
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

### Changed

- No longer renders to macos and x11 windows that are fully occluded / not directly visible
- The `--help` output was reworked with a new colorful syntax
- OSC 52 is now disabled on unfocused windows
- `SpawnNewInstance` no longer inherits initial `--command`
Expand Down
5 changes: 4 additions & 1 deletion alacritty/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ pub struct ActionContext<'a, N, T> {
pub search_state: &'a mut SearchState,
pub font_size: &'a mut Size,
pub dirty: &'a mut bool,
pub occluded: &'a mut bool,
pub preserve_title: bool,
#[cfg(not(windows))]
pub master_fd: RawFd,
Expand Down Expand Up @@ -1201,6 +1202,9 @@ impl input::Processor<EventProxy, ActionContext<'_, Notifier, EventProxy>> {
self.ctx.update_cursor_blinking();
self.on_focus_change(is_focused);
},
WindowEvent::Occluded(occluded) => {
*self.ctx.occluded = occluded;
},
WindowEvent::DroppedFile(path) => {
let path: String = path.to_string_lossy().into();
self.ctx.write_to_pty((path + " ").into_bytes());
Expand Down Expand Up @@ -1229,7 +1233,6 @@ impl input::Processor<EventProxy, ActionContext<'_, Notifier, EventProxy>> {
| WindowEvent::ThemeChanged(_)
| WindowEvent::HoveredFile(_)
| WindowEvent::Touch(_)
| WindowEvent::Occluded(_)
| WindowEvent::Moved(_) => (),
}
},
Expand Down
5 changes: 4 additions & 1 deletion alacritty/src/window_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ pub struct WindowContext {
font_size: Size,
mouse: Mouse,
dirty: bool,
occluded: bool,
preserve_title: bool,
#[cfg(not(windows))]
master_fd: RawFd,
Expand Down Expand Up @@ -161,6 +162,7 @@ impl WindowContext {
modifiers: Default::default(),
mouse: Default::default(),
dirty: Default::default(),
occluded: Default::default(),
})
}

Expand Down Expand Up @@ -276,6 +278,7 @@ impl WindowContext {
display: &mut self.display,
mouse: &mut self.mouse,
dirty: &mut self.dirty,
occluded: &mut self.occluded,
terminal: &mut terminal,
#[cfg(not(windows))]
master_fd: self.master_fd,
Expand Down Expand Up @@ -324,7 +327,7 @@ impl WindowContext {
return;
}

if self.dirty {
if self.dirty && !self.occluded {
// Force the display to process any pending display update.
self.display.process_renderer_update();

Expand Down

0 comments on commit 3763003

Please sign in to comment.