Forum > GTK
More TrayIcon Issues
dbannon:
Hi Folks, more TrayIcon issues I am afraid.
Several years ago I patched the GTK2 (and GTK3) code so that the TrayIcon would use libappindicator and then, later, libayatana as workaround as Gnome waged war on the System Tray. It was not too bad for a while but I just did a survey of the various distros I test against and it needs more work. Ideally, before release of Lazarus 3.0 ?
I find that some Desktop's tried to address the problem but its still broken in various ways. All the Gnome Disrributions must still go direct to libayatana, many Distro/Desktop combinations can work with either and some, KDE and (strangely) 32bit Debian won't work with Ayanta but are OK with the old, traditional TrayIcon ! And it keeps changing.
I suggest a small change to gtk2/unitywsctrls.pas to export out a Global var that allows the application programmer to determine which Tray Icon model to use. If the programmer does not want to, it has a usable default.
Attached is a patch against lazarus main that adds that Global var, adds a type that the var is and alters the way RegisterCustomTrayIcon() in gtk2wsfactory decides which sort of TrayIcon to use.
Also attached is a small lazarus project that demonstrates how to use this Global var and how to protect from the Access Violation that results when its wrong. It has a bit of code in the lpr file that looks at command line switches and environment vars to set the vars. A more in depth test would easily slot in there. The patch affects ONLY gtk2 and the default behavior remains the same as it was.
If no problems identified, I will create a bug report.
David
Edit : sorry, apparently the patch file was not attached the first time. I'll try again.
Handoko:
I tried your code but I got compile time error, see the attached screenshot. I am using Ubuntu Mate 23.10 Lazarus 2.2.6 GTK2.
dbannon:
--- Quote from: Handoko on November 26, 2023, 11:03:50 am ---I tried your code but I got compile time error, see the attached screenshot. I am using Ubuntu Mate 23.10 Lazarus 2.2.6 GTK2.
--- End quote ---
Did you apply the patch to your Lazarus source ? That variable is a new addition in gtk2/unityctrls.pas.
Davo
Handoko:
I am sorry, I didn't read the comment in source code. It works now.
But for your information, my Lazarus-created program still works correctly even without the patch. From the screenshot below, yours is the green icon with a pencil. My program (SideNote) is the blue circle with a cheetah paw. I just formatted and reinstall my OS and Lazarus some weeks ago, I had no problem recompiling and running my SideNote.
I don't know why I didn't have any TrayIcon-GTK issue, perhaps because I am using Ubuntu Mate.
dbannon:
Ah, Handoko, the truth is that Mate is one of the better ones in this space, for real trouble, try Gnome (can be made to work is you install gnome-shell-extension-appindicator and enable gnome-extensions). I too use Mate (I think I might have suggested it to you ?) and a quite old Ubuntu, it works in both modes.
Here is the list I tested today, the really surprising ones is the difference between 32bit and 64bit Debian Mate, with 32bit, must use old traditional System Tray, with 64bit either will work.
Its the erratic nature of these things, changes with each release, that convinced me that allowing the programmer to manage the situation was the only way forward.
Bad with App Indicator only ie OK with Traditional
[x] 32bit Bookworm and Bullseye - both fail in AppIndicator mode, either 1 or 3
[x] Bookworm KDE - has no AppIndicator by default, AV
[x] Trixie KDE -has no AppIndicator by default, AV
Bad with Traditional SysTray only ie OK with App Indicator
[x] Ubuntu 2304 Gnome (in Traditional, menu pops up in random places)
[x] Ubuntu 2310 Gnome, as above
Good with either works with both App Indicator and Traditional
[x] Ubuntu 2004 Mate
[x] Bookworm Cinnamon
[x] Bookworm LXDE
[x] Bookworm Mate
[x] Bullseye Mate
[x] Trixie Mate
[x] Mint 21.1 Cinnamon
[x] Ubuntu2304 XFCe
[x] Ubuntu 2204 Mate
Bad with Either #@1 Gnome
[x] Bookworm Gnome (but can be made work)
[x] OpenBox, no (default) System Tray.
[x] Fedora Gnome
(Gnome generally fixable for App Indicator by installing gnome-shell-extension-appindicator and enabling it in in gnome-extension-app but traditional sys tray is still non-functional as menu appears in random locations.)
By Traditional, I mean hitting the DE's api, by using an App Indicator, we bypass the DE, directly open the library and use it's calls to do what we must. Most of the "works with either" ones also rely on LibAyatana and connect their API to that Library.
KDE implements its own solution.
Davo
Navigation
[0] Message Index
[#] Next page