Skip to content

Implemented XApp::StatusIcon for Wayland - #836

Open
Photon89 wants to merge 1 commit into
masterfrom
xapp-tray
Open

Implemented XApp::StatusIcon for Wayland#836
Photon89 wants to merge 1 commit into
masterfrom
xapp-tray

Conversation

@Photon89

Copy link
Copy Markdown
Member

As we found out, the legacy tray icon GtkStatusIcon doesn't work on Wayland, so we only get AppIndicators there which are unable to show/hide the main window but show the context menu for both mouse buttons.

Now this PR implements XApp::StatusIcon for Wayland as optional dependency. On X11 the good working legacy GtkStatusIcon is always used as before. On Wayland we check for the optional dependency libxapp and use XApp::StatusIcon if possible, otherwise fall back to AppIndicators.

With XApp under X11 there was an issue where a single click would trigger two events. It didn't happen on Wayland (at least not on Wayland Cinnamon where I tested), but i still kept the workaround which adds a 250ms timeout after the tray icon has been clicked. During these 250ms $tray_click_locked tells us that no further clicks will be accepted.

Comment thread bin/shutter
my $prefer_legacy_on_x11 = ($x11_supported && !$ENV{WAYLAND_DISPLAY});

if ($prefer_legacy_on_x11) {
# Init legacy Gtk3 status icon for pure X11 (only once)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. if this should be done only once, then instead of such condition, simply don't call this function in a loop
  2. the loop was necessary because depending on the order of programs startup during system boot, if shutter launched before tray itself, the icon is lost. Did something change to fix it?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Sorry and thanks for pointing that out, I think, $x11_supported is completely sufficient, no need to define a new variable. I'll change that.
  2. Good to know, I didn't know it and thus didn't test. I'll look into it!

Comment thread bin/shutter
$tray_legacy = undef;
# Try to init XApp status icon first for Wayland/Cinnamon (only once)
if ($xapp_supported && !$tray_xapp) {
$tray_xapp = eval { XApp::StatusIcon->new() };

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean that if the dependency is installed, but the running DE is gnome instead of linux mint's one, the icon won't be shown?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to rework the comment. It works in Cinnamon and KDE for sure, in Gnome I couldn't make the Gnome Shell extension showing tray icons work so far...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Photon89 Photon89 Aug 23, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Damn, I just retested in KDE and the newest variant (which is what is inside the PR) doesn't show a tray icon in KDE, though it worked earlier. I need to look into this again, sorry!

Regarding the xapp issue, at least in Cinnamon the xapp tray icon was able to do the left click (show/hide main window) and the right click (show context menu) correctly, so maybe this old issue is fixed already?

Sorry, I need to read more carefully. I'm not sure whether it's a Shutter xapp issue or an issue of showing to tray icons in Gnome at all. I'll try to figure it out.

@DarthGandalf

DarthGandalf commented Aug 23, 2026

Copy link
Copy Markdown
Member

Ideally, instead of this many different libraries with fallback to each other, we should just use one. As long as it shows icon everywhere and behaves correctly

@Photon89

Copy link
Copy Markdown
Member Author

I'm trying SNI for Wayland now (and GtkStatusIcon stays for X11). Looks like SNI should be well supported by all DEs (Gnome with a Gnome Shell extension only, of course).

@DarthGandalf

Copy link
Copy Markdown
Member

SNI is not even limited to wayland: if a library does SNI fully and distinguishes left click vs right click menu, it can be used in X11 too.

I also took a look at the newly rewritten AyatanaAppIndicator-Glib and it does support both activation signals, but it doesn't work on KDE: AyatanaIndicators/libayatana-appindicator-glib#103

@DarthGandalf

Copy link
Copy Markdown
Member

One library which could work, but that's quite a dependency, is https://doc.qt.io/qt-6/qsystemtrayicon.html

@Photon89

Copy link
Copy Markdown
Member Author

I finally made some progress with SNI. It is now able to process the left click to show/hide the main window and it shows a dummy menu for the right click. So I'm optimistic that this solution will work in the end, but it needs some more time.

@DarthGandalf

Copy link
Copy Markdown
Member

Cool. On which DE?

@Photon89

Copy link
Copy Markdown
Member Author

I tested on KDE Wayland so far, but I'll also test on Gnome and Cinnamon once the functionality is implemented. I'll create a new PR and close this one when it's done!

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