Skip to content

优化用于覆盖红绿灯按钮的Topit按钮在macOS26下的位置#41

Open
arnozxchen wants to merge 5 commits into
lihaoyun6:mainfrom
arnozxchen:main
Open

优化用于覆盖红绿灯按钮的Topit按钮在macOS26下的位置#41
arnozxchen wants to merge 5 commits into
lihaoyun6:mainfrom
arnozxchen:main

Conversation

@arnozxchen

Copy link
Copy Markdown
  • 新增了一个方法用于实时获取目标窗口的红绿灯按钮位置
  • 对于红绿灯位置可用的窗口,用公式 $x = axPosition.x - windowFrame.origin.x + axSize.width / 2$$y = axPosition.y - windowFrame.origin.y + axSize.height/2$计算按钮中心位置;对于红绿灯位置不可用的窗口(如基于Electron应用:Feishu...),使用假设偏移来规整。

… detection

- Add getCloseButtonLocalCenter() to read target window's close button
  position via AXUIElement, converting to overlay-local coordinates
- Apply calculated offset to control button VStack in all three
  overlay views (OverlayView, OverlayView12, OverlayViewOpacity)
- Graceful fallback: when AX close button is unavailable (Electron/
  Java/custom windows), offset remains .zero preserving existing behavior
- Fix parenthesis bug in getCloseButtonLocalCenter: axSize.height/2 was
  outside the parentheses, causing Y offset to be off by full button height
- Fix orphaned else block in OverlayViewOpacity.swift
- Add print diagnostics in all overlay views to log AX detection results
- Fix Y formula: axPosition.y - windowFrame.origin.y + axSize.height/2
  (AX close button position is screen top-left origin, subtract window origin)
- Add estimated position fallback (20,20) for Electron apps where
  kAXCloseButtonAttribute returns .noValue (e.g. Feishu)
- Fix escaped print statements (\\( → \()
- Clean up duplicate fallback lines in OverlayView files
@arnozxchen
arnozxchen marked this pull request as draft July 1, 2026 08:47
- Add .allowsHitTesting(opacity != 0) to capture group so transparent
  overlay lets mouse events reach the underlying window while keeping
  control buttons clickable
- Add mouse-leave detection in Timer as fallback for restoring overlay
  when onHover exit may be missed
- Fix stopMouseMonitor() to synchronously close all auxiliary windows
  (screen covers + mask) by title filter, preventing orphaned mask
  windows from blocking the overlay after Cmd+P window selection
- Reset mask and targetWindowID in stopMouseMonitor() to avoid stale state
@arnozxchen
arnozxchen marked this pull request as ready for review July 1, 2026 10:01
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