Add notch avoidance with safe area insets detection#12
Open
clvrobj wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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)
get_safe_area_insetsinsrc-tauri/src/commands/get_safe_area_insets.rsthat uses macOS APIs (NSScreen) to detect notch presence and dimensions, returning aNotchInfostruct to the frontend.src-tauri/src/lib.rs) and module (src-tauri/src/commands/mod.rs). [1] [2]NSScreensupport inobjc2-app-kit.Frontend: Layout and Workspace Splitting (React/TypeScript)
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.Barcomponent (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]AeroSpacewidget (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]AeroSpace.tsx.Documentation
docs/notch-avoidance.md) explaining the notch avoidance implementation, configuration options, and future enhancements.Key Changes by Theme:
Notch Detection & Backend Integration
get_safe_area_insetsRust command to detect notch presence and dimensions using macOS APIs, returning structured info to the frontend.NSScreensupport. [1] [2] [3]Layout & Workspace Splitting
App.tsxto fetch notch info, measure time widget width, and render the bar with split workspaces and a central notch gap using the new layout logic.Bar.tsxto use CSS Grid for a three-column layout when a notch is present, reserving the correct gap and splitting content. [1] [2]AeroSpace.tsxto support automatic workspace splitting based on available width, notch size, and reserved right width, and cleaned up unused types. [1] [2] [3]Documentation
docs/notch-avoidance.mddetailing the implementation, configuration, and testing instructions for notch avoidance.Screenshot:
