Route native macOS Quit through the tray confirmation lifecycle

This commit is contained in:
2026-11-14 09:16:19 +01:00
parent 00d2b19bf0
commit 7581cf0b45
4 changed files with 56 additions and 2 deletions
@@ -33,8 +33,15 @@ class TraySupportTest {
stage.fireEvent(new WindowEvent(stage,WindowEvent.WINDOW_CLOSE_REQUEST));
assertFalse(stage.isShowing()); assertFalse(exited.get());
open.get().run(); assertTrue(stage.isShowing());
quit.get().run(); assertFalse(exited.get());
allowed.set(true); quit.get().run(); assertTrue(exited.get());
Runnable nativeQuit = System.getProperty("os.name", "").startsWith("Mac")
? () -> {
var app = com.sun.glass.ui.Application.GetApplication();
app.getEventHandler().handleQuitAction(app, System.nanoTime());
} : quit.get();
// Native Quit must use the same confirmation as the tray, even hidden.
stage.hide(); nativeQuit.run();
assertTrue(stage.isShowing()); assertFalse(exited.get());
allowed.set(true); nativeQuit.run(); assertTrue(exited.get());
tray.close(); assertTrue(removed.get());
var unavailable=TraySupport.attach(stage,new BufferedImage(16,16,BufferedImage.TYPE_INT_ARGB),"test",() -> true,() -> {},
(icon,label,onOpen,onQuit) -> CompletableFuture.completedFuture(null));