TrayIcon broken on some Linux Distros/Desktops
- Lazarus/FPC Version: Main
- Operating System: Linux
- CPU / Bitness: 32bit especially but some 64bit as well
What happens
All linux 32bit distros I tested (Debian, Mageia, OpenSuse) generate an Access Violation when using the TrayIcon. Some 64bit ones too.
Background
The LCL TrayIcon Component, under Linux and gtk2, has two modes. The attached is a simple patch that allows a programmer to choose which mode to use at run time. And a demo app showing how the patch is used.
The first mode, I call the Traditional System Tray, uses the desktop's API and the other uses one of several "appindicator" libraries (or AppInd) directly. A couple of years ago, when many Desktops stopped supporting the API, I made some changes to lcl/interfaces/gtk2/unityctrl.pas (and a gtk3 version) so that the system would try to load the AppInd and if that failed, it would try the traditional approach.
That has been working OK but recently I have noticed all 32 bit distros I tested generates an Access Violation in the libayatana library. Additionally, SUSE Tumbleweed with Xfce soes the same. Combine that with a couple I found that just don't work with the AppInd library but are OK with traditional TrayIcon.
It is, however, still the case that every Gnome based distribution will ONLY work with the AppInd model (and then, reluctantly).
KDE is OK as a fresh install does not install the AppInd library and our apps can work there using the Traditional one. But if a KDE box has multiple Desktops installed, it will have a AppInd Library and that breaks about half of them.
So, relying on a "default behaviour" model no longer works.
My patch exposes a global variable down in unityctrls.pas that can be set at run time BEFORE the trayicon is created. The programmer sets it, depending on, perhaps a config file, a command line setting or some innovative test done as the app starts up.
The changes ONLY affects gtk2 widgetset and can be ignored, default behaviour has not changed.
I have tested on 18 different distro/desktop combinations with no unexpected results. Debian, Ubuntu, Fedora, UltraMarine, Mageia and OpenSUSE
David
Steps to reproduce
The attached demo will not compile unless my patch has been applied. It shows (in the lpr file) two things that can be done using this patch.
It does have a define (in the .lpr file) you can disable and it will build and run on an unpatched system. Its now just a demo of how to use the System Tray Icon, nothing more. Try that on a 32bit system and you will see a nice AV.