[client] keybind: validate and consume chord events

This commit is contained in:
Geoffrey McRae
2026-08-12 04:58:36 +10:00
parent 7b5936574c
commit f8cf0740e3
2 changed files with 23 additions and 7 deletions

View File

@@ -416,12 +416,14 @@ void app_handleKeyPressInternal(int sc)
g_state.escapeActive = true;
g_state.escapeTime = microtime();
g_state.escapeAction = -1;
g_state.escapeKeys[sc] = true;
return;
}
if (g_state.escapeActive)
{
g_state.escapeAction = sc;
g_state.escapeKeys[sc] = true;
KeybindHandle handle;
ll_forEachNL(g_state.bindings, item, handle)
{
@@ -435,6 +437,8 @@ void app_handleKeyPressInternal(int sc)
}
}
g_state.escapeKeys[sc] = false;
if (app_isOverlayMode())
{
if (sc == KEY_ESC)
@@ -459,7 +463,7 @@ void app_handleKeyPressInternal(int sc)
void app_handleKeyReleaseInternal(int sc)
{
if (g_state.escapeActive)
if (g_state.escapeActive && sc == g_params.escapeKey)
{
if (g_state.escapeAction == -1)
{
@@ -468,10 +472,15 @@ void app_handleKeyReleaseInternal(int sc)
core_setGrab(!g_cursor.grab);
}
if (sc == g_params.escapeKey)
g_state.escapeActive = false;
}
if (g_state.escapeKeys[sc])
{
g_state.escapeKeys[sc] = false;
return;
}
if (app_isOverlayMode())
{
if (linux_to_imgui[sc])
@@ -759,6 +768,12 @@ void app_showRecord(bool show)
KeybindHandle app_registerKeybind(int sc, KeybindFn callback, void * opaque,
const char * description)
{
if (!callback)
{
DEBUG_ERROR("invalid keybind callback");
return NULL;
}
if (sc <= KEY_RESERVED || sc >= KEY_MAX || !linux_to_display[sc])
{
DEBUG_ERROR("invalid keybind keycode: %d", sc);

View File

@@ -124,6 +124,7 @@ struct AppState
bool escapeActive;
uint64_t escapeTime;
int escapeAction;
bool escapeKeys[KEY_MAX];
bool escapeHelp;
struct ll * bindings;
bool haveSrcSize;