mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-08-26 00:51:44 +00:00
macos: tolerate display link creation failures
Fixes #13293 Treat Core Video display link creation as optional when macOS has no active displays. The previous error path reported every creation failure as out of memory and aborted renderer initialization. This also resyncs the display link on any display change so when a display becomes available it re-adds itself. Tabs created while the session is locked now initialize normally and fall back to event-driven rendering without vsync.
This commit is contained in:
@@ -1,21 +1,19 @@
|
||||
const std = @import("std");
|
||||
const assert = std.debug.assert;
|
||||
const Allocator = std.mem.Allocator;
|
||||
const c = @import("c.zig").c;
|
||||
|
||||
pub const DisplayLink = opaque {
|
||||
pub const Error = error{
|
||||
CreationFailed,
|
||||
InvalidOperation,
|
||||
};
|
||||
|
||||
pub fn createWithActiveCGDisplays() Allocator.Error!*DisplayLink {
|
||||
pub fn createWithActiveCGDisplays() Error!*DisplayLink {
|
||||
var result: ?*DisplayLink = null;
|
||||
if (c.CVDisplayLinkCreateWithActiveCGDisplays(
|
||||
@ptrCast(&result),
|
||||
) != c.kCVReturnSuccess)
|
||||
return error.OutOfMemory;
|
||||
return error.CreationFailed;
|
||||
|
||||
return result orelse error.OutOfMemory;
|
||||
return result orelse error.CreationFailed;
|
||||
}
|
||||
|
||||
pub fn release(self: *DisplayLink) void {
|
||||
|
||||
Reference in New Issue
Block a user