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

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

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