ipc: share one keysym and modifier mapping across frontends
The keysym-to-engine-key rule lived in ibus.c, xim/xim.c and gtk/main.c, and the copies disagreed: GTK sent keypad digits as special keys while IBus and XIM sent '1'..'9'. Modifiers were rebuilt bit by bit in two places although Mmask already is the X core layout; only the virtual Super bit (26) that GDK and IBus set needs folding. ipckey/ipcmod in ipc.c serve the daemon, the module and the tests.
This commit is contained in:
30
ibus.c
30
ibus.c
@@ -17,7 +17,6 @@ enum
|
||||
Maxwatches = 2*Maxconns + 1,
|
||||
Maxcontexts = Maxclients,
|
||||
Relmask = 1<<30,
|
||||
Ibussupermask = 1<<26,
|
||||
/* IBus wire constants; the daemon does not link libibus. */
|
||||
Ibuscappreedit = 1<<0,
|
||||
Ibuspurposepassword = 8,
|
||||
@@ -266,32 +265,6 @@ togglewatch(DBusWatch *w, void *_)
|
||||
USED(_);
|
||||
}
|
||||
|
||||
static u32int
|
||||
kget(u32int sym)
|
||||
{
|
||||
u32int c;
|
||||
|
||||
c = xkb_keysym_to_utf32(sym);
|
||||
if(c >= ' ' && c != 0x7f)
|
||||
return c;
|
||||
if(sym >= 0xff00 && sym <= 0xffff)
|
||||
return Kspec + (sym - 0xff00);
|
||||
return c;
|
||||
}
|
||||
|
||||
static u32int
|
||||
mget(u32int state)
|
||||
{
|
||||
u32int m;
|
||||
|
||||
m = 0;
|
||||
if(state & (1<<0)) m |= Mshift;
|
||||
if(state & (1<<2)) m |= Mctrl;
|
||||
if(state & (1<<3)) m |= Malt;
|
||||
if(state & ((1<<6)|Ibussupermask)) m |= Msuper;
|
||||
return m;
|
||||
}
|
||||
|
||||
static Ictx*
|
||||
findcontext(DBusConnection *conn, const char *path)
|
||||
{
|
||||
@@ -385,7 +358,8 @@ processkey(Ictx *ctx, u32int sym, u32int state, Keyres *res)
|
||||
{
|
||||
if(state & Relmask || !ctx->focused || hidden(ctx))
|
||||
return 0;
|
||||
sendrequest(ctx, Keypress, kget(sym), mget(state), res);
|
||||
sendrequest(ctx, Keypress, ipckey(sym, xkb_keysym_to_utf32(sym)),
|
||||
ipcmod(state), res);
|
||||
if(preowner != nil && preowner != ctx)
|
||||
checkpreowner();
|
||||
return 1;
|
||||
|
||||
Reference in New Issue
Block a user