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

Side by Side Diff: ui/views/widget/native_widget_win.cc

Issue 10828395: Move more message handlers from NativeWidgetWin to HWNDMessageHandler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « ui/views/widget/native_widget_win.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/widget/native_widget_win.h" 5 #include "ui/views/widget/native_widget_win.h"
6 6
7 #include <dwmapi.h> 7 #include <dwmapi.h>
8 #include <shellapi.h> 8 #include <shellapi.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 WindowImpl::Init(params.GetParent(), params.bounds); 537 WindowImpl::Init(params.GetParent(), params.bounds);
538 } 538 }
539 539
540 NonClientFrameView* NativeWidgetWin::CreateNonClientFrameView() { 540 NonClientFrameView* NativeWidgetWin::CreateNonClientFrameView() {
541 return GetWidget()->ShouldUseNativeFrame() ? 541 return GetWidget()->ShouldUseNativeFrame() ?
542 new NativeFrameView(GetWidget()) : NULL; 542 new NativeFrameView(GetWidget()) : NULL;
543 } 543 }
544 544
545 void NativeWidgetWin::UpdateFrameAfterFrameChange() { 545 void NativeWidgetWin::UpdateFrameAfterFrameChange() {
546 // We've either gained or lost a custom window region, so reset it now. 546 // We've either gained or lost a custom window region, so reset it now.
547 ResetWindowRegion(true); 547 message_handler_->ResetWindowRegion(true);
548 } 548 }
549 549
550 bool NativeWidgetWin::ShouldUseNativeFrame() const { 550 bool NativeWidgetWin::ShouldUseNativeFrame() const {
551 return IsAeroGlassEnabled(); 551 return IsAeroGlassEnabled();
552 } 552 }
553 553
554 void NativeWidgetWin::FrameTypeChanged() { 554 void NativeWidgetWin::FrameTypeChanged() {
555 // Called when the frame type could possibly be changing (theme change or 555 // Called when the frame type could possibly be changing (theme change or
556 // DWM composition change). 556 // DWM composition change).
557 if (base::win::GetVersion() >= base::win::VERSION_VISTA) { 557 if (base::win::GetVersion() >= base::win::VERSION_VISTA) {
(...skipping 1341 matching lines...) Expand 10 before | Expand all | Expand 10 after
1899 SetMsgHandled(TRUE); 1899 SetMsgHandled(TRUE);
1900 } else { 1900 } else {
1901 // TODO(beng): move to Widget. 1901 // TODO(beng): move to Widget.
1902 if (flags == SPI_SETWORKAREA) 1902 if (flags == SPI_SETWORKAREA)
1903 GetWidget()->widget_delegate()->OnWorkAreaChanged(); 1903 GetWidget()->widget_delegate()->OnWorkAreaChanged();
1904 SetMsgHandled(FALSE); 1904 SetMsgHandled(FALSE);
1905 } 1905 }
1906 } 1906 }
1907 1907
1908 void NativeWidgetWin::OnSize(UINT param, const CSize& size) { 1908 void NativeWidgetWin::OnSize(UINT param, const CSize& size) {
1909 RedrawWindow(GetNativeView(), NULL, NULL, RDW_INVALIDATE | RDW_ALLCHILDREN); 1909 message_handler_->OnSize(param, size);
1910 // ResetWindowRegion is going to trigger WM_NCPAINT. By doing it after we've
1911 // invoked OnSize we ensure the RootView has been laid out.
1912 ResetWindowRegion(false);
1913 } 1910 }
1914 1911
1915 void NativeWidgetWin::OnSysCommand(UINT notification_code, CPoint click) { 1912 void NativeWidgetWin::OnSysCommand(UINT notification_code, CPoint click) {
1916 if (!GetWidget()->non_client_view()) 1913 if (!GetWidget()->non_client_view())
1917 return; 1914 return;
1918 1915
1919 // Windows uses the 4 lower order bits of |notification_code| for type- 1916 // Windows uses the 4 lower order bits of |notification_code| for type-
1920 // specific information so we must exclude this when comparing. 1917 // specific information so we must exclude this when comparing.
1921 static const int sc_mask = 0xFFF0; 1918 static const int sc_mask = 0xFFF0;
1922 // Ignore size/move/maximize in fullscreen mode. 1919 // Ignore size/move/maximize in fullscreen mode.
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after
2493 if (use_layered_buffer_) 2490 if (use_layered_buffer_)
2494 layered_window_contents_.reset( 2491 layered_window_contents_.reset(
2495 new gfx::Canvas(s, ui::SCALE_FACTOR_100P, false)); 2492 new gfx::Canvas(s, ui::SCALE_FACTOR_100P, false));
2496 } 2493 }
2497 2494
2498 void NativeWidgetWin::UpdateDWMFrame() { 2495 void NativeWidgetWin::UpdateDWMFrame() {
2499 MARGINS m = {10, 10, 10, 10}; 2496 MARGINS m = {10, 10, 10, 10};
2500 DwmExtendFrameIntoClientArea(GetNativeView(), &m); 2497 DwmExtendFrameIntoClientArea(GetNativeView(), &m);
2501 } 2498 }
2502 2499
2503 void NativeWidgetWin::ResetWindowRegion(bool force) {
2504 // A native frame uses the native window region, and we don't want to mess
2505 // with it.
2506 if (GetWidget()->ShouldUseNativeFrame() || !GetWidget()->non_client_view()) {
2507 if (force)
2508 SetWindowRgn(NULL, TRUE);
2509 return;
2510 }
2511
2512 // Changing the window region is going to force a paint. Only change the
2513 // window region if the region really differs.
2514 HRGN current_rgn = CreateRectRgn(0, 0, 0, 0);
2515 int current_rgn_result = GetWindowRgn(GetNativeView(), current_rgn);
2516
2517 CRect window_rect;
2518 GetWindowRect(&window_rect);
2519 HRGN new_region;
2520 if (IsMaximized()) {
2521 HMONITOR monitor =
2522 MonitorFromWindow(GetNativeView(), MONITOR_DEFAULTTONEAREST);
2523 MONITORINFO mi;
2524 mi.cbSize = sizeof mi;
2525 GetMonitorInfo(monitor, &mi);
2526 CRect work_rect = mi.rcWork;
2527 work_rect.OffsetRect(-window_rect.left, -window_rect.top);
2528 new_region = CreateRectRgnIndirect(&work_rect);
2529 } else {
2530 gfx::Path window_mask;
2531 GetWidget()->non_client_view()->GetWindowMask(
2532 gfx::Size(window_rect.Width(), window_rect.Height()), &window_mask);
2533 new_region = window_mask.CreateNativeRegion();
2534 }
2535
2536 if (current_rgn_result == ERROR || !EqualRgn(current_rgn, new_region)) {
2537 // SetWindowRgn takes ownership of the HRGN created by CreateNativeRegion.
2538 SetWindowRgn(new_region, TRUE);
2539 } else {
2540 DeleteObject(new_region);
2541 }
2542
2543 DeleteObject(current_rgn);
2544 }
2545
2546 LRESULT NativeWidgetWin::DefWindowProcWithRedrawLock(UINT message, 2500 LRESULT NativeWidgetWin::DefWindowProcWithRedrawLock(UINT message,
2547 WPARAM w_param, 2501 WPARAM w_param,
2548 LPARAM l_param) { 2502 LPARAM l_param) {
2549 ScopedRedrawLock lock(this); 2503 ScopedRedrawLock lock(this);
2550 // The Widget and HWND can be destroyed in the call to DefWindowProc, so use 2504 // The Widget and HWND can be destroyed in the call to DefWindowProc, so use
2551 // the |destroyed_| flag to avoid unlocking (and crashing) after destruction. 2505 // the |destroyed_| flag to avoid unlocking (and crashing) after destruction.
2552 bool destroyed = false; 2506 bool destroyed = false;
2553 destroyed_ = &destroyed; 2507 destroyed_ = &destroyed;
2554 LRESULT result = DefWindowProc(GetNativeView(), message, w_param, l_param); 2508 LRESULT result = DefWindowProc(GetNativeView(), message, w_param, l_param);
2555 if (destroyed) 2509 if (destroyed)
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
2748 // static 2702 // static
2749 bool NativeWidgetPrivate::IsTouchDown() { 2703 bool NativeWidgetPrivate::IsTouchDown() {
2750 // This currently isn't necessary because we're not generating touch events on 2704 // This currently isn't necessary because we're not generating touch events on
2751 // windows. When we do, this will need to be updated. 2705 // windows. When we do, this will need to be updated.
2752 return false; 2706 return false;
2753 } 2707 }
2754 2708
2755 } // namespace internal 2709 } // namespace internal
2756 2710
2757 } // namespace views 2711 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/native_widget_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698