aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortrimental <timmins.s.lucas@gmail.com>2022-08-11 17:06:19 +0800
committerGitHub <noreply@github.com>2022-08-11 13:06:19 +0400
commit376300385b5a9377470567094ca28ed831769c30 (patch)
treec363308639b0b44127231867d1b329c031930651
parent7d708d53f7ecb4c64db10ae44e7f4fca47c29a85 (diff)
downloadalacritty-376300385b5a9377470567094ca28ed831769c30.tar.gz
alacritty-376300385b5a9377470567094ca28ed831769c30.zip
Use `WindowEvent::Occluded` to hint rendering
This should prevent rendering on macOS and X11 to invisible windows.
-rw-r--r--CHANGELOG.md1
-rw-r--r--alacritty/src/event.rs5
-rw-r--r--alacritty/src/window_context.rs5
3 files changed, 9 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c40e8b14..aa6091d9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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`
diff --git a/alacritty/src/event.rs b/alacritty/src/event.rs
index 54bb239e..3beb5d1e 100644
--- a/alacritty/src/event.rs
+++ b/alacritty/src/event.rs
@@ -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,
@@ -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());
@@ -1229,7 +1233,6 @@ impl input::Processor<EventProxy, ActionContext<'_, Notifier, EventProxy>> {
| WindowEvent::ThemeChanged(_)
| WindowEvent::HoveredFile(_)
| WindowEvent::Touch(_)
- | WindowEvent::Occluded(_)
| WindowEvent::Moved(_) => (),
}
},
diff --git a/alacritty/src/window_context.rs b/alacritty/src/window_context.rs
index 1dd620a4..e75f118d 100644
--- a/alacritty/src/window_context.rs
+++ b/alacritty/src/window_context.rs
@@ -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,
@@ -161,6 +162,7 @@ impl WindowContext {
modifiers: Default::default(),
mouse: Default::default(),
dirty: Default::default(),
+ occluded: Default::default(),
})
}
@@ -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,
@@ -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();