Commit 3c5880e7 authored by Alan Coopersmith's avatar Alan Coopersmith Committed by Ulrich Sibiller

Reindent XKB code to X.Org standard style

parent 3cd82252
......@@ -34,7 +34,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
Bool
XkbDeviceBell( Display * dpy,
XkbDeviceBell(Display *dpy,
Window window,
int deviceID,
int bellClass,
......@@ -46,31 +46,32 @@ XkbDeviceBell( Display * dpy,
XkbInfoPtr xkbi;
if ((dpy->flags & XlibDisplayNoXkb) ||
(!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
(!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
return False;
LockDisplay(dpy);
xkbi = dpy->xkb_info;
GetReq(kbBell,req);
GetReq(kbBell, req);
req->reqType = xkbi->codes->major_opcode;
req->xkbReqType = X_kbBell;
req->deviceSpec = deviceID;
req->window = (CARD32)window;
req->bellClass = (CARD16)bellClass;
req->bellID = (CARD16)bellID;
req->window = (CARD32) window;
req->bellClass = (CARD16) bellClass;
req->bellID = (CARD16) bellID;
req->percent = percent;
req->forceSound = False;
req->eventOnly = False;
req->pitch = 0;
req->duration = 0;
req->name = (CARD32)name;
req->pad1= 0; req->pad2= 0;
req->name = (CARD32) name;
req->pad1 = 0;
req->pad2 = 0;
UnlockDisplay(dpy);
SyncHandle();
return True;
}
Bool
XkbForceDeviceBell( Display * dpy,
XkbForceDeviceBell(Display *dpy,
int deviceID,
int bellClass,
int bellID,
......@@ -80,31 +81,32 @@ XkbForceDeviceBell( Display * dpy,
XkbInfoPtr xkbi;
if ((dpy->flags & XlibDisplayNoXkb) ||
(!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
(!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
return False;
LockDisplay(dpy);
xkbi = dpy->xkb_info;
GetReq(kbBell,req);
GetReq(kbBell, req);
req->reqType = xkbi->codes->major_opcode;
req->xkbReqType = X_kbBell;
req->deviceSpec = deviceID;
req->window = (CARD32)None;
req->bellClass = (CARD16)bellClass;
req->bellID = (CARD16)bellID;
req->window = (CARD32) None;
req->bellClass = (CARD16) bellClass;
req->bellID = (CARD16) bellID;
req->percent = percent;
req->forceSound = True;
req->eventOnly = False;
req->pitch = 0;
req->duration = 0;
req->name = None;
req->pad1= 0; req->pad2= 0;
req->pad1 = 0;
req->pad2 = 0;
UnlockDisplay(dpy);
SyncHandle();
return True;
}
Bool
XkbDeviceBellEvent( Display * dpy,
XkbDeviceBellEvent(Display *dpy,
Window window,
int deviceID,
int bellClass,
......@@ -116,63 +118,62 @@ XkbDeviceBellEvent( Display * dpy,
XkbInfoPtr xkbi;
if ((dpy->flags & XlibDisplayNoXkb) ||
(!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
(!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
return False;
LockDisplay(dpy);
xkbi = dpy->xkb_info;
GetReq(kbBell,req);
GetReq(kbBell, req);
req->reqType = xkbi->codes->major_opcode;
req->xkbReqType = X_kbBell;
req->deviceSpec = deviceID;
req->window = (CARD32)window;
req->bellClass = (CARD16)bellClass;
req->bellID = (CARD16)bellID;
req->window = (CARD32) window;
req->bellClass = (CARD16) bellClass;
req->bellID = (CARD16) bellID;
req->percent = percent;
req->forceSound = False;
req->eventOnly = True;
req->pitch = 0;
req->duration = 0;
req->name = (CARD32)name;
req->pad1= 0; req->pad2= 0;
req->name = (CARD32) name;
req->pad1 = 0;
req->pad2 = 0;
UnlockDisplay(dpy);
SyncHandle();
return True;
}
Bool
XkbBell(Display *dpy,Window window,int percent,Atom name)
XkbBell(Display *dpy, Window window, int percent, Atom name)
{
if ((dpy->flags & XlibDisplayNoXkb) ||
(!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL))) {
XBell(dpy,percent);
(!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL))) {
XBell(dpy, percent);
return False;
}
return XkbDeviceBell(dpy,window,XkbUseCoreKbd,XkbDfltXIClass,XkbDfltXIId,
percent,name);
return XkbDeviceBell(dpy, window, XkbUseCoreKbd,
XkbDfltXIClass, XkbDfltXIId, percent, name);
}
Bool
XkbForceBell(Display *dpy,int percent)
XkbForceBell(Display *dpy, int percent)
{
if ((dpy->flags & XlibDisplayNoXkb) ||
(!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL))) {
XBell(dpy,percent);
(!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL))) {
XBell(dpy, percent);
return False;
}
return XkbForceDeviceBell(dpy,XkbUseCoreKbd,XkbDfltXIClass,XkbDfltXIId,
return XkbForceDeviceBell(dpy, XkbUseCoreKbd, XkbDfltXIClass, XkbDfltXIId,
percent);
}
Bool
XkbBellEvent(Display *dpy,Window window,int percent,Atom name)
XkbBellEvent(Display *dpy, Window window, int percent, Atom name)
{
if ((dpy->flags & XlibDisplayNoXkb) ||
(!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL))) {
(!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL))) {
return False;
}
/* class 0 = KbdFeedbackClass (X Input Extension) */
return XkbDeviceBellEvent(dpy,window,XkbUseCoreKbd,
XkbDfltXIClass,XkbDfltXIId,
percent,name);
return XkbDeviceBellEvent(dpy, window, XkbUseCoreKbd,
XkbDfltXIClass, XkbDfltXIId, percent, name);
}
......@@ -64,40 +64,40 @@ _XkbHandleSpecialSym(KeySym keysym, char *buffer, int nbytes, int *extra_rtrn)
(keysym == XK_KP_Space) || (keysym == XK_KP_Tab) ||
(keysym == XK_KP_Enter) ||
((keysym >= XK_KP_Multiply) && (keysym <= XK_KP_9)) ||
(keysym == XK_KP_Equal) ||
(keysym == XK_Delete)))
(keysym == XK_KP_Equal) || (keysym == XK_Delete)))
return 0;
if (nbytes<1) {
if (nbytes < 1) {
if (extra_rtrn)
*extra_rtrn= 1;
*extra_rtrn = 1;
return 0;
}
/* if X keysym, convert to ascii by grabbing low 7 bits */
if (keysym == XK_KP_Space)
buffer[0] = XK_space & 0x7F; /* patch encoding botch */
else if (keysym == XK_hyphen)
buffer[0] = (char)(XK_minus & 0xFF); /* map to equiv character */
else buffer[0] = (char)(keysym & 0x7F);
buffer[0] = (char) (XK_minus & 0xFF); /* map to equiv character */
else
buffer[0] = (char) (keysym & 0x7F);
return 1;
}
/*ARGSUSED*/
static int
_XkbKSToKnownSet ( XPointer priv,
_XkbKSToKnownSet(XPointer priv,
KeySym keysym,
char * buffer,
char *buffer,
int nbytes,
int * extra_rtrn)
int *extra_rtrn)
{
char tbuf[8],*buf;
char tbuf[8], *buf;
if (extra_rtrn)
*extra_rtrn= 0;
*extra_rtrn = 0;
/* convert "dead" diacriticals for dumb applications */
if ( (keysym&0xffffff00)== 0xfe00 ) {
switch ( keysym ) {
if ((keysym & 0xffffff00) == 0xfe00) {
switch (keysym) {
case XK_dead_grave: keysym = XK_grave; break;
case XK_dead_acute: keysym = XK_acute; break;
case XK_dead_circumflex: keysym = XK_asciicircum; break;
......@@ -110,22 +110,24 @@ _XkbKSToKnownSet ( XPointer priv,
case XK_dead_doubleacute: keysym = XK_doubleacute; break;
case XK_dead_caron: keysym = XK_caron; break;
case XK_dead_cedilla: keysym = XK_cedilla; break;
case XK_dead_ogonek : keysym = XK_ogonek; break;
case XK_dead_ogonek: keysym = XK_ogonek; break;
case XK_dead_iota: keysym = XK_Greek_iota; break;
#ifdef XK_KATAKANA
case XK_dead_voiced_sound: keysym = XK_voicedsound; break;
case XK_dead_semivoiced_sound:keysym = XK_semivoicedsound; break;
case XK_dead_semivoiced_sound: keysym = XK_semivoicedsound; break;
#endif
}
}
if (nbytes<1) buf= tbuf;
else buf= buffer;
if (nbytes < 1)
buf = tbuf;
else
buf = buffer;
if ((keysym&0xffffff00)==0xff00) {
if ((keysym & 0xffffff00) == 0xff00) {
return _XkbHandleSpecialSym(keysym, buf, nbytes, extra_rtrn);
}
return _XimGetCharCode (priv, keysym, (unsigned char *)buf, nbytes);
return _XimGetCharCode(priv, keysym, (unsigned char *) buf, nbytes);
}
typedef struct _XkbToKS {
......@@ -135,17 +137,20 @@ typedef struct _XkbToKS {
/*ARGSUSED*/
static KeySym
_XkbKnownSetToKS(XPointer priv,char *buffer,int nbytes,Status *status)
_XkbKnownSetToKS(XPointer priv, char *buffer, int nbytes, Status *status)
{
if (nbytes!=1)
if (nbytes != 1)
return NoSymbol;
if (((buffer[0]&0x80)==0)&&(buffer[0]>=32))
if (((buffer[0] & 0x80) == 0) && (buffer[0] >= 32))
return buffer[0];
else if ((buffer[0]&0x7f)>=32) {
XkbToKS *map= (XkbToKS *)priv;
if ( map ) {
if ( map->map ) return map->prefix|map->map[buffer[0]&0x7f];
else return map->prefix|buffer[0];
else if ((buffer[0] & 0x7f) >= 32) {
XkbToKS *map = (XkbToKS *) priv;
if (map) {
if (map->map)
return map->prefix | map->map[buffer[0] & 0x7f];
else
return map->prefix | buffer[0];
}
return buffer[0];
}
......@@ -155,7 +160,7 @@ _XkbKnownSetToKS(XPointer priv,char *buffer,int nbytes,Status *status)
static KeySym
__XkbDefaultToUpper(KeySym sym)
{
KeySym lower,upper;
KeySym lower, upper;
XConvertCase(sym, &lower, &upper);
return upper;
......@@ -175,7 +180,7 @@ Strcmp(char *str1, char *str2)
if (strlen(str1) >= sizeof(str)) /* almost certain it's a mismatch */
return 1;
for (s = str; (c = *str1++); ) {
for (s = str; (c = *str1++);) {
if (isupper(c))
c = tolower(c);
*s++ = c;
......@@ -186,9 +191,10 @@ Strcmp(char *str1, char *str2)
#endif
int
_XkbGetConverters(const char *encoding_name, XkbConverters *cvt_rtrn)
_XkbGetConverters(const char *encoding_name, XkbConverters * cvt_rtrn)
{
if ( !cvt_rtrn ) return 0;
if (!cvt_rtrn)
return 0;
cvt_rtrn->KSToMB = _XkbKSToKnownSet;
cvt_rtrn->KSToMBPriv = _XimGetLocaleCode(encoding_name);
......@@ -214,7 +220,12 @@ _XkbGetConverters(const char *encoding_name, XkbConverters *cvt_rtrn)
*/
#define CHARSET_FILE "/usr/lib/X11/input/charsets"
static char *_XkbKnownLanguages = "c=ascii:da,de,en,es,fr,is,it,nl,no,pt,sv=iso8859-1:hu,pl,cs=iso8859-2:eo=iso8859-3:sp=iso8859-5:ar,ara=iso8859-6:el=iso8859-7:he=iso8859-8:tr=iso8859-9:lt,lv=iso8859-13:et,fi=iso8859-15:ru=koi8-r:uk=koi8-u:th,th_TH,th_TH.iso8859-11=iso8859-11:th_TH.TIS620=tis620:hy=armscii-8:vi=tcvn-5712:ka=georgian-academy:be,bg=microsoft-cp1251";
static char *_XkbKnownLanguages =
"c=ascii:da,de,en,es,fr,is,it,nl,no,pt,sv=iso8859-1:hu,pl,cs=iso8859-2:"
"eo=iso8859-3:sp=iso8859-5:ar,ara=iso8859-6:el=iso8859-7:he=iso8859-8:"
"tr=iso8859-9:lt,lv=iso8859-13:et,fi=iso8859-15:ru=koi8-r:uk=koi8-u:"
"th,th_TH,th_TH.iso8859-11=iso8859-11:th_TH.TIS620=tis620:hy=armscii-8:"
"vi=tcvn-5712:ka=georgian-academy:be,bg=microsoft-cp1251";
char *
_XkbGetCharset(void)
......@@ -225,16 +236,16 @@ _XkbGetCharset(void)
*/
static char buf[100] = { 0 };
char lang[256];
char *start,*tmp,*end,*next,*set;
char *country,*charset;
char *start, *tmp, *end, *next, *set;
char *country, *charset;
char *locale;
tmp = getenv( "_XKB_CHARSET" );
if ( tmp )
tmp = getenv("_XKB_CHARSET");
if (tmp)
return tmp;
locale = setlocale(LC_CTYPE,NULL);
locale = setlocale(LC_CTYPE, NULL);
if ( locale == NULL )
if (locale == NULL)
return NULL;
if (strlen(locale) >= sizeof(lang))
......@@ -244,13 +255,14 @@ _XkbGetCharset(void)
if (isupper(*tmp))
*tmp = tolower(*tmp);
}
country = strchr( lang, '_');
if ( country ) {
country = strchr(lang, '_');
if (country) {
*country++ = '\0';
charset = strchr( country, '.' );
if ( charset ) *charset++ = '\0';
if ( charset ) {
strncpy(buf,charset,99);
charset = strchr(country, '.');
if (charset)
*charset++ = '\0';
if (charset) {
strncpy(buf, charset, 99);
buf[99] = '\0';
return buf;
}
......@@ -259,11 +271,12 @@ _XkbGetCharset(void)
charset = NULL;
}
if ((tmp = getenv("_XKB_LOCALE_CHARSETS"))!=NULL) {
if ((tmp = getenv("_XKB_LOCALE_CHARSETS")) != NULL) {
start = _XkbAlloc(strlen(tmp) + 1);
strcpy(start, tmp);
tmp = start;
} else {
}
else {
struct stat sbuf;
FILE *file;
#ifndef __UNIXOS2__
......@@ -276,18 +289,18 @@ _XkbGetCharset(void)
# define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
#endif
if ( (stat(cf,&sbuf)==0) && S_ISREG(sbuf.st_mode) &&
(file = fopen(cf,"r")) ) {
tmp = _XkbAlloc(sbuf.st_size+1);
if (tmp!=NULL) {
sbuf.st_size = (long)fread(tmp,1,sbuf.st_size,file);
if ((stat(cf, &sbuf) == 0) && S_ISREG(sbuf.st_mode) &&
(file = fopen(cf, "r"))) {
tmp = _XkbAlloc(sbuf.st_size + 1);
if (tmp != NULL) {
sbuf.st_size = (long) fread(tmp, 1, sbuf.st_size, file);
tmp[sbuf.st_size] = '\0';
}
fclose(file);
}
}
if ( tmp == NULL ) {
if (tmp == NULL) {
tmp = _XkbAlloc(strlen(_XkbKnownLanguages) + 1);
if (!tmp)
return NULL;
......@@ -295,16 +308,16 @@ _XkbGetCharset(void)
}
start = tmp;
do {
if ( (set=strchr(tmp,'=')) == NULL )
if ((set = strchr(tmp, '=')) == NULL)
break;
*set++ = '\0';
if ( (next=strchr(set,':')) != NULL )
if ((next = strchr(set, ':')) != NULL)
*next++ = '\0';
while ( tmp && *tmp ) {
if ( (end=strchr(tmp,',')) != NULL )
while (tmp && *tmp) {
if ((end = strchr(tmp, ',')) != NULL)
*end++ = '\0';
if ( Strcmp( tmp, lang ) == 0 ) {
strncpy(buf,set,100);
if (Strcmp(tmp, lang) == 0) {
strncpy(buf, set, 100);
buf[99] = '\0';
Xfree(start);
return buf;
......@@ -312,7 +325,7 @@ _XkbGetCharset(void)
tmp = end;
}
tmp = next;
} while ( tmp && *tmp );
} while (tmp && *tmp);
Xfree(start);
return NULL;
}
......@@ -323,15 +336,14 @@ _XkbGetCharset(void)
char *tmp;
XLCd lcd;
tmp = getenv( "_XKB_CHARSET" );
if ( tmp )
tmp = getenv("_XKB_CHARSET");
if (tmp)
return tmp;
lcd = _XlcCurrentLC();
if ( lcd )
return XLC_PUBLIC(lcd,encoding_name);
if (lcd)
return XLC_PUBLIC(lcd, encoding_name);
return NULL;
}
#endif
......@@ -35,32 +35,32 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
/***====================================================================***/
XkbDescPtr
XkbGetKeyboardByName( Display * dpy,
XkbGetKeyboardByName(Display *dpy,
unsigned deviceSpec,
XkbComponentNamesPtr names,
unsigned want,
unsigned need,
Bool load)
{
register xkbGetKbdByNameReq * req;
register xkbGetKbdByNameReq *req;
xkbGetKbdByNameReply rep;
int len,extraLen;
char * str;
int len, extraLen;
char *str;
XkbDescPtr xkb;
int mapLen,codesLen,typesLen,compatLen;
int symsLen,geomLen;
int mapLen, codesLen, typesLen, compatLen;
int symsLen, geomLen;
XkbInfoPtr xkbi;
if ( (dpy==NULL) || (dpy->flags & XlibDisplayNoXkb) ||
(!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)) )
if ((dpy == NULL) || (dpy->flags & XlibDisplayNoXkb) ||
(!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
return NULL;
xkbi= dpy->xkb_info;
xkb = (XkbDescRec *)_XkbCalloc(1,sizeof(XkbDescRec));
xkbi = dpy->xkb_info;
xkb = (XkbDescRec *) _XkbCalloc(1, sizeof(XkbDescRec));
if (!xkb)
return NULL;
xkb->device_spec = deviceSpec;
xkb->map = (XkbClientMapRec *)_XkbCalloc(1,sizeof(XkbClientMapRec));
xkb->map = (XkbClientMapRec *) _XkbCalloc(1, sizeof(XkbClientMapRec));
xkb->dpy = dpy;
LockDisplay(dpy);
......@@ -68,147 +68,155 @@ XkbGetKeyboardByName( Display * dpy,
req->reqType = xkbi->codes->major_opcode;
req->xkbReqType = X_kbGetKbdByName;
req->deviceSpec = xkb->device_spec;
req->want= want;
req->need= need;
req->load= load;
req->want = want;
req->need = need;
req->load = load;
mapLen= codesLen= typesLen= compatLen= symsLen= geomLen= 0;
mapLen = codesLen = typesLen = compatLen = symsLen = geomLen = 0;
if (names) {
if (names->keymap)
mapLen= (int)strlen(names->keymap);
mapLen = (int) strlen(names->keymap);
if (names->keycodes)
codesLen= (int)strlen(names->keycodes);
codesLen = (int) strlen(names->keycodes);
if (names->types)
typesLen= (int)strlen(names->types);
typesLen = (int) strlen(names->types);
if (names->compat)
compatLen= (int)strlen(names->compat);
compatLen = (int) strlen(names->compat);
if (names->symbols)
symsLen= (int)strlen(names->symbols);
symsLen = (int) strlen(names->symbols);
if (names->geometry)
geomLen= (int)strlen(names->geometry);
if (mapLen>255) mapLen= 255;
if (codesLen>255) codesLen= 255;
if (typesLen>255) typesLen= 255;
if (compatLen>255) compatLen= 255;
if (symsLen>255) symsLen= 255;
if (geomLen>255) geomLen= 255;
geomLen = (int) strlen(names->geometry);
if (mapLen > 255)
mapLen = 255;
if (codesLen > 255)
codesLen = 255;
if (typesLen > 255)
typesLen = 255;
if (compatLen > 255)
compatLen = 255;
if (symsLen > 255)
symsLen = 255;
if (geomLen > 255)
geomLen = 255;
}
else mapLen= codesLen= typesLen= compatLen= symsLen= geomLen= 0;
len= mapLen+codesLen+typesLen+compatLen+symsLen+geomLen+6;
len= XkbPaddedSize(len);
req->length+= len/4;
BufAlloc(char *,str,len);
*str++= mapLen;
if (mapLen>0) {
memcpy(str,names->keymap,mapLen);
str+= mapLen;
else
mapLen = codesLen = typesLen = compatLen = symsLen = geomLen = 0;
len = mapLen + codesLen + typesLen + compatLen + symsLen + geomLen + 6;
len = XkbPaddedSize(len);
req->length += len / 4;
BufAlloc(char *, str, len);
*str++ = mapLen;
if (mapLen > 0) {
memcpy(str, names->keymap, mapLen);
str += mapLen;
}
*str++= codesLen;
if (codesLen>0) {
memcpy(str,names->keycodes,codesLen);
str+= codesLen;
*str++ = codesLen;
if (codesLen > 0) {
memcpy(str, names->keycodes, codesLen);
str += codesLen;
}
*str++= typesLen;
if (typesLen>0) {
memcpy(str,names->types,typesLen);
str+= typesLen;
*str++ = typesLen;
if (typesLen > 0) {
memcpy(str, names->types, typesLen);
str += typesLen;
}
*str++= compatLen;
if (compatLen>0) {
memcpy(str,names->compat,compatLen);
str+= compatLen;
*str++ = compatLen;
if (compatLen > 0) {
memcpy(str, names->compat, compatLen);
str += compatLen;
}
*str++= symsLen;
if (symsLen>0) {
memcpy(str,names->symbols,symsLen);
str+= symsLen;
*str++ = symsLen;
if (symsLen > 0) {
memcpy(str, names->symbols, symsLen);
str += symsLen;
}
*str++= geomLen;
if (geomLen>0) {
memcpy(str,names->geometry,geomLen);
str+= geomLen;
*str++ = geomLen;
if (geomLen > 0) {
memcpy(str, names->geometry, geomLen);
str += geomLen;
}
if ((!_XReply(dpy, (xReply *)&rep, 0, xFalse))||(!rep.reported))
if ((!_XReply(dpy, (xReply *) &rep, 0, xFalse)) || (!rep.reported))
goto BAILOUT;
extraLen= (int)rep.length*4;
extraLen = (int) rep.length * 4;
xkb->device_spec= rep.deviceID;
xkb->device_spec = rep.deviceID;
xkb->min_key_code = rep.minKeyCode;
xkb->max_key_code = rep.maxKeyCode;
if (rep.reported&(XkbGBN_SymbolsMask|XkbGBN_TypesMask)) {
if (rep.reported & (XkbGBN_SymbolsMask | XkbGBN_TypesMask)) {
xkbGetMapReply mrep;
Status status;
int nread= 0;
int nread = 0;
_XRead(dpy, (char *)&mrep, SIZEOF(xkbGetMapReply));
extraLen-= SIZEOF(xkbGetMapReply);
status= _XkbReadGetMapReply(dpy,&mrep,xkb,&nread);
extraLen-= nread;
if (status!=Success)
_XRead(dpy, (char *) &mrep, SIZEOF(xkbGetMapReply));
extraLen -= SIZEOF(xkbGetMapReply);
status = _XkbReadGetMapReply(dpy, &mrep, xkb, &nread);
extraLen -= nread;
if (status != Success)
goto BAILOUT;
}
if (rep.reported&XkbGBN_CompatMapMask) {
if (rep.reported & XkbGBN_CompatMapMask) {
xkbGetCompatMapReply crep;
Status status;
int nread= 0;
int nread = 0;
_XRead(dpy, (char *)&crep, SIZEOF(xkbGetCompatMapReply));
extraLen-= SIZEOF(xkbGetCompatMapReply);
status= _XkbReadGetCompatMapReply(dpy,&crep,xkb,&nread);
extraLen-= nread;
if (status!=Success)
_XRead(dpy, (char *) &crep, SIZEOF(xkbGetCompatMapReply));
extraLen -= SIZEOF(xkbGetCompatMapReply);
status = _XkbReadGetCompatMapReply(dpy, &crep, xkb, &nread);
extraLen -= nread;
if (status != Success)
goto BAILOUT;
}
if (rep.reported&XkbGBN_IndicatorMapMask) {
if (rep.reported & XkbGBN_IndicatorMapMask) {
xkbGetIndicatorMapReply irep;
Status status;
int nread= 0;
int nread = 0;
_XRead(dpy, (char *)&irep, SIZEOF(xkbGetIndicatorMapReply));
extraLen-= SIZEOF(xkbGetIndicatorMapReply);
status= _XkbReadGetIndicatorMapReply(dpy,&irep,xkb,&nread);
extraLen-= nread;
if (status!=Success)
_XRead(dpy, (char *) &irep, SIZEOF(xkbGetIndicatorMapReply));
extraLen -= SIZEOF(xkbGetIndicatorMapReply);
status = _XkbReadGetIndicatorMapReply(dpy, &irep, xkb, &nread);
extraLen -= nread;
if (status != Success)
goto BAILOUT;
}
if (rep.reported&(XkbGBN_KeyNamesMask|XkbGBN_OtherNamesMask)) {
if (rep.reported & (XkbGBN_KeyNamesMask | XkbGBN_OtherNamesMask)) {
xkbGetNamesReply nrep;
Status status;
int nread= 0;
int nread = 0;
_XRead(dpy, (char *)&nrep, SIZEOF(xkbGetNamesReply));
extraLen-= SIZEOF(xkbGetNamesReply);
status= _XkbReadGetNamesReply(dpy,&nrep,xkb,&nread);
extraLen-= nread;
if (status!=Success)
_XRead(dpy, (char *) &nrep, SIZEOF(xkbGetNamesReply));
extraLen -= SIZEOF(xkbGetNamesReply);
status = _XkbReadGetNamesReply(dpy, &nrep, xkb, &nread);
extraLen -= nread;
if (status != Success)
goto BAILOUT;
}
if (rep.reported&XkbGBN_GeometryMask) {
if (rep.reported & XkbGBN_GeometryMask) {
xkbGetGeometryReply grep;
Status status;
int nread= 0;
int nread = 0;
_XRead(dpy, (char *)&grep, SIZEOF(xkbGetGeometryReply));
extraLen-= SIZEOF(xkbGetGeometryReply);
status= _XkbReadGetGeometryReply(dpy,&grep,xkb,&nread);
extraLen-= nread;
if (status!=Success)
_XRead(dpy, (char *) &grep, SIZEOF(xkbGetGeometryReply));
extraLen -= SIZEOF(xkbGetGeometryReply);
status = _XkbReadGetGeometryReply(dpy, &grep, xkb, &nread);
extraLen -= nread;
if (status != Success)
goto BAILOUT;
}
UnlockDisplay(dpy);
SyncHandle();
return xkb;
BAILOUT:
if (xkb!=NULL)
XkbFreeKeyboard(xkb,XkbAllComponentsMask,xTrue);
BAILOUT:
if (xkb != NULL)
XkbFreeKeyboard(xkb, XkbAllComponentsMask, xTrue);
UnlockDisplay(dpy);
SyncHandle();
return NULL;
}
XkbDescPtr
XkbGetKeyboard(Display *dpy,unsigned which,unsigned deviceSpec)
XkbGetKeyboard(Display *dpy, unsigned which, unsigned deviceSpec)
{
return XkbGetKeyboardByName(dpy,deviceSpec,NULL,which,which,False);
return XkbGetKeyboardByName(dpy, deviceSpec, NULL, which, which, False);
}
......@@ -35,12 +35,12 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
/***====================================================================***/
int
_XkbInitReadBuffer(Display *dpy,XkbReadBufferPtr buf,int size)
_XkbInitReadBuffer(Display *dpy, XkbReadBufferPtr buf, int size)
{
if ((dpy!=NULL) && (buf!=NULL) && (size>0)) {
buf->error= 0;
buf->size= size;
buf->start= buf->data= _XkbAlloc(size);
if ((dpy != NULL) && (buf != NULL) && (size > 0)) {
buf->error = 0;
buf->size = size;
buf->start = buf->data = _XkbAlloc(size);
if (buf->start) {
_XRead(dpy, buf->start, size);
return 1;
......@@ -52,56 +52,55 @@ _XkbInitReadBuffer(Display *dpy,XkbReadBufferPtr buf,int size)
#define _XkbReadBufferDataLeft(b) (((b)->size)-((b)->data-(b)->start))
int
_XkbSkipReadBufferData(XkbReadBufferPtr from,int size)
_XkbSkipReadBufferData(XkbReadBufferPtr from, int size)
{
if (size==0)
if (size == 0)
return 1;
if ((from==NULL)||(from->error)||(size<1)||
(_XkbReadBufferDataLeft(from)<size))
if ((from == NULL) || (from->error) || (size < 1) ||
(_XkbReadBufferDataLeft(from) < size))
return 0;
from->data+= size;
from->data += size;
return 1;
}
int
_XkbCopyFromReadBuffer(XkbReadBufferPtr from,char *to,int size)
_XkbCopyFromReadBuffer(XkbReadBufferPtr from, char *to, int size)
{
if (size==0)
if (size == 0)
return 1;
if ((from==NULL)||(from->error)||(to==NULL)||(size<1)||
(_XkbReadBufferDataLeft(from)<size))
if ((from == NULL) || (from->error) || (to == NULL) || (size < 1) ||
(_XkbReadBufferDataLeft(from) < size))
return 0;
memcpy(to,from->data,size);
from->data+= size;
memcpy(to, from->data, size);
from->data += size;
return 1;
}
#ifdef XKB_FORCE_INT_KEYSYM
int
_XkbReadCopyKeySyms(int *wire,KeySym *to,int num_words)
_XkbReadCopyKeySyms(int *wire, KeySym * to, int num_words)
{
while (num_words-->0) {
*to++= *wire++;
while (num_words-- > 0) {
*to++ = *wire++;
}
return 1;
}
int
_XkbReadBufferCopyKeySyms(XkbReadBufferPtr from,KeySym *to,int num_words)
_XkbReadBufferCopyKeySyms(XkbReadBufferPtr from, KeySym * to, int num_words)
{
if ((unsigned)(num_words*4)>_XkbReadBufferDataLeft(from))
if ((unsigned) (num_words * 4) > _XkbReadBufferDataLeft(from))
return 0;
_XkbReadCopyKeySyms((int *)from->data,to,num_words);
from->data+= (4*num_words);
_XkbReadCopyKeySyms((int *) from->data, to, num_words);
from->data += (4 * num_words);
return True;
}
int
_XkbWriteCopyKeySyms (register KeySym *from,CARD32 *to,int len)
_XkbWriteCopyKeySyms(register KeySym * from, CARD32 *to, int len)
{
while (len-->0) {
*to++= (CARD32)*from++;
while (len-- > 0) {
*to++ = (CARD32) *from++;
}
return True;
}
......@@ -109,30 +108,29 @@ _XkbWriteCopyKeySyms (register KeySym *from,CARD32 *to,int len)
#ifdef LONG64
int
_XkbReadCopyData32(int *wire,long *to,int num_words)
_XkbReadCopyData32(int *wire, long *to, int num_words)
{
while (num_words-->0) {
*to++= *wire++;
while (num_words-- > 0) {
*to++ = *wire++;
}
return 1;
}
int
_XkbReadBufferCopy32(XkbReadBufferPtr from,long *to,int num_words)
_XkbReadBufferCopy32(XkbReadBufferPtr from, long *to, int num_words)
{
if ((unsigned)(num_words*4)>_XkbReadBufferDataLeft(from))
if ((unsigned) (num_words * 4) > _XkbReadBufferDataLeft(from))
return 0;
_XkbReadCopyData32((int *)from->data,to,num_words);
from->data+= (4*num_words);
_XkbReadCopyData32((int *) from->data, to, num_words);
from->data += (4 * num_words);
return True;
}
int
_XkbWriteCopyData32 (register unsigned long *from,CARD32 *to,int len)
_XkbWriteCopyData32(register unsigned long *from, CARD32 *to, int len)
{
while (len-->0) {
*to++= (CARD32)*from++;
while (len-- > 0) {
*to++ = (CARD32) *from++;
}
return True;
}
......@@ -140,23 +138,24 @@ _XkbWriteCopyData32 (register unsigned long *from,CARD32 *to,int len)
char *
_XkbPeekAtReadBuffer(XkbReadBufferPtr from,int size)
_XkbPeekAtReadBuffer(XkbReadBufferPtr from, int size)
{
if ((from==NULL)||(from->error)||(size<1)||
(_XkbReadBufferDataLeft(from)<size))
if ((from == NULL) || (from->error) || (size < 1) ||
(_XkbReadBufferDataLeft(from) < size))
return NULL;
return from->data;
}
char *
_XkbGetReadBufferPtr(XkbReadBufferPtr from,int size)
_XkbGetReadBufferPtr(XkbReadBufferPtr from, int size)
{
char *ptr;
if ((from==NULL)||(from->error)||(size<1)||
(_XkbReadBufferDataLeft(from)<size))
char *ptr;
if ((from == NULL) || (from->error) || (size < 1) ||
(_XkbReadBufferDataLeft(from) < size))
return NULL;
ptr= from->data;
from->data+= size;
ptr = from->data;
from->data += size;
return ptr;
}
......@@ -164,39 +163,41 @@ char *ptr;
int
_XkbFreeReadBuffer(XkbReadBufferPtr buf)
{
if ((buf!=NULL) && (buf->start!=NULL)) {
if ((buf != NULL) && (buf->start != NULL)) {
int left;
left= (int)_XkbReadBufferDataLeft(buf);
if (buf->start!=NULL)
left = (int) _XkbReadBufferDataLeft(buf);
if (buf->start != NULL)
Xfree(buf->start);
buf->size= 0;
buf->start= buf->data= NULL;
buf->size = 0;
buf->start = buf->data = NULL;
return left;
}
return 0;
}
Bool
_XkbGetReadBufferCountedString(XkbReadBufferPtr buf,char **rtrn)
_XkbGetReadBufferCountedString(XkbReadBufferPtr buf, char **rtrn)
{
CARD16 len,*pLen;
int left;
char * str = NULL;
CARD16 len, *pLen;
int left;
char *str = NULL;
if ((buf==NULL)||(buf->error)||((left=(int)_XkbReadBufferDataLeft(buf))<4))
if ((buf == NULL) || (buf->error) ||
((left = (int) _XkbReadBufferDataLeft(buf)) < 4))
return False;
pLen= (CARD16 *)buf->data;
len= *pLen;
if (len>0) {
if (XkbPaddedSize(len+2)>left)
pLen = (CARD16 *) buf->data;
len = *pLen;
if (len > 0) {
if (XkbPaddedSize(len + 2) > left)
return False;
str= _XkbAlloc(len+1);
str = _XkbAlloc(len + 1);
if (str) {
memcpy(str,&buf->data[2],len);
str[len]= '\0';
memcpy(str, &buf->data[2], len);
str[len] = '\0';
}
}
buf->data+= XkbPaddedSize(len+2);
*rtrn= str;
buf->data += XkbPaddedSize(len + 2);
*rtrn = str;
return True;
}
......@@ -81,19 +81,19 @@ typedef struct _XkbInfoRec {
#define _XkbUnavailable(d) \
(((d)->flags&XlibDisplayNoXkb) ||\
(((d)->flags&XlibDisplayNoXkb) || \
((!(d)->xkb_info || (!(d)->xkb_info->desc)) && !_XkbLoadDpy(d)))
#define _XkbCheckPendingRefresh(d,xi) {\
if ((xi)->flags&XkbXlibNewKeyboard)\
_XkbReloadDpy((d));\
else if ((xi)->flags&XkbMapPending) {\
if (XkbGetMapChanges((d),(xi)->desc, &(xi)->changes)==Success) {\
LockDisplay((d));\
(xi)->changes.changed= 0;\
UnlockDisplay((d));\
}\
}\
#define _XkbCheckPendingRefresh(d,xi) { \
if ((xi)->flags&XkbXlibNewKeyboard) \
_XkbReloadDpy((d)); \
else if ((xi)->flags&XkbMapPending) { \
if (XkbGetMapChanges((d),(xi)->desc, &(xi)->changes)==Success) { \
LockDisplay((d)); \
(xi)->changes.changed= 0; \
UnlockDisplay((d)); \
} \
} \
}
#define _XkbNeedModmap(i) ((!(i)->desc->map)||(!(i)->desc->map->modmap))
......@@ -112,7 +112,7 @@ typedef struct _XkbReadBuffer {
int size;
char *start;
char *data;
} XkbReadBufferRec,*XkbReadBufferPtr;
} XkbReadBufferRec, *XkbReadBufferPtr;
#define _XkbAlloc(s) Xmalloc((s))
#define _XkbCalloc(n,s) Xcalloc((n),(s))
......@@ -120,8 +120,8 @@ typedef struct _XkbReadBuffer {
#define _XkbTypedAlloc(t) ((t *)Xmalloc(sizeof(t)))
#define _XkbTypedCalloc(n,t) ((t *)Xcalloc((n),sizeof(t)))
#define _XkbTypedRealloc(o,n,t) \
((o)?(t *)Xrealloc((o),(n)*sizeof(t)):_XkbTypedCalloc(n,t))
#define _XkbClearElems(a,f,l,t) bzero(&(a)[f],((l)-(f)+1)*sizeof(t))
((o) ? (t *)Xrealloc((o), (n)*sizeof(t)) : _XkbTypedCalloc(n,t))
#define _XkbClearElems(a,f,l,t) bzero(&(a)[f], ((l)-(f)+1) * sizeof(t))
#define _XkbFree(p) Xfree(p)
_XFUNCPROTOBEGIN
......@@ -131,7 +131,7 @@ extern void _XkbReloadDpy(
);
extern KeySym _XKeycodeToKeysym(
Display* /* display */,
Display * /* display */,
#if NeedWidePrototypes
unsigned int /* keycode */,
#else
......@@ -141,17 +141,17 @@ extern KeySym _XKeycodeToKeysym(
);
extern KeyCode _XKeysymToKeycode(
Display* /* display */,
Display * /* display */,
KeySym /* keysym */
);
extern KeySym _XLookupKeysym(
XKeyEvent* /* key_event */,
XKeyEvent * /* key_event */,
int /* index */
);
extern int _XRefreshKeyboardMapping(
XMappingEvent* /* event_map */
XMappingEvent * /* event_map */
);
extern unsigned _XKeysymToModifiers(
......@@ -226,9 +226,9 @@ extern int _XkbReadBufferCopy32(
int /* size */
);
#else
#define _XkbReadCopyData32(f,t,s) memcpy((char *)(t),(char *)(f),(s)*4)
#define _XkbWriteCopyData32(f,t,s) memcpy((char *)(t),(char *)(f),(s)*4)
#define _XkbReadBufferCopy32(f,t,s) _XkbCopyFromReadBuffer(f,(char *)t,(s)*4)
#define _XkbReadCopyData32(f,t,s) memcpy((char *)(t), (char *)(f), (s)*4)
#define _XkbWriteCopyData32(f,t,s) memcpy((char *)(t), (char *)(f), (s)*4)
#define _XkbReadBufferCopy32(f,t,s) _XkbCopyFromReadBuffer(f, (char *)t, (s)*4)
#endif
#ifndef NO_DEC_BINARY_COMPATIBILITY
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment