mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 16:56:09 +03:00
renderer/metal: stop display link when we lose focus
This commit is contained in:
@ -723,6 +723,18 @@ fn gridSize(self: *Metal) ?renderer.GridSize {
|
|||||||
/// Must be called on the render thread.
|
/// Must be called on the render thread.
|
||||||
pub fn setFocus(self: *Metal, focus: bool) !void {
|
pub fn setFocus(self: *Metal, focus: bool) !void {
|
||||||
self.focused = focus;
|
self.focused = focus;
|
||||||
|
|
||||||
|
// If we're not focused, then we want to stop the display link
|
||||||
|
// because it is a waste of resources and we can move to pure
|
||||||
|
// change-driven updates.
|
||||||
|
if (comptime DisplayLink != void) link: {
|
||||||
|
const display_link = self.display_link orelse break :link;
|
||||||
|
if (focus) {
|
||||||
|
display_link.start() catch {};
|
||||||
|
} else {
|
||||||
|
display_link.stop() catch {};
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the new font size.
|
/// Set the new font size.
|
||||||
|
Reference in New Issue
Block a user