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/Xlib.h> | 7 #include <X11/Xlib.h> |
| 8 #include <X11/extensions/XInput2.h> | 8 #include <X11/extensions/XInput2.h> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "ui/base/keycodes/keyboard_code_conversion_x.h" | 11 #include "ui/base/keycodes/keyboard_code_conversion_x.h" |
| 12 #include "ui/base/touch/touch_factory.h" | 12 #include "ui/base/touch/touch_factory.h" |
| 13 #include "ui/gfx/point.h" | 13 #include "ui/gfx/point.h" |
| 14 | 14 |
| 15 #if !defined(TOOLKIT_USES_GTK) | |
| 16 #include "base/message_pump_x.h" | |
| 17 #endif | |
| 18 | |
| 15 namespace { | 19 namespace { |
| 16 | 20 |
| 17 // Scroll amount for each wheelscroll event. 53 is also the value used for GTK+. | 21 // Scroll amount for each wheelscroll event. 53 is also the value used for GTK+. |
| 18 static const int kWheelScrollAmount = 53; | 22 static const int kWheelScrollAmount = 53; |
| 19 | 23 |
| 20 static const int kMinWheelButton = 4; | 24 static const int kMinWheelButton = 4; |
| 21 #if defined(OS_CHROMEOS) | 25 #if defined(OS_CHROMEOS) |
| 22 // Chrome OS also uses buttons 8 and 9 for scrolling. | 26 // Chrome OS also uses buttons 8 and 9 for scrolling. |
| 23 static const int kMaxWheelButton = 9; | 27 static const int kMaxWheelButton = 9; |
| 24 #else | 28 #else |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 364 unsigned int deviceid = | 368 unsigned int deviceid = |
| 365 static_cast<XIDeviceEvent*>(native_event->xcookie.data)->sourceid; | 369 static_cast<XIDeviceEvent*>(native_event->xcookie.data)->sourceid; |
| 366 // Force is normalized to fall into [0, 1] | 370 // Force is normalized to fall into [0, 1] |
| 367 if (!ui::TouchFactory::GetInstance()->NormalizeTouchParam( | 371 if (!ui::TouchFactory::GetInstance()->NormalizeTouchParam( |
| 368 deviceid, ui::TouchFactory::TP_PRESSURE, &force)) | 372 deviceid, ui::TouchFactory::TP_PRESSURE, &force)) |
| 369 force = 0.0; | 373 force = 0.0; |
| 370 return force; | 374 return force; |
| 371 } | 375 } |
| 372 | 376 |
| 373 base::NativeEvent CreateNoopEvent() { | 377 base::NativeEvent CreateNoopEvent() { |
| 374 static XEvent* noop = new XEvent(); | 378 static XEvent* noop = NULL; |
| 375 noop->xclient.type = ClientMessage; | 379 if (!noop) { |
| 376 noop->xclient.display = NULL; | 380 noop = new XEvent(); |
|
Daniel Erat
2011/11/22 01:46:14
i don't think there's any non-default constructor
oshima
2011/11/22 03:02:09
C++ supposed to be able to initialize POD types in
| |
| 377 noop->xclient.window = None; | 381 noop->xclient.type = ClientMessage; |
| 378 noop->xclient.message_type = 0; | 382 noop->xclient.window = None; |
|
Daniel Erat
2011/11/22 01:46:14
None == 0
oshima
2011/11/22 03:02:09
Hmm, it's implementation details and I think we sh
| |
| 379 noop->xclient.format = 0; | 383 noop->xclient.format = 8; |
| 384 DCHECK(!noop->xclient.display); | |
| 385 } | |
| 386 // TODO(oshima): Remove ifdef once gtk is removed from views. | |
| 387 #if defined(TOOLKIT_USES_GTK) | |
| 388 NOTREACHED(); | |
| 389 #else | |
| 390 // Make sure we use atom from current xdisplay, which may | |
| 391 // change during the test. | |
| 392 noop->xclient.message_type = XInternAtom( | |
| 393 base::MessagePumpX::GetDefaultXDisplay(), | |
| 394 "noop", False); | |
| 395 #endif | |
| 380 return noop; | 396 return noop; |
| 381 } | 397 } |
| 382 | 398 |
| 383 } // namespace ui | 399 } // namespace ui |
| OLD | NEW |