OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "ui/views/events/event.h" | |
6 | |
7 #include <gdk/gdk.h> | |
8 #include <gdk/gdkx.h> | |
9 #include <X11/extensions/XInput2.h> | |
10 #include <X11/Xlib.h> | |
11 | |
12 #include "base/logging.h" | |
13 #include "base/utf_string_conversions.h" | |
14 #include "ui/base/events.h" | |
15 #include "ui/base/keycodes/keyboard_code_conversion.h" | |
16 #include "ui/base/keycodes/keyboard_code_conversion_x.h" | |
17 #include "ui/base/touch/touch_factory.h" | |
18 #include "ui/views/widget/root_view.h" | |
19 | |
20 namespace views { | |
21 | |
22 //////////////////////////////////////////////////////////////////////////////// | |
23 // TouchEvent, public: | |
24 | |
25 TouchEvent::TouchEvent(const base::NativeEvent& native_event) | |
26 : LocatedEvent(native_event), | |
27 touch_id_(ui::GetTouchId(native_event)), | |
28 radius_x_(ui::GetTouchRadiusX(native_event)), | |
29 radius_y_(ui::GetTouchRadiusY(native_event)), | |
30 rotation_angle_(ui::GetTouchAngle(native_event)), | |
31 force_(ui::GetTouchForce(native_event)) { | |
32 #if defined(USE_XI2_MT) | |
33 if (type() == ui::ET_TOUCH_RELEASED) { | |
34 // NOTE: The slot is allocated by TouchFactory for each XI_TouchBegin | |
35 // event, which carries a new tracking ID to identify a new touch | |
36 // sequence. | |
37 ui::TouchFactory* factory = ui::TouchFactory::GetInstance(); | |
38 float tracking_id; | |
39 if (factory->ExtractTouchParam(*native_event, | |
40 ui::TouchFactory::TP_TRACKING_ID, | |
41 &tracking_id)) { | |
42 factory->ReleaseSlotForTrackingID(tracking_id); | |
43 } | |
44 } | |
45 #else | |
46 if (type() == ui::ET_TOUCH_PRESSED || type() == ui::ET_TOUCH_RELEASED) { | |
47 ui::TouchFactory* factory = ui::TouchFactory::GetInstance(); | |
48 float slot; | |
49 if (factory->ExtractTouchParam(*native_event, | |
50 ui::TouchFactory::TP_SLOT_ID, &slot)) { | |
51 factory->SetSlotUsed(slot, type() == ui::ET_TOUCH_PRESSED); | |
52 } | |
53 } | |
54 #endif | |
55 } | |
56 | |
57 } // namespace views | |
OLD | NEW |