ipc: negotiate preedit capability and caret messages

This commit is contained in:
2026-08-14 18:53:14 +09:00
parent b536573622
commit 6a58b63223
7 changed files with 538 additions and 17 deletions

23
ipc.h
View File

@@ -2,7 +2,7 @@
#include <stdint.h>
/*
* Request: [flags, modifiers, key byte 0, ..., key byte 3].
* Legacy request: [flags, modifiers, key byte 0, ..., key byte 3].
* Flags request preedit and distinguish lifecycle reset from physical Escape.
* The server identifies the connection as the engine owner; that identity is
* not sent on the wire.
@@ -11,12 +11,20 @@
* followed, when requested, by
* [preedit-length-low, preedit-length-high, preedit...].
* Lengths are little-endian byte counts; fields are at most Ipcfieldmax bytes.
*
* Capability control is six bytes: [0x80|want, version, 0, 0, 0, 0].
* Caret control is sixteen bytes: [0x80, version, 1, valid, x, y, h],
* with the signed coordinates and height encoded as little-endian 32-bit words.
*/
enum
{
Ipcreqwant = 1<<0,
Ipcreqreset = 1<<1,
Ipcext = 1<<7,
Ipcversion = 1,
Ipcopcap = 0,
Ipcopcaret = 1,
Kspec = 0x110000,
Kback = Kspec|0x08,
@@ -35,12 +43,21 @@ enum
Mmask = Mshift|Mctrl|Malt|Msuper,
Ipcreqsz = 6,
Ipccaretsz = 16,
Ipclensz = 2,
Ipcresphdrsz = 1 + Ipclensz,
Ipcfieldmax = 256,
Ipcmaxresp = Ipcresphdrsz + Ipcfieldmax + Ipclensz + Ipcfieldmax,
};
enum
{
Ipcunknown = -1,
Ipclegacy,
Ipccap,
Ipccaret,
};
typedef struct Ipcresp Ipcresp;
struct Ipcresp
{
@@ -51,7 +68,11 @@ struct Ipcresp
void ipcpackreq(unsigned char[Ipcreqsz], int, uint32_t, uint32_t);
void ipcpackreset(unsigned char[Ipcreqsz], int);
void ipcpackcap(unsigned char[Ipcreqsz], int);
int ipcpackcaret(unsigned char[Ipccaretsz], int, int32_t, int32_t, int32_t);
void ipcunpackreq(const unsigned char[Ipcreqsz], int*, uint32_t*, uint32_t*);
int ipcunpackcaret(const unsigned char[Ipccaretsz], int*, int32_t*, int32_t*, int32_t*);
int ipcreqtype(const unsigned char[Ipcreqsz]);
int ipcreqreset(const unsigned char[Ipcreqsz]);
int ipcpackresp(unsigned char*, size_t, int, const char*, size_t, const char*, size_t, int);
int ipcreadn(int, void*, size_t);