Skip to content

fix(linux): migrate to qt tray#104

Open
ReenigneArcher wants to merge 8 commits intomasterfrom
fix/linux/migrate-to-qt-tray
Open

fix(linux): migrate to qt tray#104
ReenigneArcher wants to merge 8 commits intomasterfrom
fix/linux/migrate-to-qt-tray

Conversation

@ReenigneArcher
Copy link
Member

Description

Migrate to qt5/6 for Linux tray.

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

codecov bot commented Mar 24, 2026

Codecov Report

❌ Patch coverage is 55.69620% with 105 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.90%. Comparing base (98a0a39) to head (998ffb0).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/tray_linux.cpp 56.89% 64 Missing and 36 partials ⚠️
src/tray_darwin.m 0.00% 3 Missing ⚠️
src/tray_windows.c 0.00% 2 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (98a0a39) and HEAD (998ffb0). Click for more details.

HEAD has 3 uploads less than BASE
Flag BASE (98a0a39) HEAD (998ffb0)
libayatana-appindicator3-dev 1 0
Linux 2 1
libappindicator3-dev 1 0
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #104      +/-   ##
==========================================
- Coverage   73.06%   65.90%   -7.17%     
==========================================
  Files           4        4              
  Lines         427      522      +95     
  Branches       83      152      +69     
==========================================
+ Hits          312      344      +32     
- Misses         72      119      +47     
- Partials       43       59      +16     
Flag Coverage Δ
Linux 51.76% <56.89%> (-8.24%) ⬇️
Windows 70.38% <0.00%> (-1.19%) ⬇️
libappindicator3-dev ?
libayatana-appindicator3-dev ?
macOS 62.61% <0.00%> (-1.81%) ⬇️

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

Files with missing lines Coverage Δ
src/example.c 0.00% <ø> (ø)
src/tray_windows.c 79.23% <0.00%> (-1.43%) ⬇️
src/tray_darwin.m 83.75% <0.00%> (-3.27%) ⬇️
src/tray_linux.cpp 56.89% <56.89%> (ø)

@ReenigneArcher ReenigneArcher force-pushed the fix/linux/migrate-to-qt-tray branch 3 times, most recently from 5c51030 to 55d2fb6 Compare March 24, 2026 01:24
@ReenigneArcher ReenigneArcher force-pushed the fix/linux/migrate-to-qt-tray branch 3 times, most recently from a84acf6 to f357f00 Compare March 24, 2026 02:35
@ReenigneArcher ReenigneArcher force-pushed the fix/linux/migrate-to-qt-tray branch from f357f00 to c4b0b6e Compare March 24, 2026 02:49
@ReenigneArcher ReenigneArcher force-pushed the fix/linux/migrate-to-qt-tray branch 4 times, most recently from f24fd24 to 8341803 Compare March 24, 2026 03:31
Add support for simulating notification clicks and routing D-Bus notification actions to callbacks.

- Export tray_simulate_notification_click() in tray.h and provide platform implementations: no-op stubs for macOS and Windows, and a working simulator for Linux.
- Introduce TrayNotificationHandler (src/tray_notification_handler.h) to handle org.freedesktop.Notifications ActionInvoked signals and invoke the stored callback when the "default" action is triggered.
- Integrate the handler into the Linux tray: create/connect a single handler per QApplication, store callback and notification ID before calling Notify, set up a fallback that connects QSystemTrayIcon::messageClicked when D-Bus is unavailable, and clean up/disconnect the handler on app destroy.
- Also connect QSystemTrayIcon::activated to popup the context menu on left/middle clicks (fixes missing menu on left-click).
- Add unit tests verifying left-click menu popup and that notification callbacks fire when simulated (tests call tray_simulate_notification_click()).

These changes ensure notification clicks are handled consistently for D-Bus-dispatched notifications and add a test hook for exercising the click behavior.
@ReenigneArcher ReenigneArcher force-pushed the fix/linux/migrate-to-qt-tray branch from 3f1fcd4 to 8e42188 Compare March 26, 2026 00:28
Expose tray_set_log_callback in the public API and implement it on Linux to forward Qt diagnostic messages to a user-provided callback (NULL restores default behavior). Add a Qt message handler and global callback state, and route qInstallMessageHandler accordingly; provide no-op stubs on macOS and Windows since Qt logging is not used there. Improve context-menu positioning by calculating a sensible popup point from the tray icon geometry (falling back to cursor position) and use it when showing menus. Defer D-Bus ActionInvoked connection via QTimer::singleShot to avoid QSocketNotifier warnings when the tray runs in a std::thread, and add a few related include adjustments and minor activation handling cleanup.
Revise tray context-menu positioning and activation handling. calculateMenuPosition() now prefers tray icon geometry, then a non-zero cursor position, and finally a screen-geometry heuristic to infer the panel edge (fixes Wayland/XWayland cursor (0,0) issues). The tray activation handler now responds to both Trigger and Context reasons, captures the anchor point, and defers menu->popup() via QTimer::singleShot(0) to avoid platform grab conflicts on Xorg; it also avoids reopening an already visible menu.
@ReenigneArcher ReenigneArcher force-pushed the fix/linux/migrate-to-qt-tray branch from 7ebea4e to 998ffb0 Compare March 26, 2026 02:35
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
7 New issues
7 New Code Smells (required ≤ 0)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@github-actions
Copy link

Screenshot Comparison

PR #104 screenshots vs screenshots baseline.

Matrix: Linux

Image Baseline PR
tray_icon_initial.png
tray_icon_themed.png
tray_menu_checkbox_checked.png
tray_menu_checkbox_unchecked.png
tray_menu_left_click.png
tray_menu_shown.png
tray_notification_displayed.png
tray_notification_themed_icon.png

Matrix: Linux-libappindicator3-dev

Image Baseline PR
tray_icon_initial.png
tray_menu_checkbox_checked.png
tray_menu_checkbox_unchecked.png
tray_menu_shown.png
tray_notification_displayed.png

Matrix: Linux-libayatana-appindicator3-dev

Image Baseline PR
tray_icon_initial.png
tray_menu_checkbox_checked.png
tray_menu_checkbox_unchecked.png
tray_menu_shown.png
tray_notification_displayed.png

Matrix: Windows

Image Baseline PR
tray_icon_initial.png
tray_menu_checkbox_checked.png
tray_menu_checkbox_unchecked.png
tray_menu_shown.png
tray_notification_displayed.png

Matrix: macOS

Image Baseline PR
tray_icon_initial.png
tray_menu_checkbox_checked.png
tray_menu_checkbox_unchecked.png
tray_menu_shown.png
tray_notification_displayed.png

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.

1 participant