os: no mouse interval on ios

This commit is contained in:
Mitchell Hashimoto
2024-01-14 14:48:56 -08:00
parent 8c8838542f
commit 470b57f194

View File

@ -7,8 +7,9 @@ const log = std.log.scoped(.os);
/// The system-configured double-click interval if its available.
pub fn clickInterval() ?u32 {
return switch (builtin.os.tag) {
// On macOS, we can ask the system.
if (comptime builtin.target.isDarwin()) {
.macos => macos: {
const NSEvent = objc.getClass("NSEvent") orelse {
log.err("NSEvent class not found. Can't get click interval.", .{});
return null;
@ -17,8 +18,9 @@ pub fn clickInterval() ?u32 {
// Get the interval and convert to ms
const interval = NSEvent.msgSend(f64, objc.sel("doubleClickInterval"), .{});
const ms = @as(u32, @intFromFloat(@ceil(interval * 1000)));
return ms;
}
break :macos ms;
},
return null;
else => null,
};
}