Bug 495064

Summary: Java AWT TrayIcon stopped working on KDE 6.6 Plasma
Product: [Plasma] xdg-desktop-portal-kde Reporter: Davide Perini <perini.davide>
Component: generalAssignee: Plasma Bugs List <plasma-bugs>
Status: REPORTED ---    
Severity: normal CC: aleixpol, mail, matteo.hausner, nicolas.fella, ricken.ludger
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Ubuntu   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Davide Perini 2024-10-19 22:38:44 UTC
Running Ubuntu 24.10 and KDE 6.6 Plasma.
Java TrayIcon stopped working.

With this simple code:
```
import java.awt.*;
import java.awt.event.*;

public class TrayIconExample {
    public static void main(String[] args) {
        if (SystemTray.isSupported()) {
            SystemTray tray = SystemTray.getSystemTray();
            Image image = Toolkit.getDefaultToolkit().createImage("icon.png");
            TrayIcon trayIcon = new TrayIcon(image, "Tray Demo");

            trayIcon.setImageAutoSize(true);
            trayIcon.setToolTip("Tray Icon Demo");

            trayIcon.addMouseListener(new MouseAdapter() {
                u/Override
                public void mouseClicked(MouseEvent e) {
                    if (e.getButton() == MouseEvent.BUTTON1) {
                        System.out.println("Left button clicked");
                    } else if (e.getButton() == MouseEvent.BUTTON3) {
                        System.out.println("Right button clicked");
                    } else if (e.getButton() == MouseEvent.BUTTON2) {
                        System.out.println("Middle button clicked");
                    }
                }
            });

            try {
                tray.add(trayIcon);
            } catch (AWTException e) {
                System.err.println("TrayIcon could not be added.");
            }
        } else {
            System.err.println("System tray not supported!");
        }
    }
}
```

Tray icon is correctly added to the tray bar but there is no way to listen to mouse button on it making it unusable.

No event is triggered when I click on the tray icon.

This issue is blocking making all Java programs that uses a tray icon to not work correcly.
Comment 1 Pounder 2024-12-12 15:41:43 UTC
Doesn't seem to be distro specific, seeing this on
Arch (Plasma 6.2.4, KDE Frameworks 6.8.0, Qt 6.8.1)
Debian Trixie (Plasma 6.2.4, KDE Frameworks 6.6.0, Qt 6.7.2)
Comment 2 Matteo Hausner 2025-01-25 18:37:21 UTC
I am also experiencing this issue with my app ControllerBuddy -> https://controllerbuddy.org
As far as I can tell this appeared with KDE 6.0 - on KDE 5 the tray works flawlessly with AWT.
As this issue renders the tray icon useless, in my app I even started checking for KDE versions >= 6 to handle them as if the tray is not supported at all, which is really unfortunate... :(
I might be willing to look into this if nobody else cares, but at least some intial pointers on where to start digging would be helpful...