mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-22 11:46:11 +03:00
mac: get default click repeat interval from NSEvent
This commit is contained in:
@ -5,6 +5,7 @@ const ArenaAllocator = std.heap.ArenaAllocator;
|
|||||||
const inputpkg = @import("input.zig");
|
const inputpkg = @import("input.zig");
|
||||||
const passwd = @import("passwd.zig");
|
const passwd = @import("passwd.zig");
|
||||||
const terminal = @import("terminal/main.zig");
|
const terminal = @import("terminal/main.zig");
|
||||||
|
const internal_os = @import("os/main.zig");
|
||||||
|
|
||||||
const log = std.log.scoped(.config);
|
const log = std.log.scoped(.config);
|
||||||
|
|
||||||
@ -327,7 +328,7 @@ pub const Config = struct {
|
|||||||
|
|
||||||
// Default our click interval
|
// Default our click interval
|
||||||
if (self.@"click-repeat-interval" == 0) {
|
if (self.@"click-repeat-interval" == 0) {
|
||||||
self.@"click-repeat-interval" = 500;
|
self.@"click-repeat-interval" = internal_os.clickInterval() orelse 500;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -4,3 +4,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");
|
pub usingnamespace @import("macos_version.zig");
|
||||||
|
pub usingnamespace @import("mouse.zig");
|
||||||
|
24
src/os/mouse.zig
Normal file
24
src/os/mouse.zig
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
const std = @import("std");
|
||||||
|
const builtin = @import("builtin");
|
||||||
|
const assert = std.debug.assert;
|
||||||
|
const objc = @import("objc");
|
||||||
|
|
||||||
|
const log = std.log.scoped(.os);
|
||||||
|
|
||||||
|
/// The system-configured double-click interval if its available.
|
||||||
|
pub fn clickInterval() ?u32 {
|
||||||
|
// On macOS, we can ask the system.
|
||||||
|
if (comptime builtin.target.isDarwin()) {
|
||||||
|
const NSEvent = objc.Class.getClass("NSEvent") orelse {
|
||||||
|
log.err("NSEvent class not found. Can't get click interval.", .{});
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Get the interval and convert to ms
|
||||||
|
const interval = NSEvent.msgSend(f64, objc.sel("doubleClickInterval"), .{});
|
||||||
|
const ms = @floatToInt(u32, @ceil(interval * 1000));
|
||||||
|
return ms;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
Reference in New Issue
Block a user