Added in support for foreground and background events. (#1395)

This commit is contained in:
Adam 2023-04-07 12:58:56 -04:00 committed by George Sokianos
parent 7f9030bfb4
commit 9634715618
2 changed files with 20 additions and 0 deletions

View File

@ -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

View File

@ -369,6 +369,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;