You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.9 KiB

From a90a2e7582a73f7b69b14437287aa15945bf5989 Mon Sep 17 00:00:00 2001
From: Weng Xuetian <wengxt@gmail.com>
Date: Sun, 30 Jan 2022 16:44:44 -0800
Subject: [PATCH 10/11] Fix text_input_v3 preedit string
For every batch of text_input_v3 updates, if there is no preedit in this
batch, preedit should be cleared.
---
src/video/wayland/SDL_waylandevents.c | 8 +++++++-
src/video/wayland/SDL_waylandkeyboard.h | 1 +
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/video/wayland/SDL_waylandevents.c b/src/video/wayland/SDL_waylandevents.c
index bf2aeea5b..85d4edfc8 100644
--- a/src/video/wayland/SDL_waylandevents.c
+++ b/src/video/wayland/SDL_waylandevents.c
@@ -1505,7 +1505,9 @@ text_input_preedit_string(void *data,
int32_t cursor_begin,
int32_t cursor_end)
{
+ SDL_WaylandTextInput *text_input = data;
char buf[SDL_TEXTEDITINGEVENT_TEXT_SIZE];
+ text_input->has_preedit = SDL_TRUE;
if (text) {
size_t text_bytes = SDL_strlen(text), i = 0;
size_t cursor = 0;
@@ -1557,7 +1559,11 @@ text_input_done(void *data,
struct zwp_text_input_v3 *zwp_text_input_v3,
uint32_t serial)
{
- /* No-op */
+ SDL_WaylandTextInput *text_input = data;
+ if (!text_input->has_preedit) {
+ SDL_SendEditingText("", 0, 0);
+ }
+ text_input->has_preedit = SDL_FALSE;
}
static const struct zwp_text_input_v3_listener text_input_listener = {
diff --git a/src/video/wayland/SDL_waylandkeyboard.h b/src/video/wayland/SDL_waylandkeyboard.h
index dd8c146e6..604e0f37f 100644
--- a/src/video/wayland/SDL_waylandkeyboard.h
+++ b/src/video/wayland/SDL_waylandkeyboard.h
@@ -27,6 +27,7 @@ typedef struct SDL_WaylandTextInput
{
struct zwp_text_input_v3 *text_input;
SDL_Rect cursor_rect;
+ SDL_bool has_preedit;
} SDL_WaylandTextInput;
extern int Wayland_InitKeyboard(_THIS);
--
2.34.1