Skip to content

Commit

Permalink
8301616: Drag & maximize to another monitor places window incorrectly…
Browse files Browse the repository at this point in the history
… (Windows)

Reviewed-by: avu, aivanov, serb
  • Loading branch information
YaaZ authored and Alexey Ushakov committed Apr 5, 2023
1 parent a3137c7 commit f69d88c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/java.desktop/windows/native/libawt/windows/awt_Window.cpp
Expand Up @@ -371,6 +371,20 @@ void AwtWindow::RepositionSecurityWarning(JNIEnv *env)
MsgRouting AwtWindow::WmWindowPosChanged(LPARAM windowPos) {
WINDOWPOS * wp = (WINDOWPOS *)windowPos;

// There's no good way to detect partial maximization (e.g. Aero Snap),
// but by inspecting SWP_* flags we can guess it and reset
// prevScaleRec to neutralize the CheckWindowDPIChange logic.
// Here are the flags, observed on Windows 11 for reference:
// Restore/maximize: SWP_NOZORDER | SWP_DRAWFRAME
// Partial Aero Snap: SWP_NOZORDER | SWP_NOREPOSITION
// DPI change (new screen): SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOCOPYBITS
if (!(wp->flags & (SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE)) &&
prevScaleRec.screen != -1 && prevScaleRec.screen != m_screenNum) {
prevScaleRec.screen = -1;
prevScaleRec.scaleX = -1.0f;
prevScaleRec.scaleY = -1.0f;
}

// Reposition the warning window
if (IsUntrusted() && warningWindow != NULL) {
if (wp->flags & SWP_HIDEWINDOW) {
Expand Down

1 comment on commit f69d88c

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

Please sign in to comment.