Skip to content

Linux X11: 从托盘恢复窗口导致窗口逐次膨胀 (+52×99/次),v3.18–v3.20.3 均未修复 #7480

Done

Description

@zhuzhumiemie-cell

问题描述

Linux (GNOME, X11) 下,开启"最小化到托盘"后,每次从系统托盘恢复主窗口,窗口都会永久变大一次。重复几次后窗口会大到超出屏幕。重启应用可恢复初始尺寸 1000×650。

环境

  • OS: Ubuntu (GNOME), X11
  • 显示器: 2560×1440 scale=1 + 1920×1080 scale=1,已开启 fractional scaling
  • cc-switch: v3.18.0(已确认 v3.20.3 同样存在)
  • GDK_SCALE / GDK_DPI_SCALE 未设置

复现步骤

  1. 设置里开启"最小化到托盘"(minimizeToTrayOnClose)
  2. 把主窗口最小化/关闭到系统托盘
  3. 从托盘点击恢复主窗口
  4. 重复步骤 2–3 数次

实际现象

窗口尺寸逐次增大,日志如下:

[INFO ][cc_switch_lib::linux_fix] Linux nudge 尺寸 drift: expected=1052x749, got=1104x848,已补偿
[WARN ][cc_switch_lib::linux_fix] Linux nudge 尺寸 drift 补偿后仍不一致: expected=1052x749, got=1104x848
[INFO ][cc_switch_lib::linux_fix] Linux nudge 尺寸 drift: expected=1104x848, got=1156x947,已补偿
[WARN ][cc_switch_lib::linux_fix] Linux nudge 尺寸 drift 补偿后仍不一致: expected=1104x848, got=1156x947

尺寸变化:1052×749 → 1104×848 → 1156×947 → … 每次固定增加 +52 宽 / +99 高。

根因分析

  • 窗口配置为内容区 1000×650(tauri.conf.json),带 Overlay 标题栏。
  • 在 tao/GTK 下 inner_size() 返回外层尺寸(含标题栏/边框/阴影,约 +52 宽、+99 高),而 set_size() 设置的是内容区尺寸。
  • linux_fix.rs 每次托盘恢复时读取 inner_size() 再原样 set_size() 写回,等于每次把窗口自增 52×99。
  • 算术验证:1052−52=1000、749−99=650;1104−52=1052、848−99=749 —— 与内容区/外层尺寸差完全吻合。

额外说明

  • 已核对 v3.20.3 的 src-tauri/src/linux_fix.rs 与 v3.18.0 完全相同,升级无法修复。
  • 本机无窗口状态持久化文件,重启后恢复 1000×650,是纯运行时 bug。

建议修复

在 Linux 上去掉 nudge 中对尺寸的 set_size() 回写(仅保留 focus / surface 重激活),或改为按"内容区"语义换算后再写回。

相关

Activity

  1. github-actions commented on Nov 22, 2026

    @github-actions

    此 issue 已超过 60 天没有活动,已被标记为 stale。
    如果此问题仍然存在,请回复以保持 issue 打开状态,否则将在 14 天后自动关闭。

    This issue has been automatically marked as stale because it has not had activity for 60 days.
    Please reply to keep it open, otherwise it will be automatically closed in 14 days.

  2. added
    stale
    on Nov 22, 2026
  3. farion1231 commented on Dec 4, 2026

    @farion1231
    Owner

    修复已随 v4.0.48 发布(#10241):Linux 主窗口的尺寸和最大化状态改由 GTK 原生接口保存和恢复,不再用 ±1px 的伪调整大小,从托盘恢复时窗口不会再变大。

    如果问题仍然存在,请在这里回复或新开一个 issue。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stale

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions