fix(desktop): 对齐 tab bar 左上角 Home 按钮与 macOS 红绿灯 - #793
Open
Gyarados4157 wants to merge 1 commit into
Open
Gyarados4157 wants to merge 1 commit into
Gyarados4157 wants to merge 1 commit into
Conversation
…ghts `trafficLightPosition.y` does not set the buttons' top offset: tao's `inset_traffic_lights` only rewrites the titlebar container's height (button height + y) and each button's origin.x, and AppKit keeps the buttons at a fixed inset from the container's bottom edge. The effective top is therefore `y - defaultInset`: with y = 10 the lights land at y = 1 (centre 8) on macOS 27.0 while the 32pt tab bar centres the home button at y = 16, so the button sits 8pt below the window controls and looks misplaced. y = 18 restores the intended centre of 16pt (= where macOS puts them when no position is set). The 68pt leading inset was derived from the old window-control geometry (12 + 3*12 + 2*8 = 64, +4pt gap). The controls are now 14pt wide on 23pt centres, so the group reaches 72pt and the home button's hover area overlapped the green button. Reserve the wider geometry plus an 8pt gap.
This branch has not been deployed
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.
Fixes #792
问题
macOS 桌面端左侧栏上方的 tab bar 左上角,Home 按钮和系统红绿灯既垂直错位 8pt,又水平贴在一起(Home 按钮的 hover 背景伸进红绿灯 4pt)。本机 macOS 27.0 (26A428) + ReadAny 1.3.6 实测:
issue 里有标注截图和完整的推导过程。
改动
packages/app/src-tauri/tauri.conf.json:trafficLightPosition.y由10改为18packages/app/src/components/layout/TabBar.tsx:paddingLeft的68抽成常量MAC_TRAFFIC_LIGHTS_INSET = 80,推导写进注释为什么是这两个值
y = 18:
trafficLightPosition.y并不是"按钮顶部 = y"。tao 的inset_traffic_lights把 titlebar 容器高度改成按钮高 + y并只改按钮的origin.x,AppKit 让按钮与容器底边保持固定内边距,所以实际顶部 =y − 默认内边距。用相同 styleMask(fullSizeContentView + titlebarAppearsTransparent + 隐藏 title)的最小 AppKit 探针套用该算法,在本机实测:trafficLightPosition.y18让红绿灯回到系统默认位置,也正好是 32pt tab bar(h-8)的中心。按旧版 macOS 的标准几何(28pt 标题栏、12pt 按钮、默认内边距 8pt)推算同样得到中心 16pt,所以旧系统不会回归。80:红绿灯组现在是
12 + 3×14 + 2×9 = 72pt宽,旧的 68 是按12 + 3×12 + 2×8 = 64pt加 4pt 留白算的。取72 + 8留白;旧系统上多出的 12pt 空白无害。验证
standardWindowButton(...).frame,得上面的表格(y=10 → 顶部 1pt / 中心 8pt;y=18 → 顶部 9pt / 中心 16pt)x: 12(与红绿灯宽度无关),未做其他 macOS 标题栏相关的假设改动npx @biomejs/biome@1.9.4 check:改动没有新增告警(该文件在 main 上已有 format / organizeImports / useKeyWithClickEvents 三条既存告警,为保持 diff 最小未一并处理)说明
standardWindowButton(...).frame把真实几何传给前端,避免以后系统改版再次错位;这个 PR 先做最小修复。