Ignore text input done if serial is incorrect

This commit is contained in:
Kovid Goyal 2021-03-25 15:05:48 +05:30
parent 7b130dc220
commit 5dbbed3dcc
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

14
glfw/wl_text_input.c vendored
View File

@ -15,8 +15,14 @@ static struct zwp_text_input_v3* text_input;
static struct zwp_text_input_manager_v3* text_input_manager;
static char *pending_pre_edit = NULL;
static char *pending_commit = NULL;
uint32_t commit_serial = 0;
static void commit(void) { if (text_input) zwp_text_input_v3_commit (text_input); }
static void commit(void) {
if (text_input) {
zwp_text_input_v3_commit (text_input);
commit_serial++;
}
}
static void
text_input_enter(void *data UNUSED, struct zwp_text_input_v3 *text_input UNUSED, struct wl_surface *surface UNUSED) {
@ -79,7 +85,11 @@ text_input_delete_surrounding_text(
static void
text_input_done(void *data UNUSED, struct zwp_text_input_v3 *zwp_text_input_v3 UNUSED, uint32_t serial UNUSED) {
debug("text-input: done event: serial: %u\n", serial);
debug("text-input: done event: serial: %u current_commit_serial: %u\n", serial, commit_serial);
if (serial != commit_serial) {
_glfwInputError(GLFW_PLATFORM_ERROR, "Wayland: text_input_done serial mismatch, expected=%u got=%u\n", commit_serial, serial);
return;
}
if (pending_pre_edit) {
send_text(pending_pre_edit, GLFW_IME_PREEDIT_CHANGED);
free(pending_pre_edit); pending_pre_edit = NULL;