Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: ui/views/win/hwnd_message_handler.cc

Issue 1903223005: Fix for 593676 - Minimizes/eliminates momentary flash of Windows frame (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Better solution to minimize/eliminate 'ghost' frame when showing/hiding borderless window Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/win/hwnd_message_handler.h" 5 #include "ui/views/win/hwnd_message_handler.h"
6 6
7 #include <dwmapi.h> 7 #include <dwmapi.h>
8 #include <oleacc.h> 8 #include <oleacc.h>
9 #include <shellapi.h> 9 #include <shellapi.h>
10 #include <tchar.h> 10 #include <tchar.h>
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 *show_state = ui::SHOW_STATE_NORMAL; 515 *show_state = ui::SHOW_STATE_NORMAL;
516 } 516 }
517 } 517 }
518 518
519 void HWNDMessageHandler::SetBounds(const gfx::Rect& bounds_in_pixels, 519 void HWNDMessageHandler::SetBounds(const gfx::Rect& bounds_in_pixels,
520 bool force_size_changed) { 520 bool force_size_changed) {
521 background_fullscreen_hack_ = false; 521 background_fullscreen_hack_ = false;
522 SetBoundsInternal(bounds_in_pixels, force_size_changed); 522 SetBoundsInternal(bounds_in_pixels, force_size_changed);
523 } 523 }
524 524
525 void HWNDMessageHandler::SetDwmFrameExtension(DwmFrameState state) {
526 if (!delegate_->HasFrame() && ui::win::IsAeroGlassEnabled() &&
527 (window_ex_style() & WS_EX_COMPOSITED) == 0) {
528 MARGINS m = {0, 0, 0, 0};
529 if (state == DwmFrameState::ON)
530 m = {0, 0, 1, 0};
531 DwmExtendFrameIntoClientArea(hwnd(), &m);
532 }
533 }
534
525 void HWNDMessageHandler::SetSize(const gfx::Size& size) { 535 void HWNDMessageHandler::SetSize(const gfx::Size& size) {
526 SetWindowPos(hwnd(), NULL, 0, 0, size.width(), size.height(), 536 SetWindowPos(hwnd(), NULL, 0, 0, size.width(), size.height(),
527 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE); 537 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE);
528 } 538 }
529 539
530 void HWNDMessageHandler::CenterWindow(const gfx::Size& size) { 540 void HWNDMessageHandler::CenterWindow(const gfx::Size& size) {
531 HWND parent = GetParent(hwnd()); 541 HWND parent = GetParent(hwnd());
532 if (!IsWindow(hwnd())) 542 if (!IsWindow(hwnd()))
533 parent = ::GetWindow(hwnd(), GW_OWNER); 543 parent = ::GetWindow(hwnd(), GW_OWNER);
534 gfx::CenterAndSizeWindow(parent, hwnd(), size); 544 gfx::CenterAndSizeWindow(parent, hwnd(), size);
(...skipping 1806 matching lines...) Expand 10 before | Expand all | Expand 10 after
2341 } 2351 }
2342 2352
2343 if (ScopedFullscreenVisibility::IsHiddenForFullscreen(hwnd())) { 2353 if (ScopedFullscreenVisibility::IsHiddenForFullscreen(hwnd())) {
2344 // Prevent the window from being made visible if we've been asked to do so. 2354 // Prevent the window from being made visible if we've been asked to do so.
2345 // See comment in header as to why we might want this. 2355 // See comment in header as to why we might want this.
2346 window_pos->flags &= ~SWP_SHOWWINDOW; 2356 window_pos->flags &= ~SWP_SHOWWINDOW;
2347 } 2357 }
2348 2358
2349 if (window_pos->flags & SWP_SHOWWINDOW) 2359 if (window_pos->flags & SWP_SHOWWINDOW)
2350 delegate_->HandleVisibilityChanging(true); 2360 delegate_->HandleVisibilityChanging(true);
2351 else if (window_pos->flags & SWP_HIDEWINDOW) 2361 else if (window_pos->flags & SWP_HIDEWINDOW) {
2362 SetDwmFrameExtension(DwmFrameState::OFF);
2352 delegate_->HandleVisibilityChanging(false); 2363 delegate_->HandleVisibilityChanging(false);
2364 }
2353 2365
2354 SetMsgHandled(FALSE); 2366 SetMsgHandled(FALSE);
2355 } 2367 }
2356 2368
2357 void HWNDMessageHandler::OnWindowPosChanged(WINDOWPOS* window_pos) { 2369 void HWNDMessageHandler::OnWindowPosChanged(WINDOWPOS* window_pos) {
2358 if (DidClientAreaSizeChange(window_pos)) 2370 if (DidClientAreaSizeChange(window_pos))
2359 ClientAreaSizeChanged(); 2371 ClientAreaSizeChanged();
2360 if (!delegate_->HasFrame() && window_pos->flags & SWP_FRAMECHANGED && 2372 if (window_pos->flags & SWP_FRAMECHANGED)
2361 ui::win::IsAeroGlassEnabled() && 2373 SetDwmFrameExtension(DwmFrameState::ON);
2362 (window_ex_style() & WS_EX_COMPOSITED) == 0) {
2363 MARGINS m = {10, 10, 10, 10};
2364 DwmExtendFrameIntoClientArea(hwnd(), &m);
2365 }
2366 if (window_pos->flags & SWP_SHOWWINDOW) { 2374 if (window_pos->flags & SWP_SHOWWINDOW) {
2367 delegate_->HandleVisibilityChanged(true); 2375 delegate_->HandleVisibilityChanged(true);
2368 if (direct_manipulation_helper_) 2376 if (direct_manipulation_helper_)
2369 direct_manipulation_helper_->Activate(hwnd()); 2377 direct_manipulation_helper_->Activate(hwnd());
2378 SetDwmFrameExtension(DwmFrameState::ON);
2370 } else if (window_pos->flags & SWP_HIDEWINDOW) { 2379 } else if (window_pos->flags & SWP_HIDEWINDOW) {
2371 delegate_->HandleVisibilityChanged(false); 2380 delegate_->HandleVisibilityChanged(false);
2372 if (direct_manipulation_helper_) 2381 if (direct_manipulation_helper_)
2373 direct_manipulation_helper_->Deactivate(hwnd()); 2382 direct_manipulation_helper_->Deactivate(hwnd());
2374 } 2383 }
2375 if (sent_window_size_changing_) { 2384 if (sent_window_size_changing_) {
2376 sent_window_size_changing_ = false; 2385 sent_window_size_changing_ = false;
2377 delegate_->HandleWindowSizeChanged(); 2386 delegate_->HandleWindowSizeChanged();
2378 } 2387 }
2379 SetMsgHandled(FALSE); 2388 SetMsgHandled(FALSE);
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
2736 MONITORINFO monitor_info = {sizeof(monitor_info)}; 2745 MONITORINFO monitor_info = {sizeof(monitor_info)};
2737 GetMonitorInfo(MonitorFromWindow(hwnd(), MONITOR_DEFAULTTOPRIMARY), 2746 GetMonitorInfo(MonitorFromWindow(hwnd(), MONITOR_DEFAULTTOPRIMARY),
2738 &monitor_info); 2747 &monitor_info);
2739 gfx::Rect shrunk_rect(monitor_info.rcMonitor); 2748 gfx::Rect shrunk_rect(monitor_info.rcMonitor);
2740 shrunk_rect.set_height(shrunk_rect.height() - 1); 2749 shrunk_rect.set_height(shrunk_rect.height() - 1);
2741 background_fullscreen_hack_ = true; 2750 background_fullscreen_hack_ = true;
2742 SetBoundsInternal(shrunk_rect, false); 2751 SetBoundsInternal(shrunk_rect, false);
2743 } 2752 }
2744 2753
2745 } // namespace views 2754 } // namespace views
OLDNEW
« ui/views/win/hwnd_message_handler.h ('K') | « ui/views/win/hwnd_message_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698