Index: ui/aura/desktop_host_linux.cc |
diff --git a/ui/aura/desktop_host_linux.cc b/ui/aura/desktop_host_linux.cc |
index 9934467fcbb2b8b49208f0a45a5fcdf60137d293..6344d69f572d34f7caa8c6f59a320dc9f8ab174d 100644 |
--- a/ui/aura/desktop_host_linux.cc |
+++ b/ui/aura/desktop_host_linux.cc |
@@ -33,6 +33,51 @@ namespace aura { |
namespace { |
+// The events reported for slave devices can have incorrect information for some |
+// fields. This utility function is used to check for such inconsistencies. |
+void CheckXEventForConsistency(XEvent* xevent) { |
+ static bool expect_master_event = false; |
+ static XIDeviceEvent slave_event; |
+ static gfx::Point slave_location; |
sky
2011/11/30 16:38:04
Statics should only be primitive types.
|
+ |
+ if (!xevent || xevent->type != GenericEvent) { |
+ expect_master_event = false; |
+ return; |
+ } |
+ |
+ XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(xevent->xcookie.data); |
+ if (xievent->evtype != XI_Motion && |
+ xievent->evtype != XI_ButtonPress && |
+ xievent->evtype != XI_ButtonRelease) { |
+ expect_master_event = false; |
+ return; |
+ } |
+ |
+ if (xievent->sourceid == xievent->deviceid) { |
+ // This is a slave event. We shouldn't have been expecting a master event. |
+ CHECK(!expect_master_event); |
+ slave_event = *xievent; |
+ slave_location = ui::EventLocationFromNative(xevent); |
+ expect_master_event = true; |
+ } else if (expect_master_event) { |
+ CHECK_EQ(slave_location.x(), ui::EventLocationFromNative(xevent).x()); |
+ CHECK_EQ(slave_location.y(), ui::EventLocationFromNative(xevent).y()); |
+ |
+ CHECK_EQ(slave_event.type, xievent->type); |
+ CHECK_EQ(slave_event.evtype, xievent->evtype); |
+ CHECK_EQ(slave_event.detail, xievent->detail); |
+ CHECK_EQ(slave_event.flags, xievent->flags); |
+ CHECK_EQ(slave_event.buttons.mask_len, xievent->buttons.mask_len); |
+ CHECK_EQ(slave_event.valuators.mask_len, xievent->valuators.mask_len); |
+ CHECK_EQ(slave_event.mods.base, xievent->mods.base); |
+ CHECK_EQ(slave_event.mods.latched, xievent->mods.latched); |
+ CHECK_EQ(slave_event.mods.locked, xievent->mods.locked); |
+ CHECK_EQ(slave_event.mods.effective, xievent->mods.effective); |
+ |
+ expect_master_event = false; |
+ } |
+} |
+ |
// Returns X font cursor shape from an Aura cursor. |
int CursorShapeFromNative(gfx::NativeCursor native_cursor) { |
switch (native_cursor) { |
@@ -141,6 +186,7 @@ int CoalescePendingXIMotionEvents(const XEvent* xev, XEvent* last_event) { |
// with one from the master and one from the slave so there will |
// always be at least one pending. |
if (!ui::TouchFactory::GetInstance()->ShouldProcessXI2Event(&next_event)) { |
+ CheckXEventForConsistency(&next_event); |
XFreeEventData(display, &next_event.xcookie); |
XNextEvent(display, &next_event); |
continue; |
@@ -169,6 +215,7 @@ int CoalescePendingXIMotionEvents(const XEvent* xev, XEvent* last_event) { |
// Get the event and its cookie data. |
XNextEvent(display, last_event); |
XGetEventData(display, &last_event->xcookie); |
+ CheckXEventForConsistency(last_event); |
++num_coalesed; |
continue; |
} else { |
@@ -280,6 +327,7 @@ DesktopHostLinux::DesktopHostLinux(const gfx::Rect& bounds) |
long event_mask = ButtonPressMask | ButtonReleaseMask | |
KeyPressMask | KeyReleaseMask | |
+ EnterWindowMask | LeaveWindowMask | |
ExposureMask | VisibilityChangeMask | |
StructureNotifyMask | PropertyChangeMask | |
PointerMotionMask; |
@@ -287,11 +335,8 @@ DesktopHostLinux::DesktopHostLinux(const gfx::Rect& bounds) |
XSelectInput(xdisplay_, root_window_, StructureNotifyMask); |
XFlush(xdisplay_); |
- // TODO(sadrul): reenable once 103981 is fixed. |
-#if defined(TOUCH_UI) |
if (base::MessagePumpForUI::HasXInput2()) |
DaveMoore
2011/11/30 16:51:51
Do we ever expect to run in an environment w/out X
sadrul
2011/11/30 16:53:50
XInput2 is usually not available when running over
|
ui::TouchFactory::GetInstance()->SetupXI2ForXWindow(xwindow_); |
-#endif |
} |
DesktopHostLinux::~DesktopHostLinux() { |
@@ -306,6 +351,9 @@ base::MessagePumpDispatcher::DispatchStatus DesktopHostLinux::Dispatch( |
DLOG(WARNING) << "DispatchEvent:" << xev->type; |
bool handled = false; |
+ |
+ CheckXEventForConsistency(xev); |
+ |
switch (xev->type) { |
case Expose: |
desktop_->Draw(); |