engine: the one capability is a flag

Cclientpreedit was a one-bit mask that every producer set as "want ?
Cclientpreedit : 0" and every consumer masked out again; nothing else
was ever going to join it.  Keyreq carries clientpre, an int that says
whether the client draws the preedit, and the engine and the XIM
context keep it under that name.
This commit is contained in:
2026-08-17 10:57:15 +09:00
parent 33023d7f51
commit 88ad5f7630
10 changed files with 53 additions and 57 deletions

View File

@@ -184,7 +184,7 @@ ownerrequestatcap(void *owner, int cap, int op, Rune key, u32int mod,
reply = chancreate(sizeof(Keyres), 1);
memset(&req, 0, sizeof req);
req.owner = owner;
req.cap = cap;
req.clientpre = cap;
req.op = op;
req.ks = key;
req.mod = mod;
@@ -360,7 +360,7 @@ engine_vietnamese_client_preedit(struct ct *t)
draindraw(nil);
sclear(&com);
for(k = cases[i].keys; *k != '\0'; k++){
res = ownerrequestcap(&owner, Cclientpreedit,
res = ownerrequestcap(&owner, 1,
Keypress, *k, 0);
sappend(&com, &res.commit);
if(!res.eaten)
@@ -371,7 +371,7 @@ engine_vietnamese_client_preedit(struct ct *t)
shown = com;
sappend(&shown, &res.preedit);
checkstr(t, "client preedit", cases[i].shown, &shown);
activecap = 0;
clientpre = 0;
redraw();
if(CT_CHECK(t, draindraw(&dc) > 0))
CT_EQ_INT(t, 0, scmp(&dc.pre, &res.preedit));
@@ -403,7 +403,7 @@ engine_commit_contract(struct ct *t)
im.l = getlang(LangKO);
sclear(&all);
for(i = 0; i < 3; i++){
res = ownerrequestcap(&owner, Cclientpreedit,
res = ownerrequestcap(&owner, 1,
Keypress, cases[j].key, 0);
CT_CHECK(t, res.eaten);
checkstr(t, "repeated jamo commit",
@@ -692,7 +692,7 @@ struct Searchfix
Search search;
Lang *dictlang;
Trie *dict;
int activecap;
int clientpre;
Drawcmd lastdraw;
};
@@ -919,7 +919,7 @@ searchsave(Searchfix *f, int lang)
f->search = search;
f->dictlang = getlang(lang);
f->dict = f->dictlang->dict;
f->activecap = activecap;
f->clientpre = clientpre;
f->lastdraw = lastdraw;
draindraw(nil);
}
@@ -947,7 +947,7 @@ emojibegin(Searchfix *f, int showpre)
"c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12");
init();
im.l = getlang(LangKO);
activecap = showpre ? 0 : Cclientpreedit;
clientpre = showpre ? 0 : 1;
}
static void
@@ -961,7 +961,7 @@ searchend(Searchfix *f)
draindraw(nil);
im = f->im;
search = f->search;
activecap = f->activecap;
clientpre = f->clientpre;
lastdraw = f->lastdraw;
}
@@ -981,8 +981,8 @@ engine_popup_preedit_capability(struct ct *t)
init();
im.l = jp;
draindraw(nil);
ownerrequestcap(&client, Cclientpreedit, Keypress, 'k', 0);
ownerrequestcap(&client, Cclientpreedit, Keypress, 'a', 0);
ownerrequestcap(&client, 1, Keypress, 'k', 0);
ownerrequestcap(&client, 1, Keypress, 'a', 0);
CT_EQ_INT(t, 1, im.nkouho);
redraw();
if(CT_CHECK(t, draindraw(&dc) > 0)){
@@ -1009,14 +1009,14 @@ engine_popup_preedit_capability(struct ct *t)
CT_CHECK(t, kres.eaten);
CT_EQ_INT(t, 0, draindraw(nil));
kres = ownerrequestcap(&inactive, Cclientpreedit, Keycap, 0, 0);
kres = ownerrequestcap(&inactive, 1, Keycap, 0, 0);
CT_CHECK(t, !kres.eaten);
CT_EQ_INT(t, 0, kres.preedit.n);
CT_EQ_PTR(t, &client, activeowner);
CT_EQ_INT(t, 0, activecap & Cclientpreedit);
CT_EQ_INT(t, 0, clientpre);
CT_EQ_INT(t, 0, draindraw(nil));
kres = ownerrequestcap(&client, Cclientpreedit, Keycap, 0, 0);
kres = ownerrequestcap(&client, 1, Keycap, 0, 0);
CT_CHECK(t, kres.eaten);
checkstr(t, "restored client preedit", "", &kres.preedit);
if(CT_CHECK(t, draindraw(&dc) > 0)){
@@ -1028,7 +1028,7 @@ engine_popup_preedit_capability(struct ct *t)
CT_EQ_INT(t, 1, im.nkouho);
CT_EQ_INT(t, -1, im.sel);
checkstr(t, "retained client candidate", "", &im.kouho[0]);
kres = ownerrequestcap(&client, Cclientpreedit, Keycap, 0, 0);
kres = ownerrequestcap(&client, 1, Keycap, 0, 0);
CT_CHECK(t, kres.eaten);
CT_EQ_INT(t, 0, draindraw(nil));

View File

@@ -133,7 +133,7 @@ nexttrace(struct ct *t, Ibusfix *f, int op, Ictx *ctx)
CT_EQ_INT(t, op, req.op);
CT_EQ_PTR(t, ctx, req.owner);
if(ctx != nil)
CT_EQ_INT(t, ctx->cap & 1 ? Cclientpreedit : 0, req.cap);
CT_EQ_INT(t, clientpreedit(ctx), req.clientpre);
CT_EQ_PTR(t, replyc, req.reply);
return req;
}
@@ -178,7 +178,7 @@ ibus_capability_policy(struct ct *t)
checkstr(t, "preedit", "k", &res.preedit);
CT_EQ_PTR(t, a, testengineowner());
a->cap = Cclientpreedit;
a->cap = Ibuscappreedit;
memset(&res, 0, sizeof res);
sendrequest(a, Keycap, 0, 0, &res);
nexttrace(t, &f, Keycap, a);
@@ -186,7 +186,7 @@ ibus_capability_policy(struct ct *t)
checkstr(t, "preedit", "k", &res.preedit);
b->focused = 1;
b->cap = Cclientpreedit;
b->cap = Ibuscappreedit;
memset(&res, 0, sizeof res);
sendrequest(b, Keycap, 0, 0, &res);
nexttrace(t, &f, Keycap, b);
@@ -229,7 +229,7 @@ ibus_private_input_policy(struct ct *t)
}
ctx->focused = 1;
ctx->cap = Cclientpreedit;
ctx->cap = 1;
ctx->purpose = 0;
contextkey(t, &f, ctx, 'n', Testctrlmask);
res = contextkey(t, &f, ctx, 'k', 0);

View File

@@ -70,7 +70,7 @@ void
ipc_control_and_caret_frames(struct ct *t)
{
static const uchar capon[Ipcreqsz] = {
Ipcext|Cclientpreedit, Ipcversion, Ipcopcap, 0, 0, 0,
Ipcext|Ipcreqwant, Ipcversion, Ipcopcap, 0, 0, 0,
};
static const uchar capoff[Ipcreqsz] = {
Ipcext, Ipcversion, Ipcopcap, 0, 0, 0,
@@ -89,7 +89,7 @@ ipc_control_and_caret_frames(struct ct *t)
int valid, want;
int32_t x, y, h;
ipcpackcap(buf, Cclientpreedit);
ipcpackcap(buf, 1);
CT_EQ_MEM(t, capon, buf, sizeof capon);
CT_EQ_INT(t, Ipccap, ipcreqtype(buf));
/* The probe remains a harmless key-zero request to an old daemon. */

View File

@@ -143,14 +143,14 @@ nextrequestcap(struct ct *t, Pump *p, int op, int cap)
memset(&req, 0, sizeof req);
chanrecv(p->trace, &req);
CT_EQ_INT(t, op, req.op);
CT_EQ_INT(t, cap, req.cap);
CT_EQ_INT(t, cap, req.clientpre);
return req;
}
static Keyreq
nextrequest(struct ct *t, Pump *p, int op)
{
return nextrequestcap(t, p, op, Cclientpreedit);
return nextrequestcap(t, p, op, 1);
}
static void
@@ -387,7 +387,7 @@ server_extension_stream(struct ct *t)
goto cleanup;
/* Capability and caret frames may be split at any byte boundary. */
ipcpackcap(frame, Cclientpreedit);
ipcpackcap(frame, 1);
if(!sendframe(t, &a, frame, Ipcreqsz, 1))
goto cleanup;
req = nextrequest(t, &f.pump, Keycap);
@@ -446,7 +446,7 @@ server_extension_stream(struct ct *t)
allowrequest(&f.pump);
CT_EQ_INT(t, 1, readreply(t, &a, 0, "k", preedit));
ipcpackcap(frame, Cclientpreedit);
ipcpackcap(frame, 1);
if(!sendframe(t, &a, frame, Ipcreqsz, 0))
goto cleanup;
req = nextrequest(t, &f.pump, Keycap);

View File

@@ -437,7 +437,7 @@ nexttracecap(struct ct *t, Ximfix *f, int op, Ic *owner, int cap)
return req;
CT_EQ_INT(t, op, req.op);
CT_EQ_PTR(t, owner, req.owner);
CT_EQ_INT(t, cap, req.cap);
CT_EQ_INT(t, cap, req.clientpre);
CT_EQ_PTR(t, replyc, req.reply);
return req;
}
@@ -445,7 +445,7 @@ nexttracecap(struct ct *t, Ximfix *f, int op, Ic *owner, int cap)
static Keyreq
nexttrace(struct ct *t, Ximfix *f, int op, Ic *state)
{
return nexttracecap(t, f, op, state, state->cap);
return nexttracecap(t, f, op, state, state->clientpre);
}
static void
@@ -539,7 +539,7 @@ xim_adapter_release_lifecycle(struct ct *t)
keypress(dead, 'n', 0, &res);
nexttrace(t, &f, Keypress, dead);
CT_EQ_PTR(t, dead, testengineowner());
deadcap = dead->cap;
deadcap = dead->clientpre;
icfree(dead);
nexttracecap(t, &f, Keyrelease, dead, deadcap);
dead = nil;
@@ -654,8 +654,8 @@ xim_adapter_styles(struct ct *t)
state = icbindings[0].data;
if(!CT_CHECK(t, state != nil && state == ics))
continue;
CT_EQ_INT(t, want[i] & XCB_IM_PreeditCallbacks ? Cclientpreedit : 0,
state->cap);
CT_EQ_INT(t, want[i] & XCB_IM_PreeditCallbacks ? 1 : 0,
state->clientpre);
CT_EQ_PTR(t, ic, state->xic);
icunlink(state);
free(state);
@@ -799,7 +799,7 @@ xim_adapter_callback_replacement(struct ct *t)
ic = (xcb_im_input_context_t*)(uintptr)3;
memset(&state, 0, sizeof state);
state.xic = ic;
state.cap = Cclientpreedit;
state.clientpre = 1;
wireclear();
sinit(&pre, "k", strlen("k"));
updatepreedit(&state, &pre);
@@ -848,7 +848,7 @@ xim_adapter_callback_unicode(struct ct *t)
for(i = 0; i < nelem(text); i++){
memset(&state, 0, sizeof state);
state.xic = (xcb_im_input_context_t*)(uintptr)(10+i);
state.cap = Cclientpreedit;
state.clientpre = 1;
sinit(&pre, text[i], strlen(text[i]));
wireclear();
updatepreedit(&state, &pre);
@@ -868,7 +868,7 @@ startstate(Ic *state, xcb_im_input_context_t *ic)
memset(state, 0, sizeof *state);
state->xic = ic;
state->cap = Cclientpreedit;
state->clientpre = 1;
sinit(&pre, "", strlen(""));
updatepreedit(state, &pre);
}
@@ -896,7 +896,7 @@ xim_adapter_callback_cleanup(struct ct *t)
wireclear();
wirebind(0, ic, &state);
state.xic = ic;
state.cap = Cclientpreedit;
state.clientpre = 1;
keypress(&state, 'k', 0, &res);
nexttrace(t, &f, Keypress, &state);
keypress(&state, 'a', 0, &res);
@@ -984,7 +984,7 @@ xim_adapter_callback_transfer(struct ct *t)
goto cleanup;
wireclear();
a.xic = aic;
a.cap = Cclientpreedit;
a.clientpre = 1;
sinit(&pre, "", strlen(""));
updatepreedit(&a, &pre);
keypress(&b, 'x', 0, &res);
@@ -1021,7 +1021,7 @@ xim_adapter_callback_owner_loss(struct ct *t)
wireclear();
wirebind(0, ic, &state);
state.xic = ic;
state.cap = Cclientpreedit;
state.clientpre = 1;
keypress(&state, 'k', 0, &res);
nexttrace(t, &f, Keypress, &state);
updatepreedit(&state, &res.preedit);