test: a key passed through is not committed text
A Korean Enter commits the syllable and lets the key on, so xim.c sends the commit and then forwards the key. pumpinput took the text of either and kept the last, so under load the Return's own carriage return overwrote 가: 22 of 25 runs failed on a loaded machine and none on an idle one. An XIM commit arrives as XLookupChars; a forwarded key comes back as XLookupBoth, and is not a commit. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -129,10 +129,10 @@ pumpinput(Display *dpy, XIC ic, char *commit, size_t cap, int timeout)
|
||||
continue;
|
||||
n = Xutf8LookupString(ic, &ev.xkey, buf, sizeof buf - 1,
|
||||
&sym, &status);
|
||||
if(n < 0 || ((status == XLookupChars || status == XLookupBoth) &&
|
||||
if(n < 0 || (status == XLookupChars &&
|
||||
((size_t)n >= cap || commit == NULL)))
|
||||
return 0;
|
||||
if((status == XLookupChars || status == XLookupBoth) && n != 0){
|
||||
if(status == XLookupChars && n != 0){
|
||||
memcpy(commit, buf, n);
|
||||
commit[n] = '\0';
|
||||
}
|
||||
@@ -273,7 +273,7 @@ sendkey(Display *dpy, XIC ic, Window win, KeySym sym, unsigned int state,
|
||||
if(n < 0)
|
||||
return fail("Xutf8LookupString failed for keysym %#lx",
|
||||
(unsigned long)sym);
|
||||
if((status == XLookupChars || status == XLookupBoth) && n != 0){
|
||||
if(status == XLookupChars && n != 0){
|
||||
if((size_t)n >= cap)
|
||||
return fail("commit buffer overflow");
|
||||
memcpy(commit, buf, n);
|
||||
|
||||
Reference in New Issue
Block a user