aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2004-03-01 11:20:32 +0000
committerMax Horn2004-03-01 11:20:32 +0000
commit0603c3a11fc377f6b20b766e046d7b1373b12319 (patch)
tree1c94c59862170b68aed1e51e1b0b5b53186fad46
parent09198784082b797f4e0b862c0f86e2ab4f1fb63d (diff)
downloadscummvm-rg350-0603c3a11fc377f6b20b766e046d7b1373b12319.tar.gz
scummvm-rg350-0603c3a11fc377f6b20b766e046d7b1373b12319.tar.bz2
scummvm-rg350-0603c3a11fc377f6b20b766e046d7b1373b12319.zip
Fix for bug #907280: Mouse glitches and crashes (Regression)
svn-id: r13123
-rw-r--r--backends/sdl/graphics.cpp30
1 files changed, 25 insertions, 5 deletions
diff --git a/backends/sdl/graphics.cpp b/backends/sdl/graphics.cpp
index 1d975b2b92..307caa724a 100644
--- a/backends/sdl/graphics.cpp
+++ b/backends/sdl/graphics.cpp
@@ -1074,12 +1074,32 @@ void OSystem_SDL::undraw_mouse() {
if (SDL_LockSurface(_overlayVisible ? _tmpscreen : _screen) == -1)
error("SDL_LockSurface failed: %s", SDL_GetError());
- const int old_mouse_x = _mouseCurState.x;
- const int old_mouse_y = _mouseCurState.y;
- const int old_mouse_w = _mouseCurState.w;
- const int old_mouse_h = _mouseCurState.h;
- int x, y;
+ int old_mouse_x = _mouseCurState.x - _mouseHotspotX;
+ int old_mouse_y = _mouseCurState.y - _mouseHotspotY;
+ int old_mouse_w = _mouseCurState.w;
+ int old_mouse_h = _mouseCurState.h;
+
+ // clip the mouse rect, and addjust the src pointer accordingly
+ if (old_mouse_x < 0) {
+ old_mouse_w += old_mouse_x;
+ old_mouse_x = 0;
+ }
+ if (old_mouse_y < 0) {
+ old_mouse_h += old_mouse_y;
+ old_mouse_y = 0;
+ }
+
+ if (old_mouse_w > _screenWidth - old_mouse_x)
+ old_mouse_w = _screenWidth - old_mouse_x;
+ if (old_mouse_h > _screenHeight - old_mouse_y)
+ old_mouse_h = _screenHeight - old_mouse_y;
+ // Quick check to see if anything has to be drawn at all
+ if (old_mouse_w <= 0 || old_mouse_h <= 0)
+ return;
+
+
+ int x, y;
if (!_overlayVisible) {
byte *dst, *bak = _mouseBackup;