+#ifdef HAVE_XINPUT
+ /* If we got a MotionNotify event, check to see if the mouse has
+ moved far enough to count as "real" motion, if not, then ignore
+ this event.
+ */
+ if ((si->num_xinput_devices > 0) &&
+ (event.x_event.type == si->xinput_DeviceMotionNotify))
+ {
+ XDeviceMotionEvent *dme = (XDeviceMotionEvent *) &event;
+ poll_mouse_data *last_poll_mouse = NULL;
+ int d;
+
+ for (d = 0; d < si->num_xinput_devices; d++)
+ {
+ if (si->xinput_devices[d].device->device_id == dme->deviceid)
+ {
+ last_poll_mouse = &(si->xinput_devices[d].last_poll_mouse);
+ break;
+ }
+ }
+
+ if (last_poll_mouse)
+ {
+ poll_mouse_data this_poll_mouse;
+ this_poll_mouse.root_x = dme->x_root;
+ this_poll_mouse.root_y = dme->y_root;
+ this_poll_mouse.child = dme->subwindow;
+ this_poll_mouse.mask = dme->device_state;
+ this_poll_mouse.time = dme->time / 1000; /* milliseconds */
+
+ if (!device_pointer_moved_p (si, last_poll_mouse,
+ &this_poll_mouse, False,
+ "device", dme->deviceid))
+ continue;
+ }
+ else if (p->debug_p)
+ fprintf (stderr,
+ "%s: received MotionNotify from unknown device %d\n",
+ blurb(), (int) dme->deviceid);
+ }
+
+ if ((!until_idle_p) &&
+ (si->num_xinput_devices > 0) &&
+ (event.x_event.type == si->xinput_DeviceMotionNotify ||
+ event.x_event.type == si->xinput_DeviceButtonPress))
+ /* Ignore DeviceButtonRelease, see ButtonRelease comment above. */
+ {
+
+ dispatch_event (si, &event.x_event);
+ if (si->demoing_p &&
+ event.x_event.type == si->xinput_DeviceMotionNotify)
+ /* When we're demoing a single hack, mouse motion doesn't
+ cause deactivation. Only clicks and keypresses do. */
+ ;
+ else
+ /* If we're not demoing, then any activity causes deactivation.
+ */
+ {
+ why = (event.x_event.type == si->xinput_DeviceMotionNotify
+ ? "XI mouse motion" :
+ event.x_event.type == si->xinput_DeviceButtonPress
+ ? "XI mouse click" : "unknown XINPUT event");
+ goto DONE;
+ }
+ }
+ else
+#endif /* HAVE_XINPUT */
+