diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/Controllers.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/Controllers.java index 570ef874b..ff4b5de72 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/Controllers.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/Controllers.java @@ -217,8 +217,10 @@ public final class Controllers { if (targetProperty != null && Controllers.stage != null && !Controllers.stage.isIconified() - && !Controllers.stage.isFullScreen() - && !Controllers.stage.isMaximized()) { + // https://github.com/HMCL-dev/HMCL/issues/4290 + && (OperatingSystem.CURRENT_OS == OperatingSystem.MACOS || + !Controllers.stage.isFullScreen() && !Controllers.stage.isMaximized()) + ) { targetProperty.set(sourceProperty.get()); } }; diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/decorator/DecoratorController.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/decorator/DecoratorController.java index e8a2a03ec..523b4657c 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/decorator/DecoratorController.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/decorator/DecoratorController.java @@ -58,6 +58,7 @@ import org.jackhuang.hmcl.ui.construct.JFXDialogPane; import org.jackhuang.hmcl.ui.wizard.Refreshable; import org.jackhuang.hmcl.ui.wizard.WizardProvider; import org.jackhuang.hmcl.util.Lang; +import org.jackhuang.hmcl.util.platform.OperatingSystem; import org.jetbrains.annotations.Nullable; import java.io.IOException; @@ -164,13 +165,16 @@ public class DecoratorController { // press ESC to go back onEscPressed(navigator, this::back); - // press F11 to toggle full screen - navigator.addEventHandler(KeyEvent.KEY_PRESSED, e -> { - if (e.getCode() == KeyCode.F11) { - stage.setFullScreen(!stage.isFullScreen()); - e.consume(); - } - }); + // https://github.com/HMCL-dev/HMCL/issues/4290 + if (OperatingSystem.CURRENT_OS != OperatingSystem.MACOS) { + // press F11 to toggle full screen + navigator.addEventHandler(KeyEvent.KEY_PRESSED, e -> { + if (e.getCode() == KeyCode.F11) { + stage.setFullScreen(!stage.isFullScreen()); + e.consume(); + } + }); + } try { // For JavaFX 12+ diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/decorator/DecoratorSkin.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/decorator/DecoratorSkin.java index c182dbcb4..e2047009c 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/decorator/DecoratorSkin.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/decorator/DecoratorSkin.java @@ -47,6 +47,7 @@ import org.jackhuang.hmcl.ui.animation.AnimationProducer; import org.jackhuang.hmcl.ui.animation.ContainerAnimations; import org.jackhuang.hmcl.ui.animation.TransitionPane; import org.jackhuang.hmcl.ui.wizard.Navigation; +import org.jackhuang.hmcl.util.platform.OperatingSystem; public class DecoratorSkin extends SkinBase { private final StackPane root, parent; @@ -89,22 +90,31 @@ public class DecoratorSkin extends SkinBase { EventHandler onMouseReleased = this::onMouseReleased; EventHandler onMouseDragged = this::onMouseDragged; EventHandler onMouseMoved = this::onMouseMoved; - onWindowsStatusChange = observable -> { - if (primaryStage.isIconified() || primaryStage.isFullScreen() || primaryStage.isMaximized()) { - root.removeEventFilter(MouseEvent.MOUSE_RELEASED, onMouseReleased); - root.removeEventFilter(MouseEvent.MOUSE_DRAGGED, onMouseDragged); - root.removeEventFilter(MouseEvent.MOUSE_MOVED, onMouseMoved); - } else { - root.addEventFilter(MouseEvent.MOUSE_RELEASED, onMouseReleased); - root.addEventFilter(MouseEvent.MOUSE_DRAGGED, onMouseDragged); - root.addEventFilter(MouseEvent.MOUSE_MOVED, onMouseMoved); - } - }; - WeakInvalidationListener weakOnWindowsStatusChange = new WeakInvalidationListener(onWindowsStatusChange); - primaryStage.iconifiedProperty().addListener(weakOnWindowsStatusChange); - primaryStage.maximizedProperty().addListener(weakOnWindowsStatusChange); - primaryStage.fullScreenProperty().addListener(weakOnWindowsStatusChange); - onWindowsStatusChange.invalidated(null); + + // https://github.com/HMCL-dev/HMCL/issues/4290 + if (OperatingSystem.CURRENT_OS != OperatingSystem.MACOS) { + onWindowsStatusChange = observable -> { + if (primaryStage.isIconified() || primaryStage.isFullScreen() || primaryStage.isMaximized()) { + root.removeEventFilter(MouseEvent.MOUSE_RELEASED, onMouseReleased); + root.removeEventFilter(MouseEvent.MOUSE_DRAGGED, onMouseDragged); + root.removeEventFilter(MouseEvent.MOUSE_MOVED, onMouseMoved); + } else { + root.addEventFilter(MouseEvent.MOUSE_RELEASED, onMouseReleased); + root.addEventFilter(MouseEvent.MOUSE_DRAGGED, onMouseDragged); + root.addEventFilter(MouseEvent.MOUSE_MOVED, onMouseMoved); + } + }; + WeakInvalidationListener weakOnWindowsStatusChange = new WeakInvalidationListener(onWindowsStatusChange); + primaryStage.iconifiedProperty().addListener(weakOnWindowsStatusChange); + primaryStage.maximizedProperty().addListener(weakOnWindowsStatusChange); + primaryStage.fullScreenProperty().addListener(weakOnWindowsStatusChange); + onWindowsStatusChange.invalidated(null); + } else { + onWindowsStatusChange = null; + root.addEventFilter(MouseEvent.MOUSE_RELEASED, onMouseReleased); + root.addEventFilter(MouseEvent.MOUSE_DRAGGED, onMouseDragged); + root.addEventFilter(MouseEvent.MOUSE_MOVED, onMouseMoved); + } shadowContainer.getChildren().setAll(parent); root.getChildren().setAll(shadowContainer); @@ -177,12 +187,16 @@ public class DecoratorSkin extends SkinBase { BorderPane titleBar = new BorderPane(); titleContainer.getChildren().add(titleBar); - titleBar.addEventHandler(MouseEvent.MOUSE_CLICKED, event -> { - if (event.getButton() == MouseButton.PRIMARY && event.getClickCount() == 2) { - primaryStage.setMaximized(!primaryStage.isMaximized()); - event.consume(); - } - }); + + // https://github.com/HMCL-dev/HMCL/issues/4290 + if (OperatingSystem.CURRENT_OS != OperatingSystem.MACOS) { + titleBar.addEventHandler(MouseEvent.MOUSE_CLICKED, event -> { + if (event.getButton() == MouseButton.PRIMARY && event.getClickCount() == 2) { + primaryStage.setMaximized(!primaryStage.isMaximized()); + event.consume(); + } + }); + } Rectangle buttonsContainerPlaceHolder = new Rectangle(); {