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