Recent

Author Topic: TTrayIcon with Lazarus 2.2+ on Linux with Mate  (Read 1712 times)

mhart

  • Newbie
  • Posts: 3
TTrayIcon with Lazarus 2.2+ on Linux with Mate
« on: November 09, 2021, 01:09:09 pm »
Hi, Could you please advise me some way how to display an icon on system tray (Fedora 35 with Mate desktop). It was possible building app with Lazarus 2.0.12 GTK2, but this option is no longer supported by Lazarus 2.2+. Thanks.

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4052
  • I like bugs.
Re: TTrayIcon with Lazarus 2.2+ on Linux with Mate
« Reply #1 on: November 09, 2021, 02:19:25 pm »
Hi, Could you please advise me some way how to display an icon on system tray (Fedora 35 with Mate desktop). It was possible building app with Lazarus 2.0.12 GTK2, but this option is no longer supported by Lazarus 2.2+.
It is supported, even better than before. Explain more please.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

mhart

  • Newbie
  • Posts: 3
Re: TTrayIcon with Lazarus 2.2+ on Linux with Mate
« Reply #2 on: November 09, 2021, 02:33:24 pm »
An app built with Lazarus 2.0.12 displays icon on system tray perfectly, but the same app built with Lazarus 2.2 RC1 or RC2 does not display the icon. I try it on ubuntu 21.10 and no icon as well, but if app was built with Lazarus 2.0.12 it works perfectly. At Lazarus Wiki about TTrayIcon says the behavior was changed in Lazarus 2.2.

Gustavo 'Gus' Carreno

  • Hero Member
  • *****
  • Posts: 838
  • Professional amateur ;-P
Re: TTrayIcon with Lazarus 2.2+ on Linux with Mate
« Reply #3 on: November 09, 2021, 04:27:52 pm »
Hey MHart,

Could you please tell us if you attached a TPopUpMenu to the TTrayIcon ?

ATM I'm upgrading Ubuntu boxes and after that I'm finally gonna start on my TestTrayIcon app that I've been putting off for a while.
I'm gonna host it on GitHub, so I'll link it here if I get any answers to this question.

As you can see by my signature I'm on Ubuntu 21.10 also.

Cheers,
Gus
Lazarus 2.3.0(trunk) FPC 3.3.1(trunk) Ubuntu 21.10 64b Dark Theme
Lazarus 2.0.12(stable) FPC 3.2.2(stable) Ubuntu 21.10 64b Dark Theme
http://github.com/gcarreno

Gustavo 'Gus' Carreno

  • Hero Member
  • *****
  • Posts: 838
  • Professional amateur ;-P
Re: TTrayIcon with Lazarus 2.2+ on Linux with Mate
« Reply #4 on: November 09, 2021, 04:33:31 pm »
Hey MHart,

BTW, when I get some answers for myself I'll also update this thread: Why did the Tray Icon stop working with Ubuntu?.

I started it quite a while ago and then planned the TestTrayIcon project but never got around to get to it.
So I'll keep both threads updated on my progress.
In the mean time have a read an try to see if any of the info already relayed on that thread can help you.

Cheers,
Gus
Lazarus 2.3.0(trunk) FPC 3.3.1(trunk) Ubuntu 21.10 64b Dark Theme
Lazarus 2.0.12(stable) FPC 3.2.2(stable) Ubuntu 21.10 64b Dark Theme
http://github.com/gcarreno

mhart

  • Newbie
  • Posts: 3
Re: TTrayIcon with Lazarus 2.2+ on Linux with Mate
« Reply #5 on: November 09, 2021, 05:29:40 pm »
Hey Gustavo,

I attached a popupmenu to TTrayIcon and the icon is there, perfect! Without attached popupmenu the icon appears if libindicator-gtk3 is removed and libindicator-gtk2 installed, but Lazarus 2.0.12 works perfectly in any case.

Thank you,
Mhart.

Gustavo 'Gus' Carreno

  • Hero Member
  • *****
  • Posts: 838
  • Professional amateur ;-P
Re: TTrayIcon with Lazarus 2.2+ on Linux with Mate
« Reply #6 on: November 09, 2021, 05:53:18 pm »
Hey Mhart,

I attached a popupmenu to TTrayIcon and the icon is there, perfect! Without attached popupmenu the icon appears if libindicator-gtk3 is removed and libindicator-gtk2 installed, but Lazarus 2.0.12 works perfectly in any case.

Yeah, it was mentioned on the other thread I started, something about the fact that now we need to have a TPopUpMenu for it to work.
What I wasn't aware is that you didn't need it on 2.0.12.

Need to get all that info in my TestTrayIcon project.

Thank you,

You are most welcome!!

Cheers,
Gus
Lazarus 2.3.0(trunk) FPC 3.3.1(trunk) Ubuntu 21.10 64b Dark Theme
Lazarus 2.0.12(stable) FPC 3.2.2(stable) Ubuntu 21.10 64b Dark Theme
http://github.com/gcarreno

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4052
  • I like bugs.
Re: TTrayIcon with Lazarus 2.2+ on Linux with Mate
« Reply #7 on: November 09, 2021, 08:39:53 pm »
See
 https://wiki.lazarus.freepascal.org/How_to_use_a_TrayIcon

LAZUSEAPPIND=NO
environment variable may be useful.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

dbannon

  • Hero Member
  • *****
  • Posts: 1816
    • tomboy-ng, a rewrite of the classic Tomboy
Re: TTrayIcon with Lazarus 2.2+ on Linux with Mate
« Reply #8 on: November 10, 2021, 02:20:54 am »
In the "new" but not necessarily "better" model, a tray icon MUST have a popup menu and does not return, as separate events things like double click, drag, right click.

Desktops like Mate do still support the old, richer, system tray model but there is no guarantee that they will even the next release. So, you are well advised to design your apps to use only the new model.

(Sadly) most of your linux end users will be using Gnome (no, I don't know why) and it will not display the old model at all.

And, for the record, most newly released distros right now, on Gnome are using libayatana-appindicator3 rather than libappindicator3. Lazarus less than 2.2.* (or trunk) does not know about libayanta !  So, fail.

I am experimenting with a postinst script that creates a symlink, do not like it, but ...

EDIT: I should have mentioned one of the reasons why the old systray model will disappear is Wayland. Right now, its Gnome on Wayland, but the others are expected to follow.

Davo
« Last Edit: November 10, 2021, 02:27:51 am by dbannon »
Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng

 

TinyPortal © 2005-2018