Skip to content

fix(linux): migrate to qt tray#4907

Draft
ReenigneArcher wants to merge 1 commit intomasterfrom
fix/linux/migrate-to-qt-tray
Draft

fix(linux): migrate to qt tray#4907
ReenigneArcher wants to merge 1 commit intomasterfrom
fix/linux/migrate-to-qt-tray

Conversation

@ReenigneArcher
Copy link
Copy Markdown
Member

@ReenigneArcher ReenigneArcher commented Mar 24, 2026

Description

Migrates system tray library on Linux to use Qt version, from LizardByte/tray#104

TODO:

  • clicking pair notification does not open Sunshine config ui
  • left clicking tray icon does not bring up menu (double click works)
  • menu opens near top left of screen on Wayland, okay on Xorg
  • cannot dismiss menu by clicking outside of it on Xorg, okay on Wayland (esc key allows dismissing in Xorg)
  • KDE Plasma's settings for tray icon visibility don't allow changing the tray icon visibility
  • Using Qt6, icon is not setup properly (uses generic ... replacement)
  • Fix coredump on Arch Linux, KDE, Wayland - https://discord.com/channels/804382334370578482/1355414409417199678/1487211872104222832 (WAYLAND_DISPLAY was not defined)
  • Merge fix(linux): migrate to qt tray tray#104
  • create new release in tray repo
  • update cuda to 13.2 everywhere, to match changes in the Flatpak

Screenshot

Issues Fixed or Closed

Roadmap Issues

Type of Change

  • feat: New feature (non-breaking change which adds functionality)
  • fix: Bug fix (non-breaking change which fixes an issue)
  • docs: Documentation only changes
  • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semicolons, etc.)
  • refactor: Code change that neither fixes a bug nor adds a feature
  • perf: Code change that improves performance
  • test: Adding missing tests or correcting existing tests
  • build: Changes that affect the build system or external dependencies
  • ci: Changes to CI configuration files and scripts
  • chore: Other changes that don't modify src or test files
  • revert: Reverts a previous commit
  • BREAKING CHANGE: Introduces a breaking change (can be combined with any type above)

Checklist

  • Code follows the style guidelines of this project
  • Code has been self-reviewed
  • Code has been commented, particularly in hard-to-understand areas
  • Code docstring/documentation-blocks for new or existing methods/components have been added or updated
  • Unit tests have been added or updated for any new or modified functionality

AI Usage

  • None: No AI tools were used in creating this PR
  • Light: AI provided minor assistance (formatting, simple suggestions)
  • Moderate: AI helped with code generation or debugging specific parts
  • Heavy: AI generated most or all of the code changes

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 24, 2026

Bundle Report

Bundle size has no change ✅

@ReenigneArcher ReenigneArcher force-pushed the fix/linux/migrate-to-qt-tray branch 10 times, most recently from f4eceff to 73ec9c7 Compare March 25, 2026 03:37
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 25, 2026

Codecov Report

❌ Patch coverage is 15.38462% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 17.96%. Comparing base (ba4db46) to head (484fe46).
⚠️ Report is 69 commits behind head on master.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/system_tray.cpp 15.38% 7 Missing and 15 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4907      +/-   ##
==========================================
- Coverage   17.99%   17.96%   -0.04%     
==========================================
  Files         108      108              
  Lines       23317    23331      +14     
  Branches    10263    10275      +12     
==========================================
- Hits         4197     4191       -6     
+ Misses      17092    16726     -366     
- Partials     2028     2414     +386     
Flag Coverage Δ
Archlinux 11.66% <0.00%> (-0.02%) ⬇️
FreeBSD-14.3-aarch64 ?
FreeBSD-14.3-amd64 13.57% <0.00%> (-0.01%) ⬇️
Homebrew-ubuntu-22.04 13.99% <0.00%> (-0.02%) ⬇️
Linux-AppImage 12.20% <0.00%> (-0.02%) ⬇️
Windows-AMD64 14.91% <0.00%> (-0.01%) ⬇️
Windows-ARM64 13.24% <0.00%> (-0.01%) ⬇️
macOS-arm64 18.92% <20.00%> (-0.11%) ⬇️
macOS-x86_64 18.39% <0.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/system_tray.cpp 4.03% <15.38%> (-4.58%) ⬇️

