Skip to content

最大化和全屏时隐藏窗口阴影#5213

Closed
neveler wants to merge 5 commits into
HMCL-dev:mainfrom
neveler:fork/p4
Closed

最大化和全屏时隐藏窗口阴影#5213
neveler wants to merge 5 commits into
HMCL-dev:mainfrom
neveler:fork/p4

Conversation

@neveler
Copy link
Copy Markdown
Contributor

@neveler neveler commented Jan 12, 2026

解决如下问题

目前最大化/全屏模式...由于自绘阴影,窗口会和显示器边缘存在一段的边距。

  • Windows 11 上应该可以解决最大化覆盖任务栏的情况,其它系统不确定。
  • 多屏环境可能出现问题。
  • 屏幕状态变化时(修改分辨率,隐藏任务栏等)可能出现问题。

@neveler
Copy link
Copy Markdown
Contributor Author

neveler commented Jan 13, 2026

窗口的圆角效果来自

parent = new StackPane();
Rectangle clip = new Rectangle();
clip.widthProperty().bind(parent.widthProperty());
clip.heightProperty().bind(parent.heightProperty());
clip.setArcWidth(8);
clip.setArcHeight(8);
parent.setClip(clip);

@Mine-diamond
Copy link
Copy Markdown
Contributor

目前在多显示器情况下在非主显示器时会出错(至少在我的电脑上是这样),会导致在其它显示器上最大化时最大化到一个不可见的地方,如图,HMCL直接跑到屏幕之外,Windows任务视图中直接不能显示HMCL当前窗口的样子

image image

也许可以这么改,该代码是能正常工作的

import javafx.scene.robot.Robot;

        //可复用
        Robot robot = new Robot();

        primaryStage.maximizedProperty().addListener((obs, oldVal, newVal) -> {
            pseudoClassStateChanged(MAXIMIZED, newVal);
            if (newVal) {
                Rectangle2D visualBounds = Screen.getScreensForRectangle(new Rectangle2D(robot.getMouseX(), robot.getMouseY(), 1, 1)).get(0).getVisualBounds();
                primaryStage.setX(visualBounds.getMinX());
                primaryStage.setY(visualBounds.getMinY());
                primaryStage.setWidth(visualBounds.getWidth());
                primaryStage.setHeight(visualBounds.getHeight());
            }
        });

@neveler neveler closed this Jan 13, 2026
@neveler neveler deleted the fork/p4 branch January 13, 2026 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants