Skip to content

fix: Linux 支持托盘图标左键单击 - #388

Closed
VillagerTom wants to merge 1 commit into
appshubcc:mainfrom
VillagerTom:fix/linux_tray_click
Closed

fix: Linux 支持托盘图标左键单击#388
VillagerTom wants to merge 1 commit into
appshubcc:mainfrom
VillagerTom:fix/linux_tray_click

Conversation

@VillagerTom

@VillagerTom VillagerTom commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

问题

Linux 上左键单击托盘图标无响应,右键菜单正常。

根因

Dart 侧已有左键处理( lib/manager/tray_manager.dart:42 onTrayIconMouseDown()window?.show()),但 vendored 的 tray_manager Linux 插件从未监听 ayatana-appindicator 的 activate(SNI Activate 主键)信号,因此该事件在 Linux 上从不触发。

改动

plugins/tray_manager/linux/tray_manager_plugin.cc

  • HAVE_AYATANA 下创建 indicator 后连接 activate 信号(tray_manager_plugin.cc:254-258),回调 _on_indicator_activate 向 Dart 发送 onTrayIconMouseDown(tray_manager_plugin.cc:225-232)。
  • g_signal_lookup 探测信号存在性,避免低版本 libayatana 连接非法信号。
  • 已用系统头文件做过语法编译验证(g++ -fsyntax-only 通过)。

依赖与生效条件:

  • activate 信号始于 ayatana-appindicator 0.6.0;0.5.x 及老版 libappindicator 无此信号,该分支被编译掉,左键回退为原行为。
  • 即使有 0.6.0+,还需宿主 DE 发送 Activate(如 KDE/GNOME/Xfce);部分宿主仍只会弹菜单。
  • 已验证在 Arch Linux Niri + DMS shell 工作正常

By DeepSeek V4 Flash Free

@VillagerTom

Copy link
Copy Markdown
Contributor Author

Feature request: 二次点击关闭主窗口 @appshubcc

@appshubcc

Copy link
Copy Markdown
Owner

@VillagerTom 开启状态托盘图标自动变更你要再试一下吗,我想三端统一

@VillagerTom

Copy link
Copy Markdown
Contributor Author

@VillagerTom 开启状态托盘图标自动变更你要再试一下吗,我想三端统一

我之前在 #255 实现了一个版本,但导致了 #274 问题回归,遂搁置

@appshubcc

Copy link
Copy Markdown
Owner

@VillagerTom 那算了,估计做出来也分裂,到时候能用又不能用的,麻烦

@appshubcc

Copy link
Copy Markdown
Owner

@VillagerTom 和托盘Commit合到一起了,试下看看

https://github.com/appshubcc/Bettbox/actions/runs/32113522999

@VillagerTom

Copy link
Copy Markdown
Contributor Author

@VillagerTom 和托盘Commit合到一起了,试下看看

https://github.com/appshubcc/Bettbox/actions/runs/32113522999

抱歉,我之前打包时拷错文件了。测试有效。

@VillagerTom

Copy link
Copy Markdown
Contributor Author

@VillagerTom 和托盘Commit合到一起了,试下看看

https://github.com/appshubcc/Bettbox/actions/runs/32113522999

哦,左键设置为“打开菜单”时无响应。

@VillagerTom

VillagerTom commented Aug 18, 2026

Copy link
Copy Markdown
Contributor Author

@VillagerTom 和托盘Commit合到一起了,试下看看

https://github.com/appshubcc/Bettbox/actions/runs/32113522999

又发现一个 bug:

  • 左键托盘打开窗口后,顶栏窗口按钮会一直显示,直到鼠标移动到 Bettbox 窗口内任意位置
  • 但是如果鼠标移动到顶栏,按钮也会消失,只有离开顶栏再回来才会重新显示

也就是说这里窗口按钮隐藏的逻辑可能写反了

@VillagerTom

Copy link
Copy Markdown
Contributor Author

Closed in favour of 69d5f17.

@VillagerTom

Copy link
Copy Markdown
Contributor Author

@VillagerTom 和托盘Commit合到一起了,试下看看
https://github.com/appshubcc/Bettbox/actions/runs/32113522999

哦,左键设置为“打开菜单”时无响应。

Linux 端已不再提供托盘点击设置,此 bug 已被绕过。

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