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

Side by Side Diff: views/focus/focus_util_win.cc

Issue 5075003: Converts usage of SetProp/GetProp to a map. Even after making sure we (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix gyp files Created 10 years, 1 month 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 | « views/focus/focus_util_win.h ('k') | views/widget/child_window_message_processor.h » ('j') | 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) 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/scoped_prop.h" 9 #include "app/view_prop.h"
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
11 #include "base/win_util.h" 11 #include "base/win_util.h"
12 12
13 using app::ViewProp;
14
13 namespace views { 15 namespace views {
14 16
15 // Property used to indicate the HWND supports having mouse wheel messages 17 // Property used to indicate the HWND supports having mouse wheel messages
16 // rerouted to it. 18 // rerouted to it.
17 static const wchar_t* const kHWNDSupportMouseWheelRerouting = 19 static const char* const kHWNDSupportMouseWheelRerouting =
18 L"__HWND_MW_REROUTE_OK"; 20 "__HWND_MW_REROUTE_OK";
19 21
20 static bool WindowSupportsRerouteMouseWheel(HWND window) { 22 static bool WindowSupportsRerouteMouseWheel(HWND window) {
21 while (GetWindowLong(window, GWL_STYLE) & WS_CHILD) { 23 while (GetWindowLong(window, GWL_STYLE) & WS_CHILD) {
22 if (!IsWindow(window)) 24 if (!IsWindow(window))
23 break; 25 break;
24 26
25 if (reinterpret_cast<bool>(GetProp(window, 27 if (reinterpret_cast<bool>(
26 kHWNDSupportMouseWheelRerouting))) { 28 ViewProp::GetValue(window, kHWNDSupportMouseWheelRerouting))) {
27 return true; 29 return true;
28 } 30 }
29 window = GetParent(window); 31 window = GetParent(window);
30 } 32 }
31 return false; 33 return false;
32 } 34 }
33 35
34 static bool IsCompatibleWithMouseWheelRedirection(HWND window) { 36 static bool IsCompatibleWithMouseWheelRedirection(HWND window) {
35 std::wstring class_name = win_util::GetClassName(window); 37 std::wstring class_name = win_util::GetClassName(window);
36 // Mousewheel redirection to comboboxes is a surprising and 38 // Mousewheel redirection to comboboxes is a surprising and
37 // undesireable user behavior. 39 // undesireable user behavior.
38 return !(class_name == L"ComboBox" || 40 return !(class_name == L"ComboBox" ||
39 class_name == L"ComboBoxEx32"); 41 class_name == L"ComboBoxEx32");
40 } 42 }
41 43
42 static bool CanRedirectMouseWheelFrom(HWND window) { 44 static bool CanRedirectMouseWheelFrom(HWND window) {
43 std::wstring class_name = win_util::GetClassName(window); 45 std::wstring class_name = win_util::GetClassName(window);
44 46
45 // Older Thinkpad mouse wheel drivers create a window under mouse wheel 47 // Older Thinkpad mouse wheel drivers create a window under mouse wheel
46 // 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
47 // 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
48 // mouse wheel messages to the right window. 50 // mouse wheel messages to the right window.
49 if ((class_name == L"Syn Visual Class") || 51 if ((class_name == L"Syn Visual Class") ||
50 (class_name == L"SynTrackCursorWindowClass")) 52 (class_name == L"SynTrackCursorWindowClass"))
51 return false; 53 return false;
52 54
53 return true; 55 return true;
54 } 56 }
55 57
56 app::win::ScopedProp* SetWindowSupportsRerouteMouseWheel(HWND hwnd) { 58 ViewProp* SetWindowSupportsRerouteMouseWheel(HWND hwnd) {
57 return new app::win::ScopedProp(hwnd, kHWNDSupportMouseWheelRerouting, 59 return new ViewProp(hwnd, kHWNDSupportMouseWheelRerouting,
58 reinterpret_cast<HANDLE>(true)); 60 reinterpret_cast<HANDLE>(true));
59 } 61 }
60 62
61 bool RerouteMouseWheel(HWND window, WPARAM w_param, LPARAM l_param) { 63 bool RerouteMouseWheel(HWND window, WPARAM w_param, LPARAM l_param) {
62 // Since this is called from a subclass for every window, we can get 64 // Since this is called from a subclass for every window, we can get
63 // here recursively. This will happen if, for example, a control 65 // here recursively. This will happen if, for example, a control
64 // reflects wheel scroll messages to its parent. Bail out if we got 66 // reflects wheel scroll messages to its parent. Bail out if we got
65 // here recursively. 67 // here recursively.
66 static bool recursion_break = false; 68 static bool recursion_break = false;
67 if (recursion_break) 69 if (recursion_break)
68 return false; 70 return false;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 } 112 }
111 // If redirection is disallowed, try the parent. 113 // If redirection is disallowed, try the parent.
112 window_under_wheel = GetAncestor(window_under_wheel, GA_PARENT); 114 window_under_wheel = GetAncestor(window_under_wheel, GA_PARENT);
113 } 115 }
114 // If we traversed back to the starting point, we should process 116 // If we traversed back to the starting point, we should process
115 // this message normally; return false. 117 // this message normally; return false.
116 return false; 118 return false;
117 } 119 }
118 120
119 } // namespace views 121 } // namespace views
OLDNEW
« no previous file with comments | « views/focus/focus_util_win.h ('k') | views/widget/child_window_message_processor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698