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