... and 55 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ba4db46...484fe46. Read the comment docs.

@ReenigneArcher ReenigneArcher force-pushed the fix/linux/migrate-to-qt-tray branch 4 times, most recently from 8640c4a to 4ee4ef1 Compare March 25, 2026 14:07
@ReenigneArcher ReenigneArcher marked this pull request as ready for review March 25, 2026 15:28
@ReenigneArcher ReenigneArcher marked this pull request as draft March 25, 2026 17:21
@ReenigneArcher ReenigneArcher force-pushed the fix/linux/migrate-to-qt-tray branch 10 times, most recently from c741880 to afcf57b Compare March 26, 2026 14:03
@ReenigneArcher ReenigneArcher force-pushed the fix/linux/migrate-to-qt-tray branch from 8334eb9 to 484fe46 Compare April 3, 2026 17:51
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Apr 3, 2026

@Kishi85
Copy link
Copy Markdown
Contributor

Kishi85 commented May 3, 2026

I've been running this for a few days now and the only minor thing I've noticed is that left clicking (and also double left clicking) is not working for me (on CachyOS-latest, QT6.11.0, KDE 6.6.4) with the following error message in log for every click:

Warning: Qt: Failed to create grabbing popup. Ensure popup QWidgetWindow(0x560097b3db40, name="QMenuClassWindow") has a transientParent set and that parent window has received input.

Right clicking is working as expected and everything else also is working fine here so far.

@ReenigneArcher
Copy link
Copy Markdown
Member Author

@Kishi85 that looks like an issue that I was aware of and thought was fixed. Probably needs to be fixed in the tray library itself. Not sure double clicking should have any action though.

As FYI... When I migrated it I used Claude Sonnet 4.5 and it really struggled, near the end I switched to GPT 5.3-codex which was able to solve a lot more. These were both with Copilot before they crippled everything about the service. I think the new 5.5 model would have no problems with this though.

Would probably be better if someone using Linux fixes it because I don't and my testing will be limited.

@Kishi85
Copy link
Copy Markdown
Contributor

Kishi85 commented May 3, 2026

I'll have a look at it when time permits

@Kishi85
Copy link
Copy Markdown
Contributor

Kishi85 commented May 5, 2026

A thing I've noted after quickly looking at the change in LizardByte/tray is that the qt based tray icon is trying to call XDG via dbus which is bound to fail (there is a fallback in place it seems but that behaviour might be the cause of my current issues) due to kmsgrab requiring CAP_SYS_ADMIN and the dbus connection therefore not being able to access /proc/<pid-of-sunshine>/root hence the whole thing failing. It's the same issue that requires workarounds for portalgrab but those will not be usable here as they fully break kmsgrab after they are applied.

EDIT: I'll also have to check the differences between the AI approach and upstream's qt6 implementation to see if the latter does anything better and maybe port that as it is already tried and proven for a while (was committed sometime in 2023).

@Kishi85
Copy link
Copy Markdown
Contributor

Kishi85 commented May 6, 2026

I've looked at the upstream implementation for a bit today and it's a lot simpler (it pulls in 4 includes from QT, not like the 10+ the AI solution does) and also encapsulated into it's own QtTrayMenu class (positioning also works without any special position calculations).
So I'll try to re-implement the whole thing as much as possible based on the old AppIndicator variant and the upstream implemenation next (even if it's just for my personal exercise) and then look at how notifications can be added so they work in all cases. I'm also not so sure the whole async threading from AppIndicator is needed with QT as it has it's own thread loop and event system.

