diff options
author | Takao Fujiwara <tfujiwar@redhat.com> | 2024-01-31 20:27:57 +0900 |
---|---|---|
committer | Takao Fujiwara <tfujiwar@redhat.com> | 2024-01-31 20:27:57 +0900 |
commit | 041b5291f0956c5cda5054be2981c0d02b009a4c (patch) | |
tree | f4a6ec1b77a6a876dbed55f2f3d1a7ae78217912 | |
parent | 024d229fdf88a7755577b01b46af6ef908d599e0 (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.
Fixes: #198
-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); |