diff options
author | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2010-12-05 15:36:12 +0000 |
---|---|---|
committer | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2010-12-05 15:36:12 +0000 |
commit | a90ee792d96752ad1b71b9ada922fa6afe478c99 (patch) | |
tree | 6143b00f7646951d23dfe2a4fe2992ca40b77069 /xserver/xkb/xkbUtils.c | |
parent | bc97d4ecc0aa9e1b823565b07282f848700bd11a (diff) |
Upgrade to xorg-server 1.9.2.
Tested by ajacoutot@, krw@, shadchin@ and jasper@ on various configurations
including multihead with both zaphod and xrandr.
Diffstat (limited to 'xserver/xkb/xkbUtils.c')
-rw-r--r-- | xserver/xkb/xkbUtils.c | 406 |
1 files changed, 168 insertions, 238 deletions
diff --git a/xserver/xkb/xkbUtils.c b/xserver/xkb/xkbUtils.c index b1e0e552c..14dc784b8 100644 --- a/xserver/xkb/xkbUtils.c +++ b/xserver/xkb/xkbUtils.c @@ -282,7 +282,7 @@ register unsigned key; register unsigned bit,i; unsigned present; - bzero(newVMods,XkbNumVirtualMods); + memset(newVMods, 0, XkbNumVirtualMods); present= 0; for (key=xkb->min_key_code;key<=xkb->max_key_code;key++) { if (xkb->server->vmodmap[key]==0) @@ -410,7 +410,7 @@ int maxNumberOfGroups; if (maxSymsPerKey <= 0) return NULL; - syms = xcalloc(1, sizeof(*syms)); + syms = calloc(1, sizeof(*syms)); if (!syms) return NULL; @@ -427,9 +427,9 @@ int maxNumberOfGroups; syms->maxKeyCode = xkb->max_key_code; tmp = syms->mapWidth * (xkb->max_key_code - xkb->min_key_code + 1); - syms->map = xcalloc(tmp, sizeof(*syms->map)); + syms->map = calloc(tmp, sizeof(*syms->map)); if (!syms->map) { - xfree(syms); + free(syms); return NULL; } @@ -588,7 +588,7 @@ XkbSrvInfoPtr xkbi = dev->key->xkbInfo; xkbMapNotify mn; xkbi->desc->server->explicit[key]|= XkbExplicitAutoRepeatMask; - bzero(&mn,sizeof(mn)); + memset(&mn, 0, sizeof(mn)); mn.changed= XkbExplicitComponentsMask; mn.firstKeyExplicit= key; mn.nKeyExplicit= 1; @@ -911,7 +911,7 @@ _XkbCopyClientMap(XkbDescPtr src, XkbDescPtr dst) /* client map */ if (src->map) { if (!dst->map) { - tmp = xcalloc(1, sizeof(XkbClientMapRec)); + tmp = calloc(1, sizeof(XkbClientMapRec)); if (!tmp) return FALSE; dst->map = tmp; @@ -919,11 +919,8 @@ _XkbCopyClientMap(XkbDescPtr src, XkbDescPtr dst) if (src->map->syms) { if (src->map->size_syms != dst->map->size_syms) { - if (dst->map->syms) - tmp = xrealloc(dst->map->syms, - src->map->size_syms * sizeof(KeySym)); - else - tmp = xalloc(src->map->size_syms * sizeof(KeySym)); + tmp = realloc(dst->map->syms, + src->map->size_syms * sizeof(KeySym)); if (!tmp) return FALSE; dst->map->syms = tmp; @@ -933,23 +930,16 @@ _XkbCopyClientMap(XkbDescPtr src, XkbDescPtr dst) src->map->size_syms * sizeof(KeySym)); } else { - if (dst->map->syms) { - xfree(dst->map->syms); - dst->map->syms = NULL; - } + free(dst->map->syms); + dst->map->syms = NULL; } dst->map->num_syms = src->map->num_syms; dst->map->size_syms = src->map->size_syms; if (src->map->key_sym_map) { if (src->max_key_code != dst->max_key_code) { - if (dst->map->key_sym_map) - tmp = xrealloc(dst->map->key_sym_map, - (src->max_key_code + 1) * - sizeof(XkbSymMapRec)); - else - tmp = xalloc((src->max_key_code + 1) * - sizeof(XkbSymMapRec)); + tmp = realloc(dst->map->key_sym_map, + (src->max_key_code + 1) * sizeof(XkbSymMapRec)); if (!tmp) return FALSE; dst->map->key_sym_map = tmp; @@ -958,27 +948,25 @@ _XkbCopyClientMap(XkbDescPtr src, XkbDescPtr dst) (src->max_key_code + 1) * sizeof(XkbSymMapRec)); } else { - if (dst->map->key_sym_map) { - xfree(dst->map->key_sym_map); - dst->map->key_sym_map = NULL; - } + free(dst->map->key_sym_map); + dst->map->key_sym_map = NULL; } if (src->map->types && src->map->num_types) { if (src->map->num_types > dst->map->size_types || !dst->map->types || !dst->map->size_types) { if (dst->map->types && dst->map->size_types) { - tmp = xrealloc(dst->map->types, + tmp = realloc(dst->map->types, src->map->num_types * sizeof(XkbKeyTypeRec)); if (!tmp) return FALSE; dst->map->types = tmp; - bzero(dst->map->types + dst->map->num_types, + memset(dst->map->types + dst->map->num_types, 0, (src->map->num_types - dst->map->num_types) * sizeof(XkbKeyTypeRec)); } else { - tmp = xcalloc(src->map->num_types, sizeof(XkbKeyTypeRec)); + tmp = calloc(src->map->num_types, sizeof(XkbKeyTypeRec)); if (!tmp) return FALSE; dst->map->types = tmp; @@ -988,15 +976,12 @@ _XkbCopyClientMap(XkbDescPtr src, XkbDescPtr dst) dst->map->types) { for (i = src->map->num_types, dtype = (dst->map->types + i); i < dst->map->num_types; i++, dtype++) { - if (dtype->level_names) - xfree(dtype->level_names); + free(dtype->level_names); dtype->level_names = NULL; dtype->num_levels = 0; if (dtype->map_count) { - if (dtype->map) - xfree(dtype->map); - if (dtype->preserve) - xfree(dtype->preserve); + free(dtype->map); + free(dtype->preserve); } } } @@ -1008,7 +993,7 @@ _XkbCopyClientMap(XkbDescPtr src, XkbDescPtr dst) if (stype->num_levels != dtype->num_levels && dtype->num_levels && dtype->level_names && i < dst->map->num_types) { - tmp = xrealloc(dtype->level_names, + tmp = realloc(dtype->level_names, stype->num_levels * sizeof(Atom)); if (!tmp) continue; @@ -1016,7 +1001,7 @@ _XkbCopyClientMap(XkbDescPtr src, XkbDescPtr dst) } else if (!dtype->num_levels || !dtype->level_names || i >= dst->map->num_types) { - tmp = xalloc(stype->num_levels * sizeof(Atom)); + tmp = malloc(stype->num_levels * sizeof(Atom)); if (!tmp) continue; dtype->level_names = tmp; @@ -1028,7 +1013,7 @@ _XkbCopyClientMap(XkbDescPtr src, XkbDescPtr dst) else { if (dtype->num_levels && dtype->level_names && i < dst->map->num_types) - xfree(dtype->level_names); + free(dtype->level_names); dtype->num_levels = 0; dtype->level_names = NULL; } @@ -1041,7 +1026,7 @@ _XkbCopyClientMap(XkbDescPtr src, XkbDescPtr dst) if (stype->map_count != dtype->map_count && dtype->map_count && dtype->map && i < dst->map->num_types) { - tmp = xrealloc(dtype->map, + tmp = realloc(dtype->map, stype->map_count * sizeof(XkbKTMapEntryRec)); if (!tmp) @@ -1050,7 +1035,7 @@ _XkbCopyClientMap(XkbDescPtr src, XkbDescPtr dst) } else if (!dtype->map_count || !dtype->map || i >= dst->map->num_types) { - tmp = xalloc(stype->map_count * + tmp = malloc(stype->map_count * sizeof(XkbKTMapEntryRec)); if (!tmp) return FALSE; @@ -1062,7 +1047,7 @@ _XkbCopyClientMap(XkbDescPtr src, XkbDescPtr dst) } else { if (dtype->map && i < dst->map->num_types) - xfree(dtype->map); + free(dtype->map); dtype->map = NULL; } @@ -1070,7 +1055,7 @@ _XkbCopyClientMap(XkbDescPtr src, XkbDescPtr dst) if (stype->map_count != dtype->map_count && dtype->map_count && dtype->preserve && i < dst->map->num_types) { - tmp = xrealloc(dtype->preserve, + tmp = realloc(dtype->preserve, stype->map_count * sizeof(XkbModsRec)); if (!tmp) @@ -1079,7 +1064,7 @@ _XkbCopyClientMap(XkbDescPtr src, XkbDescPtr dst) } else if (!dtype->preserve || !dtype->map_count || i >= dst->map->num_types) { - tmp = xalloc(stype->map_count * + tmp = malloc(stype->map_count * sizeof(XkbModsRec)); if (!tmp) return FALSE; @@ -1091,7 +1076,7 @@ _XkbCopyClientMap(XkbDescPtr src, XkbDescPtr dst) } else { if (dtype->preserve && i < dst->map->num_types) - xfree(dtype->preserve); + free(dtype->preserve); dtype->preserve = NULL; } @@ -1099,10 +1084,8 @@ _XkbCopyClientMap(XkbDescPtr src, XkbDescPtr dst) } else { if (dtype->map_count && i < dst->map->num_types) { - if (dtype->map) - xfree(dtype->map); - if (dtype->preserve) - xfree(dtype->preserve); + free(dtype->map); + free(dtype->preserve); } dtype->map_count = 0; dtype->map = NULL; @@ -1117,26 +1100,22 @@ _XkbCopyClientMap(XkbDescPtr src, XkbDescPtr dst) if (dst->map->types) { for (i = 0, dtype = dst->map->types; i < dst->map->num_types; i++, dtype++) { - if (dtype->level_names) - xfree(dtype->level_names); + free(dtype->level_names); if (dtype->map && dtype->map_count) - xfree(dtype->map); + free(dtype->map); if (dtype->preserve && dtype->map_count) - xfree(dtype->preserve); + free(dtype->preserve); } - xfree(dst->map->types); - dst->map->types = NULL; } + free(dst->map->types); + dst->map->types = NULL; dst->map->num_types = 0; dst->map->size_types = 0; } if (src->map->modmap) { if (src->max_key_code != dst->max_key_code) { - if (dst->map->modmap) - tmp = xrealloc(dst->map->modmap, src->max_key_code + 1); - else - tmp = xalloc(src->max_key_code + 1); + tmp = realloc(dst->map->modmap, src->max_key_code + 1); if (!tmp) return FALSE; dst->map->modmap = tmp; @@ -1144,10 +1123,8 @@ _XkbCopyClientMap(XkbDescPtr src, XkbDescPtr dst) memcpy(dst->map->modmap, src->map->modmap, src->max_key_code + 1); } else { - if (dst->map->modmap) { - xfree(dst->map->modmap); - dst->map->modmap = NULL; - } + free(dst->map->modmap); + dst->map->modmap = NULL; } } else { @@ -1166,7 +1143,7 @@ _XkbCopyServerMap(XkbDescPtr src, XkbDescPtr dst) /* server map */ if (src->server) { if (!dst->server) { - tmp = xcalloc(1, sizeof(XkbServerMapRec)); + tmp = calloc(1, sizeof(XkbServerMapRec)); if (!tmp) return FALSE; dst->server = tmp; @@ -1174,10 +1151,7 @@ _XkbCopyServerMap(XkbDescPtr src, XkbDescPtr dst) if (src->server->explicit) { if (src->max_key_code != dst->max_key_code) { - if (dst->server->explicit) - tmp = xrealloc(dst->server->explicit, src->max_key_code + 1); - else - tmp = xalloc(src->max_key_code + 1); + tmp = realloc(dst->server->explicit, src->max_key_code + 1); if (!tmp) return FALSE; dst->server->explicit = tmp; @@ -1186,19 +1160,14 @@ _XkbCopyServerMap(XkbDescPtr src, XkbDescPtr dst) src->max_key_code + 1); } else { - if (dst->server->explicit) { - xfree(dst->server->explicit); - dst->server->explicit = NULL; - } + free(dst->server->explicit); + dst->server->explicit = NULL; } if (src->server->acts) { if (src->server->size_acts != dst->server->size_acts) { - if (dst->server->acts) - tmp = xrealloc(dst->server->acts, - src->server->size_acts * sizeof(XkbAction)); - else - tmp = xalloc(src->server->size_acts * sizeof(XkbAction)); + tmp = realloc(dst->server->acts, + src->server->size_acts * sizeof(XkbAction)); if (!tmp) return FALSE; dst->server->acts = tmp; @@ -1207,23 +1176,16 @@ _XkbCopyServerMap(XkbDescPtr src, XkbDescPtr dst) src->server->size_acts * sizeof(XkbAction)); } else { - if (dst->server->acts) { - xfree(dst->server->acts); - dst->server->acts = NULL; - } + free(dst->server->acts); + dst->server->acts = NULL; } dst->server->size_acts = src->server->size_acts; dst->server->num_acts = src->server->num_acts; if (src->server->key_acts) { if (src->max_key_code != dst->max_key_code) { - if (dst->server->key_acts) - tmp = xrealloc(dst->server->key_acts, - (src->max_key_code + 1) * - sizeof(unsigned short)); - else - tmp = xalloc((src->max_key_code + 1) * - sizeof(unsigned short)); + tmp = realloc(dst->server->key_acts, + (src->max_key_code + 1) * sizeof(unsigned short)); if (!tmp) return FALSE; dst->server->key_acts = tmp; @@ -1232,21 +1194,14 @@ _XkbCopyServerMap(XkbDescPtr src, XkbDescPtr dst) (src->max_key_code + 1) * sizeof(unsigned short)); } else { - if (dst->server->key_acts) { - xfree(dst->server->key_acts); - dst->server->key_acts = NULL; - } + free(dst->server->key_acts); + dst->server->key_acts = NULL; } if (src->server->behaviors) { if (src->max_key_code != dst->max_key_code) { - if (dst->server->behaviors) - tmp = xrealloc(dst->server->behaviors, - (src->max_key_code + 1) * - sizeof(XkbBehavior)); - else - tmp = xalloc((src->max_key_code + 1) * - sizeof(XkbBehavior)); + tmp = realloc(dst->server->behaviors, + (src->max_key_code + 1) * sizeof(XkbBehavior)); if (!tmp) return FALSE; dst->server->behaviors = tmp; @@ -1255,23 +1210,16 @@ _XkbCopyServerMap(XkbDescPtr src, XkbDescPtr dst) (src->max_key_code + 1) * sizeof(XkbBehavior)); } else { - if (dst->server->behaviors) { - xfree(dst->server->behaviors); - dst->server->behaviors = NULL; - } + free(dst->server->behaviors); + dst->server->behaviors = NULL; } memcpy(dst->server->vmods, src->server->vmods, XkbNumVirtualMods); if (src->server->vmodmap) { if (src->max_key_code != dst->max_key_code) { - if (dst->server->vmodmap) - tmp = xrealloc(dst->server->vmodmap, - (src->max_key_code + 1) * - sizeof(unsigned short)); - else - tmp = xalloc((src->max_key_code + 1) * - sizeof(unsigned short)); + tmp = realloc(dst->server->vmodmap, + (src->max_key_code + 1) * sizeof(unsigned short)); if (!tmp) return FALSE; dst->server->vmodmap = tmp; @@ -1280,10 +1228,8 @@ _XkbCopyServerMap(XkbDescPtr src, XkbDescPtr dst) (src->max_key_code + 1) * sizeof(unsigned short)); } else { - if (dst->server->vmodmap) { - xfree(dst->server->vmodmap); - dst->server->vmodmap = NULL; - } + free(dst->server->vmodmap); + dst->server->vmodmap = NULL; } } else { @@ -1302,19 +1248,15 @@ _XkbCopyNames(XkbDescPtr src, XkbDescPtr dst) /* names */ if (src->names) { if (!dst->names) { - dst->names = xcalloc(1, sizeof(XkbNamesRec)); + dst->names = calloc(1, sizeof(XkbNamesRec)); if (!dst->names) return FALSE; } if (src->names->keys) { if (src->max_key_code != dst->max_key_code) { - if (dst->names->keys) - tmp = xrealloc(dst->names->keys, (src->max_key_code + 1) * - sizeof(XkbKeyNameRec)); - else - tmp = xalloc((src->max_key_code + 1) * - sizeof(XkbKeyNameRec)); + tmp = realloc(dst->names->keys, + (src->max_key_code + 1) * sizeof(XkbKeyNameRec)); if (!tmp) return FALSE; dst->names->keys = tmp; @@ -1323,21 +1265,15 @@ _XkbCopyNames(XkbDescPtr src, XkbDescPtr dst) (src->max_key_code + 1) * sizeof(XkbKeyNameRec)); } else { - if (dst->names->keys) { - xfree(dst->names->keys); - dst->names->keys = NULL; - } + free(dst->names->keys); + dst->names->keys = NULL; } if (src->names->num_key_aliases) { if (src->names->num_key_aliases != dst->names->num_key_aliases) { - if (dst->names->key_aliases) - tmp = xrealloc(dst->names->key_aliases, - src->names->num_key_aliases * - sizeof(XkbKeyAliasRec)); - else - tmp = xalloc(src->names->num_key_aliases * - sizeof(XkbKeyAliasRec)); + tmp = realloc(dst->names->key_aliases, + src->names->num_key_aliases * + sizeof(XkbKeyAliasRec)); if (!tmp) return FALSE; dst->names->key_aliases = tmp; @@ -1346,20 +1282,15 @@ _XkbCopyNames(XkbDescPtr src, XkbDescPtr dst) src->names->num_key_aliases * sizeof(XkbKeyAliasRec)); } else { - if (dst->names->key_aliases) { - xfree(dst->names->key_aliases); - dst->names->key_aliases = NULL; - } + free(dst->names->key_aliases); + dst->names->key_aliases = NULL; } dst->names->num_key_aliases = src->names->num_key_aliases; if (src->names->num_rg) { if (src->names->num_rg != dst->names->num_rg) { - if (dst->names->radio_groups) - tmp = xrealloc(dst->names->radio_groups, - src->names->num_rg * sizeof(Atom)); - else - tmp = xalloc(src->names->num_rg * sizeof(Atom)); + tmp = realloc(dst->names->radio_groups, + src->names->num_rg * sizeof(Atom)); if (!tmp) return FALSE; dst->names->radio_groups = tmp; @@ -1368,8 +1299,7 @@ _XkbCopyNames(XkbDescPtr src, XkbDescPtr dst) src->names->num_rg * sizeof(Atom)); } else { - if (dst->names->radio_groups) - xfree(dst->names->radio_groups); + free(dst->names->radio_groups); } dst->names->num_rg = src->names->num_rg; @@ -1403,20 +1333,15 @@ _XkbCopyCompat(XkbDescPtr src, XkbDescPtr dst) /* compat */ if (src->compat) { if (!dst->compat) { - dst->compat = xcalloc(1, sizeof(XkbCompatMapRec)); + dst->compat = calloc(1, sizeof(XkbCompatMapRec)); if (!dst->compat) return FALSE; } if (src->compat->sym_interpret && src->compat->num_si) { if (src->compat->num_si != dst->compat->size_si) { - if (dst->compat->sym_interpret) - tmp = xrealloc(dst->compat->sym_interpret, - src->compat->num_si * - sizeof(XkbSymInterpretRec)); - else - tmp = xalloc(src->compat->num_si * - sizeof(XkbSymInterpretRec)); + tmp = realloc(dst->compat->sym_interpret, + src->compat->num_si * sizeof(XkbSymInterpretRec)); if (!tmp) return FALSE; dst->compat->sym_interpret = tmp; @@ -1429,7 +1354,7 @@ _XkbCopyCompat(XkbDescPtr src, XkbDescPtr dst) } else { if (dst->compat->sym_interpret && dst->compat->size_si) - xfree(dst->compat->sym_interpret); + free(dst->compat->sym_interpret); dst->compat->sym_interpret = NULL; dst->compat->num_si = 0; @@ -1463,7 +1388,7 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst) /* geometry */ if (src->geom) { if (!dst->geom) { - dst->geom = xcalloc(sizeof(XkbGeometryRec), 1); + dst->geom = calloc(sizeof(XkbGeometryRec), 1); if (!dst->geom) return FALSE; } @@ -1479,17 +1404,17 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst) dprop = dst->geom->properties + i; i < dst->geom->num_properties; i++, dprop++) { - xfree(dprop->name); - xfree(dprop->value); + free(dprop->name); + free(dprop->value); } } if (dst->geom->sz_properties) - tmp = xrealloc(dst->geom->properties, + tmp = realloc(dst->geom->properties, src->geom->num_properties * sizeof(XkbPropertyRec)); else - tmp = xalloc(src->geom->num_properties * + tmp = malloc(src->geom->num_properties * sizeof(XkbPropertyRec)); if (!tmp) return FALSE; @@ -1501,7 +1426,7 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst) dst->geom->sz_properties = src->geom->num_properties; if (dst->geom->sz_properties > dst->geom->num_properties) { - bzero(dst->geom->properties + dst->geom->num_properties, + memset(dst->geom->properties + dst->geom->num_properties, 0, (dst->geom->sz_properties - dst->geom->num_properties) * sizeof(XkbPropertyRec)); } @@ -1513,13 +1438,13 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst) i++, sprop++, dprop++) { if (i < dst->geom->num_properties) { if (strlen(sprop->name) != strlen(dprop->name)) { - tmp = xrealloc(dprop->name, strlen(sprop->name) + 1); + tmp = realloc(dprop->name, strlen(sprop->name) + 1); if (!tmp) return FALSE; dprop->name = tmp; } if (strlen(sprop->value) != strlen(dprop->value)) { - tmp = xrealloc(dprop->value, strlen(sprop->value) + 1); + tmp = realloc(dprop->value, strlen(sprop->value) + 1); if (!tmp) return FALSE; dprop->value = tmp; @@ -1541,10 +1466,10 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst) for (i = 0, dprop = dst->geom->properties; i < dst->geom->num_properties; i++, dprop++) { - xfree(dprop->name); - xfree(dprop->value); + free(dprop->name); + free(dprop->value); } - xfree(dst->geom->properties); + free(dst->geom->properties); dst->geom->properties = NULL; } @@ -1560,16 +1485,16 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst) dcolor = dst->geom->colors + i; i < dst->geom->num_colors; i++, dcolor++) { - xfree(dcolor->spec); + free(dcolor->spec); } } if (dst->geom->sz_colors) - tmp = xrealloc(dst->geom->colors, + tmp = realloc(dst->geom->colors, src->geom->num_colors * sizeof(XkbColorRec)); else - tmp = xalloc(src->geom->num_colors * + tmp = malloc(src->geom->num_colors * sizeof(XkbColorRec)); if (!tmp) return FALSE; @@ -1579,7 +1504,7 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst) dst->geom->sz_colors = src->geom->num_colors; if (dst->geom->sz_colors > dst->geom->num_colors) { - bzero(dst->geom->colors + dst->geom->num_colors, + memset(dst->geom->colors + dst->geom->num_colors, 0, (dst->geom->sz_colors - dst->geom->num_colors) * sizeof(XkbColorRec)); } @@ -1591,7 +1516,7 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst) i++, scolor++, dcolor++) { if (i < dst->geom->num_colors) { if (strlen(scolor->spec) != strlen(dcolor->spec)) { - tmp = xrealloc(dcolor->spec, strlen(scolor->spec) + 1); + tmp = realloc(dcolor->spec, strlen(scolor->spec) + 1); if (!tmp) return FALSE; dcolor->spec = tmp; @@ -1611,9 +1536,9 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst) for (i = 0, dcolor = dst->geom->colors; i < dst->geom->num_colors; i++, dcolor++) { - xfree(dcolor->spec); + free(dcolor->spec); } - xfree(dst->geom->colors); + free(dst->geom->colors); dst->geom->colors = NULL; } @@ -1631,11 +1556,11 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst) j < dshape->num_outlines; j++, doutline++) { if (doutline->sz_points) - xfree(doutline->points); + free(doutline->points); } if (dshape->sz_outlines) { - xfree(dshape->outlines); + free(dshape->outlines); dshape->outlines = NULL; } @@ -1645,7 +1570,7 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst) } if (src->geom->num_shapes) { - tmp = xcalloc(src->geom->num_shapes, sizeof(XkbShapeRec)); + tmp = calloc(src->geom->num_shapes, sizeof(XkbShapeRec)); if (!tmp) return FALSE; dst->geom->shapes = tmp; @@ -1654,7 +1579,7 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst) i < src->geom->num_shapes; i++, sshape++, dshape++) { if (sshape->num_outlines) { - tmp = xcalloc(sshape->num_outlines, sizeof(XkbOutlineRec)); + tmp = calloc(sshape->num_outlines, sizeof(XkbOutlineRec)); if (!tmp) return FALSE; dshape->outlines = tmp; @@ -1665,7 +1590,7 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst) j < sshape->num_outlines; j++, soutline++, doutline++) { if (soutline->num_points) { - tmp = xalloc(soutline->num_points * + tmp = malloc(soutline->num_points * sizeof(XkbPointRec)); if (!tmp) return FALSE; @@ -1721,7 +1646,7 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst) } else { if (dst->geom->sz_shapes) { - xfree(dst->geom->shapes); + free(dst->geom->shapes); } dst->geom->shapes = NULL; dst->geom->num_shapes = 0; @@ -1739,36 +1664,29 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst) j < dsection->num_rows; j++, drow++) { if (drow->num_keys) - xfree(drow->keys); + free(drow->keys); } if (dsection->num_rows) - xfree(dsection->rows); + free(dsection->rows); /* cut and waste from geom/doodad below. */ for (j = 0, ddoodad = dsection->doodads; j < dsection->num_doodads; j++, ddoodad++) { if (ddoodad->any.type == XkbTextDoodad) { - if (ddoodad->text.text) { - xfree(ddoodad->text.text); - ddoodad->text.text = NULL; - } - if (ddoodad->text.font) { - xfree(ddoodad->text.font); - ddoodad->text.font = NULL; - } + free(ddoodad->text.text); + ddoodad->text.text = NULL; + free(ddoodad->text.font); + ddoodad->text.font = NULL; } else if (ddoodad->any.type == XkbLogoDoodad) { - if (ddoodad->logo.logo_name) { - xfree(ddoodad->logo.logo_name); - ddoodad->logo.logo_name = NULL; - } + free(ddoodad->logo.logo_name); + ddoodad->logo.logo_name = NULL; } } - if (dsection->num_doodads) - xfree(dsection->doodads); + free(dsection->doodads); } dst->geom->num_sections = 0; @@ -1777,11 +1695,11 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst) if (src->geom->num_sections) { if (dst->geom->sz_sections) - tmp = xrealloc(dst->geom->sections, + tmp = realloc(dst->geom->sections, src->geom->num_sections * sizeof(XkbSectionRec)); else - tmp = xalloc(src->geom->num_sections * sizeof(XkbSectionRec)); + tmp = malloc(src->geom->num_sections * sizeof(XkbSectionRec)); if (!tmp) return FALSE; memset(tmp, 0, src->geom->num_sections * sizeof(XkbSectionRec)); @@ -1796,7 +1714,7 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst) i++, ssection++, dsection++) { *dsection = *ssection; if (ssection->num_rows) { - tmp = xcalloc(ssection->num_rows, sizeof(XkbRowRec)); + tmp = calloc(ssection->num_rows, sizeof(XkbRowRec)); if (!tmp) return FALSE; dsection->rows = tmp; @@ -1808,7 +1726,7 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst) j < ssection->num_rows; j++, srow++, drow++) { if (srow->num_keys) { - tmp = xalloc(srow->num_keys * sizeof(XkbKeyRec)); + tmp = malloc(srow->num_keys * sizeof(XkbKeyRec)); if (!tmp) return FALSE; drow->keys = tmp; @@ -1824,7 +1742,7 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst) } if (ssection->num_doodads) { - tmp = xcalloc(ssection->num_doodads, sizeof(XkbDoodadRec)); + tmp = calloc(ssection->num_doodads, sizeof(XkbDoodadRec)); if (!tmp) return FALSE; dsection->doodads = tmp; @@ -1843,15 +1761,15 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst) if (sdoodad->any.type == XkbTextDoodad) { if (sdoodad->text.text) ddoodad->text.text = - xstrdup(sdoodad->text.text); + strdup(sdoodad->text.text); if (sdoodad->text.font) ddoodad->text.font = - xstrdup(sdoodad->text.font); + strdup(sdoodad->text.font); } else if (sdoodad->any.type == XkbLogoDoodad) { if (sdoodad->logo.logo_name) ddoodad->logo.logo_name = - xstrdup(sdoodad->logo.logo_name); + strdup(sdoodad->logo.logo_name); } } dsection->overlays = NULL; @@ -1861,7 +1779,7 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst) } else { if (dst->geom->sz_sections) { - xfree(dst->geom->sections); + free(dst->geom->sections); } dst->geom->sections = NULL; @@ -1877,20 +1795,14 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst) i < dst->geom->num_doodads; i++, ddoodad++) { if (ddoodad->any.type == XkbTextDoodad) { - if (ddoodad->text.text) { - xfree(ddoodad->text.text); - ddoodad->text.text = NULL; - } - if (ddoodad->text.font) { - xfree(ddoodad->text.font); - ddoodad->text.font = NULL; - } + free(ddoodad->text.text); + ddoodad->text.text = NULL; + free(ddoodad->text.font); + ddoodad->text.font = NULL; } else if (ddoodad->any.type == XkbLogoDoodad) { - if (ddoodad->logo.logo_name) { - xfree(ddoodad->logo.logo_name); - ddoodad->logo.logo_name = NULL; - } + free(ddoodad->logo.logo_name); + ddoodad->logo.logo_name = NULL; } } dst->geom->num_doodads = 0; @@ -1899,11 +1811,11 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst) if (src->geom->num_doodads) { if (dst->geom->sz_doodads) - tmp = xrealloc(dst->geom->doodads, + tmp = realloc(dst->geom->doodads, src->geom->num_doodads * sizeof(XkbDoodadRec)); else - tmp = xalloc(src->geom->num_doodads * + tmp = malloc(src->geom->num_doodads * sizeof(XkbDoodadRec)); if (!tmp) return FALSE; @@ -1920,14 +1832,14 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst) memcpy(ddoodad , sdoodad, sizeof(XkbDoodadRec)); if (sdoodad->any.type == XkbTextDoodad) { if (sdoodad->text.text) - ddoodad->text.text = xstrdup(sdoodad->text.text); + ddoodad->text.text = strdup(sdoodad->text.text); if (sdoodad->text.font) - ddoodad->text.font = xstrdup(sdoodad->text.font); + ddoodad->text.font = strdup(sdoodad->text.font); } else if (sdoodad->any.type == XkbLogoDoodad) { if (sdoodad->logo.logo_name) ddoodad->logo.logo_name = - xstrdup(sdoodad->logo.logo_name); + strdup(sdoodad->logo.logo_name); } } @@ -1935,7 +1847,7 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst) } else { if (dst->geom->sz_doodads) { - xfree(dst->geom->doodads); + free(dst->geom->doodads); } dst->geom->doodads = NULL; @@ -1947,11 +1859,11 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst) if (src->geom->num_key_aliases) { if (src->geom->num_key_aliases != dst->geom->sz_key_aliases) { if (dst->geom->sz_key_aliases) - tmp = xrealloc(dst->geom->key_aliases, + tmp = realloc(dst->geom->key_aliases, src->geom->num_key_aliases * 2 * XkbKeyNameLength); else - tmp = xalloc(src->geom->num_key_aliases * + tmp = malloc(src->geom->num_key_aliases * 2 * XkbKeyNameLength); if (!tmp) return FALSE; @@ -1966,9 +1878,7 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst) dst->geom->num_key_aliases = dst->geom->sz_key_aliases; } else { - if (dst->geom->key_aliases) { - xfree(dst->geom->key_aliases); - } + free(dst->geom->key_aliases); dst->geom->key_aliases = NULL; dst->geom->num_key_aliases = 0; dst->geom->sz_key_aliases = 0; @@ -1977,14 +1887,14 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst) /* font */ if (src->geom->label_font) { if (!dst->geom->label_font) { - tmp = xalloc(strlen(src->geom->label_font) + 1); + tmp = malloc(strlen(src->geom->label_font) + 1); if (!tmp) return FALSE; dst->geom->label_font = tmp; } else if (strlen(src->geom->label_font) != strlen(dst->geom->label_font)) { - tmp = xrealloc(dst->geom->label_font, + tmp = realloc(dst->geom->label_font, strlen(src->geom->label_font) + 1); if (!tmp) return FALSE; @@ -1998,9 +1908,7 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst) dst->geom->base_color = &(dst->geom->colors[i]); } else { - if (dst->geom->label_font) { - xfree(dst->geom->label_font); - } + free(dst->geom->label_font); dst->geom->label_font = NULL; dst->geom->label_color = NULL; dst->geom->base_color = NULL; @@ -2028,17 +1936,15 @@ _XkbCopyIndicators(XkbDescPtr src, XkbDescPtr dst) /* indicators */ if (src->indicators) { if (!dst->indicators) { - dst->indicators = xalloc(sizeof(XkbIndicatorRec)); + dst->indicators = malloc(sizeof(XkbIndicatorRec)); if (!dst->indicators) return FALSE; } memcpy(dst->indicators, src->indicators, sizeof(XkbIndicatorRec)); } else { - if (dst->indicators) { - xfree(dst->indicators); - dst->indicators = NULL; - } + free(dst->indicators); + dst->indicators = NULL; } return TRUE; } @@ -2049,17 +1955,15 @@ _XkbCopyControls(XkbDescPtr src, XkbDescPtr dst) /* controls */ if (src->ctrls) { if (!dst->ctrls) { - dst->ctrls = xalloc(sizeof(XkbControlsRec)); + dst->ctrls = malloc(sizeof(XkbControlsRec)); if (!dst->ctrls) return FALSE; } memcpy(dst->ctrls, src->ctrls, sizeof(XkbControlsRec)); } else { - if (dst->ctrls) { - xfree(dst->ctrls); - dst->ctrls = NULL; - } + free(dst->ctrls); + dst->ctrls = NULL; } return TRUE; } @@ -2190,3 +2094,29 @@ XkbGetEffectiveGroup(XkbSrvInfoPtr xkbi, XkbStatePtr xkbState, CARD8 keycode) return effectiveGroup; } + +/* Merge the lockedPtrButtons from all attached SDs for the given master + * device into the MD's state. + */ +void +XkbMergeLockedPtrBtns(DeviceIntPtr master) +{ + DeviceIntPtr d = inputInfo.devices; + XkbSrvInfoPtr xkbi = NULL; + + if (!IsMaster(master)) + return; + + if (!master->key) + return; + + xkbi = master->key->xkbInfo; + xkbi->lockedPtrButtons = 0; + + for (; d; d = d->next) { + if (IsMaster(d) || GetMaster(d, MASTER_KEYBOARD) != master || !d->key) + continue; + + xkbi->lockedPtrButtons |= d->key->xkbInfo->lockedPtrButtons; + } +} |