Skip to content

Commit

Permalink
Fixed mouse warp position bug with offset video modes
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Oct 11, 2002
1 parent 7812a4e commit 0b101b7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
8 changes: 5 additions & 3 deletions src/video/SDL_cursor.c
Expand Up @@ -295,13 +295,15 @@ void SDL_WarpMouse (Uint16 x, Uint16 y)
SDL_VideoDevice *video = current_video;
SDL_VideoDevice *this = current_video;

/* If we have an offset video mode, offset the mouse coordinates */
x += (this->screen->offset % this->screen->pitch) /
this->screen->format->BytesPerPixel;
y += (this->screen->offset / this->screen->pitch);

/* This generates a mouse motion event */
if ( video->WarpWMCursor ) {
video->WarpWMCursor(this, x, y);
} else {
x += (this->screen->offset % this->screen->pitch) /
this->screen->format->BytesPerPixel;
y += (this->screen->offset / this->screen->pitch);
SDL_PrivateMouseMotion(0, 0, x, y);
}
}
Expand Down
3 changes: 0 additions & 3 deletions src/video/vgl/SDL_vglmouse.c
Expand Up @@ -58,9 +58,6 @@ int VGL_ShowWMCursor(_THIS, WMcursor *cursor)

void VGL_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
{
x += (this->screen->offset % this->screen->pitch) /
this->screen->format->BytesPerPixel;
y += (this->screen->offset / this->screen->pitch);
SDL_PrivateMouseMotion(0, 0, x, y);
}

6 changes: 1 addition & 5 deletions src/video/wincommon/SDL_sysmouse.c
Expand Up @@ -213,19 +213,15 @@ int WIN_ShowWMCursor(_THIS, WMcursor *cursor)

void WIN_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
{
POINT pt;

if ( DDRAW_FULLSCREEN() ) {
x += (this->screen->offset % this->screen->pitch) /
this->screen->format->BytesPerPixel;
y += (this->screen->offset / this->screen->pitch);
SDL_PrivateMouseMotion(0, 0, x, y);
} else if ( mouse_relative) {
/* RJR: March 28, 2000
leave physical cursor at center of screen if
mouse hidden and grabbed */
SDL_PrivateMouseMotion(0, 0, x, y);
} else {
POINT pt;
pt.x = x;
pt.y = y;
ClientToScreen(SDL_Window, &pt);
Expand Down
8 changes: 5 additions & 3 deletions src/video/x11/SDL_x11mouse.c
Expand Up @@ -177,9 +177,11 @@ int X11_ShowWMCursor(_THIS, WMcursor *cursor)
void X11_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
{
if ( using_dga & DGA_MOUSE ) {
x += (this->screen->offset % this->screen->pitch) /
this->screen->format->BytesPerPixel;
y += (this->screen->offset / this->screen->pitch);
SDL_PrivateMouseMotion(0, 0, x, y);
} else if ( mouse_relative) {
/* RJR: March 28, 2000
leave physical cursor at center of screen if
mouse hidden and grabbed */
SDL_PrivateMouseMotion(0, 0, x, y);
} else {
SDL_Lock_EventThread();
Expand Down

0 comments on commit 0b101b7

Please sign in to comment.