Skip to content

Track the pointer over the notch instead of everywhere - #94

Merged
jordan-cod merged 1 commit into
mainfrom
perf/hover-tracking
Oct 25, 2026
Merged

jordan-cod merged 1 commit into
mainfrom
perf/hover-tracking

Conversation

@jordan-cod

Copy link
Copy Markdown
Owner

Why

Pullo listened to every mouse move on the system (NSEvent.addGlobalMonitorForEvents([.mouseMoved, ...])) to notice the pointer reaching the notch. It needed that because the panel toggled ignoresMouseEvents, and a window with that set can't see the pointer. Once the setter is called, the window also loses per-pixel click-through for good.

Boring Notch, Peninsula and DynamicNotchKit don't do this: they leave ignoresMouseEvents alone, let transparent pixels pass clicks through, and track hover only over what they draw.

What

  • The panel never sets ignoresMouseEvents. Transparent pixels pass clicks to the app behind; the drawn notch, pill, wings and panel receive them.
  • A new PointerTracker adds an .activeAlways tracking area to the panel and reports enter/move/exit. Exit is passed to NotchInteraction.mouseMoved(..., leaving: true), so leaving the drawn shape closes even when the pointer is still inside the old, padded hit rect.
  • The global monitor now listens to leftMouseDown/leftMouseUp only (close on outside click, end of a drag). A mouseMoved monitor is installed only while Display is set to follow the pointer.
  • Handing key focus back after closing (orderOut + orderFront) now waits for the close animation. Before, it ran right away and cut the animation when the panel closed by moving the pointer away (the old ignoresMouseEvents toggling happened to drop key focus first and hid this).

Measurements

CPU time used by Pullo in 15 s, measured with ps on a MacBook with 2 accounts:

Mouse still Moving the mouse away from the notch
Before (0.11.3) 30 ms 760 ms
After 30 ms 40 ms

Checked by hand: hover opens and closes (with the animation), outside click closes, keyboard focus returns to the previous app after closing, menus and status items beside the notch still work.

Screenshots

No UI change: same look, only how the pointer is detected.

Tests

  • leavingThePanelClosesItEvenNearItsEdge
  • leavingTheClosedNotchCancelsTheOpen

Pullo listened to every mouse move on the system to notice the pointer
reaching the notch, because the panel toggled ignoresMouseEvents and so
could not see the pointer itself. The panel now leaves that property
alone, so transparent pixels pass clicks through on their own, and a
tracking area on the panel reports the pointer only over what is drawn.
The global monitor only listens for clicks, plus pointer moves when the
notch follows the pointer between displays.

Handing key focus back after closing waits for the close animation, so
closing by moving the pointer away animates again.
@jordan-cod
jordan-cod merged commit 806e586 into main Oct 25, 2026
3 checks passed
@jordan-cod
jordan-cod deleted the perf/hover-tracking branch October 25, 2026 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant