Skip to content

Conversation

@stonerl
Copy link
Contributor

@stonerl stonerl commented Jan 6, 2026

This PR introduces optimizations to reduce the app's energy impact, regarding mouse event handling. This should fix issue #479 and issue #334

  • Conditional Event Monitoring:

    • The mouseMoved event tap is now only enabled when the "Show on Hover" setting is active.
    • This completely eliminates overhead during mouse movement when the feature is disabled.
  • Event Throttling:

    • When "Show on Hover" is enabled, mouseMoved events are now throttled to process only every 5th event.
    • CPU usage is reduced without affecting perceived responsiveness.
  • Optimized Hit-Testing:

    • Reordered hit-test checks to prioritize cheap geometric calculations (bounds, notch) before performing expensive Window Server queries.
    • Implemented a short-lived cache (0.5s) for the menu bar window list to minimize expensive IPC calls to the Window Server while the user is interacting with the menu bar.

- Only enable the `mouseMoved` event tap when the "Show on Hover" setting is enabled.
- This prevents unnecessary event processing on every mouse movement when the feature is disabled, significantly reducing idle CPU usage and energy impact.
- Added observers to dynamically start/stop the event tap when the setting is toggled.
- fixes jordanbaird#479

Signed-off-by: Toni Förster <[email protected]>
- Throttle `mouseMoved` event processing to handle only every 5th event, significantly reducing CPU usage during high-frequency mouse movement.
- Reorder checks in `isMouseInsideEmptyMenuBarSpace` to prioritize cheap geometric calculations over expensive Window Server calls.
- Implement a short-lived cache (0.5s) for the menu bar window list in `isMouseInsideMenuBarItem` to minimize IPC overhead with the Window Server.

Signed-off-by: Toni Förster <[email protected]>
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