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

Unified Diff: ui/aura/window_tree_host_x11.cc

Issue 191223007: Move touch CTM from X into Chrome (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rework Created 6 years, 8 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/aura/window_tree_host_x11.h ('k') | ui/display/chromeos/display_configurator.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura/window_tree_host_x11.cc
diff --git a/ui/aura/window_tree_host_x11.cc b/ui/aura/window_tree_host_x11.cc
index 5fec30cff62fda35b1975630facf2dfe77f50c88..0a9e5c402461766ec1ae9d07f72d19996228071f 100644
--- a/ui/aura/window_tree_host_x11.cc
+++ b/ui/aura/window_tree_host_x11.cc
@@ -499,6 +499,7 @@ ui::EventProcessor* WindowTreeHostX11::GetEventProcessor() {
void WindowTreeHostX11::DispatchXI2Event(const base::NativeEvent& event) {
ui::TouchFactory* factory = ui::TouchFactory::GetInstance();
XEvent* xev = event;
+ XIDeviceEvent* xiev = static_cast<XIDeviceEvent*>(xev->xcookie.data);
if (!factory->ShouldProcessXI2Event(xev))
return;
@@ -516,7 +517,6 @@ void WindowTreeHostX11::DispatchXI2Event(const base::NativeEvent& event) {
case ui::ET_TOUCH_PRESSED:
case ui::ET_TOUCH_CANCELLED:
case ui::ET_TOUCH_RELEASED: {
-#if defined(OS_CHROMEOS)
// Bail out early before generating a ui::TouchEvent if this event
// is not within the range of this RootWindow. Converting an xevent
// to ui::TouchEvent might change the state of the global touch tracking
@@ -524,11 +524,11 @@ void WindowTreeHostX11::DispatchXI2Event(const base::NativeEvent& event) {
// record, and doing this multiple time when there are multiple
// RootWindow will cause problem. So only generate the ui::TouchEvent
// when we are sure it belongs to this RootWindow.
- if (base::SysInfo::IsRunningOnChromeOS() &&
- !bounds().Contains(ui::EventLocationFromNative(xev)))
+ if (!IsTouchEventTargetingThisRootWindow(xev))
return;
-#endif
ui::TouchEvent touchev(xev);
+ ui::DeviceDataManager::GetInstance()->CalibrateTouchEvent(
+ &touchev, xiev->deviceid, bounds_);
TranslateAndDispatchLocatedEvent(&touchev);
break;
}
@@ -592,6 +592,28 @@ void WindowTreeHostX11::TranslateAndDispatchLocatedEvent(
SendEventToProcessor(event);
}
+bool WindowTreeHostX11::IsTouchEventTargetingThisRootWindow(XEvent* xev) {
+#if defined(OS_CHROMEOS)
+ XIDeviceEvent* xiev = static_cast<XIDeviceEvent*>(xev->xcookie.data);
+ int64 touch_display_id =
+ ui::DeviceDataManager::GetInstance()->GetDisplayForTouchDevice(
+ xiev->deviceid);
+ // If we don't have record of display id for this touch device, check
+ // that if the event is within the bound of the root window. Note
+ // that in multi-monitor case, the event position is in framebuffer
+ // space so the bounds check will not work so well.
+ if (touch_display_id == gfx::Display::kInvalidDisplayID) {
+ if (base::SysInfo::IsRunningOnChromeOS() &&
+ !bounds_.Contains(ui::EventLocationFromNative(xev)))
+ return false;
+ } else if (touch_display_id != display_ids().first &&
+ touch_display_id != display_ids().second) {
+ return false;
+ }
oshima 2014/04/30 16:19:05 Can you move chromeos specific code to ash/host/as
Yufeng Shen (Slow to review) 2014/04/30 16:42:42 The thing is IsTouchEventTargetingThisRootWindow(x
Yufeng Shen (Slow to review) 2014/04/30 19:16:44 as Sadrul suggested, moved this into AshWindowTree
+#endif // defined(OS_CHROMEOS)
+ return true;
+}
+
// static
WindowTreeHost* WindowTreeHost::Create(const gfx::Rect& bounds) {
return new WindowTreeHostX11(bounds);
« no previous file with comments | « ui/aura/window_tree_host_x11.h ('k') | ui/display/chromeos/display_configurator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698