diff --git a/sdl2/pdcdisp.c b/sdl2/pdcdisp.c index 79eec1f2..4409d260 100644 --- a/sdl2/pdcdisp.c +++ b/sdl2/pdcdisp.c @@ -556,6 +556,5 @@ void PDC_blink_text(void) void PDC_doupdate(void) { - PDC_update_rects(); - SDL_Delay(1); + PDC_napms(1); } diff --git a/sdl2/pdckbd.c b/sdl2/pdckbd.c index 0ac76a7f..8e42eb70 100644 --- a/sdl2/pdckbd.c +++ b/sdl2/pdckbd.c @@ -400,6 +400,19 @@ static int _process_mouse_event(void) return KEY_MOUSE; } +int PDC_event_filter(void *userdata, SDL_Event *event) +{ + if (SDL_WINDOWEVENT == event->type && + (SDL_WINDOWEVENT_RESTORED == event->window.event || + SDL_WINDOWEVENT_EXPOSED == event->window.event)) + { + SDL_UpdateWindowSurface(pdc_window); + return 0; + } + + return 1; +} + /* return the next available key or mouse event */ int PDC_get_key(void) @@ -409,9 +422,8 @@ int PDC_get_key(void) case SDL_QUIT: exit(1); case SDL_WINDOWEVENT: - switch (event.window.event) + if (SDL_WINDOWEVENT_SIZE_CHANGED == event.window.event) { - case SDL_WINDOWEVENT_SIZE_CHANGED: pdc_screen = SDL_GetWindowSurface(pdc_window); pdc_sheight = pdc_screen->h - pdc_xoffset; pdc_swidth = pdc_screen->w - pdc_yoffset; @@ -424,10 +436,6 @@ int PDC_get_key(void) SP->key_code = TRUE; return KEY_RESIZE; } - break; - case SDL_WINDOWEVENT_RESTORED: - case SDL_WINDOWEVENT_EXPOSED: - SDL_UpdateWindowSurface(pdc_window); } break; case SDL_MOUSEMOTION: diff --git a/sdl2/pdcscrn.c b/sdl2/pdcscrn.c index 93b308a8..e0a52ea2 100644 --- a/sdl2/pdcscrn.c +++ b/sdl2/pdcscrn.c @@ -311,6 +311,8 @@ int PDC_scr_open(void) PDC_reset_prog_mode(); + SDL_SetEventFilter(PDC_event_filter, NULL); + return OK; } diff --git a/sdl2/pdcsdl.h b/sdl2/pdcsdl.h index 6fa37751..01d3f994 100644 --- a/sdl2/pdcsdl.h +++ b/sdl2/pdcsdl.h @@ -32,4 +32,5 @@ extern bool pdc_own_window; /* if pdc_window was not set PDCEX void PDC_update_rects(void); PDCEX void PDC_retile(void); +extern int PDC_event_filter(void *, SDL_Event *); extern void PDC_blink_text(void); diff --git a/sdl2/pdcutil.c b/sdl2/pdcutil.c index 3f0e9dc3..222e5a99 100644 --- a/sdl2/pdcutil.c +++ b/sdl2/pdcutil.c @@ -12,6 +12,12 @@ void PDC_napms(int ms) PDC_LOG(("PDC_napms() - called: ms=%d\n", ms)); PDC_update_rects(); + while (ms > 50) + { + SDL_PumpEvents(); + SDL_Delay(50); + ms -= 50; + } SDL_PumpEvents(); SDL_Delay(ms); }