#include <X11/extensions/XKBgeomcommon.h>
#include <X11/extensions/XKBrulescommon.h>
+/* Action structures used in the server */
+typedef struct _XkbcModAction {
+ unsigned char type;
+ unsigned char flags;
+ unsigned char mask;
+ unsigned char real_mods;
+ unsigned int vmods;
+} XkbcModAction;
+
+typedef struct _XkbcISOAction {
+ unsigned char type;
+ unsigned char flags;
+ unsigned char mask;
+ unsigned char real_mods;
+ /* FIXME: Make this an int. */
+ char group_XXX;
+ unsigned char affect;
+ unsigned int vmods;
+} XkbcISOAction;
+
+typedef struct _XkbcPtrAction {
+ unsigned char type;
+ unsigned char flags;
+ int x;
+ int y;
+} XkbcPtrAction;
+
+typedef struct _XkbcCtrlsAction {
+ unsigned char type;
+ unsigned char flags;
+ unsigned long ctrls;
+} XkbcCtrlsAction;
+
+typedef struct _XkbcRedirectKeyAction {
+ unsigned char type;
+ unsigned char new_key;
+ unsigned char mods_mask;
+ unsigned char mods;
+ unsigned int vmods_mask;
+ unsigned int vmods;
+} XkbcRedirectKeyAction;
+
+typedef union _XkbcAction {
+ XkbAnyAction any;
+ XkbcModAction mods;
+ XkbGroupAction group;
+ XkbcISOAction iso;
+ XkbcPtrAction ptr;
+ XkbPtrBtnAction btn;
+ XkbPtrDfltAction dflt;
+ XkbSwitchScreenAction screen;
+ XkbcCtrlsAction ctrls;
+ XkbMessageAction msg;
+ XkbcRedirectKeyAction redirect;
+ XkbDeviceBtnAction devbtn;
+ XkbDeviceValuatorAction devval;
+ unsigned char type;
+} XkbcAction;
+
+typedef struct _XkbcServerMapRec {
+ unsigned short num_acts;
+ unsigned short size_acts;
+ XkbcAction * acts;
+
+ XkbBehavior * behaviors;
+ unsigned short * key_acts;
+#if defined(__cplusplus) || defined(c_plusplus)
+ /* explicit is a C++ reserved word */
+ unsigned char * c_explicit;
+#else
+ unsigned char * explicit;
+#endif
+ unsigned char vmods[XkbNumVirtualMods];
+ unsigned short * vmodmap;
+} XkbcServerMapRec, *XkbcServerMapPtr;
+
/* Common keyboard description structure */
typedef struct _XkbcDesc {
unsigned int defined;
KeyCode max_key_code;
XkbControlsPtr ctrls;
- XkbServerMapPtr server;
+ XkbcServerMapPtr server;
XkbClientMapPtr map;
XkbIndicatorPtr indicators;
XkbNamesPtr names;
XkbcChangeKeycodeRange(XkbcDescPtr xkb, int minKC, int maxKC,
XkbChangesPtr changes);
-extern XkbAction *
+extern XkbcAction *
XkbcResizeKeyActions(XkbcDescPtr xkb, int key, int needed);
extern void
XkbcAllocServerMap(XkbcDescPtr xkb, unsigned which, unsigned nNewActions)
{
int i;
- XkbServerMapPtr map;
+ XkbcServerMapPtr map;
if (!xkb)
return BadMatch;
if (!xkb->server) {
- map = _XkbTypedCalloc(1, XkbServerMapRec);
+ map = _XkbTypedCalloc(1, XkbcServerMapRec);
if (!map)
return BadAlloc;
nNewActions = 1;
if (!map->acts) {
- map->acts = _XkbTypedCalloc(nNewActions + 1, XkbAction);
+ map->acts = _XkbTypedCalloc(nNewActions + 1, XkbcAction);
if (!map->acts)
return BadAlloc;
map->num_acts = 1;
}
else if ((map->size_acts - map->num_acts) < nNewActions) {
unsigned need;
- XkbAction *prev_acts = map->acts;
+ XkbcAction *prev_acts = map->acts;
need = map->num_acts + nNewActions;
- map->acts = _XkbTypedRealloc(map->acts, need, XkbAction);
+ map->acts = _XkbTypedRealloc(map->acts, need, XkbcAction);
if (!map->acts) {
_XkbFree(prev_acts);
map->num_acts = map->size_acts = 0;
map->size_acts = need;
bzero(&map->acts[map->num_acts],
- (map->size_acts - map->num_acts) * sizeof(XkbAction));
+ (map->size_acts - map->num_acts) * sizeof(XkbcAction));
}
if (!map->key_acts) {
return Success;
}
-XkbAction *
+XkbcAction *
XkbcResizeKeyActions(XkbcDescPtr xkb, int key, int needed)
{
int i, nActs;
- XkbAction *newActs;
+ XkbcAction *newActs;
if (needed == 0) {
xkb->server->key_acts[key] = 0;
(XkbKeyNumSyms(xkb, key) >= (unsigned)needed))
return XkbKeyActionsPtr(xkb, key);
- if (xkb->server->size_acts-xkb->server->num_acts >= (unsigned)needed) {
+ if (xkb->server->size_acts - xkb->server->num_acts >= (unsigned)needed) {
xkb->server->key_acts[key] = xkb->server->num_acts;
xkb->server->num_acts += needed;
}
xkb->server->size_acts = xkb->server->num_acts + needed + 8;
- newActs = _XkbTypedCalloc(xkb->server->size_acts, XkbAction);
+ newActs = _XkbTypedCalloc(xkb->server->size_acts, XkbcAction);
if (!newActs)
return NULL;
newActs[0].type = XkbSA_NoAction;
if (nCopy > 0)
memcpy(&newActs[nActs], XkbKeyActionsPtr(xkb, i),
- nCopy * sizeof(XkbAction));
+ nCopy * sizeof(XkbcAction));
if (nCopy < nKeyActs)
- bzero(&newActs[nActs+nCopy],
- (nKeyActs - nCopy) * sizeof(XkbAction));
+ bzero(&newActs[nActs + nCopy],
+ (nKeyActs - nCopy) * sizeof(XkbcAction));
xkb->server->key_acts[i] = nActs;
nActs += nKeyActs;
void
XkbcFreeServerMap(XkbcDescPtr xkb, unsigned what, Bool freeMap)
{
- XkbServerMapPtr map;
+ XkbcServerMapPtr map;
if (!xkb || !xkb->server)
return;
XkbAnyAction * action,
unsigned field, ExprDef * array_ndx, ExprDef * value)
{
- XkbModAction *act;
+ XkbcModAction *act;
unsigned rtrn;
unsigned t1, t2;
- act = (XkbModAction *) action;
+ act = (XkbcModAction *) action;
if (array_ndx != NULL)
{
switch (field)
{
act->flags = t1;
act->real_mods = act->mask = (t2 & 0xff);
- t2 = (t2 >> 8) & 0xffff;
- XkbSetModActionVMods(act, t2);
+ act->vmods = (t2 >> 8) & 0xffff;
return True;
}
return False;
XkbAnyAction * action,
unsigned field, ExprDef * array_ndx, ExprDef * value)
{
- XkbModAction *act;
+ XkbcModAction *act;
unsigned t1, t2;
- act = (XkbModAction *) action;
+ act = (XkbcModAction *) action;
if ((array_ndx != NULL) && (field == F_Modifiers))
return ReportActionNotArray(action->type, field);
switch (field)
{
act->flags = t1;
act->real_mods = act->mask = (t2 & 0xff);
- t2 = (t2 >> 8) & 0xffff;
- XkbSetModActionVMods(act, t2);
+ act->vmods = (t2 >> 8) & 0xffff;
return True;
}
return False;
unsigned field, ExprDef * array_ndx, ExprDef * value)
{
ExprResult rtrn;
- XkbPtrAction *act;
+ XkbcPtrAction *act;
Bool absolute;
- act = (XkbPtrAction *) action;
+ act = (XkbcPtrAction *) action;
if ((array_ndx != NULL) && ((field == F_X) || (field == F_Y)))
return ReportActionNotArray(action->type, field);
{
if (absolute)
act->flags |= XkbSA_MoveAbsoluteX;
- XkbSetPtrActionX(act, rtrn.ival);
+ act->x = rtrn.ival;
}
else
{
if (absolute)
act->flags |= XkbSA_MoveAbsoluteY;
- XkbSetPtrActionY(act, rtrn.ival);
+ act->y = rtrn.ival;
}
return True;
}
unsigned field, ExprDef * array_ndx, ExprDef * value)
{
ExprResult rtrn;
- XkbISOAction *act;
+ XkbcISOAction *act;
unsigned flags, mods;
int group;
- act = (XkbISOAction *) action;
+ act = (XkbcISOAction *) action;
switch (field)
{
case F_Modifiers:
{
act->flags = flags & (~XkbSA_ISODfltIsGroup);
act->real_mods = mods & 0xff;
- mods = (mods >> 8) & 0xff;
- XkbSetModActionVMods(act, mods);
+ act->vmods = (mods >> 8) & 0xff;
return True;
}
return False;
unsigned field, ExprDef * array_ndx, ExprDef * value)
{
ExprResult rtrn;
- XkbCtrlsAction *act;
+ XkbcCtrlsAction *act;
- act = (XkbCtrlsAction *) action;
+ act = (XkbcCtrlsAction *) action;
if (field == F_Controls)
{
if (array_ndx != NULL)
if (!ExprResolveMask
(value, &rtrn, SimpleLookup, (char *) ctrlNames))
return ReportMismatch(action->type, field, "controls mask");
- XkbActionSetCtrls(act, rtrn.uval);
+ act->ctrls = rtrn.uval;
return True;
}
return ReportIllegal(action->type, field);
unsigned field, ExprDef * array_ndx, ExprDef * value)
{
ExprResult rtrn;
- XkbRedirectKeyAction *act;
- unsigned t1, t2, vmods, vmask;
+ XkbcRedirectKeyAction *act;
+ unsigned t1, t2;
unsigned long tmp;
if (array_ndx != NULL)
return ReportActionNotArray(action->type, field);
- act = (XkbRedirectKeyAction *) action;
+ act = (XkbcRedirectKeyAction *) action;
switch (field)
{
case F_Keycode:
act->mods &= ~(t2 & 0xff);
t2 = (t2 >> 8) & 0xffff;
- vmods = XkbSARedirectVMods(act);
- vmask = XkbSARedirectVModsMask(act);
- vmask |= t2;
+ act->vmods_mask |= t2;
if (field == F_Modifiers)
- vmods |= t2;
+ act->vmods |= t2;
else
- vmods &= ~t2;
- XkbSARedirectSetVMods(act, vmods);
- XkbSARedirectSetVModsMask(act, vmask);
+ act->vmods &= ~t2;
return True;
}
return True;
/***====================================================================***/
static void
-ApplyActionFactoryDefaults(XkbAction * action)
+ApplyActionFactoryDefaults(XkbcAction * action)
{
if (action->type == XkbSA_SetPtrDflt)
{ /* increment default button */
action->type = hndlrType = tmp;
if (action->type != XkbSA_NoAction)
{
- ApplyActionFactoryDefaults((XkbAction *) action);
+ ApplyActionFactoryDefaults((XkbcAction *) action);
while (info)
{
if ((info->action == XkbSA_NoAction)
unsigned char actsDefined;
short numLevels[XkbNumKbdGroups];
KeySym *syms[XkbNumKbdGroups];
- XkbAction *acts[XkbNumKbdGroups];
+ XkbcAction *acts[XkbNumKbdGroups];
Atom types[XkbNumKbdGroups];
unsigned repeat;
XkbBehavior behavior;
}
if (old->acts[i] != NULL)
{
- new->acts[i] = uTypedCalloc(width, XkbAction);
+ new->acts[i] = uTypedCalloc(width, XkbcAction);
if (!new->acts[i])
{
new->acts[i] = NULL;
return False;
}
memcpy((char *) new->acts[i], (char *) old->acts[i],
- width * sizeof(XkbAction));
+ width * sizeof(XkbcAction));
}
}
}
{
key->acts[group] = uTypedRecalloc(key->acts[group],
key->numLevels[group], newWidth,
- XkbAction);
+ XkbcAction);
if (!key->acts[group])
return False;
}
KeyInfo * into, KeyInfo * from, unsigned group)
{
KeySym *resultSyms;
- XkbAction *resultActs;
+ XkbcAction *resultActs;
int resultWidth;
register int i;
Bool report, clobber;
}
if ((resultActs == NULL) && (into->acts[group] || from->acts[group]))
{
- resultActs = uTypedCalloc(resultWidth, XkbAction);
+ resultActs = uTypedCalloc(resultWidth, XkbcAction);
if (!resultActs)
{
WSGO("Could not allocate actions for group merge\n");
}
if (resultActs != NULL)
{
- XkbAction *fromAct, *toAct;
+ XkbcAction *fromAct, *toAct;
fromAct = (from->acts[group] ? &from->acts[group][i] : NULL);
toAct = (into->acts[group] ? &into->acts[group][i] : NULL);
if (((fromAct == NULL) || (fromAct->type == XkbSA_NoAction))
}
else
{
- XkbAction *use, *ignore;
+ XkbcAction *use, *ignore;
if (clobber)
{
use = fromAct;
key->syms[i] = (KeySym *) NULL;
if (key->acts[i] != NULL)
uFree(key->acts[i]);
- key->acts[i] = (XkbAction *) NULL;
+ key->acts[i] = (XkbcAction *) NULL;
key->types[i] = (Atom) 0;
}
}
key->syms[group] = key->syms[0];
key->syms[0] = (KeySym *) NULL;
key->acts[group] = key->acts[0];
- key->acts[0] = (XkbAction *) NULL;
+ key->acts[0] = (XkbcAction *) NULL;
key->types[group] = key->types[0];
key->types[0] = (Atom) 0;
return True;
}
if ((key->actsDefined & 1) && key->acts[0])
{
- key->acts[i] = uTypedCalloc(width, XkbAction);
+ key->acts[i] = uTypedCalloc(width, XkbcAction);
if (key->acts[i] == NULL)
continue;
memcpy((void *) key->acts[i], (void *) key->acts[0],
- width * sizeof(XkbAction));
+ width * sizeof(XkbcAction));
key->actsDefined |= 1 << i;
}
if ((key->symsDefined & 1) && key->syms[0])
if ((key->acts[i] != key->acts[0]) &&
(key->acts[i] == NULL || key->acts[0] == NULL ||
memcmp((void *) key->acts[i], (void *) key->acts[0],
- sizeof(XkbAction) * key->numLevels[0])))
+ sizeof(XkbcAction) * key->numLevels[0])))
{
identical = False;
break;
key->syms[i] = (KeySym *) NULL;
if (key->acts[i] != NULL)
uFree(key->acts[i]);
- key->acts[i] = (XkbAction *) NULL;
+ key->acts[i] = (XkbcAction *) NULL;
key->types[i] = (Atom) 0;
}
key->symsDefined &= 1;
XkbKeyTypePtr type;
Bool haveActions, autoType, useAlias;
KeySym *outSyms;
- XkbAction *outActs;
+ XkbcAction *outActs;
unsigned types[XkbNumKbdGroups];
useAlias = (start_from == 0);
{
register int i, bit, nextFree;
ExprResult mod;
- XkbServerMapPtr srv;
+ XkbcServerMapPtr srv;
XkbNamesPtr names;
Atom stmtName;