Chromium Code Reviews| 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 <windowsx.h> | 5 #include <windowsx.h> |
| 6 | 6 |
| 7 #include "ui/base/events.h" | 7 #include "ui/base/events.h" |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/time.h" | 10 #include "base/time.h" |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 204 DCHECK(IsNonClientMouseEvent(native_event) || | 204 DCHECK(IsNonClientMouseEvent(native_event) || |
| 205 IsMouseWheelEvent(native_event)); | 205 IsMouseWheelEvent(native_event)); |
| 206 // Non-client message. The position is contained in a POINTS structure in | 206 // Non-client message. The position is contained in a POINTS structure in |
| 207 // LPARAM, and is in screen coordinates so we have to convert to client. | 207 // LPARAM, and is in screen coordinates so we have to convert to client. |
| 208 POINT native_point = { GET_X_LPARAM(native_event.lParam), | 208 POINT native_point = { GET_X_LPARAM(native_event.lParam), |
| 209 GET_Y_LPARAM(native_event.lParam) }; | 209 GET_Y_LPARAM(native_event.lParam) }; |
| 210 ScreenToClient(native_event.hwnd, &native_point); | 210 ScreenToClient(native_event.hwnd, &native_point); |
| 211 return gfx::Point(native_point); | 211 return gfx::Point(native_point); |
| 212 } | 212 } |
| 213 | 213 |
| 214 gfx::Point EventRootLocationFromNative(const base::NativeEvent& native_event) { | |
| 215 // Note: Wheel events are considered client, but their position is in screen | |
| 216 // coordinates. | |
| 217 // Client message. The position is contained in the LPARAM. | |
| 218 if (IsClientMouseEvent(native_event) && !IsMouseWheelEvent(native_event)) | |
| 219 return gfx::Point(native_event.lParam); | |
| 220 DCHECK(IsNonClientMouseEvent(native_event) || | |
| 221 IsMouseWheelEvent(native_event)); | |
| 222 // Non-client message. The position is contained in a POINTS structure in | |
| 223 // LPARAM, and is in screen coordinates so we have to convert to client. | |
| 224 POINT native_point = { GET_X_LPARAM(native_event.lParam), | |
| 225 GET_Y_LPARAM(native_event.lParam) }; | |
| 226 | |
| 227 // TODO(erg): The windows folks say the above is done in screen | |
| 228 // coordinates. Is that equivalent to root coordinates on windows? | |
|
Elliot Glaysher
2012/05/09 19:39:18
attn ben: is this correct for window?
| |
| 229 return gfx::Point(native_point); | |
| 230 } | |
| 231 | |
| 214 KeyboardCode KeyboardCodeFromNative(const base::NativeEvent& native_event) { | 232 KeyboardCode KeyboardCodeFromNative(const base::NativeEvent& native_event) { |
| 215 return KeyboardCodeForWindowsKeyCode(native_event.wParam); | 233 return KeyboardCodeForWindowsKeyCode(native_event.wParam); |
| 216 } | 234 } |
| 217 | 235 |
| 218 bool IsMouseEvent(const base::NativeEvent& native_event) { | 236 bool IsMouseEvent(const base::NativeEvent& native_event) { |
| 219 return IsClientMouseEvent(native_event) || | 237 return IsClientMouseEvent(native_event) || |
| 220 IsNonClientMouseEvent(native_event); | 238 IsNonClientMouseEvent(native_event); |
| 221 } | 239 } |
| 222 | 240 |
| 223 int GetMouseWheelOffset(const base::NativeEvent& native_event) { | 241 int GetMouseWheelOffset(const base::NativeEvent& native_event) { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 294 return event.message == WM_USER + 310; | 312 return event.message == WM_USER + 310; |
| 295 } | 313 } |
| 296 | 314 |
| 297 base::NativeEvent CreateNoopEvent() { | 315 base::NativeEvent CreateNoopEvent() { |
| 298 MSG event = { NULL }; | 316 MSG event = { NULL }; |
| 299 event.message = WM_USER + 310; | 317 event.message = WM_USER + 310; |
| 300 return event; | 318 return event; |
| 301 } | 319 } |
| 302 | 320 |
| 303 } // namespace ui | 321 } // namespace ui |
| OLD | NEW |