summaryrefslogtreecommitdiff
path: root/hw/xquartz
diff options
context:
space:
mode:
authorJeremy Huddleston <jeremyhu@freedesktop.org>2009-08-01 22:53:45 -0700
committerJeremy Huddleston <jeremyhu@freedesktop.org>2009-08-01 22:53:45 -0700
commit552be074e5be6492df3e290e8b7d9daff1a2cb34 (patch)
tree38691cf558d57a1f7404ee615264918332026002 /hw/xquartz
parent65ae2d00e1a53f97f2ff9522406ab69d50bf3199 (diff)
XQuartz: Only save lastpt on mouse/tablet events
Diffstat (limited to 'hw/xquartz')
-rw-r--r--hw/xquartz/X11Application.m83
1 files changed, 39 insertions, 44 deletions
diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 5d28132bf..6ade527bd 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -990,55 +990,50 @@ static inline int ensure_flag(int flags, int device_independent, int device_depe
#endif
- (void) sendX11NSEvent:(NSEvent *)e {
- NSRect screen;
- NSPoint location, tilt;
- NSWindow *window;
+ NSPoint location = NSZeroPoint, tilt = NSZeroPoint;
int ev_button, ev_type;
- float pressure;
+ float pressure = 0.0;
DeviceIntPtr pDev;
int modifierFlags;
- BOOL isTabletEvent;
-
- static NSPoint lastpt;
-
- /* convert location to be relative to top-left of primary display */
- window = [e window];
-
- isTabletEvent = ([e type] == NSTabletPoint) ||
- (( [e type] == NSLeftMouseDown || [e type] == NSOtherMouseDown || [e type] == NSRightMouseDown ||
- [e type] == NSLeftMouseUp || [e type] == NSOtherMouseUp || [e type] == NSRightMouseUp ||
- [e type] == NSLeftMouseDragged || [e type] == NSOtherMouseDragged || [e type] == NSRightMouseDragged ||
- [e type] == NSMouseMoved ) && ([e subtype] == NSTabletPointEventSubtype || [e subtype] == NSTabletProximityEventSubtype));
-
- 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) {
- // 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
- // <rdar://problem/7111003> deltaX and deltaY are incorrect for NSMouseMoved, NSTabletPointEventSubtype
- // http://xquartz.macosforge.org/trac/ticket/288
- location = [e locationInWindow];
- lastpt = location;
- } else {
- location.x = lastpt.x + [e deltaX];
- location.y = lastpt.y - [e deltaY];
- lastpt = [NSEvent mouseLocation]; // [e locationInWindow] gives us the "unfixed" location when our cursor is fixed. This bugs things like quake
+ BOOL isMouseOrTabletEvent, isTabletEvent;
+
+ isMouseOrTabletEvent = [e type] == NSLeftMouseDown || [e type] == NSOtherMouseDown || [e type] == NSRightMouseDown ||
+ [e type] == NSLeftMouseUp || [e type] == NSOtherMouseUp || [e type] == NSRightMouseUp ||
+ [e type] == NSLeftMouseDragged || [e type] == NSOtherMouseDragged || [e type] == NSRightMouseDragged ||
+ [e type] == NSMouseMoved || [e type] == NSTabletPoint;
+
+ isTabletEvent = ([e type] == NSTabletPoint) ||
+ (isMouseOrTabletEvent && ([e subtype] == NSTabletPointEventSubtype || [e subtype] == NSTabletProximityEventSubtype));
+
+ if(isMouseOrTabletEvent) {
+ static NSPoint lastpt;
+ NSWindow *window = [e window];
+ NSRect screen = [[[NSScreen screens] objectAtIndex:0] frame];;
+
+ 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) {
+ // 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
+ // <rdar://problem/7111003> deltaX and deltaY are incorrect for NSMouseMoved, NSTabletPointEventSubtype
+ // http://xquartz.macosforge.org/trac/ticket/288
+ location = [e locationInWindow];
+ lastpt = location;
+ } else {
+ location.x = lastpt.x + [e deltaX];
+ location.y = lastpt.y - [e deltaY];
+ lastpt = [e locationInWindow];
+ }
+
+ /* Convert coordinate system */
+ location.y = (screen.origin.y + screen.size.height) - location.y;
}
- /* Convert coordinate system */
- screen = [[[NSScreen screens] objectAtIndex:0] frame];
- location.y = (screen.origin.y + screen.size.height) - location.y;
-
- /* Setup our valuators. These will range from 0 to 1 */
- pressure = 0;
- tilt.x = 0.0;
- tilt.y = 0.0;
-
modifierFlags = [e modifierFlags];
#ifdef NX_DEVICELCMDKEYMASK