View Issue Details

IDProjectCategoryView StatusLast Update
0033778LazarusLCLpublic2019-07-25 22:58
ReporterDavidAssigned ToJuha Manninen 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Platformx86OSLinuxOS Versioneg Ubuntu
Product Version1.9 (SVN)Product Build 
Target VersionFixed in Version 
Summary0033778: With recent releases of Ubuntu (in particular) the TrayIcon no longer works.
DescriptionWith recent releases of Ubuntu (in particular) the TrayIcon no longer works. Attached is a patch that fixes that problem by allowing the TrayIcon to use the (Unity inspired) libappindicator3 that is shipped with most Debian based distributions.

This patch does not solve the problem for other Gnome 3 based distributions that don't install libappindicator. End users can resort to a number of Gnome Extensions (and the patch will help) but thats not a good solution.

But at least, with this patch, TrayIcon works again for a good percentage of Linux Users. And does no harm to the rest.
Steps To ReproduceAny distro based on Ubuntu 17.10 or later. Put a TrayIcon on a form, set its icon and call show.

The small icon that should be visible top right (or, stupidly when mouse was moved to bottom left side) does not show.
Additional InformationAttached is a patch that allows the TrayIcon to use the (Unity inspired) libappindicator3 that is shipped with most Debian based distributions.

I have determined that Ubuntu based systems with libappindicator installed do work OK with the SystemTray model. However, later ones that have libappindicator3 alone do not support the System Tray model and our apps need to use the AppIndicator model instead.

Support for the Unity model has been in the LCL for some time but is limited to desktops that identify themselves as Unity. With this patch, we'll assume if only libappindicator3 is present, we should try to load it. If that loading fails, or expected functions are not found, behavior will revert to previous so we are no worse off than before.

The patch changes only unitywsctrls.pas and should be run in lcl/interfaces/gtk2.

The patch does not change how the unit works, just how it decides if it should or should not take over the TrayIcon process.

Has been tested with -
Ubuntu Mate 16.04 - does not use or need patch, OK
Ubuntu Mate 17.04 - does not use or need patch, OK
Ubuntu 17.10 - needs patch, OK
Ubuntu 18.04 - needs patch, OK.
Ubuntu 18.04 with Topicons installed - does not need, does use, OK
Xubuntu 18.04 - needs patch, OK
Debian 9.1 xfce - does not use or need patch, OK



