Fixed right-click menu visibility/stability issues on older macos and older jvm installs.

This commit is contained in:
Robinson 2023-01-03 14:13:31 +01:00
parent 5294caaf73
commit 9afe4b5c5e
No known key found for this signature in database
GPG Key ID: 8E7DB78588BD6F5C
1 changed files with 15 additions and 9 deletions

View File

@ -164,20 +164,26 @@ class _OsxAwtTray extends Tray {
final AwtOsxMenu awtOsxMenu = this;
if (dorkbox.systemTray.SystemTray.AUTO_FIX_INCONSISTENCIES) {
dorkbox.systemTray.SystemTray.logger.error("Auto-fixing right-click for macOS system tray");
trayIcon.addMouseListener(new MouseAdapter() {
@Override
public
void mouseClicked(final MouseEvent e) {
final Point2D location = AwtAccessor.getLocation(trayIcon);
final Component component = new Component() {
@Override
public
Point getLocationOnScreen() {
return new Point((int) location.getX()-4, (int) location.getY()+6);
}
};
if (!e.isPopupTrigger() && e.getButton() != 1) {
// there can be race conditions when the native bits are sending events, so we have to manually check these!
dorkbox.systemTray.SystemTray.logger.error("NOT popup trigger: " + e);
AwtAccessor.showPopup(component, _native);
final Point2D location = AwtAccessor.getLocation(trayIcon);
final Component component = new Component() {
@Override
public
Point getLocationOnScreen() {
return new Point((int) location.getX()-4, (int) location.getY()+6);
}
};
AwtAccessor.showPopup(component, _native);
}
}
});
}