From 2fb329c9649a6e743416b6457bb0af9633ac1064 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Wed, 23 Jun 2010 16:25:10 +0100 Subject: [PATCH] Copy and duplicate XkbModsRec and XkbKTMapEntryRec Copy these types in so we can extend the vmod size. Signed-off-by: Daniel Stone --- include/X11/extensions/XKBcommon.h | 22 +++++++++++++++++----- src/alloc.c | 4 ++-- src/malloc.c | 16 ++++++++-------- src/misc.c | 10 +++++----- src/xkb.c | 2 +- src/xkbcomp/compat.c | 2 +- src/xkbcomp/keytypes.c | 34 +++++++++++++++++----------------- 7 files changed, 51 insertions(+), 39 deletions(-) diff --git a/include/X11/extensions/XKBcommon.h b/include/X11/extensions/XKBcommon.h index 5b6d02c..a508990 100644 --- a/include/X11/extensions/XKBcommon.h +++ b/include/X11/extensions/XKBcommon.h @@ -149,12 +149,24 @@ typedef union _XkbcAction { unsigned char type; } XkbcAction; +typedef struct _XkbcMods { + uint32_t mask; /* effective mods */ + uint32_t vmods; + uint8_t real_mods; +} XkbcModsRec, *XkbcModsPtr; + +typedef struct _XkbcKTMapEntry { + Bool active; + uint16_t level; + XkbcModsRec mods; +} XkbcKTMapEntryRec, *XkbcKTMapEntryPtr; + typedef struct _XkbcKeyType { - XkbModsRec mods; - unsigned char num_levels; + XkbcModsRec mods; + uint16_t num_levels; unsigned char map_count; - XkbKTMapEntryPtr map; - XkbModsPtr preserve; + XkbcKTMapEntryPtr map; + XkbcModsPtr preserve; CARD32 name; CARD32 *level_names; } XkbcKeyTypeRec, *XkbcKeyTypePtr; @@ -170,7 +182,7 @@ typedef struct _XkbcSymInterpretRec { typedef struct _XkbcCompatMapRec { XkbcSymInterpretPtr sym_interpret; - XkbModsRec groups[XkbNumKbdGroups]; + XkbcModsRec groups[XkbNumKbdGroups]; unsigned short num_si; unsigned short size_si; } XkbcCompatMapRec, *XkbcCompatMapPtr; diff --git a/src/alloc.c b/src/alloc.c index b0393b9..7c81271 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -79,7 +79,7 @@ XkbcAllocCompatMap(XkbcDescPtr xkb, unsigned which, unsigned nSI) } compat->size_si = nSI; compat->num_si = 0; - bzero(&compat->groups[0], XkbNumKbdGroups * sizeof(XkbModsRec)); + bzero(&compat->groups[0], XkbNumKbdGroups * sizeof(XkbcModsRec)); xkb->compat = compat; return Success; @@ -99,7 +99,7 @@ XkbcFreeCompatMap(XkbcDescPtr xkb, unsigned which, Bool freeMap) which = XkbAllCompatMask; if (which & XkbGroupCompatMask) - bzero(&compat->groups[0], XkbNumKbdGroups * sizeof(XkbModsRec)); + bzero(&compat->groups[0], XkbNumKbdGroups * sizeof(XkbcModsRec)); if (which & XkbSymInterpMask) { if (compat->sym_interpret && (compat->size_si > 0)) diff --git a/src/malloc.c b/src/malloc.c index 7bcea7c..708407a 100644 --- a/src/malloc.c +++ b/src/malloc.c @@ -252,19 +252,19 @@ XkbcCopyKeyType(XkbcKeyTypePtr from, XkbcKeyTypePtr into) *into = *from; if (from->map && (into->map_count > 0)) { - into->map = _XkbTypedCalloc(into->map_count, XkbKTMapEntryRec); + into->map = _XkbTypedCalloc(into->map_count, XkbcKTMapEntryRec); if (!into->map) return BadAlloc; memcpy(into->map, from->map, - into->map_count * sizeof(XkbKTMapEntryRec)); + into->map_count * sizeof(XkbcKTMapEntryRec)); } if (from->preserve && (into->map_count > 0)) { - into->preserve = _XkbTypedCalloc(into->map_count, XkbModsRec); + into->preserve = _XkbTypedCalloc(into->map_count, XkbcModsRec); if (!into->preserve) return BadAlloc; memcpy(into->preserve, from->preserve, - into->map_count * sizeof(XkbModsRec)); + into->map_count * sizeof(XkbcModsRec)); } if (from->level_names && (into->num_levels > 0)) { @@ -330,11 +330,11 @@ XkbcResizeKeyType(XkbcDescPtr xkb, int type_ndx, int map_count, type->map_count = 0; } else { - XkbKTMapEntryRec *prev_map = type->map; + XkbcKTMapEntryRec *prev_map = type->map; if ((map_count > type->map_count) || !type->map) type->map = _XkbTypedRealloc(type->map, map_count, - XkbKTMapEntryRec); + XkbcKTMapEntryRec); if (!type->map) { if (prev_map) _XkbFree(prev_map); @@ -342,11 +342,11 @@ XkbcResizeKeyType(XkbcDescPtr xkb, int type_ndx, int map_count, } if (want_preserve) { - XkbModsRec *prev_preserve = type->preserve; + XkbcModsRec *prev_preserve = type->preserve; if ((map_count > type->map_count) || !type->preserve) type->preserve = _XkbTypedRealloc(type->preserve, map_count, - XkbModsRec); + XkbcModsRec); if (!type->preserve) { if (prev_preserve) _XkbFree(prev_preserve); diff --git a/src/misc.c b/src/misc.c index 2a1f9cd..e1896a2 100644 --- a/src/misc.c +++ b/src/misc.c @@ -35,23 +35,23 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include -#define mapSize(m) (sizeof(m) / sizeof(XkbKTMapEntryRec)) -static XkbKTMapEntryRec map2Level[]= { +#define mapSize(m) (sizeof(m) / sizeof(XkbcKTMapEntryRec)) +static XkbcKTMapEntryRec map2Level[]= { { True, ShiftMask, {1, ShiftMask, 0} } }; -static XkbKTMapEntryRec mapAlpha[]= { +static XkbcKTMapEntryRec mapAlpha[]= { { True, ShiftMask, { 1, ShiftMask, 0 } }, { True, LockMask, { 0, LockMask, 0 } } }; -static XkbModsRec preAlpha[]= { +static XkbcModsRec preAlpha[]= { { 0, 0, 0 }, { LockMask, LockMask, 0 } }; #define NL_VMOD_MASK 0 -static XkbKTMapEntryRec mapKeypad[]= { +static XkbcKTMapEntryRec mapKeypad[]= { { True, ShiftMask, { 1, ShiftMask, 0 } }, { False, 0, { 1, 0, NL_VMOD_MASK } } }; diff --git a/src/xkb.c b/src/xkb.c index f5a1a0f..28b5cf4 100644 --- a/src/xkb.c +++ b/src/xkb.c @@ -103,7 +103,7 @@ XkbcComputeEffectiveMap(XkbcDescPtr xkb, XkbcKeyTypePtr type, { int i; unsigned tmp; - XkbKTMapEntryPtr entry = NULL; + XkbcKTMapEntryPtr entry = NULL; if (!xkb || !type || !xkb->server) return False; diff --git a/src/xkbcomp/compat.c b/src/xkbcomp/compat.c index 6058c5a..5c8d7df 100644 --- a/src/xkbcomp/compat.c +++ b/src/xkbcomp/compat.c @@ -54,7 +54,7 @@ typedef struct _GroupCompatInfo unsigned char fileID; unsigned char merge; unsigned char real_mods; - unsigned short vmods; + uint32_t vmods; } GroupCompatInfo; typedef struct _CompatInfo diff --git a/src/xkbcomp/keytypes.c b/src/xkbcomp/keytypes.c index 786052c..cf5d96f 100644 --- a/src/xkbcomp/keytypes.c +++ b/src/xkbcomp/keytypes.c @@ -60,7 +60,7 @@ typedef struct _KeyTypeInfo int numLevels; int nEntries; int szEntries; - XkbKTMapEntryPtr entries; + XkbcKTMapEntryPtr entries; PreserveInfo *preserve; int szNames; CARD32 *lvlNames; @@ -94,7 +94,7 @@ CARD32 tok_KEYPAD; extern Bool AddMapEntry(XkbcDescPtr /* xkb */ , KeyTypeInfo * /* type */ , - XkbKTMapEntryPtr /* new */ , + XkbcKTMapEntryPtr /* new */ , Bool /* clobber */ , Bool /* report */ ); @@ -159,10 +159,10 @@ InitKeyTypesInfo(KeyTypesInfo * info, XkbcDescPtr xkb, KeyTypesInfo * from) if (from->dflt.entries) { info->dflt.entries = uTypedCalloc(from->dflt.szEntries, - XkbKTMapEntryRec); + XkbcKTMapEntryRec); if (info->dflt.entries) { - unsigned sz = from->dflt.nEntries * sizeof(XkbKTMapEntryRec); + unsigned sz = from->dflt.nEntries * sizeof(XkbcKTMapEntryRec); memcpy(info->dflt.entries, from->dflt.entries, sz); } } @@ -472,11 +472,11 @@ HandleIncludeKeyTypes(IncludeStmt * stmt, /***====================================================================***/ -static XkbKTMapEntryPtr +static XkbcKTMapEntryPtr FindMatchingMapEntry(KeyTypeInfo * type, unsigned mask, unsigned vmask) { register int i; - XkbKTMapEntryPtr entry; + XkbcKTMapEntryPtr entry; for (i = 0, entry = type->entries; i < type->nEntries; i++, entry++) { @@ -506,15 +506,15 @@ DeleteLevel1MapEntries(KeyTypeInfo * type) } /** - * Return a pointer to the next free XkbKTMapEntry, reallocating space if + * Return a pointer to the next free XkbcKTMapEntry, reallocating space if * necessary. */ -static XkbKTMapEntryPtr +static XkbcKTMapEntryPtr NextMapEntry(KeyTypeInfo * type) { if (type->entries == NULL) { - type->entries = uTypedCalloc(2, XkbKTMapEntryRec); + type->entries = uTypedCalloc(2, XkbcKTMapEntryRec); if (type->entries == NULL) { ERROR("Couldn't allocate map entries for %s\n", TypeTxt(type)); @@ -529,7 +529,7 @@ NextMapEntry(KeyTypeInfo * type) type->szEntries *= 2; type->entries = uTypedRecalloc(type->entries, type->nEntries, type->szEntries, - XkbKTMapEntryRec); + XkbcKTMapEntryRec); if (type->entries == NULL) { ERROR("Couldn't reallocate map entries for %s\n", TypeTxt(type)); @@ -615,9 +615,9 @@ AddPreserve(XkbcDescPtr xkb, Bool AddMapEntry(XkbcDescPtr xkb, KeyTypeInfo * type, - XkbKTMapEntryPtr new, Bool clobber, Bool report) + XkbcKTMapEntryPtr new, Bool clobber, Bool report) { - XkbKTMapEntryPtr old; + XkbcKTMapEntryPtr old; if ((old = FindMatchingMapEntry(type, new->mods.real_mods, new->mods.vmods))) @@ -682,7 +682,7 @@ SetMapEntry(KeyTypeInfo * type, XkbcDescPtr xkb, ExprDef * arrayNdx, ExprDef * value) { ExprResult rtrn; - XkbKTMapEntryRec entry; + XkbcKTMapEntryRec entry; if (arrayNdx == NULL) return ReportTypeShouldBeArray(type, "map entry"); @@ -1019,7 +1019,7 @@ HandleKeyTypeDef(KeyTypeDef * def, /* default type */ for (i = 0; i < info->dflt.nEntries; i++) { - XkbKTMapEntryPtr dflt; + XkbcKTMapEntryPtr dflt; dflt = &info->dflt.entries[i]; if (((dflt->mods.real_mods & type.mask) == dflt->mods.real_mods) && ((dflt->mods.vmods & type.vmask) == dflt->mods.vmods)) @@ -1134,8 +1134,8 @@ CopyDefToKeyType(XkbcDescPtr xkb, XkbcKeyTypePtr type, KeyTypeInfo * def) for (pre = def->preserve; pre != NULL; pre = (PreserveInfo *) pre->defs.next) { - XkbKTMapEntryPtr match; - XkbKTMapEntryRec tmp; + XkbcKTMapEntryPtr match; + XkbcKTMapEntryRec tmp; tmp.mods.real_mods = pre->indexMods; tmp.mods.vmods = pre->indexVMods; tmp.level = 0; @@ -1156,7 +1156,7 @@ CopyDefToKeyType(XkbcDescPtr xkb, XkbcKeyTypePtr type, KeyTypeInfo * def) type->map = def->entries; if (def->preserve) { - type->preserve = uTypedCalloc(type->map_count, XkbModsRec); + type->preserve = uTypedCalloc(type->map_count, XkbcModsRec); if (!type->preserve) { WARN("Couldn't allocate preserve array in CopyDefToKeyType\n"); -- 2.7.4