changeset 3952:e3c28caea46d SDL-1.2

Better handling of multiple queued Cocoa mouse events. Thanks to Christian Walther for the patch. Fixes Bugzilla #353.
author Ryan C. Gordon <icculus@icculus.org>
date Mon, 04 Jun 2007 11:22:23 +0000
parents e1e525d96838
children d3c1161652d5
files src/video/quartz/SDL_QuartzEvents.m
diffstat 1 files changed, 11 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/src/video/quartz/SDL_QuartzEvents.m	Mon Jun 04 11:15:58 2007 +0000
+++ b/src/video/quartz/SDL_QuartzEvents.m	Mon Jun 04 11:22:23 2007 +0000
@@ -722,7 +722,6 @@
 {
     static Uint32 screensaverTicks = 0;
     Uint32 nowTicks;
-    int firstMouseEvent;
     CGMouseDelta dx, dy;
 
     NSDate *distantPast;
@@ -748,10 +747,7 @@
 
     winRect = NSMakeRect (0, 0, SDL_VideoSurface->w, SDL_VideoSurface->h);
     
-    /* send the first mouse event in absolute coordinates */
-    firstMouseEvent = 1;
-    
-    /* accumulate any additional mouse moved events into one SDL mouse event */
+    /* while grabbed, accumulate all mouse moved events into one SDL mouse event */
     dx = 0;
     dy = 0;
     
@@ -853,29 +849,22 @@
                         dx += dx1;
                         dy += dy1;
                     }
-                    else if (firstMouseEvent) {
+                    else {
                         
                         /*
-                            Get the first mouse event in a possible
-                            sequence of mouse moved events. Since we
-                            use absolute coordinates, this serves to
-                            compensate any inaccuracy in deltas, and
-                            provides the first known mouse position,
-                            since everything after this uses deltas
+                            Get the absolute mouse location. This is not the
+                            mouse location after the currently processed event,
+                            but the *current* mouse location, i.e. after all
+                            pending events. This means that if there are
+                            multiple mouse moved events in the queue, we make
+                            multiple identical calls to SDL_PrivateMouseMotion(),
+                            but that's no problem since the latter only
+                            generates SDL events for nonzero movements. In my
+                            experience on PBG4/10.4.8, this rarely happens anyway.
                         */
                         NSPoint p;
                         QZ_GetMouseLocation (this, &p);
                         SDL_PrivateMouseMotion (0, 0, p.x, p.y);
-                        firstMouseEvent = 0;
-                   }
-                    else {
-                    
-                        /*
-                            Get the amount moved since the last drag or move event,
-                            add it on for one big move event at the end.
-                        */
-                        dx += [ event deltaX ];
-                        dy += [ event deltaY ];
                     }
                     
                     /*