From 0b101b78b10011b92d808f9e2c3343ea520605d0 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 11 Oct 2002 08:09:26 +0000 Subject: [PATCH] Fixed mouse warp position bug with offset video modes --- src/video/SDL_cursor.c | 8 +++++--- src/video/vgl/SDL_vglmouse.c | 3 --- src/video/wincommon/SDL_sysmouse.c | 6 +----- src/video/x11/SDL_x11mouse.c | 8 +++++--- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/video/SDL_cursor.c b/src/video/SDL_cursor.c index 8d23a33c4..3d19abade 100644 --- a/src/video/SDL_cursor.c +++ b/src/video/SDL_cursor.c @@ -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); } } diff --git a/src/video/vgl/SDL_vglmouse.c b/src/video/vgl/SDL_vglmouse.c index 4f700c854..540df3cc7 100644 --- a/src/video/vgl/SDL_vglmouse.c +++ b/src/video/vgl/SDL_vglmouse.c @@ -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); } diff --git a/src/video/wincommon/SDL_sysmouse.c b/src/video/wincommon/SDL_sysmouse.c index 3314273a3..ddb8def94 100644 --- a/src/video/wincommon/SDL_sysmouse.c +++ b/src/video/wincommon/SDL_sysmouse.c @@ -213,12 +213,7 @@ 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 @@ -226,6 +221,7 @@ void WIN_WarpWMCursor(_THIS, Uint16 x, Uint16 y) mouse hidden and grabbed */ SDL_PrivateMouseMotion(0, 0, x, y); } else { + POINT pt; pt.x = x; pt.y = y; ClientToScreen(SDL_Window, &pt); diff --git a/src/video/x11/SDL_x11mouse.c b/src/video/x11/SDL_x11mouse.c index d6f7d3a1b..a4a9ac0d9 100644 --- a/src/video/x11/SDL_x11mouse.c +++ b/src/video/x11/SDL_x11mouse.c @@ -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();