input: allow NULL as XkbRMVLOSet in InitKeyboardDeviceStruct.

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@who-t.net>
Acked-by: Benjamin Close <Benjamin.Close@clearchain.com>
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
This commit is contained in:
Peter Hutterer 2009-04-14 16:57:29 +10:00
parent 4e4e263bc0
commit b406886bbf
6 changed files with 16 additions and 28 deletions

View File

@ -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;
}

View File

@ -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 "

View File

@ -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;

View File

@ -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);

View File

@ -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 */

View File

@ -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);