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); |