Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/events.h" | 5 #include "ui/base/events.h" |
| 6 | 6 |
| 7 #include <X11/extensions/XInput2.h> | 7 #include <X11/extensions/XInput2.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "ui/base/keycodes/keyboard_code_conversion_x.h" | 10 #include "ui/base/keycodes/keyboard_code_conversion_x.h" |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 347 0.0); | 347 0.0); |
| 348 unsigned int deviceid = | 348 unsigned int deviceid = |
| 349 static_cast<XIDeviceEvent*>(native_event->xcookie.data)->sourceid; | 349 static_cast<XIDeviceEvent*>(native_event->xcookie.data)->sourceid; |
| 350 // Force is normalized to fall into [0, 1] | 350 // Force is normalized to fall into [0, 1] |
| 351 if (!ui::TouchFactory::GetInstance()->NormalizeTouchParam( | 351 if (!ui::TouchFactory::GetInstance()->NormalizeTouchParam( |
| 352 deviceid, ui::TouchFactory::TP_PRESSURE, &force)) | 352 deviceid, ui::TouchFactory::TP_PRESSURE, &force)) |
| 353 force = 0.0; | 353 force = 0.0; |
| 354 return force; | 354 return force; |
| 355 } | 355 } |
| 356 | 356 |
| 357 base::NativeEvent GetNativeEventForTesting() { | |
|
rjkroege
2011/11/10 16:34:40
see comment in .h file -- move this to the test.
Gajen
2011/11/11 13:39:07
Done.
| |
| 358 XEvent* event = new XEvent; | |
| 359 memset(event, 0, sizeof(*event)); | |
| 360 XGenericEventCookie* cookie = &(event->xcookie); | |
| 361 cookie->type = GenericEvent; | |
| 362 XIDeviceEvent* dev_event = new XIDeviceEvent; | |
| 363 memset(dev_event, 0, sizeof(*dev_event)); | |
| 364 cookie->data = dev_event; | |
| 365 return event; | |
| 366 } | |
| 367 | |
| 368 void SetNativeEventLocationForTesting(const base::NativeEvent& native_event, | |
| 369 int x, int y) { | |
| 370 XIDeviceEvent* xievent = | |
| 371 static_cast<XIDeviceEvent*>(native_event->xcookie.data); | |
| 372 xievent->event_x = x; | |
| 373 xievent->event_y = y; | |
| 374 return; | |
| 375 } | |
| 376 | |
| 357 } // namespace ui | 377 } // namespace ui |
| OLD | NEW |