Hey everyone, I'm excited to announce my new libra...
# compose-desktop
u
Hey everyone, I'm excited to announce my new library, Compose Native Tray for compose for Desktop! 🎉 After quite a journey, I've finally solved the HDPI issues for system tray icons on both Windows and Linux, and it's all native! For macOS, I don't own a device to test on, so I've implemented it with AWT, but it's untested. The library allows you to easily create system tray apps with a Kotlin DSL, supporting features like checkable items, submenus, dividers, and dynamic item enable/disable. Check it out if you want a modern, cross-platform solution for tray applications: https://github.com/kdroidFilter/ComposeNativeTray
🤩 1
👍 5
👍🏻 1
K 2
🔥 2
🙌 1
e
I see no callbacks available for simple actions on the tray icon. In my app I currently don't have any menu but just a tray icon that allows to bring the app to front on a simple click on the tray icon. Is that a use case you could consider?
u
I didn't think about this kind of case 😅, yes I will add that as soon as possible
e
One thing that would be very useful to position some application's window close to the system tray would be to get the screen position of the tray icon in the action callback. It can be so different depending on the platform and user's layout.
u
Yes it's true, I don't think it's very complicated on Linux and Windows, on Mac I don't know much about it and I don't have anything to test either 😕
e
Well on Linux the system tray could be anywhere as it depends largely on the desktop environment and user customizations.
On Windows the system tray is always on the main monitor but the user can move the taskbar on different screen edges.
On macOS the system tray is always in the menu bar at the top of the screen but it is displayed simultaneously on all monitors.
The mouse click position might be the easiest way to get the icon position.
u
It's true I hadn't thought about it, under Linux I must first check if libappindicator doesn't already give me this information
I added an onLeftClick callback, I implemented it on windows and mac (awt) for now, I still have linux.
On Linux it is not possible with libappindicator to capture a left click, so I added an Item at the top of the context menu with the possibility to modify the label, but otherwise I have just published the update with support for left click on Windows and Mac
r
Curious what the Linux support for this looks like? Does it work across the common desktop environments (Gnome, KDE, XFCE, whatever Ubuntu is using)
u
I posted screenshots in the readme on github
I posted for kde and gnome, I also tested xfce and it is exactly like kde
image.png,image.png
About simple click on tray icon on Linux, doesn't appindicator support the
activate
signal? ☝️
u
no I tried, it's the philosophy of libappindicator according to what I understood
the solution would be to rewrite everything with qt which supports this
😑 1
Yes I don't really want to write everything with qt, especially since I have the impression of being the only one who uses compose with linux :)
e
You're not the only one 🙂
😅 1
👍 1
u
you too ?
👌 2
e
I guess good old
GtkStatusIcon
could work on non-unity desktop environments.
It also seems that one could abuse the
about-to-show
signal if no menu is needed https://github.com/seppestas/test-libappindicator/blob/master/test-menu-about-to-show-signal.c
u
I tried with Gtkstatusicon and it works but it's ugly
e
It's ugly even in other DEs than Ubuntu Gnome?
u
About libappindicator it can be interesting to implement it with libappindicator if there is no context menu
👍 1
I have only tried on gnome
e
For my usecase I'd be happy with a tray icon click callback and no context menu at all.
d
Thanks for the hard work @אליהו הדס. Another Linux Compose Desktop user here. I will try your lib when I have some time.
👍 1
u
@eskatos I will try :)
❤️ 1
a
Not sure if related to the goals of this lib, but it would be cool to have an API for native notifications too
u
@Alex Styl https://github.com/kdroidFilter/KNotify I'm writing a special library for this, the first version I deployed just runs scripts, but the next one I'm about to deploy will support callbacks with buttons, and will support android.
💡 1
a
awesome. the major pain in CMP is desktop rn. try nailing that one first before introducing other platforms (talking in terms of one library dev to an other)
u
Unfortunately I can only do Linux and Windows because I don't have a Mac (yet), and I'm almost done already, you can already try on the 0.2.0 branch on Github, I still have a memory error on Windows that I haven't managed to correct yet, I hope to get there soon
a
happy to test on my mac, but i need a test app
u
That's not the problem, I can't develop such a feature without testing it as I go.
👍 1
@Alex Styl I just released a new version of my library for compose for desktop (linux windows) and android https://kotlinlang.slack.com/archives/C0BJ0GTE2/p1729990322414189
👍 1