Skip to content

Commit

Permalink
Fix race condition in forced unicode character input
Browse files Browse the repository at this point in the history
We would previously check the window to see if the input request was for a
unicode character, after cancelling the input request; so there was a race
condition where the input request type might end up being NONE, meaning
that we could not generate a character input event for a non-Latin1 key.
  • Loading branch information
ptomato committed Sep 24, 2023
1 parent 3c541dc commit 06b9ef6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion libchimara/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ force_char_input_from_queue(winid_t win, event_t *event)
{
ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key);
guint keyval = GPOINTER_TO_UINT(g_async_queue_pop(glk_data->char_input_queue));
bool is_unicode = win->input_request_type == INPUT_REQUEST_CHARACTER_UNICODE;

glk_cancel_char_event(win);

Expand All @@ -346,7 +347,7 @@ force_char_input_from_queue(winid_t win, event_t *event)

event->type = evtype_CharInput;
event->win = win;
event->val1 = keyval_to_glk_keycode(keyval, win->input_request_type == INPUT_REQUEST_CHARACTER_UNICODE);
event->val1 = keyval_to_glk_keycode(keyval, is_unicode);
event->val2 = 0;
}

Expand Down

0 comments on commit 06b9ef6

Please sign in to comment.