From: Timo Korvola Date: Wed, 28 Mar 2018 18:37:51 +0000 (+0300) Subject: Handle expose events. X-Git-Url: https://scope-eye.net/git/?a=commitdiff_plain;h=dc289f37745f621048a6c46723d72f7bad81b1a9;p=liskon_frotz.git Handle expose events. Expose events are handled even in os_tick. --- diff --git a/src/sdl/sf_frotz.h b/src/sdl/sf_frotz.h index 727ff68..d95cb22 100644 --- a/src/sdl/sf_frotz.h +++ b/src/sdl/sf_frotz.h @@ -233,7 +233,7 @@ void sf_poptextsettings(void); void sf_chline( int x, int y, ulong c, int n); void sf_cvline( int x, int y, ulong c, int n); -void sf_flushdisplay(void); +bool sf_flushdisplay(void); void sf_getclip( int *x, int *y, int *w, int *h); void sf_rect( unsigned long color, int x, int y, int w, int h); void sf_setclip( int x, int y, int w, int h); diff --git a/src/sdl/sf_sound.c b/src/sdl/sf_sound.c index 626493e..2268aed 100644 --- a/src/sdl/sf_sound.c +++ b/src/sdl/sf_sound.c @@ -405,15 +405,5 @@ void sf_checksound() } } -void os_tick() - { - sf_checksound(); - if (SFticked) - { - SFticked = false; - sf_flushdisplay(); - } - } - /////////////////////////////////////// diff --git a/src/sdl/sf_video.c b/src/sdl/sf_video.c index f1ca7f1..b1bfc91 100644 --- a/src/sdl/sf_video.c +++ b/src/sdl/sf_video.c @@ -342,11 +342,18 @@ static void scroll( int x, int y, int w, int h, int n) } } -void sf_flushdisplay() - { - if (dirty) myGrefresh(); - dirty = 0; - } +/** + * Update the display if contents have changed. + * Return whether contents had changed, i.e., display was updated. + */ +bool sf_flushdisplay() { + if (dirty) { + myGrefresh(); + dirty = 0; + return true; + } else + return false; +} /* * os_scroll_area @@ -586,6 +593,14 @@ static zword decode_utf8(char *str) return res; } +static void handle_window_event(SDL_Event *e) +{ + switch (e->window.event) { + case SDL_WINDOWEVENT_EXPOSED: + SDL_RenderPresent(renderer); + } +} + static zword goodzkey( SDL_Event *e, int allowed) { SDL_Keycode c; @@ -678,9 +693,10 @@ static zword goodzkey( SDL_Event *e, int allowed) return res; else return 0; - default: - return 0; + case SDL_WINDOWEVENT: + handle_window_event(e); } + return 0; } zword sf_read_key( int timeout, bool cursor, bool allowed, bool text) @@ -1136,3 +1152,16 @@ static void sf_quitconf() } } +void os_tick() { + sf_checksound(); + if (SFticked) { + SFticked = false; + if (!sf_flushdisplay()) { + SDL_Event ev; + SDL_PumpEvents(); + while (SDL_PeepEvents(&ev, 1, SDL_GETEVENT, + SDL_WINDOWEVENT, SDL_WINDOWEVENT) > 0) + handle_window_event(&ev); + } + } +}