From ecfeabec8d0dcfe286fb893047f1fe1a7ea9f8f5 Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Date: Sun, 16 May 2010 10:03:13 -0700 Subject: [PATCH] XQuartz: Don't use deltaXY for determining pointer location on scroll events Signed-off-by: Jeremy Huddleston Reviewed-by: Edward Moy --- hw/xquartz/X11Application.m | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m index ed9fb32b1..805ed9933 100644 --- a/hw/xquartz/X11Application.m +++ b/hw/xquartz/X11Application.m @@ -1030,23 +1030,32 @@ static inline int ensure_flag(int flags, int device_independent, int device_depe if(isMouseOrTabletEvent) { static NSPoint lastpt; NSWindow *window = [e window]; - NSRect screen = [[[NSScreen screens] objectAtIndex:0] frame];; + NSRect screen = [[[NSScreen screens] objectAtIndex:0] frame]; + BOOL hasUntrustedPointerDelta; + + // NSEvents for tablets are not consistent wrt deltaXY between events, so we cannot rely on that + // Thus tablets will be subject to the warp-pointer bug worked around by the delta, but tablets + // are not normally used in cases where that bug would present itself, so this is a fair tradeoff + // deltaX and deltaY are incorrect for NSMouseMoved, NSTabletPointEventSubtype + // http://xquartz.macosforge.org/trac/ticket/288 + hasUntrustedPointerDelta = isTabletEvent; + + // The deltaXY for middle click events also appear erroneous after fast user switching + // deltaX and deltaY are incorrect for NSOtherMouseDown and NSOtherMouseUp after FUS + // http://xquartz.macosforge.org/trac/ticket/389 + hasUntrustedPointerDelta = hasUntrustedPointerDelta || [e type] == NSOtherMouseDown || [e type] == NSOtherMouseUp; + // The deltaXY for scroll events correspond to the scroll delta, not the pointer delta + // deltaXY for wheel events are being sent as mouse movement + hasUntrustedPointerDelta = hasUntrustedPointerDelta || [e type] == NSScrollWheel; + if (window != nil) { NSRect frame = [window frame]; location = [e locationInWindow]; location.x += frame.origin.x; location.y += frame.origin.y; lastpt = location; - } else if(isTabletEvent || [e type] == NSOtherMouseDown || [e type] == NSOtherMouseUp) { - // NSEvents for tablets are not consistent wrt deltaXY between events, so we cannot rely on that - // Thus tablets will be subject to the warp-pointer bug worked around by the delta, but tablets - // are not normally used in cases where that bug would present itself, so this is a fair tradeoff - // deltaX and deltaY are incorrect for NSMouseMoved, NSTabletPointEventSubtype - // http://xquartz.macosforge.org/trac/ticket/288 - // The deltaXY for middle click events also appear erroneous after fast user switching - // deltaX and deltaY are incorrect for NSOtherMouseDown and NSOtherMouseUp after FUS - // http://xquartz.macosforge.org/trac/ticket/389 + } else if(hasUntrustedPointerDelta) { location = [e locationInWindow]; lastpt = location; } else {