diff --git a/data/core/init.lua b/data/core/init.lua index 8c9dafcc..016385fd 100644 --- a/data/core/init.lua +++ b/data/core/init.lua @@ -1338,6 +1338,11 @@ function core.step() did_keymap = false elseif type == "mousemoved" then core.try(core.on_event, type, a, b, c, d) + elseif type == "enteringforeground" then + -- to break our frame refresh in two if we get entering/entered at the same time. + -- required to avoid flashing and refresh issues on mobile + core.redraw = true + break else local _, res = core.try(core.on_event, type, a, b, c, d) did_keymap = res or did_keymap diff --git a/src/api/system.c b/src/api/system.c index 9da499a6..ba4f39f9 100644 --- a/src/api/system.c +++ b/src/api/system.c @@ -358,6 +358,21 @@ top: lua_pushinteger(L, (lua_Integer)(e.tfinger.dy * h)); lua_pushinteger(L, e.tfinger.fingerId); return 6; + case SDL_APP_WILLENTERFOREGROUND: + case SDL_APP_DIDENTERFOREGROUND: + #ifdef LITE_USE_SDL_RENDERER + rencache_invalidate(); + #else + SDL_UpdateWindowSurface(window_renderer.window); + #endif + lua_pushstring(L, e.type == SDL_APP_WILLENTERFOREGROUND ? "enteringforeground" : "enteredforeground"); + return 1; + case SDL_APP_WILLENTERBACKGROUND: + lua_pushstring(L, "enteringbackground"); + return 1; + case SDL_APP_DIDENTERBACKGROUND: + lua_pushstring(L, "enteredbackground"); + return 1; default: goto top;