From: Holger Schemel Date: Wed, 6 Dec 2000 00:48:28 +0000 (+0100) Subject: rnd-20001206-1-src X-Git-Tag: 2.0.0^2~10 X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=commitdiff_plain;h=d2098db6b7b0cee3b43e341c012beec5bc6ef6bd rnd-20001206-1-src --- diff --git a/src/events.c b/src/events.c index 1e2ca168..f4e690f8 100644 --- a/src/events.c +++ b/src/events.c @@ -45,6 +45,23 @@ int FilterMouseMotionEvents(const Event *event) return 1; } +/* this is only really needed for non-SDL targets to filter unwanted events; + when using SDL with properly installed event filter, this function can be + replaced with a simple "NextEvent()" call, but it doesn't hurt either */ + +static boolean NextValidEvent(Event *event) +{ + while (PendingEvent()) + { + NextEvent(event); + + if (FilterMouseMotionEvents(event)) + return TRUE; + } + + return FALSE; +} + void EventLoop(void) { while(1) @@ -53,9 +70,7 @@ void EventLoop(void) { Event event; - NextEvent(&event); - - if (FilterMouseMotionEvents(&event)) + if (NextValidEvent(&event)) { switch(event.type) { diff --git a/src/init.c b/src/init.c index 3b607274..304b1037 100644 --- a/src/init.c +++ b/src/init.c @@ -62,12 +62,12 @@ void OpenAll(void) InitJoysticks(); InitRND(NEW_RANDOMIZE); - InitEventFilter(FilterMouseMotionEvents); - InitVideoDisplay(); InitVideoBuffer(&backbuffer, &window, WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH, setup.fullscreen); + InitEventFilter(FilterMouseMotionEvents); + InitGfx(); InitElementProperties(); /* initializes IS_CHAR() for el2gfx() */ diff --git a/src/libgame/sdl.c b/src/libgame/sdl.c index 7c38aa94..a4fbf7de 100644 --- a/src/libgame/sdl.c +++ b/src/libgame/sdl.c @@ -24,8 +24,8 @@ inline void SDLInitVideoDisplay(void) { /* initialize SDL video */ - if (SDL_Init(SDL_INIT_VIDEO) < 0) - Error(ERR_EXIT, "SDL_Init() failed: %s", SDL_GetError()); + if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) + Error(ERR_EXIT, "SDL_InitSubSystem() failed: %s", SDL_GetError()); /* set default SDL depth */ video.default_depth = SDL_GetVideoInfo()->vfmt->BitsPerPixel; @@ -707,9 +707,9 @@ Bitmap *SDLLoadImage(char *filename) inline boolean SDLOpenAudio(void) { - if (SDL_Init(SDL_INIT_AUDIO) < 0) + if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) { - Error(ERR_WARN, "SDL_Init() failed: %s", SDL_GetError()); + Error(ERR_WARN, "SDL_InitSubSystem() failed: %s", SDL_GetError()); return FALSE; } diff --git a/src/libgame/system.c b/src/libgame/system.c index 07d4de79..341da455 100644 --- a/src/libgame/system.c +++ b/src/libgame/system.c @@ -89,6 +89,11 @@ void InitPlatformDependantStuff(void) #if !defined(PLATFORM_UNIX) initErrorFile(); #endif + +#if defined(TARGET_SDL) + if (SDL_Init(SDL_INIT_EVENTTHREAD | SDL_INIT_NOPARACHUTE) < 0) + Error(ERR_EXIT, "SDL_Init() failed: %s", SDL_GetError()); +#endif } void ClosePlatformDependantStuff(void)