JBR-4466 fix mouse event coordinates for non-client events with custom window decorations
diff --git a/src/java.desktop/windows/native/libawt/windows/awt_Frame.cpp b/src/java.desktop/windows/native/libawt/windows/awt_Frame.cpp
index d5f7490..4f40cbf 100644
--- a/src/java.desktop/windows/native/libawt/windows/awt_Frame.cpp
+++ b/src/java.desktop/windows/native/libawt/windows/awt_Frame.cpp
@@ -631,11 +631,13 @@
case HTMAXBUTTON:
case HTCLOSE:
case HTMENU:
- RECT rcWindow;
- GetWindowRect(GetHWnd(), &rcWindow);
+ POINT myPos;
+ myPos.x = x;
+ myPos.y = y;
+ ::ScreenToClient(GetHWnd(), &myPos);
WmMouseDown(GetButtonMK(button),
- x - rcWindow.left,
- y - rcWindow.top,
+ myPos.x,
+ myPos.y,
button);
return mrConsume;
}
@@ -680,9 +682,11 @@
case HTCLOSE:
case HTMENU:
case HTCAPTION:
- RECT rcWindow;
- GetWindowRect(GetHWnd(), &rcWindow);
- WmMouseMove(0, x - rcWindow.left, y - rcWindow.top);
+ POINT myPos;
+ myPos.x = x;
+ myPos.y = y;
+ ::ScreenToClient(GetHWnd(), &myPos);
+ WmMouseMove(0, myPos.x, myPos.y);
if (hitTest != HTCAPTION) return mrConsume; // Preserve default window drag for HTCAPTION
}
}