From 1098e76f73ace6fcfa518f4cb80b37977d9fe51f Mon Sep 17 00:00:00 2001 From: Aura - jc <67582323+Catafal@users.noreply.github.com> Date: Fri, 10 Apr 2026 11:32:50 +0200 Subject: [PATCH] Fix cursor overlay invisible on secondary monitors NSView.frame uses window-local coordinates, not global screen coordinates. For secondary monitors with non-zero origins (e.g. {1920,0}), setting hostingView.frame = screen.frame displaced the SwiftUI content 1920pt outside the window bounds, making the overlay invisible. The window itself is correctly positioned via NSPanel.setFrame(screen.frame) in OverlayWindow.init. Only the content view frame needs fixing. Fixes #24 Co-Authored-By: Claude Sonnet 4.6 --- leanring-buddy/OverlayWindow.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/leanring-buddy/OverlayWindow.swift b/leanring-buddy/OverlayWindow.swift index 884ebcbf..50c6a0da 100644 --- a/leanring-buddy/OverlayWindow.swift +++ b/leanring-buddy/OverlayWindow.swift @@ -799,7 +799,12 @@ class OverlayWindowManager { ) let hostingView = NSHostingView(rootView: contentView) - hostingView.frame = screen.frame + // Use window-local coordinates (origin .zero), not global screen coordinates. + // The NSPanel is already positioned at screen.frame.origin via OverlayWindow.init. + // NSView.frame is relative to the window's content area, which always starts at (0,0). + // Using screen.frame here (with non-zero origin on secondary monitors) would offset + // the hosting view outside the window bounds, making the overlay invisible. + hostingView.frame = CGRect(origin: .zero, size: screen.frame.size) window.contentView = hostingView overlayWindows.append(window)