Use `WindowEvent::Occluded` to hint rendering

This should prevent rendering on macOS and X11 to invisible
windows.
This commit is contained in:
trimental 2022-08-11 17:06:19 +08:00 committed by GitHub
parent 7d708d53f7
commit 376300385b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 2 deletions

View File

@ -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`

View File

@ -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(_) => (),
}
},

View File

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