diff options
| author | Petr Mrázek | 2012-02-28 12:59:02 +0100 |
|---|---|---|
| committer | Petr Mrázek | 2012-02-28 12:59:02 +0100 |
| commit | 95ac3db54280f3a28f7d6076714aa8250c831eec (patch) | |
| tree | 9cc913f91139d3cd445ed0059671a366c61d3245 /library/Hooks-linux.cpp | |
| parent | 731472a4781f091ae313bd39d512207e920db10c (diff) | |
| download | dfhack-95ac3db54280f3a28f7d6076714aa8250c831eec.tar.gz dfhack-95ac3db54280f3a28f7d6076714aa8250c831eec.tar.bz2 dfhack-95ac3db54280f3a28f7d6076714aa8250c831eec.tar.xz | |
Fix normal hooks.
Diffstat (limited to 'library/Hooks-linux.cpp')
| -rw-r--r-- | library/Hooks-linux.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/library/Hooks-linux.cpp b/library/Hooks-linux.cpp index 9ceeeff6..aeb719b8 100644 --- a/library/Hooks-linux.cpp +++ b/library/Hooks-linux.cpp @@ -69,12 +69,18 @@ DFhackCExport void SDL_Quit(void) static int (*_SDL_PollEvent)(SDL::Event* event) = 0; DFhackCExport int SDL_PollEvent(SDL::Event* event) { + pollevent_again: + // if SDL returns 0 here, it means there are no more events. return 0 int orig_return = _SDL_PollEvent(event); - // if the event is valid, intercept - if( event != 0 ) + if(!orig_return) + return 0; + // otherwise we have an event to filter + else if( event != 0 ) { DFHack::Core & c = DFHack::Core::getInstance(); - return c.SDL_Event(event, orig_return); + // if we consume the event, ask SDL for more. + if(!c.SDL_Event(event)) + goto pollevent_again; } return orig_return; } |
