Yet Another TrayIcon issue lazarus / 31-LCL ---------------------------------------------------------------------- dbannon · 2023-05-02 03:05 Posted under LCL because, while its a quite specific Linux issue, it needs to be avoided in all cross platform code that uses the TrayIcon. We know that calling Show before assigning a menu to the TrayIcon results in a "no show". But, new in Gnome Desktop 44 the Gnome developers have found a new way to torment System Tray users. If the assigned menu contains no menu items at time of TrayIcon.Show, the Icon appears but will never show menu items subsequently assigned to it. This was not the case in, eg Gnome DT 43, nor in any other Linux desktop, now in any other OS that has a compatible System Tray. The error message shown fortunately is clear about what the issue is. If you generate your menus dynamically, make sure there is at least one menu item in there before you call TrayIcon.Show. Near as I can tell, the problem only shows up on Gnome 44, that means Ubuntu Luna (and, obviously only with a Gnome Desktop). The misspelt error message has been in libdbusmenu-glib for a long time, I guess the Gnome Developers only recently spotted it. I have made a note about this on the TrayIcon wiki page. Davo ---------------------------------------------------------------------- Fred vS · 2023-05-03 16:20 Hello Davo. Here on XUbuntu and Xfce I have no luck, even using your popup-menu- item trick. I did test with TrayIcon widget from LCL-Gtk, MSEgui and fpGUI. No icon show.  :'( But the strange thing is that the same Trayicon-test-app compiled for Windows and running the application on Linux via the emulator wine, the icon appears! So there is a trick that wine understood and maybe we have to check in his code for us. Fre;D ---------------------------------------------------------------------- dbannon · 2023-05-04 00:09 Oh, thats a worry Fred.  I have not checked XUbuntu in U23.04, XFCe is more popular in Debian so I test it there. But Debian does not have this particular problem .... I'll run some tests later today if I get a chance. > I did test with TrayIcon widget from LCL-Gtk, MSEgui and fpGUI. Hmm, I guess its a typo, I assume you mean LCL-Gtk2 ?  I don't test fpGUI and, sorry, I don't test MSEgui even though I know its near to your heart. I test GTK2 and Qt5 on Linux, both were affected by the Gnome 44 bug and both were 'fixable' on Gnome itself. I'd expect GTK3 to be the same and probably Qt6 But I will try my normal tests on XFCe  asap ! Davo ---------------------------------------------------------------------- dbannon · 2023-05-04 10:52 No Fred, I lie, I did in fact test Ubuntu XFCe 23.04. And it works perfectly with both LCL-GTK2 and LCL-Qt5. Do you want to send me your test project please ? Davo ---------------------------------------------------------------------- Fred vS · 2023-05-04 11:40 Quote from: dbannon on May 04, 2023, 12:52:25 pmNo Fred, I lie, I did in fact test Ubuntu XFCe 23.04. And it works perfectly with both LCL-GTK2 and LCL-Qt5. Do you want to send me your test project please ? Davo Hello Davo. In attachment a LCL-GTK2 project, compiled with fpc 3.2.2. on Lazarus 2.2.4., that gives no icon on the traybar of my system XUbuntu 22.10 + XFCe. Compiled-binary: https://github.com/fredvs/attach/files/11397514/project1_bin.zip Fre;D [EDIT] In picture-attachment, same project compiled for Windows and run on Linux via wine emulator: The icon is shown ! ---------------------------------------------------------------------- dbannon · 2023-05-04 22:47 Ah, I assumed you meant U23.04.  I don't do much testing on the short release versions of Ubuntu, they are around for such a short time and Ubuntu's own figures seem to indicate most Ubuntu users use the LTS ones. Further, I find the short release ones are not usually quite as stable as the LTS. It was just luck I picked up the new problem in 23.04. So, 22.10 ? Only has a few weeks of official support left.  I'll pull down an image and see what I can find. Davo ---------------------------------------------------------------------- Fred vS · 2023-05-04 23:18 Quote from: dbannon on May 05, 2023, 12:47:02 amAh, I assumed you meant U23.04.  I don't do much testing on the short release versions of Ubuntu, they are around for such a short time and Ubuntu's own figures seem to indicate most Ubuntu users use the LTS ones. Further, I find the short release ones are not usually quite as stable as the LTS. It was just luck I picked up the new problem in 23.04. So, 22.10 ? Only has a few weeks of official support left.  I'll pull down an image and see what I can find. Davo It is the XUbuntu version: https://xubuntu.org/ Without the "Unity" manager. Indeed, there is just a new release 23.04, I did not yet the upgrade. But I did have same trayicon problems on previous release of XUbuntu +  XFCe, not only 22.10. It is the reason why I do not use TrayIcon anymore in Linux/FreeBSD system. But, like said in previous post, there is something that wine does ok for dealing with X11-tray that I would be happy to understand. ---------------------------------------------------------------------- Fred vS · 2023-05-05 00:07 Hello Davo. OK, upgrade done: Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i ~> lsb_release -aNo LSB modules are available.Distributor ID: UbuntuDescription:    Ubuntu 23.04Release:        23.04Codename:     lunar  Now testing the TrayIcon test (see attachment in previous post): No, there is no icon in the Traybar.  [EDIT] And there is no more sound now (white night sure  ).             Ok, sound fixed (but still no icon in traybar). ---------------------------------------------------------------------- rca · 2023-05-05 00:52 @Fred vS I downloaded their Compiled-binary: https://github.com/fredvs/attach/files/11397514/project1_bin.zip I ran it with Xubuntu Live 22.10 into USB. And it works correctly, it shows the icon and the PopupMenu. Attached image. I also tested it on Fedora 38 with Gnome 44 and it works, just the icon looks smaller. Attached image. ---------------------------------------------------------------------- Fred vS · 2023-05-05 01:15 Quote from: rca on May 05, 2023, 02:52:54 am@Fred vS I downloaded their Compiled-binary: https://github.com/fredvs/attach/files/11397514/project1_bin.zip I ran it with Xubuntu Live 22.10 into USB. And it works correctly, it shows the icon and the PopupMenu. Attached image. I also tested it on Fedora 38 with Gnome 44 and it works, just the icon looks smaller. Attached image. Hello Rca. Nice that it works for you.  So I am lost, I dont see what is wrong on my side.  Do you have Xfce panel and window manager installed (see picture) ? ---------------------------------------------------------------------- rca · 2023-05-05 01:36 Hello @Fred vS Yes, I have the Xfce panel and window manager installed. Attached images ---------------------------------------------------------------------- Fred vS · 2023-05-05 01:48 Hello Rca. Yep, I get it!  But only with sudo privilege (see picture). Strange that I need root privilege to see the icon. Anyway, thanks for your test, so here it works with sudo ( but I am not sure that I will use TrayIcon again  ) Fre;D ---------------------------------------------------------------------- rca · 2023-05-05 01:55 Quote from: Fred vS on May 05, 2023, 03:48:38 amHello Rca. ... Anyway, thanks for your test, so here it works with sudo ( but I am not sure that I will use TrayIcon again  ) Fre;D Hello @Fred vS With great pleasure. I'm glad you got it to work. ---------------------------------------------------------------------- Fred vS · 2023-05-05 02:52 OK, I get the solution. From here: https://gitlab.xfce.org/xfce/xfce4-panel/-/issues/599#note_63222 The guilty: ayatana-indicator-application, it makes conflict with the Xfce indicator. Just disable it in Settings/Session and Startup > Application Autostart Now the icon appears, even without sudo  (Hard fight) ---------------------------------------------------------------------- dbannon · 2023-05-05 05:13 Ah, thats an interesting one Fred. You should not need libayatana on XFCe, its only necessary, as I understand it, on a Gnome Desktop (along with some Gnome extensions). Are you running a multidesktop system ?  Where you select the Desktop as you login ? I suspect you could have made it work if you started your app lile this - Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i LAZUSEAPPIND=NO ./project1 [enter] Be interesting to know.  I don't have that code in the GTK3 version, only the GTK2 version of TrayIcon incidentally. And Qtx does not know about it either. I do have a couple of "dual boot" (desktop only) VM I use for testing and have not seen any conflicts previously. I have libayatana installed on my Mate system and never had any problems. But I do remember that XFCe did announce they were developing their own SystemTray model a few years ago, along with a programme to eliminate all GTK2 code from XFCe. Right now, the TrayIcon code 'prefers' libayatana if it finds it, that appears to be OK everywhere I test but now I need to start testing for combinations !  In my own app, I determine if the user is using Gnome and then look for libayatana and the gnome extension and warn them to install or activate the extension if necessary. Thats not necessary on Ubuntu Gnome but is necessary on all the other non-Ubuntu Gnome using systems. Gnome puts a lot of effort into making things hard for us. Davo ---------------------------------------------------------------------- dbannon · 2023-05-05 07:43 Nope, wrong again Davo. On my U22.10 XFCe, you definitely need libayatana-appindicator3 - without it, either no icon or no menu. So, Fred, I don't understand why your system behaves so differently to mine ! As for Ayatana-Indicator-Application, it appears to be a Unity compatibility layer, the LCL TrayIcon code can use Unity but its not necessary. It makes no difference to my fresh install. Incidentally, I might consider checking just what libayatana dependencies are, in the past it needed just about the whole Gnome- Shell stack so I was very reluctant to add it to a list of dependencies.... Davo