mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-19 10:16:12 +03:00
don't change cursor to ibeam on macOS prior to Ventura
glfw crashes with our tab group usage (see comment)
This commit is contained in:
@ -29,6 +29,7 @@ const Config = @import("config.zig").Config;
|
|||||||
const input = @import("input.zig");
|
const input = @import("input.zig");
|
||||||
const DevMode = @import("DevMode.zig");
|
const DevMode = @import("DevMode.zig");
|
||||||
const App = @import("App.zig");
|
const App = @import("App.zig");
|
||||||
|
const internal_os = @import("os/main.zig");
|
||||||
|
|
||||||
// Get native API access on certain platforms so we can do more customization.
|
// Get native API access on certain platforms so we can do more customization.
|
||||||
const glfwNative = glfw.Native(.{
|
const glfwNative = glfw.Native(.{
|
||||||
@ -333,7 +334,12 @@ pub fn create(alloc: Allocator, app: *App, config: *const Config) !*Window {
|
|||||||
// Create the cursor
|
// Create the cursor
|
||||||
const cursor = try glfw.Cursor.createStandard(.ibeam);
|
const cursor = try glfw.Cursor.createStandard(.ibeam);
|
||||||
errdefer cursor.destroy();
|
errdefer cursor.destroy();
|
||||||
try window.setCursor(cursor);
|
if ((comptime !builtin.target.isDarwin()) or internal_os.macosVersionAtLeast(13, 0, 0)) {
|
||||||
|
// We only set our cursor if we're NOT on Mac, or if we are then the
|
||||||
|
// macOS version is >= 13 (Ventura). On prior versions, glfw crashes
|
||||||
|
// since we use a tab group.
|
||||||
|
try window.setCursor(cursor);
|
||||||
|
}
|
||||||
|
|
||||||
// The mutex used to protect our renderer state.
|
// The mutex used to protect our renderer state.
|
||||||
var mutex = try alloc.create(std.Thread.Mutex);
|
var mutex = try alloc.create(std.Thread.Mutex);
|
||||||
|
21
src/os/macos_version.zig
Normal file
21
src/os/macos_version.zig
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
const std = @import("std");
|
||||||
|
const builtin = @import("builtin");
|
||||||
|
const assert = std.debug.assert;
|
||||||
|
const objc = @import("objc");
|
||||||
|
|
||||||
|
/// Verifies that the running macOS system version is at least the given version.
|
||||||
|
pub fn macosVersionAtLeast(major: i64, minor: i64, patch: i64) bool {
|
||||||
|
assert(builtin.target.isDarwin());
|
||||||
|
|
||||||
|
const NSProcessInfo = objc.Class.getClass("NSProcessInfo").?;
|
||||||
|
const info = NSProcessInfo.msgSend(objc.Object, objc.sel("processInfo"), .{});
|
||||||
|
return info.msgSend(bool, objc.sel("isOperatingSystemAtLeastVersion:"), .{
|
||||||
|
NSOperatingSystemVersion{ .major = major, .minor = minor, .patch = patch },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
pub const NSOperatingSystemVersion = extern struct {
|
||||||
|
major: i64,
|
||||||
|
minor: i64,
|
||||||
|
patch: i64,
|
||||||
|
};
|
@ -3,3 +3,4 @@
|
|||||||
|
|
||||||
pub usingnamespace @import("file.zig");
|
pub usingnamespace @import("file.zig");
|
||||||
pub usingnamespace @import("locale.zig");
|
pub usingnamespace @import("locale.zig");
|
||||||
|
pub usingnamespace @import("macos_version.zig");
|
||||||
|
Reference in New Issue
Block a user