| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "views/focus/focus_util_win.h" | 5 #include "views/focus/focus_util_win.h" |
| 6 | 6 |
| 7 #include <windowsx.h> | 7 #include <windowsx.h> |
| 8 | 8 |
| 9 #include "app/win/hwnd_util.h" | |
| 10 #include "app/view_prop.h" | 9 #include "app/view_prop.h" |
| 11 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| 11 #include "ui/base/win/hwnd_util.h" |
| 12 | 12 |
| 13 using app::ViewProp; | 13 using app::ViewProp; |
| 14 | 14 |
| 15 namespace views { | 15 namespace views { |
| 16 | 16 |
| 17 // Property used to indicate the HWND supports having mouse wheel messages | 17 // Property used to indicate the HWND supports having mouse wheel messages |
| 18 // rerouted to it. | 18 // rerouted to it. |
| 19 static const char* const kHWNDSupportMouseWheelRerouting = | 19 static const char* const kHWNDSupportMouseWheelRerouting = |
| 20 "__HWND_MW_REROUTE_OK"; | 20 "__HWND_MW_REROUTE_OK"; |
| 21 | 21 |
| 22 static bool WindowSupportsRerouteMouseWheel(HWND window) { | 22 static bool WindowSupportsRerouteMouseWheel(HWND window) { |
| 23 while (GetWindowLong(window, GWL_STYLE) & WS_CHILD) { | 23 while (GetWindowLong(window, GWL_STYLE) & WS_CHILD) { |
| 24 if (!IsWindow(window)) | 24 if (!IsWindow(window)) |
| 25 break; | 25 break; |
| 26 | 26 |
| 27 if (reinterpret_cast<bool>( | 27 if (reinterpret_cast<bool>( |
| 28 ViewProp::GetValue(window, kHWNDSupportMouseWheelRerouting))) { | 28 ViewProp::GetValue(window, kHWNDSupportMouseWheelRerouting))) { |
| 29 return true; | 29 return true; |
| 30 } | 30 } |
| 31 window = GetParent(window); | 31 window = GetParent(window); |
| 32 } | 32 } |
| 33 return false; | 33 return false; |
| 34 } | 34 } |
| 35 | 35 |
| 36 static bool IsCompatibleWithMouseWheelRedirection(HWND window) { | 36 static bool IsCompatibleWithMouseWheelRedirection(HWND window) { |
| 37 std::wstring class_name = app::win::GetClassName(window); | 37 std::wstring class_name = ui::GetClassName(window); |
| 38 // Mousewheel redirection to comboboxes is a surprising and | 38 // Mousewheel redirection to comboboxes is a surprising and |
| 39 // undesireable user behavior. | 39 // undesireable user behavior. |
| 40 return !(class_name == L"ComboBox" || | 40 return !(class_name == L"ComboBox" || |
| 41 class_name == L"ComboBoxEx32"); | 41 class_name == L"ComboBoxEx32"); |
| 42 } | 42 } |
| 43 | 43 |
| 44 static bool CanRedirectMouseWheelFrom(HWND window) { | 44 static bool CanRedirectMouseWheelFrom(HWND window) { |
| 45 std::wstring class_name = app::win::GetClassName(window); | 45 std::wstring class_name = ui::GetClassName(window); |
| 46 | 46 |
| 47 // Older Thinkpad mouse wheel drivers create a window under mouse wheel | 47 // Older Thinkpad mouse wheel drivers create a window under mouse wheel |
| 48 // pointer. Detect if we are dealing with this window. In this case we | 48 // pointer. Detect if we are dealing with this window. In this case we |
| 49 // don't need to do anything as the Thinkpad mouse driver will send | 49 // don't need to do anything as the Thinkpad mouse driver will send |
| 50 // mouse wheel messages to the right window. | 50 // mouse wheel messages to the right window. |
| 51 if ((class_name == L"Syn Visual Class") || | 51 if ((class_name == L"Syn Visual Class") || |
| 52 (class_name == L"SynTrackCursorWindowClass")) | 52 (class_name == L"SynTrackCursorWindowClass")) |
| 53 return false; | 53 return false; |
| 54 | 54 |
| 55 return true; | 55 return true; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 } | 112 } |
| 113 // If redirection is disallowed, try the parent. | 113 // If redirection is disallowed, try the parent. |
| 114 window_under_wheel = GetAncestor(window_under_wheel, GA_PARENT); | 114 window_under_wheel = GetAncestor(window_under_wheel, GA_PARENT); |
| 115 } | 115 } |
| 116 // If we traversed back to the starting point, we should process | 116 // If we traversed back to the starting point, we should process |
| 117 // this message normally; return false. | 117 // this message normally; return false. |
| 118 return false; | 118 return false; |
| 119 } | 119 } |
| 120 | 120 |
| 121 } // namespace views | 121 } // namespace views |
| OLD | NEW |