Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions Sources/Fluid/Services/NotchOverlayManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ final class NotchOverlayManager {

// Start monitoring active app changes (updates icon in real-time)
ActiveAppMonitor.shared.startMonitoring()
let targetScreen = OverlayScreenResolver.screenForCurrentPointer()

// Route to bottom overlay if user preference is set
if SettingsStore.shared.overlayPosition == .bottom {
Expand All @@ -168,7 +169,7 @@ final class NotchOverlayManager {
}

// Otherwise show notch overlay (original behavior)
self.showNotchOverlay(audioLevelPublisher: audioLevelPublisher, mode: mode)
self.showNotchOverlay(audioLevelPublisher: audioLevelPublisher, mode: mode, screen: targetScreen)
}

/// Show bottom overlay (alternative to notch)
Expand All @@ -186,7 +187,7 @@ final class NotchOverlayManager {
}

/// Show notch overlay (original behavior)
private func showNotchOverlay(audioLevelPublisher: AnyPublisher<CGFloat, Never>, mode: OverlayMode) {
private func showNotchOverlay(audioLevelPublisher: AnyPublisher<CGFloat, Never>, mode: OverlayMode, screen: NSScreen?) {
// Hide bottom overlay if it was visible
if self.isBottomOverlayVisible {
BottomOverlayWindowController.shared.hide()
Expand Down Expand Up @@ -221,7 +222,11 @@ final class NotchOverlayManager {

// Show in expanded state
Task { [weak self] in
await newNotch.expand()
if let screen {
await newNotch.expand(on: screen)
} else {
await newNotch.expand()
}
// Only update state if we're still the active generation
guard let self = self, self.generation == currentGeneration else { return }
self.state = .visible
Expand Down Expand Up @@ -403,7 +408,11 @@ final class NotchOverlayManager {

self.commandOutputNotch = newNotch

await newNotch.expand()
if let screen = OverlayScreenResolver.screenForCurrentPointer() {
await newNotch.expand(on: screen)
} else {
await newNotch.expand()
}

guard self.commandOutputGeneration == currentGeneration else { return }
self.commandOutputState = .visible
Expand Down
15 changes: 15 additions & 0 deletions Sources/Fluid/Services/OverlayScreenResolver.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// OverlayScreenResolver.swift
// Fluid
//

import AppKit

enum OverlayScreenResolver {
static func screenForCurrentPointer() -> NSScreen? {
let location = NSEvent.mouseLocation
return NSScreen.screens.first { screen in
screen.frame.contains(location)
} ?? NSScreen.main ?? NSScreen.screens.first
}
}
7 changes: 4 additions & 3 deletions Sources/Fluid/Views/BottomOverlayView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ final class BottomOverlayWindowController {
private var pendingResizeWorkItem: DispatchWorkItem?
private var localMouseDownMonitor: Any?
private var globalMouseDownMonitor: Any?
private var targetScreen: NSScreen?

private init() {
NotificationCenter.default.addObserver(forName: NSNotification.Name("OverlayOffsetChanged"), object: nil, queue: .main) { [weak self] _ in
Expand Down Expand Up @@ -78,7 +79,7 @@ final class BottomOverlayWindowController {
self.createWindow()
}

// Position at bottom center of main screen
self.targetScreen = OverlayScreenResolver.screenForCurrentPointer()
self.positionWindow()

// Show with animation
Expand All @@ -98,6 +99,7 @@ final class BottomOverlayWindowController {
self.audioSubscription = nil
self.pendingResizeWorkItem?.cancel()
self.pendingResizeWorkItem = nil
self.targetScreen = nil
self.removeMouseDownMonitors()
BottomOverlayPromptMenuController.shared.hide()
BottomOverlayModeMenuController.shared.hide()
Expand Down Expand Up @@ -247,8 +249,7 @@ final class BottomOverlayWindowController {
// Safe check for window and screen availability
guard let window = window else { return }

// Use the screen that contains the window, or fallback to the main screen
let screen = window.screen ?? NSScreen.main
let screen = self.targetScreen ?? window.screen ?? OverlayScreenResolver.screenForCurrentPointer()
guard let screen = screen else { return }

let fullFrame = screen.frame
Expand Down
Loading