Skip to content

fix: rewrite popup positioning for consistent Y level across all widgets#100

Open
bottlebrushes wants to merge 16 commits intomocki-toki:mainfrom
bottlebrushes:bettercoderthanyou/fix-popup-position
Open

fix: rewrite popup positioning for consistent Y level across all widgets#100
bottlebrushes wants to merge 16 commits intomocki-toki:mainfrom
bottlebrushes:bettercoderthanyou/fix-popup-position

Conversation

@bottlebrushes
Copy link
Copy Markdown

Summary

  • Changed from center-based positioning (.position()) to top-aligned positioning (.topLeading alignment with offset)
  • All popups now appear at exactly the same Y level regardless of content height
  • Popup top edge aligns precisely with the bottom of the Barik menu bar using foregroundHeight directly
  • X positioning centers popup under widget with edge constraints

Problem

Previously, popups for different widgets (Battery, Wi-Fi, Weather, etc.) appeared at different vertical positions because .position(x:) was positioning the center of each view. Since different popups have different heights, their centers were at different Y positions relative to their tops.

Solution

  • Removed the .position() modifier that was centering views
  • Using .topLeading alignment so all popups start from the same origin
  • Calculate X offset to center under widget while respecting screen edge margins
  • Y position uses foregroundHeight directly - the exact height of the Barik menu bar

Test plan

  • Click on Battery widget - popup appears just below menu bar
  • Click on Wi-Fi widget - popup appears at same Y level as Battery
  • Click on Weather widget - popup appears at same Y level
  • Test with widgets near screen edges - popup stays within bounds

🤖 Generated with Claude Code

bottlebrushes and others added 16 commits January 3, 2026 14:03
…aying

Replace aggressive 0.3s AppleScript polling with DistributedNotificationCenter
observers for instant media updates.

Changes:
- Listen to Spotify (`com.spotify.client.PlaybackStateChanged`) and
  Apple Music (`com.apple.Music.playerInfo`) notifications
- Only poll every 1s for position updates (progress bar) when playing
- Fetch track info on-demand when notifications fire
- Add initial fetch on startup to populate current state

This significantly reduces CPU usage and provides instant UI updates
when track changes or playback state changes.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add WeatherWidget displaying current temperature and weather icon
- Use Open-Meteo free API (no API key required)
- Dynamic SF Symbols based on weather conditions (sun, clouds, rain, snow, etc.)
- Location-based weather with CoreLocation
- Click to open macOS Weather dropdown
- Add SystemUIHelper for triggering system UI elements
- Add required entitlements for location and network access

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replace polling-based space monitoring with event-driven updates:
- Add SpaceEvent enum and EventBasedSpacesProvider protocol
- Implement Unix socket listener in YabaiProvider
- Update SpacesViewModel to handle space events reactively

Yabai signals now send events to /tmp/barik-yabai.sock for instant updates.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add WeatherPopup matching Barik's dark theme style
- Show location name, current temp, condition, high/low
- Display hourly forecast with icons and precipitation %
- Add "Open Weather" button to launch macOS Weather app
- Extend WeatherManager with hourly data and location name via geocoding

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Run initial space fetch asynchronously in startObserving()
- Run refreshSpaces() on background queue
- Dispatch results back to main thread for UI updates
- Fixes SwiftUI AttributeGraph crash from blocking main thread

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add `click-action` config option to TimeWidget
- Supports "calendar" (default) or "notification-center"
- When set to "notification-center", clicking time opens macOS Notification Center

Usage in config.toml:
```toml
[widgets.default.time]
click-action = "notification-center"
```

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add `click-action` config option to TimeWidget ("calendar" or "notification-center")
- Request Accessibility permission before opening Notification Center
- System prompts user to grant permission if not already allowed

Usage:
```toml
[widgets.default.time]
click-action = "notification-center"
```

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Changed from SOCK_DGRAM to SOCK_STREAM for nc -U compatibility
- Added listen() and accept() for stream socket handling
- Fixes event-based space subscription not receiving messages

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add WiFi toggle switch at the top
- Show connected network in "Known Network" section
- Add expandable "Other Networks" section with available networks
- Add network scanning functionality
- Add "Wi-Fi Settings..." button to open System Preferences
- Fixed width to 280px for consistent appearance

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replace fragile AppleScript approach with CGEvent keyboard simulation.
Simulates Ctrl+Option+N keypress which user has mapped to Notification Center.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Remove unnecessary Y offset that pushed popups down by half their height.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Use widgetRect.maxY to position popups just below the clicked widget
instead of using a fixed foreground height. This ensures popups appear
at the correct vertical position regardless of widget location.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Adjusted popup offset calculation and added anchor: .top to scaleEffect
so popups animate and position correctly below the Barik menu bar.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Battery: use IOPSNotificationCreateRunLoopSource instead of 1s timer
- Calendar: use EKEventStoreChangedNotification instead of 5s timer
- WiFi: use CWEventDelegate for SSID/link changes, reduce RSSI polling to 30s
- Spaces: use NSWorkspace notifications instead of 100ms fallback timer
- MenuBarPopup: use DispatchWorkItem + asyncAfter instead of Timer

This significantly reduces CPU usage and improves power efficiency by
responding to system events rather than continuously polling.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…ve-polling

feat: replace polling with event-driven notifications
- Changed from center-based positioning (.position()) to top-aligned
  positioning (.topLeading alignment with offset)
- All popups now appear at exactly the same Y level regardless of content height
- Popup top edge aligns precisely with the bottom of the Barik menu bar
  using foregroundHeight directly
- X positioning centers popup under widget with edge constraints

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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