ibus: keep only the content purpose; nothing read the hints

This commit is contained in:
2026-08-16 16:58:12 +09:00
parent 8831b84ffc
commit 03c196a7f6
2 changed files with 10 additions and 17 deletions

13
ibus.c
View File

@@ -35,7 +35,6 @@ struct Ictx
int focused; int focused;
u32int cap; u32int cap;
u32int purpose; u32int purpose;
u32int hints;
int clientcommitpreedit; int clientcommitpreedit;
Caret caret; Caret caret;
}; };
@@ -671,11 +670,12 @@ getproperty(DBusMessage *m, const char **iface, const char **name,
return 1; return 1;
} }
/* ContentType is (purpose, hints); only the purpose matters to us. */
static int static int
getcontent(DBusMessageIter *value, u32int *purpose, u32int *hints) getcontent(DBusMessageIter *value, u32int *purpose)
{ {
DBusMessageIter st; DBusMessageIter st;
dbus_uint32_t p, h; dbus_uint32_t p;
if(dbus_message_iter_get_arg_type(value) != DBUS_TYPE_STRUCT) if(dbus_message_iter_get_arg_type(value) != DBUS_TYPE_STRUCT)
return 0; return 0;
@@ -686,11 +686,9 @@ getcontent(DBusMessageIter *value, u32int *purpose, u32int *hints)
if(!dbus_message_iter_next(&st) || if(!dbus_message_iter_next(&st) ||
dbus_message_iter_get_arg_type(&st) != DBUS_TYPE_UINT32) dbus_message_iter_get_arg_type(&st) != DBUS_TYPE_UINT32)
return 0; return 0;
dbus_message_iter_get_basic(&st, &h);
if(dbus_message_iter_next(&st)) if(dbus_message_iter_next(&st))
return 0; return 0;
*purpose = p; *purpose = p;
*hints = h;
return 1; return 1;
} }
@@ -701,7 +699,7 @@ handlepropertyset(DBusConnection *c, DBusMessage *m, Ictx *ctx)
const char *iface, *name; const char *iface, *name;
DBusMessageIter value, st; DBusMessageIter value, st;
dbus_bool_t b; dbus_bool_t b;
u32int purpose, hints; u32int purpose;
Keyres res; Keyres res;
int washidden; int washidden;
@@ -712,12 +710,11 @@ handlepropertyset(DBusConnection *c, DBusMessage *m, Ictx *ctx)
return handleerror(c, m, DBUS_ERROR_UNKNOWN_INTERFACE, return handleerror(c, m, DBUS_ERROR_UNKNOWN_INTERFACE,
"unknown property interface"); "unknown property interface");
if(strcmp(name, "ContentType") == 0){ if(strcmp(name, "ContentType") == 0){
if(!getcontent(&value, &purpose, &hints)) if(!getcontent(&value, &purpose))
return handleerror(c, m, DBUS_ERROR_INVALID_ARGS, return handleerror(c, m, DBUS_ERROR_INVALID_ARGS,
"ContentType expects (uu)"); "ContentType expects (uu)");
washidden = hidden(ctx); washidden = hidden(ctx);
ctx->purpose = purpose; ctx->purpose = purpose;
ctx->hints = hints;
if(ctx->focused && !washidden && hidden(ctx)){ if(ctx->focused && !washidden && hidden(ctx)){
sendrequest(ctx, Keyreset, 0, 0, &res); sendrequest(ctx, Keyreset, 0, 0, &res);
if(clientpreedit(ctx)) if(clientpreedit(ctx))

View File

@@ -285,12 +285,11 @@ cleanup:
void void
ibus_private_input_policy(struct ct *t) ibus_private_input_policy(struct ct *t)
{ {
static const struct { u32int purpose, hints; int want; } cases[] = { static const struct { u32int purpose; int want; } cases[] = {
{ 0, 0, 0 }, { 0, 0 },
{ Ibuspurposepassword, 0, 1 }, { Ibuspurposepassword, 1 },
{ Ibuspurposepin, 0, 1 }, { Ibuspurposepin, 1 },
{ 0, 1<<11, 0 }, { 37, 0 },
{ 37, 1<<20, 0 },
}; };
Ibusfix f; Ibusfix f;
Ictx *ctx; Ictx *ctx;
@@ -304,14 +303,12 @@ ibus_private_input_policy(struct ct *t)
goto cleanup; goto cleanup;
for(i = 0; i < nelem(cases); i++){ for(i = 0; i < nelem(cases); i++){
ctx->purpose = cases[i].purpose; ctx->purpose = cases[i].purpose;
ctx->hints = cases[i].hints;
CT_EQ_INT(t, cases[i].want, hidden(ctx)); CT_EQ_INT(t, cases[i].want, hidden(ctx));
} }
ctx->focused = 1; ctx->focused = 1;
ctx->cap = Cclientpreedit; ctx->cap = Cclientpreedit;
ctx->purpose = 0; ctx->purpose = 0;
ctx->hints = 0;
contextkey(t, &f, ctx, 'n', Testctrlmask); contextkey(t, &f, ctx, 'n', Testctrlmask);
res = contextkey(t, &f, ctx, 'k', 0); res = contextkey(t, &f, ctx, 'k', 0);
checkstr(t, "preedit", "k", &res.preedit); checkstr(t, "preedit", "k", &res.preedit);
@@ -323,7 +320,6 @@ ibus_private_input_policy(struct ct *t)
checkenginepreedit(t, "k"); checkenginepreedit(t, "k");
ctx->purpose = 0; ctx->purpose = 0;
ctx->hints = 1<<11;
res = contextkey(t, &f, ctx, 'a', 0); res = contextkey(t, &f, ctx, 'a', 0);
checkstr(t, "preedit", "", &res.preedit); checkstr(t, "preedit", "", &res.preedit);
cleanup: cleanup: