[PATCH 1/2] input: allow NULL as XkbRMVLOSet in InitKeyboardDeviceStruct.
Benjamin Close
Benjamin.Close at clearchain.com
Tue Apr 14 23:56:19 PDT 2009
On 15/04/2009 3:10 PM, Peter Hutterer wrote:
> Virtually all callers use
> XkbGetRulesDefault(&rmlvo);
> InitKeyboardDeviceStruct(..., rmlvo);
>
> Let's save them the trouble and accept NULL as a hint to take the
> default RMLVO.
>
> Signed-off-by: Peter Hutterer<peter.hutterer at who-t.net>
> ---
> Xi/exevents.c | 13 +++----------
> dix/devices.c | 4 +---
> hw/vfb/InitInput.c | 4 +---
> hw/xnest/Keyboard.c | 9 +--------
> hw/xquartz/quartzKeyboard.c | 4 +---
> xkb/xkbInit.c | 10 +++++++++-
> 6 files changed, 16 insertions(+), 28 deletions(-)
>
> diff --git a/Xi/exevents.c b/Xi/exevents.c
> index 4788665..cfae57d 100644
> --- a/Xi/exevents.c
> +++ b/Xi/exevents.c
> @@ -226,11 +226,7 @@ DeepCopyFeedbackClasses(DeviceIntPtr from, DeviceIntPtr to)
>
> to->kbdfeed = classes->kbdfeed;
> if (!to->kbdfeed)
> - {
> - XkbRMLVOSet rmlvo;
> - XkbGetRulesDflts(&rmlvo);
> - InitKeyboardDeviceStruct(to,&rmlvo, NULL, NULL);
> - }
> + InitKeyboardDeviceStruct(to, NULL, NULL, NULL);
> }
>
> k =&to->kbdfeed;
> @@ -473,11 +469,8 @@ DeepCopyDeviceClasses(DeviceIntPtr from, DeviceIntPtr to)
> UnusedClassesPrivateKey);
> to->key = classes->key;
> if (!to->key)
> - {
> - XkbRMLVOSet rmlvo;
> - XkbGetRulesDflts(&rmlvo);
> - InitKeyboardDeviceStruct(to,&rmlvo, NULL, NULL);
> - } else
> + InitKeyboardDeviceStruct(to, NULL, NULL, NULL);
> + else
> classes->key = NULL;
> }
>
> diff --git a/dix/devices.c b/dix/devices.c
> index b9d1c85..d14eddd 100644
> --- a/dix/devices.c
> +++ b/dix/devices.c
> @@ -471,12 +471,10 @@ CoreKeyboardCtl(DeviceIntPtr pDev, KeybdCtrl *ctrl)
> static int
> CoreKeyboardProc(DeviceIntPtr pDev, int what)
> {
> - XkbRMLVOSet rmlvo;
>
> switch (what) {
> case DEVICE_INIT:
> - XkbGetRulesDflts(&rmlvo);
> - if (!InitKeyboardDeviceStruct(pDev,&rmlvo, CoreKeyboardBell,
> + if (!InitKeyboardDeviceStruct(pDev, NULL, CoreKeyboardBell,
> CoreKeyboardCtl))
> {
> ErrorF("Keyboard initialization failed. This could be a missing "
> diff --git a/hw/vfb/InitInput.c b/hw/vfb/InitInput.c
> index aa90252..4c8c996 100644
> --- a/hw/vfb/InitInput.c
> +++ b/hw/vfb/InitInput.c
> @@ -66,13 +66,11 @@ static int
> vfbKeybdProc(DeviceIntPtr pDevice, int onoff)
> {
> DevicePtr pDev = (DevicePtr)pDevice;
> - XkbRMLVOSet rmlvo;
>
> switch (onoff)
> {
> case DEVICE_INIT:
> - XkbGetRulesDflts(&rmlvo);
> - InitKeyboardDeviceStruct(pDevice,&rmlvo, NULL, NULL);
> + InitKeyboardDeviceStruct(pDevice, NULL, NULL, NULL);
> break;
> case DEVICE_ON:
> pDev->on = TRUE;
> diff --git a/hw/xnest/Keyboard.c b/hw/xnest/Keyboard.c
> index 8404c8b..f94e260 100644
> --- a/hw/xnest/Keyboard.c
> +++ b/hw/xnest/Keyboard.c
> @@ -121,7 +121,6 @@ xnestKeyboardProc(DeviceIntPtr pDev, int onoff)
> int i;
> XKeyboardState values;
> XkbDescPtr xkb;
> - XkbRMLVOSet rmlvo;
> int op, event, error, major, minor;
>
> switch (onoff)
> @@ -165,13 +164,7 @@ xnestKeyboardProc(DeviceIntPtr pDev, int onoff)
> }
> XkbGetControls(xnestDisplay, XkbAllControlsMask, xkb);
>
> - rmlvo.rules = XKB_DFLT_RULES;
> - rmlvo.model = XKB_DFLT_MODEL;
> - rmlvo.layout = XKB_DFLT_LAYOUT;
> - rmlvo.variant = XKB_DFLT_VARIANT;
> - rmlvo.options = XKB_DFLT_OPTIONS;
> -
> - InitKeyboardDeviceStruct(pDev,&rmlvo,
> + InitKeyboardDeviceStruct(pDev, NULL,
> xnestBell, xnestChangeKeyboardControl);
> XkbDDXChangeControls(pDev, xkb->ctrls, xkb->ctrls);
> XkbFreeKeyboard(xkb, 0, False);
> diff --git a/hw/xquartz/quartzKeyboard.c b/hw/xquartz/quartzKeyboard.c
> index 823c2e6..2b8cb13 100644
> --- a/hw/xquartz/quartzKeyboard.c
> +++ b/hw/xquartz/quartzKeyboard.c
> @@ -317,7 +317,6 @@ void DarwinKeyboardInit(DeviceIntPtr pDev) {
> XkbComponentNamesRec names;
> CFIndex value;
> BOOL ok;
> - XkbRMLVOSet rmlvo;
>
> // Open a shared connection to the HID System.
> // Note that the Event Status Driver is really just a wrapper
> @@ -328,8 +327,7 @@ void DarwinKeyboardInit(DeviceIntPtr pDev) {
>
> bzero(&names, sizeof(names));
>
> - XkbGetRulesDflts(&rmlvo);
> - InitKeyboardDeviceStruct(pDev,&rmlvo, QuartzBell,
> + InitKeyboardDeviceStruct(pDev, NULL, QuartzBell,
> DarwinChangeKeyboardControl);
>
> /* Get our key repeat settings from GlobalPreferences */
> diff --git a/xkb/xkbInit.c b/xkb/xkbInit.c
> index 1f5f8dc..2e75612 100644
> --- a/xkb/xkbInit.c
> +++ b/xkb/xkbInit.c
> @@ -474,10 +474,18 @@ InitKeyboardDeviceStruct(DeviceIntPtr dev, XkbRMLVOSet *rmlvo,
> XkbSrvLedInfoPtr sli;
> XkbChangesRec changes;
> XkbEventCauseRec cause;
> + XkbRMLVOSet rmlvo_dflts = { NULL };
>
> - if (dev->key || dev->kbdfeed || !rmlvo)
> + if (dev->key || dev->kbdfeed)
> return False;
>
> + if (!rmlvo)
> + {
> + rmlvo =&rmlvo_dflts;
> + XkbGetRulesDflts(rmlvo);
> + }
> +
> +
> memset(&changes, 0, sizeof(changes));
> XkbSetCauseUnknown(&cause);
>
>
Acked to both
More information about the xorg-devel
mailing list