fix(frontends): restart preedit around commits
This commit is contained in:
@@ -80,7 +80,9 @@ struct Siglog
|
||||
char event[128];
|
||||
int n;
|
||||
char pre[Ipcfieldmax+1];
|
||||
char shown[Ipcfieldmax+1];
|
||||
char commit[Ipcfieldmax+1];
|
||||
int prechanged;
|
||||
};
|
||||
|
||||
static int
|
||||
@@ -568,6 +570,8 @@ prechange(GtkIMContext *ctx, Siglog *l)
|
||||
gchar *s;
|
||||
|
||||
gtk_im_context_get_preedit_string(ctx, &s, NULL, NULL);
|
||||
if(strcmp(l->pre, s) != 0)
|
||||
l->prechanged = 1;
|
||||
snprintf(l->pre, sizeof l->pre, "%s", s);
|
||||
g_free(s);
|
||||
logsig(l, 'C');
|
||||
@@ -585,10 +589,27 @@ commit(GtkIMContext *ctx, gchar *s, Siglog *l)
|
||||
{
|
||||
(void)ctx;
|
||||
snprintf(l->commit, sizeof l->commit, "%s", s);
|
||||
l->pre[0] = '\0';
|
||||
logsig(l, 'K');
|
||||
}
|
||||
|
||||
static void
|
||||
clearevent(Siglog *l)
|
||||
{
|
||||
l->event[0] = '\0';
|
||||
l->n = 0;
|
||||
l->commit[0] = '\0';
|
||||
l->prechanged = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
applyclient(Siglog *l)
|
||||
{
|
||||
if(l->commit[0] != '\0')
|
||||
l->shown[0] = '\0';
|
||||
if(l->prechanged)
|
||||
snprintf(l->shown, sizeof l->shown, "%s", l->pre);
|
||||
}
|
||||
|
||||
static void
|
||||
clearlog(Siglog *l)
|
||||
{
|
||||
@@ -748,18 +769,23 @@ main(int argc, char **argv)
|
||||
setpre(&srv, "ㅋ");
|
||||
clearlog(&log);
|
||||
Check(key(ctx, win, GDK_KEY_z), "first preedit key was not eaten");
|
||||
Check(strcmp(log.event, "SC") == 0 && strcmp(log.pre, "ㅋ") == 0,
|
||||
"first preedit signals were %s (%s)", log.event, log.pre);
|
||||
clearlog(&log);
|
||||
applyclient(&log);
|
||||
Check(strcmp(log.event, "SC") == 0 && strcmp(log.pre, "ㅋ") == 0 &&
|
||||
strcmp(log.shown, "ㅋ") == 0,
|
||||
"first preedit signals were %s (preedit %s, shown %s)",
|
||||
log.event, log.pre, log.shown);
|
||||
clearevent(&log);
|
||||
setreply(&srv, 1, Rcommitpre, 0);
|
||||
Check(key(ctx, win, GDK_KEY_z), "repeated preedit key was not eaten");
|
||||
Check(strcmp(log.event, "KC") == 0 &&
|
||||
strcmp(log.commit, "ㅋ") == 0 && strcmp(log.pre, "ㅋ") == 0,
|
||||
"repeated preedit signals were %s (commit %s, preedit %s)",
|
||||
log.event, log.commit, log.pre);
|
||||
Check(g_utf8_strlen(log.commit, -1) + g_utf8_strlen(log.pre, -1) == 2,
|
||||
"two physical keys produced commit %s and preedit %s",
|
||||
log.commit, log.pre);
|
||||
applyclient(&log);
|
||||
Check(strcmp(log.event, "CEKSC") == 0 &&
|
||||
strcmp(log.commit, "ㅋ") == 0 && strcmp(log.pre, "ㅋ") == 0 &&
|
||||
strcmp(log.shown, "ㅋ") == 0,
|
||||
"repeated preedit signals were %s (commit %s, preedit %s, shown %s)",
|
||||
log.event, log.commit, log.pre, log.shown);
|
||||
Check(g_utf8_strlen(log.commit, -1) + g_utf8_strlen(log.shown, -1) == 2,
|
||||
"two physical keys produced commit %s and shown preedit %s",
|
||||
log.commit, log.shown);
|
||||
|
||||
/* Unconsumed input uses GtkIMContextSimple, including its stateful forms. */
|
||||
setpre(&srv, "");
|
||||
|
||||
Reference in New Issue
Block a user