diff options
author | Takao Fujiwara <tfujiwar@redhat.com> | 2024-04-12 10:21:43 +0900 |
---|---|---|
committer | Takao Fujiwara <tfujiwar@redhat.com> | 2024-04-12 10:21:43 +0900 |
commit | c7790072657f9fdbe8cda031776617088c5f11db (patch) | |
tree | a788708fb7f75cfc496446dc85de00356fa7cc2d /modules | |
parent | 13e9ac4d458069c81d795f6b4842814d30431b4b (diff) |
imDefLkup: Commit first info in XimCommitInfo
Xic.private.proto.commit_info can receive multiple XimCommitInfo
when typing keys very quickly like an bar code scanner (or evemu-play)
and the first info in XimCommitInfo should be committed to keep
the typing key order.
This and 041b5291 are same patches but the regression issues will be
fixed by the later patches.
Closes: #198
Fixes: 041b5291 ("imDefLkup: Commit first info in XimCommitInfo")
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libx11/-/merge_requests/246>
Diffstat (limited to 'modules')
-rw-r--r-- | modules/im/ximcp/imDefLkup.c | 60 |
1 files changed, 49 insertions, 11 deletions
diff --git a/modules/im/ximcp/imDefLkup.c b/modules/im/ximcp/imDefLkup.c index 5192e8c1..6ffe6f48 100644 --- a/modules/im/ximcp/imDefLkup.c +++ b/modules/im/ximcp/imDefLkup.c @@ -640,22 +640,47 @@ _XimRegCommitInfo( } static void -_XimUnregCommitInfo( - Xic ic) +_XimUnregRealCommitInfo( + Xic ic, + Bool reverse) { XimCommitInfo info; + XimCommitInfo prev_info = NULL; - if (!(info = ic->private.proto.commit_info)) + info = ic->private.proto.commit_info; + while (reverse && info) { + if (!info->next) + break; + prev_info = info; + info = info->next; + } + if (!info) return; - Xfree(info->string); Xfree(info->keysym); - ic->private.proto.commit_info = info->next; + if (prev_info) + prev_info->next = info->next; + else + ic->private.proto.commit_info = info->next; Xfree(info); return; } +static void +_XimUnregCommitInfo( + Xic ic) +{ + _XimUnregRealCommitInfo(ic, False); +} + +static void +_XimUnregFirstCommitInfo( + Xic ic) +{ + _XimUnregRealCommitInfo(ic, True); +} + void _XimFreeCommitInfo( Xic ic) @@ -665,6 +690,19 @@ _XimFreeCommitInfo( return; } +static XimCommitInfo +_XimFirstCommitInfo( + Xic ic) +{ + XimCommitInfo info = ic->private.proto.commit_info; + while (info) { + if (!info->next) + break; + info = info->next; + } + return info; +} + static Bool _XimProcKeySym( Xic ic, @@ -1059,7 +1097,7 @@ _XimProtoMbLookupString( state = &tmp_state; if ((ev->type == KeyPress) && (ev->keycode == 0)) { /* Filter function */ - if (!(info = ic->private.proto.commit_info)) { + if (!(info = _XimFirstCommitInfo(ic))) { *state = XLookupNone; return 0; } @@ -1075,7 +1113,7 @@ _XimProtoMbLookupString( else *state = XLookupKeySym; } - _XimUnregCommitInfo(ic); + _XimUnregFirstCommitInfo(ic); } else if (ev->type == KeyPress) { ret = _XimLookupMBText(ic, ev, buffer, bytes, keysym, NULL); @@ -1122,7 +1160,7 @@ _XimProtoWcLookupString( state = &tmp_state; if (ev->type == KeyPress && ev->keycode == 0) { /* Filter function */ - if (!(info = ic->private.proto.commit_info)) { + if (!(info = _XimFirstCommitInfo(ic))) { *state = XLookupNone; return 0; } @@ -1138,7 +1176,7 @@ _XimProtoWcLookupString( else *state = XLookupKeySym; } - _XimUnregCommitInfo(ic); + _XimUnregFirstCommitInfo(ic); } else if (ev->type == KeyPress) { ret = _XimLookupWCText(ic, ev, buffer, bytes, keysym, NULL); @@ -1185,7 +1223,7 @@ _XimProtoUtf8LookupString( state = &tmp_state; if (ev->type == KeyPress && ev->keycode == 0) { /* Filter function */ - if (!(info = ic->private.proto.commit_info)) { + if (!(info = _XimFirstCommitInfo(ic))) { *state = XLookupNone; return 0; } @@ -1201,7 +1239,7 @@ _XimProtoUtf8LookupString( else *state = XLookupKeySym; } - _XimUnregCommitInfo(ic); + _XimUnregFirstCommitInfo(ic); } else if (ev->type == KeyPress) { ret = _XimLookupUTF8Text(ic, ev, buffer, bytes, keysym, NULL); |