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