Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(134)

Unified Diff: ui/events/x/device_data_manager.cc

Issue 280833002: Re-land "Issue 191223007: Move touch CTM from X into Chrome" (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: adding missing file again Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/events/x/device_data_manager.h ('k') | ui/events/x/events_x.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 cac9dfda0bdbb6f93a7adf451f54070c25041984..4cc0957b4a8379140c3dda73ceee093d4b0d52aa 100644
--- a/ui/events/x/device_data_manager.cc
+++ b/ui/events/x/device_data_manager.cc
@@ -10,9 +10,13 @@
#include "base/logging.h"
#include "base/memory/singleton.h"
+#include "base/sys_info.h"
#include "ui/events/event_constants.h"
+#include "ui/events/event_switches.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/point3_f.h"
#include "ui/gfx/x/x11_types.h"
// XIScrollClass was introduced in XI 2.1 so we need to define it here
@@ -120,6 +124,8 @@ 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() {
@@ -634,4 +640,54 @@ void DeviceDataManager::InitializeValuatorsForTest(int deviceid,
}
}
+bool DeviceDataManager::TouchEventNeedsCalibrate(int touch_device_id) const {
+#if defined(OS_CHROMEOS) && defined(USE_XI2_MT)
+ int64 touch_display_id = GetDisplayForTouchDevice(touch_device_id);
+ if (base::SysInfo::IsRunningOnChromeOS() &&
+ touch_display_id == gfx::Display::InternalDisplayId()) {
+ return true;
+ }
+#endif // defined(OS_CHROMEOS) && defined(USE_XI2_MT)
+ return false;
+}
+
+void DeviceDataManager::ClearTouchTransformerRecord() {
+ for (int i = 0; i < kMaxDeviceNum; i++) {
+ touch_device_transformer_map_[i] = gfx::Transform();
+ touch_device_to_display_map_[i] = gfx::Display::kInvalidDisplayID;
+ }
+}
+
+bool DeviceDataManager::IsTouchDeviceIdValid(int touch_device_id) const {
+ return (touch_device_id > 0 && touch_device_id < kMaxDeviceNum);
+}
+
+void DeviceDataManager::UpdateTouchInfoForDisplay(
+ int64 display_id,
+ int touch_device_id,
+ const gfx::Transform& touch_transformer) {
+ if (IsTouchDeviceIdValid(touch_device_id)) {
+ touch_device_to_display_map_[touch_device_id] = display_id;
+ touch_device_transformer_map_[touch_device_id] = touch_transformer;
+ }
+}
+
+void DeviceDataManager::ApplyTouchTransformer(int touch_device_id,
+ float* x, float* y) {
+ if (IsTouchDeviceIdValid(touch_device_id)) {
+ gfx::Point3F point(*x, *y, 0.0);
+ const gfx::Transform& trans =
+ touch_device_transformer_map_[touch_device_id];
+ trans.TransformPoint(&point);
+ *x = point.x();
+ *y = point.y();
+ }
+}
+
+int64 DeviceDataManager::GetDisplayForTouchDevice(int touch_device_id) const {
+ if (IsTouchDeviceIdValid(touch_device_id))
+ return touch_device_to_display_map_[touch_device_id];
+ return gfx::Display::kInvalidDisplayID;
+}
+
} // namespace ui
« no previous file with comments | « ui/events/x/device_data_manager.h ('k') | ui/events/x/events_x.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698