Batch x11 dga mouse motion events into a single SDL event. SDL-1.2
authorRyan C. Gordon <icculus@icculus.org>
Tue, 29 Sep 2009 11:28:43 +0000
branchSDL-1.2
changeset 4264d6f4cc9a5bf6
parent 4263 3c12d2e84bcb
child 4265 c7b1d5eaa77d
Batch x11 dga mouse motion events into a single SDL event.

Untested attempt to fix Bugzilla #609. Do not merge into 1.3 in any case.
src/video/x11/SDL_x11events.c
src/video/x11/SDL_x11video.h
     1.1 --- a/src/video/x11/SDL_x11events.c	Tue Sep 29 06:31:29 2009 +0000
     1.2 +++ b/src/video/x11/SDL_x11events.c	Tue Sep 29 11:28:43 2009 +0000
     1.3 @@ -515,9 +515,9 @@
     1.4  #ifdef DEBUG_MOTION
     1.5    printf("DGA motion: %d,%d\n", xevent.xmotion.x_root, xevent.xmotion.y_root);
     1.6  #endif
     1.7 -					posted = SDL_PrivateMouseMotion(0, 1,
     1.8 -							xevent.xmotion.x_root,
     1.9 -							xevent.xmotion.y_root);
    1.10 +					/* batch DGA motion into one event, queued later. */
    1.11 +					dga_x += xevent.xmotion.x_root;
    1.12 +					dga_y += xevent.xmotion.y_root;
    1.13  				} else {
    1.14  					posted = X11_WarpedMotion(this,&xevent);
    1.15  				}
    1.16 @@ -931,6 +931,16 @@
    1.17  		X11_DispatchEvent(this);
    1.18  		++pending;
    1.19  	}
    1.20 +
    1.21 +	/* We batch up all the DGA motion events and generate a single SDL
    1.22 +	   event from them, since newer x.org releases might send a LOT of
    1.23 +	   these at once and flood the SDL event queue. --ryan. */
    1.24 +	if (dga_x || dga_y) {
    1.25 +		SDL_PrivateMouseMotion(0, 1, dga_x, dga_y);
    1.26 +		dga_x = 0;
    1.27 +		dga_y = 0;
    1.28 +	}
    1.29 +
    1.30  	if ( switch_waiting ) {
    1.31  		Uint32 now;
    1.32  
     2.1 --- a/src/video/x11/SDL_x11video.h	Tue Sep 29 06:31:29 2009 +0000
     2.2 +++ b/src/video/x11/SDL_x11video.h	Tue Sep 29 11:28:43 2009 +0000
     2.3 @@ -70,6 +70,8 @@
     2.4  
     2.5      /* Direct Graphics Access extension information */
     2.6      int using_dga;
     2.7 +    Sint16 dga_x;
     2.8 +    Sint16 dga_y;
     2.9  
    2.10  #ifndef NO_SHARED_MEMORY
    2.11      /* MIT shared memory extension information */
    2.12 @@ -172,6 +174,8 @@
    2.13  #define SDL_IC			(this->hidden->X11_IC)
    2.14  #define SDL_windowid		(this->hidden->SDL_windowid)
    2.15  #define using_dga		(this->hidden->using_dga)
    2.16 +#define dga_x			(this->hidden->dga_x)
    2.17 +#define dga_y			(this->hidden->dga_y)
    2.18  #define use_mitshm		(this->hidden->use_mitshm)
    2.19  #define shminfo			(this->hidden->shminfo)
    2.20  #define SDL_Ximage		(this->hidden->Ximage)