From e41fa8fc818bf3ee728975bab2a25613678e1093 Mon Sep 17 00:00:00 2001 From: William Kendrick Date: Fri, 22 Apr 2011 01:02:57 +0000 Subject: [PATCH] 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") --- src/tuxpaint.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/tuxpaint.c b/src/tuxpaint.c index 038c8f330..bc33ee6a5 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; }