From 425372ee74c5744ecf6ed43653edbe1c695b1342 Mon Sep 17 00:00:00 2001 From: Juha Date: Sun, 3 Dec 2023 17:49:20 +0200 Subject: [PATCH] LCL-GTK2: Make TrayIcon more configurable based on libraries and features provided by a distro. Issue #40629, patch by dbannon. --- lcl/interfaces/gtk2/gtk2wsfactory.pas | 14 ++++++++++---- lcl/interfaces/gtk2/unitywsctrls.pas | 8 +++++++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/lcl/interfaces/gtk2/gtk2wsfactory.pas b/lcl/interfaces/gtk2/gtk2wsfactory.pas index 94632d0ddc..24094efcfc 100644 --- a/lcl/interfaces/gtk2/gtk2wsfactory.pas +++ b/lcl/interfaces/gtk2/gtk2wsfactory.pas @@ -464,11 +464,17 @@ end; function RegisterCustomTrayIcon: Boolean; alias : 'WSRegisterCustomTrayIcon'; begin - if UnityAppIndicatorInit then - RegisterWSComponent(TCustomTrayIcon, TUnityWSCustomTrayIcon) - else - RegisterWSComponent(TCustomTrayIcon, TGtk2WSCustomTrayIcon); Result := True; + case UnityWSCtrls.GlobalUseAppInd of + UseAppIndAuto : if UnityAppIndicatorInit then + RegisterWSComponent(TCustomTrayIcon, TUnityWSCustomTrayIcon) + else + RegisterWSComponent(TCustomTrayIcon, TGtk2WSCustomTrayIcon); + UseAppIndYes : if UnityAppIndicatorInit then + RegisterWSComponent(TCustomTrayIcon, TUnityWSCustomTrayIcon) + else Result := false; + UseAppIndNo : RegisterWSComponent(TCustomTrayIcon, TGtk2WSCustomTrayIcon); + end; end; //ExtDlgs diff --git a/lcl/interfaces/gtk2/unitywsctrls.pas b/lcl/interfaces/gtk2/unitywsctrls.pas index 59ff7d3989..4fb9c1f471 100644 --- a/lcl/interfaces/gtk2/unitywsctrls.pas +++ b/lcl/interfaces/gtk2/unitywsctrls.pas @@ -71,10 +71,16 @@ type class function GetPosition(const {%H-}ATrayIcon: TCustomTrayIcon): TPoint; override; end; -{ UnityAppIndicatorInit returns true if an AppIndicator library can be loaded } +type TUseAppIndInstruction = (UseAppIndYes, UseAppIndNo, UseAppIndAuto); +{ UnityAppIndicatorInit returns true if an AppIndicator library can be loaded } function UnityAppIndicatorInit: Boolean; +var + // A Global used in RegisterCustomTrayIcon() and possibly set in higher level + // code to predetermine the SysTray model to use. + GlobalUseAppInd : TUseAppIndInstruction = UseAppIndAuto; + implementation const