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 GitHub
parent 45e0454a3b
commit a0de8ea81d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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

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