| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/events/event_constants.h" | 5 #include "ui/events/event_constants.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 #include <X11/extensions/XInput.h> | 9 #include <X11/extensions/XInput.h> |
| 10 #include <X11/extensions/XInput2.h> | 10 #include <X11/extensions/XInput2.h> |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 } | 279 } |
| 280 | 280 |
| 281 double GetTouchParamFromXEvent(XEvent* xev, | 281 double GetTouchParamFromXEvent(XEvent* xev, |
| 282 ui::DeviceDataManagerX11::DataType val, | 282 ui::DeviceDataManagerX11::DataType val, |
| 283 double default_value) { | 283 double default_value) { |
| 284 ui::DeviceDataManagerX11::GetInstance()->GetEventData( | 284 ui::DeviceDataManagerX11::GetInstance()->GetEventData( |
| 285 *xev, val, &default_value); | 285 *xev, val, &default_value); |
| 286 return default_value; | 286 return default_value; |
| 287 } | 287 } |
| 288 | 288 |
| 289 void ScaleTouchRadius(XEvent* xev, double* radius) { |
| 290 if (xev->type != GenericEvent) |
| 291 return; |
| 292 XIDeviceEvent* xiev = static_cast<XIDeviceEvent*>(xev->xcookie.data); |
| 293 ui::DeviceDataManagerX11::GetInstance()->ApplyTouchRadiusScale( |
| 294 xiev->sourceid, radius); |
| 295 } |
| 296 |
| 289 } // namespace | 297 } // namespace |
| 290 | 298 |
| 291 namespace ui { | 299 namespace ui { |
| 292 | 300 |
| 293 void UpdateDeviceList() { | 301 void UpdateDeviceList() { |
| 294 XDisplay* display = gfx::GetXDisplay(); | 302 XDisplay* display = gfx::GetXDisplay(); |
| 295 DeviceListCacheX::GetInstance()->UpdateDeviceList(display); | 303 DeviceListCacheX::GetInstance()->UpdateDeviceList(display); |
| 296 TouchFactory::GetInstance()->UpdateDeviceList(display); | 304 TouchFactory::GetInstance()->UpdateDeviceList(display); |
| 297 DeviceDataManagerX11::GetInstance()->UpdateDeviceList(display); | 305 DeviceDataManagerX11::GetInstance()->UpdateDeviceList(display); |
| 298 } | 306 } |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 697 *xev, ui::DeviceDataManagerX11::DT_TOUCH_TRACKING_ID, &tracking_id)) { | 705 *xev, ui::DeviceDataManagerX11::DT_TOUCH_TRACKING_ID, &tracking_id)) { |
| 698 LOG(ERROR) << "Could not get the tracking ID for the event. Using 0."; | 706 LOG(ERROR) << "Could not get the tracking ID for the event. Using 0."; |
| 699 } else { | 707 } else { |
| 700 ui::TouchFactory* factory = ui::TouchFactory::GetInstance(); | 708 ui::TouchFactory* factory = ui::TouchFactory::GetInstance(); |
| 701 slot = factory->GetSlotForTrackingID(tracking_id); | 709 slot = factory->GetSlotForTrackingID(tracking_id); |
| 702 } | 710 } |
| 703 return slot; | 711 return slot; |
| 704 } | 712 } |
| 705 | 713 |
| 706 float GetTouchRadiusX(const base::NativeEvent& native_event) { | 714 float GetTouchRadiusX(const base::NativeEvent& native_event) { |
| 707 return GetTouchParamFromXEvent(native_event, | 715 double radius = GetTouchParamFromXEvent(native_event, |
| 708 ui::DeviceDataManagerX11::DT_TOUCH_MAJOR, 0.0) / 2.0; | 716 ui::DeviceDataManagerX11::DT_TOUCH_MAJOR, 0.0) / 2.0; |
| 717 ScaleTouchRadius(native_event, &radius); |
| 718 return radius; |
| 709 } | 719 } |
| 710 | 720 |
| 711 float GetTouchRadiusY(const base::NativeEvent& native_event) { | 721 float GetTouchRadiusY(const base::NativeEvent& native_event) { |
| 712 return GetTouchParamFromXEvent(native_event, | 722 double radius = GetTouchParamFromXEvent(native_event, |
| 713 ui::DeviceDataManagerX11::DT_TOUCH_MINOR, 0.0) / 2.0; | 723 ui::DeviceDataManagerX11::DT_TOUCH_MINOR, 0.0) / 2.0; |
| 724 ScaleTouchRadius(native_event, &radius); |
| 725 return radius; |
| 714 } | 726 } |
| 715 | 727 |
| 716 float GetTouchAngle(const base::NativeEvent& native_event) { | 728 float GetTouchAngle(const base::NativeEvent& native_event) { |
| 717 return GetTouchParamFromXEvent(native_event, | 729 return GetTouchParamFromXEvent(native_event, |
| 718 ui::DeviceDataManagerX11::DT_TOUCH_ORIENTATION, 0.0) / 2.0; | 730 ui::DeviceDataManagerX11::DT_TOUCH_ORIENTATION, 0.0) / 2.0; |
| 719 } | 731 } |
| 720 | 732 |
| 721 float GetTouchForce(const base::NativeEvent& native_event) { | 733 float GetTouchForce(const base::NativeEvent& native_event) { |
| 722 double force = 0.0; | 734 double force = 0.0; |
| 723 force = GetTouchParamFromXEvent(native_event, | 735 force = GetTouchParamFromXEvent(native_event, |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 802 start_time = &start_time_; | 814 start_time = &start_time_; |
| 803 if (!end_time) | 815 if (!end_time) |
| 804 end_time = &end_time_; | 816 end_time = &end_time_; |
| 805 | 817 |
| 806 DeviceDataManagerX11::GetInstance()->GetGestureTimes( | 818 DeviceDataManagerX11::GetInstance()->GetGestureTimes( |
| 807 native_event, start_time, end_time); | 819 native_event, start_time, end_time); |
| 808 return true; | 820 return true; |
| 809 } | 821 } |
| 810 | 822 |
| 811 } // namespace ui | 823 } // namespace ui |
| OLD | NEW |