Conversation
| 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) |
There was a problem hiding this comment.
- if this should be done only once, then instead of such condition, simply don't call this function in a loop
- 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?
There was a problem hiding this comment.
- Sorry and thanks for pointing that out, I think,
$x11_supportedis completely sufficient, no need to define a new variable. I'll change that. - Good to know, I didn't know it and thus didn't test. I'll look into it!
| $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() }; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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.
|
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 |
|
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). |
|
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 |
|
One library which could work, but that's quite a dependency, is https://doc.qt.io/qt-6/qsystemtrayicon.html |
|
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. |
|
Cool. On which DE? |
|
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! |
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::StatusIconfor Wayland as optional dependency. On X11 the good working legacy GtkStatusIcon is always used as before. On Wayland we check for the optional dependencylibxappand useXApp::StatusIconif 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_lockedtells us that no further clicks will be accepted.