Forum > LCL

TTrayIcon do not work properly on Raspberry Pi OS(Raspi400)

(1/1)

atell:
Hi, All.

I'm a programming beginner living Sapporo City, Hokkaido, Japan.

Raspberry Pi 400 and Raspberry Pi OS 64bit 6.6.51+... with Lazarus 4.0RC1 and FPC 3.2.3. Revision: Unknown, aarch64-linux-gtk2. On Wayland.

My test-program of task tray icon won't activate. Please help me.

https://forum.lazarus.freepascal.org/index.php/topic,68967.msg534292.html#msg534292
https://wiki.freepascal.org/How_to_use_a_TrayIcon

Panel?..., 'ONLY gtk2 and Lazarus >= 3.0.0'? higher?

Below is my source code.

Best Regard,
Thank you.

atell.

---

(lpr)


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---program trayon01; {$mode objfpc}{$H+} uses  {$IFDEF UNIX}  cthreads,  {$ENDIF}  {$IFDEF HASAMIGA}  athreads,  {$ENDIF}  Interfaces, // this includes the LCL widgetset  Forms, Unit1_trayon01  {$ifdef LCLGTK2}  , unitywsctrls  {$endif}  { you can add units after this }; {$R *.res} // ----------------------------------------------------------------------------//   This about reading the command line and env for instructions re TrayIcon//   It applies to ONLY gtk2 and Lazarus >= 3.0.0 !// ----------------------------------------------------------------------------{$ifdef LCLGTK2} function GetUseAppInd() : UnityWSCtrls.TUseAppIndInstruction; var    EnvVar : string; begin Result := UnityWSCtrls.GlobalUseAppInd; if Application.HasOption('useappind') then begin              // Command line    if Application.GetOptionValue('useappind') = 'yes' then    // if not set, leave it alone.        Result := UseAppIndYes    else if Application.GetOptionValue('useappind') = 'no' then        Result := UseAppIndNo;                            // Anything other than yes or no is ignored end else begin    EnvVar := Application.EnvironmentVariable['LAZUSEAPPIND'];   // EnvironmentVariable    if EnvVar = 'YES' then        Result := UseAppIndYes    else if EnvVar = 'NO' then        Result := UseAppIndNo;    end;                        // EnvVar : 0x0end;{$endif} begin  RequireDerivedFormResource:=True;  Application.Scaled:=True;  Application.{%H-}MainFormOnTaskbar:=True;  Application.Initialize;  {$ifdef LCLGTK2 }      {$ifdef CPUi386}             // Note: unless Ayatana fix their problem, no option for Gnome users                                  // https://github.com/AyatanaIndicators/libayatana-appindicator/issues/76      UnityWSCtrls.GlobalUseAppInd := UnityWSCtrls.UseAppIndNo;     // 32bit must be a 'no'.      {$endif}      UnityWSCtrls.GlobalUseAppInd := GetUseAppInd();      //UnityWSCtrls.GlobalUseAppInd := UnityWSCtrls.UseAppIndAuto;  {$endif}  Application.CreateForm(TForm1, Form1);  Application.Run;end. 

(pas)


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---unit Unit1_trayon01; interface uses  Classes, SysUtils, Forms, Controls, Menus, ExtCtrls, Dialogs, StdCtrls;//, UnityWSCtrls; type   { TForm1 }   TForm1 = class(TForm)    Button1: TButton;    MainMenu1: TMainMenu;    TrayIcon1: TTrayIcon;    PopupMenu1: TPopupMenu;    MenuItem1: TMenuItem;    procedure Button1Click(Sender: TObject);    procedure FormCreate(Sender: TObject);    procedure MenuItem1Click(Sender: TObject);  private    { private declarations }  public    { public declarations }  end; var  Form1: TForm1; implementation {$R *.lfm} procedure TForm1.FormCreate(Sender: TObject);begin  //Application.ShowMainForm := False;  //Form1.Hide;end; procedure TForm1.Button1Click(Sender: TObject);begin  TrayIcon1.Icon := Application.Icon;  TrayIcon1.PopupMenu := PopupMenu1;  TrayIcon1.Visible := True;  TrayIcon1.Show;end; procedure TForm1.MenuItem1Click(Sender: TObject);begin  ShowMessage('Menu item clicked!');end; end. 

(lfm)

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---object Form1: TForm1  Left = 1480  Height = 300  Top = 250  Width = 500  Caption = 'Form1'  ClientHeight = 300  ClientWidth = 500  Menu = MainMenu1  LCLVersion = '4.0.0.1'  OnCreate = FormCreate  object Button1: TButton    Left = 341    Height = 25    Top = 170    Width = 75    Caption = 'Trayon!'    TabOrder = 0    OnClick = Button1Click  end  object TrayIcon1: TTrayIcon    PopUpMenu = PopupMenu1    Left = 176    Top = 152  end  object PopupMenu1: TPopupMenu    Left = 176    Top = 88    object MenuItem1: TMenuItem      Caption = 'Menu Item'      OnClick = MenuItem1Click    end  end  object MainMenu1: TMainMenu    Left = 129    Top = 232  endend 

Thanks.

Thaddy:
MainformOnTaskbar is only for Windows. you don?'t need it for Raspberry Pi OS.
If everything is installed correctly it should work out of the box.
(will test later for aarch64 Pi)
As a side note: did you make sure that the OS is up-to-date?
That is important, because Wayland is a moving target and a lot of updates happen to improve compatibility with X-windows.
So:
sudo apt update && sudo apt upgrade -y

You may also add backports to the apt configuration to get even more recent updates.
So for the moment don't touch fpc and lazarus, but do upgrade the system.
Big chance that is enough.
[edit]
TTrayIcon works on one of my RPi aarch64's. Not extensively tested.

atell:
Thanks, Thaddy  :D

Sorry it took so long. I was trying other Raspberry Pi OS.

The result is a difficult situation. It works on one Raspberry Pi OS, but not on the other. :(

Both are supposed to be the latest versions, "Linux raspberrypi 6.6.62+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.6.62-1+rpt1 (2024-11-25) aarch64 GNU/Linux".

As you pointed out, I tried other Raspberry Pi OS and it worked.

Thank you...

Atell at Japan.

Navigation

[0] Message Index

Go to full version