Chromium Code Reviews| Index: ui/events/x/device_data_manager.cc |
| diff --git a/ui/events/x/device_data_manager.cc b/ui/events/x/device_data_manager.cc |
| index a2e02928c4bb9288353d465c4e52f619682f06b4..b68f5271ee2c0594c59ebcb1259d6821337c0627 100644 |
| --- a/ui/events/x/device_data_manager.cc |
| +++ b/ui/events/x/device_data_manager.cc |
| @@ -13,6 +13,7 @@ |
| #include "ui/events/event_constants.h" |
| #include "ui/events/x/device_list_cache_x.h" |
| #include "ui/events/x/touch_factory_x11.h" |
| +#include "ui/gfx/display.h" |
| #include "ui/gfx/x/x11_types.h" |
| // XIScrollClass was introduced in XI 2.1 so we need to define it here |
| @@ -121,6 +122,9 @@ DeviceDataManager::DeviceDataManager() |
| CHECK(arraysize(kCachedAtoms) == static_cast<size_t>(DT_LAST_ENTRY) + 1); |
| UpdateDeviceList(gfx::GetXDisplay()); |
| UpdateButtonMap(); |
| + |
| + for (int i = 0; i < kMaxDeviceNum; i++) |
| + touch_device_to_display_map_[i] = gfx::Display::kInvalidDisplayID; |
| } |
| DeviceDataManager::~DeviceDataManager() { |
| @@ -581,6 +585,43 @@ bool DeviceDataManager::GetDataRange(unsigned int deviceid, |
| return false; |
| } |
| +void DeviceDataManager::ClearTouchCTM() { |
| + for (int i = 0; i < kMaxDeviceNum; i++) |
| + touch_device_ctm_map_[i] = TouchCTM(); |
| +} |
| + |
| +void DeviceDataManager::SetTouchCTM(int touch_device_id, |
| + const TouchCTM& touch_ctm) { |
| + if (touch_device_id > 0 && touch_device_id < kMaxDeviceNum) |
| + touch_device_ctm_map_[touch_device_id] = touch_ctm; |
| +} |
| + |
| +void DeviceDataManager::ApplyTouchCTM(int touch_device_id, float* x, float* y) { |
| + if (touch_device_id > 0 && touch_device_id < kMaxDeviceNum) { |
| + const TouchCTM ctm = touch_device_ctm_map_[touch_device_id]; |
| + *x = *x * ctm.x_scale + ctm.x_offset; |
| + *y = *y * ctm.y_scale + ctm.y_offset; |
| + } |
| +} |
| + |
| +void DeviceDataManager::ClearTouchDeviceToDisplayMap() { |
| + for (int i = 0 ; i < kMaxDeviceNum; i++) |
| + touch_device_to_display_map_[i] = gfx::Display::kInvalidDisplayID; |
| +} |
| + |
| +void DeviceDataManager::MapTouchDeviceToDisplay(int touch_device_id, |
| + int64 display_id) { |
| + if (touch_device_id > 0 && touch_device_id < kMaxDeviceNum) |
| + touch_device_to_display_map_[touch_device_id] = display_id; |
| +} |
| + |
| +int64 DeviceDataManager::GetDisplayForTouchDevice(int touch_device_id) { |
| + if (touch_device_id > 0 && touch_device_id < kMaxDeviceNum) |
| + return touch_device_to_display_map_[touch_device_id]; |
| + else |
|
sadrul
2014/03/15 19:32:51
Don't need the else here.
Yufeng Shen (Slow to review)
2014/04/29 20:34:18
Done.
|
| + return gfx::Display::kInvalidDisplayID; |
| +} |
| + |
| void DeviceDataManager::SetDeviceListForTest( |
| const std::vector<unsigned int>& touchscreen, |
| const std::vector<unsigned int>& cmt_devices) { |