@@ -651,39 +651,46 @@ MsgRouting AwtFrame::WmNcMouseDown(WPARAM hitTest, int x, int y, int button) {
651651
652652// Override AwtWindow::Reshape() to handle minimized/maximized
653653// frames (see 6525850, 4065534)
654- void AwtFrame::Reshape (int x, int y, int width , int height )
654+ void AwtFrame::Reshape (int x, int y, int w , int h )
655655{
656656 if (isIconic ()) {
657657 // normal AwtComponent::Reshape will not work for iconified windows so...
658+ POINT pt = {x + w / 2 , y + h / 2 };
659+ Devices::InstanceAccess devices;
660+ HMONITOR monitor = MonitorFromPoint (pt, MONITOR_DEFAULTTONEAREST);
661+ int screen = AwtWin32GraphicsDevice::GetScreenFromHMONITOR (monitor);
662+ AwtWin32GraphicsDevice *device = devices->GetDevice (screen);
663+ // Try to set the correct size and jump to the correct location, even if
664+ // it is on the different monitor. Note that for the "size" we use the
665+ // current monitor, so the WM_DPICHANGED will adjust it for the "target"
666+ // monitor.
667+ MONITORINFO *miInfo = AwtWin32GraphicsDevice::GetMonitorInfo (screen);
668+ x = device == NULL ? x : device->ScaleUpAbsX (x);
669+ y = device == NULL ? y : device->ScaleUpAbsY (y);
670+ w = ScaleUpX (w);
671+ h = ScaleUpY (h);
672+ // SetWindowPlacement takes workspace coordinates, but if taskbar is at
673+ // top/left of screen, workspace coords != screen coords, so offset by
674+ // workspace origin
675+ x = x - (miInfo->rcWork .left - miInfo->rcMonitor .left );
676+ y = y - (miInfo->rcWork .top - miInfo->rcMonitor .top );
658677 WINDOWPLACEMENT wp;
659- POINT ptMinPosition = {x,y};
660- POINT ptMaxPosition = {0 ,0 };
661- RECT rcNormalPosition = {x,y,x+width,y+height};
662- RECT rcWorkspace;
663- HWND hWndDesktop = GetDesktopWindow ();
664- HWND hWndSelf = GetHWnd ();
665-
666- // SetWindowPlacement takes workspace coordinates, but
667- // if taskbar is at top of screen, workspace coords !=
668- // screen coords, so offset by workspace origin
669- VERIFY (::SystemParametersInfo (SPI_GETWORKAREA, 0 , (PVOID)&rcWorkspace, 0 ));
670- ::OffsetRect (&rcNormalPosition, -rcWorkspace.left, -rcWorkspace.top);
671-
678+ ::ZeroMemory (&wp, sizeof (WINDOWPLACEMENT));
672679 // set the window size for when it is not-iconified
673680 wp.length = sizeof (wp);
674681 wp.flags = WPF_SETMINPOSITION;
675682 wp.showCmd = IsVisible () ? SW_SHOWMINIMIZED : SW_HIDE;
676- wp.ptMinPosition = ptMinPosition ;
677- wp.ptMaxPosition = ptMaxPosition ;
678- wp.rcNormalPosition = rcNormalPosition ;
683+ wp.ptMinPosition = {x, y} ;
684+ wp.ptMaxPosition = { 0 , 0 } ;
685+ wp.rcNormalPosition = {x, y, x + w, y + h} ;
679686
680687 // If the call is not guarded with ignoreWmSize,
681688 // a regression for bug 4851435 appears.
682689 // Having this call guarded also prevents
683690 // changing the iconified state of the frame
684691 // while calling the Frame.setBounds() method.
685692 m_ignoreWmSize = TRUE ;
686- ::SetWindowPlacement (hWndSelf , &wp);
693+ ::SetWindowPlacement (GetHWnd() , &wp);
687694 m_ignoreWmSize = FALSE ;
688695
689696 return ;
@@ -703,7 +710,7 @@ void AwtFrame::Reshape(int x, int y, int width, int height)
703710 }
704711 }
705712
706- AwtWindow::Reshape (x, y, width, height );
713+ AwtWindow::Reshape (x, y, w, h );
707714}
708715
709716
0 commit comments