dat: one pair of content purposes

Two frontends read the same two numbers, and wl.c carried four lines of
comment to say why it kept its own copy of them.  IBus and text-input-v3
number the purposes alike because both took them from GTK, so the header
is where they belong and the explanation goes away with the copy.  hidden
stays in both files: one asks about a context, the other about the seat.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-17 21:23:20 +09:00
parent 8472474332
commit aef577026d
4 changed files with 11 additions and 15 deletions

5
dat.h
View File

@@ -29,6 +29,11 @@ enum
Maxkouho = 128,
Maxdisp = 9,
/* Content purposes whose keys the engine never sees; IBus and
* text-input-v3 number them alike, both after GTK. */
Purposepassword = 8,
Purposepin = 9,
Colfg = 0x000000,
Colbg = 0xffffff,
Colsep = 0xd0d0d0,

6
ibus.c
View File

@@ -16,8 +16,6 @@ enum
Relmask = 1<<30,
/* IBus wire constants; the daemon does not link libibus. */
Ibuscappreedit = 1<<0,
Ibuspurposepassword = 8,
Ibuspurposepin = 9,
Ibusattrunderline = 1,
Ibusunderlinesingle = 1,
Ibuspreeditclear = 0,
@@ -313,8 +311,8 @@ sendrequest(Ictx *ctx, int op, u32int ks, u32int mod, Keyres *res)
static int
hidden(Ictx *ctx)
{
return ctx->purpose == Ibuspurposepassword ||
ctx->purpose == Ibuspurposepin;
return ctx->purpose == Purposepassword ||
ctx->purpose == Purposepin;
}
static void

View File

@@ -213,8 +213,8 @@ ibus_private_input_policy(struct ct *t)
{
static const struct { u32int purpose; int want; } cases[] = {
{ 0, 0 },
{ Ibuspurposepassword, 1 },
{ Ibuspurposepin, 1 },
{ Purposepassword, 1 },
{ Purposepin, 1 },
{ 37, 0 },
};
Ibusfix f;
@@ -239,7 +239,7 @@ ibus_private_input_policy(struct ct *t)
contextkey(t, &f, ctx, 'n', Testctrlmask);
res = contextkey(t, &f, ctx, 'k', 0);
checkstr(t, "preedit", "k", &res.preedit);
ctx->purpose = Ibuspurposepassword;
ctx->purpose = Purposepassword;
memset(&res, 0, sizeof res);
CT_CHECK(t, !processkey(ctx, 'x', 0, text, sizeof text, &res));
CT_CHECK(t, !res.eaten);

9
wl.c
View File

@@ -9,16 +9,9 @@
#include "imv2.h"
#include "vkv1.h"
/*
* text-input-v3 content purposes whose keys the engine never sees. IBus
* numbers these alike but does not share them: one enum here is cheaper
* than reaching into dat.h and ibus.c both.
*/
enum
{
Purposepassword = 8,
Purposepin = 9,
Maxcode = 0x300, /* KEY_MAX+1: what evdev can send */
Maxcode = 0x300, /* KEY_MAX+1: what evdev can send */
};
/*