On Mon, Oct 21, 2013 at 02:41:54PM +0200, Rui Matos wrote: > --- > hw/xfree86/xwayland/xwayland-input.c | 39 > +++++++++++++++++++++++++++++++++--- > include/input.h | 2 +- > 2 files changed, 37 insertions(+), 4 deletions(-) > > diff --git a/hw/xfree86/xwayland/xwayland-input.c > b/hw/xfree86/xwayland/xwayland-input.c > index d031b34..ebf1af1 100644 > --- a/hw/xfree86/xwayland/xwayland-input.c > +++ b/hw/xfree86/xwayland/xwayland-input.c > @@ -143,7 +143,10 @@ xwl_keyboard_proc(DeviceIntPtr device, int what) > switch (what) { > case DEVICE_INIT: > device->public.on = FALSE; > - len = strnlen(xwl_seat->keymap, xwl_seat->keymap_size); > + if (xwl_seat->keymap) > + len = strnlen(xwl_seat->keymap, xwl_seat->keymap_size); > + else > + len = 0; > if (!InitKeyboardDeviceStructFromString(device, xwl_seat->keymap, > len, > NULL, xwl_keyboard_control)) > @@ -453,12 +456,42 @@ keyboard_handle_keymap(void *data, struct wl_keyboard > *keyboard, > uint32_t format, int fd, uint32_t size) > { > struct xwl_seat *xwl_seat = data; > + DeviceIntPtr master; > + XkbDescPtr xkb; > + XkbChangesRec changes = { 0 }; > + > + if (xwl_seat->keymap) > + munmap(xwl_seat->keymap, xwl_seat->keymap_size); > > xwl_seat->keymap_size = size; > xwl_seat->keymap = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0); > - if (xwl_seat->keymap == MAP_FAILED) > - ; /* wah wah */
So much better than the current way we handle this... Thanks all three committed to the xwayland branch. Kristian > + if (xwl_seat->keymap == MAP_FAILED) { > + xwl_seat->keymap_size = 0; > + xwl_seat->keymap = NULL; > + goto out; > + } > + > + if (!xwl_seat->keyboard) > + goto out; > + > + xkb = XkbCompileKeymapFromString(xwl_seat->keyboard, xwl_seat->keymap, > + strnlen(xwl_seat->keymap, > xwl_seat->keymap_size)); > + if (!xkb) > + goto out; > + > + XkbUpdateDescActions(xkb, xkb->min_key_code, XkbNumKeys(xkb), &changes); > + /* Keep the current controls */ > + XkbCopyControls(xkb, xwl_seat->keyboard->key->xkbInfo->desc); > + > + XkbDeviceApplyKeymap(xwl_seat->keyboard, xkb); > + > + master = GetMaster(xwl_seat->keyboard, MASTER_KEYBOARD); > + if (master && master->lastSlave == xwl_seat->keyboard) > + XkbDeviceApplyKeymap(master, xkb); > + > + XkbFreeKeyboard(xkb, XkbAllComponentsMask, TRUE); > > + out: > close(fd); > } > > diff --git a/include/input.h b/include/input.h > index 9f09e65..ecbcb0a 100644 > --- a/include/input.h > +++ b/include/input.h > @@ -508,7 +508,7 @@ extern int AttachDevice(ClientPtr client, > DeviceIntPtr slave, DeviceIntPtr master); > > extern _X_EXPORT DeviceIntPtr GetPairedDevice(DeviceIntPtr kbd); > -extern DeviceIntPtr GetMaster(DeviceIntPtr dev, int type); > +extern _X_EXPORT DeviceIntPtr GetMaster(DeviceIntPtr dev, int type); > > extern _X_EXPORT int AllocDevicePair(ClientPtr client, > const char *name, > -- > 1.8.3.1 > > _______________________________________________ > wayland-devel mailing list > wayland-devel@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/wayland-devel _______________________________________________ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel