Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2015-10

Patch for TTrayIcon on Ubuntu's Unity

16 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Anthony Walter

I create a fix for Lazarus TTrayIcon on Unity. if anyone wants to test it out or add it to the LCL please do so. The fix is located here:

https://github.com/sysrpl/Lazarus.UnityAppIndicators

To use this fix get the code above and:

Add 'unitywsctrls.pas' to 'lazarus/lcl/interfaces/gtk2' Apply patch to your 'lazarus' folder
Rebuild the 'lcl' package with the gtk2 widget set

A linux x86_64 compiled executable example is included.

A few notes:

It seems to me (which I say a lot because I'm not 100% positive) that app indicators in Unity were designed to restrict programmers and guide the UI design of Ubuntu in a specific direction. Namely to create more uniform visual styles and user interaction with apps.

As such I believe the following restrictions to apply to Unity app indicators:

* You cannot receive click or any mouse events for icons in the tray.
* A menu is required for an app indicator and the only action allowed is to show the menu when the mouse clicks with either button on a tray icon.
* An app can only have one app indicator and attempts to destroy or create a new one fail.
* You can only set the menu for an app indicator one time.
* Icons can be set from files only (you are supposed to use /usr/icons/share with themes).

More notes are in the source code.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20151012/e9af02bd/attachment.html>

Reply by email

Juha Manninen
to Anthony Walter

A stupid question: what is the best Ubuntu version to test with? I have avoided Unity desktop so far exactly because of the Lazarus related problems.

Another question: what about Lazarus built with QT bindings but running on Unity?

Third question: would it be possible to unite the TrayIcon code for Unity and other desktops? Now you have 2 separate implementations.

Regards,
Juha

Reply by email

Michael Van Canneyt
to Juha Manninen
Juha Manninen wrote 9 lines
A stupid question: what is the best Ubuntu version to test with? I have avoided Unity desktop so far exactly because of the Lazarus related problems. Another question: what about Lazarus built with QT bindings but running on Unity? Third question: would it be possible to unite the TrayIcon code for Unity and other desktops? Now you have 2 separate implementations.

Ow, that is rather bad :(

Michael.

Reply by email

zeljko
to Juha Manninen: A stupid question: what is the best Ubuntu version to test with? I have avoided Unity…
Juha Manninen wrote 6 lines
A stupid question: what is the best Ubuntu version to test with? I have avoided Unity desktop so far exactly because of the Lazarus related problems. Another question: what about Lazarus built with QT bindings but running on Unity?

Don't know, but Qt handles such stuff and QTrayIcon is transparent to LCL.

Third question: would it be possible to unite the TrayIcon code for Unity and other desktops? Now you have 2 separate implementations.

Maybe, but only in case if it's easy to extract information if we are under unity wm or other wm (I guess that it should not be an issue).

zeljko

Reply by email

Luca Olivetti
to Anthony Walter: I create a fix for Lazarus TTrayIcon on Unity. if anyone wants to test it out or add it…

El 12/10/15 a les 09:34, Anthony Walter ha escrit:

A linux x86_64 compiled executable example is included.

FWIW, that executable doesn't show any tray icon in kubuntu 15.04 with plasma 5.3.2.
As I reported before, trayicons in this environment don't work either with unpatched lazarus with the gtk2 widgetset but do work with the qt one. Disclaimer: I don't usually need tryicons, but the various threads on them piqued my curiosity.

Bye

Luca Olivetti Wetron Automation Technology http://www.wetron.es/ Tel. +34 93 5883004 (Ext.3010) Fax +34 93 5883007

Reply by email

Anthony Walter
to zeljko: Don't know, but Qt handles such stuff and QTrayIcon is transparent to LCL. Maybe, but…

""Maybe, but only in case if it's easy to extract information if we are under unity wm or other wm (I guess that it should not be an issue)."

{ UnityAppIndicatorInit returns true if Unity is the current desktop and the required appindicator libraries can be loaded }

function UnityAppIndicatorInit: Boolean;

The relevant HOWTO:

https://github.com/sysrpl/Lazarus.UnityAppIndicators/blob/master/lazarus/lcl/interfaces/gtk2/unitywsctrls.pas#L263-L267 https://github.com/sysrpl/Lazarus.UnityAppIndicators/blob/master/changes.patch#L18 -------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20151012/e44f0b49/attachment.html>

Reply by email

zeljko
to Anthony Walter
Anthony Walter wrote 12 lines
""Maybe, but only in case if it's easy to extract information if we are under unity wm or other wm (I guess that it should not be an issue)." { UnityAppIndicatorInit returns true if Unity is the current desktop and the required appindicator libraries can be loaded } function UnityAppIndicatorInit: Boolean; The relevant HOWTO: https://github.com/sysrpl/Lazarus.UnityAppIndicators/blob/master/lazarus/lcl/interfaces/gtk2/unitywsctrls.pas#L263-L267 https://github.com/sysrpl/Lazarus.UnityAppIndicators/blob/master/changes.patch#L18

ok, thanks. Can you provide result of TGtk2WidgetSet.GetWindowManager when you running simple app under unity ?

zeljko

Reply by email

Luca Olivetti
to Anthony Walter: The exe is 64 bit and built with the Gtk2 widget set. So the thing to test would be if…

El 12/10/15 a les 14:37, Anthony Walter ha escrit:

The exe is 64 bit and built with the Gtk2 widget set. So the thing to test would be if the Qt/KDE desktop normally shows with Lazarus applications built the Gtk2 tray icon.

No, as I said, it doesn't.
But, as per

http://blog.martin-graesslin.com/blog/2014/06/where-are-my-systray-icons/

if the gtk2 application uses libappindicator for unity compatibility, it should also work with plasma.
In fact I checked your code and it only tries to load libappindicator if XDG_CURRENT_DESKTOP is Unity. With that variable set I can see the tray icon (note that its normal value is KDE).

Bye

Luca Olivetti Wetron Automation Technology http://www.wetron.es/ Tel. +34 93 5883004 (Ext.3010) Fax +34 93 5883007

Reply by email

Anthony Walter
to Luca Olivetti

In fact I checked your code and it only tries to load libappindicator if XDG_CURRENT_DESKTOP is Unity. With that variable set I can see the tray icon (note that its normal value is KDE).

That's good then. I added 'KDE' to the allowed desktops when libappindicator is present with the Gtk2 toolkit. I also recompiled the 64bit example program with this change and overwrote it in the repository. So now if the fix it should also work on KDE, given XDG_CURRENT_DESKTOP returns 'KDE'.

Thank for the link as well. It would seem, reading the information in the link you posted, that Gtk3 uses libappindicator3-1. If anyone actively is working on adding to Gtk3 lcl interface you may want to consider looking at and copying some of the code I committed to github. -------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20151012/a7a543c6/attachment.html>

Reply by email

Luca Olivetti
to Anthony Walter

El 12/10/15 a les 17:53, Anthony Walter ha escrit:

Show quoted text 14 lines
In fact I checked your code and it only tries to load libappindicator if XDG_CURRENT_DESKTOP is Unity. With that variable set I can see the tray icon (note that its normal value is KDE). That's good then. I added 'KDE' to the allowed desktops when libappindicator is present with the Gtk2 toolkit. I also recompiled the 64bit example program with this change and overwrote it in the repository. So now if the fix it should also work on KDE, given XDG_CURRENT_DESKTOP returns 'KDE'. Thank for the link as well. It would seem, reading the information in the link you posted, that Gtk3 uses libappindicator3-1. If anyone actively is working on adding to Gtk3 lcl interface you may want to consider looking at and copying some of the code I committed to github.

FYI, just saw this:

http://blog.davidedmundson.co.uk/blog/xembed_back

(from https://lists.debian.org/debian-kde/2015/10/msg00047.html)

Bye

Luca Olivetti Wetron Automation Technology http://www.wetron.es/ Tel. +34 93 5883004 (Ext.3010) Fax +34 93 5883007

Reply by email

zeljko
to Juha Manninen
Juha Manninen wrote
Unfortunately I don't have much info about TrayIcons. Is it possible to add this Unity support to LCL? The idea sounds good but the discussion stopped early.

Yes it's possible, but wm recognition should be added...eg maybe you run kde instead of unity on ubuntu, but unity trayicon lib is installed, so it'll load unity trayicon instead of xorg one (afair from looking into sources of that patch).

zeljko

Reply by email

Anthony Walter
to zeljko

My patch checks for Unity and KDE desktop. Just remove the KDE check and it should be good to go. By the way I tested on Mint 13 Cinnamon (based on 12.04) and it still works.

https://github.com/sysrpl/Lazarus.UnityAppIndicators/blob/master/lazarus/lcl/interfaces/gtk2/unitywsctrls.pas#L264

To people with actual SVN commit rights, if this gets add it into the LCL could you remember to add me to the Lazarus contributor lists? Thanks. -------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20151103/e3bc4468/attachment.html>

Reply by email

zeljko
to Anthony Walter
Anthony Walter wrote 5 lines
My patch checks for Unity and KDE desktop. Just remove the KDE check and it should be good to go. By the way I tested on Mint 13 Cinnamon (based on 12.04) and it still works. https://github.com/sysrpl/Lazarus.UnityAppIndicators/blob/master/lazarus/lcl/interfaces/gtk2/unitywsctrls.pas#L264

I'll try to implement it in lazarus during weekend.

To people with actual SVN commit rights, if this gets add it into the LCL could you remember to add me to the Lazarus contributor lists? Thanks.

Sure.

zeljko

Reply by email