@@ -239,6 +239,15 @@ int GetAppbarAutohideEdges(HWND hwnd) {
239
239
return edges;
240
240
}
241
241
242
+ void TriggerNCCalcSize (HWND hwnd) {
243
+ RECT rcClient;
244
+ ::GetWindowRect (hwnd, &rcClient);
245
+
246
+ ::SetWindowPos (hwnd, NULL , rcClient.left, rcClient.top,
247
+ rcClient.right - rcClient.left, rcClient.bottom - rcClient.top,
248
+ SWP_FRAMECHANGED);
249
+ }
250
+
242
251
} // namespace
243
252
244
253
std::set<NativeWindowViews*> NativeWindowViews::forwarding_windows_;
@@ -369,8 +378,12 @@ bool NativeWindowViews::PreHandleMSG(UINT message,
369
378
// https://blogs.msdn.microsoft.com/wpfsdk/2008/09/08/custom-window-chrome-in-wpf/
370
379
DefWindowProcW (GetAcceleratedWidget (), WM_NCCALCSIZE, w_param, l_param);
371
380
372
- params->rgrc [0 ] = PROPOSED;
373
- params->rgrc [1 ] = BEFORE;
381
+ if (last_window_state_ == ui::SHOW_STATE_MAXIMIZED) {
382
+ params->rgrc [0 ].top = 0 ;
383
+ } else {
384
+ params->rgrc [0 ] = PROPOSED;
385
+ params->rgrc [1 ] = BEFORE;
386
+ }
374
387
375
388
return true ;
376
389
} else {
@@ -453,26 +466,15 @@ void NativeWindowViews::HandleSizeEvent(WPARAM w_param, LPARAM l_param) {
453
466
// window state and notify the user accordingly.
454
467
switch (w_param) {
455
468
case SIZE_MAXIMIZED: {
456
- // Frameless maximized windows are size compensated by Windows for a
457
- // border that's not actually there, so we must conter-compensate.
458
- // https://blogs.msdn.microsoft.com/wpfsdk/2008/09/08/custom-window-chrome-in-wpf/
459
- if (!has_frame ()) {
460
- float scale_factor = display::win::ScreenWin::GetScaleFactorForHWND (
461
- GetAcceleratedWidget ());
462
-
463
- int border =
464
- GetSystemMetrics (SM_CXFRAME) + GetSystemMetrics (SM_CXPADDEDBORDER);
465
- if (!thick_frame_) {
466
- border -= GetSystemMetrics (SM_CXBORDER);
467
- }
468
- root_view_->SetInsets (gfx::Insets (border).Scale (1 .0f / scale_factor));
469
- }
470
-
471
469
last_window_state_ = ui::SHOW_STATE_MAXIMIZED;
472
470
if (consecutive_moves_) {
473
471
last_normal_bounds_ = last_normal_bounds_before_move_;
474
472
}
475
473
474
+ if (!has_frame ()) {
475
+ TriggerNCCalcSize (GetAcceleratedWidget ());
476
+ }
477
+
476
478
NotifyWindowMaximize ();
477
479
break ;
478
480
}
@@ -497,8 +499,12 @@ void NativeWindowViews::HandleSizeEvent(WPARAM w_param, LPARAM l_param) {
497
499
switch (last_window_state_) {
498
500
case ui::SHOW_STATE_MAXIMIZED:
499
501
last_window_state_ = ui::SHOW_STATE_NORMAL;
500
- root_view_->SetInsets (gfx::Insets (0 ));
501
502
NotifyWindowUnmaximize ();
503
+
504
+ if (!has_frame ()) {
505
+ TriggerNCCalcSize (GetAcceleratedWidget ());
506
+ }
507
+
502
508
break ;
503
509
case ui::SHOW_STATE_MINIMIZED:
504
510
if (IsFullscreen ()) {
0 commit comments