OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/views/widget/widget_win.h" | 5 #include "chrome/views/widget/widget_win.h" |
6 | 6 |
7 #include "base/gfx/native_theme.h" | 7 #include "base/gfx/native_theme.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/win_util.h" | 9 #include "base/win_util.h" |
10 #include "chrome/app/chrome_dll_resource.h" | 10 #include "chrome/app/chrome_dll_resource.h" |
11 #include "chrome/common/gfx/chrome_canvas.h" | 11 #include "chrome/common/gfx/chrome_canvas.h" |
12 #include "chrome/common/notification_service.h" | 12 #include "chrome/common/notification_service.h" |
13 #include "chrome/common/win_util.h" | 13 #include "chrome/common/win_util.h" |
14 #include "chrome/views/accessibility/view_accessibility.h" | 14 #include "chrome/views/accessibility/view_accessibility.h" |
15 #include "chrome/views/controls/native_control_win.h" | 15 #include "chrome/views/controls/native_control_win.h" |
16 #include "chrome/views/fill_layout.h" | 16 #include "chrome/views/fill_layout.h" |
| 17 #include "chrome/views/focus/focus_util_win.h" |
17 #include "chrome/views/widget/aero_tooltip_manager.h" | 18 #include "chrome/views/widget/aero_tooltip_manager.h" |
18 #include "chrome/views/widget/hwnd_notification_source.h" | 19 #include "chrome/views/widget/hwnd_notification_source.h" |
19 #include "chrome/views/widget/root_view.h" | 20 #include "chrome/views/widget/root_view.h" |
20 | 21 |
21 namespace views { | 22 namespace views { |
22 | 23 |
23 static const DWORD kWindowDefaultChildStyle = | 24 static const DWORD kWindowDefaultChildStyle = |
24 WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; | 25 WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; |
25 static const DWORD kWindowDefaultStyle = WS_OVERLAPPEDWINDOW; | 26 static const DWORD kWindowDefaultStyle = WS_OVERLAPPEDWINDOW; |
26 static const DWORD kWindowDefaultExStyle = 0; | 27 static const DWORD kWindowDefaultExStyle = 0; |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 if (parent && !::IsWindow(parent)) { | 142 if (parent && !::IsWindow(parent)) { |
142 NOTREACHED() << "invalid parent window specified."; | 143 NOTREACHED() << "invalid parent window specified."; |
143 parent = NULL; | 144 parent = NULL; |
144 } | 145 } |
145 | 146 |
146 hwnd_ = CreateWindowEx(window_ex_style_, GetWindowClassName().c_str(), L"", | 147 hwnd_ = CreateWindowEx(window_ex_style_, GetWindowClassName().c_str(), L"", |
147 window_style_, bounds.x(), bounds.y(), bounds.width(), | 148 window_style_, bounds.x(), bounds.y(), bounds.width(), |
148 bounds.height(), parent, NULL, NULL, this); | 149 bounds.height(), parent, NULL, NULL, this); |
149 DCHECK(hwnd_); | 150 DCHECK(hwnd_); |
150 TRACK_HWND_CREATION(hwnd_); | 151 TRACK_HWND_CREATION(hwnd_); |
| 152 SetWindowSupportsRerouteMouseWheel(hwnd_); |
151 | 153 |
152 // The window procedure should have set the data for us. | 154 // The window procedure should have set the data for us. |
153 DCHECK(win_util::GetWindowUserData(hwnd_) == this); | 155 DCHECK(win_util::GetWindowUserData(hwnd_) == this); |
154 | 156 |
155 root_view_->OnWidgetCreated(); | 157 root_view_->OnWidgetCreated(); |
156 | 158 |
157 if (has_own_focus_manager) { | 159 if (has_own_focus_manager) { |
158 FocusManager::CreateFocusManager(hwnd_, GetRootView()); | 160 FocusManager::CreateFocusManager(hwnd_, GetRootView()); |
159 } else { | 161 } else { |
160 // Subclass the window so we get the tab key messages when a view with no | 162 // Subclass the window so we get the tab key messages when a view with no |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 void WidgetWin::OnMouseMove(UINT flags, const CPoint& point) { | 552 void WidgetWin::OnMouseMove(UINT flags, const CPoint& point) { |
551 ProcessMouseMoved(point, flags, false); | 553 ProcessMouseMoved(point, flags, false); |
552 } | 554 } |
553 | 555 |
554 LRESULT WidgetWin::OnMouseLeave(UINT message, WPARAM w_param, LPARAM l_param) { | 556 LRESULT WidgetWin::OnMouseLeave(UINT message, WPARAM w_param, LPARAM l_param) { |
555 tooltip_manager_->OnMouseLeave(); | 557 tooltip_manager_->OnMouseLeave(); |
556 ProcessMouseExited(); | 558 ProcessMouseExited(); |
557 return 0; | 559 return 0; |
558 } | 560 } |
559 | 561 |
560 LRESULT WidgetWin::OnMouseWheel(UINT flags, short distance, | 562 LRESULT WidgetWin::OnMouseWheel(UINT message, WPARAM w_param, LPARAM l_param) { |
561 const CPoint& point) { | 563 // Reroute the mouse-wheel to the window under the mouse pointer if |
562 MouseWheelEvent e(distance, | 564 // applicable. |
563 point.x, | 565 if (message == WM_MOUSEWHEEL && |
564 point.y, | 566 views::RerouteMouseWheel(hwnd_, w_param, l_param)) { |
565 Event::ConvertWindowsFlags(flags)); | 567 return 0; |
| 568 } |
| 569 |
| 570 int flags = GET_KEYSTATE_WPARAM(w_param); |
| 571 short distance = GET_WHEEL_DELTA_WPARAM(w_param); |
| 572 int x = GET_X_LPARAM(l_param); |
| 573 int y = GET_Y_LPARAM(l_param); |
| 574 MouseWheelEvent e(distance, x, y, Event::ConvertWindowsFlags(flags)); |
566 return root_view_->ProcessMouseWheelEvent(e) ? 0 : 1; | 575 return root_view_->ProcessMouseWheelEvent(e) ? 0 : 1; |
567 } | 576 } |
568 | 577 |
569 LRESULT WidgetWin::OnMouseRange(UINT msg, WPARAM w_param, LPARAM l_param) { | 578 LRESULT WidgetWin::OnMouseRange(UINT msg, WPARAM w_param, LPARAM l_param) { |
570 tooltip_manager_->OnMouse(msg, w_param, l_param); | 579 tooltip_manager_->OnMouse(msg, w_param, l_param); |
571 SetMsgHandled(FALSE); | 580 SetMsgHandled(FALSE); |
572 return 0; | 581 return 0; |
573 } | 582 } |
574 | 583 |
575 void WidgetWin::OnNCLButtonDblClk(UINT flags, const CPoint& point) { | 584 void WidgetWin::OnNCLButtonDblClk(UINT flags, const CPoint& point) { |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
988 result = DefWindowProc(window, message, w_param, l_param); | 997 result = DefWindowProc(window, message, w_param, l_param); |
989 if (message == WM_NCDESTROY) { | 998 if (message == WM_NCDESTROY) { |
990 TRACK_HWND_DESTRUCTION(window); | 999 TRACK_HWND_DESTRUCTION(window); |
991 widget->hwnd_ = NULL; | 1000 widget->hwnd_ = NULL; |
992 widget->OnFinalMessage(window); | 1001 widget->OnFinalMessage(window); |
993 } | 1002 } |
994 return result; | 1003 return result; |
995 } | 1004 } |
996 | 1005 |
997 } // namespace views | 1006 } // namespace views |
OLD | NEW |