diff options
author | wkendrick <wkendrick> | 2011-04-22 01:02:57 (GMT) |
---|---|---|
committer | wkendrick <wkendrick> | 2011-04-22 01:02:57 (GMT) |
commit | 9d2983b380c1f4598de19761c83d27615517dcf7 (patch) | |
tree | 8532df65acc93b06c5295c0e919b51ce0bd66d8c | |
parent | 7a76861bbd3819acea13e482d48b6dd51e7faa95 (diff) |
Silly attempt at improving event handling.
(Will probably need to set up event handling in a separate thread so that
we can have an increased mouse motion event buffer, to avoid artifacts
when drawing/moving quickly. e.g., try to draw "O", but get a "D")
-rw-r--r-- | src/tuxpaint.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/tuxpaint.c b/src/tuxpaint.c index 038c8f3..bc33ee6 100644 --- a/src/tuxpaint.c +++ b/src/tuxpaint.c @@ -5469,7 +5469,6 @@ static void mainloop(void) draw_blinking_cursor(); } } - SDL_Delay(10); } while (!done); } @@ -21533,6 +21532,25 @@ static void do_lock_file(void) free(lock_fname); } +int TP_EventFilter(const SDL_Event * event) +{ + if (event->type == SDL_QUIT || + event->type == SDL_ACTIVEEVENT || + event->type == SDL_JOYAXISMOTION || + event->type == SDL_JOYBALLMOTION || + event->type == SDL_JOYBUTTONDOWN || + event->type == SDL_JOYBUTTONUP || + event->type == SDL_KEYDOWN || + event->type == SDL_KEYUP || + event->type == SDL_MOUSEBUTTONDOWN || + event->type == SDL_MOUSEBUTTONUP || + event->type == SDL_MOUSEMOTION || + event->type == SDL_QUIT || + event->type == SDL_USEREVENT) + return 1; + + return 0; +} ///////////////////////////////////////////////////////////////////////////// static void setup(void) @@ -21630,6 +21648,10 @@ static void setup(void) } } + /* Set up event filter */ + + SDL_SetEventFilter(TP_EventFilter); + #ifndef NOSOUND #ifndef WIN32 @@ -23686,7 +23708,7 @@ void on_screen_keyboard(void ) SDL_UpdateRect(screen, 0, 0, 640, 480); - SDL_Delay(10); + /* SDL_Delay(10); */ /* FIXME: This should not be necessary! -bjk 2011.04.21 */ keybd_flag = 1; } |