fix: preserve emoji commits through XIM

This commit is contained in:
2026-08-12 16:40:58 +09:00
parent 3f5e107230
commit 71af269efe
5 changed files with 62 additions and 3 deletions

View File

@@ -1,8 +1,12 @@
#include <assert.h>
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <xcb-imdkit/encoding.h>
#include <xkbcommon/xkbcommon-keysyms.h>
#include "../xim/keymap.h"
#include "../xim/ximtext.h"
enum
{
@@ -11,6 +15,23 @@ enum
Group1 = 1<<13,
};
static void
checktext(const char *s)
{
char *ct, *utf8;
size_t clen, len, ulen;
len = strlen(s);
ct = ximcompound(s, len, &clen);
assert(ct != NULL);
utf8 = xcb_compound_text_to_utf8(ct, clen, &ulen);
assert(utf8 != NULL);
assert(ulen == len);
assert(memcmp(utf8, s, len) == 0);
free(utf8);
free(ct);
}
int
main(void)
{
@@ -23,6 +44,8 @@ main(void)
XKB_KEY_a, XKB_KEY_A, XKB_KEY_NoSymbol, XKB_KEY_NoSymbol,
};
xcb_compound_text_init();
assert(keymaplookup(letters, 4, 0) == XKB_KEY_a);
assert(keymaplookup(letters, 4, ShiftMask) == XKB_KEY_A);
assert(keymaplookup(letters, 4, LockMask) == XKB_KEY_A);
@@ -34,5 +57,9 @@ main(void)
assert(keymaplookup(punctuation, 2, LockMask|ShiftMask) == XKB_KEY_exclam);
assert(keymaplookup(missing, 4, Group1) == XKB_KEY_a);
assert(keymaplookup(NULL, 0, 0) == XKB_KEY_NoSymbol);
checktext("한글");
checktext("😀");
checktext("❤️");
checktext("A😀한");
return 0;
}