Get rid of xkb_server_map Same as xkb_client_map which was removed before. Signed-off-by: Ran Benita <ran234@gmail.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517
diff --git a/src/alloc.c b/src/alloc.c
index d29c740..8b8fb2b 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -27,62 +27,6 @@
#include "alloc.h"
int
-XkbcAllocServerMap(struct xkb_keymap *keymap, unsigned which,
- unsigned nNewActions)
-{
- unsigned i;
- struct xkb_server_map * map;
-
- if (!keymap)
- return BadMatch;
-
- if (!keymap->server) {
- map = uTypedCalloc(1, struct xkb_server_map);
- if (!map)
- return BadAlloc;
-
- for (i = 0; i < XkbNumVirtualMods; i++)
- map->vmods[i] = XkbNoModifierMask;
-
- keymap->server = map;
- }
- else
- map = keymap->server;
-
- if (!which)
- return Success;
-
- if (!map->explicit) {
- i = keymap->max_key_code + 1;
- map->explicit = uTypedCalloc(i, unsigned char);
- if (!map->explicit)
- return BadAlloc;
- }
-
- if (nNewActions < 1)
- nNewActions = 1;
-
- darray_resize0(map->acts, darray_size(map->acts) + nNewActions + 1);
- darray_resize0(map->key_acts, keymap->max_key_code + 1);
-
- if (!map->behaviors) {
- i = keymap->max_key_code + 1;
- map->behaviors = uTypedCalloc(i, struct xkb_behavior);
- if (!map->behaviors)
- return BadAlloc;
- }
-
- if (!map->vmodmap) {
- i = keymap->max_key_code + 1;
- map->vmodmap = uTypedCalloc(i, uint32_t);
- if (!map->vmodmap)
- return BadAlloc;
- }
-
- return Success;
-}
-
-int
XkbcCopyKeyType(const struct xkb_key_type *from, struct xkb_key_type *into)
{
int i;
@@ -137,7 +81,7 @@ XkbcResizeKeyActions(struct xkb_keymap *keymap, xkb_keycode_t key,
size_t old_ndx, old_num_acts, new_ndx;
if (needed == 0) {
- darray_item(keymap->server->key_acts, key) = 0;
+ darray_item(keymap->key_acts, key) = 0;
return NULL;
}
@@ -152,20 +96,20 @@ XkbcResizeKeyActions(struct xkb_keymap *keymap, xkb_keycode_t key,
* space for the key at the end, and leave the old space alone.
*/
- old_ndx = darray_item(keymap->server->key_acts, key);
+ old_ndx = darray_item(keymap->key_acts, key);
old_num_acts = XkbKeyNumActions(keymap, key);
- new_ndx = darray_size(keymap->server->acts);
+ new_ndx = darray_size(keymap->acts);
- darray_resize0(keymap->server->acts, new_ndx + needed);
- darray_item(keymap->server->key_acts, key) = new_ndx;
+ darray_resize0(keymap->acts, new_ndx + needed);
+ darray_item(keymap->key_acts, key) = new_ndx;
/*
* The key was already in the array, copy the old actions to the
* new space.
*/
if (old_ndx != 0)
- memcpy(darray_mem(keymap->server->acts, new_ndx),
- darray_mem(keymap->server->acts, old_ndx),
+ memcpy(darray_mem(keymap->acts, new_ndx),
+ darray_mem(keymap->acts, old_ndx),
old_num_acts * sizeof(union xkb_action));
return XkbKeyActionsPtr(keymap, key);
@@ -201,25 +145,6 @@ free_sym_maps(struct xkb_keymap *keymap)
darray_free(keymap->key_sym_map);
}
-void
-XkbcFreeServerMap(struct xkb_keymap *keymap)
-{
- struct xkb_server_map * map;
-
- if (!keymap || !keymap->server)
- return;
-
- map = keymap->server;
-
- free(map->explicit);
- darray_free(map->key_acts);
- darray_free(map->acts);
- free(map->behaviors);
- free(map->vmodmap);
- free(keymap->server);
- keymap->server = NULL;
-}
-
int
XkbcAllocCompatMap(struct xkb_keymap *keymap, unsigned nSI)
{
@@ -407,7 +332,11 @@ XkbcFreeKeyboard(struct xkb_keymap *keymap)
free_types(keymap);
free_sym_maps(keymap);
free(keymap->modmap);
- XkbcFreeServerMap(keymap);
+ free(keymap->explicit);
+ darray_free(keymap->key_acts);
+ darray_free(keymap->acts);
+ free(keymap->behaviors);
+ free(keymap->vmodmap);
XkbcFreeCompatMap(keymap);
XkbcFreeIndicatorMaps(keymap);
XkbcFreeNames(keymap);
diff --git a/src/alloc.h b/src/alloc.h
index bea53cf..a933929 100644
--- a/src/alloc.h
+++ b/src/alloc.h
@@ -49,10 +49,6 @@ extern void
XkbcFreeKeyboard(struct xkb_keymap *keymap);
extern int
-XkbcAllocServerMap(struct xkb_keymap *keymap, unsigned which,
- unsigned nNewActions);
-
-extern int
XkbcCopyKeyType(const struct xkb_key_type *from, struct xkb_key_type *into);
extern bool
@@ -63,7 +59,4 @@ extern union xkb_action *
XkbcResizeKeyActions(struct xkb_keymap *keymap, xkb_keycode_t key,
uint32_t needed);
-extern void
-XkbcFreeServerMap(struct xkb_keymap *keymap);
-
#endif /* ALLOC_H */
diff --git a/src/keymap-dump.c b/src/keymap-dump.c
index 6870ca7..8443e7d 100644
--- a/src/keymap-dump.c
+++ b/src/keymap-dump.c
@@ -779,7 +779,6 @@ static bool
write_symbols(struct xkb_keymap *keymap, char **buf, size_t *size,
size_t *offset)
{
- struct xkb_server_map *srv = keymap->server;
xkb_keycode_t key;
int group, tmp;
bool showActions;
@@ -809,8 +808,8 @@ write_symbols(struct xkb_keymap *keymap, char **buf, size_t *size,
write_buf(keymap, buf, size, offset, "\t\tkey %6s {",
XkbcKeyNameText(darray_item(keymap->names->keys, key).name));
- if (srv->explicit) {
- if ((srv->explicit[key] & XkbExplicitKeyTypesMask)) {
+ if (keymap->explicit) {
+ if ((keymap->explicit[key] & XkbExplicitKeyTypesMask)) {
bool multi_type = false;
int type = XkbKeyTypeIndex(keymap, key, 0);
@@ -827,7 +826,7 @@ write_symbols(struct xkb_keymap *keymap, char **buf, size_t *size,
for (group = 0;
group < xkb_key_num_groups(keymap, key);
group++) {
- if (!(srv->explicit[key] & (1 << group)))
+ if (!(keymap->explicit[key] & (1 << group)))
continue;
type = XkbKeyTypeIndex(keymap, key, group);
write_buf(keymap, buf, size, offset,
@@ -843,7 +842,7 @@ write_symbols(struct xkb_keymap *keymap, char **buf, size_t *size,
}
}
if (keymap->ctrls &&
- (srv->explicit[key] & XkbExplicitAutoRepeatMask)) {
+ (keymap->explicit[key] & XkbExplicitAutoRepeatMask)) {
if (keymap->ctrls->per_key_repeat[key / 8] & (1 << (key % 8)))
write_buf(keymap, buf, size, offset,
"\n\t\t\trepeat= Yes,");
@@ -852,12 +851,11 @@ write_symbols(struct xkb_keymap *keymap, char **buf, size_t *size,
"\n\t\t\trepeat= No,");
simple = false;
}
- if (keymap->server->vmodmap[key] &&
- (srv->explicit[key] & XkbExplicitVModMapMask)) {
+ if (keymap->vmodmap[key] &&
+ (keymap->explicit[key] & XkbExplicitVModMapMask)) {
write_buf(keymap, buf, size, offset,
"\n\t\t\tvirtualMods= %s,",
- get_mod_mask_text(keymap, 0,
- keymap->server->vmodmap[key]));
+ get_mod_mask_text(keymap, 0, keymap->vmodmap[key]));
}
}
@@ -874,8 +872,8 @@ write_symbols(struct xkb_keymap *keymap, char **buf, size_t *size,
break;
}
- if (srv->explicit == NULL ||
- (srv->explicit[key] & XkbExplicitInterpretMask))
+ if (keymap->explicit == NULL ||
+ (keymap->explicit[key] & XkbExplicitInterpretMask))
showActions = XkbKeyHasActions(keymap, key);
else
showActions = false;
diff --git a/src/xkb-priv.h b/src/xkb-priv.h
index bb7410c..2072010 100644
--- a/src/xkb-priv.h
+++ b/src/xkb-priv.h
@@ -280,16 +280,6 @@ struct xkb_behavior {
unsigned char data;
};
-struct xkb_server_map {
- unsigned char * explicit;
-
- darray(union xkb_action) acts;
- darray(size_t) key_acts; /* acts[key_acts[keycode]] */
- struct xkb_behavior *behaviors;
- uint32_t vmods[XkbNumVirtualMods]; /* vmod -> mod mapping */
- uint32_t *vmodmap; /* key -> vmod mapping */
-};
-
struct xkb_indicator_map {
unsigned char flags;
unsigned char which_groups;
@@ -354,14 +344,29 @@ struct xkb_keymap {
xkb_keycode_t max_key_code;
struct xkb_controls * ctrls;
- struct xkb_server_map * server;
struct xkb_indicator * indicators;
struct xkb_names * names;
struct xkb_compat_map * compat;
+ /* key -> explicit flags mapping */
+ unsigned char *explicit;
+
darray(struct xkb_key_type) types;
+
darray(struct xkb_sym_map) key_sym_map;
+
+ /* key -> mod mapping */
unsigned char *modmap;
+ /* vmod -> mod mapping */
+ uint32_t vmods[XkbNumVirtualMods];
+ /* key -> vmod mapping */
+ uint32_t *vmodmap;
+
+ /* acts[key_acts[keycode]] */
+ darray(union xkb_action) acts;
+ darray(size_t ) key_acts;
+
+ struct xkb_behavior *behaviors;
};
#define XkbNumGroups(g) ((g) & 0x0f)
@@ -396,13 +401,13 @@ struct xkb_keymap {
#define XkbKeySymEntry(d, k, g, sl) \
(XkbKeySym(d, k, XkbKeySymOffset(d, k, g, sl)))
#define XkbKeyHasActions(d, k) \
- (darray_item((d)->server->key_acts, k) != 0)
+ (darray_item((d)->key_acts, k) != 0)
#define XkbKeyNumActions(d, k) \
(XkbKeyHasActions(d, k) ? \
(XkbKeyGroupsWidth(d, k) * XkbKeyNumGroups(d, k)) : \
1)
#define XkbKeyActionsPtr(d, k) \
- (darray_mem((d)->server->acts, darray_item((d)->server->key_acts, k)))
+ (darray_mem((d)->acts, darray_item((d)->key_acts, k)))
#define XkbKeyAction(d, k, n) \
(XkbKeyHasActions(d, k) ? &XkbKeyActionsPtr(d, k)[n] : NULL)
#define XkbKeyActionEntry(d, k, sl, g) \
diff --git a/src/xkbcomp/compat.c b/src/xkbcomp/compat.c
index ec743f2..c9cf637 100644
--- a/src/xkbcomp/compat.c
+++ b/src/xkbcomp/compat.c
@@ -794,7 +794,7 @@ VModsToReal(struct xkb_keymap *keymap, uint32_t vmodmask)
for (i = 0; i < XkbNumVirtualMods; i++) {
if (!(vmodmask & (1 << i)))
continue;
- ret |= keymap->server->vmods[i];
+ ret |= keymap->vmods[i];
}
return ret;
@@ -902,7 +902,7 @@ ApplyInterpsToKey(struct xkb_keymap *keymap, xkb_keycode_t key)
int i;
/* If we've been told not to bind interps to this key, then don't. */
- if (keymap->server->explicit[key] & XkbExplicitInterpretMask)
+ if (keymap->explicit[key] & XkbExplicitInterpretMask)
return true;
for (i = 0; i < INTERP_SIZE; i++)
@@ -936,14 +936,13 @@ ApplyInterpsToKey(struct xkb_keymap *keymap, xkb_keycode_t key)
/* Infer default key behaviours from the base level. */
if (group == 0 && level == 0) {
- if (!(keymap->server->explicit[key] &
- XkbExplicitAutoRepeatMask) &&
+ if (!(keymap->explicit[key] & XkbExplicitAutoRepeatMask) &&
(!interp || interp->flags & XkbSI_AutoRepeat))
- keymap->ctrls->per_key_repeat[key / 8] |= (1 << (key % 8));
- if (!(keymap->server->explicit[key] &
- XkbExplicitBehaviorMask) &&
+ keymap->ctrls->per_key_repeat[key / 8] |=
+ (1 << (key % 8));
+ if (!(keymap->explicit[key] & XkbExplicitBehaviorMask) &&
interp && (interp->flags & XkbSI_LockingKey))
- keymap->server->behaviors[key].type = XkbKB_Lock;
+ keymap->behaviors[key].type = XkbKB_Lock;
}
if (!interp)
@@ -958,8 +957,8 @@ ApplyInterpsToKey(struct xkb_keymap *keymap, xkb_keycode_t key)
}
}
- if (!(keymap->server->explicit[key] & XkbExplicitVModMapMask))
- keymap->server->vmodmap[key] = vmodmask;
+ if (!(keymap->explicit[key] & XkbExplicitVModMapMask))
+ keymap->vmodmap[key] = vmodmask;
return true;
#undef INTERP_SIZE
@@ -985,16 +984,16 @@ UpdateModifiersFromCompat(struct xkb_keymap *keymap)
if (!ApplyInterpsToKey(keymap, key))
return false;
- /* Update keymap->server->vmods, the virtual -> real mod mapping. */
+ /* Update keymap->vmods, the virtual -> real mod mapping. */
for (i = 0; i < XkbNumVirtualMods; i++)
- keymap->server->vmods[i] = 0;
+ keymap->vmods[i] = 0;
for (key = keymap->min_key_code; key <= keymap->max_key_code; key++) {
- if (!keymap->server->vmodmap[key])
+ if (!keymap->vmodmap[key])
continue;
for (i = 0; i < XkbNumVirtualMods; i++) {
- if (!(keymap->server->vmodmap[key] & (1 << i)))
+ if (!(keymap->vmodmap[key] & (1 << i)))
continue;
- keymap->server->vmods[i] |= keymap->modmap[key];
+ keymap->vmods[i] |= keymap->modmap[key];
}
}
@@ -1007,7 +1006,7 @@ UpdateModifiersFromCompat(struct xkb_keymap *keymap)
for (j = 0; j < XkbNumVirtualMods; j++) {
if (!(type->mods.vmods & (1 << j)))
continue;
- mask |= keymap->server->vmods[j];
+ mask |= keymap->vmods[j];
}
darray_foreach(entry, type->map)
diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c
index d1d6b0b..2ae0ebe 100644
--- a/src/xkbcomp/symbols.c
+++ b/src/xkbcomp/symbols.c
@@ -1739,7 +1739,7 @@ CopySymbolsDef(struct xkb_keymap *keymap, KeyInfo *key, int start_from)
}
if (FindNamedType(keymap, key->types[i], &types[i])) {
if (!autoType || key->numLevels[i] > 2)
- keymap->server->explicit[kc] |= (1 << i);
+ keymap->explicit[kc] |= (1 << i);
}
else {
if (warningLevel >= 3) {
@@ -1780,7 +1780,7 @@ CopySymbolsDef(struct xkb_keymap *keymap, KeyInfo *key, int start_from)
longText(key->name), kc);
return false;
}
- keymap->server->explicit[kc] |= XkbExplicitInterpretMask;
+ keymap->explicit[kc] |= XkbExplicitInterpretMask;
}
else
outActs = NULL;
@@ -1840,20 +1840,20 @@ CopySymbolsDef(struct xkb_keymap *keymap, KeyInfo *key, int start_from)
break;
default:
- keymap->server->behaviors[kc] = key->behavior;
- keymap->server->explicit[kc] |= XkbExplicitBehaviorMask;
+ keymap->behaviors[kc] = key->behavior;
+ keymap->explicit[kc] |= XkbExplicitBehaviorMask;
break;
}
if (key->defs.defined & _Key_VModMap) {
- keymap->server->vmodmap[kc] = key->vmodmap;
- keymap->server->explicit[kc] |= XkbExplicitVModMapMask;
+ keymap->vmodmap[kc] = key->vmodmap;
+ keymap->explicit[kc] |= XkbExplicitVModMapMask;
}
if (key->repeat != RepeatUndefined) {
if (key->repeat == RepeatYes)
keymap->ctrls->per_key_repeat[kc / 8] |= (1 << (kc % 8));
else
keymap->ctrls->per_key_repeat[kc / 8] &= ~(1 << (kc % 8));
- keymap->server->explicit[kc] |= XkbExplicitAutoRepeatMask;
+ keymap->explicit[kc] |= XkbExplicitAutoRepeatMask;
}
/* do the same thing for the next key */
@@ -1930,11 +1930,24 @@ CompileSymbols(XkbFile *file, struct xkb_keymap *keymap,
if (!keymap->modmap)
goto err_info;
- if (XkbcAllocServerMap(keymap, XkbAllServerInfoMask, 32) != Success) {
- WSGO("Could not allocate server map in CompileSymbols\n");
- ACTION("Symbols not added\n");
+ i = keymap->max_key_code + 1;
+ keymap->explicit = calloc(keymap->max_key_code + 1,
+ sizeof(*keymap->explicit));
+ if (!keymap->explicit)
+ goto err_info;
+
+ darray_resize0(keymap->acts, darray_size(keymap->acts) + 32 + 1);
+ darray_resize0(keymap->key_acts, keymap->max_key_code + 1);
+
+ keymap->behaviors = calloc(keymap->max_key_code + 1,
+ sizeof(*keymap->behaviors));
+ if (!keymap->behaviors)
+ goto err_info;
+
+ keymap->vmodmap = calloc(keymap->max_key_code + 1,
+ sizeof(*keymap->vmodmap));
+ if (!keymap->vmodmap)
goto err_info;
- }
if (XkbcAllocControls(keymap) != Success) {
WSGO("Could not allocate controls in CompileSymbols\n");
diff --git a/src/xkbcomp/vmod.c b/src/xkbcomp/vmod.c
index 2a90603..341f6be 100644
--- a/src/xkbcomp/vmod.c
+++ b/src/xkbcomp/vmod.c
@@ -43,8 +43,8 @@ ClearVModInfo(VModInfo *info, struct xkb_keymap *keymap)
if (XkbcAllocNames(keymap, 0, 0) != Success)
return;
- if (XkbcAllocServerMap(keymap, 0, 0) != Success)
- return;
+ for (i = 0; i < XkbNumVirtualMods; i++)
+ keymap->vmods[i] = XkbNoModifierMask;
info->keymap = keymap;
if (keymap && keymap->names) {
@@ -73,7 +73,6 @@ HandleVModDef(VModDef *stmt, struct xkb_keymap *keymap,
{
int i, bit, nextFree;
ExprResult mod;
- struct xkb_server_map *srv = keymap->server;
struct xkb_names *names = keymap->names;
for (i = 0, bit = 1, nextFree = -1; i < XkbNumVirtualMods; i++, bit <<=
@@ -94,19 +93,19 @@ HandleVModDef(VModDef *stmt, struct xkb_keymap *keymap,
ACTION("Declaration of %s ignored\n", str1);
return false;
}
- if (mod.uval == srv->vmods[i])
+ if (mod.uval == keymap->vmods[i])
return true;
str1 = xkb_atom_text(keymap->ctx, stmt->name);
WARN("Virtual modifier %s multiply defined\n", str1);
- str1 = XkbcModMaskText(srv->vmods[i], true);
+ str1 = XkbcModMaskText(keymap->vmods[i], true);
if (mergeMode == MERGE_OVERRIDE) {
str2 = str1;
str1 = XkbcModMaskText(mod.uval, true);
}
ACTION("Using %s, ignoring %s\n", str1, str2);
if (mergeMode == MERGE_OVERRIDE)
- srv->vmods[i] = mod.uval;
+ keymap->vmods[i] = mod.uval;
return true;
}
}
@@ -126,7 +125,7 @@ HandleVModDef(VModDef *stmt, struct xkb_keymap *keymap,
if (stmt->value == NULL)
return true;
if (ExprResolveModMask(keymap->ctx, stmt->value, &mod)) {
- srv->vmods[nextFree] = mod.uval;
+ keymap->vmods[nextFree] = mod.uval;
return true;
}
ACTION("Declaration of %s ignored\n",