diff --git a/client/include/app.h b/client/include/app.h index 872e9ffc..18962a16 100644 --- a/client/include/app.h +++ b/client/include/app.h @@ -54,6 +54,7 @@ void app_handleKeyRelease(int scancode); void app_handleEnterEvent(bool entered); void app_handleFocusEvent(bool focused); void app_handleCloseEvent(void); +void app_handleRenderEvent(const uint64_t timeUs); void app_setFullscreen(bool fs); bool app_getFullscreen(void); diff --git a/client/src/app.c b/client/src/app.c index 3d540dee..babea6f3 100644 --- a/client/src/app.c +++ b/client/src/app.c @@ -196,7 +196,6 @@ void app_handleKeyPress(int sc) g_state.escapeActive = true; g_state.escapeTime = microtime(); g_state.escapeAction = -1; - app_showHelp(true); return; } @@ -234,7 +233,7 @@ void app_handleKeyRelease(int sc) { if (g_state.escapeAction == -1) { - if (microtime() - g_state.escapeTime < 500000 && g_params.useSpiceInput) + if (!g_state.escapeHelp && g_params.useSpiceInput) core_setGrab(!g_cursor.grab); } else @@ -248,10 +247,7 @@ void app_handleKeyRelease(int sc) } if (sc == g_params.escapeKey) - { g_state.escapeActive = false; - app_showHelp(false); - } } if (!core_inputEnabled()) @@ -386,6 +382,26 @@ void app_handleCloseEvent(void) g_state.state = APP_STATE_SHUTDOWN; } +void app_handleRenderEvent(const uint64_t timeUs) +{ + if (!g_state.escapeActive) + { + if (g_state.escapeHelp) + { + g_state.escapeHelp = false; + app_showHelp(false); + } + } + else + { + if (!g_state.escapeHelp && timeUs - g_state.escapeTime > 200000) + { + g_state.escapeHelp = true; + app_showHelp(true); + } + } +} + void app_setFullscreen(bool fs) { g_state.ds->setFullscreen(fs); diff --git a/client/src/main.c b/client/src/main.c index 45238f3d..425a1156 100644 --- a/client/src/main.c +++ b/client/src/main.c @@ -157,7 +157,8 @@ static int renderThread(void * unused) } } - if (!g_state.resizeDone && g_state.resizeTimeout < microtime()) + const uint64_t now = microtime(); + if (!g_state.resizeDone && g_state.resizeTimeout < now) { g_state.ds->setWindowSize( g_state.dstRect.w, @@ -165,6 +166,8 @@ static int renderThread(void * unused) ); g_state.resizeDone = true; } + + app_handleRenderEvent(now); } g_state.state = APP_STATE_SHUTDOWN; diff --git a/client/src/main.h b/client/src/main.h index 382dc643..39675773 100644 --- a/client/src/main.h +++ b/client/src/main.h @@ -51,6 +51,7 @@ struct AppState bool escapeActive; uint64_t escapeTime; int escapeAction; + bool escapeHelp; KeybindHandle bindings[KEY_MAX]; const char * keyDescription[KEY_MAX]; bool keyDown[KEY_MAX];