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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include <config.h>
|
|
|
|
#endif
|
2009-04-08 08:46:25 -06:00
|
|
|
#include "xkbgeom.h"
|
2009-03-05 19:20:15 -07:00
|
|
|
#include "X11/extensions/XKBcommon.h"
|
|
|
|
#include "XKBcommonint.h"
|
2009-03-19 17:57:01 -06:00
|
|
|
#include <X11/extensions/XKB.h>
|
|
|
|
|
|
|
|
static void
|
2009-03-25 16:41:21 -06:00
|
|
|
_XkbFreeGeomLeafElems(Bool freeAll, int first, int count,
|
|
|
|
unsigned short *num_inout, unsigned short *sz_inout,
|
|
|
|
char **elems, unsigned int elem_sz)
|
2009-03-19 17:57:01 -06:00
|
|
|
{
|
2009-03-25 16:41:21 -06:00
|
|
|
if (freeAll || !(*elems)) {
|
|
|
|
*num_inout = *sz_inout = 0;
|
|
|
|
if (*elems) {
|
2010-06-30 14:56:24 -06:00
|
|
|
free(*elems);
|
2009-03-25 16:41:21 -06:00
|
|
|
*elems = NULL;
|
|
|
|
}
|
|
|
|
return;
|
2009-03-19 17:57:01 -06:00
|
|
|
}
|
|
|
|
|
2009-03-25 16:41:21 -06:00
|
|
|
if ((first >= (*num_inout)) || (first < 0) || (count < 1))
|
|
|
|
return;
|
2009-03-19 17:57:01 -06:00
|
|
|
|
2009-03-25 16:41:21 -06:00
|
|
|
if (first + count >= (*num_inout))
|
|
|
|
/* truncating the array is easy */
|
|
|
|
(*num_inout) = first;
|
2009-03-19 17:57:01 -06:00
|
|
|
else {
|
2009-03-25 16:41:21 -06:00
|
|
|
char *ptr = *elems;
|
|
|
|
int extra = ((*num_inout) - first + count) * elem_sz;
|
|
|
|
|
|
|
|
if (extra > 0)
|
|
|
|
memmove(&ptr[first * elem_sz], &ptr[(first + count) * elem_sz],
|
|
|
|
extra);
|
|
|
|
|
|
|
|
(*num_inout) -= count;
|
2009-03-19 17:57:01 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-25 16:41:21 -06:00
|
|
|
typedef void (*ContentsClearFunc)(char *priv);
|
2009-03-19 17:57:01 -06:00
|
|
|
|
|
|
|
static void
|
2009-03-25 16:41:21 -06:00
|
|
|
_XkbFreeGeomNonLeafElems(Bool freeAll, int first, int count,
|
|
|
|
unsigned short *num_inout, unsigned short *sz_inout,
|
|
|
|
char **elems, unsigned int elem_sz,
|
|
|
|
ContentsClearFunc freeFunc)
|
2009-03-19 17:57:01 -06:00
|
|
|
{
|
2009-03-25 16:41:21 -06:00
|
|
|
int i;
|
|
|
|
char *ptr;
|
2009-03-19 17:57:01 -06:00
|
|
|
|
|
|
|
if (freeAll) {
|
2009-03-25 16:41:21 -06:00
|
|
|
first = 0;
|
|
|
|
count = *num_inout;
|
2009-03-19 17:57:01 -06:00
|
|
|
}
|
2009-03-25 16:41:21 -06:00
|
|
|
else if ((first >= (*num_inout)) || (first < 0) || (count < 1))
|
|
|
|
return;
|
|
|
|
else if (first + count > (*num_inout))
|
|
|
|
count = (*num_inout) - first;
|
|
|
|
|
|
|
|
if (!(*elems))
|
|
|
|
return;
|
2009-03-19 17:57:01 -06:00
|
|
|
|
|
|
|
if (freeFunc) {
|
2009-03-25 16:41:21 -06:00
|
|
|
ptr = *elems;
|
|
|
|
ptr += first * elem_sz;
|
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
(*freeFunc)(ptr);
|
|
|
|
ptr += elem_sz;
|
|
|
|
}
|
2009-03-19 17:57:01 -06:00
|
|
|
}
|
2009-03-25 16:41:21 -06:00
|
|
|
|
2009-03-19 17:57:01 -06:00
|
|
|
if (freeAll) {
|
2009-03-25 16:41:21 -06:00
|
|
|
*num_inout = *sz_inout = 0;
|
|
|
|
if (*elems) {
|
2010-06-30 14:56:24 -06:00
|
|
|
free(*elems);
|
2009-03-25 16:41:21 -06:00
|
|
|
*elems = NULL;
|
|
|
|
}
|
2009-03-19 17:57:01 -06:00
|
|
|
}
|
2009-03-25 16:41:21 -06:00
|
|
|
else if (first + count >= (*num_inout))
|
|
|
|
*num_inout = first;
|
2009-03-19 17:57:01 -06:00
|
|
|
else {
|
2009-03-25 16:41:21 -06:00
|
|
|
i = ((*num_inout) - first + count) * elem_sz;
|
|
|
|
ptr = *elems;
|
|
|
|
memmove(&ptr[first * elem_sz], &ptr[(first + count) * elem_sz], i);
|
|
|
|
(*num_inout) -= count;
|
2009-03-19 17:57:01 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_XkbClearProperty(char *prop_in)
|
|
|
|
{
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcPropertyPtr prop = (XkbcPropertyPtr)prop_in;
|
2009-03-19 17:57:01 -06:00
|
|
|
|
|
|
|
if (prop->name) {
|
2010-06-30 14:56:24 -06:00
|
|
|
free(prop->name);
|
2009-03-25 16:41:21 -06:00
|
|
|
prop->name = NULL;
|
2009-03-19 17:57:01 -06:00
|
|
|
}
|
|
|
|
if (prop->value) {
|
2010-06-30 14:56:24 -06:00
|
|
|
free(prop->value);
|
2009-03-25 16:41:21 -06:00
|
|
|
prop->value = NULL;
|
2009-03-19 17:57:01 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcFreeGeomProperties(XkbcGeometryPtr geom, int first, int count, Bool freeAll)
|
2009-03-19 17:57:01 -06:00
|
|
|
{
|
2009-03-25 16:41:21 -06:00
|
|
|
_XkbFreeGeomNonLeafElems(freeAll, first, count,
|
|
|
|
&geom->num_properties, &geom->sz_properties,
|
|
|
|
(char **)&geom->properties,
|
2010-06-21 07:28:34 -06:00
|
|
|
sizeof(XkbcPropertyRec),
|
2009-03-25 16:41:21 -06:00
|
|
|
_XkbClearProperty);
|
2009-03-19 17:57:01 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcFreeGeomKeyAliases(XkbcGeometryPtr geom, int first, int count, Bool freeAll)
|
2009-03-19 17:57:01 -06:00
|
|
|
{
|
2009-03-25 16:41:21 -06:00
|
|
|
_XkbFreeGeomLeafElems(freeAll, first, count,
|
|
|
|
&geom->num_key_aliases, &geom->sz_key_aliases,
|
|
|
|
(char **)&geom->key_aliases,
|
|
|
|
sizeof(XkbKeyAliasRec));
|
2009-03-19 17:57:01 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_XkbClearColor(char *color_in)
|
|
|
|
{
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcColorPtr color = (XkbcColorPtr)color_in;
|
2009-03-19 17:57:01 -06:00
|
|
|
|
|
|
|
if (color->spec)
|
2010-06-30 14:56:24 -06:00
|
|
|
free(color->spec);
|
2009-03-19 17:57:01 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcFreeGeomColors(XkbcGeometryPtr geom, int first, int count, Bool freeAll)
|
2009-03-19 17:57:01 -06:00
|
|
|
{
|
2009-03-25 16:41:21 -06:00
|
|
|
_XkbFreeGeomNonLeafElems(freeAll, first, count,
|
|
|
|
&geom->num_colors, &geom->sz_colors,
|
2010-06-21 07:28:34 -06:00
|
|
|
(char **)&geom->colors, sizeof(XkbcColorRec),
|
2009-03-25 16:41:21 -06:00
|
|
|
_XkbClearColor);
|
2009-03-19 17:57:01 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcFreeGeomPoints(XkbcOutlinePtr outline, int first, int count, Bool freeAll)
|
2009-03-19 17:57:01 -06:00
|
|
|
{
|
2009-03-25 16:41:21 -06:00
|
|
|
_XkbFreeGeomLeafElems(freeAll, first, count,
|
|
|
|
&outline->num_points, &outline->sz_points,
|
2010-06-21 07:28:34 -06:00
|
|
|
(char **)&outline->points, sizeof(XkbcPointRec));
|
2009-03-19 17:57:01 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_XkbClearOutline(char *outline_in)
|
|
|
|
{
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcOutlinePtr outline = (XkbcOutlinePtr)outline_in;
|
2009-03-19 17:57:01 -06:00
|
|
|
|
2009-03-25 16:41:21 -06:00
|
|
|
if (outline->points)
|
|
|
|
XkbcFreeGeomPoints(outline, 0, outline->num_points, True);
|
2009-03-19 17:57:01 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcFreeGeomOutlines(XkbcShapePtr shape, int first, int count, Bool freeAll)
|
2009-03-19 17:57:01 -06:00
|
|
|
{
|
2009-03-25 16:41:21 -06:00
|
|
|
_XkbFreeGeomNonLeafElems(freeAll, first, count,
|
|
|
|
&shape->num_outlines, &shape->sz_outlines,
|
2010-06-21 07:28:34 -06:00
|
|
|
(char **)&shape->outlines, sizeof(XkbcOutlineRec),
|
2009-03-25 16:41:21 -06:00
|
|
|
_XkbClearOutline);
|
2009-03-19 17:57:01 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_XkbClearShape(char *shape_in)
|
|
|
|
{
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcShapePtr shape = (XkbcShapePtr)shape_in;
|
2009-03-19 17:57:01 -06:00
|
|
|
|
|
|
|
if (shape->outlines)
|
2009-03-25 16:41:21 -06:00
|
|
|
XkbcFreeGeomOutlines(shape, 0, shape->num_outlines, True);
|
2009-03-19 17:57:01 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcFreeGeomShapes(XkbcGeometryPtr geom, int first, int count, Bool freeAll)
|
2009-03-19 17:57:01 -06:00
|
|
|
{
|
2009-03-25 16:41:21 -06:00
|
|
|
_XkbFreeGeomNonLeafElems(freeAll, first, count,
|
|
|
|
&geom->num_shapes, &geom->sz_shapes,
|
2010-06-21 07:28:34 -06:00
|
|
|
(char **)&geom->shapes, sizeof(XkbcShapeRec),
|
2009-03-25 16:41:21 -06:00
|
|
|
_XkbClearShape);
|
2009-03-19 17:57:01 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcFreeGeomOverlayKeys(XkbcOverlayRowPtr row, int first, int count,
|
2009-03-25 16:41:21 -06:00
|
|
|
Bool freeAll)
|
2009-03-19 17:57:01 -06:00
|
|
|
{
|
2009-03-25 16:41:21 -06:00
|
|
|
_XkbFreeGeomLeafElems(freeAll, first, count,
|
|
|
|
&row->num_keys, &row->sz_keys,
|
2010-06-21 07:28:34 -06:00
|
|
|
(char **)&row->keys, sizeof(XkbcOverlayKeyRec));
|
2009-03-19 17:57:01 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
_XkbClearOverlayRow(char *row_in)
|
|
|
|
{
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcOverlayRowPtr row = (XkbcOverlayRowPtr)row_in;
|
2009-03-19 17:57:01 -06:00
|
|
|
|
2009-03-25 16:41:21 -06:00
|
|
|
if (row->keys)
|
|
|
|
XkbcFreeGeomOverlayKeys(row, 0, row->num_keys, True);
|
2009-03-19 17:57:01 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcFreeGeomOverlayRows(XkbcOverlayPtr overlay, int first, int count,
|
2009-03-25 16:41:21 -06:00
|
|
|
Bool freeAll)
|
2009-03-19 17:57:01 -06:00
|
|
|
{
|
2009-03-25 16:41:21 -06:00
|
|
|
_XkbFreeGeomNonLeafElems(freeAll, first, count,
|
|
|
|
&overlay->num_rows, &overlay->sz_rows,
|
|
|
|
(char **)&overlay->rows,
|
2010-06-21 07:28:34 -06:00
|
|
|
sizeof(XkbcOverlayRowRec),
|
2009-03-25 16:41:21 -06:00
|
|
|
_XkbClearOverlayRow);
|
2009-03-19 17:57:01 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
_XkbClearOverlay(char *overlay_in)
|
|
|
|
{
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcOverlayPtr overlay = (XkbcOverlayPtr)overlay_in;
|
2009-03-19 17:57:01 -06:00
|
|
|
|
2009-03-25 16:41:21 -06:00
|
|
|
if (overlay->rows)
|
|
|
|
XkbcFreeGeomOverlayRows(overlay, 0, overlay->num_rows, True);
|
2009-03-19 17:57:01 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcFreeGeomOverlays(XkbcSectionPtr section, int first, int count, Bool freeAll)
|
2009-03-19 17:57:01 -06:00
|
|
|
{
|
2009-03-25 16:41:21 -06:00
|
|
|
_XkbFreeGeomNonLeafElems(freeAll, first, count,
|
|
|
|
§ion->num_overlays, §ion->sz_overlays,
|
|
|
|
(char **)§ion->overlays,
|
2010-06-21 07:28:34 -06:00
|
|
|
sizeof(XkbcOverlayRec),
|
2009-03-25 16:41:21 -06:00
|
|
|
_XkbClearOverlay);
|
2009-03-19 17:57:01 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcFreeGeomKeys(XkbcRowPtr row, int first, int count, Bool freeAll)
|
2009-03-19 17:57:01 -06:00
|
|
|
{
|
2009-03-25 16:41:21 -06:00
|
|
|
_XkbFreeGeomLeafElems(freeAll, first, count,
|
|
|
|
&row->num_keys, &row->sz_keys,
|
2010-06-21 07:28:34 -06:00
|
|
|
(char **)&row->keys, sizeof(XkbcKeyRec));
|
2009-03-19 17:57:01 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
_XkbClearRow(char *row_in)
|
|
|
|
{
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcRowPtr row = (XkbcRowPtr)row_in;
|
2009-03-19 17:57:01 -06:00
|
|
|
|
2009-03-25 16:41:21 -06:00
|
|
|
if (row->keys)
|
|
|
|
XkbcFreeGeomKeys(row, 0, row->num_keys, True);
|
2009-03-19 17:57:01 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcFreeGeomRows(XkbcSectionPtr section, int first, int count, Bool freeAll)
|
2009-03-19 17:57:01 -06:00
|
|
|
{
|
2009-03-25 16:41:21 -06:00
|
|
|
_XkbFreeGeomNonLeafElems(freeAll, first, count,
|
|
|
|
§ion->num_rows, §ion->sz_rows,
|
2010-06-21 07:28:34 -06:00
|
|
|
(char **)§ion->rows, sizeof(XkbcRowRec),
|
2009-03-25 16:41:21 -06:00
|
|
|
_XkbClearRow);
|
2009-03-19 17:57:01 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
_XkbClearSection(char *section_in)
|
|
|
|
{
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcSectionPtr section = (XkbcSectionPtr)section_in;
|
2009-03-19 17:57:01 -06:00
|
|
|
|
2009-03-25 16:41:21 -06:00
|
|
|
if (section->rows)
|
|
|
|
XkbcFreeGeomRows(section, 0, section->num_rows, True);
|
|
|
|
if (section->doodads) {
|
|
|
|
XkbcFreeGeomDoodads(section->doodads, section->num_doodads, True);
|
|
|
|
section->doodads = NULL;
|
2009-03-19 17:57:01 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcFreeGeomSections(XkbcGeometryPtr geom, int first, int count, Bool freeAll)
|
2009-03-19 17:57:01 -06:00
|
|
|
{
|
2009-03-25 16:41:21 -06:00
|
|
|
_XkbFreeGeomNonLeafElems(freeAll, first, count,
|
|
|
|
&geom->num_sections, &geom->sz_sections,
|
2010-06-21 07:28:34 -06:00
|
|
|
(char **)&geom->sections, sizeof(XkbcSectionRec),
|
2009-03-25 16:41:21 -06:00
|
|
|
_XkbClearSection);
|
2009-03-19 17:57:01 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
_XkbClearDoodad(char *doodad_in)
|
|
|
|
{
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcDoodadPtr doodad = (XkbcDoodadPtr)doodad_in;
|
2009-03-19 17:57:01 -06:00
|
|
|
|
|
|
|
switch (doodad->any.type) {
|
2009-03-25 16:41:21 -06:00
|
|
|
case XkbTextDoodad:
|
|
|
|
if (doodad->text.text) {
|
2010-06-30 14:56:24 -06:00
|
|
|
free(doodad->text.text);
|
2009-03-25 16:41:21 -06:00
|
|
|
doodad->text.text = NULL;
|
|
|
|
}
|
|
|
|
if (doodad->text.font) {
|
2010-06-30 14:56:24 -06:00
|
|
|
free(doodad->text.font);
|
2009-03-25 16:41:21 -06:00
|
|
|
doodad->text.font = NULL;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case XkbLogoDoodad:
|
|
|
|
if (doodad->logo.logo_name) {
|
2010-06-30 14:56:24 -06:00
|
|
|
free(doodad->logo.logo_name);
|
2009-03-25 16:41:21 -06:00
|
|
|
doodad->logo.logo_name = NULL;
|
|
|
|
}
|
|
|
|
break;
|
2009-03-19 17:57:01 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcFreeGeomDoodads(XkbcDoodadPtr doodads, int nDoodads, Bool freeAll)
|
2009-03-19 17:57:01 -06:00
|
|
|
{
|
2009-03-25 16:41:21 -06:00
|
|
|
int i;
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcDoodadPtr doodad;
|
2009-03-19 17:57:01 -06:00
|
|
|
|
|
|
|
if (doodads) {
|
2009-03-25 16:41:21 -06:00
|
|
|
for (i = 0, doodad = doodads; i < nDoodads; i++, doodad++)
|
|
|
|
_XkbClearDoodad((char *)doodad);
|
|
|
|
if (freeAll)
|
2010-06-30 14:56:24 -06:00
|
|
|
free(doodads);
|
2009-03-19 17:57:01 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcFreeGeometry(XkbcGeometryPtr geom, unsigned which, Bool freeMap)
|
2009-03-19 17:57:01 -06:00
|
|
|
{
|
2009-03-25 16:41:21 -06:00
|
|
|
if (!geom)
|
|
|
|
return;
|
|
|
|
|
2009-03-19 17:57:01 -06:00
|
|
|
if (freeMap)
|
2009-03-25 16:41:21 -06:00
|
|
|
which = XkbGeomAllMask;
|
|
|
|
|
|
|
|
if ((which & XkbGeomPropertiesMask) && geom->properties)
|
|
|
|
XkbcFreeGeomProperties(geom, 0, geom->num_properties, True);
|
|
|
|
|
|
|
|
if ((which & XkbGeomColorsMask) && geom->colors)
|
|
|
|
XkbcFreeGeomColors(geom, 0, geom->num_colors, True);
|
|
|
|
|
|
|
|
if ((which & XkbGeomShapesMask) && geom->shapes)
|
|
|
|
XkbcFreeGeomShapes(geom, 0, geom->num_shapes, True);
|
|
|
|
|
|
|
|
if ((which & XkbGeomSectionsMask) && geom->sections)
|
|
|
|
XkbcFreeGeomSections(geom, 0, geom->num_sections, True);
|
|
|
|
|
|
|
|
if ((which & XkbGeomDoodadsMask) && geom->doodads) {
|
|
|
|
XkbcFreeGeomDoodads(geom->doodads, geom->num_doodads, True);
|
|
|
|
geom->doodads = NULL;
|
|
|
|
geom->num_doodads = geom->sz_doodads = 0;
|
2009-03-19 17:57:01 -06:00
|
|
|
}
|
2009-03-25 16:41:21 -06:00
|
|
|
|
|
|
|
if ((which & XkbGeomKeyAliasesMask) && geom->key_aliases)
|
|
|
|
XkbcFreeGeomKeyAliases(geom, 0, geom->num_key_aliases, True);
|
|
|
|
|
2009-03-19 17:57:01 -06:00
|
|
|
if (freeMap) {
|
2009-03-25 16:41:21 -06:00
|
|
|
if (geom->label_font) {
|
2010-06-30 14:56:24 -06:00
|
|
|
free(geom->label_font);
|
2009-03-25 16:41:21 -06:00
|
|
|
geom->label_font = NULL;
|
|
|
|
}
|
2010-06-30 14:56:24 -06:00
|
|
|
free(geom);
|
2009-03-19 17:57:01 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2009-03-25 16:41:21 -06:00
|
|
|
_XkbGeomAlloc(char **old, unsigned short *num, unsigned short *total,
|
|
|
|
int num_new, size_t sz_elem)
|
2009-03-19 17:57:01 -06:00
|
|
|
{
|
2009-03-25 16:41:21 -06:00
|
|
|
if (num_new < 1)
|
|
|
|
return Success;
|
|
|
|
|
|
|
|
if (!(*old))
|
|
|
|
*num = *total = 0;
|
|
|
|
|
|
|
|
if ((*num) + num_new <= (*total))
|
|
|
|
return Success;
|
|
|
|
|
|
|
|
*total = (*num) + num_new;
|
|
|
|
|
|
|
|
if (*old)
|
2010-06-30 14:56:24 -06:00
|
|
|
*old = (char *)realloc(*old, (*total) * sz_elem);
|
2009-03-25 16:41:21 -06:00
|
|
|
else
|
2010-06-30 14:56:24 -06:00
|
|
|
*old = (char *)calloc(*total, sz_elem);
|
2009-03-25 16:41:21 -06:00
|
|
|
if (!(*old)) {
|
|
|
|
*total = *num = 0;
|
|
|
|
return BadAlloc;
|
2009-03-19 17:57:01 -06:00
|
|
|
}
|
|
|
|
|
2009-03-25 16:41:21 -06:00
|
|
|
if (*num > 0) {
|
|
|
|
char *tmp = *old;
|
|
|
|
bzero(&tmp[sz_elem * (*num)], num_new * sz_elem);
|
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;
|
|
|
|
}
|
|
|
|
|
2009-03-25 16:41:21 -06:00
|
|
|
#define _XkbAllocProps(g, n) _XkbGeomAlloc((char **)&(g)->properties, \
|
|
|
|
&(g)->num_properties, \
|
|
|
|
&(g)->sz_properties, \
|
2010-06-21 07:28:34 -06:00
|
|
|
(n), sizeof(XkbcPropertyRec))
|
2009-03-25 16:41:21 -06:00
|
|
|
#define _XkbAllocColors(g, n) _XkbGeomAlloc((char **)&(g)->colors, \
|
|
|
|
&(g)->num_colors, \
|
|
|
|
&(g)->sz_colors, \
|
2010-06-21 07:28:34 -06:00
|
|
|
(n), sizeof(XkbcColorRec))
|
2009-03-25 16:41:21 -06:00
|
|
|
#define _XkbAllocShapes(g, n) _XkbGeomAlloc((char **)&(g)->shapes, \
|
|
|
|
&(g)->num_shapes, \
|
|
|
|
&(g)->sz_shapes, \
|
2010-06-21 07:28:34 -06:00
|
|
|
(n), sizeof(XkbcShapeRec))
|
2009-03-25 16:41:21 -06:00
|
|
|
#define _XkbAllocSections(g, n) _XkbGeomAlloc((char **)&(g)->sections, \
|
|
|
|
&(g)->num_sections, \
|
|
|
|
&(g)->sz_sections, \
|
2010-06-21 07:28:34 -06:00
|
|
|
(n), sizeof(XkbcSectionRec))
|
2009-03-25 16:41:21 -06:00
|
|
|
#define _XkbAllocDoodads(g, n) _XkbGeomAlloc((char **)&(g)->doodads, \
|
|
|
|
&(g)->num_doodads, \
|
|
|
|
&(g)->sz_doodads, \
|
2010-06-21 07:28:34 -06:00
|
|
|
(n), sizeof(XkbcDoodadRec))
|
2009-03-25 16:41:21 -06:00
|
|
|
#define _XkbAllocKeyAliases(g, n) _XkbGeomAlloc((char **)&(g)->key_aliases, \
|
|
|
|
&(g)->num_key_aliases, \
|
|
|
|
&(g)->sz_key_aliases, \
|
|
|
|
(n), sizeof(XkbKeyAliasRec))
|
|
|
|
|
|
|
|
#define _XkbAllocOutlines(s, n) _XkbGeomAlloc((char **)&(s)->outlines, \
|
|
|
|
&(s)->num_outlines, \
|
|
|
|
&(s)->sz_outlines, \
|
2010-06-21 07:28:34 -06:00
|
|
|
(n), sizeof(XkbcOutlineRec))
|
2009-03-25 16:41:21 -06:00
|
|
|
#define _XkbAllocRows(s, n) _XkbGeomAlloc((char **)&(s)->rows, \
|
|
|
|
&(s)->num_rows, \
|
|
|
|
&(s)->sz_rows, \
|
2010-06-21 07:28:34 -06:00
|
|
|
(n), sizeof(XkbcRowRec))
|
2009-03-25 16:41:21 -06:00
|
|
|
#define _XkbAllocPoints(o, n) _XkbGeomAlloc((char **)&(o)->points, \
|
|
|
|
&(o)->num_points, \
|
|
|
|
&(o)->sz_points, \
|
2010-06-21 07:28:34 -06:00
|
|
|
(n), sizeof(XkbcPointRec))
|
2009-03-25 16:41:21 -06:00
|
|
|
#define _XkbAllocKeys(r, n) _XkbGeomAlloc((char **)&(r)->keys, \
|
|
|
|
&(r)->num_keys, \
|
|
|
|
&(r)->sz_keys, \
|
2010-06-21 07:28:34 -06:00
|
|
|
(n), sizeof(XkbcKeyRec))
|
2009-03-25 16:41:21 -06:00
|
|
|
#define _XkbAllocOverlays(s, n) _XkbGeomAlloc((char **)&(s)->overlays, \
|
|
|
|
&(s)->num_overlays, \
|
|
|
|
&(s)->sz_overlays, \
|
2010-06-21 07:28:34 -06:00
|
|
|
(n), sizeof(XkbcOverlayRec))
|
2009-03-25 16:41:21 -06:00
|
|
|
#define _XkbAllocOverlayRows(o, n) _XkbGeomAlloc((char **)&(o)->rows, \
|
|
|
|
&(o)->num_rows, \
|
|
|
|
&(o)->sz_rows, \
|
2010-06-21 07:28:34 -06:00
|
|
|
(n), sizeof(XkbcOverlayRowRec))
|
2009-03-25 16:41:21 -06:00
|
|
|
#define _XkbAllocOverlayKeys(r, n) _XkbGeomAlloc((char **)&(r)->keys, \
|
|
|
|
&(r)->num_keys, \
|
|
|
|
&(r)->sz_keys, \
|
2010-06-21 07:28:34 -06:00
|
|
|
(n), sizeof(XkbcOverlayKeyRec))
|
2009-03-19 17:57:01 -06:00
|
|
|
|
2009-03-28 12:56:35 -06:00
|
|
|
int
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcAllocGeomProps(XkbcGeometryPtr geom, int nProps)
|
2009-03-28 12:56:35 -06:00
|
|
|
{
|
|
|
|
return _XkbAllocProps(geom, nProps);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcAllocGeomColors(XkbcGeometryPtr geom, int nColors)
|
2009-03-28 12:56:35 -06:00
|
|
|
{
|
|
|
|
return _XkbAllocColors(geom, nColors);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcAllocGeomKeyAliases(XkbcGeometryPtr geom, int nKeyAliases)
|
2009-03-28 12:56:35 -06:00
|
|
|
{
|
|
|
|
return _XkbAllocKeyAliases(geom, nKeyAliases);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcAllocGeomShapes(XkbcGeometryPtr geom, int nShapes)
|
2009-03-28 12:56:35 -06:00
|
|
|
{
|
|
|
|
return _XkbAllocShapes(geom, nShapes);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcAllocGeomSections(XkbcGeometryPtr geom, int nSections)
|
2009-03-28 12:56:35 -06:00
|
|
|
{
|
|
|
|
return _XkbAllocSections(geom, nSections);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcAllocGeomOverlays(XkbcSectionPtr section, int nOverlays)
|
2009-03-28 12:56:35 -06:00
|
|
|
{
|
|
|
|
return _XkbAllocOverlays(section, nOverlays);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcAllocGeomOverlayRows(XkbcOverlayPtr overlay, int nRows)
|
2009-03-28 12:56:35 -06:00
|
|
|
{
|
|
|
|
return _XkbAllocOverlayRows(overlay, nRows);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcAllocGeomOverlayKeys(XkbcOverlayRowPtr row, int nKeys)
|
2009-03-28 12:56:35 -06:00
|
|
|
{
|
|
|
|
return _XkbAllocOverlayKeys(row, nKeys);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcAllocGeomDoodads(XkbcGeometryPtr geom, int nDoodads)
|
2009-03-28 12:56:35 -06:00
|
|
|
{
|
|
|
|
return _XkbAllocDoodads(geom, nDoodads);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcAllocGeomSectionDoodads(XkbcSectionPtr section, int nDoodads)
|
2009-03-28 12:56:35 -06:00
|
|
|
{
|
|
|
|
return _XkbAllocDoodads(section, nDoodads);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcAllocGeomOutlines(XkbcShapePtr shape, int nOL)
|
2009-03-28 12:56:35 -06:00
|
|
|
{
|
|
|
|
return _XkbAllocOutlines(shape, nOL);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcAllocGeomRows(XkbcSectionPtr section, int nRows)
|
2009-03-28 12:56:35 -06:00
|
|
|
{
|
|
|
|
return _XkbAllocRows(section, nRows);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcAllocGeomPoints(XkbcOutlinePtr ol, int nPts)
|
2009-03-28 12:56:35 -06:00
|
|
|
{
|
|
|
|
return _XkbAllocPoints(ol, nPts);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcAllocGeomKeys(XkbcRowPtr row, int nKeys)
|
2009-03-28 12:56:35 -06:00
|
|
|
{
|
2010-06-16 22:56:08 -06:00
|
|
|
int ret = _XkbAllocKeys(row, nKeys);
|
|
|
|
fprintf(stderr, "!!! allocated %d keys at %p\n", nKeys, row->keys);
|
|
|
|
return ret;
|
2009-03-28 12:56:35 -06:00
|
|
|
}
|
|
|
|
|
2009-03-19 17:57:01 -06:00
|
|
|
int
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcAllocGeometry(XkbcDescPtr xkb, XkbcGeometrySizesPtr sizes)
|
2009-03-19 17:57:01 -06:00
|
|
|
{
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcGeometryPtr geom;
|
2009-03-25 16:41:21 -06:00
|
|
|
int rtrn;
|
2009-03-19 17:57:01 -06:00
|
|
|
|
2009-03-25 16:41:21 -06:00
|
|
|
if (!xkb->geom) {
|
2010-06-21 07:28:34 -06:00
|
|
|
xkb->geom = _XkbTypedCalloc(1, XkbcGeometryRec);
|
2009-03-25 16:41:21 -06:00
|
|
|
if (!xkb->geom)
|
|
|
|
return BadAlloc;
|
2009-03-19 17:57:01 -06:00
|
|
|
}
|
2009-03-25 16:41:21 -06:00
|
|
|
geom = xkb->geom;
|
|
|
|
|
|
|
|
if ((sizes->which & XkbGeomPropertiesMask) &&
|
|
|
|
((rtrn = _XkbAllocProps(geom, sizes->num_properties)) != Success))
|
|
|
|
goto bail;
|
|
|
|
|
|
|
|
if ((sizes->which & XkbGeomColorsMask) &&
|
|
|
|
((rtrn = _XkbAllocColors(geom, sizes->num_colors)) != Success))
|
|
|
|
goto bail;
|
|
|
|
|
|
|
|
if ((sizes->which & XkbGeomShapesMask) &&
|
|
|
|
((rtrn = _XkbAllocShapes(geom, sizes->num_shapes)) != Success))
|
|
|
|
goto bail;
|
|
|
|
|
|
|
|
if ((sizes->which & XkbGeomSectionsMask) &&
|
|
|
|
((rtrn = _XkbAllocSections(geom, sizes->num_sections)) != Success))
|
|
|
|
goto bail;
|
|
|
|
|
|
|
|
if ((sizes->which & XkbGeomDoodadsMask) &&
|
|
|
|
((rtrn = _XkbAllocDoodads(geom, sizes->num_doodads)) != Success))
|
|
|
|
goto bail;
|
|
|
|
|
|
|
|
if ((sizes->which & XkbGeomKeyAliasesMask) &&
|
|
|
|
((rtrn = _XkbAllocKeyAliases(geom, sizes->num_key_aliases)) != Success))
|
|
|
|
goto bail;
|
|
|
|
|
2009-03-19 17:57:01 -06:00
|
|
|
return Success;
|
2009-03-25 16:41:21 -06:00
|
|
|
bail:
|
|
|
|
XkbcFreeGeometry(geom, XkbGeomAllMask, True);
|
|
|
|
xkb->geom = NULL;
|
2009-03-19 17:57:01 -06:00
|
|
|
return rtrn;
|
|
|
|
}
|
2009-03-28 13:39:21 -06:00
|
|
|
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcPropertyPtr
|
|
|
|
XkbcAddGeomProperty(XkbcGeometryPtr geom,char *name,char *value)
|
2009-03-28 13:39:21 -06:00
|
|
|
{
|
|
|
|
register int i;
|
2010-06-21 07:28:34 -06:00
|
|
|
register XkbcPropertyPtr prop;
|
2009-03-28 13:39:21 -06:00
|
|
|
|
|
|
|
if ((!geom)||(!name)||(!value))
|
|
|
|
return NULL;
|
|
|
|
for (i=0,prop=geom->properties;i<geom->num_properties;i++,prop++) {
|
|
|
|
if ((prop->name)&&(strcmp(name,prop->name)==0)) {
|
|
|
|
if (prop->value)
|
2010-06-30 14:56:24 -06:00
|
|
|
free(prop->value);
|
|
|
|
prop->value= (char *)malloc(strlen(value)+1);
|
2009-03-28 13:39:21 -06:00
|
|
|
if (prop->value)
|
|
|
|
strcpy(prop->value,value);
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((geom->num_properties>=geom->sz_properties)&&
|
|
|
|
(_XkbAllocProps(geom,1)!=Success)) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
prop= &geom->properties[geom->num_properties];
|
2010-06-30 14:56:24 -06:00
|
|
|
prop->name= (char *)malloc(strlen(name)+1);
|
2009-03-28 13:39:21 -06:00
|
|
|
if (!name)
|
|
|
|
return NULL;
|
|
|
|
strcpy(prop->name,name);
|
2010-06-30 14:56:24 -06:00
|
|
|
prop->value= (char *)malloc(strlen(value)+1);
|
2009-03-28 13:39:21 -06:00
|
|
|
if (!value) {
|
2010-06-30 14:56:24 -06:00
|
|
|
free(prop->name);
|
2009-03-28 13:39:21 -06:00
|
|
|
prop->name= NULL;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
strcpy(prop->value,value);
|
|
|
|
geom->num_properties++;
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
|
|
|
XkbKeyAliasPtr
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcAddGeomKeyAlias(XkbcGeometryPtr geom,char *aliasStr,char *realStr)
|
2009-03-28 13:39:21 -06:00
|
|
|
{
|
|
|
|
register int i;
|
|
|
|
register XkbKeyAliasPtr alias;
|
|
|
|
|
|
|
|
if ((!geom)||(!aliasStr)||(!realStr)||(!aliasStr[0])||(!realStr[0]))
|
|
|
|
return NULL;
|
|
|
|
for (i=0,alias=geom->key_aliases;i<geom->num_key_aliases;i++,alias++) {
|
|
|
|
if (strncmp(alias->alias,aliasStr,XkbKeyNameLength)==0) {
|
|
|
|
bzero(alias->real,XkbKeyNameLength);
|
|
|
|
strncpy(alias->real,realStr,XkbKeyNameLength);
|
|
|
|
return alias;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((geom->num_key_aliases>=geom->sz_key_aliases)&&
|
|
|
|
(_XkbAllocKeyAliases(geom,1)!=Success)) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
alias= &geom->key_aliases[geom->num_key_aliases];
|
|
|
|
bzero(alias,sizeof(XkbKeyAliasRec));
|
|
|
|
strncpy(alias->alias,aliasStr,XkbKeyNameLength);
|
|
|
|
strncpy(alias->real,realStr,XkbKeyNameLength);
|
|
|
|
geom->num_key_aliases++;
|
|
|
|
return alias;
|
|
|
|
}
|
|
|
|
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcColorPtr
|
|
|
|
XkbcAddGeomColor(XkbcGeometryPtr geom,char *spec,unsigned int pixel)
|
2009-03-28 13:39:21 -06:00
|
|
|
{
|
|
|
|
register int i;
|
2010-06-21 07:28:34 -06:00
|
|
|
register XkbcColorPtr color;
|
2009-03-28 13:39:21 -06:00
|
|
|
|
|
|
|
if ((!geom)||(!spec))
|
|
|
|
return NULL;
|
|
|
|
for (i=0,color=geom->colors;i<geom->num_colors;i++,color++) {
|
|
|
|
if ((color->spec)&&(strcmp(color->spec,spec)==0)) {
|
|
|
|
color->pixel= pixel;
|
|
|
|
return color;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((geom->num_colors>=geom->sz_colors)&&
|
|
|
|
(_XkbAllocColors(geom,1)!=Success)) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
color= &geom->colors[geom->num_colors];
|
|
|
|
color->pixel= pixel;
|
2010-06-30 14:56:24 -06:00
|
|
|
color->spec= (char *)malloc(strlen(spec)+1);
|
2009-03-28 13:39:21 -06:00
|
|
|
if (!color->spec)
|
|
|
|
return NULL;
|
|
|
|
strcpy(color->spec,spec);
|
|
|
|
geom->num_colors++;
|
|
|
|
return color;
|
|
|
|
}
|
|
|
|
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcOutlinePtr
|
|
|
|
XkbcAddGeomOutline(XkbcShapePtr shape,int sz_points)
|
2009-03-28 13:39:21 -06:00
|
|
|
{
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcOutlinePtr outline;
|
2009-03-28 13:39:21 -06:00
|
|
|
|
|
|
|
if ((!shape)||(sz_points<0))
|
|
|
|
return NULL;
|
|
|
|
if ((shape->num_outlines>=shape->sz_outlines)&&
|
|
|
|
(_XkbAllocOutlines(shape,1)!=Success)) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
outline= &shape->outlines[shape->num_outlines];
|
2010-06-21 07:28:34 -06:00
|
|
|
bzero(outline,sizeof(XkbcOutlineRec));
|
2009-03-28 13:39:21 -06:00
|
|
|
if ((sz_points>0)&&(_XkbAllocPoints(outline,sz_points)!=Success))
|
|
|
|
return NULL;
|
|
|
|
shape->num_outlines++;
|
|
|
|
return outline;
|
|
|
|
}
|
|
|
|
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcShapePtr
|
2010-06-28 04:50:12 -06:00
|
|
|
XkbcAddGeomShape(XkbcGeometryPtr geom,uint32_t name,int sz_outlines)
|
2009-03-28 13:39:21 -06:00
|
|
|
{
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcShapePtr shape;
|
2009-03-28 13:39:21 -06:00
|
|
|
register int i;
|
|
|
|
|
|
|
|
if ((!geom)||(!name)||(sz_outlines<0))
|
|
|
|
return NULL;
|
|
|
|
if (geom->num_shapes>0) {
|
|
|
|
for (shape=geom->shapes,i=0;i<geom->num_shapes;i++,shape++) {
|
|
|
|
if (name==shape->name)
|
|
|
|
return shape;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((geom->num_shapes>=geom->sz_shapes)&&
|
|
|
|
(_XkbAllocShapes(geom,1)!=Success))
|
|
|
|
return NULL;
|
|
|
|
shape= &geom->shapes[geom->num_shapes];
|
2010-06-21 07:28:34 -06:00
|
|
|
bzero(shape,sizeof(XkbcShapeRec));
|
2009-03-28 13:39:21 -06:00
|
|
|
if ((sz_outlines>0)&&(_XkbAllocOutlines(shape,sz_outlines)!=Success))
|
|
|
|
return NULL;
|
|
|
|
shape->name= name;
|
|
|
|
shape->primary= shape->approx= NULL;
|
|
|
|
geom->num_shapes++;
|
|
|
|
return shape;
|
|
|
|
}
|
|
|
|
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcKeyPtr
|
|
|
|
XkbcAddGeomKey(XkbcRowPtr row)
|
2009-03-28 13:39:21 -06:00
|
|
|
{
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcKeyPtr key;
|
2009-03-28 13:39:21 -06:00
|
|
|
if (!row)
|
|
|
|
return NULL;
|
|
|
|
if ((row->num_keys>=row->sz_keys)&&(_XkbAllocKeys(row,1)!=Success))
|
|
|
|
return NULL;
|
|
|
|
key= &row->keys[row->num_keys++];
|
2010-06-21 07:28:34 -06:00
|
|
|
bzero(key,sizeof(XkbcKeyRec));
|
2009-03-28 13:39:21 -06:00
|
|
|
return key;
|
|
|
|
}
|
|
|
|
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcRowPtr
|
|
|
|
XkbcAddGeomRow(XkbcSectionPtr section,int sz_keys)
|
2009-03-28 13:39:21 -06:00
|
|
|
{
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcRowPtr row;
|
2009-03-28 13:39:21 -06:00
|
|
|
|
|
|
|
if ((!section)||(sz_keys<0))
|
|
|
|
return NULL;
|
|
|
|
if ((section->num_rows>=section->sz_rows)&&
|
|
|
|
(_XkbAllocRows(section,1)!=Success))
|
|
|
|
return NULL;
|
|
|
|
row= §ion->rows[section->num_rows];
|
2010-06-21 07:28:34 -06:00
|
|
|
bzero(row,sizeof(XkbcRowRec));
|
2009-03-28 13:39:21 -06:00
|
|
|
if ((sz_keys>0)&&(_XkbAllocKeys(row,sz_keys)!=Success))
|
|
|
|
return NULL;
|
|
|
|
section->num_rows++;
|
|
|
|
return row;
|
|
|
|
}
|
|
|
|
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcSectionPtr
|
|
|
|
XkbcAddGeomSection( XkbcGeometryPtr geom,
|
2010-06-28 04:50:12 -06:00
|
|
|
uint32_t name,
|
2009-03-28 13:39:21 -06:00
|
|
|
int sz_rows,
|
|
|
|
int sz_doodads,
|
|
|
|
int sz_over)
|
|
|
|
{
|
|
|
|
register int i;
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcSectionPtr section;
|
2009-03-28 13:39:21 -06:00
|
|
|
|
|
|
|
if ((!geom)||(name==None)||(sz_rows<0))
|
|
|
|
return NULL;
|
|
|
|
for (i=0,section=geom->sections;i<geom->num_sections;i++,section++) {
|
|
|
|
if (section->name!=name)
|
|
|
|
continue;
|
|
|
|
if (((sz_rows>0)&&(_XkbAllocRows(section,sz_rows)!=Success))||
|
|
|
|
((sz_doodads>0)&&(_XkbAllocDoodads(section,sz_doodads)!=Success))||
|
|
|
|
((sz_over>0)&&(_XkbAllocOverlays(section,sz_over)!=Success)))
|
|
|
|
return NULL;
|
|
|
|
return section;
|
|
|
|
}
|
|
|
|
if ((geom->num_sections>=geom->sz_sections)&&
|
|
|
|
(_XkbAllocSections(geom,1)!=Success))
|
|
|
|
return NULL;
|
|
|
|
section= &geom->sections[geom->num_sections];
|
|
|
|
if ((sz_rows>0)&&(_XkbAllocRows(section,sz_rows)!=Success))
|
|
|
|
return NULL;
|
|
|
|
if ((sz_doodads>0)&&(_XkbAllocDoodads(section,sz_doodads)!=Success)) {
|
|
|
|
if (section->rows) {
|
2010-06-30 14:56:24 -06:00
|
|
|
free(section->rows);
|
2009-03-28 13:39:21 -06:00
|
|
|
section->rows= NULL;
|
|
|
|
section->sz_rows= section->num_rows= 0;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
section->name= name;
|
|
|
|
geom->num_sections++;
|
|
|
|
return section;
|
|
|
|
}
|
|
|
|
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcDoodadPtr
|
2010-06-28 04:50:12 -06:00
|
|
|
XkbcAddGeomDoodad(XkbcGeometryPtr geom,XkbcSectionPtr section,uint32_t name)
|
2009-03-28 13:39:21 -06:00
|
|
|
{
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcDoodadPtr old,doodad;
|
2009-03-28 13:39:21 -06:00
|
|
|
register int i,nDoodads;
|
|
|
|
|
|
|
|
if ((!geom)||(name==None))
|
|
|
|
return NULL;
|
|
|
|
if ((section!=NULL)&&(section->num_doodads>0)) {
|
|
|
|
old= section->doodads;
|
|
|
|
nDoodads= section->num_doodads;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
old= geom->doodads;
|
|
|
|
nDoodads= geom->num_doodads;
|
|
|
|
}
|
|
|
|
for (i=0,doodad=old;i<nDoodads;i++,doodad++) {
|
|
|
|
if (doodad->any.name==name)
|
|
|
|
return doodad;
|
|
|
|
}
|
|
|
|
if (section) {
|
|
|
|
if ((section->num_doodads>=geom->sz_doodads)&&
|
|
|
|
(_XkbAllocDoodads(section,1)!=Success)) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
doodad= §ion->doodads[section->num_doodads++];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if ((geom->num_doodads>=geom->sz_doodads)&&
|
|
|
|
(_XkbAllocDoodads(geom,1)!=Success))
|
|
|
|
return NULL;
|
|
|
|
doodad= &geom->doodads[geom->num_doodads++];
|
|
|
|
}
|
2010-06-21 07:28:34 -06:00
|
|
|
bzero(doodad,sizeof(XkbcDoodadRec));
|
2009-03-28 13:39:21 -06:00
|
|
|
doodad->any.name= name;
|
|
|
|
return doodad;
|
|
|
|
}
|
|
|
|
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcOverlayKeyPtr
|
|
|
|
XkbcAddGeomOverlayKey( XkbcOverlayPtr overlay,
|
|
|
|
XkbcOverlayRowPtr row,
|
2009-03-28 13:39:21 -06:00
|
|
|
char * over,
|
|
|
|
char * under)
|
|
|
|
{
|
|
|
|
register int i;
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcOverlayKeyPtr key;
|
|
|
|
XkbcSectionPtr section;
|
|
|
|
XkbcRowPtr row_under;
|
2009-03-28 13:39:21 -06:00
|
|
|
Bool found;
|
|
|
|
|
|
|
|
if ((!overlay)||(!row)||(!over)||(!under))
|
|
|
|
return NULL;
|
|
|
|
section= overlay->section_under;
|
|
|
|
if (row->row_under>=section->num_rows)
|
|
|
|
return NULL;
|
|
|
|
row_under= §ion->rows[row->row_under];
|
|
|
|
for (i=0,found=False;i<row_under->num_keys;i++) {
|
|
|
|
if (strncmp(under,row_under->keys[i].name.name,XkbKeyNameLength)==0) {
|
|
|
|
found= True;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!found)
|
|
|
|
return NULL;
|
|
|
|
if ((row->num_keys>=row->sz_keys)&&(_XkbAllocOverlayKeys(row,1)!=Success))
|
|
|
|
return NULL;
|
|
|
|
key= &row->keys[row->num_keys];
|
|
|
|
strncpy(key->under.name,under,XkbKeyNameLength);
|
|
|
|
strncpy(key->over.name,over,XkbKeyNameLength);
|
|
|
|
row->num_keys++;
|
|
|
|
return key;
|
|
|
|
}
|
|
|
|
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcOverlayRowPtr
|
|
|
|
XkbcAddGeomOverlayRow(XkbcOverlayPtr overlay,int row_under,int sz_keys)
|
2009-03-28 13:39:21 -06:00
|
|
|
{
|
|
|
|
register int i;
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcOverlayRowPtr row;
|
2009-03-28 13:39:21 -06:00
|
|
|
|
|
|
|
if ((!overlay)||(sz_keys<0))
|
|
|
|
return NULL;
|
|
|
|
if (row_under>=overlay->section_under->num_rows)
|
|
|
|
return NULL;
|
|
|
|
for (i=0;i<overlay->num_rows;i++) {
|
|
|
|
if (overlay->rows[i].row_under==row_under) {
|
|
|
|
row= &overlay->rows[i];
|
|
|
|
if ((row->sz_keys<sz_keys)&&
|
|
|
|
(_XkbAllocOverlayKeys(row,sz_keys)!=Success)) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return &overlay->rows[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((overlay->num_rows>=overlay->sz_rows)&&
|
|
|
|
(_XkbAllocOverlayRows(overlay,1)!=Success))
|
|
|
|
return NULL;
|
|
|
|
row= &overlay->rows[overlay->num_rows];
|
2010-06-21 07:28:34 -06:00
|
|
|
bzero(row,sizeof(XkbcOverlayRowRec));
|
2009-03-28 13:39:21 -06:00
|
|
|
if ((sz_keys>0)&&(_XkbAllocOverlayKeys(row,sz_keys)!=Success))
|
|
|
|
return NULL;
|
|
|
|
row->row_under= row_under;
|
|
|
|
overlay->num_rows++;
|
|
|
|
return row;
|
|
|
|
}
|
|
|
|
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcOverlayPtr
|
2010-06-28 04:50:12 -06:00
|
|
|
XkbcAddGeomOverlay(XkbcSectionPtr section,uint32_t name,int sz_rows)
|
2009-03-28 13:39:21 -06:00
|
|
|
{
|
|
|
|
register int i;
|
2010-06-21 07:28:34 -06:00
|
|
|
XkbcOverlayPtr overlay;
|
2009-03-28 13:39:21 -06:00
|
|
|
|
|
|
|
if ((!section)||(name==None)||(sz_rows==0))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
for (i=0,overlay=section->overlays;i<section->num_overlays;i++,overlay++) {
|
|
|
|
if (overlay->name==name) {
|
|
|
|
if ((sz_rows>0)&&(_XkbAllocOverlayRows(overlay,sz_rows)!=Success))
|
|
|
|
return NULL;
|
|
|
|
return overlay;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((section->num_overlays>=section->sz_overlays)&&
|
|
|
|
(_XkbAllocOverlays(section,1)!=Success))
|
|
|
|
return NULL;
|
|
|
|
overlay= §ion->overlays[section->num_overlays];
|
|
|
|
if ((sz_rows>0)&&(_XkbAllocOverlayRows(overlay,sz_rows)!=Success))
|
|
|
|
return NULL;
|
|
|
|
overlay->name= name;
|
|
|
|
overlay->section_under= section;
|
|
|
|
section->num_overlays++;
|
|
|
|
return overlay;
|
|
|
|
}
|