Fixed mouse warp position bug with offset video modes
authorSam Lantinga <slouken@libsdl.org>
Fri, 11 Oct 2002 08:09:26 +0000
changeset 5275c74ac147358
parent 526 4314a501d7be
child 528 9cba51c7a4ef
Fixed mouse warp position bug with offset video modes
src/video/SDL_cursor.c
src/video/vgl/SDL_vglmouse.c
src/video/wincommon/SDL_sysmouse.c
src/video/x11/SDL_x11mouse.c
     1.1 --- a/src/video/SDL_cursor.c	Fri Oct 11 07:56:36 2002 +0000
     1.2 +++ b/src/video/SDL_cursor.c	Fri Oct 11 08:09:26 2002 +0000
     1.3 @@ -295,13 +295,15 @@
     1.4  	SDL_VideoDevice *video = current_video;
     1.5  	SDL_VideoDevice *this  = current_video;
     1.6  
     1.7 +	/* If we have an offset video mode, offset the mouse coordinates */
     1.8 +	x += (this->screen->offset % this->screen->pitch) /
     1.9 +	      this->screen->format->BytesPerPixel;
    1.10 +	y += (this->screen->offset / this->screen->pitch);
    1.11 +
    1.12  	/* This generates a mouse motion event */
    1.13  	if ( video->WarpWMCursor ) {
    1.14  		video->WarpWMCursor(this, x, y);
    1.15  	} else {
    1.16 -		x += (this->screen->offset % this->screen->pitch) /
    1.17 -		      this->screen->format->BytesPerPixel;
    1.18 -		y += (this->screen->offset / this->screen->pitch);
    1.19  		SDL_PrivateMouseMotion(0, 0, x, y);
    1.20  	}
    1.21  }
     2.1 --- a/src/video/vgl/SDL_vglmouse.c	Fri Oct 11 07:56:36 2002 +0000
     2.2 +++ b/src/video/vgl/SDL_vglmouse.c	Fri Oct 11 08:09:26 2002 +0000
     2.3 @@ -58,9 +58,6 @@
     2.4  
     2.5  void VGL_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
     2.6  {
     2.7 -	x += (this->screen->offset % this->screen->pitch) /
     2.8 -	      this->screen->format->BytesPerPixel;
     2.9 -	y += (this->screen->offset / this->screen->pitch);
    2.10  	SDL_PrivateMouseMotion(0, 0, x, y);
    2.11  }
    2.12  
     3.1 --- a/src/video/wincommon/SDL_sysmouse.c	Fri Oct 11 07:56:36 2002 +0000
     3.2 +++ b/src/video/wincommon/SDL_sysmouse.c	Fri Oct 11 08:09:26 2002 +0000
     3.3 @@ -213,12 +213,7 @@
     3.4  
     3.5  void WIN_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
     3.6  {
     3.7 -	POINT pt;
     3.8 -
     3.9  	if ( DDRAW_FULLSCREEN() ) {
    3.10 -		x += (this->screen->offset % this->screen->pitch) /
    3.11 -		      this->screen->format->BytesPerPixel;
    3.12 -		y += (this->screen->offset / this->screen->pitch);
    3.13  		SDL_PrivateMouseMotion(0, 0, x, y);
    3.14  	} else if ( mouse_relative) {
    3.15  		/*	RJR: March 28, 2000
    3.16 @@ -226,6 +221,7 @@
    3.17  			mouse hidden and grabbed */
    3.18  		SDL_PrivateMouseMotion(0, 0, x, y);
    3.19  	} else {
    3.20 +		POINT pt;
    3.21  		pt.x = x;
    3.22  		pt.y = y;
    3.23  		ClientToScreen(SDL_Window, &pt);
     4.1 --- a/src/video/x11/SDL_x11mouse.c	Fri Oct 11 07:56:36 2002 +0000
     4.2 +++ b/src/video/x11/SDL_x11mouse.c	Fri Oct 11 08:09:26 2002 +0000
     4.3 @@ -177,9 +177,11 @@
     4.4  void X11_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
     4.5  {
     4.6  	if ( using_dga & DGA_MOUSE ) {
     4.7 -		x += (this->screen->offset % this->screen->pitch) /
     4.8 -		      this->screen->format->BytesPerPixel;
     4.9 -		y += (this->screen->offset / this->screen->pitch);
    4.10 +		SDL_PrivateMouseMotion(0, 0, x, y);
    4.11 +	} else if ( mouse_relative) {
    4.12 +		/*	RJR: March 28, 2000
    4.13 +			leave physical cursor at center of screen if
    4.14 +			mouse hidden and grabbed */
    4.15  		SDL_PrivateMouseMotion(0, 0, x, y);
    4.16  	} else {
    4.17  		SDL_Lock_EventThread();