On Wed, Jul 14, 2010 at 6:04 PM, Peter Hutterer
<[email protected]> wrote:
> This fixes a hang caused by wcmEmitKeySyms(). XkbGetCoreMap() allocates
> memory and doing so in the signal handler (i.e. event processing) may hang
> the machine. Instead, get the core keymap after initialising the key class
> and save it in the device.
>
> Side-effect: if the keyboard layout is set after device initialization, the
> keycodes sent by the wacom device are almost certainly wrong.
>
> Note: while we asked for the keysyms rec on X servers with an ABI < 7  we
> never actually initialised it. The ifdef for the ABI check was removed in
> this patch since the call to XkbGetCoreMap is already inside the ABI >= 7
> check.
>
> Signed-off-by: Peter Hutterer <[email protected]>

Acked-by: Ping Cheng <[email protected]>

> ---
> I don't have a good answer to how to update the keymap when it changes yet.

Maybe we can add a new xsetwacom property so clients/users can inform
the driver when keyboard layout changed. Driver then convert the
existing keys into the new form (I don't know if this is
possible/doable or not though).

>  src/wcmCommon.c     |   14 ++++++--------
>  src/xf86Wacom.c     |    2 ++
>  src/xf86WacomDefs.h |    2 ++
>  3 files changed, 10 insertions(+), 8 deletions(-)
>
> diff --git a/src/wcmCommon.c b/src/wcmCommon.c
> index 2185725..629ff0b 100644
> --- a/src/wcmCommon.c
> +++ b/src/wcmCommon.c
> @@ -350,14 +350,14 @@ static int ODDKEYSYM [][2] =
>
>  void wcmEmitKeysym (DeviceIntPtr keydev, int keysym, int state)
>  {
> +       LocalDevicePtr local = (LocalDevicePtr)keydev->public.devicePrivate;
> +       WacomDevicePtr priv = (WacomDevicePtr)local->private;
> +       WacomCommonPtr common = priv->common;
> +
>        int i, j, alt_keysym = 0;
>
>        /* Now that we have the keycode look for key index */
> -#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
> -       KeySymsRec *ksr = XkbGetCoreMap(keydev);
> -#else
> -       KeySymsRec *ksr = &keydev->key->curKeySyms;
> -#endif
> +       KeySymsRec *ksr = common->keysyms;
>
>        for (i = ksr->minKeyCode; i <= ksr->maxKeyCode; i++)
>                if (ksr->map [(i - ksr->minKeyCode) * ksr->mapWidth] == keysym)
> @@ -403,9 +403,6 @@ void wcmEmitKeysym (DeviceIntPtr keydev, int keysym, int 
> state)
>                return;
>        }
>        xf86PostKeyboardEvent (keydev, i, state);
> -#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
> -       free(ksr);
> -#endif
>  }
>
>  static void toggleDisplay(LocalDevicePtr local)
> @@ -2025,6 +2022,7 @@ void wcmFreeCommon(WacomCommonPtr *ptr)
>        if (--common->refcnt == 0)
>        {
>                free(common->private);
> +               free(common->keysyms);
>                free(common);
>        }
>        *ptr = NULL;
> diff --git a/src/xf86Wacom.c b/src/xf86Wacom.c
> index 28042ed..ddfe09c 100644
> --- a/src/xf86Wacom.c
> +++ b/src/xf86Wacom.c
> @@ -646,6 +646,8 @@ static int wcmRegisterX11Devices (LocalDevicePtr local)
>                modmap[XkbMinLegalKeyCode + 2] = ShiftMask;
>                XkbApplyMappingChange(local->dev, &syms, syms.minKeyCode, 
> num_keys, NULL, // modmap,
>                                serverClient);
> +
> +               common->keysyms = XkbGetCoreMap(local->dev);
>        } else
>        {
>                xf86Msg(X_ERROR, "%s: unable to init kbd device struct\n", 
> local->name);
> diff --git a/src/xf86WacomDefs.h b/src/xf86WacomDefs.h
> index b700431..b61d71c 100644
> --- a/src/xf86WacomDefs.h
> +++ b/src/xf86WacomDefs.h
> @@ -445,6 +445,8 @@ struct _WacomCommonRec
>
>        /* DO NOT TOUCH THIS. use wcmRefCommon() instead */
>        int refcnt;                     /* number of devices sharing this 
> struct */
> +
> +       KeySymsRec *keysyms;    /* core keyboard map */
>  };
>
>  #define HANDLE_TILT(comm) ((comm)->wcmFlags & TILT_ENABLED_FLAG)
> --
> 1.7.1
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by Sprint
> What will you do first with EVO, the first 4G phone?
> Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
> _______________________________________________
> Linuxwacom-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel
>

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Linuxwacom-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to