OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/hwnd_subclass.h" | 5 #include "ui/base/win/hwnd_subclass.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
11 #include "base/memory/singleton.h" | 11 #include "base/memory/singleton.h" |
12 #include "ui/base/win/dpi.h" | |
12 #include "ui/base/win/hwnd_util.h" | 13 #include "ui/base/win/hwnd_util.h" |
13 | 14 |
14 namespace { | 15 namespace { |
15 const char kHWNDSubclassKey[] = "__UI_BASE_WIN_HWND_SUBCLASS_PROC__"; | 16 const char kHWNDSubclassKey[] = "__UI_BASE_WIN_HWND_SUBCLASS_PROC__"; |
16 | 17 |
17 LRESULT CALLBACK WndProc(HWND hwnd, | 18 LRESULT CALLBACK WndProc(HWND hwnd, |
18 UINT message, | 19 UINT message, |
19 WPARAM w_param, | 20 WPARAM w_param, |
20 LPARAM l_param) { | 21 LPARAM l_param) { |
21 ui::HWNDSubclass* wrapped_wnd_proc = | 22 ui::HWNDSubclass* wrapped_wnd_proc = |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 ui::SetWindowProc(target_, &WndProc); | 113 ui::SetWindowProc(target_, &WndProc); |
113 } | 114 } |
114 | 115 |
115 HWNDSubclass::~HWNDSubclass() { | 116 HWNDSubclass::~HWNDSubclass() { |
116 } | 117 } |
117 | 118 |
118 LRESULT HWNDSubclass::OnWndProc(HWND hwnd, | 119 LRESULT HWNDSubclass::OnWndProc(HWND hwnd, |
119 UINT message, | 120 UINT message, |
120 WPARAM w_param, | 121 WPARAM w_param, |
121 LPARAM l_param) { | 122 LPARAM l_param) { |
123 | |
124 // Touch messages are always passed in screen coordinates. If the OS is | |
125 // scaled, but the app is not DPI aware, then then WM_TOUCH might be | |
126 // intended for a different window. | |
127 if (message == WM_TOUCH) { | |
128 TOUCHINPUT point; | |
129 | |
130 if (GetTouchInputInfo((HTOUCHINPUT)l_param, 1, | |
131 &point, sizeof(TOUCHINPUT))) { | |
Ryan Sleevi
2013/03/05 18:32:56
style: indentation
BUG: GetTouchInputInfo is only
| |
132 POINT touch_location = { | |
133 TOUCH_COORD_TO_PIXEL(point.x) / ui::win::GetDPIScaleFromRegistry(), | |
134 TOUCH_COORD_TO_PIXEL(point.y) / ui::win::GetDPIScaleFromRegistry()}; | |
135 HWND actual_target = WindowFromPoint(touch_location); | |
136 if (actual_target != hwnd) { | |
137 return SendMessage(actual_target, message, w_param, l_param); | |
138 } | |
139 } | |
140 } | |
141 | |
122 for (std::vector<HWNDMessageFilter*>::iterator it = filters_.begin(); | 142 for (std::vector<HWNDMessageFilter*>::iterator it = filters_.begin(); |
123 it != filters_.end(); ++it) { | 143 it != filters_.end(); ++it) { |
124 LRESULT l_result = 0; | 144 LRESULT l_result = 0; |
125 if ((*it)->FilterMessage(hwnd, message, w_param, l_param, &l_result)) | 145 if ((*it)->FilterMessage(hwnd, message, w_param, l_param, &l_result)) |
126 return l_result; | 146 return l_result; |
127 } | 147 } |
128 | 148 |
129 // In most cases, |original_wnd_proc_| will take care of calling | 149 // In most cases, |original_wnd_proc_| will take care of calling |
130 // DefWindowProc. | 150 // DefWindowProc. |
131 return CallWindowProc(original_wnd_proc_, hwnd, message, w_param, l_param); | 151 return CallWindowProc(original_wnd_proc_, hwnd, message, w_param, l_param); |
132 } | 152 } |
133 | 153 |
134 HWNDMessageFilter::~HWNDMessageFilter() { | 154 HWNDMessageFilter::~HWNDMessageFilter() { |
135 HWNDSubclass::RemoveFilterFromAllTargets(this); | 155 HWNDSubclass::RemoveFilterFromAllTargets(this); |
136 } | 156 } |
137 | 157 |
138 } // namespace ui | 158 } // namespace ui |
OLD | NEW |