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.44k stars 1.12k forks source link

System trays/menus do not work on Ubuntu 18.04 w/ Gnome 3.28.2 #65

Closed malachid closed 2 years ago

malachid commented 3 years ago

Expected Tutorials would work out of the box

Actual

When running the Tray_Notifications_MenuBar tutorials on Ubuntu 18.04, the applications launch but do not function as expected.

There is the standard icon (with an exit option), but none of the application-specified menus. The notifier similarly does not present.

In the same manner, the Windows Attributes tutorial fails, as there are no menu options to click.

When I run this, it confirms that the SystemTray is no longer supported.

        if (!SystemTray.isSupported()) {
            System.out.println("SystemTray is not supported");
        }

I tried TopIconsPlus Gnome shell extension ( as per the Gnome Release notes ) and got the Tray example to work, but not the others. TBH, UI was not great either.

I also tried AppIndicator Gnome shell extension (as per the documentation on https://github.com/dorkbox/SystemTray ). That didn't work for any of the tutorials.

Suggestions

NangiDev commented 3 years ago

I just tried the tray example out on Ubuntu 18.04 w/ Gnome 3.28.2. Same issue. I get a desktop windows with the "Increment value", but no tray Icon.

EDIT: These frameworks seems to have solved the issue Dorkbox and TornadoFX

olonho commented 3 years ago

@NangiDev is 0.3.0-build134 any better wrt menus?

ptitjes commented 3 years ago

I tried the tutorial on Fedora 33 with Gnome 38 and the extension TrayIcons Reloaded. It more or less works.

Here are the problems that I observe:

I must add that I have a 2x scale factor (high dpi) as I use an 4K screen.

screenshot-1 screenshot-2

NangiDev commented 3 years ago

@olonho Sorry for slow response. I went with another solution, but just to answer your question I tried the same example project with version 0.3.0-build134 and still no tray menu, but I get the message "The os does not support: 'Taskbar.setIconImage'" in console.

I will try the TrayIcons Reloaded plugin that @ptitjes mentions. Not really an ideal solution for me, but I'm guessing it's more of an Gnome problem than compose-js problem

fauxvillage commented 3 years ago

if you are getting the "The os does not support: 'Taskbar.setIconImage'" error message when running from within IntelliJ; try packaging, installing, and running the program; this was necessary for me on Ubuntu 20.04, though not on Red Hat 8.3 if run directly (unfortunately no packaging yet for rpm, however); also this method works only as a window parameter function, not using the setIcon() method

malachid commented 3 years ago

Based on the comment from @fauxvillage I decided to try that on the notepad example in the repo. Whether running directly from gradle, or building the package and installing it - the tray does not work on it.

malachid commented 3 years ago

Not sure if there is anything we can learn from it, but the tray icon does work on the JetBrains Toolbox app.

malachid commented 2 years ago

Just re-tested this example https://github.com/JetBrains/compose-jb/tree/master/tutorials/Tray_Notifications_MenuBar_new on 20.04.2 (a different machine) by running ./gradlew packageDeb then using sudo apt install -f on it.

Instead of a tray icon, there was the normal app icon with "Untitled" and "Exit" under it.

If I run ./gradlew run on JDK11 or JDK16 instead, it says:

Tray is not supported on the current platform. Use global property isTraySupported to check.

I saw in https://blog.jetbrains.com/kotlin/2021/08/compose-multiplatform-goes-alpha/ that the Jetbrains Toolbox has been converted to Compose. It still has a tray icon on version "JetBrains Toolbox 1.21.9547, Ubuntu 20.04 (Linux 5.4.0-80-generic)".

Jeansen commented 2 years ago

I just tested this with the current version on a plain Debian 11.2 Installation with JDK 11 and 17. When I run the https://github.com/JetBrains/compose-jb/tree/master/tutorials/Tray_Notifications_MenuBar_new I get two things:

Context menu works in both scenarios.

Note: Tray only works when this extension is installed: https://extensions.gnome.org/extension/615/appindicator-support/ .

malachid commented 2 years ago

I already had the extension installed; however your timing is great because I had just been testing the same thing in Rust and had needed to do:

With those and the extension, I do see the tray now.

Results:

malachid commented 2 years ago

Verified the tray examples on Window_API_new are also working now.

Jeansen commented 2 years ago

@malachid Glad to here at least sometimes my timing is perfect ;-). I installed the packages, too. But no changes to my original post.

zoff99 commented 8 months ago

any progress on this? especially having notifications on ubuntu would be good

elect86 commented 3 months ago
the notification window that appears when I click on "Send notification" does not conform to platform notifications and is also very-badly rendered and position (see screenshots below)

screenshot-1 screenshot-2

I have the same on Ubuntu 23.10, tray works fine but the graphics is horrible

is there anything we can do to help? (guide us where/how to contribute with a PR)

zoff99 commented 3 months ago

@elect86 i made this until we have a better solution:

https://github.com/zoff99/jni_notifications

example usage is included:

https://github.com/zoff99/jni_notifications/blob/master/com/zoffcc/applications/jninotifications/NTFYActivity.java#L146

it works on macOS and on Linux. in windows notifications with try seem to work fine with this