Bug 388995 - Plasma::Types::FormFactor or Plasma::Types::Location miss SystemTray variant
Summary: Plasma::Types::FormFactor or Plasma::Types::Location miss SystemTray variant
Status: RESOLVED FIXED
Alias: None
Product: libplasma
Classification: Frameworks and Libraries
Component: libplasma (other bugs)
Version First Reported In: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Marco Martin
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-01-15 08:11 UTC by Friedrich W. H. Kossebau
Modified: 2020-11-24 19:30 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In: 5.77
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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
}