diff options
author | Daiki Ueno <ueno@unixuser.org> | 2012-10-25 15:23:52 +0900 |
---|---|---|
committer | Daiki Ueno <ueno@unixuser.org> | 2012-10-26 21:44:34 +0900 |
commit | e39364ba5a8930ade20af80ad30aba69ea9398cd (patch) | |
tree | 7e91691ddb083d0588607b6dd26bd6e81cbca837 /libcaribou/xadapter.vala | |
parent | 661d4dcb62c201e1a8899e91f09fcaa1a0206294 (diff) | |
download | caribou-e39364ba5a8930ade20af80ad30aba69ea9398cd.tar.gz |
xadapter: use XkbChangeMap instead of XkbSetMap
Optimize keycode replacement logic using XkbChangeMap instead
of XkbSetMap.
https://bugzilla.gnome.org/show_bug.cgi?id=673547
Diffstat (limited to 'libcaribou/xadapter.vala')
-rw-r--r-- | libcaribou/xadapter.vala | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/libcaribou/xadapter.vala b/libcaribou/xadapter.vala index a222f2f..8319313 100644 --- a/libcaribou/xadapter.vala +++ b/libcaribou/xadapter.vala @@ -154,16 +154,21 @@ namespace Caribou { this.xdisplay.flush (); uint offset = this.xkbdesc.map.key_sym_map[this.reserved_keycode].offset; - this.xkbdesc.map.syms[offset] = keysym; this.xkbdesc.device_spec = (ushort) Xkb.UseCoreKbd; - Xkb.set_map (this.xdisplay, Xkb.AllMapComponentsMask, this.xkbdesc); - /** - * FIXME: the use of XkbChangeMap, and the reuse of the priv->xkb_desc - * structure, would be far preferable. HOWEVER it does not seem to work - * using XFree 4.3. - **/ + Xkb.MapChanges changes = Xkb.MapChanges (); + + // We don't touch key types here but include the + // information in XkbSetMap request to the server, because + // some X servers need the information to check the sanity + // of the keysyms change. + changes.changed = (ushort) (Xkb.KeySymsMask | Xkb.KeyTypesMask); + changes.first_key_sym = (char) this.reserved_keycode; + changes.num_key_syms = this.xkbdesc.map.key_sym_map[this.reserved_keycode].width; + changes.first_type = 0; + changes.num_types = this.xkbdesc.map.num_types; + Xkb.change_map (this.xdisplay, this.xkbdesc, changes); this.xdisplay.flush (); |