2009-03-27 07:55:32 -06:00
|
|
|
/************************************************************
|
|
|
|
Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
|
|
|
|
|
|
|
|
Permission to use, copy, modify, and distribute this
|
|
|
|
software and its documentation for any purpose and without
|
|
|
|
fee is hereby granted, provided that the above copyright
|
|
|
|
notice appear in all copies and that both that copyright
|
|
|
|
notice and this permission notice appear in supporting
|
2009-04-04 10:19:51 -06:00
|
|
|
documentation, and that the name of Silicon Graphics not be
|
|
|
|
used in advertising or publicity pertaining to distribution
|
2009-03-27 07:55:32 -06:00
|
|
|
of the software without specific prior written permission.
|
2009-04-04 10:19:51 -06:00
|
|
|
Silicon Graphics makes no representation about the suitability
|
2009-03-27 07:55:32 -06:00
|
|
|
of this software for any purpose. It is provided "as is"
|
|
|
|
without any express or implied warranty.
|
2009-04-04 10:19:51 -06:00
|
|
|
|
|
|
|
SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
|
|
|
|
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
2009-03-27 07:55:32 -06:00
|
|
|
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
|
2009-04-04 10:19:51 -06:00
|
|
|
GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
|
|
|
|
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
|
|
|
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
2009-03-27 07:55:32 -06:00
|
|
|
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
|
|
|
|
THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
|
|
|
|
********************************************************/
|
|
|
|
|
|
|
|
#include "xkbcomp.h"
|
2009-04-08 08:46:25 -06:00
|
|
|
#include "xkbmisc.h"
|
2009-03-27 07:55:32 -06:00
|
|
|
#include "expr.h"
|
|
|
|
|
|
|
|
#include "keycodes.h"
|
|
|
|
#include "vmod.h"
|
|
|
|
#include "misc.h"
|
|
|
|
#include "action.h"
|
|
|
|
#include "misc.h"
|
|
|
|
|
|
|
|
static Bool actionsInitialized;
|
|
|
|
static ExprDef constTrue;
|
|
|
|
static ExprDef constFalse;
|
|
|
|
|
|
|
|
/***====================================================================***/
|
|
|
|
|
2012-03-02 08:25:58 -07:00
|
|
|
static const LookupEntry actionStrings[] = {
|
|
|
|
{ "noaction", XkbSA_NoAction },
|
|
|
|
{ "setmods", XkbSA_SetMods },
|
|
|
|
{ "latchmods", XkbSA_LatchMods },
|
|
|
|
{ "lockmods", XkbSA_LockMods },
|
|
|
|
{ "setgroup", XkbSA_SetGroup },
|
|
|
|
{ "latchgroup", XkbSA_LatchGroup },
|
|
|
|
{ "lockgroup", XkbSA_LockGroup },
|
|
|
|
{ "moveptr", XkbSA_MovePtr },
|
|
|
|
{ "movepointer", XkbSA_MovePtr },
|
|
|
|
{ "ptrbtn", XkbSA_PtrBtn },
|
|
|
|
{ "pointerbutton", XkbSA_PtrBtn },
|
|
|
|
{ "lockptrbtn", XkbSA_LockPtrBtn },
|
|
|
|
{ "lockpointerbutton", XkbSA_LockPtrBtn },
|
|
|
|
{ "lockptrbutton", XkbSA_LockPtrBtn },
|
|
|
|
{ "lockpointerbtn", XkbSA_LockPtrBtn },
|
|
|
|
{ "setptrdflt", XkbSA_SetPtrDflt },
|
|
|
|
{ "setpointerdefault", XkbSA_SetPtrDflt },
|
|
|
|
{ "isolock", XkbSA_ISOLock },
|
|
|
|
{ "terminate", XkbSA_Terminate },
|
|
|
|
{ "terminateserver", XkbSA_Terminate },
|
|
|
|
{ "switchscreen", XkbSA_SwitchScreen },
|
|
|
|
{ "setcontrols", XkbSA_SetControls },
|
|
|
|
{ "lockcontrols", XkbSA_LockControls },
|
|
|
|
{ "actionmessage", XkbSA_ActionMessage },
|
|
|
|
{ "messageaction", XkbSA_ActionMessage },
|
|
|
|
{ "message", XkbSA_ActionMessage },
|
|
|
|
{ "redirect", XkbSA_RedirectKey },
|
|
|
|
{ "redirectkey", XkbSA_RedirectKey },
|
|
|
|
{ "devbtn", XkbSA_DeviceBtn },
|
|
|
|
{ "devicebtn", XkbSA_DeviceBtn },
|
|
|
|
{ "devbutton", XkbSA_DeviceBtn },
|
|
|
|
{ "devicebutton", XkbSA_DeviceBtn },
|
|
|
|
{ "lockdevbtn", XkbSA_DeviceBtn },
|
|
|
|
{ "lockdevicebtn", XkbSA_LockDeviceBtn },
|
|
|
|
{ "lockdevbutton", XkbSA_LockDeviceBtn },
|
|
|
|
{ "lockdevicebutton", XkbSA_LockDeviceBtn },
|
|
|
|
{ "devval", XkbSA_DeviceValuator },
|
|
|
|
{ "deviceval", XkbSA_DeviceValuator },
|
|
|
|
{ "devvaluator", XkbSA_DeviceValuator },
|
|
|
|
{ "devicevaluator", XkbSA_DeviceValuator },
|
|
|
|
{ "private", PrivateAction },
|
|
|
|
{ NULL, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const LookupEntry fieldStrings[] = {
|
|
|
|
{ "clearLocks", F_ClearLocks },
|
|
|
|
{ "latchToLock", F_LatchToLock },
|
|
|
|
{ "genKeyEvent", F_GenKeyEvent },
|
|
|
|
{ "generateKeyEvent", F_GenKeyEvent },
|
|
|
|
{ "report", F_Report },
|
|
|
|
{ "default", F_Default },
|
|
|
|
{ "affect", F_Affect },
|
|
|
|
{ "increment", F_Increment },
|
|
|
|
{ "modifiers", F_Modifiers },
|
|
|
|
{ "mods", F_Modifiers },
|
|
|
|
{ "group", F_Group },
|
|
|
|
{ "x", F_X },
|
|
|
|
{ "y", F_Y },
|
|
|
|
{ "accel", F_Accel },
|
|
|
|
{ "accelerate", F_Accel },
|
|
|
|
{ "repeat", F_Accel },
|
|
|
|
{ "button", F_Button },
|
|
|
|
{ "value", F_Value },
|
|
|
|
{ "controls", F_Controls },
|
|
|
|
{ "ctrls", F_Controls },
|
|
|
|
{ "type", F_Type },
|
|
|
|
{ "count", F_Count },
|
|
|
|
{ "screen", F_Screen },
|
|
|
|
{ "same", F_Same },
|
|
|
|
{ "sameServer", F_Same },
|
|
|
|
{ "data", F_Data },
|
|
|
|
{ "device", F_Device },
|
|
|
|
{ "dev", F_Device },
|
|
|
|
{ "key", F_Keycode },
|
|
|
|
{ "keycode", F_Keycode },
|
|
|
|
{ "kc", F_Keycode },
|
|
|
|
{ "clearmods", F_ModsToClear },
|
|
|
|
{ "clearmodifiers", F_ModsToClear },
|
|
|
|
{ NULL, 0 }
|
|
|
|
};
|
|
|
|
|
2009-03-27 07:55:32 -06:00
|
|
|
static Bool
|
2012-03-02 08:25:58 -07:00
|
|
|
stringToValue(const LookupEntry tab[], const char *string,
|
|
|
|
unsigned *value_rtrn)
|
2009-03-27 07:55:32 -06:00
|
|
|
{
|
2012-03-02 08:25:58 -07:00
|
|
|
const LookupEntry *entry;
|
2009-03-27 07:55:32 -06:00
|
|
|
|
2012-03-02 08:25:58 -07:00
|
|
|
if (!string)
|
2009-03-27 07:55:32 -06:00
|
|
|
return False;
|
2012-03-02 08:25:58 -07:00
|
|
|
|
|
|
|
for (entry = tab; entry->name != NULL; entry++) {
|
|
|
|
if (uStrCaseCmp(entry->name, string) == 0) {
|
|
|
|
*value_rtrn = entry->result;
|
|
|
|
return True;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return False;
|
2009-03-27 07:55:32 -06:00
|
|
|
}
|
|
|
|
|
2012-03-02 08:25:58 -07:00
|
|
|
static const char *
|
|
|
|
valueToString(const LookupEntry tab[], unsigned value)
|
2009-03-27 07:55:32 -06:00
|
|
|
{
|
2012-03-02 08:25:58 -07:00
|
|
|
const LookupEntry *entry;
|
2009-03-27 07:55:32 -06:00
|
|
|
|
2012-03-02 08:25:58 -07:00
|
|
|
for (entry = tab; entry->name != NULL; entry++)
|
|
|
|
if (entry->result == value)
|
|
|
|
return entry->name;
|
2009-03-27 07:55:32 -06:00
|
|
|
|
2012-03-02 08:25:58 -07:00
|
|
|
return "unknown";
|
2009-03-27 07:55:32 -06:00
|
|
|
}
|
|
|
|
|
2012-03-02 08:25:58 -07:00
|
|
|
static Bool
|
|
|
|
stringToAction(const char *str, unsigned *type_rtrn)
|
2009-03-27 07:55:32 -06:00
|
|
|
{
|
2012-03-02 08:25:58 -07:00
|
|
|
return stringToValue(actionStrings, str, type_rtrn);
|
|
|
|
}
|
2009-03-27 07:55:32 -06:00
|
|
|
|
2012-03-02 08:25:58 -07:00
|
|
|
static Bool
|
|
|
|
stringToField(const char *str, unsigned *field_rtrn)
|
|
|
|
{
|
|
|
|
return stringToValue(fieldStrings, str, field_rtrn);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char *
|
|
|
|
fieldText(unsigned field)
|
|
|
|
{
|
|
|
|
return valueToString(fieldStrings, field);
|
2009-03-27 07:55:32 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/***====================================================================***/
|
|
|
|
|
|
|
|
static Bool
|
|
|
|
ReportMismatch(unsigned action, unsigned field, const char *type)
|
|
|
|
{
|
2009-03-31 08:21:20 -06:00
|
|
|
ERROR("Value of %s field must be of type %s\n", fieldText(field), type);
|
|
|
|
ACTION("Action %s definition ignored\n", XkbcActionTypeText(action));
|
2009-03-27 07:55:32 -06:00
|
|
|
return False;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
|
|
|
ReportIllegal(unsigned action, unsigned field)
|
|
|
|
{
|
2009-03-31 08:21:20 -06:00
|
|
|
ERROR("Field %s is not defined for an action of type %s\n",
|
2009-03-28 15:06:26 -06:00
|
|
|
fieldText(field), XkbcActionTypeText(action));
|
2009-03-27 07:55:32 -06:00
|
|
|
ACTION("Action definition ignored\n");
|
|
|
|
return False;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
|
|
|
ReportActionNotArray(unsigned action, unsigned field)
|
|
|
|
{
|
2009-03-31 08:21:20 -06:00
|
|
|
ERROR("The %s field in the %s action is not an array\n",
|
2009-03-28 15:06:26 -06:00
|
|
|
fieldText(field), XkbcActionTypeText(action));
|
2009-03-27 07:55:32 -06:00
|
|
|
ACTION("Action definition ignored\n");
|
|
|
|
return False;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
2012-02-24 07:07:17 -07:00
|
|
|
ReportNotFound(unsigned action, unsigned field, const char *what,
|
|
|
|
const char *bad)
|
2009-03-27 07:55:32 -06:00
|
|
|
{
|
2009-03-31 08:21:20 -06:00
|
|
|
ERROR("%s named %s not found\n", what, bad);
|
|
|
|
ACTION("Ignoring the %s field of an %s action\n", fieldText(field),
|
2009-03-28 15:06:26 -06:00
|
|
|
XkbcActionTypeText(action));
|
2009-03-27 07:55:32 -06:00
|
|
|
return False;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
2010-07-01 12:35:24 -06:00
|
|
|
HandleNoAction(struct xkb_desc * xkb,
|
2010-06-30 11:31:21 -06:00
|
|
|
struct xkb_any_action * action,
|
2009-03-27 07:55:32 -06:00
|
|
|
unsigned field, ExprDef * array_ndx, ExprDef * value)
|
|
|
|
{
|
|
|
|
return ReportIllegal(action->type, field);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
|
|
|
CheckLatchLockFlags(unsigned action,
|
|
|
|
unsigned field, ExprDef * value, unsigned *flags_inout)
|
|
|
|
{
|
|
|
|
unsigned tmp;
|
|
|
|
ExprResult result;
|
|
|
|
|
|
|
|
if (field == F_ClearLocks)
|
|
|
|
tmp = XkbSA_ClearLocks;
|
|
|
|
else if (field == F_LatchToLock)
|
|
|
|
tmp = XkbSA_LatchToLock;
|
|
|
|
else
|
|
|
|
return False; /* WSGO! */
|
2012-02-20 06:44:27 -07:00
|
|
|
if (!ExprResolveBoolean(value, &result))
|
2009-03-27 07:55:32 -06:00
|
|
|
return ReportMismatch(action, field, "boolean");
|
|
|
|
if (result.uval)
|
|
|
|
*flags_inout |= tmp;
|
|
|
|
else
|
|
|
|
*flags_inout &= ~tmp;
|
|
|
|
return True;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
2010-07-01 12:35:24 -06:00
|
|
|
CheckModifierField(struct xkb_desc * xkb,
|
2009-03-27 07:55:32 -06:00
|
|
|
unsigned action,
|
|
|
|
ExprDef * value,
|
|
|
|
unsigned *flags_inout, unsigned *mods_rtrn)
|
|
|
|
{
|
|
|
|
ExprResult rtrn;
|
|
|
|
|
|
|
|
if (value->op == ExprIdent)
|
|
|
|
{
|
2010-06-30 15:20:56 -06:00
|
|
|
const char *valStr;
|
2010-06-15 08:20:32 -06:00
|
|
|
valStr = XkbcAtomText(value->value.str);
|
2009-03-27 07:55:32 -06:00
|
|
|
if (valStr && ((uStrCaseCmp(valStr, "usemodmapmods") == 0) ||
|
|
|
|
(uStrCaseCmp(valStr, "modmapmods") == 0)))
|
|
|
|
{
|
|
|
|
|
|
|
|
*mods_rtrn = 0;
|
|
|
|
*flags_inout |= XkbSA_UseModMapMods;
|
|
|
|
return True;
|
|
|
|
}
|
|
|
|
}
|
2012-02-20 06:32:09 -07:00
|
|
|
if (!ExprResolveVModMask(value, &rtrn, xkb))
|
2009-03-27 07:55:32 -06:00
|
|
|
return ReportMismatch(action, F_Modifiers, "modifier mask");
|
|
|
|
*mods_rtrn = rtrn.uval;
|
|
|
|
*flags_inout &= ~XkbSA_UseModMapMods;
|
|
|
|
return True;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
2010-07-01 12:35:24 -06:00
|
|
|
HandleSetLatchMods(struct xkb_desc * xkb,
|
2010-06-30 11:31:21 -06:00
|
|
|
struct xkb_any_action * action,
|
2009-03-27 07:55:32 -06:00
|
|
|
unsigned field, ExprDef * array_ndx, ExprDef * value)
|
|
|
|
{
|
2010-06-30 11:31:21 -06:00
|
|
|
struct xkb_mod_action *act;
|
2009-03-27 07:55:32 -06:00
|
|
|
unsigned rtrn;
|
|
|
|
unsigned t1, t2;
|
|
|
|
|
2010-06-30 11:31:21 -06:00
|
|
|
act = (struct xkb_mod_action *) action;
|
2009-03-27 07:55:32 -06:00
|
|
|
if (array_ndx != NULL)
|
|
|
|
{
|
|
|
|
switch (field)
|
|
|
|
{
|
|
|
|
case F_ClearLocks:
|
|
|
|
case F_LatchToLock:
|
|
|
|
case F_Modifiers:
|
|
|
|
return ReportActionNotArray(action->type, field);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
switch (field)
|
|
|
|
{
|
|
|
|
case F_ClearLocks:
|
|
|
|
case F_LatchToLock:
|
|
|
|
rtrn = act->flags;
|
|
|
|
if (CheckLatchLockFlags(action->type, field, value, &rtrn))
|
|
|
|
{
|
|
|
|
act->flags = rtrn;
|
|
|
|
return True;
|
|
|
|
}
|
|
|
|
return False;
|
|
|
|
case F_Modifiers:
|
|
|
|
t1 = act->flags;
|
|
|
|
if (CheckModifierField(xkb, action->type, value, &t1, &t2))
|
|
|
|
{
|
|
|
|
act->flags = t1;
|
|
|
|
act->real_mods = act->mask = (t2 & 0xff);
|
2009-04-05 16:15:20 -06:00
|
|
|
act->vmods = (t2 >> 8) & 0xffff;
|
2009-03-27 07:55:32 -06:00
|
|
|
return True;
|
|
|
|
}
|
|
|
|
return False;
|
|
|
|
}
|
|
|
|
return ReportIllegal(action->type, field);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
2010-07-01 12:35:24 -06:00
|
|
|
HandleLockMods(struct xkb_desc * xkb,
|
2010-06-30 11:31:21 -06:00
|
|
|
struct xkb_any_action * action,
|
2009-03-27 07:55:32 -06:00
|
|
|
unsigned field, ExprDef * array_ndx, ExprDef * value)
|
|
|
|
{
|
2010-06-30 11:31:21 -06:00
|
|
|
struct xkb_mod_action *act;
|
2009-03-27 07:55:32 -06:00
|
|
|
unsigned t1, t2;
|
|
|
|
|
2010-06-30 11:31:21 -06:00
|
|
|
act = (struct xkb_mod_action *) action;
|
2009-03-27 07:55:32 -06:00
|
|
|
if ((array_ndx != NULL) && (field == F_Modifiers))
|
|
|
|
return ReportActionNotArray(action->type, field);
|
|
|
|
switch (field)
|
|
|
|
{
|
|
|
|
case F_Modifiers:
|
|
|
|
t1 = act->flags;
|
|
|
|
if (CheckModifierField(xkb, action->type, value, &t1, &t2))
|
|
|
|
{
|
|
|
|
act->flags = t1;
|
|
|
|
act->real_mods = act->mask = (t2 & 0xff);
|
2009-04-05 16:15:20 -06:00
|
|
|
act->vmods = (t2 >> 8) & 0xffff;
|
2009-03-27 07:55:32 -06:00
|
|
|
return True;
|
|
|
|
}
|
|
|
|
return False;
|
|
|
|
}
|
|
|
|
return ReportIllegal(action->type, field);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
|
|
|
CheckGroupField(unsigned action,
|
|
|
|
ExprDef * value, unsigned *flags_inout, int *grp_rtrn)
|
|
|
|
{
|
|
|
|
ExprDef *spec;
|
|
|
|
ExprResult rtrn;
|
|
|
|
|
|
|
|
if ((value->op == OpNegate) || (value->op == OpUnaryPlus))
|
|
|
|
{
|
|
|
|
*flags_inout &= ~XkbSA_GroupAbsolute;
|
|
|
|
spec = value->value.child;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*flags_inout |= XkbSA_GroupAbsolute;
|
|
|
|
spec = value;
|
|
|
|
}
|
|
|
|
|
2012-02-20 08:47:57 -07:00
|
|
|
if (!ExprResolveGroup(spec, &rtrn))
|
2009-03-27 07:55:32 -06:00
|
|
|
return ReportMismatch(action, F_Group, "integer (range 1..8)");
|
|
|
|
if (value->op == OpNegate)
|
|
|
|
*grp_rtrn = -rtrn.ival;
|
|
|
|
else if (value->op == OpUnaryPlus)
|
|
|
|
*grp_rtrn = rtrn.ival;
|
|
|
|
else
|
|
|
|
*grp_rtrn = rtrn.ival - 1;
|
|
|
|
return True;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
2010-07-01 12:35:24 -06:00
|
|
|
HandleSetLatchGroup(struct xkb_desc * xkb,
|
2010-06-30 11:31:21 -06:00
|
|
|
struct xkb_any_action * action,
|
2009-03-27 07:55:32 -06:00
|
|
|
unsigned field, ExprDef * array_ndx, ExprDef * value)
|
|
|
|
{
|
2010-06-30 14:33:25 -06:00
|
|
|
struct xkb_group_action *act;
|
2009-03-27 07:55:32 -06:00
|
|
|
unsigned rtrn;
|
|
|
|
unsigned t1;
|
|
|
|
int t2;
|
|
|
|
|
2010-06-30 14:33:25 -06:00
|
|
|
act = (struct xkb_group_action *) action;
|
2009-03-27 07:55:32 -06:00
|
|
|
if (array_ndx != NULL)
|
|
|
|
{
|
|
|
|
switch (field)
|
|
|
|
{
|
|
|
|
case F_ClearLocks:
|
|
|
|
case F_LatchToLock:
|
|
|
|
case F_Group:
|
|
|
|
return ReportActionNotArray(action->type, field);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
switch (field)
|
|
|
|
{
|
|
|
|
case F_ClearLocks:
|
|
|
|
case F_LatchToLock:
|
|
|
|
rtrn = act->flags;
|
|
|
|
if (CheckLatchLockFlags(action->type, field, value, &rtrn))
|
|
|
|
{
|
|
|
|
act->flags = rtrn;
|
|
|
|
return True;
|
|
|
|
}
|
|
|
|
return False;
|
|
|
|
case F_Group:
|
|
|
|
t1 = act->flags;
|
|
|
|
if (CheckGroupField(action->type, value, &t1, &t2))
|
|
|
|
{
|
|
|
|
act->flags = t1;
|
2010-07-01 12:35:24 -06:00
|
|
|
act->group = t2;
|
2009-03-27 07:55:32 -06:00
|
|
|
return True;
|
|
|
|
}
|
|
|
|
return False;
|
|
|
|
}
|
|
|
|
return ReportIllegal(action->type, field);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
2010-07-01 12:35:24 -06:00
|
|
|
HandleLockGroup(struct xkb_desc * xkb,
|
2010-06-30 11:31:21 -06:00
|
|
|
struct xkb_any_action * action,
|
2009-03-27 07:55:32 -06:00
|
|
|
unsigned field, ExprDef * array_ndx, ExprDef * value)
|
|
|
|
{
|
2010-06-30 14:33:25 -06:00
|
|
|
struct xkb_group_action *act;
|
2009-03-27 07:55:32 -06:00
|
|
|
unsigned t1;
|
|
|
|
int t2;
|
|
|
|
|
2010-06-30 14:33:25 -06:00
|
|
|
act = (struct xkb_group_action *) action;
|
2009-03-27 07:55:32 -06:00
|
|
|
if ((array_ndx != NULL) && (field == F_Group))
|
|
|
|
return ReportActionNotArray(action->type, field);
|
|
|
|
if (field == F_Group)
|
|
|
|
{
|
|
|
|
t1 = act->flags;
|
|
|
|
if (CheckGroupField(action->type, value, &t1, &t2))
|
|
|
|
{
|
|
|
|
act->flags = t1;
|
2010-07-01 12:35:24 -06:00
|
|
|
act->group = t2;
|
2009-03-27 07:55:32 -06:00
|
|
|
return True;
|
|
|
|
}
|
|
|
|
return False;
|
|
|
|
}
|
|
|
|
return ReportIllegal(action->type, field);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
2010-07-01 12:35:24 -06:00
|
|
|
HandleMovePtr(struct xkb_desc * xkb,
|
2010-06-30 11:31:21 -06:00
|
|
|
struct xkb_any_action * action,
|
2009-03-27 07:55:32 -06:00
|
|
|
unsigned field, ExprDef * array_ndx, ExprDef * value)
|
|
|
|
{
|
|
|
|
ExprResult rtrn;
|
2010-06-30 13:48:39 -06:00
|
|
|
struct xkb_pointer_action *act;
|
2009-03-27 07:55:32 -06:00
|
|
|
Bool absolute;
|
|
|
|
|
2010-06-30 13:48:39 -06:00
|
|
|
act = (struct xkb_pointer_action *) action;
|
2009-03-27 07:55:32 -06:00
|
|
|
if ((array_ndx != NULL) && ((field == F_X) || (field == F_Y)))
|
|
|
|
return ReportActionNotArray(action->type, field);
|
|
|
|
|
|
|
|
if ((field == F_X) || (field == F_Y))
|
|
|
|
{
|
|
|
|
if ((value->op == OpNegate) || (value->op == OpUnaryPlus))
|
|
|
|
absolute = False;
|
|
|
|
else
|
|
|
|
absolute = True;
|
2012-02-20 09:24:02 -07:00
|
|
|
if (!ExprResolveInteger(value, &rtrn))
|
2009-03-27 07:55:32 -06:00
|
|
|
return ReportMismatch(action->type, field, "integer");
|
|
|
|
if (field == F_X)
|
|
|
|
{
|
|
|
|
if (absolute)
|
|
|
|
act->flags |= XkbSA_MoveAbsoluteX;
|
2010-10-20 13:57:45 -06:00
|
|
|
act->x = rtrn.ival;
|
2009-03-27 07:55:32 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (absolute)
|
|
|
|
act->flags |= XkbSA_MoveAbsoluteY;
|
2010-10-20 13:57:45 -06:00
|
|
|
act->y = rtrn.ival;
|
2009-03-27 07:55:32 -06:00
|
|
|
}
|
|
|
|
return True;
|
|
|
|
}
|
|
|
|
else if (field == F_Accel)
|
|
|
|
{
|
2012-02-20 06:44:27 -07:00
|
|
|
if (!ExprResolveBoolean(value, &rtrn))
|
2009-03-27 07:55:32 -06:00
|
|
|
return ReportMismatch(action->type, field, "boolean");
|
|
|
|
if (rtrn.uval)
|
|
|
|
act->flags &= ~XkbSA_NoAcceleration;
|
|
|
|
else
|
|
|
|
act->flags |= XkbSA_NoAcceleration;
|
|
|
|
}
|
|
|
|
return ReportIllegal(action->type, field);
|
|
|
|
}
|
|
|
|
|
2012-03-02 08:40:19 -07:00
|
|
|
static const LookupEntry lockWhich[] = {
|
2009-03-27 07:55:32 -06:00
|
|
|
{"both", 0},
|
|
|
|
{"lock", XkbSA_LockNoUnlock},
|
|
|
|
{"neither", (XkbSA_LockNoLock | XkbSA_LockNoUnlock)},
|
|
|
|
{"unlock", XkbSA_LockNoLock},
|
|
|
|
{NULL, 0}
|
|
|
|
};
|
|
|
|
|
|
|
|
static Bool
|
2010-07-01 12:35:24 -06:00
|
|
|
HandlePtrBtn(struct xkb_desc * xkb,
|
2010-06-30 11:31:21 -06:00
|
|
|
struct xkb_any_action * action,
|
2009-03-27 07:55:32 -06:00
|
|
|
unsigned field, ExprDef * array_ndx, ExprDef * value)
|
|
|
|
{
|
|
|
|
ExprResult rtrn;
|
2010-06-30 13:48:39 -06:00
|
|
|
struct xkb_pointer_button_action *act;
|
2009-03-27 07:55:32 -06:00
|
|
|
|
2010-06-30 13:48:39 -06:00
|
|
|
act = (struct xkb_pointer_button_action *) action;
|
2009-03-27 07:55:32 -06:00
|
|
|
if (field == F_Button)
|
|
|
|
{
|
|
|
|
if (array_ndx != NULL)
|
|
|
|
return ReportActionNotArray(action->type, field);
|
2012-02-20 08:47:38 -07:00
|
|
|
if (!ExprResolveButton(value, &rtrn))
|
2009-03-27 07:55:32 -06:00
|
|
|
return ReportMismatch(action->type, field,
|
|
|
|
"integer (range 1..5)");
|
|
|
|
if ((rtrn.ival < 0) || (rtrn.ival > 5))
|
|
|
|
{
|
|
|
|
ERROR("Button must specify default or be in the range 1..5\n");
|
2009-03-31 08:21:20 -06:00
|
|
|
ACTION("Illegal button value %d ignored\n", rtrn.ival);
|
2009-03-27 07:55:32 -06:00
|
|
|
return False;
|
|
|
|
}
|
|
|
|
act->button = rtrn.ival;
|
|
|
|
return True;
|
|
|
|
}
|
|
|
|
else if ((action->type == XkbSA_LockPtrBtn) && (field == F_Affect))
|
|
|
|
{
|
|
|
|
if (array_ndx != NULL)
|
|
|
|
return ReportActionNotArray(action->type, field);
|
|
|
|
if (!ExprResolveEnum(value, &rtrn, lockWhich))
|
|
|
|
return ReportMismatch(action->type, field, "lock or unlock");
|
|
|
|
act->flags &= ~(XkbSA_LockNoLock | XkbSA_LockNoUnlock);
|
|
|
|
act->flags |= rtrn.ival;
|
|
|
|
return True;
|
|
|
|
}
|
|
|
|
else if (field == F_Count)
|
|
|
|
{
|
|
|
|
if (array_ndx != NULL)
|
|
|
|
return ReportActionNotArray(action->type, field);
|
2012-02-20 08:47:38 -07:00
|
|
|
if (!ExprResolveButton(value, &rtrn))
|
2009-03-27 07:55:32 -06:00
|
|
|
return ReportMismatch(action->type, field, "integer");
|
|
|
|
if ((rtrn.ival < 0) || (rtrn.ival > 255))
|
|
|
|
{
|
|
|
|
ERROR("The count field must have a value in the range 0..255\n");
|
2009-03-31 08:21:20 -06:00
|
|
|
ACTION("Illegal count %d ignored\n", rtrn.ival);
|
2009-03-27 07:55:32 -06:00
|
|
|
return False;
|
|
|
|
}
|
|
|
|
act->count = rtrn.ival;
|
|
|
|
return True;
|
|
|
|
}
|
|
|
|
return ReportIllegal(action->type, field);
|
|
|
|
}
|
|
|
|
|
2012-03-02 08:40:19 -07:00
|
|
|
static const LookupEntry ptrDflts[] = {
|
2009-03-27 07:55:32 -06:00
|
|
|
{"dfltbtn", XkbSA_AffectDfltBtn},
|
|
|
|
{"defaultbutton", XkbSA_AffectDfltBtn},
|
|
|
|
{"button", XkbSA_AffectDfltBtn},
|
|
|
|
{NULL, 0}
|
|
|
|
};
|
|
|
|
|
|
|
|
static Bool
|
2010-07-01 12:35:24 -06:00
|
|
|
HandleSetPtrDflt(struct xkb_desc * xkb,
|
2010-06-30 11:31:21 -06:00
|
|
|
struct xkb_any_action * action,
|
2009-03-27 07:55:32 -06:00
|
|
|
unsigned field, ExprDef * array_ndx, ExprDef * value)
|
|
|
|
{
|
|
|
|
ExprResult rtrn;
|
2010-06-30 14:33:25 -06:00
|
|
|
struct xkb_pointer_default_action *act;
|
2009-03-27 07:55:32 -06:00
|
|
|
|
2010-06-30 14:33:25 -06:00
|
|
|
act = (struct xkb_pointer_default_action *) action;
|
2009-03-27 07:55:32 -06:00
|
|
|
if (field == F_Affect)
|
|
|
|
{
|
|
|
|
if (array_ndx != NULL)
|
|
|
|
return ReportActionNotArray(action->type, field);
|
|
|
|
if (!ExprResolveEnum(value, &rtrn, ptrDflts))
|
|
|
|
return ReportMismatch(action->type, field, "pointer component");
|
|
|
|
act->affect = rtrn.uval;
|
|
|
|
return True;
|
|
|
|
}
|
|
|
|
else if ((field == F_Button) || (field == F_Value))
|
|
|
|
{
|
|
|
|
ExprDef *btn;
|
|
|
|
if (array_ndx != NULL)
|
|
|
|
return ReportActionNotArray(action->type, field);
|
|
|
|
if ((value->op == OpNegate) || (value->op == OpUnaryPlus))
|
|
|
|
{
|
|
|
|
act->flags &= ~XkbSA_DfltBtnAbsolute;
|
|
|
|
btn = value->value.child;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
act->flags |= XkbSA_DfltBtnAbsolute;
|
|
|
|
btn = value;
|
|
|
|
}
|
|
|
|
|
2012-02-20 08:47:38 -07:00
|
|
|
if (!ExprResolveButton(btn, &rtrn))
|
2009-03-27 07:55:32 -06:00
|
|
|
return ReportMismatch(action->type, field,
|
|
|
|
"integer (range 1..5)");
|
|
|
|
if ((rtrn.ival < 0) || (rtrn.ival > 5))
|
|
|
|
{
|
|
|
|
ERROR("New default button value must be in the range 1..5\n");
|
2009-03-31 08:21:20 -06:00
|
|
|
ACTION("Illegal default button value %d ignored\n", rtrn.ival);
|
2009-03-27 07:55:32 -06:00
|
|
|
return False;
|
|
|
|
}
|
|
|
|
if (rtrn.ival == 0)
|
|
|
|
{
|
|
|
|
ERROR("Cannot set default pointer button to \"default\"\n");
|
|
|
|
ACTION("Illegal default button setting ignored\n");
|
|
|
|
return False;
|
|
|
|
}
|
|
|
|
if (value->op == OpNegate)
|
2010-07-01 12:35:24 -06:00
|
|
|
act->value = -rtrn.ival;
|
2009-03-27 07:55:32 -06:00
|
|
|
else
|
2010-07-01 12:35:24 -06:00
|
|
|
act->value = rtrn.ival;
|
2009-03-27 07:55:32 -06:00
|
|
|
return True;
|
|
|
|
}
|
|
|
|
return ReportIllegal(action->type, field);
|
|
|
|
}
|
|
|
|
|
2012-03-02 08:40:19 -07:00
|
|
|
static const LookupEntry isoNames[] = {
|
2009-03-27 07:55:32 -06:00
|
|
|
{"mods", XkbSA_ISONoAffectMods},
|
|
|
|
{"modifiers", XkbSA_ISONoAffectMods},
|
|
|
|
{"group", XkbSA_ISONoAffectGroup},
|
|
|
|
{"groups", XkbSA_ISONoAffectGroup},
|
|
|
|
{"ptr", XkbSA_ISONoAffectPtr},
|
|
|
|
{"pointer", XkbSA_ISONoAffectPtr},
|
|
|
|
{"ctrls", XkbSA_ISONoAffectCtrls},
|
|
|
|
{"controls", XkbSA_ISONoAffectCtrls},
|
|
|
|
{"all", ~((unsigned) 0)},
|
|
|
|
{"none", 0},
|
|
|
|
{NULL, 0},
|
|
|
|
};
|
|
|
|
|
|
|
|
static Bool
|
2010-07-01 12:35:24 -06:00
|
|
|
HandleISOLock(struct xkb_desc * xkb,
|
2010-06-30 11:31:21 -06:00
|
|
|
struct xkb_any_action * action,
|
2009-03-27 07:55:32 -06:00
|
|
|
unsigned field, ExprDef * array_ndx, ExprDef * value)
|
|
|
|
{
|
|
|
|
ExprResult rtrn;
|
2010-06-30 11:31:21 -06:00
|
|
|
struct xkb_iso_action *act;
|
2009-03-27 07:55:32 -06:00
|
|
|
unsigned flags, mods;
|
|
|
|
int group;
|
|
|
|
|
2010-06-30 11:31:21 -06:00
|
|
|
act = (struct xkb_iso_action *) action;
|
2009-03-27 07:55:32 -06:00
|
|
|
switch (field)
|
|
|
|
{
|
|
|
|
case F_Modifiers:
|
|
|
|
if (array_ndx != NULL)
|
|
|
|
return ReportActionNotArray(action->type, field);
|
|
|
|
flags = act->flags;
|
|
|
|
if (CheckModifierField(xkb, action->type, value, &flags, &mods))
|
|
|
|
{
|
|
|
|
act->flags = flags & (~XkbSA_ISODfltIsGroup);
|
|
|
|
act->real_mods = mods & 0xff;
|
2009-04-05 16:15:20 -06:00
|
|
|
act->vmods = (mods >> 8) & 0xff;
|
2009-03-27 07:55:32 -06:00
|
|
|
return True;
|
|
|
|
}
|
|
|
|
return False;
|
|
|
|
case F_Group:
|
|
|
|
if (array_ndx != NULL)
|
|
|
|
return ReportActionNotArray(action->type, field);
|
|
|
|
flags = act->flags;
|
|
|
|
if (CheckGroupField(action->type, value, &flags, &group))
|
|
|
|
{
|
|
|
|
act->flags = flags | XkbSA_ISODfltIsGroup;
|
2010-06-16 17:51:49 -06:00
|
|
|
act->group = group;
|
2009-03-27 07:55:32 -06:00
|
|
|
return True;
|
|
|
|
}
|
|
|
|
return False;
|
|
|
|
case F_Affect:
|
|
|
|
if (array_ndx != NULL)
|
|
|
|
return ReportActionNotArray(action->type, field);
|
2012-02-20 09:54:54 -07:00
|
|
|
if (!ExprResolveMask(value, &rtrn, isoNames))
|
2009-03-27 07:55:32 -06:00
|
|
|
return ReportMismatch(action->type, field, "keyboard component");
|
|
|
|
act->affect = (~rtrn.uval) & XkbSA_ISOAffectMask;
|
|
|
|
return True;
|
|
|
|
}
|
|
|
|
return ReportIllegal(action->type, field);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
2010-07-01 12:35:24 -06:00
|
|
|
HandleSwitchScreen(struct xkb_desc * xkb,
|
2010-06-30 11:31:21 -06:00
|
|
|
struct xkb_any_action * action,
|
2009-03-27 07:55:32 -06:00
|
|
|
unsigned field, ExprDef * array_ndx, ExprDef * value)
|
|
|
|
{
|
|
|
|
ExprResult rtrn;
|
2010-06-30 14:33:25 -06:00
|
|
|
struct xkb_switch_screen_action *act;
|
2009-03-27 07:55:32 -06:00
|
|
|
|
2010-06-30 14:33:25 -06:00
|
|
|
act = (struct xkb_switch_screen_action *) action;
|
2009-03-27 07:55:32 -06:00
|
|
|
if (field == F_Screen)
|
|
|
|
{
|
|
|
|
ExprDef *scrn;
|
|
|
|
if (array_ndx != NULL)
|
|
|
|
return ReportActionNotArray(action->type, field);
|
|
|
|
if ((value->op == OpNegate) || (value->op == OpUnaryPlus))
|
|
|
|
{
|
|
|
|
act->flags &= ~XkbSA_SwitchAbsolute;
|
|
|
|
scrn = value->value.child;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
act->flags |= XkbSA_SwitchAbsolute;
|
|
|
|
scrn = value;
|
|
|
|
}
|
|
|
|
|
2012-02-20 09:24:02 -07:00
|
|
|
if (!ExprResolveInteger(scrn, &rtrn))
|
2009-03-27 07:55:32 -06:00
|
|
|
return ReportMismatch(action->type, field, "integer (0..255)");
|
|
|
|
if ((rtrn.ival < 0) || (rtrn.ival > 255))
|
|
|
|
{
|
|
|
|
ERROR("Screen index must be in the range 1..255\n");
|
2009-03-31 08:21:20 -06:00
|
|
|
ACTION("Illegal screen value %d ignored\n", rtrn.ival);
|
2009-03-27 07:55:32 -06:00
|
|
|
return False;
|
|
|
|
}
|
|
|
|
if (value->op == OpNegate)
|
2010-07-01 12:35:24 -06:00
|
|
|
act->screen = -rtrn.ival;
|
2009-03-27 07:55:32 -06:00
|
|
|
else
|
2010-07-01 12:35:24 -06:00
|
|
|
act->screen = rtrn.ival;
|
2009-03-27 07:55:32 -06:00
|
|
|
return True;
|
|
|
|
}
|
|
|
|
else if (field == F_Same)
|
|
|
|
{
|
|
|
|
if (array_ndx != NULL)
|
|
|
|
return ReportActionNotArray(action->type, field);
|
2012-02-20 06:44:27 -07:00
|
|
|
if (!ExprResolveBoolean(value, &rtrn))
|
2009-03-27 07:55:32 -06:00
|
|
|
return ReportMismatch(action->type, field, "boolean");
|
|
|
|
if (rtrn.uval)
|
|
|
|
act->flags &= ~XkbSA_SwitchApplication;
|
|
|
|
else
|
|
|
|
act->flags |= XkbSA_SwitchApplication;
|
|
|
|
return True;
|
|
|
|
}
|
|
|
|
return ReportIllegal(action->type, field);
|
|
|
|
}
|
|
|
|
|
2012-03-02 08:40:19 -07:00
|
|
|
const LookupEntry ctrlNames[] = {
|
|
|
|
{"repeatkeys", XkbRepeatKeysMask},
|
|
|
|
{"repeat", XkbRepeatKeysMask},
|
|
|
|
{"autorepeat", XkbRepeatKeysMask},
|
|
|
|
{"slowkeys", XkbSlowKeysMask},
|
|
|
|
{"bouncekeys", XkbBounceKeysMask},
|
|
|
|
{"stickykeys", XkbStickyKeysMask},
|
|
|
|
{"mousekeys", XkbMouseKeysMask},
|
|
|
|
{"mousekeysaccel", XkbMouseKeysAccelMask},
|
|
|
|
{"accessxkeys", XkbAccessXKeysMask},
|
|
|
|
{"accessxtimeout", XkbAccessXTimeoutMask},
|
|
|
|
{"accessxfeedback", XkbAccessXFeedbackMask},
|
|
|
|
{"audiblebell", XkbAudibleBellMask},
|
|
|
|
{"overlay1", XkbOverlay1Mask},
|
|
|
|
{"overlay2", XkbOverlay2Mask},
|
|
|
|
{"ignoregrouplock", XkbIgnoreGroupLockMask},
|
|
|
|
{"all", XkbAllBooleanCtrlsMask},
|
|
|
|
{"none", 0},
|
2009-03-27 07:55:32 -06:00
|
|
|
{NULL, 0}
|
|
|
|
};
|
|
|
|
|
|
|
|
static Bool
|
2010-07-01 12:35:24 -06:00
|
|
|
HandleSetLockControls(struct xkb_desc * xkb,
|
2010-06-30 11:31:21 -06:00
|
|
|
struct xkb_any_action * action,
|
2009-03-27 07:55:32 -06:00
|
|
|
unsigned field, ExprDef * array_ndx, ExprDef * value)
|
|
|
|
{
|
|
|
|
ExprResult rtrn;
|
2010-06-30 11:31:21 -06:00
|
|
|
struct xkb_controls_action *act;
|
2009-03-27 07:55:32 -06:00
|
|
|
|
2010-06-30 11:31:21 -06:00
|
|
|
act = (struct xkb_controls_action *) action;
|
2009-03-27 07:55:32 -06:00
|
|
|
if (field == F_Controls)
|
|
|
|
{
|
|
|
|
if (array_ndx != NULL)
|
|
|
|
return ReportActionNotArray(action->type, field);
|
2012-02-20 09:54:54 -07:00
|
|
|
if (!ExprResolveMask(value, &rtrn, ctrlNames))
|
2009-03-27 07:55:32 -06:00
|
|
|
return ReportMismatch(action->type, field, "controls mask");
|
2009-04-05 16:15:20 -06:00
|
|
|
act->ctrls = rtrn.uval;
|
2009-03-27 07:55:32 -06:00
|
|
|
return True;
|
|
|
|
}
|
|
|
|
return ReportIllegal(action->type, field);
|
|
|
|
}
|
|
|
|
|
2012-03-02 08:40:19 -07:00
|
|
|
static const LookupEntry evNames[] = {
|
2009-03-27 07:55:32 -06:00
|
|
|
{"press", XkbSA_MessageOnPress},
|
|
|
|
{"keypress", XkbSA_MessageOnPress},
|
|
|
|
{"release", XkbSA_MessageOnRelease},
|
|
|
|
{"keyrelease", XkbSA_MessageOnRelease},
|
|
|
|
{"all", XkbSA_MessageOnPress | XkbSA_MessageOnRelease},
|
|
|
|
{"none", 0},
|
|
|
|
{NULL, 0}
|
|
|
|
};
|
|
|
|
|
|
|
|
static Bool
|
2010-07-01 12:35:24 -06:00
|
|
|
HandleActionMessage(struct xkb_desc * xkb,
|
2010-06-30 11:31:21 -06:00
|
|
|
struct xkb_any_action * action,
|
2009-03-27 07:55:32 -06:00
|
|
|
unsigned field, ExprDef * array_ndx, ExprDef * value)
|
|
|
|
{
|
|
|
|
ExprResult rtrn;
|
2010-06-30 13:48:39 -06:00
|
|
|
struct xkb_message_action *act;
|
2009-03-27 07:55:32 -06:00
|
|
|
|
2010-06-30 13:48:39 -06:00
|
|
|
act = (struct xkb_message_action *) action;
|
2009-03-27 07:55:32 -06:00
|
|
|
switch (field)
|
|
|
|
{
|
|
|
|
case F_Report:
|
|
|
|
if (array_ndx != NULL)
|
|
|
|
return ReportActionNotArray(action->type, field);
|
2012-02-20 09:54:54 -07:00
|
|
|
if (!ExprResolveMask(value, &rtrn, evNames))
|
2009-03-27 07:55:32 -06:00
|
|
|
return ReportMismatch(action->type, field, "key event mask");
|
|
|
|
act->flags &= ~(XkbSA_MessageOnPress | XkbSA_MessageOnRelease);
|
|
|
|
act->flags =
|
|
|
|
rtrn.uval & (XkbSA_MessageOnPress | XkbSA_MessageOnRelease);
|
|
|
|
return True;
|
|
|
|
case F_GenKeyEvent:
|
|
|
|
if (array_ndx != NULL)
|
|
|
|
return ReportActionNotArray(action->type, field);
|
2012-02-20 06:44:27 -07:00
|
|
|
if (!ExprResolveBoolean(value, &rtrn))
|
2009-03-27 07:55:32 -06:00
|
|
|
return ReportMismatch(action->type, field, "boolean");
|
|
|
|
if (rtrn.uval)
|
|
|
|
act->flags |= XkbSA_MessageGenKeyEvent;
|
|
|
|
else
|
|
|
|
act->flags &= ~XkbSA_MessageGenKeyEvent;
|
|
|
|
return True;
|
|
|
|
case F_Data:
|
|
|
|
if (array_ndx == NULL)
|
|
|
|
{
|
2012-02-20 07:15:08 -07:00
|
|
|
if (!ExprResolveString(value, &rtrn))
|
2009-03-27 07:55:32 -06:00
|
|
|
return ReportMismatch(action->type, field, "string");
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int len = strlen(rtrn.str);
|
|
|
|
if ((len < 1) || (len > 6))
|
|
|
|
{
|
|
|
|
WARN("An action message can hold only 6 bytes\n");
|
2009-03-31 08:21:20 -06:00
|
|
|
ACTION("Extra %d bytes ignored\n", len - 6);
|
2009-03-27 07:55:32 -06:00
|
|
|
}
|
|
|
|
strncpy((char *) act->message, rtrn.str, 6);
|
|
|
|
}
|
|
|
|
return True;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
unsigned ndx;
|
2012-02-20 09:24:02 -07:00
|
|
|
if (!ExprResolveInteger(array_ndx, &rtrn))
|
2009-03-27 07:55:32 -06:00
|
|
|
{
|
|
|
|
ERROR("Array subscript must be integer\n");
|
|
|
|
ACTION("Illegal subscript ignored\n");
|
|
|
|
return False;
|
|
|
|
}
|
|
|
|
ndx = rtrn.uval;
|
|
|
|
if (ndx > 5)
|
|
|
|
{
|
|
|
|
ERROR("An action message is at most 6 bytes long\n");
|
2009-03-31 08:21:20 -06:00
|
|
|
ACTION("Attempt to use data[%d] ignored\n", ndx);
|
2009-03-27 07:55:32 -06:00
|
|
|
return False;
|
|
|
|
}
|
2012-02-20 09:24:02 -07:00
|
|
|
if (!ExprResolveInteger(value, &rtrn))
|
2009-03-27 07:55:32 -06:00
|
|
|
return ReportMismatch(action->type, field, "integer");
|
|
|
|
if ((rtrn.ival < 0) || (rtrn.ival > 255))
|
|
|
|
{
|
|
|
|
ERROR("Message data must be in the range 0..255\n");
|
2009-03-31 08:21:20 -06:00
|
|
|
ACTION("Illegal datum %d ignored\n", rtrn.ival);
|
2009-03-27 07:55:32 -06:00
|
|
|
return False;
|
|
|
|
}
|
|
|
|
act->message[ndx] = rtrn.uval;
|
|
|
|
}
|
|
|
|
return True;
|
|
|
|
}
|
|
|
|
return ReportIllegal(action->type, field);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
2010-07-01 12:35:24 -06:00
|
|
|
HandleRedirectKey(struct xkb_desc * xkb,
|
2010-06-30 11:31:21 -06:00
|
|
|
struct xkb_any_action * action,
|
2009-03-27 07:55:32 -06:00
|
|
|
unsigned field, ExprDef * array_ndx, ExprDef * value)
|
|
|
|
{
|
|
|
|
ExprResult rtrn;
|
2010-06-30 13:48:39 -06:00
|
|
|
struct xkb_redirect_key_action *act;
|
2009-04-05 16:15:20 -06:00
|
|
|
unsigned t1, t2;
|
2012-02-15 07:34:08 -07:00
|
|
|
xkb_keycode_t kc;
|
2009-03-27 07:55:32 -06:00
|
|
|
unsigned long tmp;
|
|
|
|
|
|
|
|
if (array_ndx != NULL)
|
|
|
|
return ReportActionNotArray(action->type, field);
|
|
|
|
|
2010-06-30 13:48:39 -06:00
|
|
|
act = (struct xkb_redirect_key_action *) action;
|
2009-03-27 07:55:32 -06:00
|
|
|
switch (field)
|
|
|
|
{
|
|
|
|
case F_Keycode:
|
2012-02-20 07:08:55 -07:00
|
|
|
if (!ExprResolveKeyName(value, &rtrn))
|
2009-03-27 07:55:32 -06:00
|
|
|
return ReportMismatch(action->type, field, "key name");
|
|
|
|
tmp = KeyNameToLong(rtrn.keyName.name);
|
2012-02-15 07:34:08 -07:00
|
|
|
if (!FindNamedKey(xkb, tmp, &kc, True, CreateKeyNames(xkb), 0))
|
2009-03-27 07:55:32 -06:00
|
|
|
{
|
|
|
|
return ReportNotFound(action->type, field, "Key",
|
2009-03-28 15:06:26 -06:00
|
|
|
XkbcKeyNameText(rtrn.keyName.name));
|
2009-03-27 07:55:32 -06:00
|
|
|
}
|
2012-02-15 07:34:08 -07:00
|
|
|
act->new_key = kc;
|
2009-03-27 07:55:32 -06:00
|
|
|
return True;
|
|
|
|
case F_ModsToClear:
|
|
|
|
case F_Modifiers:
|
|
|
|
t1 = 0;
|
|
|
|
if (CheckModifierField(xkb, action->type, value, &t1, &t2))
|
|
|
|
{
|
|
|
|
act->mods_mask |= (t2 & 0xff);
|
|
|
|
if (field == F_Modifiers)
|
|
|
|
act->mods |= (t2 & 0xff);
|
|
|
|
else
|
|
|
|
act->mods &= ~(t2 & 0xff);
|
|
|
|
|
|
|
|
t2 = (t2 >> 8) & 0xffff;
|
2010-10-20 13:57:45 -06:00
|
|
|
act->vmods_mask |= t2;
|
2009-03-27 07:55:32 -06:00
|
|
|
if (field == F_Modifiers)
|
2010-10-20 13:57:45 -06:00
|
|
|
act->vmods |= t2;
|
2009-03-27 07:55:32 -06:00
|
|
|
else
|
2010-10-20 13:57:45 -06:00
|
|
|
act->vmods &= ~t2;
|
2009-03-27 07:55:32 -06:00
|
|
|
return True;
|
|
|
|
}
|
|
|
|
return True;
|
|
|
|
}
|
|
|
|
return ReportIllegal(action->type, field);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
2010-07-01 12:35:24 -06:00
|
|
|
HandleDeviceBtn(struct xkb_desc * xkb,
|
2010-06-30 11:31:21 -06:00
|
|
|
struct xkb_any_action * action,
|
2009-03-27 07:55:32 -06:00
|
|
|
unsigned field, ExprDef * array_ndx, ExprDef * value)
|
|
|
|
{
|
|
|
|
ExprResult rtrn;
|
2010-06-30 14:33:25 -06:00
|
|
|
struct xkb_device_button_action *act;
|
2009-03-27 07:55:32 -06:00
|
|
|
|
2010-06-30 14:33:25 -06:00
|
|
|
act = (struct xkb_device_button_action *) action;
|
2009-03-27 07:55:32 -06:00
|
|
|
if (field == F_Button)
|
|
|
|
{
|
|
|
|
if (array_ndx != NULL)
|
|
|
|
return ReportActionNotArray(action->type, field);
|
2012-02-20 09:24:02 -07:00
|
|
|
if (!ExprResolveInteger(value, &rtrn))
|
2009-03-27 07:55:32 -06:00
|
|
|
return ReportMismatch(action->type, field,
|
|
|
|
"integer (range 1..255)");
|
|
|
|
if ((rtrn.ival < 0) || (rtrn.ival > 255))
|
|
|
|
{
|
|
|
|
ERROR("Button must specify default or be in the range 1..255\n");
|
2009-03-31 08:21:20 -06:00
|
|
|
ACTION("Illegal button value %d ignored\n", rtrn.ival);
|
2009-03-27 07:55:32 -06:00
|
|
|
return False;
|
|
|
|
}
|
|
|
|
act->button = rtrn.ival;
|
|
|
|
return True;
|
|
|
|
}
|
|
|
|
else if ((action->type == XkbSA_LockDeviceBtn) && (field == F_Affect))
|
|
|
|
{
|
|
|
|
if (array_ndx != NULL)
|
|
|
|
return ReportActionNotArray(action->type, field);
|
|
|
|
if (!ExprResolveEnum(value, &rtrn, lockWhich))
|
|
|
|
return ReportMismatch(action->type, field, "lock or unlock");
|
|
|
|
act->flags &= ~(XkbSA_LockNoLock | XkbSA_LockNoUnlock);
|
|
|
|
act->flags |= rtrn.ival;
|
|
|
|
return True;
|
|
|
|
}
|
|
|
|
else if (field == F_Count)
|
|
|
|
{
|
|
|
|
if (array_ndx != NULL)
|
|
|
|
return ReportActionNotArray(action->type, field);
|
2012-02-20 08:47:38 -07:00
|
|
|
if (!ExprResolveButton(value, &rtrn))
|
2009-03-27 07:55:32 -06:00
|
|
|
return ReportMismatch(action->type, field, "integer");
|
|
|
|
if ((rtrn.ival < 0) || (rtrn.ival > 255))
|
|
|
|
{
|
|
|
|
ERROR("The count field must have a value in the range 0..255\n");
|
2009-03-31 08:21:20 -06:00
|
|
|
ACTION("Illegal count %d ignored\n", rtrn.ival);
|
2009-03-27 07:55:32 -06:00
|
|
|
return False;
|
|
|
|
}
|
|
|
|
act->count = rtrn.ival;
|
|
|
|
return True;
|
|
|
|
}
|
|
|
|
else if (field == F_Device)
|
|
|
|
{
|
|
|
|
if (array_ndx != NULL)
|
|
|
|
return ReportActionNotArray(action->type, field);
|
2012-02-20 09:24:02 -07:00
|
|
|
if (!ExprResolveInteger(value, &rtrn))
|
2009-03-27 07:55:32 -06:00
|
|
|
return ReportMismatch(action->type, field,
|
|
|
|
"integer (range 1..255)");
|
|
|
|
if ((rtrn.ival < 0) || (rtrn.ival > 255))
|
|
|
|
{
|
|
|
|
ERROR("Device must specify default or be in the range 1..255\n");
|
2009-03-31 08:21:20 -06:00
|
|
|
ACTION("Illegal device value %d ignored\n", rtrn.ival);
|
2009-03-27 07:55:32 -06:00
|
|
|
return False;
|
|
|
|
}
|
|
|
|
act->device = rtrn.ival;
|
|
|
|
return True;
|
|
|
|
}
|
|
|
|
return ReportIllegal(action->type, field);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
2010-07-01 12:35:24 -06:00
|
|
|
HandleDeviceValuator(struct xkb_desc * xkb,
|
2010-06-30 11:31:21 -06:00
|
|
|
struct xkb_any_action * action,
|
2009-03-27 07:55:32 -06:00
|
|
|
unsigned field, ExprDef * array_ndx, ExprDef * value)
|
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
ExprResult rtrn;
|
2010-06-30 14:33:25 -06:00
|
|
|
struct xkb_device_valuator_action *act;
|
2009-03-27 07:55:32 -06:00
|
|
|
|
2010-06-30 14:33:25 -06:00
|
|
|
act = (struct xkb_device_valuator_action *) action;
|
2009-03-27 07:55:32 -06:00
|
|
|
/* XXX - Not yet implemented */
|
|
|
|
#endif
|
|
|
|
return False;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
2010-07-01 12:35:24 -06:00
|
|
|
HandlePrivate(struct xkb_desc * xkb,
|
2010-06-30 11:31:21 -06:00
|
|
|
struct xkb_any_action * action,
|
2009-03-27 07:55:32 -06:00
|
|
|
unsigned field, ExprDef * array_ndx, ExprDef * value)
|
|
|
|
{
|
|
|
|
ExprResult rtrn;
|
|
|
|
|
|
|
|
switch (field)
|
|
|
|
{
|
|
|
|
case F_Type:
|
2012-02-20 09:24:02 -07:00
|
|
|
if (!ExprResolveInteger(value, &rtrn))
|
2009-03-27 07:55:32 -06:00
|
|
|
return ReportMismatch(PrivateAction, field, "integer");
|
|
|
|
if ((rtrn.ival < 0) || (rtrn.ival > 255))
|
|
|
|
{
|
|
|
|
ERROR("Private action type must be in the range 0..255\n");
|
2009-03-31 08:21:20 -06:00
|
|
|
ACTION("Illegal type %d ignored\n", rtrn.ival);
|
2009-03-27 07:55:32 -06:00
|
|
|
return False;
|
|
|
|
}
|
|
|
|
action->type = rtrn.uval;
|
|
|
|
return True;
|
|
|
|
case F_Data:
|
|
|
|
if (array_ndx == NULL)
|
|
|
|
{
|
2012-02-20 07:15:08 -07:00
|
|
|
if (!ExprResolveString(value, &rtrn))
|
2009-03-27 07:55:32 -06:00
|
|
|
return ReportMismatch(action->type, field, "string");
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int len = strlen(rtrn.str);
|
|
|
|
if ((len < 1) || (len > 7))
|
|
|
|
{
|
|
|
|
WARN("A private action has 7 data bytes\n");
|
2009-03-31 08:21:20 -06:00
|
|
|
ACTION("Extra %d bytes ignored\n", len - 6);
|
2009-03-27 07:55:32 -06:00
|
|
|
return False;
|
|
|
|
}
|
2010-10-20 13:57:45 -06:00
|
|
|
strncpy((char *) action->data, rtrn.str, sizeof action->data);
|
2009-03-27 07:55:32 -06:00
|
|
|
}
|
2010-06-15 08:20:32 -06:00
|
|
|
free(rtrn.str);
|
2009-03-27 07:55:32 -06:00
|
|
|
return True;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
unsigned ndx;
|
2012-02-20 09:24:02 -07:00
|
|
|
if (!ExprResolveInteger(array_ndx, &rtrn))
|
2009-03-27 07:55:32 -06:00
|
|
|
{
|
|
|
|
ERROR("Array subscript must be integer\n");
|
|
|
|
ACTION("Illegal subscript ignored\n");
|
|
|
|
return False;
|
|
|
|
}
|
|
|
|
ndx = rtrn.uval;
|
2010-10-20 13:57:45 -06:00
|
|
|
if (ndx >= sizeof action->data)
|
2009-03-27 07:55:32 -06:00
|
|
|
{
|
2010-06-16 22:56:08 -06:00
|
|
|
ERROR("The data for a private action is 18 bytes long\n");
|
2009-03-31 08:21:20 -06:00
|
|
|
ACTION("Attempt to use data[%d] ignored\n", ndx);
|
2009-03-27 07:55:32 -06:00
|
|
|
return False;
|
|
|
|
}
|
2012-02-20 09:24:02 -07:00
|
|
|
if (!ExprResolveInteger(value, &rtrn))
|
2009-03-27 07:55:32 -06:00
|
|
|
return ReportMismatch(action->type, field, "integer");
|
|
|
|
if ((rtrn.ival < 0) || (rtrn.ival > 255))
|
|
|
|
{
|
|
|
|
ERROR("All data for a private action must be 0..255\n");
|
2009-03-31 08:21:20 -06:00
|
|
|
ACTION("Illegal datum %d ignored\n", rtrn.ival);
|
2009-03-27 07:55:32 -06:00
|
|
|
return False;
|
|
|
|
}
|
2010-10-20 13:57:45 -06:00
|
|
|
action->data[ndx] = rtrn.uval;
|
2009-03-27 07:55:32 -06:00
|
|
|
return True;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ReportIllegal(PrivateAction, field);
|
|
|
|
}
|
|
|
|
|
2010-07-01 12:35:24 -06:00
|
|
|
typedef Bool(*actionHandler) (struct xkb_desc * /* xkb */ ,
|
2010-06-30 11:31:21 -06:00
|
|
|
struct xkb_any_action * /* action */ ,
|
2009-03-27 07:55:32 -06:00
|
|
|
unsigned /* field */ ,
|
|
|
|
ExprDef * /* array_ndx */ ,
|
|
|
|
ExprDef * /* value */
|
|
|
|
);
|
|
|
|
|
2012-03-02 08:40:19 -07:00
|
|
|
static const actionHandler handleAction[XkbSA_NumActions + 1] = {
|
2009-03-27 07:55:32 -06:00
|
|
|
HandleNoAction /* NoAction */ ,
|
|
|
|
HandleSetLatchMods /* SetMods */ ,
|
|
|
|
HandleSetLatchMods /* LatchMods */ ,
|
|
|
|
HandleLockMods /* LockMods */ ,
|
|
|
|
HandleSetLatchGroup /* SetGroup */ ,
|
|
|
|
HandleSetLatchGroup /* LatchGroup */ ,
|
|
|
|
HandleLockGroup /* LockGroup */ ,
|
|
|
|
HandleMovePtr /* MovePtr */ ,
|
|
|
|
HandlePtrBtn /* PtrBtn */ ,
|
|
|
|
HandlePtrBtn /* LockPtrBtn */ ,
|
|
|
|
HandleSetPtrDflt /* SetPtrDflt */ ,
|
|
|
|
HandleISOLock /* ISOLock */ ,
|
|
|
|
HandleNoAction /* Terminate */ ,
|
|
|
|
HandleSwitchScreen /* SwitchScreen */ ,
|
|
|
|
HandleSetLockControls /* SetControls */ ,
|
|
|
|
HandleSetLockControls /* LockControls */ ,
|
|
|
|
HandleActionMessage /* ActionMessage */ ,
|
|
|
|
HandleRedirectKey /* RedirectKey */ ,
|
|
|
|
HandleDeviceBtn /* DeviceBtn */ ,
|
|
|
|
HandleDeviceBtn /* LockDeviceBtn */ ,
|
|
|
|
HandleDeviceValuator /* DeviceValuatr */ ,
|
|
|
|
HandlePrivate /* Private */
|
|
|
|
};
|
|
|
|
|
|
|
|
/***====================================================================***/
|
|
|
|
|
|
|
|
static void
|
2010-06-30 11:31:21 -06:00
|
|
|
ApplyActionFactoryDefaults(union xkb_action * action)
|
2009-03-27 07:55:32 -06:00
|
|
|
{
|
|
|
|
if (action->type == XkbSA_SetPtrDflt)
|
|
|
|
{ /* increment default button */
|
|
|
|
action->dflt.affect = XkbSA_AffectDfltBtn;
|
|
|
|
action->dflt.flags = 0;
|
2010-07-01 12:35:24 -06:00
|
|
|
action->dflt.value = 1;
|
2009-03-27 07:55:32 -06:00
|
|
|
}
|
|
|
|
else if (action->type == XkbSA_ISOLock)
|
|
|
|
{
|
|
|
|
action->iso.real_mods = LockMask;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-27 14:05:52 -06:00
|
|
|
static void
|
|
|
|
ActionsInit(void);
|
2009-03-27 07:55:32 -06:00
|
|
|
|
|
|
|
int
|
|
|
|
HandleActionDef(ExprDef * def,
|
2010-07-01 12:35:24 -06:00
|
|
|
struct xkb_desc * xkb,
|
2010-06-30 11:31:21 -06:00
|
|
|
struct xkb_any_action * action, unsigned mergeMode, ActionInfo * info)
|
2009-03-27 07:55:32 -06:00
|
|
|
{
|
|
|
|
ExprDef *arg;
|
2010-06-30 15:20:56 -06:00
|
|
|
const char *str;
|
2009-03-27 07:55:32 -06:00
|
|
|
unsigned tmp, hndlrType;
|
|
|
|
|
|
|
|
if (!actionsInitialized)
|
|
|
|
ActionsInit();
|
|
|
|
|
|
|
|
if (def->op != ExprActionDecl)
|
|
|
|
{
|
2009-03-31 08:21:20 -06:00
|
|
|
ERROR("Expected an action definition, found %s\n",
|
2009-03-27 07:55:32 -06:00
|
|
|
exprOpText(def->op));
|
|
|
|
return False;
|
|
|
|
}
|
2010-06-16 22:56:08 -06:00
|
|
|
str = XkbcAtomText(def->value.action.name);
|
2009-03-27 07:55:32 -06:00
|
|
|
if (!str)
|
|
|
|
{
|
|
|
|
WSGO("Missing name in action definition!!\n");
|
|
|
|
return False;
|
|
|
|
}
|
|
|
|
if (!stringToAction(str, &tmp))
|
|
|
|
{
|
2009-03-31 08:21:20 -06:00
|
|
|
ERROR("Unknown action %s\n", str);
|
2009-03-27 07:55:32 -06:00
|
|
|
return False;
|
|
|
|
}
|
|
|
|
action->type = hndlrType = tmp;
|
|
|
|
if (action->type != XkbSA_NoAction)
|
|
|
|
{
|
2010-06-30 11:31:21 -06:00
|
|
|
ApplyActionFactoryDefaults((union xkb_action *) action);
|
2009-03-27 07:55:32 -06:00
|
|
|
while (info)
|
|
|
|
{
|
|
|
|
if ((info->action == XkbSA_NoAction)
|
|
|
|
|| (info->action == hndlrType))
|
|
|
|
{
|
|
|
|
if (!(*handleAction[hndlrType]) (xkb, action,
|
|
|
|
info->field,
|
|
|
|
info->array_ndx,
|
|
|
|
info->value))
|
|
|
|
{
|
|
|
|
return False;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
info = info->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (arg = def->value.action.args; arg != NULL;
|
|
|
|
arg = (ExprDef *) arg->common.next)
|
|
|
|
{
|
|
|
|
ExprDef *field, *value, *arrayRtrn;
|
|
|
|
ExprResult elemRtrn, fieldRtrn;
|
|
|
|
unsigned fieldNdx;
|
|
|
|
|
|
|
|
if (arg->op == OpAssign)
|
|
|
|
{
|
|
|
|
field = arg->value.binary.left;
|
|
|
|
value = arg->value.binary.right;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ((arg->op == OpNot) || (arg->op == OpInvert))
|
|
|
|
{
|
|
|
|
field = arg->value.child;
|
|
|
|
value = &constFalse;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
field = arg;
|
|
|
|
value = &constTrue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!ExprResolveLhs(field, &elemRtrn, &fieldRtrn, &arrayRtrn))
|
|
|
|
return False; /* internal error -- already reported */
|
|
|
|
|
|
|
|
if (elemRtrn.str != NULL)
|
|
|
|
{
|
|
|
|
ERROR("Cannot change defaults in an action definition\n");
|
2009-03-31 08:21:20 -06:00
|
|
|
ACTION("Ignoring attempt to change %s.%s\n", elemRtrn.str,
|
2009-03-27 07:55:32 -06:00
|
|
|
fieldRtrn.str);
|
2010-06-15 08:20:32 -06:00
|
|
|
free(elemRtrn.str);
|
|
|
|
free(fieldRtrn.str);
|
2009-03-27 07:55:32 -06:00
|
|
|
return False;
|
|
|
|
}
|
|
|
|
if (!stringToField(fieldRtrn.str, &fieldNdx))
|
|
|
|
{
|
2009-03-31 08:21:20 -06:00
|
|
|
ERROR("Unknown field name %s\n", uStringText(fieldRtrn.str));
|
2010-06-15 08:20:32 -06:00
|
|
|
free(elemRtrn.str);
|
|
|
|
free(fieldRtrn.str);
|
2009-03-27 07:55:32 -06:00
|
|
|
return False;
|
|
|
|
}
|
2010-06-15 08:20:32 -06:00
|
|
|
free(elemRtrn.str);
|
|
|
|
free(fieldRtrn.str);
|
2009-03-27 07:55:32 -06:00
|
|
|
if (!(*handleAction[hndlrType])
|
|
|
|
(xkb, action, fieldNdx, arrayRtrn, value))
|
|
|
|
{
|
|
|
|
return False;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return True;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***====================================================================***/
|
|
|
|
|
|
|
|
int
|
2010-07-01 12:35:24 -06:00
|
|
|
SetActionField(struct xkb_desc * xkb,
|
2009-03-27 07:55:32 -06:00
|
|
|
char *elem,
|
|
|
|
char *field,
|
|
|
|
ExprDef * array_ndx, ExprDef * value, ActionInfo ** info_rtrn)
|
|
|
|
{
|
|
|
|
ActionInfo *new, *old;
|
|
|
|
|
|
|
|
if (!actionsInitialized)
|
|
|
|
ActionsInit();
|
|
|
|
|
|
|
|
new = uTypedAlloc(ActionInfo);
|
|
|
|
if (new == NULL)
|
|
|
|
{
|
|
|
|
WSGO("Couldn't allocate space for action default\n");
|
|
|
|
return False;
|
|
|
|
}
|
|
|
|
if (uStrCaseCmp(elem, "action") == 0)
|
|
|
|
new->action = XkbSA_NoAction;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!stringToAction(elem, &new->action))
|
2010-06-15 08:20:32 -06:00
|
|
|
{
|
|
|
|
free(new);
|
2009-03-27 07:55:32 -06:00
|
|
|
return False;
|
2010-06-15 08:20:32 -06:00
|
|
|
}
|
2009-03-27 07:55:32 -06:00
|
|
|
if (new->action == XkbSA_NoAction)
|
|
|
|
{
|
2009-03-31 08:21:20 -06:00
|
|
|
ERROR("\"%s\" is not a valid field in a NoAction action\n",
|
2009-03-27 07:55:32 -06:00
|
|
|
field);
|
2010-06-15 08:20:32 -06:00
|
|
|
free(new);
|
2009-03-27 07:55:32 -06:00
|
|
|
return False;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!stringToField(field, &new->field))
|
|
|
|
{
|
2009-03-31 08:21:20 -06:00
|
|
|
ERROR("\"%s\" is not a legal field name\n", field);
|
2010-06-15 08:20:32 -06:00
|
|
|
free(new);
|
2009-03-27 07:55:32 -06:00
|
|
|
return False;
|
|
|
|
}
|
|
|
|
new->array_ndx = array_ndx;
|
|
|
|
new->value = value;
|
|
|
|
new->next = NULL;
|
|
|
|
old = *info_rtrn;
|
|
|
|
while ((old) && (old->next))
|
|
|
|
old = old->next;
|
|
|
|
if (old == NULL)
|
|
|
|
*info_rtrn = new;
|
|
|
|
else
|
|
|
|
old->next = new;
|
|
|
|
return True;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***====================================================================***/
|
|
|
|
|
2010-09-27 14:05:52 -06:00
|
|
|
static void
|
2009-03-27 07:55:32 -06:00
|
|
|
ActionsInit(void)
|
|
|
|
{
|
|
|
|
if (!actionsInitialized)
|
|
|
|
{
|
2012-02-29 11:50:17 -07:00
|
|
|
memset(&constTrue, 0, sizeof(constTrue));
|
|
|
|
memset(&constFalse, 0, sizeof(constFalse));
|
2009-03-27 07:55:32 -06:00
|
|
|
constTrue.common.stmtType = StmtExpr;
|
|
|
|
constTrue.common.next = NULL;
|
|
|
|
constTrue.op = ExprIdent;
|
|
|
|
constTrue.type = TypeBoolean;
|
2010-12-17 19:14:54 -07:00
|
|
|
constTrue.value.str = xkb_intern_atom("true");
|
2009-03-27 07:55:32 -06:00
|
|
|
constFalse.common.stmtType = StmtExpr;
|
|
|
|
constFalse.common.next = NULL;
|
|
|
|
constFalse.op = ExprIdent;
|
|
|
|
constFalse.type = TypeBoolean;
|
2010-12-17 19:14:54 -07:00
|
|
|
constFalse.value.str = xkb_intern_atom("false");
|
2009-03-27 07:55:32 -06:00
|
|
|
actionsInitialized = 1;
|
|
|
|
}
|
|
|
|
}
|