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:
34
gtk/main.c
34
gtk/main.c
@@ -223,36 +223,6 @@ srvconnect(Im *im)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
kget(uint32_t gdk)
|
||||
{
|
||||
uint32_t u;
|
||||
|
||||
u = gdk_keyval_to_unicode(gdk);
|
||||
if((gdk & 0xff000000) == 0x01000000 && u != 0)
|
||||
return u;
|
||||
if(gdk >= 0xff00 && gdk <= 0xffff)
|
||||
return Kspec + (gdk - 0xff00);
|
||||
return u;
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
mget(uint32_t state)
|
||||
{
|
||||
uint32_t m;
|
||||
|
||||
m = 0;
|
||||
if(state & GDK_SHIFT_MASK)
|
||||
m |= Mshift;
|
||||
if(state & GDK_CONTROL_MASK)
|
||||
m |= Mctrl;
|
||||
if(state & GDK_MOD1_MASK)
|
||||
m |= Malt;
|
||||
if(state & GDK_SUPER_MASK)
|
||||
m |= Msuper;
|
||||
return m;
|
||||
}
|
||||
|
||||
static void
|
||||
simplecommit(GtkIMContext *ctx, const char *s, Im *im)
|
||||
{
|
||||
@@ -327,8 +297,8 @@ kpress(GtkIMContext *ctx, GdkEventKey *ev)
|
||||
}
|
||||
if(im->simpleactive)
|
||||
return simplefilter(ctx, ev, 0);
|
||||
key = kget(ev->keyval);
|
||||
mod = mget(ev->state);
|
||||
key = ipckey(ev->keyval, gdk_keyval_to_unicode(ev->keyval));
|
||||
mod = ipcmod(ev->state);
|
||||
if(im->private || key == 0)
|
||||
return simplefilter(ctx, ev, 0);
|
||||
if(srvconnect(im) < 0)
|
||||
|
||||
Reference in New Issue
Block a user