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