fix: calculate frame when setting window placement (#25014)

This commit is contained in:
Cheng Zhao 2020-08-20 04:34:15 +09:00 committed by GitHub
parent 9021843850
commit 52d7afa4ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 8 deletions

View file

@ -180,11 +180,16 @@ bool NativeWindowViews::PreHandleMSG(UINT message,
LRESULT* result) {
NotifyWindowMessage(message, w_param, l_param);
// See code below for why blocking Chromium from handling messages.
if (block_chromium_message_handler_) {
// Handle the message with default proc.
// Avoid side effects when calling SetWindowPlacement.
if (is_setting_window_placement_) {
// Let Chromium handle the WM_NCCALCSIZE message otherwise the window size
// would be wrong.
// See https://github.com/electron/electron/issues/22393 for more.
if (message == WM_NCCALCSIZE)
return false;
// Otherwise handle the message with default proc,
*result = DefWindowProc(GetAcceleratedWidget(), message, w_param, l_param);
// Tell Chromium to ignore this message.
// and tell Chromium to ignore this message.
return true;
}
@ -239,9 +244,9 @@ bool NativeWindowViews::PreHandleMSG(UINT message,
// messages until the SetWindowPlacement call is done.
//
// See https://github.com/electron/electron/issues/21614 for more.
block_chromium_message_handler_ = true;
is_setting_window_placement_ = true;
SetWindowPlacement(GetAcceleratedWidget(), &wp);
block_chromium_message_handler_ = false;
is_setting_window_placement_ = false;
last_normal_placement_bounds_ = gfx::Rect();
}