Skip to content

Conversation

@neveler
Copy link
Contributor

@neveler neveler commented Jan 9, 2026

close #5138

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements support for exiting the maximized window state by dragging the title bar, addressing feature request #5138. When a maximized window's title bar is dragged, the window should un-maximize and follow the cursor.

Changes:

  • Enabled mouse event handling when window is maximized
  • Added logic to detect dragging on maximized windows and exit maximized state

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


if (primaryStage.isMaximized()) {
primaryStage.setMaximized(false);
mouseInitX = primaryStage.getWidth() / 2;
Copy link

Copilot AI Jan 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When exiting maximized state during a drag operation, only mouseInitX is being updated but mouseInitY is not. This will cause incorrect vertical positioning when the user drags the window. Both coordinates should be updated to ensure the window follows the cursor properly. Additionally, stageInitX and stageInitY should be set to the new window position after un-maximizing to ensure proper drag calculations.

Suggested change
mouseInitX = primaryStage.getWidth() / 2;
// Reinitialize drag reference points after restoring from maximized state
mouseInitX = mouseEvent.getScreenX();
mouseInitY = mouseEvent.getScreenY();
stageInitX = primaryStage.getX();
stageInitY = primaryStage.getY();
stageInitWidth = primaryStage.getWidth();
stageInitHeight = primaryStage.getHeight();

Copilot uses AI. Check for mistakes.
@neveler neveler marked this pull request as draft January 10, 2026 13:21
@neveler neveler closed this Jan 13, 2026
@neveler neveler deleted the fork/p1 branch January 13, 2026 13:23
@Glavo
Copy link
Member

Glavo commented Jan 13, 2026

我觉得这个还是有用的。

@neveler neveler restored the fork/p1 branch January 13, 2026 13:30
@neveler neveler reopened this Jan 13, 2026
@Glavo Glavo requested a review from Copilot January 15, 2026 14:13
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +339 to +340
primaryStage.setY(stageInitY = 0);
primaryStage.setX(stageInitX = mouseInitX - stageInitWidth / 2);
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic doesn't continue dragging after un-maximizing. After setting dragging to true and un-maximizing, the window is positioned but subsequent mouse movement won't move the window until the user releases and starts dragging again. The existing onMouseDragged handler (line 450) expects stageInitX and stageInitY to represent the initial stage position, not 0. Consider setting stageInitX and stageInitY to the calculated position values (mouseInitX - stageInitWidth / 2 and 0 respectively) after setting the stage position, so the subsequent dragging in onMouseDragged continues smoothly.

Suggested change
primaryStage.setY(stageInitY = 0);
primaryStage.setX(stageInitX = mouseInitX - stageInitWidth / 2);
double newStageY = 0;
double newStageX = mouseInitX - stageInitWidth / 2;
primaryStage.setY(newStageY);
primaryStage.setX(newStageX);
stageInitY = newStageY;
stageInitX = newStageX;

Copilot uses AI. Check for mistakes.
}
if (onTitleBarDoubleClick != null)
center.setOnMouseClicked(onTitleBarDoubleClick);
center.setOnMouseDragged(mouseEvent -> {
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This handler only handles the initial un-maximize action but doesn't consume the event or continue the drag. After un-maximizing, you should either consume the event or delegate to the existing onMouseDragged logic to ensure smooth continuous dragging. Without this, there's a disconnect between the un-maximize action and subsequent drag behavior.

Copilot uses AI. Check for mistakes.
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.

[Feature] 窗口最大化时应支持通过拖动标题栏来退出最大化状态

2 participants