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 #include <string.h> | 9 #include <string.h> |
10 | 10 |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(xev->xcookie.data); | 352 XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(xev->xcookie.data); |
353 if (!factory->IsMultiTouchDevice(xievent->sourceid)) { | 353 if (!factory->IsMultiTouchDevice(xievent->sourceid)) { |
354 // TODO(sad): Come up with a way to generate touch-ids for multi-touch | 354 // TODO(sad): Come up with a way to generate touch-ids for multi-touch |
355 // events when touch-events are generated from a single-touch device. | 355 // events when touch-events are generated from a single-touch device. |
356 return slot; | 356 return slot; |
357 } | 357 } |
358 | 358 |
359 #if defined(USE_XI2_MT) | 359 #if defined(USE_XI2_MT) |
360 float tracking_id; | 360 float tracking_id; |
361 if (!factory->ExtractTouchParam( | 361 if (!factory->ExtractTouchParam( |
362 *xev, ui::TouchFactory::TP_TRACKING_ID, &tracking_id)) | 362 *xev, ui::TouchFactory::TP_TRACKING_ID, &tracking_id)) { |
363 LOG(ERROR) << "Could not get the slot ID for the event. Using 0."; | 363 LOG(ERROR) << "Could not get the slot ID for the event. Using 0."; |
364 else | 364 } else { |
365 slot = factory->GetSlotForTrackingID(tracking_id); | 365 slot = factory->GetSlotForTrackingID(tracking_id); |
| 366 ui::EventType type = ui::EventTypeFromNative(xev); |
| 367 if (type == ui::ET_TOUCH_CANCELLED || |
| 368 type == ui::ET_TOUCH_RELEASED) { |
| 369 factory->ReleaseSlotForTrackingID(tracking_id); |
| 370 } |
| 371 } |
366 #else | 372 #else |
367 if (!factory->ExtractTouchParam( | 373 if (!factory->ExtractTouchParam( |
368 *xev, ui::TouchFactory::TP_SLOT_ID, &slot)) | 374 *xev, ui::TouchFactory::TP_SLOT_ID, &slot)) |
369 LOG(ERROR) << "Could not get the slot ID for the event. Using 0."; | 375 LOG(ERROR) << "Could not get the slot ID for the event. Using 0."; |
370 #endif | 376 #endif |
371 return slot; | 377 return slot; |
372 } | 378 } |
373 | 379 |
374 float GetTouchRadiusX(const base::NativeEvent& native_event) { | 380 float GetTouchRadiusX(const base::NativeEvent& native_event) { |
375 return GetTouchParamFromXEvent(native_event, | 381 return GetTouchParamFromXEvent(native_event, |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 // Make sure we use atom from current xdisplay, which may | 422 // Make sure we use atom from current xdisplay, which may |
417 // change during the test. | 423 // change during the test. |
418 noop->xclient.message_type = XInternAtom( | 424 noop->xclient.message_type = XInternAtom( |
419 base::MessagePumpX::GetDefaultXDisplay(), | 425 base::MessagePumpX::GetDefaultXDisplay(), |
420 "noop", False); | 426 "noop", False); |
421 #endif | 427 #endif |
422 return noop; | 428 return noop; |
423 } | 429 } |
424 | 430 |
425 } // namespace ui | 431 } // namespace ui |
OLD | NEW |