TagsNo tags attached.
Fixed in Revisionr58021
LazTarget-
WidgetsetGTK 2
Attached Files
  • trayicon.patch (1,972 bytes)
    --- unitywsctrls.pas-ref	2018-05-23 13:51:53.546732550 +1000
    +++ unitywsctrls.pas	2018-05-23 21:17:36.609914889 +1000
    @@ -12,6 +12,13 @@
       Classes, SysUtils, dynlibs,
       Graphics, Controls, Forms, ExtCtrls, WSExtCtrls, LCLType, LazUTF8;
     
    +{ Very minor changes suggested May 2018 so that -
    +  1. Tries a later version of libappindicator library if old one not present
    +  2. Now defaults to try and use this unit if above lib is present.
    +  3. Still resorts to System Tray model if all else fails.
    +  DRB
    +}
    +
     { TUnityWSCustomTrayIcon is the class for tray icons on systems
       running the Unity desktop environment.
     
    @@ -49,7 +56,8 @@
     implementation
     
     const
    -  libappindicator = 'libappindicator.so.1';
    +  libappindicator_1 = 'libappindicator.so.1';
    +  libappindicator_3 = 'libappindicator3.so.1';
     
     {const
       APP_INDICATOR_SIGNAL_NEW_ICON = 'new-icon';
    @@ -258,16 +266,20 @@
       if Loaded then
         Exit(Initialized);
       Loaded:= True;
    -  if GetEnvironmentVariableUTF8('XDG_CURRENT_DESKTOP') <> 'Unity' then
    +{  if GetEnvironmentVariableUTF8('XDG_CURRENT_DESKTOP') <> 'Unity' then
       begin
         Initialized := False;
         Exit;
    -  end;
    +  end;        }
       if Initialized then
         Exit(True);
    -  Module := LoadLibrary(libappindicator);
    -  if Module = 0 then
    -    Exit;
    +  // we'll reject if _3 not present or if both present, accept if ONLY _3 is present.
    +  Module := LoadLibrary(libappindicator_1);
    +  if Module <> 0 then       // if _1 present, will probably work with old SystemTray
    +     exit;                  // and may not work with this Unit. So let SystemTray do it.
    +  Module := LoadLibrary(libappindicator_3);        // thats the one we want here.
    +  if Module = 0 then                               // no libappindicator ....
    +     Exit;                                         // hope SystemTray can help you ....
       Result :=
         TryLoad('app_indicator_get_type', @app_indicator_get_type) and
         TryLoad('app_indicator_new', @app_indicator_new) and
    
    trayicon.patch (1,972 bytes)

Relationships

related to 0035723 resolvedJuha Manninen System Tray Icon must use libappindicator3 

Activities

David

2018-05-23 14:14

reporter  

trayicon.patch (1,972 bytes)
--- unitywsctrls.pas-ref	2018-05-23 13:51:53.546732550 +1000
+++ unitywsctrls.pas	2018-05-23 21:17:36.609914889 +1000
@@ -12,6 +12,13 @@
   Classes, SysUtils, dynlibs,
   Graphics, Controls, Forms, ExtCtrls, WSExtCtrls, LCLType, LazUTF8;
 
+{ Very minor changes suggested May 2018 so that -
+  1. Tries a later version of libappindicator library if old one not present
+  2. Now defaults to try and use this unit if above lib is present.
+  3. Still resorts to System Tray model if all else fails.
+  DRB
+}
+
 { TUnityWSCustomTrayIcon is the class for tray icons on systems
   running the Unity desktop environment.
 
@@ -49,7 +56,8 @@
 implementation
 
 const
-  libappindicator = 'libappindicator.so.1';
+  libappindicator_1 = 'libappindicator.so.1';
+  libappindicator_3 = 'libappindicator3.so.1';
 
 {const
   APP_INDICATOR_SIGNAL_NEW_ICON = 'new-icon';
@@ -258,16 +266,20 @@
   if Loaded then
     Exit(Initialized);
   Loaded:= True;
-  if GetEnvironmentVariableUTF8('XDG_CURRENT_DESKTOP') <> 'Unity' then
+{  if GetEnvironmentVariableUTF8('XDG_CURRENT_DESKTOP') <> 'Unity' then
   begin
     Initialized := False;
     Exit;
-  end;
+  end;        }
   if Initialized then
     Exit(True);
-  Module := LoadLibrary(libappindicator);
-  if Module = 0 then
-    Exit;
+  // we'll reject if _3 not present or if both present, accept if ONLY _3 is present.
+  Module := LoadLibrary(libappindicator_1);
+  if Module <> 0 then       // if _1 present, will probably work with old SystemTray
+     exit;                  // and may not work with this Unit. So let SystemTray do it.
+  Module := LoadLibrary(libappindicator_3);        // thats the one we want here.
+  if Module = 0 then                               // no libappindicator ....
+     Exit;                                         // hope SystemTray can help you ....
   Result :=
     TryLoad('app_indicator_get_type', @app_indicator_get_type) and
     TryLoad('app_indicator_new', @app_indicator_new) and
trayicon.patch (1,972 bytes)

Juha Manninen

2018-05-24 11:04

developer   ~0108510

Applied, thanks.

A minor thing: In future please create a patch from the top level directory. It is easier to apply then.

David

2018-05-25 01:16

reporter   ~0108520

Thanks Juha.
Next time I'll start the patch in 'lcl' ?

David

2018-08-17 06:08

reporter   ~0110073

Sorry, just starting to understand I need to close tickets like this ...

Thanks

Issue History

Date Modified Username Field Change
2018-05-23 14:14 David New Issue
2018-05-23 14:14 David File Added: trayicon.patch
2018-05-24 10:56 Juha Manninen Assigned To => Juha Manninen
2018-05-24 10:56 Juha Manninen Status new => assigned
2018-05-24 11:04 Juha Manninen Fixed in Revision => r58021
2018-05-24 11:04 Juha Manninen LazTarget => -
2018-05-24 11:04 Juha Manninen Note Added: 0108510
2018-05-24 11:04 Juha Manninen Status assigned => resolved
2018-05-24 11:04 Juha Manninen Resolution open => fixed
2018-05-25 01:16 David Note Added: 0108520
2018-08-17 06:08 David Note Added: 0110073
2018-08-17 06:08 David Status resolved => closed
2019-07-25 22:58 Juha Manninen Relationship added related to 0035723