2003-11-14 16:54:54 +01:00
|
|
|
/************************************************************
|
|
|
|
Copyright (c) 1994 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
|
2014-10-31 00:45:12 +01:00
|
|
|
documentation, and that the name of Silicon Graphics not be
|
|
|
|
used in advertising or publicity pertaining to distribution
|
2003-11-14 16:54:54 +01:00
|
|
|
of the software without specific prior written permission.
|
2014-10-31 00:45:12 +01:00
|
|
|
Silicon Graphics makes no representation about the suitability
|
2003-11-14 16:54:54 +01:00
|
|
|
of this software for any purpose. It is provided "as is"
|
|
|
|
without any express or implied warranty.
|
2014-10-31 00:45:12 +01:00
|
|
|
|
|
|
|
SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
|
|
|
|
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
2003-11-14 16:54:54 +01:00
|
|
|
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
|
2014-10-31 00:45:12 +01:00
|
|
|
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
|
2003-11-14 16:54:54 +01:00
|
|
|
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
|
|
|
|
THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
|
|
|
|
********************************************************/
|
|
|
|
|
2005-07-03 09:02:09 +02:00
|
|
|
#ifdef HAVE_DIX_CONFIG_H
|
|
|
|
#include <dix-config.h>
|
2005-06-13 23:51:46 +02:00
|
|
|
#endif
|
2005-07-03 09:37:35 +02:00
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include <X11/Xos.h>
|
|
|
|
#include <X11/Xfuncs.h>
|
|
|
|
|
2005-07-03 09:37:35 +02:00
|
|
|
#include <X11/X.h>
|
|
|
|
#include <X11/Xproto.h>
|
2003-11-14 16:54:54 +01:00
|
|
|
#include <X11/keysym.h>
|
2009-07-15 04:30:02 +02:00
|
|
|
#include <X11/extensions/XKMformat.h>
|
2003-11-14 16:54:54 +01:00
|
|
|
#include "misc.h"
|
|
|
|
#include "inputstr.h"
|
2008-02-03 13:12:15 +01:00
|
|
|
#include "xkbstr.h"
|
2008-02-03 13:30:22 +01:00
|
|
|
#include "xkbsrv.h"
|
2008-02-03 13:12:15 +01:00
|
|
|
#include "xkbgeom.h"
|
2003-11-14 16:54:54 +01:00
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Atom
|
2012-03-21 20:55:09 +01:00
|
|
|
XkbInternAtom(char *str, Bool only_if_exists)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
if (str == NULL)
|
|
|
|
return None;
|
|
|
|
return MakeAtom(str, strlen(str), !only_if_exists);
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***====================================================================***/
|
|
|
|
|
2008-02-03 13:43:18 +01:00
|
|
|
static void *
|
2012-03-21 20:55:09 +01:00
|
|
|
XkmInsureSize(void *oldPtr, int oldCount, int *newCountRtrn, int elemSize)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
int newCount = *newCountRtrn;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (oldPtr == NULL) {
|
|
|
|
if (newCount == 0)
|
|
|
|
return NULL;
|
|
|
|
oldPtr = calloc(newCount, elemSize);
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
else if (oldCount < newCount) {
|
2015-03-21 22:36:07 +01:00
|
|
|
oldPtr = reallocarray(oldPtr, newCount, elemSize);
|
2012-03-21 20:55:09 +01:00
|
|
|
if (oldPtr != NULL) {
|
|
|
|
char *tmp = (char *) oldPtr;
|
|
|
|
|
|
|
|
memset(&tmp[oldCount * elemSize], 0,
|
|
|
|
(newCount - oldCount) * elemSize);
|
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
else if (newCount < oldCount) {
|
|
|
|
*newCountRtrn = oldCount;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
return oldPtr;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define XkmInsureTypedSize(p,o,n,t) ((p)=((t *)XkmInsureSize((char *)(p),(o),(n),sizeof(t))))
|
|
|
|
|
|
|
|
static CARD8
|
2012-03-21 20:55:09 +01:00
|
|
|
XkmGetCARD8(FILE * file, int *pNRead)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
int tmp;
|
|
|
|
|
|
|
|
tmp = getc(file);
|
|
|
|
if (pNRead && (tmp != EOF))
|
|
|
|
(*pNRead) += 1;
|
2003-11-14 16:54:54 +01:00
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
static CARD16
|
2012-03-21 20:55:09 +01:00
|
|
|
XkmGetCARD16(FILE * file, int *pNRead)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
CARD16 val;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if ((fread(&val, 2, 1, file) == 1) && (pNRead))
|
|
|
|
(*pNRead) += 2;
|
2003-11-14 16:54:54 +01:00
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
static CARD32
|
2012-03-21 20:55:09 +01:00
|
|
|
XkmGetCARD32(FILE * file, int *pNRead)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
CARD32 val;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if ((fread(&val, 4, 1, file) == 1) && (pNRead))
|
|
|
|
(*pNRead) += 4;
|
2003-11-14 16:54:54 +01:00
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-03-21 20:55:09 +01:00
|
|
|
XkmSkipPadding(FILE * file, unsigned pad)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
register int i, nRead = 0;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
for (i = 0; i < pad; i++) {
|
|
|
|
if (getc(file) != EOF)
|
|
|
|
nRead++;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
return nRead;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-03-21 20:55:09 +01:00
|
|
|
XkmGetCountedString(FILE * file, char *str, int max_len)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
int count, nRead = 0;
|
|
|
|
|
|
|
|
count = XkmGetCARD16(file, &nRead);
|
|
|
|
if (count > 0) {
|
|
|
|
int tmp;
|
|
|
|
|
|
|
|
if (count > max_len) {
|
|
|
|
tmp = fread(str, 1, max_len, file);
|
|
|
|
while (tmp < count) {
|
|
|
|
if ((getc(file)) != EOF)
|
|
|
|
tmp++;
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
tmp = fread(str, 1, count, file);
|
|
|
|
}
|
|
|
|
nRead += tmp;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
if (count >= max_len)
|
|
|
|
str[max_len - 1] = '\0';
|
|
|
|
else
|
|
|
|
str[count] = '\0';
|
|
|
|
count = XkbPaddedSize(nRead) - nRead;
|
|
|
|
if (count > 0)
|
|
|
|
nRead += XkmSkipPadding(file, count);
|
2003-11-14 16:54:54 +01:00
|
|
|
return nRead;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***====================================================================***/
|
|
|
|
|
|
|
|
static int
|
2012-03-21 20:55:09 +01:00
|
|
|
ReadXkmVirtualMods(FILE * file, XkbDescPtr xkb, XkbChangesPtr changes)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
register unsigned int i, bit;
|
|
|
|
unsigned int bound, named, tmp;
|
|
|
|
int nRead = 0;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (XkbAllocServerMap(xkb, XkbVirtualModsMask, 0) != Success) {
|
|
|
|
_XkbLibError(_XkbErrBadAlloc, "ReadXkmVirtualMods", 0);
|
|
|
|
return -1;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
bound = XkmGetCARD16(file, &nRead);
|
|
|
|
named = XkmGetCARD16(file, &nRead);
|
|
|
|
for (i = tmp = 0, bit = 1; i < XkbNumVirtualMods; i++, bit <<= 1) {
|
|
|
|
if (bound & bit) {
|
|
|
|
xkb->server->vmods[i] = XkmGetCARD8(file, &nRead);
|
|
|
|
if (changes)
|
|
|
|
changes->map.vmods |= bit;
|
|
|
|
tmp++;
|
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
if ((i = XkbPaddedSize(tmp) - tmp) > 0)
|
|
|
|
nRead += XkmSkipPadding(file, i);
|
|
|
|
if (XkbAllocNames(xkb, XkbVirtualModNamesMask, 0, 0) != Success) {
|
|
|
|
_XkbLibError(_XkbErrBadAlloc, "ReadXkmVirtualMods", 0);
|
|
|
|
return -1;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
for (i = 0, bit = 1; i < XkbNumVirtualMods; i++, bit <<= 1) {
|
|
|
|
char name[100];
|
|
|
|
|
|
|
|
if (named & bit) {
|
|
|
|
if (nRead += XkmGetCountedString(file, name, 100)) {
|
|
|
|
xkb->names->vmods[i] = XkbInternAtom(name, FALSE);
|
|
|
|
if (changes)
|
|
|
|
changes->names.changed_vmods |= bit;
|
|
|
|
}
|
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
return nRead;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***====================================================================***/
|
|
|
|
|
|
|
|
static int
|
2012-03-21 20:55:09 +01:00
|
|
|
ReadXkmKeycodes(FILE * file, XkbDescPtr xkb, XkbChangesPtr changes)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
register int i;
|
|
|
|
unsigned minKC, maxKC, nAl;
|
|
|
|
int nRead = 0;
|
|
|
|
char name[100];
|
|
|
|
XkbKeyNamePtr pN;
|
|
|
|
|
|
|
|
name[0] = '\0';
|
|
|
|
nRead += XkmGetCountedString(file, name, 100);
|
|
|
|
minKC = XkmGetCARD8(file, &nRead);
|
|
|
|
maxKC = XkmGetCARD8(file, &nRead);
|
|
|
|
if (xkb->min_key_code == 0) {
|
|
|
|
xkb->min_key_code = minKC;
|
|
|
|
xkb->max_key_code = maxKC;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
else {
|
2012-03-21 20:55:09 +01:00
|
|
|
if (minKC < xkb->min_key_code)
|
|
|
|
xkb->min_key_code = minKC;
|
|
|
|
if (maxKC > xkb->max_key_code) {
|
|
|
|
_XkbLibError(_XkbErrBadValue, "ReadXkmKeycodes", maxKC);
|
|
|
|
return -1;
|
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
nAl = XkmGetCARD8(file, &nRead);
|
|
|
|
nRead += XkmSkipPadding(file, 1);
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
#define WANTED (XkbKeycodesNameMask|XkbKeyNamesMask|XkbKeyAliasesMask)
|
2012-03-21 20:55:09 +01:00
|
|
|
if (XkbAllocNames(xkb, WANTED, 0, nAl) != Success) {
|
|
|
|
_XkbLibError(_XkbErrBadAlloc, "ReadXkmKeycodes", 0);
|
|
|
|
return -1;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
if (name[0] != '\0') {
|
|
|
|
xkb->names->keycodes = XkbInternAtom(name, FALSE);
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
for (pN = &xkb->names->keys[minKC], i = minKC; i <= (int) maxKC; i++, pN++) {
|
|
|
|
if (fread(pN, 1, XkbKeyNameLength, file) != XkbKeyNameLength) {
|
|
|
|
_XkbLibError(_XkbErrBadLength, "ReadXkmKeycodes", 0);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
nRead += XkbKeyNameLength;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
if (nAl > 0) {
|
|
|
|
XkbKeyAliasPtr pAl;
|
|
|
|
|
|
|
|
for (pAl = xkb->names->key_aliases, i = 0; i < nAl; i++, pAl++) {
|
|
|
|
int tmp;
|
|
|
|
|
|
|
|
tmp = fread(pAl, 1, 2 * XkbKeyNameLength, file);
|
|
|
|
if (tmp != 2 * XkbKeyNameLength) {
|
|
|
|
_XkbLibError(_XkbErrBadLength, "ReadXkmKeycodes", 0);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
nRead += 2 * XkbKeyNameLength;
|
|
|
|
}
|
|
|
|
if (changes)
|
|
|
|
changes->names.changed |= XkbKeyAliasesMask;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
if (changes)
|
2012-03-21 20:55:09 +01:00
|
|
|
changes->names.changed |= XkbKeyNamesMask;
|
2003-11-14 16:54:54 +01:00
|
|
|
return nRead;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***====================================================================***/
|
|
|
|
|
|
|
|
static int
|
2012-03-21 20:55:09 +01:00
|
|
|
ReadXkmKeyTypes(FILE * file, XkbDescPtr xkb, XkbChangesPtr changes)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
register unsigned i, n;
|
|
|
|
unsigned num_types;
|
|
|
|
int nRead = 0;
|
|
|
|
int tmp;
|
|
|
|
XkbKeyTypePtr type;
|
|
|
|
xkmKeyTypeDesc wire;
|
|
|
|
XkbKTMapEntryPtr entry;
|
|
|
|
xkmKTMapEntryDesc wire_entry;
|
|
|
|
char buf[100];
|
|
|
|
|
|
|
|
if ((tmp = XkmGetCountedString(file, buf, 100)) < 1) {
|
|
|
|
_XkbLibError(_XkbErrBadLength, "ReadXkmKeyTypes", 0);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
nRead += tmp;
|
|
|
|
if (buf[0] != '\0') {
|
|
|
|
if (XkbAllocNames(xkb, XkbTypesNameMask, 0, 0) != Success) {
|
|
|
|
_XkbLibError(_XkbErrBadAlloc, "ReadXkmKeyTypes", 0);
|
|
|
|
return -1;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
xkb->names->types = XkbInternAtom(buf, FALSE);
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
num_types = XkmGetCARD16(file, &nRead);
|
|
|
|
nRead += XkmSkipPadding(file, 2);
|
|
|
|
if (num_types < 1)
|
|
|
|
return nRead;
|
|
|
|
if (XkbAllocClientMap(xkb, XkbKeyTypesMask, num_types) != Success) {
|
|
|
|
_XkbLibError(_XkbErrBadAlloc, "ReadXkmKeyTypes", 0);
|
|
|
|
return nRead;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
xkb->map->num_types = num_types;
|
|
|
|
if (num_types < XkbNumRequiredTypes) {
|
|
|
|
_XkbLibError(_XkbErrMissingReqTypes, "ReadXkmKeyTypes", 0);
|
|
|
|
return -1;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
type = xkb->map->types;
|
|
|
|
for (i = 0; i < num_types; i++, type++) {
|
|
|
|
if ((int) fread(&wire, SIZEOF(xkmKeyTypeDesc), 1, file) < 1) {
|
|
|
|
_XkbLibError(_XkbErrBadLength, "ReadXkmKeyTypes", 0);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
nRead += SIZEOF(xkmKeyTypeDesc);
|
|
|
|
if (((i == XkbOneLevelIndex) && (wire.numLevels != 1)) ||
|
|
|
|
(((i == XkbTwoLevelIndex) || (i == XkbAlphabeticIndex) ||
|
|
|
|
((i) == XkbKeypadIndex)) && (wire.numLevels != 2))) {
|
|
|
|
_XkbLibError(_XkbErrBadTypeWidth, "ReadXkmKeyTypes", i);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
tmp = wire.nMapEntries;
|
|
|
|
XkmInsureTypedSize(type->map, type->map_count, &tmp, XkbKTMapEntryRec);
|
|
|
|
if ((wire.nMapEntries > 0) && (type->map == NULL)) {
|
|
|
|
_XkbLibError(_XkbErrBadValue, "ReadXkmKeyTypes", wire.nMapEntries);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
for (n = 0, entry = type->map; n < wire.nMapEntries; n++, entry++) {
|
|
|
|
if (fread(&wire_entry, SIZEOF(xkmKTMapEntryDesc), 1, file) <
|
|
|
|
(int) 1) {
|
|
|
|
_XkbLibError(_XkbErrBadLength, "ReadXkmKeyTypes", 0);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
nRead += SIZEOF(xkmKTMapEntryDesc);
|
|
|
|
entry->active = (wire_entry.virtualMods == 0);
|
|
|
|
entry->level = wire_entry.level;
|
|
|
|
entry->mods.mask = wire_entry.realMods;
|
|
|
|
entry->mods.real_mods = wire_entry.realMods;
|
|
|
|
entry->mods.vmods = wire_entry.virtualMods;
|
|
|
|
}
|
|
|
|
nRead += XkmGetCountedString(file, buf, 100);
|
|
|
|
if (((i == XkbOneLevelIndex) && (strcmp(buf, "ONE_LEVEL") != 0)) ||
|
|
|
|
((i == XkbTwoLevelIndex) && (strcmp(buf, "TWO_LEVEL") != 0)) ||
|
|
|
|
((i == XkbAlphabeticIndex) && (strcmp(buf, "ALPHABETIC") != 0)) ||
|
|
|
|
((i == XkbKeypadIndex) && (strcmp(buf, "KEYPAD") != 0))) {
|
|
|
|
_XkbLibError(_XkbErrBadTypeName, "ReadXkmKeyTypes", 0);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (buf[0] != '\0') {
|
|
|
|
type->name = XkbInternAtom(buf, FALSE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
type->name = None;
|
|
|
|
|
|
|
|
if (wire.preserve) {
|
|
|
|
xkmModsDesc p_entry;
|
|
|
|
XkbModsPtr pre;
|
|
|
|
|
|
|
|
XkmInsureTypedSize(type->preserve, type->map_count, &tmp,
|
|
|
|
XkbModsRec);
|
|
|
|
if (type->preserve == NULL) {
|
|
|
|
_XkbLibError(_XkbErrBadMatch, "ReadXkmKeycodes", 0);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
for (n = 0, pre = type->preserve; n < wire.nMapEntries; n++, pre++) {
|
|
|
|
if (fread(&p_entry, SIZEOF(xkmModsDesc), 1, file) < 1) {
|
|
|
|
_XkbLibError(_XkbErrBadLength, "ReadXkmKeycodes", 0);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
nRead += SIZEOF(xkmModsDesc);
|
|
|
|
pre->mask = p_entry.realMods;
|
|
|
|
pre->real_mods = p_entry.realMods;
|
|
|
|
pre->vmods = p_entry.virtualMods;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (wire.nLevelNames > 0) {
|
|
|
|
int width = wire.numLevels;
|
|
|
|
|
|
|
|
if (wire.nLevelNames > (unsigned) width) {
|
|
|
|
_XkbLibError(_XkbErrBadMatch, "ReadXkmKeycodes", 0);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
XkmInsureTypedSize(type->level_names, type->num_levels, &width,
|
|
|
|
Atom);
|
|
|
|
if (type->level_names != NULL) {
|
|
|
|
for (n = 0; n < wire.nLevelNames; n++) {
|
|
|
|
if ((tmp = XkmGetCountedString(file, buf, 100)) < 1)
|
|
|
|
return -1;
|
|
|
|
nRead += tmp;
|
|
|
|
if (strlen(buf) == 0)
|
|
|
|
type->level_names[n] = None;
|
|
|
|
else
|
|
|
|
type->level_names[n] = XkbInternAtom(buf, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
type->mods.mask = wire.realMods;
|
|
|
|
type->mods.real_mods = wire.realMods;
|
|
|
|
type->mods.vmods = wire.virtualMods;
|
|
|
|
type->num_levels = wire.numLevels;
|
|
|
|
type->map_count = wire.nMapEntries;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
if (changes) {
|
2012-03-21 20:55:09 +01:00
|
|
|
changes->map.changed |= XkbKeyTypesMask;
|
|
|
|
changes->map.first_type = 0;
|
|
|
|
changes->map.num_types = xkb->map->num_types;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
return nRead;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***====================================================================***/
|
|
|
|
|
|
|
|
static int
|
2012-03-21 20:55:09 +01:00
|
|
|
ReadXkmCompatMap(FILE * file, XkbDescPtr xkb, XkbChangesPtr changes)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
register int i;
|
|
|
|
unsigned num_si, groups;
|
|
|
|
char name[100];
|
|
|
|
XkbSymInterpretPtr interp;
|
|
|
|
xkmSymInterpretDesc wire;
|
|
|
|
unsigned tmp;
|
|
|
|
int nRead = 0;
|
|
|
|
XkbCompatMapPtr compat;
|
|
|
|
XkbAction *act;
|
|
|
|
|
|
|
|
if ((tmp = XkmGetCountedString(file, name, 100)) < 1) {
|
|
|
|
_XkbLibError(_XkbErrBadLength, "ReadXkmCompatMap", 0);
|
|
|
|
return -1;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
nRead += tmp;
|
|
|
|
if (name[0] != '\0') {
|
|
|
|
if (XkbAllocNames(xkb, XkbCompatNameMask, 0, 0) != Success) {
|
|
|
|
_XkbLibError(_XkbErrBadAlloc, "ReadXkmCompatMap", 0);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
xkb->names->compat = XkbInternAtom(name, FALSE);
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
num_si = XkmGetCARD16(file, &nRead);
|
|
|
|
groups = XkmGetCARD8(file, &nRead);
|
|
|
|
nRead += XkmSkipPadding(file, 1);
|
|
|
|
if (XkbAllocCompatMap(xkb, XkbAllCompatMask, num_si) != Success)
|
|
|
|
return -1;
|
|
|
|
compat = xkb->compat;
|
|
|
|
compat->num_si = 0;
|
|
|
|
interp = compat->sym_interpret;
|
|
|
|
for (i = 0; i < num_si; i++) {
|
|
|
|
tmp = fread(&wire, SIZEOF(xkmSymInterpretDesc), 1, file);
|
|
|
|
nRead += tmp * SIZEOF(xkmSymInterpretDesc);
|
|
|
|
interp->sym = wire.sym;
|
|
|
|
interp->mods = wire.mods;
|
|
|
|
interp->match = wire.match;
|
|
|
|
interp->virtual_mod = wire.virtualMod;
|
|
|
|
interp->flags = wire.flags;
|
|
|
|
interp->act.type = wire.actionType;
|
2008-10-15 19:07:52 +02:00
|
|
|
act = (XkbAction *) &interp->act;
|
|
|
|
|
|
|
|
switch (interp->act.type) {
|
|
|
|
case XkbSA_SetMods:
|
|
|
|
case XkbSA_LatchMods:
|
|
|
|
case XkbSA_LockMods:
|
|
|
|
act->mods.flags = wire.actionData[0];
|
|
|
|
act->mods.mask = wire.actionData[1];
|
|
|
|
act->mods.real_mods = wire.actionData[2];
|
2009-07-10 03:10:30 +02:00
|
|
|
act->mods.vmods1 = wire.actionData[3];
|
|
|
|
act->mods.vmods2 = wire.actionData[4];
|
2008-10-15 19:07:52 +02:00
|
|
|
break;
|
|
|
|
case XkbSA_SetGroup:
|
|
|
|
case XkbSA_LatchGroup:
|
|
|
|
case XkbSA_LockGroup:
|
|
|
|
act->group.flags = wire.actionData[0];
|
|
|
|
act->group.group_XXX = wire.actionData[1];
|
|
|
|
break;
|
|
|
|
case XkbSA_MovePtr:
|
|
|
|
act->ptr.flags = wire.actionData[0];
|
2009-07-10 03:10:30 +02:00
|
|
|
act->ptr.high_XXX = wire.actionData[1];
|
|
|
|
act->ptr.low_XXX = wire.actionData[2];
|
|
|
|
act->ptr.high_YYY = wire.actionData[3];
|
|
|
|
act->ptr.low_YYY = wire.actionData[4];
|
2008-10-15 19:07:52 +02:00
|
|
|
break;
|
|
|
|
case XkbSA_PtrBtn:
|
|
|
|
case XkbSA_LockPtrBtn:
|
|
|
|
act->btn.flags = wire.actionData[0];
|
|
|
|
act->btn.count = wire.actionData[1];
|
|
|
|
act->btn.button = wire.actionData[2];
|
|
|
|
break;
|
|
|
|
case XkbSA_DeviceBtn:
|
|
|
|
case XkbSA_LockDeviceBtn:
|
|
|
|
act->devbtn.flags = wire.actionData[0];
|
|
|
|
act->devbtn.count = wire.actionData[1];
|
|
|
|
act->devbtn.button = wire.actionData[2];
|
|
|
|
act->devbtn.device = wire.actionData[3];
|
|
|
|
break;
|
|
|
|
case XkbSA_SetPtrDflt:
|
|
|
|
act->dflt.flags = wire.actionData[0];
|
|
|
|
act->dflt.affect = wire.actionData[1];
|
|
|
|
act->dflt.valueXXX = wire.actionData[2];
|
|
|
|
break;
|
|
|
|
case XkbSA_ISOLock:
|
|
|
|
act->iso.flags = wire.actionData[0];
|
|
|
|
act->iso.mask = wire.actionData[1];
|
|
|
|
act->iso.real_mods = wire.actionData[2];
|
|
|
|
act->iso.group_XXX = wire.actionData[3];
|
|
|
|
act->iso.affect = wire.actionData[4];
|
2009-07-10 03:10:30 +02:00
|
|
|
act->iso.vmods1 = wire.actionData[5];
|
|
|
|
act->iso.vmods2 = wire.actionData[6];
|
2008-10-15 19:07:52 +02:00
|
|
|
break;
|
|
|
|
case XkbSA_SwitchScreen:
|
|
|
|
act->screen.flags = wire.actionData[0];
|
|
|
|
act->screen.screenXXX = wire.actionData[1];
|
|
|
|
break;
|
|
|
|
case XkbSA_SetControls:
|
|
|
|
case XkbSA_LockControls:
|
|
|
|
act->ctrls.flags = wire.actionData[0];
|
2009-07-10 03:10:30 +02:00
|
|
|
act->ctrls.ctrls3 = wire.actionData[1];
|
|
|
|
act->ctrls.ctrls2 = wire.actionData[2];
|
|
|
|
act->ctrls.ctrls1 = wire.actionData[3];
|
|
|
|
act->ctrls.ctrls0 = wire.actionData[4];
|
2008-10-15 19:07:52 +02:00
|
|
|
break;
|
|
|
|
case XkbSA_RedirectKey:
|
|
|
|
act->redirect.new_key = wire.actionData[0];
|
|
|
|
act->redirect.mods_mask = wire.actionData[1];
|
|
|
|
act->redirect.mods = wire.actionData[2];
|
2009-07-10 03:10:30 +02:00
|
|
|
act->redirect.vmods_mask0 = wire.actionData[3];
|
|
|
|
act->redirect.vmods_mask1 = wire.actionData[4];
|
|
|
|
act->redirect.vmods0 = wire.actionData[4];
|
|
|
|
act->redirect.vmods1 = wire.actionData[5];
|
2008-10-15 19:07:52 +02:00
|
|
|
break;
|
|
|
|
case XkbSA_DeviceValuator:
|
|
|
|
act->devval.device = wire.actionData[0];
|
|
|
|
act->devval.v1_what = wire.actionData[1];
|
|
|
|
act->devval.v1_ndx = wire.actionData[2];
|
|
|
|
act->devval.v1_value = wire.actionData[3];
|
|
|
|
act->devval.v2_what = wire.actionData[4];
|
|
|
|
act->devval.v2_ndx = wire.actionData[5];
|
|
|
|
act->devval.v2_what = wire.actionData[6];
|
|
|
|
break;
|
2009-12-30 19:35:20 +01:00
|
|
|
|
2008-10-15 19:07:52 +02:00
|
|
|
case XkbSA_XFree86Private:
|
2011-07-13 13:08:04 +02:00
|
|
|
/*
|
|
|
|
* Bugfix for broken xkbcomp: if we encounter an XFree86Private
|
|
|
|
* action with Any+AnyOfOrNone(All), then we skip the interp as
|
|
|
|
* broken. Versions of xkbcomp below 1.2.2 had a bug where they
|
|
|
|
* would interpret a symbol that couldn't be found in an interpret
|
|
|
|
* as Any. So, an XF86LogWindowTree+AnyOfOrNone(All) interp that
|
|
|
|
* triggered the PrWins action would make every key without an
|
|
|
|
* action trigger PrWins if libX11 didn't yet know about the
|
|
|
|
* XF86LogWindowTree keysym. None too useful.
|
|
|
|
*
|
|
|
|
* We only do this for XFree86 actions, as the current XKB
|
|
|
|
* dataset relies on Any+AnyOfOrNone(All) -> SetMods for Ctrl in
|
|
|
|
* particular.
|
|
|
|
*
|
|
|
|
* See xkbcomp commits 2a473b906943ffd807ad81960c47530ee7ae9a60 and
|
|
|
|
* 3caab5aa37decb7b5dc1642a0452efc3e1f5100e for more details.
|
|
|
|
*/
|
|
|
|
if (interp->sym == NoSymbol && interp->match == XkbSI_AnyOfOrNone &&
|
|
|
|
(interp->mods & 0xff) == 0xff) {
|
|
|
|
ErrorF("XKB: Skipping broken Any+AnyOfOrNone(All) -> Private "
|
|
|
|
"action from compiled keymap\n");
|
|
|
|
continue;
|
|
|
|
}
|
2009-12-30 19:35:20 +01:00
|
|
|
/* copy the kind of action */
|
2010-07-22 10:13:10 +02:00
|
|
|
memcpy(act->any.data, wire.actionData, XkbAnyActionDataSize);
|
2012-03-21 20:55:09 +01:00
|
|
|
break;
|
2009-12-30 19:35:20 +01:00
|
|
|
|
2008-10-15 19:07:52 +02:00
|
|
|
case XkbSA_Terminate:
|
|
|
|
/* no args, kinda (note: untrue for xfree86). */
|
|
|
|
break;
|
|
|
|
case XkbSA_ActionMessage:
|
|
|
|
/* unsupported. */
|
|
|
|
break;
|
|
|
|
}
|
2011-07-13 13:08:04 +02:00
|
|
|
interp++;
|
|
|
|
compat->num_si++;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
if ((num_si > 0) && (changes)) {
|
|
|
|
changes->compat.first_si = 0;
|
|
|
|
changes->compat.num_si = compat->num_si;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
if (groups) {
|
2012-03-21 20:55:09 +01:00
|
|
|
register unsigned bit;
|
|
|
|
|
|
|
|
for (i = 0, bit = 1; i < XkbNumKbdGroups; i++, bit <<= 1) {
|
|
|
|
xkmModsDesc md;
|
|
|
|
|
|
|
|
if (groups & bit) {
|
|
|
|
tmp = fread(&md, SIZEOF(xkmModsDesc), 1, file);
|
|
|
|
nRead += tmp * SIZEOF(xkmModsDesc);
|
|
|
|
xkb->compat->groups[i].real_mods = md.realMods;
|
|
|
|
xkb->compat->groups[i].vmods = md.virtualMods;
|
|
|
|
if (md.virtualMods != 0) {
|
|
|
|
unsigned mask;
|
|
|
|
|
|
|
|
if (XkbVirtualModsToReal(xkb, md.virtualMods, &mask))
|
|
|
|
xkb->compat->groups[i].mask = md.realMods | mask;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
xkb->compat->groups[i].mask = md.realMods;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (changes)
|
|
|
|
changes->compat.changed_groups |= groups;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
return nRead;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-03-21 20:55:09 +01:00
|
|
|
ReadXkmIndicators(FILE * file, XkbDescPtr xkb, XkbChangesPtr changes)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
register unsigned nLEDs;
|
|
|
|
xkmIndicatorMapDesc wire;
|
|
|
|
char buf[100];
|
|
|
|
unsigned tmp;
|
|
|
|
int nRead = 0;
|
|
|
|
|
|
|
|
if ((xkb->indicators == NULL) && (XkbAllocIndicatorMaps(xkb) != Success)) {
|
|
|
|
_XkbLibError(_XkbErrBadAlloc, "indicator rec", 0);
|
|
|
|
return -1;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
if (XkbAllocNames(xkb, XkbIndicatorNamesMask, 0, 0) != Success) {
|
|
|
|
_XkbLibError(_XkbErrBadAlloc, "indicator names", 0);
|
|
|
|
return -1;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
nLEDs = XkmGetCARD8(file, &nRead);
|
|
|
|
nRead += XkmSkipPadding(file, 3);
|
|
|
|
xkb->indicators->phys_indicators = XkmGetCARD32(file, &nRead);
|
|
|
|
while (nLEDs-- > 0) {
|
|
|
|
Atom name;
|
|
|
|
XkbIndicatorMapPtr map;
|
|
|
|
|
|
|
|
if ((tmp = XkmGetCountedString(file, buf, 100)) < 1) {
|
|
|
|
_XkbLibError(_XkbErrBadLength, "ReadXkmIndicators", 0);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
nRead += tmp;
|
|
|
|
if (buf[0] != '\0')
|
|
|
|
name = XkbInternAtom(buf, FALSE);
|
|
|
|
else
|
|
|
|
name = None;
|
|
|
|
if ((tmp = fread(&wire, SIZEOF(xkmIndicatorMapDesc), 1, file)) < 1) {
|
|
|
|
_XkbLibError(_XkbErrBadLength, "ReadXkmIndicators", 0);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
nRead += tmp * SIZEOF(xkmIndicatorMapDesc);
|
|
|
|
if (xkb->names) {
|
|
|
|
xkb->names->indicators[wire.indicator - 1] = name;
|
|
|
|
if (changes)
|
|
|
|
changes->names.changed_indicators |=
|
|
|
|
(1 << (wire.indicator - 1));
|
|
|
|
}
|
|
|
|
map = &xkb->indicators->maps[wire.indicator - 1];
|
|
|
|
map->flags = wire.flags;
|
|
|
|
map->which_groups = wire.which_groups;
|
|
|
|
map->groups = wire.groups;
|
|
|
|
map->which_mods = wire.which_mods;
|
|
|
|
map->mods.mask = wire.real_mods;
|
|
|
|
map->mods.real_mods = wire.real_mods;
|
|
|
|
map->mods.vmods = wire.vmods;
|
|
|
|
map->ctrls = wire.ctrls;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
return nRead;
|
|
|
|
}
|
|
|
|
|
|
|
|
static XkbKeyTypePtr
|
2012-03-21 20:55:09 +01:00
|
|
|
FindTypeForKey(XkbDescPtr xkb, Atom name, unsigned width, KeySym * syms)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
if ((!xkb) || (!xkb->map))
|
|
|
|
return NULL;
|
|
|
|
if (name != None) {
|
|
|
|
register unsigned i;
|
|
|
|
|
|
|
|
for (i = 0; i < xkb->map->num_types; i++) {
|
|
|
|
if (xkb->map->types[i].name == name) {
|
|
|
|
if (xkb->map->types[i].num_levels != width)
|
|
|
|
DebugF("Group width mismatch between key and type\n");
|
|
|
|
return &xkb->map->types[i];
|
|
|
|
}
|
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
if ((width < 2) || ((syms != NULL) && (syms[1] == NoSymbol)))
|
|
|
|
return &xkb->map->types[XkbOneLevelIndex];
|
|
|
|
if (syms != NULL) {
|
|
|
|
if (XkbKSIsLower(syms[0]) && XkbKSIsUpper(syms[1]))
|
|
|
|
return &xkb->map->types[XkbAlphabeticIndex];
|
|
|
|
else if (XkbKSIsKeypad(syms[0]) || XkbKSIsKeypad(syms[1]))
|
|
|
|
return &xkb->map->types[XkbKeypadIndex];
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
return &xkb->map->types[XkbTwoLevelIndex];
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-03-21 20:55:09 +01:00
|
|
|
ReadXkmSymbols(FILE * file, XkbDescPtr xkb)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
register int i, g, s, totalVModMaps;
|
|
|
|
xkmKeySymMapDesc wireMap;
|
|
|
|
char buf[100];
|
|
|
|
unsigned minKC, maxKC, groupNames, tmp;
|
|
|
|
int nRead = 0;
|
|
|
|
|
|
|
|
if ((tmp = XkmGetCountedString(file, buf, 100)) < 1)
|
|
|
|
return -1;
|
|
|
|
nRead += tmp;
|
|
|
|
minKC = XkmGetCARD8(file, &nRead);
|
|
|
|
maxKC = XkmGetCARD8(file, &nRead);
|
|
|
|
groupNames = XkmGetCARD8(file, &nRead);
|
|
|
|
totalVModMaps = XkmGetCARD8(file, &nRead);
|
2003-11-14 16:54:54 +01:00
|
|
|
if (XkbAllocNames(xkb,
|
2012-03-21 20:55:09 +01:00
|
|
|
XkbSymbolsNameMask | XkbPhysSymbolsNameMask |
|
|
|
|
XkbGroupNamesMask, 0, 0) != Success) {
|
|
|
|
_XkbLibError(_XkbErrBadAlloc, "physical names", 0);
|
|
|
|
return -1;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
if ((buf[0] != '\0') && (xkb->names)) {
|
|
|
|
Atom name;
|
|
|
|
|
|
|
|
name = XkbInternAtom(buf, 0);
|
|
|
|
xkb->names->symbols = name;
|
|
|
|
xkb->names->phys_symbols = name;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
for (i = 0, g = 1; i < XkbNumKbdGroups; i++, g <<= 1) {
|
|
|
|
if (groupNames & g) {
|
|
|
|
if ((tmp = XkmGetCountedString(file, buf, 100)) < 1)
|
|
|
|
return -1;
|
|
|
|
nRead += tmp;
|
|
|
|
|
|
|
|
if (!xkb->names)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (buf[0] != '\0') {
|
|
|
|
Atom name;
|
|
|
|
|
|
|
|
name = XkbInternAtom(buf, 0);
|
|
|
|
xkb->names->groups[i] = name;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
xkb->names->groups[i] = None;
|
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
if (XkbAllocServerMap(xkb, XkbAllServerInfoMask, 0) != Success) {
|
|
|
|
_XkbLibError(_XkbErrBadAlloc, "server map", 0);
|
|
|
|
return -1;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
if (XkbAllocClientMap(xkb, XkbAllClientInfoMask, 0) != Success) {
|
|
|
|
_XkbLibError(_XkbErrBadAlloc, "client map", 0);
|
|
|
|
return -1;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
if (XkbAllocControls(xkb, XkbAllControlsMask) != Success) {
|
|
|
|
_XkbLibError(_XkbErrBadAlloc, "controls", 0);
|
|
|
|
return -1;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
if ((xkb->map == NULL) || (xkb->server == NULL))
|
|
|
|
return -1;
|
|
|
|
if (xkb->min_key_code < 8)
|
|
|
|
xkb->min_key_code = minKC;
|
|
|
|
if (xkb->max_key_code < 8)
|
|
|
|
xkb->max_key_code = maxKC;
|
|
|
|
if ((minKC >= 8) && (minKC < xkb->min_key_code))
|
|
|
|
xkb->min_key_code = minKC;
|
|
|
|
if ((maxKC >= 8) && (maxKC > xkb->max_key_code)) {
|
|
|
|
_XkbLibError(_XkbErrBadValue, "keys in symbol map", maxKC);
|
|
|
|
return -1;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
for (i = minKC; i <= (int) maxKC; i++) {
|
|
|
|
Atom typeName[XkbNumKbdGroups];
|
|
|
|
XkbKeyTypePtr type[XkbNumKbdGroups];
|
|
|
|
|
|
|
|
if ((tmp = fread(&wireMap, SIZEOF(xkmKeySymMapDesc), 1, file)) < 1) {
|
|
|
|
_XkbLibError(_XkbErrBadLength, "ReadXkmSymbols", 0);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
nRead += tmp * SIZEOF(xkmKeySymMapDesc);
|
|
|
|
memset((char *) typeName, 0, XkbNumKbdGroups * sizeof(Atom));
|
|
|
|
memset((char *) type, 0, XkbNumKbdGroups * sizeof(XkbKeyTypePtr));
|
|
|
|
if (wireMap.flags & XkmKeyHasTypes) {
|
|
|
|
for (g = 0; g < XkbNumKbdGroups; g++) {
|
|
|
|
if ((wireMap.flags & (1 << g)) &&
|
|
|
|
((tmp = XkmGetCountedString(file, buf, 100)) > 0)) {
|
|
|
|
typeName[g] = XkbInternAtom(buf, 1);
|
|
|
|
nRead += tmp;
|
|
|
|
}
|
|
|
|
type[g] = FindTypeForKey(xkb, typeName[g], wireMap.width, NULL);
|
|
|
|
if (type[g] == NULL) {
|
|
|
|
_XkbLibError(_XkbErrMissingTypes, "ReadXkmSymbols", 0);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (typeName[g] == type[g]->name)
|
|
|
|
xkb->server->explicit[i] |= (1 << g);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (wireMap.flags & XkmRepeatingKey) {
|
|
|
|
xkb->ctrls->per_key_repeat[i / 8] |= (1 << (i % 8));
|
|
|
|
xkb->server->explicit[i] |= XkbExplicitAutoRepeatMask;
|
|
|
|
}
|
|
|
|
else if (wireMap.flags & XkmNonRepeatingKey) {
|
|
|
|
xkb->ctrls->per_key_repeat[i / 8] &= ~(1 << (i % 8));
|
|
|
|
xkb->server->explicit[i] |= XkbExplicitAutoRepeatMask;
|
|
|
|
}
|
|
|
|
xkb->map->modmap[i] = wireMap.modifier_map;
|
|
|
|
if (XkbNumGroups(wireMap.num_groups) > 0) {
|
|
|
|
KeySym *sym;
|
|
|
|
int nSyms;
|
|
|
|
|
|
|
|
if (XkbNumGroups(wireMap.num_groups) > xkb->ctrls->num_groups)
|
|
|
|
xkb->ctrls->num_groups = wireMap.num_groups;
|
|
|
|
nSyms = XkbNumGroups(wireMap.num_groups) * wireMap.width;
|
|
|
|
sym = XkbResizeKeySyms(xkb, i, nSyms);
|
|
|
|
if (!sym)
|
|
|
|
return -1;
|
|
|
|
for (s = 0; s < nSyms; s++) {
|
|
|
|
*sym++ = XkmGetCARD32(file, &nRead);
|
|
|
|
}
|
|
|
|
if (wireMap.flags & XkmKeyHasActions) {
|
|
|
|
XkbAction *act;
|
|
|
|
|
|
|
|
act = XkbResizeKeyActions(xkb, i, nSyms);
|
|
|
|
for (s = 0; s < nSyms; s++, act++) {
|
|
|
|
tmp = fread(act, SIZEOF(xkmActionDesc), 1, file);
|
|
|
|
nRead += tmp * SIZEOF(xkmActionDesc);
|
|
|
|
}
|
|
|
|
xkb->server->explicit[i] |= XkbExplicitInterpretMask;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (g = 0; g < XkbNumGroups(wireMap.num_groups); g++) {
|
|
|
|
if (((xkb->server->explicit[i] & (1 << g)) == 0) ||
|
|
|
|
(type[g] == NULL)) {
|
|
|
|
KeySym *tmpSyms;
|
|
|
|
|
|
|
|
tmpSyms = XkbKeySymsPtr(xkb, i) + (wireMap.width * g);
|
|
|
|
type[g] = FindTypeForKey(xkb, None, wireMap.width, tmpSyms);
|
|
|
|
}
|
|
|
|
xkb->map->key_sym_map[i].kt_index[g] =
|
|
|
|
type[g] - (&xkb->map->types[0]);
|
|
|
|
}
|
|
|
|
xkb->map->key_sym_map[i].group_info = wireMap.num_groups;
|
|
|
|
xkb->map->key_sym_map[i].width = wireMap.width;
|
|
|
|
if (wireMap.flags & XkmKeyHasBehavior) {
|
|
|
|
xkmBehaviorDesc b;
|
|
|
|
|
|
|
|
tmp = fread(&b, SIZEOF(xkmBehaviorDesc), 1, file);
|
|
|
|
nRead += tmp * SIZEOF(xkmBehaviorDesc);
|
|
|
|
xkb->server->behaviors[i].type = b.type;
|
|
|
|
xkb->server->behaviors[i].data = b.data;
|
|
|
|
xkb->server->explicit[i] |= XkbExplicitBehaviorMask;
|
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
if (totalVModMaps > 0) {
|
|
|
|
xkmVModMapDesc v;
|
|
|
|
|
|
|
|
for (i = 0; i < totalVModMaps; i++) {
|
|
|
|
tmp = fread(&v, SIZEOF(xkmVModMapDesc), 1, file);
|
|
|
|
nRead += tmp * SIZEOF(xkmVModMapDesc);
|
|
|
|
if (tmp > 0)
|
|
|
|
xkb->server->vmodmap[v.key] = v.vmods;
|
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
return nRead;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-03-21 20:55:09 +01:00
|
|
|
ReadXkmGeomDoodad(FILE * file, XkbGeometryPtr geom, XkbSectionPtr section)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
XkbDoodadPtr doodad;
|
|
|
|
xkmDoodadDesc doodadWire;
|
|
|
|
char buf[100];
|
|
|
|
unsigned tmp;
|
|
|
|
int nRead = 0;
|
|
|
|
|
|
|
|
nRead += XkmGetCountedString(file, buf, 100);
|
|
|
|
tmp = fread(&doodadWire, SIZEOF(xkmDoodadDesc), 1, file);
|
|
|
|
nRead += SIZEOF(xkmDoodadDesc) * tmp;
|
|
|
|
doodad = XkbAddGeomDoodad(geom, section, XkbInternAtom(buf, FALSE));
|
2003-11-14 16:54:54 +01:00
|
|
|
if (!doodad)
|
2012-03-21 20:55:09 +01:00
|
|
|
return nRead;
|
|
|
|
doodad->any.type = doodadWire.any.type;
|
|
|
|
doodad->any.priority = doodadWire.any.priority;
|
|
|
|
doodad->any.top = doodadWire.any.top;
|
|
|
|
doodad->any.left = doodadWire.any.left;
|
2003-11-14 16:54:54 +01:00
|
|
|
switch (doodadWire.any.type) {
|
2012-03-21 20:55:09 +01:00
|
|
|
case XkbOutlineDoodad:
|
|
|
|
case XkbSolidDoodad:
|
|
|
|
doodad->shape.angle = doodadWire.shape.angle;
|
|
|
|
doodad->shape.color_ndx = doodadWire.shape.color_ndx;
|
|
|
|
doodad->shape.shape_ndx = doodadWire.shape.shape_ndx;
|
|
|
|
break;
|
|
|
|
case XkbTextDoodad:
|
|
|
|
doodad->text.angle = doodadWire.text.angle;
|
|
|
|
doodad->text.width = doodadWire.text.width;
|
|
|
|
doodad->text.height = doodadWire.text.height;
|
|
|
|
doodad->text.color_ndx = doodadWire.text.color_ndx;
|
|
|
|
nRead += XkmGetCountedString(file, buf, 100);
|
|
|
|
doodad->text.text = Xstrdup(buf);
|
|
|
|
nRead += XkmGetCountedString(file, buf, 100);
|
|
|
|
doodad->text.font = Xstrdup(buf);
|
|
|
|
break;
|
|
|
|
case XkbIndicatorDoodad:
|
|
|
|
doodad->indicator.shape_ndx = doodadWire.indicator.shape_ndx;
|
|
|
|
doodad->indicator.on_color_ndx = doodadWire.indicator.on_color_ndx;
|
|
|
|
doodad->indicator.off_color_ndx = doodadWire.indicator.off_color_ndx;
|
|
|
|
break;
|
|
|
|
case XkbLogoDoodad:
|
|
|
|
doodad->logo.angle = doodadWire.logo.angle;
|
|
|
|
doodad->logo.color_ndx = doodadWire.logo.color_ndx;
|
|
|
|
doodad->logo.shape_ndx = doodadWire.logo.shape_ndx;
|
|
|
|
nRead += XkmGetCountedString(file, buf, 100);
|
|
|
|
doodad->logo.logo_name = Xstrdup(buf);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* report error? */
|
|
|
|
return nRead;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
return nRead;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-03-21 20:55:09 +01:00
|
|
|
ReadXkmGeomOverlay(FILE * file, XkbGeometryPtr geom, XkbSectionPtr section)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
char buf[100];
|
|
|
|
unsigned tmp;
|
|
|
|
int nRead = 0;
|
|
|
|
XkbOverlayPtr ol;
|
|
|
|
XkbOverlayRowPtr row;
|
|
|
|
xkmOverlayDesc olWire;
|
|
|
|
xkmOverlayRowDesc rowWire;
|
|
|
|
register int r;
|
|
|
|
|
|
|
|
nRead += XkmGetCountedString(file, buf, 100);
|
|
|
|
tmp = fread(&olWire, SIZEOF(xkmOverlayDesc), 1, file);
|
|
|
|
nRead += tmp * SIZEOF(xkmOverlayDesc);
|
|
|
|
ol = XkbAddGeomOverlay(section, XkbInternAtom(buf, FALSE), olWire.num_rows);
|
2003-11-14 16:54:54 +01:00
|
|
|
if (!ol)
|
2012-03-21 20:55:09 +01:00
|
|
|
return nRead;
|
|
|
|
for (r = 0; r < olWire.num_rows; r++) {
|
|
|
|
int k;
|
|
|
|
xkmOverlayKeyDesc keyWire;
|
|
|
|
|
|
|
|
tmp = fread(&rowWire, SIZEOF(xkmOverlayRowDesc), 1, file);
|
|
|
|
nRead += tmp * SIZEOF(xkmOverlayRowDesc);
|
|
|
|
row = XkbAddGeomOverlayRow(ol, rowWire.row_under, rowWire.num_keys);
|
|
|
|
if (!row) {
|
|
|
|
_XkbLibError(_XkbErrBadAlloc, "ReadXkmGeomOverlay", 0);
|
|
|
|
return nRead;
|
|
|
|
}
|
|
|
|
for (k = 0; k < rowWire.num_keys; k++) {
|
|
|
|
tmp = fread(&keyWire, SIZEOF(xkmOverlayKeyDesc), 1, file);
|
|
|
|
nRead += tmp * SIZEOF(xkmOverlayKeyDesc);
|
|
|
|
memcpy(row->keys[k].over.name, keyWire.over, XkbKeyNameLength);
|
|
|
|
memcpy(row->keys[k].under.name, keyWire.under, XkbKeyNameLength);
|
|
|
|
}
|
|
|
|
row->num_keys = rowWire.num_keys;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
return nRead;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-03-21 20:55:09 +01:00
|
|
|
ReadXkmGeomSection(FILE * file, XkbGeometryPtr geom)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
register int i;
|
|
|
|
XkbSectionPtr section;
|
|
|
|
xkmSectionDesc sectionWire;
|
|
|
|
unsigned tmp;
|
|
|
|
int nRead = 0;
|
|
|
|
char buf[100];
|
|
|
|
Atom nameAtom;
|
|
|
|
|
|
|
|
nRead += XkmGetCountedString(file, buf, 100);
|
|
|
|
nameAtom = XkbInternAtom(buf, FALSE);
|
|
|
|
tmp = fread(§ionWire, SIZEOF(xkmSectionDesc), 1, file);
|
|
|
|
nRead += SIZEOF(xkmSectionDesc) * tmp;
|
|
|
|
section = XkbAddGeomSection(geom, nameAtom, sectionWire.num_rows,
|
|
|
|
sectionWire.num_doodads,
|
|
|
|
sectionWire.num_overlays);
|
2003-11-14 16:54:54 +01:00
|
|
|
if (!section) {
|
2012-03-21 20:55:09 +01:00
|
|
|
_XkbLibError(_XkbErrBadAlloc, "ReadXkmGeomSection", 0);
|
|
|
|
return nRead;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
section->top = sectionWire.top;
|
|
|
|
section->left = sectionWire.left;
|
|
|
|
section->width = sectionWire.width;
|
|
|
|
section->height = sectionWire.height;
|
|
|
|
section->angle = sectionWire.angle;
|
|
|
|
section->priority = sectionWire.priority;
|
|
|
|
if (sectionWire.num_rows > 0) {
|
|
|
|
register int k;
|
|
|
|
XkbRowPtr row;
|
|
|
|
xkmRowDesc rowWire;
|
|
|
|
XkbKeyPtr key;
|
|
|
|
xkmKeyDesc keyWire;
|
|
|
|
|
|
|
|
for (i = 0; i < sectionWire.num_rows; i++) {
|
|
|
|
tmp = fread(&rowWire, SIZEOF(xkmRowDesc), 1, file);
|
|
|
|
nRead += SIZEOF(xkmRowDesc) * tmp;
|
|
|
|
row = XkbAddGeomRow(section, rowWire.num_keys);
|
|
|
|
if (!row) {
|
|
|
|
_XkbLibError(_XkbErrBadAlloc, "ReadXkmKeycodes", 0);
|
|
|
|
return nRead;
|
|
|
|
}
|
|
|
|
row->top = rowWire.top;
|
|
|
|
row->left = rowWire.left;
|
|
|
|
row->vertical = rowWire.vertical;
|
|
|
|
for (k = 0; k < rowWire.num_keys; k++) {
|
|
|
|
tmp = fread(&keyWire, SIZEOF(xkmKeyDesc), 1, file);
|
|
|
|
nRead += SIZEOF(xkmKeyDesc) * tmp;
|
|
|
|
key = XkbAddGeomKey(row);
|
|
|
|
if (!key) {
|
|
|
|
_XkbLibError(_XkbErrBadAlloc, "ReadXkmGeomSection", 0);
|
|
|
|
return nRead;
|
|
|
|
}
|
|
|
|
memcpy(key->name.name, keyWire.name, XkbKeyNameLength);
|
|
|
|
key->gap = keyWire.gap;
|
|
|
|
key->shape_ndx = keyWire.shape_ndx;
|
|
|
|
key->color_ndx = keyWire.color_ndx;
|
|
|
|
}
|
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
if (sectionWire.num_doodads > 0) {
|
|
|
|
for (i = 0; i < sectionWire.num_doodads; i++) {
|
|
|
|
tmp = ReadXkmGeomDoodad(file, geom, section);
|
|
|
|
nRead += tmp;
|
|
|
|
if (tmp < 1)
|
|
|
|
return nRead;
|
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
if (sectionWire.num_overlays > 0) {
|
|
|
|
for (i = 0; i < sectionWire.num_overlays; i++) {
|
|
|
|
tmp = ReadXkmGeomOverlay(file, geom, section);
|
|
|
|
nRead += tmp;
|
|
|
|
if (tmp < 1)
|
|
|
|
return nRead;
|
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
return nRead;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-03-21 20:55:09 +01:00
|
|
|
ReadXkmGeometry(FILE * file, XkbDescPtr xkb)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
register int i;
|
|
|
|
char buf[100];
|
|
|
|
unsigned tmp;
|
|
|
|
int nRead = 0;
|
|
|
|
xkmGeometryDesc wireGeom;
|
|
|
|
XkbGeometryPtr geom;
|
|
|
|
XkbGeometrySizesRec sizes;
|
|
|
|
|
|
|
|
nRead += XkmGetCountedString(file, buf, 100);
|
|
|
|
tmp = fread(&wireGeom, SIZEOF(xkmGeometryDesc), 1, file);
|
|
|
|
nRead += tmp * SIZEOF(xkmGeometryDesc);
|
|
|
|
sizes.which = XkbGeomAllMask;
|
|
|
|
sizes.num_properties = wireGeom.num_properties;
|
|
|
|
sizes.num_colors = wireGeom.num_colors;
|
|
|
|
sizes.num_shapes = wireGeom.num_shapes;
|
|
|
|
sizes.num_sections = wireGeom.num_sections;
|
|
|
|
sizes.num_doodads = wireGeom.num_doodads;
|
|
|
|
sizes.num_key_aliases = wireGeom.num_key_aliases;
|
|
|
|
if (XkbAllocGeometry(xkb, &sizes) != Success) {
|
|
|
|
_XkbLibError(_XkbErrBadAlloc, "ReadXkmGeometry", 0);
|
|
|
|
return nRead;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
geom = xkb->geom;
|
|
|
|
geom->name = XkbInternAtom(buf, FALSE);
|
|
|
|
geom->width_mm = wireGeom.width_mm;
|
|
|
|
geom->height_mm = wireGeom.height_mm;
|
|
|
|
nRead += XkmGetCountedString(file, buf, 100);
|
|
|
|
geom->label_font = Xstrdup(buf);
|
|
|
|
if (wireGeom.num_properties > 0) {
|
|
|
|
char val[1024];
|
|
|
|
|
|
|
|
for (i = 0; i < wireGeom.num_properties; i++) {
|
|
|
|
nRead += XkmGetCountedString(file, buf, 100);
|
|
|
|
nRead += XkmGetCountedString(file, val, 1024);
|
|
|
|
if (XkbAddGeomProperty(geom, buf, val) == NULL) {
|
|
|
|
_XkbLibError(_XkbErrBadAlloc, "ReadXkmGeometry", 0);
|
|
|
|
return nRead;
|
|
|
|
}
|
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
if (wireGeom.num_colors > 0) {
|
|
|
|
for (i = 0; i < wireGeom.num_colors; i++) {
|
|
|
|
nRead += XkmGetCountedString(file, buf, 100);
|
|
|
|
if (XkbAddGeomColor(geom, buf, i) == NULL) {
|
|
|
|
_XkbLibError(_XkbErrBadAlloc, "ReadXkmGeometry", 0);
|
|
|
|
return nRead;
|
|
|
|
}
|
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
geom->base_color = &geom->colors[wireGeom.base_color_ndx];
|
|
|
|
geom->label_color = &geom->colors[wireGeom.label_color_ndx];
|
|
|
|
if (wireGeom.num_shapes > 0) {
|
|
|
|
XkbShapePtr shape;
|
|
|
|
xkmShapeDesc shapeWire;
|
|
|
|
Atom nameAtom;
|
|
|
|
|
|
|
|
for (i = 0; i < wireGeom.num_shapes; i++) {
|
|
|
|
register int n;
|
|
|
|
XkbOutlinePtr ol;
|
|
|
|
xkmOutlineDesc olWire;
|
|
|
|
|
|
|
|
nRead += XkmGetCountedString(file, buf, 100);
|
|
|
|
nameAtom = XkbInternAtom(buf, FALSE);
|
|
|
|
tmp = fread(&shapeWire, SIZEOF(xkmShapeDesc), 1, file);
|
|
|
|
nRead += tmp * SIZEOF(xkmShapeDesc);
|
|
|
|
shape = XkbAddGeomShape(geom, nameAtom, shapeWire.num_outlines);
|
|
|
|
if (!shape) {
|
|
|
|
_XkbLibError(_XkbErrBadAlloc, "ReadXkmGeometry", 0);
|
|
|
|
return nRead;
|
|
|
|
}
|
|
|
|
for (n = 0; n < shapeWire.num_outlines; n++) {
|
|
|
|
register int p;
|
|
|
|
xkmPointDesc ptWire;
|
|
|
|
|
|
|
|
tmp = fread(&olWire, SIZEOF(xkmOutlineDesc), 1, file);
|
|
|
|
nRead += tmp * SIZEOF(xkmOutlineDesc);
|
|
|
|
ol = XkbAddGeomOutline(shape, olWire.num_points);
|
|
|
|
if (!ol) {
|
|
|
|
_XkbLibError(_XkbErrBadAlloc, "ReadXkmGeometry", 0);
|
|
|
|
return nRead;
|
|
|
|
}
|
|
|
|
ol->num_points = olWire.num_points;
|
|
|
|
ol->corner_radius = olWire.corner_radius;
|
|
|
|
for (p = 0; p < olWire.num_points; p++) {
|
|
|
|
tmp = fread(&ptWire, SIZEOF(xkmPointDesc), 1, file);
|
|
|
|
nRead += tmp * SIZEOF(xkmPointDesc);
|
|
|
|
ol->points[p].x = ptWire.x;
|
|
|
|
ol->points[p].y = ptWire.y;
|
|
|
|
if (ptWire.x < shape->bounds.x1)
|
|
|
|
shape->bounds.x1 = ptWire.x;
|
|
|
|
if (ptWire.x > shape->bounds.x2)
|
|
|
|
shape->bounds.x2 = ptWire.x;
|
|
|
|
if (ptWire.y < shape->bounds.y1)
|
|
|
|
shape->bounds.y1 = ptWire.y;
|
|
|
|
if (ptWire.y > shape->bounds.y2)
|
|
|
|
shape->bounds.y2 = ptWire.y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (shapeWire.primary_ndx != XkbNoShape)
|
|
|
|
shape->primary = &shape->outlines[shapeWire.primary_ndx];
|
|
|
|
if (shapeWire.approx_ndx != XkbNoShape)
|
|
|
|
shape->approx = &shape->outlines[shapeWire.approx_ndx];
|
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
if (wireGeom.num_sections > 0) {
|
|
|
|
for (i = 0; i < wireGeom.num_sections; i++) {
|
|
|
|
tmp = ReadXkmGeomSection(file, geom);
|
|
|
|
nRead += tmp;
|
|
|
|
if (tmp == 0)
|
|
|
|
return nRead;
|
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
if (wireGeom.num_doodads > 0) {
|
|
|
|
for (i = 0; i < wireGeom.num_doodads; i++) {
|
|
|
|
tmp = ReadXkmGeomDoodad(file, geom, NULL);
|
|
|
|
nRead += tmp;
|
|
|
|
if (tmp == 0)
|
|
|
|
return nRead;
|
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
if ((wireGeom.num_key_aliases > 0) && (geom->key_aliases)) {
|
|
|
|
int sz = XkbKeyNameLength * 2;
|
|
|
|
int num = wireGeom.num_key_aliases;
|
|
|
|
|
|
|
|
if (fread(geom->key_aliases, sz, num, file) != num) {
|
|
|
|
_XkbLibError(_XkbErrBadLength, "ReadXkmGeometry", 0);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
nRead += (num * sz);
|
|
|
|
geom->num_key_aliases = num;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
return nRead;
|
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool
|
2012-03-21 20:55:09 +01:00
|
|
|
XkmProbe(FILE * file)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
unsigned hdr, tmp;
|
|
|
|
int nRead = 0;
|
|
|
|
|
|
|
|
hdr = (('x' << 24) | ('k' << 16) | ('m' << 8) | XkmFileVersion);
|
|
|
|
tmp = XkmGetCARD32(file, &nRead);
|
|
|
|
if (tmp != hdr) {
|
|
|
|
if ((tmp & (~0xff)) == (hdr & (~0xff))) {
|
|
|
|
_XkbLibError(_XkbErrBadFileVersion, "XkmProbe", tmp & 0xff);
|
|
|
|
}
|
|
|
|
return 0;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2008-11-30 05:59:34 +01:00
|
|
|
static Bool
|
2012-03-21 20:55:09 +01:00
|
|
|
XkmReadTOC(FILE * file, xkmFileInfo * file_info, int max_toc,
|
|
|
|
xkmSectionInfo * toc)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
unsigned hdr, tmp;
|
|
|
|
int nRead = 0;
|
|
|
|
unsigned i, size_toc;
|
|
|
|
|
|
|
|
hdr = (('x' << 24) | ('k' << 16) | ('m' << 8) | XkmFileVersion);
|
|
|
|
tmp = XkmGetCARD32(file, &nRead);
|
|
|
|
if (tmp != hdr) {
|
|
|
|
if ((tmp & (~0xff)) == (hdr & (~0xff))) {
|
|
|
|
_XkbLibError(_XkbErrBadFileVersion, "XkmReadTOC", tmp & 0xff);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
_XkbLibError(_XkbErrBadFileType, "XkmReadTOC", tmp);
|
|
|
|
}
|
|
|
|
return 0;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2014-04-19 00:12:14 +02:00
|
|
|
if (fread(file_info, SIZEOF(xkmFileInfo), 1, file) != 1)
|
|
|
|
return 0;
|
2012-03-21 20:55:09 +01:00
|
|
|
size_toc = file_info->num_toc;
|
|
|
|
if (size_toc > max_toc) {
|
|
|
|
DebugF("Warning! Too many TOC entries; last %d ignored\n",
|
|
|
|
size_toc - max_toc);
|
|
|
|
size_toc = max_toc;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
for (i = 0; i < size_toc; i++) {
|
2014-04-19 00:12:14 +02:00
|
|
|
if (fread(&toc[i], SIZEOF(xkmSectionInfo), 1, file) != 1)
|
|
|
|
return 0;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***====================================================================***/
|
|
|
|
|
|
|
|
#define MAX_TOC 16
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
unsigned
|
2012-03-21 20:55:09 +01:00
|
|
|
XkmReadFile(FILE * file, unsigned need, unsigned want, XkbDescPtr *xkb)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
register unsigned i;
|
|
|
|
xkmSectionInfo toc[MAX_TOC], tmpTOC;
|
|
|
|
xkmFileInfo fileInfo;
|
|
|
|
unsigned tmp, nRead = 0;
|
|
|
|
unsigned which = need | want;
|
|
|
|
|
|
|
|
if (!XkmReadTOC(file, &fileInfo, MAX_TOC, toc))
|
|
|
|
return which;
|
|
|
|
if ((fileInfo.present & need) != need) {
|
|
|
|
_XkbLibError(_XkbErrIllegalContents, "XkmReadFile",
|
|
|
|
need & (~fileInfo.present));
|
|
|
|
return which;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
if (*xkb == NULL)
|
|
|
|
*xkb = XkbAllocKeyboard();
|
|
|
|
for (i = 0; i < fileInfo.num_toc; i++) {
|
|
|
|
fseek(file, toc[i].offset, SEEK_SET);
|
|
|
|
tmp = fread(&tmpTOC, SIZEOF(xkmSectionInfo), 1, file);
|
|
|
|
nRead = tmp * SIZEOF(xkmSectionInfo);
|
|
|
|
if ((tmpTOC.type != toc[i].type) || (tmpTOC.format != toc[i].format) ||
|
|
|
|
(tmpTOC.size != toc[i].size) || (tmpTOC.offset != toc[i].offset)) {
|
|
|
|
return which;
|
|
|
|
}
|
|
|
|
if ((which & (1 << tmpTOC.type)) == 0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
switch (tmpTOC.type) {
|
|
|
|
case XkmVirtualModsIndex:
|
|
|
|
tmp = ReadXkmVirtualMods(file, *xkb, NULL);
|
|
|
|
break;
|
|
|
|
case XkmTypesIndex:
|
|
|
|
tmp = ReadXkmKeyTypes(file, *xkb, NULL);
|
|
|
|
break;
|
|
|
|
case XkmCompatMapIndex:
|
|
|
|
tmp = ReadXkmCompatMap(file, *xkb, NULL);
|
|
|
|
break;
|
|
|
|
case XkmKeyNamesIndex:
|
|
|
|
tmp = ReadXkmKeycodes(file, *xkb, NULL);
|
|
|
|
break;
|
|
|
|
case XkmIndicatorsIndex:
|
|
|
|
tmp = ReadXkmIndicators(file, *xkb, NULL);
|
|
|
|
break;
|
|
|
|
case XkmSymbolsIndex:
|
|
|
|
tmp = ReadXkmSymbols(file, *xkb);
|
|
|
|
break;
|
|
|
|
case XkmGeometryIndex:
|
|
|
|
tmp = ReadXkmGeometry(file, *xkb);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
_XkbLibError(_XkbErrBadImplementation,
|
|
|
|
XkbConfigText(tmpTOC.type, XkbMessage), 0);
|
|
|
|
tmp = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (tmp > 0) {
|
|
|
|
nRead += tmp;
|
|
|
|
which &= ~(1 << toc[i].type);
|
|
|
|
(*xkb)->defined |= (1 << toc[i].type);
|
|
|
|
}
|
|
|
|
if (nRead != tmpTOC.size) {
|
|
|
|
_XkbLibError(_XkbErrBadLength,
|
|
|
|
XkbConfigText(tmpTOC.type, XkbMessage),
|
|
|
|
nRead - tmpTOC.size);
|
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
return which;
|
|
|
|
}
|