I'm positioning a tooltip-style panel relative to the mouse pointer and need to avoid overlapping the pointer glyph itself. This works fine at the default pointer size, but breaks once the user sets System Settings → Accessibility → Pointer → Pointer size to something larger than Normal — the pointer is visibly bigger on screen, but my offset doesn't grow to match, so the tooltip overlaps it.
The only cursor-size-related value I've found any API expose is the ratio behind that same setting, read via:
/usr/bin/defaults read com.apple.universalaccess mouseDriverCursorSize
This returns a scale factor (1.0 = Normal, larger toward Large), not a size in points. I'm using it to scale a fixed offset, but that only approximates the real on-screen footprint of the pointer glyph — it doesn't tell me the glyph's actual rendered bounding box, so the tooltip still clips the pointer at larger sizes.
Question: Is there a supported API — AppKit, Accessibility, or otherwise — that returns the system pointer's actual rendered size (bounding box, in points) reflecting the user's Pointer size setting? Or is there a different recommended approach for positioning UI relative to the live pointer without overlapping it, that doesn't depend on knowing that size directly?
Minimal repro (AppKit, Swift Package Manager, no storyboard/xib — ~150 lines):
enum CursorPrefs {
static func readPointerScale() -> Double {
let process = Process()
process.executableURL = URL(fileURLWithPath: "/usr/bin/defaults")
process.arguments = ["read", "com.apple.universalaccess", "mouseDriverCursorSize"]
let outputPipe = Pipe()
process.standardOutput = outputPipe
process.standardError = Pipe()
try? process.run()
process.waitUntilExit()
let data = outputPipe.fileHandleForReading.readDataToEndOfFile()
let output = String(data: data, encoding: .utf8)?.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
guard let scale = Double(output), scale >= 1.0 else { return 1.0 }
return scale
}
}
// A tracking-area view shows a tooltip-style NSPanel near NSEvent.mouseLocation,
// offset by a fixed amount scaled by the value above. At Pointer size = Large,
// the tooltip still overlaps the (visibly bigger) pointer glyph, because the
// value is a ratio, not the glyph's rendered size in points.
Steps to reproduce:
- Run the demo app (
swift run, or openPackage.swiftin Xcode and Run). - Open System Settings → Accessibility → Pointer → Pointer size and set it to Large.
- Quit and relaunch the demo (it reads the setting once at launch).
- Move the mouse over the gray box in the window.
- The floating tooltip tracks the pointer but still overlaps the now-larger pointer glyph.
Environment: macOS 14.7.8 (23H730, Xcode 16.2 (16C5032a), Swift 5.9, arm64 (Apple Silicon).
Happy to attach the full repro project as a zip if useful — it's a single main.swift plus an SPM manifest, no external dependencies.