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 #if !defined(TOOLKIT_USES_GTK) | |
sky
2011/11/22 00:28:33
nit: conditional includes after non-conditional in
oshima
2011/11/22 01:36:10
Done.
| |
12 #include "base/message_pump_x.h" | |
13 #endif | |
11 #include "ui/base/keycodes/keyboard_code_conversion_x.h" | 14 #include "ui/base/keycodes/keyboard_code_conversion_x.h" |
12 #include "ui/base/touch/touch_factory.h" | 15 #include "ui/base/touch/touch_factory.h" |
13 #include "ui/gfx/point.h" | 16 #include "ui/gfx/point.h" |
14 | 17 |
15 namespace { | 18 namespace { |
16 | 19 |
17 // Scroll amount for each wheelscroll event. 53 is also the value used for GTK+. | 20 // Scroll amount for each wheelscroll event. 53 is also the value used for GTK+. |
18 static const int kWheelScrollAmount = 53; | 21 static const int kWheelScrollAmount = 53; |
19 | 22 |
20 static const int kMinWheelButton = 4; | 23 static const int kMinWheelButton = 4; |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
349 unsigned int deviceid = | 352 unsigned int deviceid = |
350 static_cast<XIDeviceEvent*>(native_event->xcookie.data)->sourceid; | 353 static_cast<XIDeviceEvent*>(native_event->xcookie.data)->sourceid; |
351 // Force is normalized to fall into [0, 1] | 354 // Force is normalized to fall into [0, 1] |
352 if (!ui::TouchFactory::GetInstance()->NormalizeTouchParam( | 355 if (!ui::TouchFactory::GetInstance()->NormalizeTouchParam( |
353 deviceid, ui::TouchFactory::TP_PRESSURE, &force)) | 356 deviceid, ui::TouchFactory::TP_PRESSURE, &force)) |
354 force = 0.0; | 357 force = 0.0; |
355 return force; | 358 return force; |
356 } | 359 } |
357 | 360 |
358 base::NativeEvent CreateNoopEvent() { | 361 base::NativeEvent CreateNoopEvent() { |
359 static XEvent* noop = new XEvent(); | 362 static XEvent* noop = NULL; |
360 noop->xclient.type = ClientMessage; | 363 if (!noop) { |
361 noop->xclient.display = NULL; | 364 noop = new XEvent(); |
362 noop->xclient.window = None; | 365 noop->xclient.type = ClientMessage; |
363 noop->xclient.message_type = 0; | 366 noop->xclient.display = NULL; |
Daniel Erat
2011/11/22 00:25:32
just memset it to 0 first? that way you don't nee
oshima
2011/11/22 01:36:10
Actually this wasn't necessary. constructor should
| |
364 noop->xclient.format = 0; | 367 noop->xclient.window = None; |
368 noop->xclient.format = 8; | |
369 } | |
370 // TODO(oshima): Remove ifdef once gtk is removed from views. | |
371 #if defined(TOOLKIT_USES_GTK) | |
372 NOTREACHED(); | |
373 #else | |
374 // Make sure we use atom from current xdisplay, which may | |
375 // change during the test. | |
376 noop->xclient.message_type = XInternAtom( | |
377 base::MessagePumpX::GetDefaultXDisplay(), | |
378 "noop", False); | |
379 #endif | |
365 return noop; | 380 return noop; |
366 } | 381 } |
367 | 382 |
368 } // namespace ui | 383 } // namespace ui |
OLD | NEW |