Skip to content

Fix tray popup placement / 修复 Windows 托盘弹窗越界 - #18

Merged
VallierDev merged 1 commit into
VallierDev:mainfrom
eerraa:fix/tray-work-area
Sep 19, 2026
Merged

VallierDev merged 1 commit into
VallierDev:mainfrom
eerraa:fix/tray-work-area

Conversation

@eerraa

@eerraa eerraa commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

English · 简体中文

English

Keep the existing tray panel visible and reachable when the tray is at the bottom or edge of a Windows monitor. This is a placement fix, not a tray redesign.

Problem and cause

With a bottom Windows taskbar, clicking the tray icon can show only the top of the popup: the existing code places its top at tray_y + 4, so most of the window extends below the screen. That assumes a top menu bar. Horizontally, clamping only to x >= 0 also ignores the right edge and monitors whose origin is negative.

Focused changes

  • Use the monitor containing the click, its physical work area, and its scale factor. Prefer below the anchor when there is room; otherwise try above, then constrain the rectangle to the work area. Do not show a newly positioned popup when monitor/position APIs report failure.
  • Keep the normal 380×410 logical size where space permits; on smaller work areas, allow vertical scrolling so the action buttons remain reachable. The same placement rule still supports a top menu bar; it does not assume every tray is at the bottom.
  • Address the popup's existing permission mismatch: grant only event listen/unlisten rights to tray-popup. Remove the redundant JS hide() call because the existing native “show main window” command already hides it. No wildcard-window or filesystem permission is added.

The diff is 7 files, one commit. Account switching and quota calculations are unchanged. It does not include the separate UNKNOWN-quota/error-display changes from the earlier combined patch, clipboard work, other desktop actions, or Korean localization.

Verification and remaining manual check

Local Windows validation at head c1368f1 passed:

npm run build
node --test scripts/tray-popup.test.mjs
cargo test --locked --manifest-path src-tauri/Cargo.toml --lib tray_position::tests

That is 2 capability/scroll contract tests and 5 geometry tests covering taskbar edges, negative monitor coordinates, multiple scale factors, small work areas, and invalid metadata.

These tests verify layout rules and permissions in source; they do not prove every native multi-monitor/WebView2 interaction. The remaining desktop check is to click the tray at a bottom/right edge and on a secondary monitor with a different scale, then confirm that the panel and its actions stay accessible.

Independent review: one commit directly on upstream main (f64a44a), with no dependency on the other split PRs.


简体中文

修复 Windows 托盘位于屏幕底部或边缘时弹窗显示不全的问题,保留现有面板,不重新设计托盘 UI。

问题与原因

Windows 使用底部任务栏时,点击托盘图标可能只看到弹窗顶部。现有代码把窗口顶部放在 tray_y + 4,相当于按“顶部菜单栏下方弹出”的方式定位,窗口的大部分因此落到屏幕外。水平方向也只限制 x >= 0,没有考虑右边界和坐标原点为负数的副显示器。

本次修改范围

  • 使用点击位置所在显示器的物理工作区和缩放比例。下方空间足够时优先向下,否则尝试向上,再将窗口限制在工作区内。显示器查询或位置设置报错时,不继续显示定位失败的弹窗。
  • 空间足够时保持原有 380×410 逻辑尺寸;工作区较小时允许内部纵向滚动,让底部按钮仍可访问。同一定位规则也兼容顶部菜单栏,并非写死“Windows 一律向上弹”。
  • 修复弹窗已有的权限不匹配:只为 tray-popup 增加事件订阅/取消订阅权限。现有“打开主窗口”原生命令已经会隐藏弹窗,因此移除重复的 JS hide() 调用,不为此扩大窗口或文件系统权限。

**7 个文件、1 个提交。**不修改账号切换或额度计算;不包含此前综合补丁中的 UNKNOWN 状态、错误展示调整,也不混入剪贴板、其他桌面操作或韩语本地化。

验证依据与待实机确认项

在 Windows 上针对当前提交 c1368f1 完成本地验证:

npm run build
node --test scripts/tray-popup.test.mjs
cargo test --locked --manifest-path src-tauri/Cargo.toml --lib tray_position::tests

2 个权限/滚动约束测试、5 个位置计算测试通过,覆盖任务栏边缘、负坐标显示器、多种缩放比例、小工作区和无效参数。

这些测试验证计算规则及源码中的权限约束,不代表已覆盖所有原生多显示器/WebView2 交互。仍需实机确认的重点是:在底部或右侧边缘点击托盘,以及在不同缩放比例的副显示器上点击,检查整个面板和底部按钮是否可访问。

**可独立审阅和合并:**直接基于 upstream main(f64a44a)的单个提交,不依赖其余拆分 PR。

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.

2 participants