Skip to content

Add notch avoidance with safe area insets detection#12

Open
clvrobj wants to merge 1 commit into
mainfrom
escape-notch
Open

Add notch avoidance with safe area insets detection#12
clvrobj wants to merge 1 commit into
mainfrom
escape-notch

Conversation

@clvrobj
Copy link
Copy Markdown
Collaborator

@clvrobj clvrobj commented Oct 20, 2025

This pull request implements automatic notch avoidance for MacBook Pro devices with a physical notch, ensuring that the top bar UI leaves a gap for the notch and splits workspace icons around it. The solution is cross-platform safe, adapting seamlessly to devices with or without a notch, and supports external monitors. The implementation involves backend detection of the notch using macOS APIs, frontend layout changes with CSS Grid, and a dynamic algorithm to split workspace icons based on available width.

Backend: Notch Detection (Rust/Tauri)

  • Added a new command get_safe_area_insets in src-tauri/src/commands/get_safe_area_insets.rs that uses macOS APIs (NSScreen) to detect notch presence and dimensions, returning a NotchInfo struct to the frontend.
  • Registered the new command in the Tauri invoke handler (src-tauri/src/lib.rs) and module (src-tauri/src/commands/mod.rs). [1] [2]
  • Updated dependencies to enable NSScreen support in objc2-app-kit.

Frontend: Layout and Workspace Splitting (React/TypeScript)

  • In src/App.tsx, fetches notch info from the backend, measures the time widget width, and conditionally renders the bar with split workspace icons and a central gap for the notch.
  • Enhanced the Bar component (src/components/Bar.tsx) to use a three-column CSS Grid layout when a notch is present, reserving the correct gap and splitting content appropriately. [1] [2]
  • Refactored the AeroSpace widget (src/widgets/AeroSpace.tsx) to support automatic splitting of workspace icons based on available width, notch size, and reserved space for the time widget. [1] [2]
  • Cleaned up unused types for clarity in AeroSpace.tsx.

Documentation

  • Added a comprehensive markdown guide (docs/notch-avoidance.md) explaining the notch avoidance implementation, configuration options, and future enhancements.

Key Changes by Theme:

Notch Detection & Backend Integration

  • Added get_safe_area_insets Rust command to detect notch presence and dimensions using macOS APIs, returning structured info to the frontend.
  • Registered the new command in the Tauri backend and updated dependencies for NSScreen support. [1] [2] [3]

Layout & Workspace Splitting

  • Modified App.tsx to fetch notch info, measure time widget width, and render the bar with split workspaces and a central notch gap using the new layout logic.
  • Refactored Bar.tsx to use CSS Grid for a three-column layout when a notch is present, reserving the correct gap and splitting content. [1] [2]
  • Enhanced AeroSpace.tsx to support automatic workspace splitting based on available width, notch size, and reserved right width, and cleaned up unused types. [1] [2] [3]

Documentation

  • Added docs/notch-avoidance.md detailing the implementation, configuration, and testing instructions for notch avoidance.

Screenshot:
SCR-20251020-tbzq

@clvrobj clvrobj requested a review from kebot October 20, 2025 14:14
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