--- Andy Gozas. diff --git a/x.c b/x.c index 2a3bd38..3084cbf 100644 --- a/x.c +++ b/x.c _AT_@ -1833,9 +1833,10 @@ void kpress(XEvent *ev) { XKeyEvent *e = &ev->xkey; - KeySym ksym; - char buf[64], *customkey; - int len; + KeySym ksym = NoSymbol; + char *buf = NULL, *customkey; + int len = 64; + int reallocd = 0; Rune c; Status status; Shortcut *bp; _AT_@ -1843,27 +1844,43 @@ kpress(XEvent *ev) if (IS_SET(MODE_KBDLOCK)) return; - if (xw.ime.xic) - len = XmbLookupString(xw.ime.xic, e, buf, sizeof buf, &ksym, &status); - else - len = XLookupString(e, buf, sizeof buf, &ksym, NULL); +reallocbuf: + free(buf); + buf = xmalloc(len); + if (xw.ime.xic) { + len = XmbLookupString(xw.ime.xic, e, buf, len, &ksym, &status); + if (status == XBufferOverflow) { + if (reallocd) { + goto cleanup; + } + reallocd = 1; + goto reallocbuf; + } + } else { + len = XLookupString(e, buf, len, &ksym, NULL); + } + + if (ksym == NoSymbol) + goto nosym; + /* 1. shortcuts */ for (bp = shortcuts; bp < shortcuts + LEN(shortcuts); bp++) { if (ksym == bp->keysym && match(bp->mod, e->state)) { bp->func(&(bp->arg)); - return; + goto cleanup; } } /* 2. custom keys from config.h */ if ((customkey = kmap(ksym, e->state))) { ttywrite(customkey, strlen(customkey), 1); - return; + goto cleanup; } +nosym: /* 3. composed string from input method */ if (len == 0) - return; + goto cleanup; if (len == 1 && e->state & Mod1Mask) { if (IS_SET(MODE_8BIT)) { if (*buf < 0177) { _AT_@ -1877,6 +1894,8 @@ kpress(XEvent *ev) } } ttywrite(buf, len, 1); +cleanup: + free(buf); } voidReceived on Mon Oct 24 2022 - 11:21:37 CEST
This archive was generated by hypermail 2.3.0 : Mon Oct 24 2022 - 11:24:36 CEST