Skip to content

Commit 9cb27db

Browse files
Stop background pointer injection after activation
1 parent 13109b8 commit 9cb27db

2 files changed

Lines changed: 4 additions & 12 deletions

File tree

OverflowBar/Services/MenuBarItemStore.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -334,20 +334,17 @@ final class MenuBarItemStore: ObservableObject {
334334
DispatchQueue.main.asyncAfter(deadline: .now() + 0.08) { [weak self] in
335335
guard let self else { return }
336336
if self.activator.activateDirectly(item) {
337-
self.rehideAfterNextUserClick(item, restoreCursorLocation: restoreCursorLocation)
338337
self.finishActivation()
339338
return
340339
}
341340
self.activator.activateMovedItem(item) { [weak self] success in
342341
guard let self else { return }
343342
self.layoutManager.restorePointerLocation(restoreCursorLocation)
344343
guard success else {
345-
self.layoutManager.rehide(item, restoreCursorLocation: restoreCursorLocation)
346344
self.lastActivationError = "Unable to activate \(item.tooltip)."
347345
self.finishActivation()
348346
return
349347
}
350-
self.rehideAfterNextUserClick(item, restoreCursorLocation: restoreCursorLocation)
351348
self.finishActivation()
352349
}
353350
}

OverflowBar/Services/MenuBarLayoutManager.swift

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,12 @@ final class MenuBarLayoutManager {
7070
/// Quartz screen coordinates captured before any synthetic menu-bar event.
7171
func currentPointerLocation() -> CGPoint? { CGEvent(source: nil)?.location }
7272

73-
/// Reassociates WindowServer with the real pointer after a synthetic click.
74-
///
75-
/// The order is intentional: Quartz documents that warping does not emit a
76-
/// mouse event, and associating before the warp can leave the hardware mouse
77-
/// and cursor in the disconnected state on recent macOS releases. Warp
78-
/// first, associate afterwards, then send a zero-delta move so other apps
79-
/// recompute hover/cursor tracking immediately.
73+
/// Synchronizes WindowServer's logical pointer with the real pointer after
74+
/// a synthetic click. Do not use CGWarpMouseCursorPosition here: warping
75+
/// changes the cursor association globally and does not emit a move event,
76+
/// which can leave other applications with stale hover/cursor state.
8077
func restorePointerLocation(_ point: CGPoint?) {
8178
guard let point, Self.isValidPointerLocation(point) else { return }
82-
_ = CGWarpMouseCursorPosition(point)
83-
_ = CGAssociateMouseAndMouseCursorPosition(1)
8479
guard let source = CGEventSource(stateID: .hidSystemState),
8580
let move = CGEvent(mouseEventSource: source, mouseType: .mouseMoved, mouseCursorPosition: point, mouseButton: .left) else { return }
8681
move.setIntegerValueField(.mouseEventDeltaX, value: 0)

0 commit comments

Comments
 (0)