2009-03-19 17:57:01 -06:00
|
|
|
/*
|
|
|
|
Copyright (c) 1993 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
|
|
|
|
documentation, and that the name of Silicon Graphics not be
|
|
|
|
used in advertising or publicity pertaining to distribution
|
|
|
|
of the software without specific prior written permission.
|
|
|
|
Silicon Graphics makes no representation about the suitability
|
|
|
|
of this software for any purpose. It is provided "as is"
|
|
|
|
without any express or implied warranty.
|
|
|
|
|
|
|
|
SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
|
|
|
|
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
|
|
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
|
|
|
|
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
|
|
|
|
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
|
|
|
|
THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2012-05-08 05:52:23 -06:00
|
|
|
#include "xkb-priv.h"
|
|
|
|
#include "alloc.h"
|
2012-04-10 17:02:45 -06:00
|
|
|
|
|
|
|
int
|
2012-05-09 08:15:30 -06:00
|
|
|
XkbcAllocClientMap(struct xkb_keymap *keymap, unsigned which,
|
2012-05-21 23:07:52 -06:00
|
|
|
size_t nTotalTypes)
|
2012-04-10 17:02:45 -06:00
|
|
|
{
|
2012-05-09 08:15:30 -06:00
|
|
|
if (!keymap || ((nTotalTypes > 0) && (nTotalTypes < XkbNumRequiredTypes)))
|
2012-04-10 17:02:45 -06:00
|
|
|
return BadValue;
|
|
|
|
|
2012-05-09 08:15:30 -06:00
|
|
|
if (!keymap->map) {
|
2012-05-21 23:07:52 -06:00
|
|
|
keymap->map = calloc(1, sizeof(*keymap->map));
|
|
|
|
if (!keymap->map)
|
2012-04-10 17:02:45 -06:00
|
|
|
return BadAlloc;
|
2012-05-21 23:07:52 -06:00
|
|
|
darray_init(keymap->map->types);
|
2012-04-10 17:02:45 -06:00
|
|
|
}
|
|
|
|
|
2012-05-21 23:07:52 -06:00
|
|
|
if (which & XkbKeyTypesMask)
|
|
|
|
darray_growalloc(keymap->map->types, nTotalTypes);
|
2012-04-10 17:02:45 -06:00
|
|
|
|
2012-05-22 06:20:47 -06:00
|
|
|
if (which & XkbKeySymsMask)
|
|
|
|
darray_resize0(keymap->map->key_sym_map, keymap->max_key_code + 1);
|
2012-04-10 17:02:45 -06:00
|
|
|
|
|
|
|
if (which & XkbModifierMapMask) {
|
2012-05-21 23:07:52 -06:00
|
|
|
if (!keymap->map->modmap) {
|
|
|
|
keymap->map->modmap = uTypedCalloc(keymap->max_key_code + 1,
|
|
|
|
unsigned char);
|
|
|
|
if (!keymap->map->modmap)
|
2012-04-10 17:02:45 -06:00
|
|
|
return BadAlloc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-05-09 08:15:30 -06:00
|
|
|
XkbcAllocServerMap(struct xkb_keymap *keymap, unsigned which,
|
|
|
|
unsigned nNewActions)
|
2012-04-10 17:02:45 -06:00
|
|
|
{
|
|
|
|
unsigned i;
|
|
|
|
struct xkb_server_map * map;
|
|
|
|
|
2012-05-09 08:15:30 -06:00
|
|
|
if (!keymap)
|
2012-04-10 17:02:45 -06:00
|
|
|
return BadMatch;
|
|
|
|
|
2012-05-09 08:15:30 -06:00
|
|
|
if (!keymap->server) {
|
2012-04-10 17:02:45 -06:00
|
|
|
map = uTypedCalloc(1, struct xkb_server_map);
|
|
|
|
if (!map)
|
|
|
|
return BadAlloc;
|
|
|
|
|
|
|
|
for (i = 0; i < XkbNumVirtualMods; i++)
|
|
|
|
map->vmods[i] = XkbNoModifierMask;
|
|
|
|
|
2012-05-09 08:15:30 -06:00
|
|
|
keymap->server = map;
|
2012-04-10 17:02:45 -06:00
|
|
|
}
|
|
|
|
else
|
2012-05-09 08:15:30 -06:00
|
|
|
map = keymap->server;
|
2012-04-10 17:02:45 -06:00
|
|
|
|
|
|
|
if (!which)
|
|
|
|
return Success;
|
|
|
|
|
|
|
|
if (!map->explicit) {
|
2012-05-09 08:15:30 -06:00
|
|
|
i = keymap->max_key_code + 1;
|
2012-04-10 17:02:45 -06:00
|
|
|
map->explicit = uTypedCalloc(i, unsigned char);
|
|
|
|
if (!map->explicit)
|
|
|
|
return BadAlloc;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nNewActions < 1)
|
|
|
|
nNewActions = 1;
|
|
|
|
|
2012-05-22 09:00:56 -06:00
|
|
|
darray_resize0(map->acts, darray_size(map->acts) + nNewActions + 1);
|
|
|
|
darray_resize0(map->key_acts, keymap->max_key_code + 1);
|
2012-04-10 17:02:45 -06:00
|
|
|
|
|
|
|
if (!map->behaviors) {
|
2012-05-09 08:15:30 -06:00
|
|
|
i = keymap->max_key_code + 1;
|
2012-04-10 17:02:45 -06:00
|
|
|
map->behaviors = uTypedCalloc(i, struct xkb_behavior);
|
|
|
|
if (!map->behaviors)
|
|
|
|
return BadAlloc;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!map->vmodmap) {
|
2012-05-09 08:15:30 -06:00
|
|
|
i = keymap->max_key_code + 1;
|
2012-04-10 17:02:45 -06:00
|
|
|
map->vmodmap = uTypedCalloc(i, uint32_t);
|
|
|
|
if (!map->vmodmap)
|
|
|
|
return BadAlloc;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-05-22 01:59:46 -06:00
|
|
|
XkbcCopyKeyType(const struct xkb_key_type *from, struct xkb_key_type *into)
|
2012-04-10 17:02:45 -06:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!from || !into)
|
|
|
|
return BadMatch;
|
|
|
|
|
2012-05-22 01:59:46 -06:00
|
|
|
darray_free(into->map);
|
2012-04-10 17:02:45 -06:00
|
|
|
free(into->preserve);
|
|
|
|
for (i = 0; i < into->num_levels; i++)
|
2012-06-08 00:25:38 -06:00
|
|
|
free(into->level_names[i]);
|
2012-04-10 17:02:45 -06:00
|
|
|
free(into->level_names);
|
|
|
|
|
|
|
|
*into = *from;
|
|
|
|
|
2012-05-22 01:59:46 -06:00
|
|
|
darray_init(into->map);
|
|
|
|
darray_from_items(into->map,
|
|
|
|
&darray_item(from->map, 0),
|
|
|
|
darray_size(from->map));
|
2012-04-10 17:02:45 -06:00
|
|
|
|
2012-05-22 01:59:46 -06:00
|
|
|
if (from->preserve && !darray_empty(into->map)) {
|
|
|
|
into->preserve = calloc(darray_size(into->map),
|
|
|
|
sizeof(*into->preserve));
|
2012-04-10 17:02:45 -06:00
|
|
|
if (!into->preserve)
|
|
|
|
return BadAlloc;
|
|
|
|
memcpy(into->preserve, from->preserve,
|
2012-05-22 01:59:46 -06:00
|
|
|
darray_size(into->map) * sizeof(*into->preserve));
|
2012-04-10 17:02:45 -06:00
|
|
|
}
|
|
|
|
|
2012-06-08 00:25:38 -06:00
|
|
|
if (from->level_names && into->num_levels > 0) {
|
|
|
|
into->level_names = calloc(into->num_levels,
|
|
|
|
sizeof(*into->level_names));
|
2012-04-10 17:02:45 -06:00
|
|
|
if (!into->level_names)
|
|
|
|
return BadAlloc;
|
2012-06-08 00:25:38 -06:00
|
|
|
|
2012-04-10 17:02:45 -06:00
|
|
|
for (i = 0; i < into->num_levels; i++)
|
|
|
|
into->level_names[i] = strdup(from->level_names[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2012-05-09 08:15:30 -06:00
|
|
|
XkbcResizeKeySyms(struct xkb_keymap *keymap, xkb_keycode_t key,
|
2012-04-10 17:02:45 -06:00
|
|
|
unsigned int needed)
|
|
|
|
{
|
2012-05-22 06:20:47 -06:00
|
|
|
struct xkb_sym_map *sym_map =
|
|
|
|
&darray_item(keymap->map->key_sym_map, key);
|
|
|
|
|
|
|
|
if (sym_map->size_syms >= needed)
|
2012-04-10 17:02:45 -06:00
|
|
|
return true;
|
|
|
|
|
2012-05-22 06:20:47 -06:00
|
|
|
sym_map->syms = uTypedRecalloc(sym_map->syms, sym_map->size_syms,
|
|
|
|
needed, xkb_keysym_t);
|
|
|
|
if (!sym_map->syms) {
|
|
|
|
sym_map->size_syms = 0;
|
2012-04-10 17:02:45 -06:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-05-22 06:20:47 -06:00
|
|
|
sym_map->size_syms = needed;
|
2012-04-10 17:02:45 -06:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
union xkb_action *
|
2012-05-09 08:15:30 -06:00
|
|
|
XkbcResizeKeyActions(struct xkb_keymap *keymap, xkb_keycode_t key,
|
|
|
|
uint32_t needed)
|
2012-04-10 17:02:45 -06:00
|
|
|
{
|
2012-05-22 09:00:56 -06:00
|
|
|
size_t old_ndx, old_num_acts, new_ndx;
|
2012-04-10 17:02:45 -06:00
|
|
|
|
|
|
|
if (needed == 0) {
|
2012-05-22 09:00:56 -06:00
|
|
|
darray_item(keymap->server->key_acts, key) = 0;
|
2012-04-10 17:02:45 -06:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-05-09 08:15:30 -06:00
|
|
|
if (XkbKeyHasActions(keymap, key) &&
|
2012-05-22 09:00:56 -06:00
|
|
|
XkbKeyGroupsWidth(keymap, key) >= needed)
|
2012-05-09 08:15:30 -06:00
|
|
|
return XkbKeyActionsPtr(keymap, key);
|
2012-04-10 17:02:45 -06:00
|
|
|
|
2012-05-22 09:00:56 -06:00
|
|
|
/*
|
|
|
|
* The key may already be in the array, but without enough space.
|
|
|
|
* This should not happen often, so in order to avoid moving and
|
|
|
|
* copying stuff from acts and key_acts, we just allocate new
|
|
|
|
* space for the key at the end, and leave the old space alone.
|
|
|
|
*/
|
|
|
|
|
|
|
|
old_ndx = darray_item(keymap->server->key_acts, key);
|
|
|
|
old_num_acts = XkbKeyNumActions(keymap, key);
|
|
|
|
new_ndx = darray_size(keymap->server->acts);
|
|
|
|
|
|
|
|
darray_resize0(keymap->server->acts, new_ndx + needed);
|
|
|
|
darray_item(keymap->server->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_item(keymap->server->acts, new_ndx),
|
|
|
|
&darray_item(keymap->server->acts, old_ndx),
|
|
|
|
old_num_acts * sizeof(union xkb_action));
|
|
|
|
|
|
|
|
return XkbKeyActionsPtr(keymap, key);
|
2012-04-10 17:02:45 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-05-09 08:15:30 -06:00
|
|
|
XkbcFreeClientMap(struct xkb_keymap *keymap)
|
2012-04-10 17:02:45 -06:00
|
|
|
{
|
|
|
|
struct xkb_client_map * map;
|
|
|
|
struct xkb_key_type * type;
|
2012-05-22 06:20:47 -06:00
|
|
|
struct xkb_sym_map *sym_map;
|
2012-04-10 17:02:45 -06:00
|
|
|
|
2012-05-09 08:15:30 -06:00
|
|
|
if (!keymap || !keymap->map)
|
2012-04-10 17:02:45 -06:00
|
|
|
return;
|
|
|
|
|
2012-05-09 08:15:30 -06:00
|
|
|
map = keymap->map;
|
2012-04-10 17:02:45 -06:00
|
|
|
|
2012-05-21 23:07:52 -06:00
|
|
|
darray_foreach(type, map->types) {
|
2012-04-10 17:02:45 -06:00
|
|
|
int j;
|
2012-05-22 01:59:46 -06:00
|
|
|
darray_free(type->map);
|
2012-04-10 17:02:45 -06:00
|
|
|
free(type->preserve);
|
|
|
|
for (j = 0; j < type->num_levels; j++)
|
2012-06-08 00:25:38 -06:00
|
|
|
free(type->level_names[j]);
|
2012-04-10 17:02:45 -06:00
|
|
|
free(type->level_names);
|
2012-06-08 00:25:38 -06:00
|
|
|
free(type->name);
|
2012-04-10 17:02:45 -06:00
|
|
|
}
|
2012-05-21 23:07:52 -06:00
|
|
|
darray_free(map->types);
|
2012-04-10 17:02:45 -06:00
|
|
|
|
2012-05-22 06:20:47 -06:00
|
|
|
darray_foreach(sym_map, map->key_sym_map) {
|
|
|
|
free(sym_map->sym_index);
|
|
|
|
free(sym_map->num_syms);
|
|
|
|
free(sym_map->syms);
|
2012-04-10 17:02:45 -06:00
|
|
|
}
|
2012-05-22 06:20:47 -06:00
|
|
|
darray_free(map->key_sym_map);
|
2012-04-10 17:02:45 -06:00
|
|
|
|
|
|
|
free(map->modmap);
|
2012-05-09 08:15:30 -06:00
|
|
|
free(keymap->map);
|
|
|
|
keymap->map = NULL;
|
2012-04-10 17:02:45 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-05-09 08:15:30 -06:00
|
|
|
XkbcFreeServerMap(struct xkb_keymap *keymap)
|
2012-04-10 17:02:45 -06:00
|
|
|
{
|
|
|
|
struct xkb_server_map * map;
|
|
|
|
|
2012-05-13 01:38:51 -06:00
|
|
|
if (!keymap || !keymap->server)
|
2012-04-10 17:02:45 -06:00
|
|
|
return;
|
|
|
|
|
2012-05-09 08:15:30 -06:00
|
|
|
map = keymap->server;
|
2012-04-10 17:02:45 -06:00
|
|
|
|
|
|
|
free(map->explicit);
|
2012-05-22 09:00:56 -06:00
|
|
|
darray_free(map->key_acts);
|
|
|
|
darray_free(map->acts);
|
2012-04-10 17:02:45 -06:00
|
|
|
free(map->behaviors);
|
|
|
|
free(map->vmodmap);
|
2012-05-09 08:15:30 -06:00
|
|
|
free(keymap->server);
|
|
|
|
keymap->server = NULL;
|
2012-04-10 17:02:45 -06:00
|
|
|
}
|
2009-03-19 17:57:01 -06:00
|
|
|
|
|
|
|
int
|
2012-05-09 08:15:30 -06:00
|
|
|
XkbcAllocCompatMap(struct xkb_keymap *keymap, unsigned nSI)
|
2009-03-19 17:57:01 -06:00
|
|
|
{
|
2012-05-09 08:15:30 -06:00
|
|
|
if (!keymap)
|
2009-03-25 16:41:21 -06:00
|
|
|
return BadMatch;
|
|
|
|
|
2012-05-21 15:52:28 -06:00
|
|
|
if (!keymap->compat) {
|
|
|
|
keymap->compat = calloc(1, sizeof(*keymap->compat));
|
|
|
|
if (!keymap->compat)
|
2009-03-25 16:41:21 -06:00
|
|
|
return BadAlloc;
|
2012-05-21 15:52:28 -06:00
|
|
|
darray_init(keymap->compat->sym_interpret);
|
2009-03-25 16:41:21 -06:00
|
|
|
}
|
|
|
|
|
2012-05-21 15:52:28 -06:00
|
|
|
darray_growalloc(keymap->compat->sym_interpret, nSI);
|
|
|
|
darray_resize(keymap->compat->sym_interpret, 0);
|
2009-03-25 16:41:21 -06:00
|
|
|
|
2012-05-21 15:52:28 -06:00
|
|
|
memset(keymap->compat->groups, 0,
|
|
|
|
XkbNumKbdGroups * sizeof(*keymap->compat->groups));
|
2009-03-25 16:41:21 -06:00
|
|
|
|
2009-03-19 17:57:01 -06:00
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-27 14:05:52 -06:00
|
|
|
static void
|
2012-05-09 08:15:30 -06:00
|
|
|
XkbcFreeCompatMap(struct xkb_keymap *keymap)
|
2009-03-19 17:57:01 -06:00
|
|
|
{
|
2012-05-09 08:15:30 -06:00
|
|
|
if (!keymap || !keymap->compat)
|
2009-03-25 16:41:21 -06:00
|
|
|
return;
|
|
|
|
|
2012-05-21 15:52:28 -06:00
|
|
|
darray_free(keymap->compat->sym_interpret);
|
|
|
|
free(keymap->compat);
|
2012-05-09 08:15:30 -06:00
|
|
|
keymap->compat = NULL;
|
2009-03-19 17:57:01 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-05-21 23:39:09 -06:00
|
|
|
XkbcAllocNames(struct xkb_keymap *keymap, unsigned which, size_t nTotalAliases)
|
2009-03-19 17:57:01 -06:00
|
|
|
{
|
2012-05-09 08:15:30 -06:00
|
|
|
if (!keymap)
|
2009-03-25 16:41:21 -06:00
|
|
|
return BadMatch;
|
|
|
|
|
2012-05-09 08:15:30 -06:00
|
|
|
if (!keymap->names) {
|
2012-05-21 23:39:09 -06:00
|
|
|
keymap->names = calloc(1, sizeof(*keymap->names));
|
2012-05-09 08:15:30 -06:00
|
|
|
if (!keymap->names)
|
2009-03-25 16:41:21 -06:00
|
|
|
return BadAlloc;
|
2012-05-21 23:39:09 -06:00
|
|
|
|
|
|
|
darray_init(keymap->names->keys);
|
|
|
|
darray_init(keymap->names->key_aliases);
|
2009-03-25 16:41:21 -06:00
|
|
|
}
|
|
|
|
|
2012-05-21 23:07:52 -06:00
|
|
|
if ((which & XkbKTLevelNamesMask) && keymap->map) {
|
2010-07-01 12:35:24 -06:00
|
|
|
struct xkb_key_type * type;
|
2009-03-25 16:41:21 -06:00
|
|
|
|
2012-05-21 23:07:52 -06:00
|
|
|
darray_foreach(type, keymap->map->types) {
|
2009-03-25 16:41:21 -06:00
|
|
|
if (!type->level_names) {
|
2012-06-08 00:25:38 -06:00
|
|
|
type->level_names = calloc(type->num_levels,
|
|
|
|
sizeof(*type->level_names));
|
2009-03-25 16:41:21 -06:00
|
|
|
if (!type->level_names)
|
|
|
|
return BadAlloc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-21 23:39:09 -06:00
|
|
|
if (which & XkbKeyNamesMask)
|
|
|
|
darray_resize0(keymap->names->keys, keymap->max_key_code + 1);
|
2009-03-25 16:41:21 -06:00
|
|
|
|
2012-05-21 23:39:09 -06:00
|
|
|
if (which & XkbKeyAliasesMask)
|
|
|
|
darray_resize0(keymap->names->key_aliases, nTotalAliases);
|
2009-03-25 16:41:21 -06:00
|
|
|
|
2009-03-19 17:57:01 -06:00
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
2010-09-27 14:05:52 -06:00
|
|
|
static void
|
2012-05-09 08:15:30 -06:00
|
|
|
XkbcFreeNames(struct xkb_keymap *keymap)
|
2009-03-19 17:57:01 -06:00
|
|
|
{
|
2010-07-01 12:35:24 -06:00
|
|
|
struct xkb_names * names;
|
2012-03-02 06:56:03 -07:00
|
|
|
struct xkb_client_map * map;
|
2012-05-21 23:07:52 -06:00
|
|
|
struct xkb_key_type *type;
|
2012-03-09 11:53:47 -07:00
|
|
|
int i;
|
2009-03-25 16:41:21 -06:00
|
|
|
|
2012-05-09 08:15:30 -06:00
|
|
|
if (!keymap || !keymap->names)
|
2009-03-25 16:41:21 -06:00
|
|
|
return;
|
2009-03-19 17:57:01 -06:00
|
|
|
|
2012-05-09 08:15:30 -06:00
|
|
|
names = keymap->names;
|
|
|
|
map = keymap->map;
|
2009-03-25 16:41:21 -06:00
|
|
|
|
2012-05-21 23:07:52 -06:00
|
|
|
if (map) {
|
|
|
|
darray_foreach(type, map->types) {
|
2012-03-09 11:53:47 -07:00
|
|
|
int j;
|
|
|
|
for (j = 0; j < type->num_levels; j++)
|
2012-06-08 00:25:38 -06:00
|
|
|
free(type->level_names[j]);
|
2012-03-02 06:56:03 -07:00
|
|
|
free(type->level_names);
|
|
|
|
type->level_names = NULL;
|
2009-03-25 16:41:21 -06:00
|
|
|
}
|
2009-03-19 17:57:01 -06:00
|
|
|
}
|
2009-03-25 16:41:21 -06:00
|
|
|
|
2012-03-09 11:53:47 -07:00
|
|
|
for (i = 0; i < XkbNumVirtualMods; i++)
|
2012-06-08 00:25:38 -06:00
|
|
|
free(names->vmods[i]);
|
2012-03-09 11:53:47 -07:00
|
|
|
for (i = 0; i < XkbNumIndicators; i++)
|
2012-06-08 00:25:38 -06:00
|
|
|
free(names->indicators[i]);
|
2012-03-09 11:53:47 -07:00
|
|
|
for (i = 0; i < XkbNumKbdGroups; i++)
|
2012-06-08 00:25:38 -06:00
|
|
|
free(names->groups[i]);
|
2012-03-09 11:53:47 -07:00
|
|
|
|
2012-05-21 23:39:09 -06:00
|
|
|
darray_free(names->keys);
|
|
|
|
darray_free(names->key_aliases);
|
2012-03-02 06:56:03 -07:00
|
|
|
free(names);
|
2012-05-09 08:15:30 -06:00
|
|
|
keymap->names = NULL;
|
2009-03-19 17:57:01 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-05-09 08:15:30 -06:00
|
|
|
XkbcAllocControls(struct xkb_keymap *keymap)
|
2009-03-19 17:57:01 -06:00
|
|
|
{
|
2012-05-09 08:15:30 -06:00
|
|
|
if (!keymap)
|
2009-03-25 16:41:21 -06:00
|
|
|
return BadMatch;
|
2009-03-19 17:57:01 -06:00
|
|
|
|
2012-05-09 08:15:30 -06:00
|
|
|
if (!keymap->ctrls) {
|
|
|
|
keymap->ctrls = uTypedCalloc(1, struct xkb_controls);
|
|
|
|
if (!keymap->ctrls)
|
2009-03-25 16:41:21 -06:00
|
|
|
return BadAlloc;
|
2009-03-19 17:57:01 -06:00
|
|
|
}
|
2009-03-25 16:41:21 -06:00
|
|
|
|
2012-05-09 08:15:30 -06:00
|
|
|
keymap->ctrls->per_key_repeat = uTypedCalloc(keymap->max_key_code >> 3,
|
|
|
|
unsigned char);
|
|
|
|
if (!keymap->ctrls->per_key_repeat)
|
2012-04-10 16:55:50 -06:00
|
|
|
return BadAlloc;
|
2012-02-15 07:34:08 -07:00
|
|
|
|
2009-03-19 17:57:01 -06:00
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
2010-09-27 14:05:52 -06:00
|
|
|
static void
|
2012-05-09 08:15:30 -06:00
|
|
|
XkbcFreeControls(struct xkb_keymap *keymap)
|
2009-03-19 17:57:01 -06:00
|
|
|
{
|
2012-05-09 08:15:30 -06:00
|
|
|
if (keymap && keymap->ctrls) {
|
|
|
|
free(keymap->ctrls->per_key_repeat);
|
|
|
|
free(keymap->ctrls);
|
|
|
|
keymap->ctrls = NULL;
|
2009-03-19 17:57:01 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-05-09 08:15:30 -06:00
|
|
|
XkbcAllocIndicatorMaps(struct xkb_keymap *keymap)
|
2009-03-19 17:57:01 -06:00
|
|
|
{
|
2012-05-09 08:15:30 -06:00
|
|
|
if (!keymap)
|
2009-03-25 16:41:21 -06:00
|
|
|
return BadMatch;
|
|
|
|
|
2012-05-09 08:15:30 -06:00
|
|
|
if (!keymap->indicators) {
|
|
|
|
keymap->indicators = uTypedCalloc(1, struct xkb_indicator);
|
|
|
|
if (!keymap->indicators)
|
2009-03-25 16:41:21 -06:00
|
|
|
return BadAlloc;
|
2009-03-19 17:57:01 -06:00
|
|
|
}
|
2009-03-25 16:41:21 -06:00
|
|
|
|
2009-03-19 17:57:01 -06:00
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
2010-09-27 14:05:52 -06:00
|
|
|
static void
|
2012-05-09 08:15:30 -06:00
|
|
|
XkbcFreeIndicatorMaps(struct xkb_keymap *keymap)
|
2009-03-19 17:57:01 -06:00
|
|
|
{
|
2012-05-09 08:15:30 -06:00
|
|
|
if (keymap) {
|
|
|
|
free(keymap->indicators);
|
|
|
|
keymap->indicators = NULL;
|
2009-03-19 17:57:01 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-03 08:14:16 -06:00
|
|
|
struct xkb_keymap *
|
2012-05-11 08:03:43 -06:00
|
|
|
XkbcAllocKeyboard(struct xkb_context *ctx)
|
2009-03-19 17:57:01 -06:00
|
|
|
{
|
2012-05-09 08:15:30 -06:00
|
|
|
struct xkb_keymap *keymap;
|
2009-03-19 17:57:01 -06:00
|
|
|
|
2012-05-09 08:15:30 -06:00
|
|
|
keymap = uTypedCalloc(1, struct xkb_keymap);
|
|
|
|
if (!keymap)
|
2012-03-27 10:22:35 -06:00
|
|
|
return NULL;
|
|
|
|
|
2012-05-09 08:15:30 -06:00
|
|
|
keymap->refcnt = 1;
|
2012-05-11 08:03:43 -06:00
|
|
|
keymap->ctx = xkb_context_ref(ctx);
|
2012-03-22 11:39:12 -06:00
|
|
|
|
2012-05-09 08:15:30 -06:00
|
|
|
return keymap;
|
2009-03-19 17:57:01 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-05-09 08:15:30 -06:00
|
|
|
XkbcFreeKeyboard(struct xkb_keymap *keymap)
|
2009-03-19 17:57:01 -06:00
|
|
|
{
|
2012-05-09 08:15:30 -06:00
|
|
|
if (!keymap)
|
2009-03-25 16:41:21 -06:00
|
|
|
return;
|
|
|
|
|
2012-05-09 08:15:30 -06:00
|
|
|
XkbcFreeClientMap(keymap);
|
|
|
|
XkbcFreeServerMap(keymap);
|
|
|
|
XkbcFreeCompatMap(keymap);
|
|
|
|
XkbcFreeIndicatorMaps(keymap);
|
|
|
|
XkbcFreeNames(keymap);
|
|
|
|
XkbcFreeControls(keymap);
|
2012-05-11 08:03:43 -06:00
|
|
|
xkb_context_unref(keymap->ctx);
|
2012-05-09 08:15:30 -06:00
|
|
|
free(keymap);
|
2009-03-19 17:57:01 -06:00
|
|
|
}
|