@@ -345,24 +345,35 @@ bool NativeWindowViews::PreHandleMSG(UINT message,
345
345
return false ;
346
346
}
347
347
case WM_GETMINMAXINFO: {
348
- WINDOWPLACEMENT wp;
349
- wp.length = sizeof (WINDOWPLACEMENT);
350
-
351
- // We do this to work around a Windows bug, where the minimized Window
352
- // would report that the closest display to it is not the one that it was
353
- // previously on (but the leftmost one instead). We restore the position
354
- // of the window during the restore operation, this way chromium can
355
- // use the proper display to calculate the scale factor to use.
356
- if (!last_normal_placement_bounds_.IsEmpty () &&
357
- GetWindowPlacement (GetAcceleratedWidget (), &wp)) {
358
- last_normal_placement_bounds_.set_size (gfx::Size (0 , 0 ));
359
- wp.rcNormalPosition = last_normal_placement_bounds_.ToRECT ();
360
- SetWindowPlacement (GetAcceleratedWidget (), &wp);
361
-
362
- last_normal_placement_bounds_ = gfx::Rect ();
348
+ // We need to handle GETMINMAXINFO ourselves because chromium tries to
349
+ // get the scale factor of the window during it's version of this handler
350
+ // based on the window position, which is invalid at this point. The
351
+ // previous method of calling SetWindowPlacement fixed the window
352
+ // position for the scale factor calculation but broke other things.
353
+ MINMAXINFO* info = reinterpret_cast <MINMAXINFO*>(l_param);
354
+
355
+ display::Display display =
356
+ display::Screen::GetScreen ()->GetDisplayNearestPoint (
357
+ last_normal_placement_bounds_.origin ());
358
+
359
+ gfx::Size min_size = gfx::ScaleToCeiledSize (
360
+ widget ()->GetMinimumSize (), display.device_scale_factor ());
361
+ gfx::Size max_size = gfx::ScaleToCeiledSize (
362
+ widget ()->GetMaximumSize (), display.device_scale_factor ());
363
+
364
+ info->ptMinTrackSize .x = min_size.width ();
365
+ info->ptMinTrackSize .y = min_size.height ();
366
+ if (max_size.width () || max_size.height ()) {
367
+ if (!max_size.width ())
368
+ max_size.set_width (GetSystemMetrics (SM_CXMAXTRACK));
369
+ if (!max_size.height ())
370
+ max_size.set_height (GetSystemMetrics (SM_CYMAXTRACK));
371
+ info->ptMaxTrackSize .x = max_size.width ();
372
+ info->ptMaxTrackSize .y = max_size.height ();
363
373
}
364
374
365
- return false ;
375
+ *result = 1 ;
376
+ return true ;
366
377
}
367
378
case WM_NCCALCSIZE: {
368
379
if (!has_frame () && w_param == TRUE ) {
0 commit comments