View Issue Details

IDProjectCategoryView StatusLast Update
0035723LazarusLCLpublic2019-08-23 19:39
ReporterDavidAssigned ToJuha Manninen 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version2.0.3 (SVN)Product Build 
Target VersionFixed in Version 
Summary0035723: System Tray Icon must use libappindicator3
DescriptionA year or so ago I submitted (and had accepted) a patch that allowed a Linux box to use the Unity inspired libappindicator3 if the more generic libappindicator1 is not present. Canonical have been shipping (and using) libappindicator3 on its newer Ubuntu (and friends) systems even after dropping Unity. New Ubuntus such as 19.04 do not ship libappindicator1 anymore (and cannot use it) so that patch is fine. However, older systems that have been updated to (eg) 19.04 may have an old version of libappindicator1 lying around so preferring it is a bad thing now.

So, the attached patch now chooses to use libappindicator3 even if libappindicator1 is present.

This has been tested successfully on a number of linux platforms - Unbuntu 16.04 and 18.04, 19.04 Debian 9.8 and 9.9, Mageia 6 ICEwm (but not Plasma), Fedora, openSUSE.

In some of the above cases, extra steps are required, https://wiki.freepascal.org/How_to_use_a_TrayIcon#Problems_with_newer_Gnome_based_Linux
Steps To ReproduceOn, for example a Ubuntu 19.04 install that has been upgraded from an older version of Ubuntu, run an app that has a System Tray Icon.

Alternatively, on U19.04, manually install libappindicator1.