@ReenigneArcher
Copy link
Copy Markdown
Member Author

Positioning was required to support the screenshots for tests in the tray library as far as I remember (may not be necessary with the QT version though). The XDG wayland detection was added because the tray was not displaying in headless environments (e.g. Sunshine started from a TTY ssh session without WAYLAND_DISPLAY defined)... drdoom reported that issue on discord. We don't necessarily need to support this method though, as he normally starts it via the service in which case the env variable is properly defined... and expecting it to be ran with a service seems reasonable to me (we also expect that on Windows anyway).

Anyway, I'm sure it's not perfect by any means... but the PR in tray library is what finally ended random unit test hangs which were occurring more than 50% of the time before. The screenshots from tests and posted in the PR comments in that library now help identify any major issues before they get merged. I'm sure it can be improved upon and hopefully simplified. Would also be nice to just use QT across all platforms which in my mind would further simplify the whole implementation.

When I last worked on this "OpenSUSE Leap 15.x" didn't have qt6 either, not sure if that has changed. If it allows it to greatly simplified though, I'm fine with not supporting qt5.

@Kishi85
Copy link
Copy Markdown
Contributor

Kishi85 commented May 7, 2026

Positioning was required to support the screenshots for tests in the tray library as far as I remember (may not be necessary with the QT version though). The XDG wayland detection was added because the tray was not displaying in headless environments (e.g. Sunshine started from a TTY ssh session without WAYLAND_DISPLAY defined)... drdoom reported that issue on discord. We don't necessarily need to support this method though, as he normally starts it via the service in which case the env variable is properly defined... and expecting it to be ran with a service seems reasonable to me (we also expect that on Windows anyway).

Anyway, I'm sure it's not perfect by any means... but the PR in tray library is what finally ended random unit test hangs which were occurring more than 50% of the time before. The screenshots from tests and posted in the PR comments in that library now help identify any major issues before they get merged. I'm sure it can be improved upon and hopefully simplified. Would also be nice to just use QT across all platforms which in my mind would further simplify the whole implementation.

When I last worked on this "OpenSUSE Leap 15.x" didn't have qt6 either, not sure if that has changed. If it allows it to greatly simplified though, I'm fine with not supporting qt5.

Positioning was required to support the screenshots for tests in the tray library as far as I remember (may not be necessary with the QT version though). The XDG wayland detection was added because the tray was not displaying in headless environments (e.g. Sunshine started from a TTY ssh session without WAYLAND_DISPLAY defined)... drdoom reported that issue on discord. We don't necessarily need to support this method though, as he normally starts it via the service in which case the env variable is properly defined... and expecting it to be ran with a service seems reasonable to me (we also expect that on Windows anyway).

Anyway, I'm sure it's not perfect by any means... but the PR in tray library is what finally ended random unit test hangs which were occurring more than 50% of the time before. The screenshots from tests and posted in the PR comments in that library now help identify any major issues before they get merged. I'm sure it can be improved upon and hopefully simplified. Would also be nice to just use QT across all platforms which in my mind would further simplify the whole implementation.

When I last worked on this "OpenSUSE Leap 15.x" didn't have qt6 either, not sure if that has changed. If it allows it to greatly simplified though, I'm fine with not supporting qt5.

Thanks for the explanations and clarifications. I'll use the current state with the AI qt-tray as a starting point for the improvements then.

Keeping Qt5 support as well should be no problem as it's essentially the same code for both versions and the cmake config already takes care of selecting the available version.

First point of action will be to pull out the Qt tray essentials into a separate class (like upstream does it and I might use that as a starting point for it) which will be fully platform independent (only dependency will be Qt) so at least that can be re-used. I'll open up a PR in the tray repo once I'm done with that.

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.

Missing systray icon KDE Plasma cannot persist tray icon visibility settings due to dynamic trayid{PID} registration

2 participants