mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-04-21 18:16:54 -04:00
when "starting hidden", only minimize when there is no tray icon
This commit is contained in:
@@ -50,15 +50,23 @@ public class FxApplication {
|
||||
applicationTerminator.initialize();
|
||||
|
||||
// init system tray
|
||||
final boolean hasTrayIcon;
|
||||
if (SystemTray.isSupported() && settings.showTrayIcon().get()) {
|
||||
trayMenu.get().initializeTrayIcon();
|
||||
Platform.setImplicitExit(false); // don't quit when closing all windows
|
||||
hasTrayIcon = true;
|
||||
} else {
|
||||
hasTrayIcon = false;
|
||||
}
|
||||
|
||||
// show main window
|
||||
appWindows.showMainWindow().thenAccept(stage -> {
|
||||
boolean hide = settings.startHidden().get();
|
||||
stage.setIconified(hide);
|
||||
if (hasTrayIcon) {
|
||||
stage.hide();
|
||||
} else {
|
||||
stage.setIconified(hide);
|
||||
}
|
||||
});
|
||||
|
||||
launchEventHandler.startHandlingLaunchEvents();
|
||||
|
||||
@@ -18,8 +18,7 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.binding.Bindings;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.collections.ListChangeListener;
|
||||
import javafx.collections.transformation.FilteredList;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.stage.Stage;
|
||||
@@ -83,13 +82,14 @@ public class FxApplicationWindows {
|
||||
|
||||
// observe visible windows
|
||||
if (trayIntegration.isPresent()) {
|
||||
Bindings.isNotEmpty(visibleWindows).addListener(this::visibleWindowsChanged);
|
||||
visibleWindows.addListener(this::visibleWindowsChanged);
|
||||
}
|
||||
}
|
||||
|
||||
private void visibleWindowsChanged(@SuppressWarnings("unused") ObservableValue<? extends Boolean> observableValue, @SuppressWarnings("unused") boolean oldValue, boolean newValue) {
|
||||
LOG.debug("has visible stages: {}", newValue);
|
||||
if (newValue) {
|
||||
private void visibleWindowsChanged(ListChangeListener.Change<? extends Window> change) {
|
||||
int visibleWindows = change.getList().size();
|
||||
LOG.debug("visible windows: {}", visibleWindows);
|
||||
if (visibleWindows > 0) {
|
||||
trayIntegration.ifPresent(TrayIntegrationProvider::restoredFromTray);
|
||||
} else {
|
||||
trayIntegration.ifPresent(TrayIntegrationProvider::minimizedToTray);
|
||||
|
||||
Reference in New Issue
Block a user