In both cases, as both libappindicator1 and libappindicator3 is present, current LCL policy is to prefer libappindicator1 and it does not work !
Additional InformationAs noted in https://wiki.freepascal.org/How_to_use_a_TrayIcon#Problems_with_newer_Gnome_based_Linux even with this patch, getting a System Tray Icon working on Fedora and openSUSE is not as easy as it should be. Ubuntu and its friends are a lot better !
TagsNo tags attached.
Fixed in Revisionr61621
LazTarget-
WidgetsetGTK 2
Attached Files
  • use_AppInd_3.patch (2,362 bytes)
    --- unitywsctrls.pas-ref	2019-06-03 20:22:52.640356117 +1000
    +++ unitywsctrls.pas	2019-06-03 22:34:45.668285649 +1000
    @@ -12,10 +12,12 @@
       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.
    +{ Changed priority, now use libappindicator_3 if available.  ~_3 is, nominally
    +  a Unity thing but Ubuntu and several other distros ship it (and support it) with
    +  Gnome desktops.
    +
    +  As of U19.04, libappindicator_1, even if present, does not seem to work.
    +
       DRB
     }
     
    @@ -49,14 +51,13 @@
         class function GetPosition(const {%H-}ATrayIcon: TCustomTrayIcon): TPoint; override;
       end;
     
    -{ UnityAppIndicatorInit returns true if appindicator libraries can be loaded }
    +{ UnityAppIndicatorInit returns true if libappindicator_3 library can be loaded }
     
     function UnityAppIndicatorInit: Boolean;
     
     implementation
     
     const
    -  libappindicator_1 = 'libappindicator.so.1';
       libappindicator_3 = 'libappindicator3.so.1';
     
     {const
    @@ -266,20 +267,11 @@
       if Loaded then
         Exit(Initialized);
       Loaded:= True;
    -{  if GetEnvironmentVariableUTF8('XDG_CURRENT_DESKTOP') <> 'Unity' then
    -  begin
    -    Initialized := False;
    -    Exit;
    -  end;        }
       if Initialized then
         Exit(True);
    -  // 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 ....
    +  if Module = 0 then                               // no libappindicator_3
    +     Exit;                                         // hope libappindicator_1 can help you ....
       Result :=
         TryLoad('app_indicator_get_type', @app_indicator_get_type) and
         TryLoad('app_indicator_new', @app_indicator_new) and
    
    use_AppInd_3.patch (2,362 bytes)
  • use_AppInd_3.txt (381 bytes)
    This patch builds on previous appindicator patch.
    It now forces LCL to use the libappindicator_3 if its available. Even
    if libappindicator_1 is present. It seem that at least U19.04 cannot
    use libappindicator_1 (maybe its only present because of a OS upgrade?).
    
    To apply, cd to YourLazDir/lcl/interfaces/gtk2 and type 
    patch < PATH_TO_Patchfile/use_AppInd_3.patch
    
    Davo, May 2019
    
    use_AppInd_3.txt (381 bytes)

Relationships

related to 0033778 closedJuha Manninen With recent releases of Ubuntu (in particular) the TrayIcon no longer works. 
related to 0035983 closedJuha Manninen TrayIcon.OnClick fires right click 

Activities

David

2019-06-16 12:18

reporter  

use_AppInd_3.patch (2,362 bytes)
--- unitywsctrls.pas-ref	2019-06-03 20:22:52.640356117 +1000
+++ unitywsctrls.pas	2019-06-03 22:34:45.668285649 +1000
@@ -12,10 +12,12 @@
   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.
+{ Changed priority, now use libappindicator_3 if available.  ~_3 is, nominally
+  a Unity thing but Ubuntu and several other distros ship it (and support it) with
+  Gnome desktops.
+
+  As of U19.04, libappindicator_1, even if present, does not seem to work.
+
   DRB
 }
 
@@ -49,14 +51,13 @@
     class function GetPosition(const {%H-}ATrayIcon: TCustomTrayIcon): TPoint; override;
   end;
 
-{ UnityAppIndicatorInit returns true if appindicator libraries can be loaded }
+{ UnityAppIndicatorInit returns true if libappindicator_3 library can be loaded }
 
 function UnityAppIndicatorInit: Boolean;
 
 implementation
 
 const
-  libappindicator_1 = 'libappindicator.so.1';
   libappindicator_3 = 'libappindicator3.so.1';
 
 {const
@@ -266,20 +267,11 @@
   if Loaded then
     Exit(Initialized);
   Loaded:= True;
-{  if GetEnvironmentVariableUTF8('XDG_CURRENT_DESKTOP') <> 'Unity' then
-  begin
-    Initialized := False;
-    Exit;
-  end;        }
   if Initialized then
     Exit(True);
-  // 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 ....
+  if Module = 0 then                               // no libappindicator_3
+     Exit;                                         // hope libappindicator_1 can help you ....
   Result :=
     TryLoad('app_indicator_get_type', @app_indicator_get_type) and
     TryLoad('app_indicator_new', @app_indicator_new) and
use_AppInd_3.patch (2,362 bytes)
use_AppInd_3.txt (381 bytes)
This patch builds on previous appindicator patch.
It now forces LCL to use the libappindicator_3 if its available. Even
if libappindicator_1 is present. It seem that at least U19.04 cannot
use libappindicator_1 (maybe its only present because of a OS upgrade?).

To apply, cd to YourLazDir/lcl/interfaces/gtk2 and type 
patch < PATH_TO_Patchfile/use_AppInd_3.patch

Davo, May 2019
use_AppInd_3.txt (381 bytes)

Juha Manninen

2019-07-25 22:52

developer   ~0117399

Applied, thanks.

David

2019-07-26 00:56

reporter   ~0117402

Thanks Juha, do you think this will this be merged into fixes in time for 2.0.4 ?

Juha Manninen

2019-07-26 08:46

developer   ~0117404

Ok, I added it to the merge list. Apparently it does not break anything even on older Linux distros.

Mario Bonati

2019-08-20 20:15

reporter   ~0117751

Hi,
with revision 61620 all is ok.
With revision 61621, there is this bug: https://bugs.freepascal.org/view.php?id=35983

Thanks, Mario

Issue History

Date Modified Username Field Change
2019-06-16 12:18 David New Issue
2019-06-16 12:18 David File Added: use_AppInd_3.patch
2019-06-16 12:18 David File Added: use_AppInd_3.txt
2019-07-25 22:39 Juha Manninen Assigned To => Juha Manninen
2019-07-25 22:39 Juha Manninen Status new => assigned
2019-07-25 22:52 Juha Manninen Status assigned => resolved
2019-07-25 22:52 Juha Manninen Resolution open => fixed
2019-07-25 22:52 Juha Manninen Fixed in Revision => r61621
2019-07-25 22:52 Juha Manninen LazTarget => -
2019-07-25 22:52 Juha Manninen Widgetset GTK 2 => GTK 2
2019-07-25 22:52 Juha Manninen Note Added: 0117399
2019-07-25 22:58 Juha Manninen Relationship added related to 0033778
2019-07-26 00:56 David Note Added: 0117402
2019-07-26 08:46 Juha Manninen Note Added: 0117404
2019-08-20 20:15 Mario Bonati Note Added: 0117751
2019-08-23 19:39 Juha Manninen Relationship added related to 0035983