Bug 388995

Summary: Plasma::Types::FormFactor or Plasma::Types::Location miss SystemTray variant
Product: [Frameworks and Libraries] libplasma Reporter: Friedrich W. H. Kossebau <kossebau>
Component: libplasmaAssignee: Marco Martin <notmart>
Status: RESOLVED FIXED    
Severity: normal CC: clearmartin, nate
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In: 5.77
Sentry Crash Report:

Description Friedrich W. H. Kossebau 2018-01-15 08:11:41 UTC
An applet shown in a system tray has to deal with the special requirement of needing to be square in that container, it seems. To allow the applet to do that, it has to be able to know about its situation.

But there seems no official way to query if an applet is placed in the system tray. While "AppletInterface" has properties "formFactor" or "location", none of the values of the returned types give a notion about the system tray.

Perhaps the enum "Plasma::Types::FormFactor" could be extended with a new value "Square", matching "Horizontal" and "Vertical". So other applet containers which have that special requirement by design can reuse that as well (IIRC macOS docker-style panels might want that with applets, too).

Workaround for now:
One can peek into the containing structure and do a guess from the data seen there:
```
    inTray = (plasmoid.parent !== null && (plasmoid.parent.pluginName === 'org.kde.plasma.private.systemtray' || plasmoid.parent.objectName === 'taskItemContainer'))
```
(found at https://github.com/kotelnik/plasma-applet-weather-widget/blob/master/package/contents/ui/main.qml#L146)
Comment 1 Friedrich W. H. Kossebau 2018-01-15 08:20:20 UTC
Adding Martin K., as he (as author of workaround :) ) might want to comment as well :)
Comment 2 Nate Graham 2020-11-24 19:30:49 UTC
This functionality was added recently in https://invent.kde.org/frameworks/plasma-framework/-/merge_requests/135, though not in exactly the way you requested.

It can be used like this:

ItemWhichShouldOnlyBeDrawnWhenInTheSystemTray {
    visible: plasmoid.containmentDisplayHints & PlasmaCore.Types.ContainmentDrawsPlasmoidHeading
}