PDA

View Full Version : QSystemTrayIcon and linux...



rockdemon
4th October 2013, 10:17
Hi all,

I've recently converted our application to run in linux. It's a big application and mostly 'it just works' and if not i've been able to tweak it. The only fly in the ointment that's left is the QSystemTrayIcon which works on some linux desktops and not others.

It works on:
KUbuntu and other KDE distros fine.

It half works on Ubuntu 13.04 unity ( it appears as an icon on the desktop instead but this at least makes the application functional )

It doesnt work on Mint 15 MATE or Cinammon, ubuntu 13.04 with Gnome...

Has anybody managed to make a tray icon appear with any of these distros? I'm using Qt5.1.1 on an x64 oracle VM to test all these systems...

Thanks in advance,

Richard.

Added after 1:

Just discovered that on ubuntu 13.04 with gnome if you click activities there's a blank icon next to the removable devices icon. This when clicked shows our context menu. So it would appear at least partially broken in this scenario? You'd expect it to appear in the task bar which is normally across the top of the screen or am I missing something, but i'd have found it if the icon actually existed?

Still no progress on the other installs as yet...

Thanks,

Rich

rockdemon
4th October 2013, 12:14
Debian with gnome seems to also be missing the tray icons...

anda_skoa
4th October 2013, 13:26
Debian with gnome seems to also be missing the tray icons...

If that is also with GNOME 3, or rather with GNOME Shell as the workspace shell, then the different distribution doesnt matter.

Basically the issue is this:
QSystemTrayIcon on X11 systems is using a technique call XEmbed to embed its icon into the system tray area of the currently active workspace shell.
This has been the primary means for system tray icons so there is nothing conceptually wrong with that.
However, XEmbed is a rather clunky thing, making it hard or even impossible for workspace shells to handle them nicely, e.g. hide unneeded/unwanted ones.

Anyway, whether or not a QSystemTrayIcon shows up depends on whether the workspace shell has support for XEmbed based tray icons. As you have discovered that is true for KDE's Plasma Workspace and, in a slightly different visualization, for the Unity Desktop Shell.

GNOME Shell based workspaces, such as GNOME3 and CINNAMON, might not either not handle those at all or require an applet or extension to be added to the normal shell configuration. You could check with respective user forums or developer lists.

GNOME Panel based workspaces, such as GNOME2 or MATE, should also be more like KDE or Unity in this regard.

QSystemTrayIcon is currently still a class that does its platform dependent things internally, i.e. has code for Windows, X11, etc. It is quite likely that it will be ported to use the new QPA (Qt Platform Abstraction) facilities at some point, which would allow it to use the native tray integration of the running workspace shell instead of falling back to the rather crude XEmbed mechanism.

Just for anyone interested in more details: :)
KDE Plasma Workspaces and Unity Desktop share a new integration technology called system notifiers (in Unity those appear where you had expected tray icons). It is based on D-Bus, so it can be used through QtDBus, and the KDE Frameworks 5 initiative will most likely have a nice Qt style API available in one of its integration frameworks.

Cheers,
_

rockdemon
4th October 2013, 14:04
Many thanks for the detailed answer. Knowing what to look for i'll go and look up XEmbed in more detail!


Cheers,

Rich

rockdemon
8th October 2013, 16:26
For anybody that's interested, I've been able to create a window with an icon to cover linux desktops without system trays. The hardest part was detecting whether the tray icon is there or now. Best trick i found for the is looking at QSystemTrayIcon::geometry()::width() as on linux where it wasnt working the width is 0 or 1. Qt always says the system tray is there and claims the tray icon is visible whether it is or now...

Hope that's some help to someone :)

Rich