JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
15.87k stars 1.15k forks source link

Support creation of menu bar apps #850

Open saket opened 3 years ago

saket commented 3 years ago

It'd be really nice if compose-desktop supported creation of apps that live solely on the system tray. It is currently possible to interact with the system tray using Tray, but it is limited to text buttons. Being able to add arbitrary content to the popup would enable us to create apps like these:

image

I came across this StackOverflow answer which suggests doing so should be possible with AWT: https://stackoverflow.com/questions/13481504/creating-an-nsstatusitem-menubar-app-in-java

saket commented 3 years ago

Someone on kotlin lang suggested these kind of apps are actually called "daemon" apps that don't have any main UI windows and are only accessible through their tray icon. Please feel free to edit the title.

olonho commented 3 years ago

Guess it could be implemented as a regular app without border rendered at predefined position.

saket commented 3 years ago

True. It'll also need to,

  1. Align its window with the tray icon when its opened. I wasn't able to find anything for AWT, but if this electron app is able to do it, there must be a way.
  2. Highlight the tray icon when its window is visible.
  3. Hide its dock icon. There are various ways of doing this with AWT.
  4. Not show any main window when it's launched.
saket commented 3 years ago

After spending some time on this, this seems impossible with the set of APIs provided by AWT. I couldn't find any existing pattern or app that has managed to do this. In comparison, there are tons of examples with electron. Here's one: https://github.com/maxogden/menubar

natanfudge commented 12 months ago

Just being able to customize the tray content would be really nice, considering the current implementation is really limiting (and ugly on windows)

Giuliopime commented 11 months ago

Any update on this?

okushnikov commented 1 month ago

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.