Commit 60030f8e authored by sadrul@chromium.org's avatar sadrul@chromium.org

aura: Re-enable XInput2 events.

It turns out that the position information in an event for a slave device
reported by X is always slightly behind than the actual position. However, it
turns out that the valuators do contain the correct information. So get the
event location from the valuator.

BUG=103981
TEST=manually

Review URL: http://codereview.chromium.org/8568044

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111016 0039d316-1c4b-4281-b951-d872f2087c98
parent a9b198bb
......@@ -281,11 +281,8 @@ DesktopHostLinux::DesktopHostLinux(const gfx::Rect& bounds)
XSelectInput(xdisplay_, xwindow_, event_mask);
XFlush(xdisplay_);
// TODO(sadrul): reenable once 103981 is fixed.
#if defined(TOUCH_UI)
if (base::MessagePumpForUI::HasXInput2())
ui::TouchFactory::GetInstance()->SetupXI2ForXWindow(xwindow_);
#endif
}
DesktopHostLinux::~DesktopHostLinux() {
......
......@@ -248,8 +248,23 @@ gfx::Point EventLocationFromNative(const base::NativeEvent& native_event) {
case GenericEvent: {
XIDeviceEvent* xievent =
static_cast<XIDeviceEvent*>(native_event->xcookie.data);
return gfx::Point(static_cast<int>(xievent->event_x),
static_cast<int>(xievent->event_y));
if (xievent->sourceid == xievent->deviceid) {
// This event is coming from a slave device. Read the position from the
// valuators, because the events reported for a slave device seems to be
// behind the master device by one event. See more on crbug.com/103981.
// The position in the valuators is in the global screen coordinates.
// But it is necessary to convert it into the window's coordinates.
// Prepare to be revolted.
double x = xievent->valuators.values[0] - (xievent->root_x -
xievent->event_x);
double y = xievent->valuators.values[1] - (xievent->root_y -
xievent->event_y);
return gfx::Point(static_cast<int>(x), static_cast<int>(y));
} else {
return gfx::Point(static_cast<int>(xievent->event_x),
static_cast<int>(xievent->event_y));
}
}
}
return gfx::Point();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment