diff --git a/app/src/main/java/io/xpipe/app/auxw/AppAuxiliaryWindow.java b/app/src/main/java/io/xpipe/app/auxw/AppAuxiliaryWindow.java index cad1a26c5..a4c7a313d 100644 --- a/app/src/main/java/io/xpipe/app/auxw/AppAuxiliaryWindow.java +++ b/app/src/main/java/io/xpipe/app/auxw/AppAuxiliaryWindow.java @@ -85,6 +85,11 @@ public class AppAuxiliaryWindow { stage.setHeight(780); stage.titleProperty().bind(PlatformThread.sync(createTitle())); + // We close this automatically after all children are gone + stage.setOnCloseRequest(event -> { + event.consume(); + }); + if (AppPrefs.get() != null) { stage.opacityProperty().bind(PlatformThread.sync(AppPrefs.get().windowOpacity())); } @@ -94,23 +99,23 @@ public class AppAuxiliaryWindow { AppWindowStyle.addFontSize(stage); AppTheme.initThemeHandlers(stage); - if (state != null) { - if (state.maximized) { - stage.setMaximized(true); - } else { - stage.setX(state.windowX); - stage.setY(state.windowY); - stage.setWidth(state.windowWidth); - stage.setHeight(state.windowHeight); - } - } - setupWindowListeners(); } + private void applyStageState() { + if (state != null) { + stage.setX(state.windowX); + stage.setY(state.windowY); + stage.setWidth(state.windowWidth); + stage.setHeight(state.windowHeight); + stage.setMaximized(state.maximized); + } + } + public void show() { PlatformThread.runLaterIfNeededBlocking(() -> { createStage(); + applyStageState(); stage.show(); nativeWinWindowControl = new NativeWinWindowControl(stage); nativeWinWindowControl.setWindowsTransitionsEnabled(false); @@ -179,7 +184,7 @@ public class AppAuxiliaryWindow { private void startStateListener() { GlobalTimer.scheduleUntil(Duration.ofMillis(500), false, () -> { - if (stage == null || !stage.isShowing()) { + if (stage == null) { return false; } @@ -222,13 +227,6 @@ public class AppAuxiliaryWindow { stage.maximizedProperty().addListener((c, o, n) -> { onWindowStateChange(); locked.set(false); - Platform.runLater(() -> { - stage.setWidth(state.getWindowWidth()); - stage.setHeight(state.getWindowHeight()); - }); - }); - locked.addListener((v, o, n) -> { - stage.setResizable(!n); }); } diff --git a/app/src/main/java/io/xpipe/app/auxw/AuxDockImpl.java b/app/src/main/java/io/xpipe/app/auxw/AuxDockImpl.java index 06aff8d8a..ebc8facf2 100644 --- a/app/src/main/java/io/xpipe/app/auxw/AuxDockImpl.java +++ b/app/src/main/java/io/xpipe/app/auxw/AuxDockImpl.java @@ -91,10 +91,6 @@ public class AuxDockImpl implements WindowDockListener { var p = e.getProcess(); if (p.isRunning()) { - // Reset style in case close is prevented by application - p.restoreIcon(); - p.disown(); - p.restoreStyle(true); p.close(); } diff --git a/app/src/main/java/io/xpipe/app/auxw/WindowDockComp.java b/app/src/main/java/io/xpipe/app/auxw/WindowDockComp.java index 6fd6df53e..0476eee74 100644 --- a/app/src/main/java/io/xpipe/app/auxw/WindowDockComp.java +++ b/app/src/main/java/io/xpipe/app/auxw/WindowDockComp.java @@ -103,7 +103,7 @@ public class WindowDockComp extends SimpleRegionBu s.heightProperty().removeListener(update); s.iconifiedProperty().removeListener(iconified); s.removeEventFilter(WindowEvent.WINDOW_SHOWN, show); - s.removeEventFilter(WindowEvent.WINDOW_HIDING, hide); + s.removeEventFilter(WindowEvent.WINDOW_CLOSE_REQUEST, hide); s.outputScaleXProperty().addListener(scale); if (parent.get() != null) { parent.get().boundsInParentProperty().removeListener(bounds); @@ -118,7 +118,7 @@ public class WindowDockComp extends SimpleRegionBu s.iconifiedProperty().addListener(iconified); s.outputScaleXProperty().removeListener(scale); s.addEventFilter(WindowEvent.WINDOW_SHOWN, show); - s.addEventFilter(WindowEvent.WINDOW_HIDING, hide); + s.addEventFilter(WindowEvent.WINDOW_CLOSE_REQUEST, hide); // As in practice this node is wrapped in another stack pane // We have to listen to the parent bounds to actually receive bounds changes stack.getParent().boundsInParentProperty().addListener(bounds);