XIM text always went out through imdkit's COMPOUND_TEXT converter, which already wraps every UTF-8 string in ESC%G; the UTF8_STRING negotiation, the per-client encoding list, ximtext.c's fallback and its wrapper never changed a byte on the wire. The spot location is honoured for every style now (GTK's XIM module sends it with PreeditCallbacks) and an unset focus window means the client window, as the spec says, so those clients get the popup at the caret. readattrs/place kept four transient fields to pass values between them; ximclose tore down state right before die(); the OOM passthrough context was a third policy for one small calloc where emalloc dies like everything else. Both frontends now poll for engine-owner loss only while a preedit shows instead of XIM waking on a pipe the engine had to know about; ibus stops waking five times a second when idle. keymeaningful() is the engine's own predicate. The standalone xim_test moved into the unit suite, so xim/Makefile is gone.
72 lines
1.9 KiB
C
72 lines
1.9 KiB
C
#include "test.h"
|
|
#include <xcb-imdkit/encoding.h>
|
|
#include <xkbcommon/xkbcommon.h>
|
|
#include <xkbcommon/xkbcommon-keysyms.h>
|
|
|
|
uint32_t keymaplookup(struct xkb_state*, uint8_t, uint16_t);
|
|
|
|
enum
|
|
{
|
|
ShiftMask = 1<<0,
|
|
LockMask = 1<<1,
|
|
Mod2Mask = 1<<4,
|
|
Mod5Mask = 1<<7,
|
|
Group1 = 1<<13,
|
|
};
|
|
|
|
void
|
|
xim_keymap_lookup(struct ct *t)
|
|
{
|
|
struct xkb_context *context;
|
|
struct xkb_keymap *keymap;
|
|
struct xkb_rule_names names;
|
|
struct xkb_state *state;
|
|
|
|
memset(&names, 0, sizeof names);
|
|
names.layout = "de,ru";
|
|
context = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
|
|
keymap = xkb_keymap_new_from_names(context, &names,
|
|
XKB_KEYMAP_COMPILE_NO_FLAGS);
|
|
if(!CT_CHECK(t, keymap != nil)){
|
|
xkb_context_unref(context);
|
|
return;
|
|
}
|
|
state = xkb_state_new(keymap);
|
|
CT_EQ_UINT(t, XKB_KEY_a, keymaplookup(state, 38, 0));
|
|
CT_EQ_UINT(t, XKB_KEY_A, keymaplookup(state, 38, ShiftMask));
|
|
CT_EQ_UINT(t, XKB_KEY_A, keymaplookup(state, 38, LockMask));
|
|
CT_EQ_UINT(t, XKB_KEY_a, keymaplookup(state, 38, LockMask|ShiftMask));
|
|
CT_EQ_UINT(t, XKB_KEY_EuroSign, keymaplookup(state, 26, Mod5Mask));
|
|
CT_EQ_UINT(t, XKB_KEY_Cyrillic_u, keymaplookup(state, 26, Group1));
|
|
CT_EQ_UINT(t, XKB_KEY_KP_End, keymaplookup(state, 87, 0));
|
|
CT_EQ_UINT(t, XKB_KEY_KP_1, keymaplookup(state, 87, Mod2Mask));
|
|
xkb_state_unref(state);
|
|
xkb_keymap_unref(keymap);
|
|
xkb_context_unref(context);
|
|
}
|
|
|
|
/* imdkit carries any UTF-8 text through COMPOUND_TEXT unchanged. */
|
|
void
|
|
xim_compound_text(struct ct *t)
|
|
{
|
|
static char *text[] = { "A😀한", "한글", "𠀋", "👩💻" };
|
|
char *ct, *utf8;
|
|
size_t clen, len, ulen;
|
|
int i;
|
|
|
|
xcb_compound_text_init();
|
|
for(i = 0; i < nelem(text); i++){
|
|
len = strlen(text[i]);
|
|
ct = xcb_utf8_to_compound_text(text[i], len, &clen);
|
|
if(!CT_CHECK(t, ct != nil))
|
|
continue;
|
|
utf8 = xcb_compound_text_to_utf8(ct, clen, &ulen);
|
|
if(CT_CHECK(t, utf8 != nil)){
|
|
CT_EQ_SIZE(t, len, ulen);
|
|
CT_EQ_MEM(t, text[i], utf8, len);
|
|
}
|
|
free(utf8);
|
|
free(ct);
|
|
}
|
|
}
|