X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fsdl.c;h=e9d10df51f3a8103acb3520b27615e00cb487e1c;hb=df11f4a529251a285f3a33946da81623044fef3f;hp=18e384c5e13530a60fb75db743059714e5f902b6;hpb=e57078603232563176d90bb543ce2bc3a15b889e;p=rocksndiamonds.git diff --git a/src/libgame/sdl.c b/src/libgame/sdl.c index 18e384c5..e9d10df5 100644 --- a/src/libgame/sdl.c +++ b/src/libgame/sdl.c @@ -26,9 +26,9 @@ /* functions from SGE library */ inline void sge_Line(SDL_Surface *, Sint16, Sint16, Sint16, Sint16, Uint32); -#ifdef PLATFORM_WIN32 +/* #ifdef PLATFORM_WIN32 */ #define FULLSCREEN_BUG -#endif +/* #endif */ /* stuff needed to work around SDL/Windows fullscreen drawing bug */ static int fullscreen_width; @@ -71,7 +71,7 @@ inline void SDLInitVideoBuffer(DrawBuffer **backbuffer, DrawWindow **window, fullscreen_yoffset = 0; #ifdef FULLSCREEN_BUG - for (i=0; screen_xy[i][0] != -1; i++) + for (i = 0; screen_xy[i][0] != -1; i++) { if (video.width <= screen_xy[i][0] && video.height <= screen_xy[i][1]) { @@ -340,11 +340,11 @@ inline void SDLDrawLines(SDL_Surface *surface, struct XY *points, int i, x, y; int line_width = 4; - for (i=0; isurface, x, y, pixel); } @@ -881,9 +889,9 @@ inline void SDLInvertArea(Bitmap *bitmap, int src_x, int src_y, { int x, y; - for (y=src_y; y < src_y + height; y++) + for (y = src_y; y < src_y + height; y++) { - for (x=src_x; x < src_x + width; x++) + for (x = src_x; x < src_x + width; x++) { Uint32 pixel = SDLGetPixel(bitmap, x, y); @@ -898,9 +906,9 @@ inline void SDLCopyInverseMasked(Bitmap *src_bitmap, Bitmap *dst_bitmap, { int x, y; - for (y=0; y < height; y++) + for (y = 0; y < height; y++) { - for (x=0; x < width; x++) + for (x = 0; x < width; x++) { Uint32 pixel = SDLGetPixel(src_bitmap, src_x + x, src_y + y); @@ -1173,7 +1181,7 @@ SDL_Surface *zoomSurface(SDL_Surface *src, int dst_width, int dst_height) else { /* copy palette */ - for (i=0; i < zoom_src->format->palette->ncolors; i++) + for (i = 0; i < zoom_src->format->palette->ncolors; i++) zoom_dst->format->palette->colors[i] = zoom_src->format->palette->colors[i]; zoom_dst->format->palette->ncolors = zoom_src->format->palette->ncolors; @@ -1269,19 +1277,26 @@ static SDL_Cursor *create_cursor(struct MouseCursorInfo *cursor_info) void SDLSetMouseCursor(struct MouseCursorInfo *cursor_info) { static struct MouseCursorInfo *last_cursor_info = NULL; + static struct MouseCursorInfo *last_cursor_info2 = NULL; static SDL_Cursor *cursor_default = NULL; static SDL_Cursor *cursor_current = NULL; + /* if invoked for the first time, store the SDL default cursor */ if (cursor_default == NULL) cursor_default = SDL_GetCursor(); + /* only create new cursor if cursor info (custom only) has changed */ if (cursor_info != NULL && cursor_info != last_cursor_info) { cursor_current = create_cursor(cursor_info); last_cursor_info = cursor_info; } - SDL_SetCursor(cursor_info ? cursor_current : cursor_default); + /* only set new cursor if cursor info (custom or NULL) has changed */ + if (cursor_info != last_cursor_info2) + SDL_SetCursor(cursor_info ? cursor_current : cursor_default); + + last_cursor_info2 = cursor_info; } @@ -1354,14 +1369,14 @@ inline void SDLNextEvent(Event *event) } else if (event->type == EVENT_MOTIONNOTIFY) { - if (((ButtonEvent *)event)->x > video_xoffset) - ((ButtonEvent *)event)->x -= video_xoffset; + if (((MotionEvent *)event)->x > video_xoffset) + ((MotionEvent *)event)->x -= video_xoffset; else - ((ButtonEvent *)event)->x = 0; - if (((ButtonEvent *)event)->y > video_yoffset) - ((ButtonEvent *)event)->y -= video_yoffset; + ((MotionEvent *)event)->x = 0; + if (((MotionEvent *)event)->y > video_yoffset) + ((MotionEvent *)event)->y -= video_yoffset; else - ((ButtonEvent *)event)->y = 0; + ((MotionEvent *)event)->y = 0; } #endif } @@ -1439,7 +1454,7 @@ void SDLInitJoysticks() } } - for (i=0; i