From 183acf7b0fb2282b6639ec08801db52017dad503 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sat, 22 Oct 2022 22:23:05 +1100 Subject: [PATCH] Mobile webclient: Try to fix issue where webclient would end up stuck as unfocused, and pressing 'Back to Game' did nothing (e.g. after clicking OK to the 'ran out of memory' dialog in chrome on android) You can still force focus to be regained by switching to another tab or triggering the on-screen keyboard somehow by e.g. trying to change an option - although that was pretty unintuitive --- src/Window_Web.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Window_Web.c b/src/Window_Web.c index 0cb83aff5..7dad97ff8 100644 --- a/src/Window_Web.c +++ b/src/Window_Web.c @@ -102,6 +102,14 @@ extern void interop_AdjustXY(int* x, int* y); static EM_BOOL OnTouchStart(int type, const EmscriptenTouchEvent* ev, void* data) { const EmscriptenTouchPoint* t; int i, x, y; + /* Because we return true to cancel default browser behaviour, sometimes we also */ + /* end up preventing the default 'focus gained' behaviour from occurring */ + /* So manually activate focus as a workaround */ + if (!WindowInfo.Focused) { + WindowInfo.Focused = true; + Event_RaiseVoid(&WindowEvents.FocusChanged); + } + for (i = 0; i < ev->numTouches; ++i) { t = &ev->touches[i]; if (!t->isChanged) continue;