New upstream version 3.5.99.27
This commit is contained in:
69
nx-X11/programs/Xserver/xkb/Imakefile
Normal file
69
nx-X11/programs/Xserver/xkb/Imakefile
Normal file
@@ -0,0 +1,69 @@
|
||||
#define SGIHyperOpt
|
||||
#include <Server.tmpl>
|
||||
|
||||
#if BuildXInputExt
|
||||
XKBXI_SRCS = xkbPrOtherEv.c
|
||||
XKBXI_OBJS = xkbPrOtherEv.o
|
||||
#endif
|
||||
|
||||
#ifdef DfltDisableXKB
|
||||
XKB_DISABLE = -DXKB_DFLT_DISABLED=1
|
||||
#else
|
||||
XKB_DISABLE = -DXKB_DFLT_DISABLED=0
|
||||
#endif
|
||||
|
||||
XKB_DDXDEFS = XkbServerDefines
|
||||
|
||||
#if defined(NXAgentServer) && NXAgentServer
|
||||
NX_DEFINES = -DNXAGENT_SERVER
|
||||
#endif
|
||||
|
||||
DDX_SRCS = ddxBeep.c ddxCtrls.c ddxFakeBtn.c ddxFakeMtn.c \
|
||||
ddxKillSrv.c ddxLEDs.c ddxVT.c ddxLoad.c \
|
||||
ddxList.c ddxDevBtn.c ddxPrivate.c
|
||||
DDX_OBJS = ddxBeep.o ddxCtrls.o ddxFakeBtn.o ddxFakeMtn.o \
|
||||
ddxKillSrv.o ddxLEDs.o ddxVT.o ddxLoad.o \
|
||||
ddxList.o ddxDevBtn.o ddxPrivate.o
|
||||
SRCS = xkb.c xkbUtils.c xkbEvents.c xkbAccessX.c xkbSwap.c \
|
||||
xkbLEDs.c xkbInit.c xkbActions.c xkbPrKeyEv.c \
|
||||
xkmread.c xkbtext.c xkbfmisc.c xkberrs.c maprules.c \
|
||||
XKBMisc.c XKBMAlloc.c XKBAlloc.c XKBGAlloc.c xkbout.c \
|
||||
$(XKBXI_SRCS) $(DDX_SRCS)
|
||||
OBJS = xkb.o xkbUtils.o xkbEvents.o xkbAccessX.o xkbSwap.o \
|
||||
xkbLEDs.o xkbInit.o xkbActions.o xkbPrKeyEv.o \
|
||||
xkmread.o xkbtext.o xkbfmisc.o xkberrs.o maprules.o \
|
||||
XKBMisc.o XKBMAlloc.o XKBAlloc.o XKBGAlloc.o xkbout.o \
|
||||
$(XKBXI_OBJS) $(DDX_OBJS)
|
||||
INCLUDES = -I../include -I$(XINCLUDESRC) -I$(EXTINCSRC) -I$(SERVERSRC)/Xext \
|
||||
-I$(SERVERSRC)/mi $(XF86INCLUDES) \
|
||||
`pkg-config --cflags-only-I pixman-1`
|
||||
LINTLIBS = ../dix/llib-ldix.ln ../os/llib-los.ln
|
||||
|
||||
DEFINES = $(XKB_DDXDEFS) $(NX_DEFINES)
|
||||
XKB_DEFINES = -DXKB_BASE_DIRECTORY=\"$(SYSTEMXKBCONFDIR)\" -DXKB_BIN_DIRECTORY=\"$(SYSTEMXKBBINDIR)\" -DXKB_DFLT_RULES_FILE=\"base\" -DXKB_DFLT_KB_LAYOUT=\"us\" -DXKB_DFLT_KB_MODEL=\"pc102\" $(XKB_DISABLE)
|
||||
|
||||
NormalLibraryObjectRule()
|
||||
NormalLibraryTarget(xkb,$(OBJS))
|
||||
LintLibraryTarget(xkb,$(SRCS))
|
||||
NormalLintTarget($(SRCS))
|
||||
|
||||
SpecialCObjectRule(xkbInit,$(ICONFIGFILES),$(XKB_DEFINES))
|
||||
|
||||
#if BuildLibraries
|
||||
#if UseConfDirForXkb
|
||||
LinkConfDirectory(xkb,.,xkb,.)
|
||||
ODIR = $(CONFDIR)
|
||||
#else
|
||||
ODIR = $(LIBDIR)
|
||||
#endif
|
||||
#ifdef VarDbDirectory
|
||||
NDIR = $(VARDBDIR)
|
||||
#else
|
||||
NDIR = $(CONFDIR)
|
||||
#endif
|
||||
#if !UseConfDirForXkb || defined(VarDbDirectory)
|
||||
LinkConfDirectoryLong(xkb,xkb,compiled,compiled,$(ODIR),$(NDIR))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
DependTarget()
|
||||
332
nx-X11/programs/Xserver/xkb/XKBAlloc.c
Normal file
332
nx-X11/programs/Xserver/xkb/XKBAlloc.c
Normal file
@@ -0,0 +1,332 @@
|
||||
/************************************************************
|
||||
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_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <nx-X11/X.h>
|
||||
#include <nx-X11/Xproto.h>
|
||||
#include "misc.h"
|
||||
#include "inputstr.h"
|
||||
#include <xkbsrv.h>
|
||||
#include "xkbgeom.h"
|
||||
|
||||
/***===================================================================***/
|
||||
|
||||
/*ARGSUSED*/
|
||||
Status
|
||||
XkbAllocCompatMap(XkbDescPtr xkb,unsigned which,unsigned nSI)
|
||||
{
|
||||
XkbCompatMapPtr compat;
|
||||
XkbSymInterpretRec *prev_interpret;
|
||||
|
||||
if (!xkb)
|
||||
return BadMatch;
|
||||
if (xkb->compat) {
|
||||
if (xkb->compat->size_si>=nSI)
|
||||
return Success;
|
||||
compat= xkb->compat;
|
||||
compat->size_si= nSI;
|
||||
if (compat->sym_interpret==NULL)
|
||||
compat->num_si= 0;
|
||||
prev_interpret = compat->sym_interpret;
|
||||
compat->sym_interpret= _XkbTypedRealloc(compat->sym_interpret,
|
||||
nSI,XkbSymInterpretRec);
|
||||
if (compat->sym_interpret==NULL) {
|
||||
_XkbFree(prev_interpret);
|
||||
compat->size_si= compat->num_si= 0;
|
||||
return BadAlloc;
|
||||
}
|
||||
if (compat->num_si!=0) {
|
||||
_XkbClearElems(compat->sym_interpret,compat->num_si,
|
||||
compat->size_si-1,XkbSymInterpretRec);
|
||||
}
|
||||
return Success;
|
||||
}
|
||||
compat= _XkbTypedCalloc(1,XkbCompatMapRec);
|
||||
if (compat==NULL)
|
||||
return BadAlloc;
|
||||
if (nSI>0) {
|
||||
compat->sym_interpret= _XkbTypedCalloc(nSI,XkbSymInterpretRec);
|
||||
if (!compat->sym_interpret) {
|
||||
_XkbFree(compat);
|
||||
return BadAlloc;
|
||||
}
|
||||
}
|
||||
compat->size_si= nSI;
|
||||
compat->num_si= 0;
|
||||
bzero((char *)&compat->groups[0],XkbNumKbdGroups*sizeof(XkbModsRec));
|
||||
xkb->compat= compat;
|
||||
return Success;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
XkbFreeCompatMap(XkbDescPtr xkb,unsigned which,Bool freeMap)
|
||||
{
|
||||
register XkbCompatMapPtr compat;
|
||||
|
||||
if ((xkb==NULL)||(xkb->compat==NULL))
|
||||
return;
|
||||
compat= xkb->compat;
|
||||
if (freeMap)
|
||||
which= XkbAllCompatMask;
|
||||
if (which&XkbGroupCompatMask)
|
||||
bzero((char *)&compat->groups[0],XkbNumKbdGroups*sizeof(XkbModsRec));
|
||||
if (which&XkbSymInterpMask) {
|
||||
if ((compat->sym_interpret)&&(compat->size_si>0))
|
||||
_XkbFree(compat->sym_interpret);
|
||||
compat->size_si= compat->num_si= 0;
|
||||
compat->sym_interpret= NULL;
|
||||
}
|
||||
if (freeMap) {
|
||||
_XkbFree(compat);
|
||||
xkb->compat= NULL;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/***===================================================================***/
|
||||
|
||||
Status
|
||||
XkbAllocNames(XkbDescPtr xkb,unsigned which,int nTotalRG,int nTotalAliases)
|
||||
{
|
||||
XkbNamesPtr names;
|
||||
|
||||
if (xkb==NULL)
|
||||
return BadMatch;
|
||||
if (xkb->names==NULL) {
|
||||
xkb->names = _XkbTypedCalloc(1,XkbNamesRec);
|
||||
if (xkb->names==NULL)
|
||||
return BadAlloc;
|
||||
}
|
||||
names= xkb->names;
|
||||
if ((which&XkbKTLevelNamesMask)&&(xkb->map!=NULL)&&(xkb->map->types!=NULL)){
|
||||
register int i;
|
||||
XkbKeyTypePtr type;
|
||||
|
||||
type= xkb->map->types;
|
||||
for (i=0;i<xkb->map->num_types;i++,type++) {
|
||||
if (type->level_names==NULL) {
|
||||
type->level_names= _XkbTypedCalloc(type->num_levels,Atom);
|
||||
if (type->level_names==NULL)
|
||||
return BadAlloc;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((which&XkbKeyNamesMask)&&(names->keys==NULL)) {
|
||||
if ((!XkbIsLegalKeycode(xkb->min_key_code))||
|
||||
(!XkbIsLegalKeycode(xkb->max_key_code))||
|
||||
(xkb->max_key_code<xkb->min_key_code))
|
||||
return BadValue;
|
||||
names->keys= _XkbTypedCalloc((xkb->max_key_code+1),XkbKeyNameRec);
|
||||
if (names->keys==NULL)
|
||||
return BadAlloc;
|
||||
}
|
||||
if ((which&XkbKeyAliasesMask)&&(nTotalAliases>0)) {
|
||||
if (names->key_aliases==NULL) {
|
||||
names->key_aliases= _XkbTypedCalloc(nTotalAliases,XkbKeyAliasRec);
|
||||
}
|
||||
else if (nTotalAliases>names->num_key_aliases) {
|
||||
XkbKeyAliasRec *prev_aliases = names->key_aliases;
|
||||
|
||||
names->key_aliases= _XkbTypedRealloc(names->key_aliases,
|
||||
nTotalAliases,XkbKeyAliasRec);
|
||||
if (names->key_aliases!=NULL) {
|
||||
_XkbClearElems(names->key_aliases,names->num_key_aliases,
|
||||
nTotalAliases-1,XkbKeyAliasRec);
|
||||
} else {
|
||||
_XkbFree(prev_aliases);
|
||||
}
|
||||
}
|
||||
if (names->key_aliases==NULL) {
|
||||
names->num_key_aliases= 0;
|
||||
return BadAlloc;
|
||||
}
|
||||
names->num_key_aliases= nTotalAliases;
|
||||
}
|
||||
if ((which&XkbRGNamesMask)&&(nTotalRG>0)) {
|
||||
if (names->radio_groups==NULL) {
|
||||
names->radio_groups= _XkbTypedCalloc(nTotalRG,Atom);
|
||||
}
|
||||
else if (nTotalRG>names->num_rg) {
|
||||
Atom *prev_radio_groups = names->radio_groups;
|
||||
|
||||
names->radio_groups= _XkbTypedRealloc(names->radio_groups,nTotalRG,
|
||||
Atom);
|
||||
if (names->radio_groups!=NULL) {
|
||||
_XkbClearElems(names->radio_groups,names->num_rg,nTotalRG-1,
|
||||
Atom);
|
||||
} else {
|
||||
_XkbFree(prev_radio_groups);
|
||||
}
|
||||
}
|
||||
if (names->radio_groups==NULL)
|
||||
return BadAlloc;
|
||||
names->num_rg= nTotalRG;
|
||||
}
|
||||
return Success;
|
||||
}
|
||||
|
||||
void
|
||||
XkbFreeNames(XkbDescPtr xkb,unsigned which,Bool freeMap)
|
||||
{
|
||||
XkbNamesPtr names;
|
||||
|
||||
if ((xkb==NULL)||(xkb->names==NULL))
|
||||
return;
|
||||
names= xkb->names;
|
||||
if (freeMap)
|
||||
which= XkbAllNamesMask;
|
||||
if (which&XkbKTLevelNamesMask) {
|
||||
XkbClientMapPtr map= xkb->map;
|
||||
if ((map!=NULL)&&(map->types!=NULL)) {
|
||||
register int i;
|
||||
register XkbKeyTypePtr type;
|
||||
type= map->types;
|
||||
for (i=0;i<map->num_types;i++,type++) {
|
||||
if (type->level_names!=NULL) {
|
||||
_XkbFree(type->level_names);
|
||||
type->level_names= NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((which&XkbKeyNamesMask)&&(names->keys!=NULL)) {
|
||||
_XkbFree(names->keys);
|
||||
names->keys= NULL;
|
||||
names->num_keys= 0;
|
||||
}
|
||||
if ((which&XkbKeyAliasesMask)&&(names->key_aliases)){
|
||||
_XkbFree(names->key_aliases);
|
||||
names->key_aliases=NULL;
|
||||
names->num_key_aliases=0;
|
||||
}
|
||||
if ((which&XkbRGNamesMask)&&(names->radio_groups)) {
|
||||
_XkbFree(names->radio_groups);
|
||||
names->radio_groups= NULL;
|
||||
names->num_rg= 0;
|
||||
}
|
||||
if (freeMap) {
|
||||
_XkbFree(names);
|
||||
xkb->names= NULL;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/***===================================================================***/
|
||||
|
||||
/*ARGSUSED*/
|
||||
Status
|
||||
XkbAllocControls(XkbDescPtr xkb,unsigned which)
|
||||
{
|
||||
if (xkb==NULL)
|
||||
return BadMatch;
|
||||
|
||||
if (xkb->ctrls==NULL) {
|
||||
xkb->ctrls= _XkbTypedCalloc(1,XkbControlsRec);
|
||||
if (!xkb->ctrls)
|
||||
return BadAlloc;
|
||||
}
|
||||
return Success;
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
static void
|
||||
XkbFreeControls(XkbDescPtr xkb,unsigned which,Bool freeMap)
|
||||
{
|
||||
if (freeMap && (xkb!=NULL) && (xkb->ctrls!=NULL)) {
|
||||
_XkbFree(xkb->ctrls);
|
||||
xkb->ctrls= NULL;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/***===================================================================***/
|
||||
|
||||
Status
|
||||
XkbAllocIndicatorMaps(XkbDescPtr xkb)
|
||||
{
|
||||
if (xkb==NULL)
|
||||
return BadMatch;
|
||||
if (xkb->indicators==NULL) {
|
||||
xkb->indicators= _XkbTypedCalloc(1,XkbIndicatorRec);
|
||||
if (!xkb->indicators)
|
||||
return BadAlloc;
|
||||
}
|
||||
return Success;
|
||||
}
|
||||
|
||||
static void
|
||||
XkbFreeIndicatorMaps(XkbDescPtr xkb)
|
||||
{
|
||||
if ((xkb!=NULL)&&(xkb->indicators!=NULL)) {
|
||||
_XkbFree(xkb->indicators);
|
||||
xkb->indicators= NULL;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
XkbDescRec *
|
||||
XkbAllocKeyboard(void)
|
||||
{
|
||||
XkbDescRec *xkb;
|
||||
|
||||
xkb = _XkbTypedCalloc(1,XkbDescRec);
|
||||
if (xkb)
|
||||
xkb->device_spec= XkbUseCoreKbd;
|
||||
return xkb;
|
||||
}
|
||||
|
||||
void
|
||||
XkbFreeKeyboard(XkbDescPtr xkb,unsigned which,Bool freeAll)
|
||||
{
|
||||
if (xkb==NULL)
|
||||
return;
|
||||
if (freeAll)
|
||||
which= XkbAllComponentsMask;
|
||||
if (which&XkbClientMapMask)
|
||||
XkbFreeClientMap(xkb,XkbAllClientInfoMask,True);
|
||||
if (which&XkbServerMapMask)
|
||||
XkbFreeServerMap(xkb,XkbAllServerInfoMask,True);
|
||||
if (which&XkbCompatMapMask)
|
||||
XkbFreeCompatMap(xkb,XkbAllCompatMask,True);
|
||||
if (which&XkbIndicatorMapMask)
|
||||
XkbFreeIndicatorMaps(xkb);
|
||||
if (which&XkbNamesMask)
|
||||
XkbFreeNames(xkb,XkbAllNamesMask,True);
|
||||
if ((which&XkbGeometryMask) && (xkb->geom!=NULL))
|
||||
XkbFreeGeometry(xkb->geom,XkbGeomAllMask,True);
|
||||
if (which&XkbControlsMask)
|
||||
XkbFreeControls(xkb,XkbAllControlsMask,True);
|
||||
if (freeAll)
|
||||
_XkbFree(xkb);
|
||||
return;
|
||||
}
|
||||
998
nx-X11/programs/Xserver/xkb/XKBGAlloc.c
Normal file
998
nx-X11/programs/Xserver/xkb/XKBGAlloc.c
Normal file
@@ -0,0 +1,998 @@
|
||||
/************************************************************
|
||||
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_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <nx-X11/X.h>
|
||||
#include <nx-X11/Xproto.h>
|
||||
#include "misc.h"
|
||||
#include "inputstr.h"
|
||||
#include <xkbsrv.h>
|
||||
#include "xkbgeom.h"
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
static void
|
||||
_XkbFreeGeomLeafElems( Bool freeAll,
|
||||
int first,
|
||||
int count,
|
||||
unsigned short * num_inout,
|
||||
unsigned short * sz_inout,
|
||||
char ** elems,
|
||||
unsigned int elem_sz)
|
||||
{
|
||||
if ((freeAll)||(*elems==NULL)) {
|
||||
*num_inout= *sz_inout= 0;
|
||||
if (*elems!=NULL) {
|
||||
_XkbFree(*elems);
|
||||
*elems= NULL;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if ((first>=(*num_inout))||(first<0)||(count<1))
|
||||
return;
|
||||
|
||||
if (first+count>=(*num_inout)) {
|
||||
/* truncating the array is easy */
|
||||
(*num_inout)= first;
|
||||
}
|
||||
else {
|
||||
char * ptr;
|
||||
int extra;
|
||||
ptr= *elems;
|
||||
extra= ((*num_inout)-(first+count))*elem_sz;
|
||||
if (extra>0)
|
||||
memmove(&ptr[first*elem_sz],&ptr[(first+count)*elem_sz],extra);
|
||||
(*num_inout)-= count;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
typedef void (*ContentsClearFunc)(
|
||||
char * /* priv */
|
||||
);
|
||||
|
||||
static void
|
||||
_XkbFreeGeomNonLeafElems( Bool freeAll,
|
||||
int first,
|
||||
int count,
|
||||
unsigned short * num_inout,
|
||||
unsigned short * sz_inout,
|
||||
char ** elems,
|
||||
unsigned int elem_sz,
|
||||
ContentsClearFunc freeFunc)
|
||||
{
|
||||
register int i;
|
||||
register char *ptr;
|
||||
|
||||
if (freeAll) {
|
||||
first= 0;
|
||||
count= (*num_inout);
|
||||
}
|
||||
else if ((first>=(*num_inout))||(first<0)||(count<1))
|
||||
return;
|
||||
else if (first+count>(*num_inout))
|
||||
count= (*num_inout)-first;
|
||||
if (*elems==NULL)
|
||||
return;
|
||||
|
||||
if (freeFunc) {
|
||||
ptr= *elems;
|
||||
ptr+= first*elem_sz;
|
||||
for (i=0;i<count;i++) {
|
||||
(*freeFunc)(ptr);
|
||||
ptr+= elem_sz;
|
||||
}
|
||||
}
|
||||
if (freeAll) {
|
||||
(*num_inout)= (*sz_inout)= 0;
|
||||
if (*elems) {
|
||||
_XkbFree(*elems);
|
||||
*elems= NULL;
|
||||
}
|
||||
}
|
||||
else if (first+count>=(*num_inout))
|
||||
*num_inout= first;
|
||||
else {
|
||||
i= ((*num_inout)-(first+count))*elem_sz;
|
||||
ptr= *elems;
|
||||
memmove(&ptr[first*elem_sz],&ptr[(first+count)*elem_sz],i);
|
||||
(*num_inout)-= count;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
static void
|
||||
_XkbClearProperty(char *prop_in)
|
||||
{
|
||||
XkbPropertyPtr prop= (XkbPropertyPtr)prop_in;
|
||||
|
||||
if (prop->name) {
|
||||
_XkbFree(prop->name);
|
||||
prop->name= NULL;
|
||||
}
|
||||
if (prop->value) {
|
||||
_XkbFree(prop->value);
|
||||
prop->value= NULL;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
XkbFreeGeomProperties( XkbGeometryPtr geom,
|
||||
int first,
|
||||
int count,
|
||||
Bool freeAll)
|
||||
{
|
||||
_XkbFreeGeomNonLeafElems(freeAll,first,count,
|
||||
&geom->num_properties,&geom->sz_properties,
|
||||
(char **)&geom->properties,
|
||||
sizeof(XkbPropertyRec),_XkbClearProperty);
|
||||
return;
|
||||
}
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
void
|
||||
XkbFreeGeomKeyAliases( XkbGeometryPtr geom,
|
||||
int first,
|
||||
int count,
|
||||
Bool freeAll)
|
||||
{
|
||||
_XkbFreeGeomLeafElems(freeAll,first,count,
|
||||
&geom->num_key_aliases,&geom->sz_key_aliases,
|
||||
(char **)&geom->key_aliases,
|
||||
sizeof(XkbKeyAliasRec));
|
||||
return;
|
||||
}
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
static void
|
||||
_XkbClearColor(char *color_in)
|
||||
{
|
||||
XkbColorPtr color= (XkbColorPtr)color_in;
|
||||
|
||||
if (color->spec)
|
||||
_XkbFree(color->spec);
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
XkbFreeGeomColors(XkbGeometryPtr geom,int first,int count,Bool freeAll)
|
||||
{
|
||||
_XkbFreeGeomNonLeafElems(freeAll,first,count,
|
||||
&geom->num_colors,&geom->sz_colors,
|
||||
(char **)&geom->colors,
|
||||
sizeof(XkbColorRec),_XkbClearColor);
|
||||
return;
|
||||
}
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
void
|
||||
XkbFreeGeomPoints(XkbOutlinePtr outline,int first,int count,Bool freeAll)
|
||||
{
|
||||
_XkbFreeGeomLeafElems(freeAll,first,count,
|
||||
&outline->num_points,&outline->sz_points,
|
||||
(char **)&outline->points,
|
||||
sizeof(XkbPointRec));
|
||||
return;
|
||||
}
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
static void
|
||||
_XkbClearOutline(char *outline_in)
|
||||
{
|
||||
XkbOutlinePtr outline= (XkbOutlinePtr)outline_in;
|
||||
|
||||
if (outline->points!=NULL)
|
||||
XkbFreeGeomPoints(outline,0,outline->num_points,True);
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
XkbFreeGeomOutlines(XkbShapePtr shape,int first,int count,Bool freeAll)
|
||||
{
|
||||
_XkbFreeGeomNonLeafElems(freeAll,first,count,
|
||||
&shape->num_outlines,&shape->sz_outlines,
|
||||
(char **)&shape->outlines,
|
||||
sizeof(XkbOutlineRec),_XkbClearOutline);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
static void
|
||||
_XkbClearShape(char *shape_in)
|
||||
{
|
||||
XkbShapePtr shape= (XkbShapePtr)shape_in;
|
||||
|
||||
if (shape->outlines)
|
||||
XkbFreeGeomOutlines(shape,0,shape->num_outlines,True);
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
XkbFreeGeomShapes(XkbGeometryPtr geom,int first,int count,Bool freeAll)
|
||||
{
|
||||
_XkbFreeGeomNonLeafElems(freeAll,first,count,
|
||||
&geom->num_shapes,&geom->sz_shapes,
|
||||
(char **)&geom->shapes,
|
||||
sizeof(XkbShapeRec),_XkbClearShape);
|
||||
return;
|
||||
}
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
void
|
||||
XkbFreeGeomOverlayKeys(XkbOverlayRowPtr row,int first,int count,Bool freeAll)
|
||||
{
|
||||
_XkbFreeGeomLeafElems(freeAll,first,count,
|
||||
&row->num_keys,&row->sz_keys,
|
||||
(char **)&row->keys,
|
||||
sizeof(XkbOverlayKeyRec));
|
||||
return;
|
||||
}
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
static void
|
||||
_XkbClearOverlayRow(char *row_in)
|
||||
{
|
||||
XkbOverlayRowPtr row= (XkbOverlayRowPtr)row_in;
|
||||
|
||||
if (row->keys!=NULL)
|
||||
XkbFreeGeomOverlayKeys(row,0,row->num_keys,True);
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
XkbFreeGeomOverlayRows(XkbOverlayPtr overlay,int first,int count,Bool freeAll)
|
||||
{
|
||||
_XkbFreeGeomNonLeafElems(freeAll,first,count,
|
||||
&overlay->num_rows,&overlay->sz_rows,
|
||||
(char **)&overlay->rows,
|
||||
sizeof(XkbOverlayRowRec),_XkbClearOverlayRow);
|
||||
return;
|
||||
}
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
static void
|
||||
_XkbClearOverlay(char *overlay_in)
|
||||
{
|
||||
XkbOverlayPtr overlay= (XkbOverlayPtr)overlay_in;
|
||||
|
||||
if (overlay->rows!=NULL)
|
||||
XkbFreeGeomOverlayRows(overlay,0,overlay->num_rows,True);
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
XkbFreeGeomOverlays(XkbSectionPtr section,int first,int count,Bool freeAll)
|
||||
{
|
||||
_XkbFreeGeomNonLeafElems(freeAll,first,count,
|
||||
§ion->num_overlays,§ion->sz_overlays,
|
||||
(char **)§ion->overlays,
|
||||
sizeof(XkbOverlayRec),_XkbClearOverlay);
|
||||
return;
|
||||
}
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
void
|
||||
XkbFreeGeomKeys(XkbRowPtr row,int first,int count,Bool freeAll)
|
||||
{
|
||||
_XkbFreeGeomLeafElems(freeAll,first,count,
|
||||
&row->num_keys,&row->sz_keys,
|
||||
(char **)&row->keys,
|
||||
sizeof(XkbKeyRec));
|
||||
return;
|
||||
}
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
static void
|
||||
_XkbClearRow(char *row_in)
|
||||
{
|
||||
XkbRowPtr row= (XkbRowPtr)row_in;
|
||||
|
||||
if (row->keys!=NULL)
|
||||
XkbFreeGeomKeys(row,0,row->num_keys,True);
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
XkbFreeGeomRows(XkbSectionPtr section,int first,int count,Bool freeAll)
|
||||
{
|
||||
_XkbFreeGeomNonLeafElems(freeAll,first,count,
|
||||
§ion->num_rows,§ion->sz_rows,
|
||||
(char **)§ion->rows,
|
||||
sizeof(XkbRowRec),_XkbClearRow);
|
||||
}
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
static void
|
||||
_XkbClearSection(char *section_in)
|
||||
{
|
||||
XkbSectionPtr section= (XkbSectionPtr)section_in;
|
||||
|
||||
if (section->rows!=NULL)
|
||||
XkbFreeGeomRows(section,0,section->num_rows,True);
|
||||
if (section->doodads!=NULL) {
|
||||
XkbFreeGeomDoodads(section->doodads,section->num_doodads,True);
|
||||
section->doodads= NULL;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
XkbFreeGeomSections(XkbGeometryPtr geom,int first,int count,Bool freeAll)
|
||||
{
|
||||
_XkbFreeGeomNonLeafElems(freeAll,first,count,
|
||||
&geom->num_sections,&geom->sz_sections,
|
||||
(char **)&geom->sections,
|
||||
sizeof(XkbSectionRec),_XkbClearSection);
|
||||
return;
|
||||
}
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
static void
|
||||
_XkbClearDoodad(char *doodad_in)
|
||||
{
|
||||
XkbDoodadPtr doodad= (XkbDoodadPtr)doodad_in;
|
||||
|
||||
switch (doodad->any.type) {
|
||||
case XkbTextDoodad:
|
||||
{
|
||||
if (doodad->text.text!=NULL) {
|
||||
_XkbFree(doodad->text.text);
|
||||
doodad->text.text= NULL;
|
||||
}
|
||||
if (doodad->text.font!=NULL) {
|
||||
_XkbFree(doodad->text.font);
|
||||
doodad->text.font= NULL;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case XkbLogoDoodad:
|
||||
{
|
||||
if (doodad->logo.logo_name!=NULL) {
|
||||
_XkbFree(doodad->logo.logo_name);
|
||||
doodad->logo.logo_name= NULL;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
XkbFreeGeomDoodads(XkbDoodadPtr doodads,int nDoodads,Bool freeAll)
|
||||
{
|
||||
register int i;
|
||||
register XkbDoodadPtr doodad;
|
||||
|
||||
if (doodads) {
|
||||
for (i=0,doodad= doodads;i<nDoodads;i++,doodad++) {
|
||||
_XkbClearDoodad((char *)doodad);
|
||||
}
|
||||
if (freeAll)
|
||||
_XkbFree(doodads);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
XkbFreeGeometry(XkbGeometryPtr geom,unsigned which,Bool freeMap)
|
||||
{
|
||||
if (geom==NULL)
|
||||
return;
|
||||
if (freeMap)
|
||||
which= XkbGeomAllMask;
|
||||
if ((which&XkbGeomPropertiesMask)&&(geom->properties!=NULL))
|
||||
XkbFreeGeomProperties(geom,0,geom->num_properties,True);
|
||||
if ((which&XkbGeomColorsMask)&&(geom->colors!=NULL))
|
||||
XkbFreeGeomColors(geom,0,geom->num_colors,True);
|
||||
if ((which&XkbGeomShapesMask)&&(geom->shapes!=NULL))
|
||||
XkbFreeGeomShapes(geom,0,geom->num_shapes,True);
|
||||
if ((which&XkbGeomSectionsMask)&&(geom->sections!=NULL))
|
||||
XkbFreeGeomSections(geom,0,geom->num_sections,True);
|
||||
if ((which&XkbGeomDoodadsMask)&&(geom->doodads!= NULL)) {
|
||||
XkbFreeGeomDoodads(geom->doodads,geom->num_doodads,True);
|
||||
geom->doodads= NULL;
|
||||
geom->num_doodads= geom->sz_doodads= 0;
|
||||
}
|
||||
if ((which&XkbGeomKeyAliasesMask)&&(geom->key_aliases!=NULL))
|
||||
XkbFreeGeomKeyAliases(geom,0,geom->num_key_aliases,True);
|
||||
if (freeMap) {
|
||||
if (geom->label_font!=NULL) {
|
||||
_XkbFree(geom->label_font);
|
||||
geom->label_font= NULL;
|
||||
}
|
||||
_XkbFree(geom);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
static Status
|
||||
_XkbGeomAlloc( XPointer * old,
|
||||
unsigned short * num,
|
||||
unsigned short * total,
|
||||
int num_new,
|
||||
size_t sz_elem)
|
||||
{
|
||||
if (num_new<1)
|
||||
return Success;
|
||||
if ((*old)==NULL)
|
||||
*num= *total= 0;
|
||||
|
||||
if ((*num)+num_new<=(*total))
|
||||
return Success;
|
||||
|
||||
*total= (*num)+num_new;
|
||||
if ((*old)!=NULL)
|
||||
(*old)= (XPointer)_XkbRealloc((*old),(*total)*sz_elem);
|
||||
else (*old)= (XPointer)_XkbCalloc((*total),sz_elem);
|
||||
if ((*old)==NULL) {
|
||||
*total= *num= 0;
|
||||
return BadAlloc;
|
||||
}
|
||||
|
||||
if (*num>0) {
|
||||
char *tmp= (char *)(*old);
|
||||
bzero(&tmp[sz_elem*(*num)],(num_new*sz_elem));
|
||||
}
|
||||
return Success;
|
||||
}
|
||||
|
||||
#define _XkbAllocProps(g,n) _XkbGeomAlloc((XPointer *)&(g)->properties,\
|
||||
&(g)->num_properties,&(g)->sz_properties,\
|
||||
(n),sizeof(XkbPropertyRec))
|
||||
#define _XkbAllocColors(g,n) _XkbGeomAlloc((XPointer *)&(g)->colors,\
|
||||
&(g)->num_colors,&(g)->sz_colors,\
|
||||
(n),sizeof(XkbColorRec))
|
||||
#define _XkbAllocShapes(g,n) _XkbGeomAlloc((XPointer *)&(g)->shapes,\
|
||||
&(g)->num_shapes,&(g)->sz_shapes,\
|
||||
(n),sizeof(XkbShapeRec))
|
||||
#define _XkbAllocSections(g,n) _XkbGeomAlloc((XPointer *)&(g)->sections,\
|
||||
&(g)->num_sections,&(g)->sz_sections,\
|
||||
(n),sizeof(XkbSectionRec))
|
||||
#define _XkbAllocDoodads(g,n) _XkbGeomAlloc((XPointer *)&(g)->doodads,\
|
||||
&(g)->num_doodads,&(g)->sz_doodads,\
|
||||
(n),sizeof(XkbDoodadRec))
|
||||
#define _XkbAllocKeyAliases(g,n) _XkbGeomAlloc((XPointer *)&(g)->key_aliases,\
|
||||
&(g)->num_key_aliases,&(g)->sz_key_aliases,\
|
||||
(n),sizeof(XkbKeyAliasRec))
|
||||
|
||||
#define _XkbAllocOutlines(s,n) _XkbGeomAlloc((XPointer *)&(s)->outlines,\
|
||||
&(s)->num_outlines,&(s)->sz_outlines,\
|
||||
(n),sizeof(XkbOutlineRec))
|
||||
#define _XkbAllocRows(s,n) _XkbGeomAlloc((XPointer *)&(s)->rows,\
|
||||
&(s)->num_rows,&(s)->sz_rows,\
|
||||
(n),sizeof(XkbRowRec))
|
||||
#define _XkbAllocPoints(o,n) _XkbGeomAlloc((XPointer *)&(o)->points,\
|
||||
&(o)->num_points,&(o)->sz_points,\
|
||||
(n),sizeof(XkbPointRec))
|
||||
#define _XkbAllocKeys(r,n) _XkbGeomAlloc((XPointer *)&(r)->keys,\
|
||||
&(r)->num_keys,&(r)->sz_keys,\
|
||||
(n),sizeof(XkbKeyRec))
|
||||
#define _XkbAllocOverlays(s,n) _XkbGeomAlloc((XPointer *)&(s)->overlays,\
|
||||
&(s)->num_overlays,&(s)->sz_overlays,\
|
||||
(n),sizeof(XkbOverlayRec))
|
||||
#define _XkbAllocOverlayRows(o,n) _XkbGeomAlloc((XPointer *)&(o)->rows,\
|
||||
&(o)->num_rows,&(o)->sz_rows,\
|
||||
(n),sizeof(XkbOverlayRowRec))
|
||||
#define _XkbAllocOverlayKeys(r,n) _XkbGeomAlloc((XPointer *)&(r)->keys,\
|
||||
&(r)->num_keys,&(r)->sz_keys,\
|
||||
(n),sizeof(XkbOverlayKeyRec))
|
||||
|
||||
Status
|
||||
XkbAllocGeomProps(XkbGeometryPtr geom,int nProps)
|
||||
{
|
||||
return _XkbAllocProps(geom,nProps);
|
||||
}
|
||||
|
||||
Status
|
||||
XkbAllocGeomColors(XkbGeometryPtr geom,int nColors)
|
||||
{
|
||||
return _XkbAllocColors(geom,nColors);
|
||||
}
|
||||
|
||||
Status
|
||||
XkbAllocGeomKeyAliases(XkbGeometryPtr geom,int nKeyAliases)
|
||||
{
|
||||
return _XkbAllocKeyAliases(geom,nKeyAliases);
|
||||
}
|
||||
|
||||
Status
|
||||
XkbAllocGeomShapes(XkbGeometryPtr geom,int nShapes)
|
||||
{
|
||||
return _XkbAllocShapes(geom,nShapes);
|
||||
}
|
||||
|
||||
Status
|
||||
XkbAllocGeomSections(XkbGeometryPtr geom,int nSections)
|
||||
{
|
||||
return _XkbAllocSections(geom,nSections);
|
||||
}
|
||||
|
||||
Status
|
||||
XkbAllocGeomOverlays(XkbSectionPtr section,int nOverlays)
|
||||
{
|
||||
return _XkbAllocOverlays(section,nOverlays);
|
||||
}
|
||||
|
||||
Status
|
||||
XkbAllocGeomOverlayRows(XkbOverlayPtr overlay,int nRows)
|
||||
{
|
||||
return _XkbAllocOverlayRows(overlay,nRows);
|
||||
}
|
||||
|
||||
Status
|
||||
XkbAllocGeomOverlayKeys(XkbOverlayRowPtr row,int nKeys)
|
||||
{
|
||||
return _XkbAllocOverlayKeys(row,nKeys);
|
||||
}
|
||||
|
||||
Status
|
||||
XkbAllocGeomDoodads(XkbGeometryPtr geom,int nDoodads)
|
||||
{
|
||||
return _XkbAllocDoodads(geom,nDoodads);
|
||||
}
|
||||
|
||||
Status
|
||||
XkbAllocGeomSectionDoodads(XkbSectionPtr section,int nDoodads)
|
||||
{
|
||||
return _XkbAllocDoodads(section,nDoodads);
|
||||
}
|
||||
|
||||
Status
|
||||
XkbAllocGeomOutlines(XkbShapePtr shape,int nOL)
|
||||
{
|
||||
return _XkbAllocOutlines(shape,nOL);
|
||||
}
|
||||
|
||||
Status
|
||||
XkbAllocGeomRows(XkbSectionPtr section,int nRows)
|
||||
{
|
||||
return _XkbAllocRows(section,nRows);
|
||||
}
|
||||
|
||||
Status
|
||||
XkbAllocGeomPoints(XkbOutlinePtr ol,int nPts)
|
||||
{
|
||||
return _XkbAllocPoints(ol,nPts);
|
||||
}
|
||||
|
||||
Status
|
||||
XkbAllocGeomKeys(XkbRowPtr row,int nKeys)
|
||||
{
|
||||
return _XkbAllocKeys(row,nKeys);
|
||||
}
|
||||
|
||||
Status
|
||||
XkbAllocGeometry(XkbDescPtr xkb,XkbGeometrySizesPtr sizes)
|
||||
{
|
||||
XkbGeometryPtr geom;
|
||||
Status rtrn;
|
||||
|
||||
if (xkb->geom==NULL) {
|
||||
xkb->geom= _XkbTypedCalloc(1,XkbGeometryRec);
|
||||
if (!xkb->geom)
|
||||
return BadAlloc;
|
||||
}
|
||||
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;
|
||||
}
|
||||
return Success;
|
||||
BAIL:
|
||||
XkbFreeGeometry(geom,XkbGeomAllMask,True);
|
||||
xkb->geom= NULL;
|
||||
return rtrn;
|
||||
}
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
XkbPropertyPtr
|
||||
XkbAddGeomProperty(XkbGeometryPtr geom,char *name,char *value)
|
||||
{
|
||||
register int i;
|
||||
register XkbPropertyPtr prop;
|
||||
|
||||
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)
|
||||
_XkbFree(prop->value);
|
||||
prop->value= (char *)_XkbAlloc(strlen(value)+1);
|
||||
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];
|
||||
prop->name= (char *)_XkbAlloc(strlen(name)+1);
|
||||
if (!name)
|
||||
return NULL;
|
||||
strcpy(prop->name,name);
|
||||
prop->value= (char *)_XkbAlloc(strlen(value)+1);
|
||||
if (!value) {
|
||||
_XkbFree(prop->name);
|
||||
prop->name= NULL;
|
||||
return NULL;
|
||||
}
|
||||
strcpy(prop->value,value);
|
||||
geom->num_properties++;
|
||||
return prop;
|
||||
}
|
||||
|
||||
XkbKeyAliasPtr
|
||||
XkbAddGeomKeyAlias(XkbGeometryPtr geom,char *aliasStr,char *realStr)
|
||||
{
|
||||
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);
|
||||
memcpy(alias->real, realStr,
|
||||
min(XkbKeyNameLength, strlen(realStr)));
|
||||
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));
|
||||
memcpy(alias->alias, aliasStr, min(XkbKeyNameLength, strlen(aliasStr)));
|
||||
memcpy(alias->real, realStr, min(XkbKeyNameLength, strlen(realStr)));
|
||||
geom->num_key_aliases++;
|
||||
return alias;
|
||||
}
|
||||
|
||||
XkbColorPtr
|
||||
XkbAddGeomColor(XkbGeometryPtr geom,char *spec,unsigned int pixel)
|
||||
{
|
||||
register int i;
|
||||
register XkbColorPtr color;
|
||||
|
||||
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;
|
||||
color->spec= (char *)_XkbAlloc(strlen(spec)+1);
|
||||
if (!color->spec)
|
||||
return NULL;
|
||||
strcpy(color->spec,spec);
|
||||
geom->num_colors++;
|
||||
return color;
|
||||
}
|
||||
|
||||
XkbOutlinePtr
|
||||
XkbAddGeomOutline(XkbShapePtr shape,int sz_points)
|
||||
{
|
||||
XkbOutlinePtr outline;
|
||||
|
||||
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];
|
||||
bzero(outline,sizeof(XkbOutlineRec));
|
||||
if ((sz_points>0)&&(_XkbAllocPoints(outline,sz_points)!=Success))
|
||||
return NULL;
|
||||
shape->num_outlines++;
|
||||
return outline;
|
||||
}
|
||||
|
||||
XkbShapePtr
|
||||
XkbAddGeomShape(XkbGeometryPtr geom,Atom name,int sz_outlines)
|
||||
{
|
||||
XkbShapePtr shape;
|
||||
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];
|
||||
bzero(shape,sizeof(XkbShapeRec));
|
||||
if ((sz_outlines>0)&&(_XkbAllocOutlines(shape,sz_outlines)!=Success))
|
||||
return NULL;
|
||||
shape->name= name;
|
||||
shape->primary= shape->approx= NULL;
|
||||
geom->num_shapes++;
|
||||
return shape;
|
||||
}
|
||||
|
||||
XkbKeyPtr
|
||||
XkbAddGeomKey(XkbRowPtr row)
|
||||
{
|
||||
XkbKeyPtr key;
|
||||
if (!row)
|
||||
return NULL;
|
||||
if ((row->num_keys>=row->sz_keys)&&(_XkbAllocKeys(row,1)!=Success))
|
||||
return NULL;
|
||||
key= &row->keys[row->num_keys++];
|
||||
bzero(key,sizeof(XkbKeyRec));
|
||||
return key;
|
||||
}
|
||||
|
||||
XkbRowPtr
|
||||
XkbAddGeomRow(XkbSectionPtr section,int sz_keys)
|
||||
{
|
||||
XkbRowPtr row;
|
||||
|
||||
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];
|
||||
bzero(row,sizeof(XkbRowRec));
|
||||
if ((sz_keys>0)&&(_XkbAllocKeys(row,sz_keys)!=Success))
|
||||
return NULL;
|
||||
section->num_rows++;
|
||||
return row;
|
||||
}
|
||||
|
||||
XkbSectionPtr
|
||||
XkbAddGeomSection( XkbGeometryPtr geom,
|
||||
Atom name,
|
||||
int sz_rows,
|
||||
int sz_doodads,
|
||||
int sz_over)
|
||||
{
|
||||
register int i;
|
||||
XkbSectionPtr section;
|
||||
|
||||
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) {
|
||||
_XkbFree(section->rows);
|
||||
section->rows= NULL;
|
||||
section->sz_rows= section->num_rows= 0;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
section->name= name;
|
||||
geom->num_sections++;
|
||||
return section;
|
||||
}
|
||||
|
||||
XkbDoodadPtr
|
||||
XkbAddGeomDoodad(XkbGeometryPtr geom,XkbSectionPtr section,Atom name)
|
||||
{
|
||||
XkbDoodadPtr old,doodad;
|
||||
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++];
|
||||
}
|
||||
bzero(doodad,sizeof(XkbDoodadRec));
|
||||
doodad->any.name= name;
|
||||
return doodad;
|
||||
}
|
||||
|
||||
XkbOverlayKeyPtr
|
||||
XkbAddGeomOverlayKey( XkbOverlayPtr overlay,
|
||||
XkbOverlayRowPtr row,
|
||||
char * over,
|
||||
char * under)
|
||||
{
|
||||
register int i;
|
||||
XkbOverlayKeyPtr key;
|
||||
XkbSectionPtr section;
|
||||
XkbRowPtr row_under;
|
||||
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];
|
||||
memcpy(key->under.name, under, min(XkbKeyNameLength, strlen(under)));
|
||||
memcpy(key->over.name, over, min(XkbKeyNameLength, strlen(over)));
|
||||
row->num_keys++;
|
||||
return key;
|
||||
}
|
||||
|
||||
XkbOverlayRowPtr
|
||||
XkbAddGeomOverlayRow(XkbOverlayPtr overlay,int row_under,int sz_keys)
|
||||
{
|
||||
register int i;
|
||||
XkbOverlayRowPtr row;
|
||||
|
||||
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];
|
||||
bzero(row,sizeof(XkbOverlayRowRec));
|
||||
if ((sz_keys>0)&&(_XkbAllocOverlayKeys(row,sz_keys)!=Success))
|
||||
return NULL;
|
||||
row->row_under= row_under;
|
||||
overlay->num_rows++;
|
||||
return row;
|
||||
}
|
||||
|
||||
XkbOverlayPtr
|
||||
XkbAddGeomOverlay(XkbSectionPtr section,Atom name,int sz_rows)
|
||||
{
|
||||
register int i;
|
||||
XkbOverlayPtr overlay;
|
||||
|
||||
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;
|
||||
}
|
||||
927
nx-X11/programs/Xserver/xkb/XKBMAlloc.c
Normal file
927
nx-X11/programs/Xserver/xkb/XKBMAlloc.c
Normal file
@@ -0,0 +1,927 @@
|
||||
/************************************************************
|
||||
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_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#elif defined(HAVE_CONFIG_H)
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <nx-X11/X.h>
|
||||
#include <nx-X11/Xproto.h>
|
||||
#include "misc.h"
|
||||
#include "inputstr.h"
|
||||
#include <nx-X11/keysym.h>
|
||||
#include <xkbsrv.h>
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
Status
|
||||
XkbAllocClientMap(XkbDescPtr xkb,unsigned which,unsigned nTotalTypes)
|
||||
{
|
||||
register int i;
|
||||
XkbClientMapPtr map;
|
||||
|
||||
if ((xkb==NULL)||((nTotalTypes>0)&&(nTotalTypes<XkbNumRequiredTypes)))
|
||||
return BadValue;
|
||||
if ((which&XkbKeySymsMask)&&
|
||||
((!XkbIsLegalKeycode(xkb->min_key_code))||
|
||||
(!XkbIsLegalKeycode(xkb->max_key_code))||
|
||||
(xkb->max_key_code<xkb->min_key_code))) {
|
||||
DebugF("bad keycode (%d,%d) in XkbAllocClientMap\n",
|
||||
xkb->min_key_code,xkb->max_key_code);
|
||||
return BadValue;
|
||||
}
|
||||
|
||||
if (xkb->map==NULL) {
|
||||
map= _XkbTypedCalloc(1,XkbClientMapRec);
|
||||
if (map==NULL)
|
||||
return BadAlloc;
|
||||
xkb->map= map;
|
||||
}
|
||||
else map= xkb->map;
|
||||
|
||||
if ((which&XkbKeyTypesMask)&&(nTotalTypes>0)) {
|
||||
if (map->types==NULL) {
|
||||
map->types= _XkbTypedCalloc(nTotalTypes,XkbKeyTypeRec);
|
||||
if (map->types==NULL)
|
||||
return BadAlloc;
|
||||
map->num_types= 0;
|
||||
map->size_types= nTotalTypes;
|
||||
}
|
||||
else if (map->size_types<nTotalTypes) {
|
||||
XkbKeyTypeRec *prev_types = map->types;
|
||||
|
||||
map->types= _XkbTypedRealloc(map->types,nTotalTypes,XkbKeyTypeRec);
|
||||
if (map->types==NULL) {
|
||||
_XkbFree(prev_types);
|
||||
map->num_types= map->size_types= 0;
|
||||
return BadAlloc;
|
||||
}
|
||||
map->size_types= nTotalTypes;
|
||||
bzero(&map->types[map->num_types],
|
||||
((map->size_types-map->num_types)*sizeof(XkbKeyTypeRec)));
|
||||
}
|
||||
}
|
||||
if (which&XkbKeySymsMask) {
|
||||
int nKeys= XkbNumKeys(xkb);
|
||||
if (map->syms==NULL) {
|
||||
map->size_syms= (nKeys*15)/10;
|
||||
map->syms= _XkbTypedCalloc(map->size_syms,KeySym);
|
||||
if (!map->syms) {
|
||||
map->size_syms= 0;
|
||||
return BadAlloc;
|
||||
}
|
||||
map->num_syms= 1;
|
||||
map->syms[0]= NoSymbol;
|
||||
}
|
||||
if (map->key_sym_map==NULL) {
|
||||
i= xkb->max_key_code+1;
|
||||
map->key_sym_map= _XkbTypedCalloc(i,XkbSymMapRec);
|
||||
if (map->key_sym_map==NULL)
|
||||
return BadAlloc;
|
||||
}
|
||||
}
|
||||
if (which&XkbModifierMapMask) {
|
||||
if ((!XkbIsLegalKeycode(xkb->min_key_code))||
|
||||
(!XkbIsLegalKeycode(xkb->max_key_code))||
|
||||
(xkb->max_key_code<xkb->min_key_code))
|
||||
return BadMatch;
|
||||
if (map->modmap==NULL) {
|
||||
i= xkb->max_key_code+1;
|
||||
map->modmap= _XkbTypedCalloc(i,unsigned char);
|
||||
if (map->modmap==NULL)
|
||||
return BadAlloc;
|
||||
}
|
||||
}
|
||||
return Success;
|
||||
}
|
||||
|
||||
Status
|
||||
XkbAllocServerMap(XkbDescPtr xkb,unsigned which,unsigned nNewActions)
|
||||
{
|
||||
register int i;
|
||||
XkbServerMapPtr map;
|
||||
|
||||
if (xkb==NULL)
|
||||
return BadMatch;
|
||||
if (xkb->server==NULL) {
|
||||
map= _XkbTypedCalloc(1,XkbServerMapRec);
|
||||
if (map==NULL)
|
||||
return BadAlloc;
|
||||
for (i=0;i<XkbNumVirtualMods;i++) {
|
||||
map->vmods[i]= XkbNoModifierMask;
|
||||
}
|
||||
xkb->server= map;
|
||||
}
|
||||
else map= xkb->server;
|
||||
if (which&XkbExplicitComponentsMask) {
|
||||
if ((!XkbIsLegalKeycode(xkb->min_key_code))||
|
||||
(!XkbIsLegalKeycode(xkb->max_key_code))||
|
||||
(xkb->max_key_code<xkb->min_key_code))
|
||||
return BadMatch;
|
||||
if (map->explicit==NULL) {
|
||||
i= xkb->max_key_code+1;
|
||||
map->explicit= _XkbTypedCalloc(i,unsigned char);
|
||||
if (map->explicit==NULL)
|
||||
return BadAlloc;
|
||||
}
|
||||
}
|
||||
if (which&XkbKeyActionsMask) {
|
||||
if ((!XkbIsLegalKeycode(xkb->min_key_code))||
|
||||
(!XkbIsLegalKeycode(xkb->max_key_code))||
|
||||
(xkb->max_key_code<xkb->min_key_code))
|
||||
return BadMatch;
|
||||
if (nNewActions<1)
|
||||
nNewActions= 1;
|
||||
if (map->acts==NULL) {
|
||||
map->acts= _XkbTypedCalloc((nNewActions+1),XkbAction);
|
||||
if (map->acts==NULL)
|
||||
return BadAlloc;
|
||||
map->num_acts= 1;
|
||||
map->size_acts= nNewActions+1;
|
||||
}
|
||||
else if ((map->size_acts-map->num_acts)<nNewActions) {
|
||||
unsigned need;
|
||||
XkbAction *prev_acts = map->acts;
|
||||
need= map->num_acts+nNewActions;
|
||||
map->acts= _XkbTypedRealloc(map->acts,need,XkbAction);
|
||||
if (map->acts==NULL) {
|
||||
_XkbFree(prev_acts);
|
||||
map->num_acts= map->size_acts= 0;
|
||||
return BadAlloc;
|
||||
}
|
||||
map->size_acts= need;
|
||||
bzero(&map->acts[map->num_acts],
|
||||
((map->size_acts-map->num_acts)*sizeof(XkbAction)));
|
||||
}
|
||||
if (map->key_acts==NULL) {
|
||||
i= xkb->max_key_code+1;
|
||||
map->key_acts= _XkbTypedCalloc(i,unsigned short);
|
||||
if (map->key_acts==NULL)
|
||||
return BadAlloc;
|
||||
}
|
||||
}
|
||||
if (which&XkbKeyBehaviorsMask) {
|
||||
if ((!XkbIsLegalKeycode(xkb->min_key_code))||
|
||||
(!XkbIsLegalKeycode(xkb->max_key_code))||
|
||||
(xkb->max_key_code<xkb->min_key_code))
|
||||
return BadMatch;
|
||||
if (map->behaviors==NULL) {
|
||||
i= xkb->max_key_code+1;
|
||||
map->behaviors= _XkbTypedCalloc(i,XkbBehavior);
|
||||
if (map->behaviors==NULL)
|
||||
return BadAlloc;
|
||||
}
|
||||
}
|
||||
if (which&XkbVirtualModMapMask) {
|
||||
if ((!XkbIsLegalKeycode(xkb->min_key_code))||
|
||||
(!XkbIsLegalKeycode(xkb->max_key_code))||
|
||||
(xkb->max_key_code<xkb->min_key_code))
|
||||
return BadMatch;
|
||||
if (map->vmodmap==NULL) {
|
||||
i= xkb->max_key_code+1;
|
||||
map->vmodmap= _XkbTypedCalloc(i,unsigned short);
|
||||
if (map->vmodmap==NULL)
|
||||
return BadAlloc;
|
||||
}
|
||||
}
|
||||
return Success;
|
||||
}
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
static Status
|
||||
XkbCopyKeyType(XkbKeyTypePtr from,XkbKeyTypePtr into)
|
||||
{
|
||||
if ((!from)||(!into))
|
||||
return BadMatch;
|
||||
if (into->map) {
|
||||
_XkbFree(into->map);
|
||||
into->map= NULL;
|
||||
}
|
||||
if (into->preserve) {
|
||||
_XkbFree(into->preserve);
|
||||
into->preserve= NULL;
|
||||
}
|
||||
if (into->level_names) {
|
||||
_XkbFree(into->level_names);
|
||||
into->level_names= NULL;
|
||||
}
|
||||
*into= *from;
|
||||
if ((from->map)&&(into->map_count>0)) {
|
||||
into->map= _XkbTypedCalloc(into->map_count,XkbKTMapEntryRec);
|
||||
if (!into->map)
|
||||
return BadAlloc;
|
||||
memcpy(into->map,from->map,into->map_count*sizeof(XkbKTMapEntryRec));
|
||||
}
|
||||
if ((from->preserve)&&(into->map_count>0)) {
|
||||
into->preserve= _XkbTypedCalloc(into->map_count,XkbModsRec);
|
||||
if (!into->preserve)
|
||||
return BadAlloc;
|
||||
memcpy(into->preserve,from->preserve,
|
||||
into->map_count*sizeof(XkbModsRec));
|
||||
}
|
||||
if ((from->level_names)&&(into->num_levels>0)) {
|
||||
into->level_names= _XkbTypedCalloc(into->num_levels,Atom);
|
||||
if (!into->level_names)
|
||||
return BadAlloc;
|
||||
memcpy(into->level_names,from->level_names,
|
||||
into->num_levels*sizeof(Atom));
|
||||
}
|
||||
return Success;
|
||||
}
|
||||
|
||||
Status
|
||||
XkbCopyKeyTypes(XkbKeyTypePtr from,XkbKeyTypePtr into,int num_types)
|
||||
{
|
||||
register int i,rtrn;
|
||||
|
||||
if ((!from)||(!into)||(num_types<0))
|
||||
return BadMatch;
|
||||
for (i=0;i<num_types;i++) {
|
||||
if ((rtrn= XkbCopyKeyType(from++,into++))!=Success)
|
||||
return rtrn;
|
||||
}
|
||||
return Success;
|
||||
}
|
||||
|
||||
Status
|
||||
XkbResizeKeyType( XkbDescPtr xkb,
|
||||
int type_ndx,
|
||||
int map_count,
|
||||
Bool want_preserve,
|
||||
int new_num_lvls)
|
||||
{
|
||||
XkbKeyTypePtr type;
|
||||
KeyCode matchingKeys[XkbMaxKeyCount],nMatchingKeys;
|
||||
|
||||
if ((type_ndx<0)||(type_ndx>=xkb->map->num_types)||(map_count<0)||
|
||||
(new_num_lvls<1))
|
||||
return BadValue;
|
||||
switch (type_ndx) {
|
||||
case XkbOneLevelIndex:
|
||||
if (new_num_lvls!=1)
|
||||
return BadMatch;
|
||||
break;
|
||||
case XkbTwoLevelIndex:
|
||||
case XkbAlphabeticIndex:
|
||||
case XkbKeypadIndex:
|
||||
if (new_num_lvls!=2)
|
||||
return BadMatch;
|
||||
break;
|
||||
}
|
||||
type= &xkb->map->types[type_ndx];
|
||||
if (map_count==0) {
|
||||
if (type->map!=NULL)
|
||||
_XkbFree(type->map);
|
||||
type->map= NULL;
|
||||
if (type->preserve!=NULL)
|
||||
_XkbFree(type->preserve);
|
||||
type->preserve= NULL;
|
||||
type->map_count= 0;
|
||||
}
|
||||
else {
|
||||
XkbKTMapEntryRec *prev_map = type->map;
|
||||
|
||||
if ((map_count>type->map_count)||(type->map==NULL))
|
||||
type->map=_XkbTypedRealloc(type->map,map_count,XkbKTMapEntryRec);
|
||||
if (!type->map) {
|
||||
if (prev_map)
|
||||
_XkbFree(prev_map);
|
||||
return BadAlloc;
|
||||
}
|
||||
if (want_preserve) {
|
||||
XkbModsRec *prev_preserve = type->preserve;
|
||||
|
||||
if ((map_count>type->map_count)||(type->preserve==NULL)) {
|
||||
type->preserve= _XkbTypedRealloc(type->preserve,map_count,
|
||||
XkbModsRec);
|
||||
}
|
||||
if (!type->preserve) {
|
||||
if (prev_preserve)
|
||||
_XkbFree(prev_preserve);
|
||||
return BadAlloc;
|
||||
}
|
||||
}
|
||||
else if (type->preserve!=NULL) {
|
||||
_XkbFree(type->preserve);
|
||||
type->preserve= NULL;
|
||||
}
|
||||
type->map_count= map_count;
|
||||
}
|
||||
|
||||
if ((new_num_lvls>type->num_levels)||(type->level_names==NULL)) {
|
||||
Atom * prev_level_names = type->level_names;
|
||||
|
||||
type->level_names=_XkbTypedRealloc(type->level_names,new_num_lvls,Atom);
|
||||
if (!type->level_names) {
|
||||
if (prev_level_names)
|
||||
_XkbFree(prev_level_names);
|
||||
return BadAlloc;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Here's the theory:
|
||||
* If the width of the type changed, we might have to resize the symbol
|
||||
* maps for any keys that use the type for one or more groups. This is
|
||||
* expensive, so we'll try to cull out any keys that are obviously okay:
|
||||
* In any case:
|
||||
* - keys that have a group width <= the old width are okay (because
|
||||
* they could not possibly have been associated with the old type)
|
||||
* If the key type increased in size:
|
||||
* - keys that already have a group width >= to the new width are okay
|
||||
* + keys that have a group width >= the old width but < the new width
|
||||
* might have to be enlarged.
|
||||
* If the key type decreased in size:
|
||||
* - keys that have a group width > the old width don't have to be
|
||||
* resized (because they must have some other wider type associated
|
||||
* with some group).
|
||||
* + keys that have a group width == the old width might have to be
|
||||
* shrunk.
|
||||
* The possibilities marked with '+' require us to examine the key types
|
||||
* associated with each group for the key.
|
||||
*/
|
||||
bzero(matchingKeys,XkbMaxKeyCount*sizeof(KeyCode));
|
||||
nMatchingKeys= 0;
|
||||
if (new_num_lvls>type->num_levels) {
|
||||
int nTotal;
|
||||
KeySym * newSyms;
|
||||
int width,match,nResize;
|
||||
register int i,g,nSyms;
|
||||
|
||||
nResize= 0;
|
||||
for (nTotal=1,i=xkb->min_key_code;i<=xkb->max_key_code;i++) {
|
||||
width= XkbKeyGroupsWidth(xkb,i);
|
||||
if (width<type->num_levels)
|
||||
continue;
|
||||
for (match=0,g=XkbKeyNumGroups(xkb,i)-1;(g>=0)&&(!match);g--) {
|
||||
if (XkbKeyKeyTypeIndex(xkb,i,g)==type_ndx) {
|
||||
matchingKeys[nMatchingKeys++]= i;
|
||||
match= 1;
|
||||
}
|
||||
}
|
||||
if ((!match)||(width>=new_num_lvls))
|
||||
nTotal+= XkbKeyNumSyms(xkb,i);
|
||||
else {
|
||||
nTotal+= XkbKeyNumGroups(xkb,i)*new_num_lvls;
|
||||
nResize++;
|
||||
}
|
||||
}
|
||||
if (nResize>0) {
|
||||
int nextMatch;
|
||||
xkb->map->size_syms= (nTotal*15)/10;
|
||||
newSyms = _XkbTypedCalloc(xkb->map->size_syms,KeySym);
|
||||
if (newSyms==NULL)
|
||||
return BadAlloc;
|
||||
nextMatch= 0;
|
||||
nSyms= 1;
|
||||
for (i=xkb->min_key_code;i<=xkb->max_key_code;i++) {
|
||||
if (matchingKeys[nextMatch]==i) {
|
||||
KeySym *pOld;
|
||||
nextMatch++;
|
||||
width= XkbKeyGroupsWidth(xkb,i);
|
||||
pOld= XkbKeySymsPtr(xkb,i);
|
||||
for (g=XkbKeyNumGroups(xkb,i)-1;g>=0;g--) {
|
||||
memcpy(&newSyms[nSyms+(new_num_lvls*g)],&pOld[width*g],
|
||||
width*sizeof(KeySym));
|
||||
}
|
||||
xkb->map->key_sym_map[i].offset= nSyms;
|
||||
nSyms+= XkbKeyNumGroups(xkb,i)*new_num_lvls;
|
||||
}
|
||||
else {
|
||||
memcpy(&newSyms[nSyms],XkbKeySymsPtr(xkb,i),
|
||||
XkbKeyNumSyms(xkb,i)*sizeof(KeySym));
|
||||
xkb->map->key_sym_map[i].offset= nSyms;
|
||||
nSyms+= XkbKeyNumSyms(xkb,i);
|
||||
}
|
||||
}
|
||||
type->num_levels= new_num_lvls;
|
||||
_XkbFree(xkb->map->syms);
|
||||
xkb->map->syms= newSyms;
|
||||
xkb->map->num_syms= nSyms;
|
||||
return Success;
|
||||
}
|
||||
}
|
||||
else if (new_num_lvls<type->num_levels) {
|
||||
int width,match;
|
||||
register int g,i;
|
||||
for (i=xkb->min_key_code;i<=xkb->max_key_code;i++) {
|
||||
width= XkbKeyGroupsWidth(xkb,i);
|
||||
if (width<type->num_levels)
|
||||
continue;
|
||||
for (match=0,g=XkbKeyNumGroups(xkb,i)-1;(g>=0)&&(!match);g--) {
|
||||
if (XkbKeyKeyTypeIndex(xkb,i,g)==type_ndx) {
|
||||
matchingKeys[nMatchingKeys++]= i;
|
||||
match= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (nMatchingKeys>0) {
|
||||
int key,firstClear;
|
||||
register int i,g;
|
||||
if (new_num_lvls>type->num_levels)
|
||||
firstClear= type->num_levels;
|
||||
else firstClear= new_num_lvls;
|
||||
for (i=0;i<nMatchingKeys;i++) {
|
||||
KeySym * pSyms;
|
||||
int width,nClear;
|
||||
|
||||
key= matchingKeys[i];
|
||||
width= XkbKeyGroupsWidth(xkb,key);
|
||||
nClear= width-firstClear;
|
||||
pSyms= XkbKeySymsPtr(xkb,key);
|
||||
for (g=XkbKeyNumGroups(xkb,key)-1;g>=0;g--) {
|
||||
if (XkbKeyKeyTypeIndex(xkb,key,g)==type_ndx) {
|
||||
if (nClear>0)
|
||||
bzero(&pSyms[g*width+firstClear],nClear*sizeof(KeySym));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
type->num_levels= new_num_lvls;
|
||||
return Success;
|
||||
}
|
||||
|
||||
KeySym *
|
||||
XkbResizeKeySyms(XkbDescPtr xkb,int key,int needed)
|
||||
{
|
||||
register int i,nSyms,nKeySyms;
|
||||
unsigned nOldSyms;
|
||||
KeySym *newSyms;
|
||||
|
||||
if (needed==0) {
|
||||
xkb->map->key_sym_map[key].offset= 0;
|
||||
return xkb->map->syms;
|
||||
}
|
||||
nOldSyms= XkbKeyNumSyms(xkb,key);
|
||||
if (nOldSyms>=(unsigned)needed) {
|
||||
return XkbKeySymsPtr(xkb,key);
|
||||
}
|
||||
if (xkb->map->size_syms-xkb->map->num_syms>=(unsigned)needed) {
|
||||
if (nOldSyms>0) {
|
||||
memcpy(&xkb->map->syms[xkb->map->num_syms],XkbKeySymsPtr(xkb,key),
|
||||
nOldSyms*sizeof(KeySym));
|
||||
}
|
||||
if ((needed-nOldSyms)>0) {
|
||||
bzero(&xkb->map->syms[xkb->map->num_syms+XkbKeyNumSyms(xkb,key)],
|
||||
(needed-nOldSyms)*sizeof(KeySym));
|
||||
}
|
||||
xkb->map->key_sym_map[key].offset = xkb->map->num_syms;
|
||||
xkb->map->num_syms+= needed;
|
||||
return &xkb->map->syms[xkb->map->key_sym_map[key].offset];
|
||||
}
|
||||
xkb->map->size_syms+= (needed>32?needed:32);
|
||||
newSyms = _XkbTypedCalloc(xkb->map->size_syms,KeySym);
|
||||
if (newSyms==NULL)
|
||||
return NULL;
|
||||
newSyms[0]= NoSymbol;
|
||||
nSyms = 1;
|
||||
for (i=xkb->min_key_code;i<=(int)xkb->max_key_code;i++) {
|
||||
int nCopy;
|
||||
|
||||
nCopy= nKeySyms= XkbKeyNumSyms(xkb,i);
|
||||
if ((nKeySyms==0)&&(i!=key))
|
||||
continue;
|
||||
if (i==key)
|
||||
nKeySyms= needed;
|
||||
if (nCopy!=0)
|
||||
memcpy(&newSyms[nSyms],XkbKeySymsPtr(xkb,i),nCopy*sizeof(KeySym));
|
||||
if (nKeySyms>nCopy)
|
||||
bzero(&newSyms[nSyms+nCopy],(nKeySyms-nCopy)*sizeof(KeySym));
|
||||
xkb->map->key_sym_map[i].offset = nSyms;
|
||||
nSyms+= nKeySyms;
|
||||
}
|
||||
_XkbFree(xkb->map->syms);
|
||||
xkb->map->syms = newSyms;
|
||||
xkb->map->num_syms = nSyms;
|
||||
return &xkb->map->syms[xkb->map->key_sym_map[key].offset];
|
||||
}
|
||||
|
||||
static unsigned
|
||||
_ExtendRange( unsigned int old_flags,
|
||||
unsigned int flag,
|
||||
KeyCode newKC,
|
||||
KeyCode * old_min,
|
||||
unsigned char * old_num)
|
||||
{
|
||||
if ((old_flags&flag)==0) {
|
||||
old_flags|= flag;
|
||||
*old_min= newKC;
|
||||
*old_num= 1;
|
||||
}
|
||||
else {
|
||||
int last= (*old_min)+(*old_num)-1;
|
||||
if (newKC<*old_min) {
|
||||
*old_min= newKC;
|
||||
*old_num= (last-newKC)+1;
|
||||
}
|
||||
else if (newKC>last) {
|
||||
*old_num= (newKC-(*old_min))+1;
|
||||
}
|
||||
}
|
||||
return old_flags;
|
||||
}
|
||||
|
||||
Status
|
||||
XkbChangeKeycodeRange( XkbDescPtr xkb,
|
||||
int minKC,
|
||||
int maxKC,
|
||||
XkbChangesPtr changes)
|
||||
{
|
||||
int tmp;
|
||||
|
||||
if ((!xkb)||(minKC<XkbMinLegalKeyCode)||(maxKC>XkbMaxLegalKeyCode))
|
||||
return BadValue;
|
||||
if (minKC>maxKC)
|
||||
return BadMatch;
|
||||
if (minKC<xkb->min_key_code) {
|
||||
if (changes)
|
||||
changes->map.min_key_code= minKC;
|
||||
tmp= xkb->min_key_code-minKC;
|
||||
if (xkb->map) {
|
||||
if (xkb->map->key_sym_map) {
|
||||
bzero((char *)&xkb->map->key_sym_map[minKC],
|
||||
tmp*sizeof(XkbSymMapRec));
|
||||
if (changes) {
|
||||
changes->map.changed= _ExtendRange(changes->map.changed,
|
||||
XkbKeySymsMask,minKC,
|
||||
&changes->map.first_key_sym,
|
||||
&changes->map.num_key_syms);
|
||||
}
|
||||
}
|
||||
if (xkb->map->modmap) {
|
||||
bzero((char *)&xkb->map->modmap[minKC],tmp);
|
||||
if (changes) {
|
||||
changes->map.changed= _ExtendRange(changes->map.changed,
|
||||
XkbModifierMapMask,minKC,
|
||||
&changes->map.first_modmap_key,
|
||||
&changes->map.num_modmap_keys);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (xkb->server) {
|
||||
if (xkb->server->behaviors) {
|
||||
bzero((char *)&xkb->server->behaviors[minKC],
|
||||
tmp*sizeof(XkbBehavior));
|
||||
if (changes) {
|
||||
changes->map.changed= _ExtendRange(changes->map.changed,
|
||||
XkbKeyBehaviorsMask,minKC,
|
||||
&changes->map.first_key_behavior,
|
||||
&changes->map.num_key_behaviors);
|
||||
}
|
||||
}
|
||||
if (xkb->server->key_acts) {
|
||||
bzero((char *)&xkb->server->key_acts[minKC],
|
||||
tmp*sizeof(unsigned short));
|
||||
if (changes) {
|
||||
changes->map.changed= _ExtendRange(changes->map.changed,
|
||||
XkbKeyActionsMask,minKC,
|
||||
&changes->map.first_key_act,
|
||||
&changes->map.num_key_acts);
|
||||
}
|
||||
}
|
||||
if (xkb->server->vmodmap) {
|
||||
bzero((char *)&xkb->server->vmodmap[minKC],
|
||||
tmp*sizeof(unsigned short));
|
||||
if (changes) {
|
||||
changes->map.changed= _ExtendRange(changes->map.changed,
|
||||
XkbVirtualModMapMask,minKC,
|
||||
&changes->map.first_modmap_key,
|
||||
&changes->map.num_vmodmap_keys);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((xkb->names)&&(xkb->names->keys)) {
|
||||
bzero((char *)&xkb->names->keys[minKC],tmp*sizeof(XkbKeyNameRec));
|
||||
if (changes) {
|
||||
changes->names.changed= _ExtendRange(changes->names.changed,
|
||||
XkbKeyNamesMask,minKC,
|
||||
&changes->names.first_key,
|
||||
&changes->names.num_keys);
|
||||
}
|
||||
}
|
||||
xkb->min_key_code= minKC;
|
||||
}
|
||||
if (maxKC>xkb->max_key_code) {
|
||||
if (changes)
|
||||
changes->map.max_key_code= maxKC;
|
||||
tmp= maxKC-xkb->max_key_code;
|
||||
if (xkb->map) {
|
||||
if (xkb->map->key_sym_map) {
|
||||
XkbSymMapRec *prev_key_sym_map = xkb->map->key_sym_map;
|
||||
|
||||
xkb->map->key_sym_map= _XkbTypedRealloc(xkb->map->key_sym_map,
|
||||
(maxKC+1),XkbSymMapRec);
|
||||
if (!xkb->map->key_sym_map) {
|
||||
_XkbFree(prev_key_sym_map);
|
||||
return BadAlloc;
|
||||
}
|
||||
#ifdef NXAGENT_SERVER
|
||||
bzero((char *)&xkb->map->key_sym_map[xkb->max_key_code+1],
|
||||
tmp*sizeof(XkbSymMapRec));
|
||||
#else
|
||||
bzero((char *)&xkb->map->key_sym_map[xkb->max_key_code],
|
||||
tmp*sizeof(XkbSymMapRec));
|
||||
#endif
|
||||
if (changes) {
|
||||
changes->map.changed= _ExtendRange(changes->map.changed,
|
||||
XkbKeySymsMask,maxKC,
|
||||
&changes->map.first_key_sym,
|
||||
&changes->map.num_key_syms);
|
||||
}
|
||||
}
|
||||
if (xkb->map->modmap) {
|
||||
unsigned char *prev_modmap = xkb->map->modmap;
|
||||
|
||||
xkb->map->modmap= _XkbTypedRealloc(xkb->map->modmap,
|
||||
(maxKC+1),unsigned char);
|
||||
if (!xkb->map->modmap) {
|
||||
_XkbFree(prev_modmap);
|
||||
return BadAlloc;
|
||||
}
|
||||
#ifdef NXAGENT_SERVER
|
||||
bzero((char *)&xkb->map->modmap[xkb->max_key_code+1],tmp);
|
||||
#else
|
||||
bzero((char *)&xkb->map->modmap[xkb->max_key_code],tmp);
|
||||
#endif
|
||||
if (changes) {
|
||||
changes->map.changed= _ExtendRange(changes->map.changed,
|
||||
XkbModifierMapMask,maxKC,
|
||||
&changes->map.first_modmap_key,
|
||||
&changes->map.num_modmap_keys);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (xkb->server) {
|
||||
if (xkb->server->behaviors) {
|
||||
XkbBehavior *prev_behaviors = xkb->server->behaviors;
|
||||
|
||||
xkb->server->behaviors=_XkbTypedRealloc(xkb->server->behaviors,
|
||||
(maxKC+1),XkbBehavior);
|
||||
if (!xkb->server->behaviors) {
|
||||
_XkbFree(prev_behaviors);
|
||||
return BadAlloc;
|
||||
}
|
||||
#ifdef NXAGENT_SERVER
|
||||
bzero((char *)&xkb->server->behaviors[xkb->max_key_code+1],
|
||||
tmp*sizeof(XkbBehavior));
|
||||
#else
|
||||
bzero((char *)&xkb->server->behaviors[xkb->max_key_code],
|
||||
tmp*sizeof(XkbBehavior));
|
||||
#endif
|
||||
if (changes) {
|
||||
changes->map.changed= _ExtendRange(changes->map.changed,
|
||||
XkbKeyBehaviorsMask,maxKC,
|
||||
&changes->map.first_key_behavior,
|
||||
&changes->map.num_key_behaviors);
|
||||
}
|
||||
}
|
||||
if (xkb->server->key_acts) {
|
||||
unsigned short *prev_key_acts = xkb->server->key_acts;
|
||||
|
||||
xkb->server->key_acts= _XkbTypedRealloc(xkb->server->key_acts,
|
||||
(maxKC+1),unsigned short);
|
||||
if (!xkb->server->key_acts) {
|
||||
_XkbFree(prev_key_acts);
|
||||
return BadAlloc;
|
||||
}
|
||||
#ifdef NXAGENT_SERVER
|
||||
bzero((char *)&xkb->server->key_acts[xkb->max_key_code+1],
|
||||
tmp*sizeof(unsigned short));
|
||||
#else
|
||||
bzero((char *)&xkb->server->key_acts[xkb->max_key_code],
|
||||
tmp*sizeof(unsigned short));
|
||||
#endif
|
||||
if (changes) {
|
||||
changes->map.changed= _ExtendRange(changes->map.changed,
|
||||
XkbKeyActionsMask,maxKC,
|
||||
&changes->map.first_key_act,
|
||||
&changes->map.num_key_acts);
|
||||
}
|
||||
}
|
||||
if (xkb->server->vmodmap) {
|
||||
unsigned short *prev_vmodmap = xkb->server->vmodmap;
|
||||
|
||||
xkb->server->vmodmap= _XkbTypedRealloc(xkb->server->vmodmap,
|
||||
(maxKC+1),unsigned short);
|
||||
if (!xkb->server->vmodmap) {
|
||||
_XkbFree(prev_vmodmap);
|
||||
return BadAlloc;
|
||||
}
|
||||
#ifdef NXAGENT_SERVER
|
||||
bzero((char *)&xkb->server->vmodmap[xkb->max_key_code+1],
|
||||
tmp*sizeof(unsigned short));
|
||||
#else
|
||||
bzero((char *)&xkb->server->vmodmap[xkb->max_key_code],
|
||||
tmp*sizeof(unsigned short));
|
||||
#endif
|
||||
if (changes) {
|
||||
changes->map.changed= _ExtendRange(changes->map.changed,
|
||||
XkbVirtualModMapMask,maxKC,
|
||||
&changes->map.first_modmap_key,
|
||||
&changes->map.num_vmodmap_keys);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((xkb->names)&&(xkb->names->keys)) {
|
||||
XkbKeyNameRec *prev_keys = xkb->names->keys;
|
||||
|
||||
xkb->names->keys= _XkbTypedRealloc(xkb->names->keys,
|
||||
(maxKC+1),XkbKeyNameRec);
|
||||
if (!xkb->names->keys) {
|
||||
_XkbFree(prev_keys);
|
||||
return BadAlloc;
|
||||
}
|
||||
#ifdef NXAGENT_SERVER
|
||||
bzero((char *)&xkb->names->keys[xkb->max_key_code+1],
|
||||
tmp*sizeof(XkbKeyNameRec));
|
||||
#else
|
||||
bzero((char *)&xkb->names->keys[xkb->max_key_code],
|
||||
tmp*sizeof(XkbKeyNameRec));
|
||||
#endif
|
||||
if (changes) {
|
||||
changes->names.changed= _ExtendRange(changes->names.changed,
|
||||
XkbKeyNamesMask,maxKC,
|
||||
&changes->names.first_key,
|
||||
&changes->names.num_keys);
|
||||
}
|
||||
}
|
||||
xkb->max_key_code= maxKC;
|
||||
}
|
||||
return Success;
|
||||
}
|
||||
|
||||
XkbAction *
|
||||
XkbResizeKeyActions(XkbDescPtr xkb,int key,int needed)
|
||||
{
|
||||
register int i,nActs;
|
||||
XkbAction *newActs;
|
||||
|
||||
if (needed==0) {
|
||||
xkb->server->key_acts[key]= 0;
|
||||
return NULL;
|
||||
}
|
||||
if (XkbKeyHasActions(xkb,key)&&(XkbKeyNumSyms(xkb,key)>=(unsigned)needed))
|
||||
return XkbKeyActionsPtr(xkb,key);
|
||||
if (xkb->server->size_acts-xkb->server->num_acts>=(unsigned)needed) {
|
||||
xkb->server->key_acts[key]= xkb->server->num_acts;
|
||||
xkb->server->num_acts+= needed;
|
||||
return &xkb->server->acts[xkb->server->key_acts[key]];
|
||||
}
|
||||
xkb->server->size_acts= xkb->server->num_acts+needed+8;
|
||||
newActs = _XkbTypedCalloc(xkb->server->size_acts,XkbAction);
|
||||
if (newActs==NULL)
|
||||
return NULL;
|
||||
newActs[0].type = XkbSA_NoAction;
|
||||
nActs = 1;
|
||||
for (i=xkb->min_key_code;i<=(int)xkb->max_key_code;i++) {
|
||||
int nKeyActs,nCopy;
|
||||
|
||||
if ((xkb->server->key_acts[i]==0)&&(i!=key))
|
||||
continue;
|
||||
|
||||
nCopy= nKeyActs= XkbKeyNumActions(xkb,i);
|
||||
if (i==key) {
|
||||
nKeyActs= needed;
|
||||
if (needed<nCopy)
|
||||
nCopy= needed;
|
||||
}
|
||||
|
||||
if (nCopy>0)
|
||||
memcpy(&newActs[nActs],XkbKeyActionsPtr(xkb,i),
|
||||
nCopy*sizeof(XkbAction));
|
||||
if (nCopy<nKeyActs)
|
||||
bzero(&newActs[nActs+nCopy],(nKeyActs-nCopy)*sizeof(XkbAction));
|
||||
xkb->server->key_acts[i]= nActs;
|
||||
nActs+= nKeyActs;
|
||||
}
|
||||
_XkbFree(xkb->server->acts);
|
||||
xkb->server->acts = newActs;
|
||||
xkb->server->num_acts= nActs;
|
||||
return &xkb->server->acts[xkb->server->key_acts[key]];
|
||||
}
|
||||
|
||||
void
|
||||
XkbFreeClientMap(XkbDescPtr xkb,unsigned what,Bool freeMap)
|
||||
{
|
||||
XkbClientMapPtr map;
|
||||
|
||||
if ((xkb==NULL)||(xkb->map==NULL))
|
||||
return;
|
||||
if (freeMap)
|
||||
what= XkbAllClientInfoMask;
|
||||
map= xkb->map;
|
||||
if (what&XkbKeyTypesMask) {
|
||||
if (map->types!=NULL) {
|
||||
if (map->num_types>0) {
|
||||
register int i;
|
||||
XkbKeyTypePtr type;
|
||||
for (i=0,type=map->types;i<map->num_types;i++,type++) {
|
||||
if (type->map!=NULL) {
|
||||
_XkbFree(type->map);
|
||||
type->map= NULL;
|
||||
}
|
||||
if (type->preserve!=NULL) {
|
||||
_XkbFree(type->preserve);
|
||||
type->preserve= NULL;
|
||||
}
|
||||
type->map_count= 0;
|
||||
if (type->level_names!=NULL) {
|
||||
_XkbFree(type->level_names);
|
||||
type->level_names= NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
_XkbFree(map->types);
|
||||
map->num_types= map->size_types= 0;
|
||||
map->types= NULL;
|
||||
}
|
||||
}
|
||||
if (what&XkbKeySymsMask) {
|
||||
if (map->key_sym_map!=NULL) {
|
||||
_XkbFree(map->key_sym_map);
|
||||
map->key_sym_map= NULL;
|
||||
}
|
||||
if (map->syms!=NULL) {
|
||||
_XkbFree(map->syms);
|
||||
map->size_syms= map->num_syms= 0;
|
||||
map->syms= NULL;
|
||||
}
|
||||
}
|
||||
if ((what&XkbModifierMapMask)&&(map->modmap!=NULL)) {
|
||||
_XkbFree(map->modmap);
|
||||
map->modmap= NULL;
|
||||
}
|
||||
if (freeMap) {
|
||||
_XkbFree(xkb->map);
|
||||
xkb->map= NULL;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
XkbFreeServerMap(XkbDescPtr xkb,unsigned what,Bool freeMap)
|
||||
{
|
||||
XkbServerMapPtr map;
|
||||
|
||||
if ((xkb==NULL)||(xkb->server==NULL))
|
||||
return;
|
||||
if (freeMap)
|
||||
what= XkbAllServerInfoMask;
|
||||
map= xkb->server;
|
||||
if ((what&XkbExplicitComponentsMask)&&(map->explicit!=NULL)) {
|
||||
_XkbFree(map->explicit);
|
||||
map->explicit= NULL;
|
||||
}
|
||||
if (what&XkbKeyActionsMask) {
|
||||
if (map->key_acts!=NULL) {
|
||||
_XkbFree(map->key_acts);
|
||||
map->key_acts= NULL;
|
||||
}
|
||||
if (map->acts!=NULL) {
|
||||
_XkbFree(map->acts);
|
||||
map->num_acts= map->size_acts= 0;
|
||||
map->acts= NULL;
|
||||
}
|
||||
}
|
||||
if ((what&XkbKeyBehaviorsMask)&&(map->behaviors!=NULL)) {
|
||||
_XkbFree(map->behaviors);
|
||||
map->behaviors= NULL;
|
||||
}
|
||||
if ((what&XkbVirtualModMapMask)&&(map->vmodmap!=NULL)) {
|
||||
_XkbFree(map->vmodmap);
|
||||
map->vmodmap= NULL;
|
||||
}
|
||||
|
||||
if (freeMap) {
|
||||
_XkbFree(xkb->server);
|
||||
xkb->server= NULL;
|
||||
}
|
||||
return;
|
||||
}
|
||||
785
nx-X11/programs/Xserver/xkb/XKBMisc.c
Normal file
785
nx-X11/programs/Xserver/xkb/XKBMisc.c
Normal file
@@ -0,0 +1,785 @@
|
||||
/************************************************************
|
||||
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_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#elif defined(HAVE_CONFIG_H)
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <nx-X11/X.h>
|
||||
#include <nx-X11/Xproto.h>
|
||||
#include "misc.h"
|
||||
#include "inputstr.h"
|
||||
#include <nx-X11/keysym.h>
|
||||
#include <xkbsrv.h>
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
#define CORE_SYM(i) (i<map_width?core_syms[i]:NoSymbol)
|
||||
#define XKB_OFFSET(g,l) (((g)*groupsWidth)+(l))
|
||||
|
||||
int
|
||||
XkbKeyTypesForCoreSymbols( XkbDescPtr xkb,
|
||||
int map_width,
|
||||
KeySym * core_syms,
|
||||
unsigned int protected,
|
||||
int * types_inout,
|
||||
KeySym * xkb_syms_rtrn)
|
||||
{
|
||||
register int i;
|
||||
unsigned int empty;
|
||||
int nSyms[XkbNumKbdGroups];
|
||||
int nGroups,tmp,groupsWidth;
|
||||
|
||||
/* Section 12.2 of the protocol describes this process in more detail */
|
||||
/* Step 1: find the # of symbols in the core mapping per group */
|
||||
groupsWidth= 2;
|
||||
for (i=0;i<XkbNumKbdGroups;i++) {
|
||||
if ((protected&(1<<i))&&(types_inout[i]<xkb->map->num_types)) {
|
||||
nSyms[i]= xkb->map->types[types_inout[i]].num_levels;
|
||||
if (nSyms[i]>groupsWidth)
|
||||
groupsWidth= nSyms[i];
|
||||
}
|
||||
else {
|
||||
types_inout[i]= XkbTwoLevelIndex; /* don't really know, yet */
|
||||
nSyms[i]= 2;
|
||||
}
|
||||
}
|
||||
if (nSyms[XkbGroup1Index]<2)
|
||||
nSyms[XkbGroup1Index]= 2;
|
||||
if (nSyms[XkbGroup2Index]<2)
|
||||
nSyms[XkbGroup2Index]= 2;
|
||||
/* Step 2: Copy the symbols from the core ordering to XKB ordering */
|
||||
/* symbols in the core are in the order: */
|
||||
/* G1L1 G1L2 G2L1 G2L2 [G1L[3-n]] [G2L[3-n]] [G3L*] [G3L*] */
|
||||
xkb_syms_rtrn[XKB_OFFSET(XkbGroup1Index,0)]= CORE_SYM(0);
|
||||
xkb_syms_rtrn[XKB_OFFSET(XkbGroup1Index,1)]= CORE_SYM(1);
|
||||
for (i=2;i<nSyms[XkbGroup1Index];i++) {
|
||||
xkb_syms_rtrn[XKB_OFFSET(XkbGroup1Index,i)]= CORE_SYM(2+i);
|
||||
}
|
||||
xkb_syms_rtrn[XKB_OFFSET(XkbGroup2Index,0)]= CORE_SYM(2);
|
||||
xkb_syms_rtrn[XKB_OFFSET(XkbGroup2Index,1)]= CORE_SYM(3);
|
||||
tmp= 2+(nSyms[XkbGroup1Index]-2); /* offset to extra group2 syms */
|
||||
for (i=2;i<nSyms[XkbGroup2Index];i++) {
|
||||
xkb_syms_rtrn[XKB_OFFSET(XkbGroup2Index,i)]= CORE_SYM(tmp+i);
|
||||
}
|
||||
tmp= nSyms[XkbGroup1Index]+nSyms[XkbGroup2Index];
|
||||
if ((tmp>=map_width)&&
|
||||
((protected&(XkbExplicitKeyType3Mask|XkbExplicitKeyType4Mask))==0)) {
|
||||
nSyms[XkbGroup3Index]= 0;
|
||||
nSyms[XkbGroup4Index]= 0;
|
||||
nGroups= 2;
|
||||
}
|
||||
else {
|
||||
nGroups= 3;
|
||||
for (i=0;i<nSyms[XkbGroup3Index];i++,tmp++) {
|
||||
xkb_syms_rtrn[XKB_OFFSET(XkbGroup3Index,i)]= CORE_SYM(tmp);
|
||||
}
|
||||
if ((tmp<map_width)||(protected&XkbExplicitKeyType4Mask)) {
|
||||
nGroups= 4;
|
||||
for (i=0;i<nSyms[XkbGroup4Index];i++,tmp++) {
|
||||
xkb_syms_rtrn[XKB_OFFSET(XkbGroup4Index,i)]= CORE_SYM(tmp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
nSyms[XkbGroup4Index]= 0;
|
||||
}
|
||||
}
|
||||
/* steps 3&4: alphanumeric expansion, assign canonical types */
|
||||
empty= 0;
|
||||
for (i=0;i<nGroups;i++) {
|
||||
KeySym *syms;
|
||||
syms= &xkb_syms_rtrn[XKB_OFFSET(i,0)];
|
||||
if ((nSyms[i]>1)&&(syms[1]==NoSymbol)&&(syms[0]!=NoSymbol)) {
|
||||
KeySym upper,lower;
|
||||
XConvertCase(syms[0],&lower,&upper);
|
||||
if (upper!=lower) {
|
||||
xkb_syms_rtrn[XKB_OFFSET(i,0)]= lower;
|
||||
xkb_syms_rtrn[XKB_OFFSET(i,1)]= upper;
|
||||
if ((protected&(1<<i))==0)
|
||||
types_inout[i]= XkbAlphabeticIndex;
|
||||
}
|
||||
else if ((protected&(1<<i))==0) {
|
||||
types_inout[i]= XkbOneLevelIndex;
|
||||
/* nSyms[i]= 1;*/
|
||||
}
|
||||
}
|
||||
if (((protected&(1<<i))==0)&&(types_inout[i]==XkbTwoLevelIndex)) {
|
||||
if (IsKeypadKey(syms[0])||IsKeypadKey(syms[1]))
|
||||
types_inout[i]= XkbKeypadIndex;
|
||||
else {
|
||||
KeySym upper,lower;
|
||||
XConvertCase(syms[0],&lower,&upper);
|
||||
if ((syms[0]==lower)&&(syms[1]==upper))
|
||||
types_inout[i]= XkbAlphabeticIndex;
|
||||
}
|
||||
}
|
||||
if (syms[0]==NoSymbol) {
|
||||
register int n;
|
||||
Bool found;
|
||||
for (n=1,found=False;(!found)&&(n<nSyms[i]);n++) {
|
||||
found= (syms[n]!=NoSymbol);
|
||||
}
|
||||
if (!found)
|
||||
empty|= (1<<i);
|
||||
}
|
||||
}
|
||||
/* step 5: squoosh out empty groups */
|
||||
if (empty) {
|
||||
for (i=nGroups-1;i>=0;i--) {
|
||||
if (((empty&(1<<i))==0)||(protected&(1<<i)))
|
||||
break;
|
||||
nGroups--;
|
||||
}
|
||||
}
|
||||
if (nGroups<1)
|
||||
return 0;
|
||||
|
||||
/* step 6: replicate group 1 into group two, if necessary */
|
||||
if ((nGroups>1)&&((empty&(XkbGroup1Mask|XkbGroup2Mask))==XkbGroup2Mask)) {
|
||||
if ((protected&(XkbExplicitKeyType1Mask|XkbExplicitKeyType2Mask))==0) {
|
||||
nSyms[XkbGroup2Index]= nSyms[XkbGroup1Index];
|
||||
types_inout[XkbGroup2Index]= types_inout[XkbGroup1Index];
|
||||
memcpy((char *)&xkb_syms_rtrn[2],(char *)xkb_syms_rtrn,
|
||||
2*sizeof(KeySym));
|
||||
}
|
||||
else if (types_inout[XkbGroup1Index]==types_inout[XkbGroup2Index]) {
|
||||
memcpy((char *)&xkb_syms_rtrn[nSyms[XkbGroup1Index]],
|
||||
(char *)xkb_syms_rtrn,
|
||||
nSyms[XkbGroup1Index]*sizeof(KeySym));
|
||||
}
|
||||
}
|
||||
|
||||
/* step 7: check for all groups identical or all width 1 */
|
||||
if (nGroups>1) {
|
||||
Bool sameType,allOneLevel;
|
||||
allOneLevel= (xkb->map->types[types_inout[0]].num_levels==1);
|
||||
for (i=1,sameType=True;(allOneLevel||sameType)&&(i<nGroups);i++) {
|
||||
sameType=(sameType&&(types_inout[i]==types_inout[XkbGroup1Index]));
|
||||
if (allOneLevel)
|
||||
allOneLevel= (xkb->map->types[types_inout[i]].num_levels==1);
|
||||
}
|
||||
if ((sameType)&&
|
||||
(!(protected&(XkbExplicitKeyTypesMask&~XkbExplicitKeyType1Mask)))){
|
||||
register int s;
|
||||
Bool identical;
|
||||
for (i=1,identical=True;identical&&(i<nGroups);i++) {
|
||||
KeySym *syms;
|
||||
syms= &xkb_syms_rtrn[XKB_OFFSET(i,0)];
|
||||
for (s=0;identical&&(s<nSyms[i]);s++) {
|
||||
if (syms[s]!=xkb_syms_rtrn[s])
|
||||
identical= False;
|
||||
}
|
||||
}
|
||||
if (identical)
|
||||
nGroups= 1;
|
||||
}
|
||||
if (allOneLevel && (nGroups>1)) {
|
||||
KeySym *syms;
|
||||
syms= &xkb_syms_rtrn[nSyms[XkbGroup1Index]];
|
||||
nSyms[XkbGroup1Index]= 1;
|
||||
for (i=1;i<nGroups;i++) {
|
||||
xkb_syms_rtrn[i]= syms[0];
|
||||
syms+= nSyms[i];
|
||||
nSyms[i]= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return nGroups;
|
||||
}
|
||||
|
||||
static XkbSymInterpretPtr
|
||||
_XkbFindMatchingInterp( XkbDescPtr xkb,
|
||||
KeySym sym,
|
||||
unsigned int real_mods,
|
||||
unsigned int level)
|
||||
{
|
||||
register unsigned i;
|
||||
XkbSymInterpretPtr interp,rtrn;
|
||||
CARD8 mods;
|
||||
|
||||
rtrn= NULL;
|
||||
interp= xkb->compat->sym_interpret;
|
||||
for (i=0;i<xkb->compat->num_si;i++,interp++) {
|
||||
if ((interp->sym==NoSymbol)||(sym==interp->sym)) {
|
||||
int match;
|
||||
if ((level==0)||((interp->match&XkbSI_LevelOneOnly)==0))
|
||||
mods= real_mods;
|
||||
else mods= 0;
|
||||
switch (interp->match&XkbSI_OpMask) {
|
||||
case XkbSI_NoneOf:
|
||||
match= ((interp->mods&mods)==0);
|
||||
break;
|
||||
case XkbSI_AnyOfOrNone:
|
||||
match= ((mods==0)||((interp->mods&mods)!=0));
|
||||
break;
|
||||
case XkbSI_AnyOf:
|
||||
match= ((interp->mods&mods)!=0);
|
||||
break;
|
||||
case XkbSI_AllOf:
|
||||
match= ((interp->mods&mods)==interp->mods);
|
||||
break;
|
||||
case XkbSI_Exactly:
|
||||
match= (interp->mods==mods);
|
||||
break;
|
||||
default:
|
||||
match= 0;
|
||||
break;
|
||||
}
|
||||
if (match) {
|
||||
if (interp->sym!=NoSymbol) {
|
||||
return interp;
|
||||
}
|
||||
else if (rtrn==NULL) {
|
||||
rtrn= interp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return rtrn;
|
||||
}
|
||||
|
||||
static void
|
||||
_XkbAddKeyChange(KeyCode *pFirst,unsigned char *pNum,KeyCode newKey)
|
||||
{
|
||||
KeyCode last;
|
||||
|
||||
last= (*pFirst)+(*pNum);
|
||||
if (newKey<*pFirst) {
|
||||
*pFirst= newKey;
|
||||
*pNum= (last-newKey)+1;
|
||||
}
|
||||
else if (newKey>last) {
|
||||
*pNum= (last-*pFirst)+1;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
_XkbSetActionKeyMods(XkbDescPtr xkb,XkbAction *act,unsigned mods)
|
||||
{
|
||||
unsigned tmp;
|
||||
|
||||
switch (act->type) {
|
||||
case XkbSA_SetMods: case XkbSA_LatchMods: case XkbSA_LockMods:
|
||||
if (act->mods.flags&XkbSA_UseModMapMods)
|
||||
act->mods.real_mods= act->mods.mask= mods;
|
||||
if ((tmp= XkbModActionVMods(&act->mods))!=0) {
|
||||
XkbVirtualModsToReal(xkb,tmp,&tmp);
|
||||
act->mods.mask|= tmp;
|
||||
}
|
||||
break;
|
||||
case XkbSA_ISOLock:
|
||||
if (act->iso.flags&XkbSA_UseModMapMods)
|
||||
act->iso.real_mods= act->iso.mask= mods;
|
||||
if ((tmp= XkbModActionVMods(&act->iso))!=0) {
|
||||
XkbVirtualModsToReal(xkb,tmp,&tmp);
|
||||
act->iso.mask|= tmp;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
#define IBUF_SIZE 8
|
||||
|
||||
Bool
|
||||
XkbApplyCompatMapToKey(XkbDescPtr xkb,KeyCode key,XkbChangesPtr changes)
|
||||
{
|
||||
KeySym * syms;
|
||||
unsigned char explicit,mods;
|
||||
XkbSymInterpretPtr *interps,ibuf[IBUF_SIZE];
|
||||
int n,nSyms,found;
|
||||
unsigned changed,tmp;
|
||||
|
||||
if ((!xkb)||(!xkb->map)||(!xkb->map->key_sym_map)||
|
||||
(!xkb->compat)||(!xkb->compat->sym_interpret)||
|
||||
(key<xkb->min_key_code)||(key>xkb->max_key_code)) {
|
||||
return False;
|
||||
}
|
||||
if (((!xkb->server)||(!xkb->server->key_acts))&&
|
||||
(XkbAllocServerMap(xkb,XkbAllServerInfoMask,0)!=Success)) {
|
||||
return False;
|
||||
}
|
||||
changed= 0; /* keeps track of what has changed in _this_ call */
|
||||
explicit= xkb->server->explicit[key];
|
||||
if (explicit&XkbExplicitInterpretMask) /* nothing to do */
|
||||
return True;
|
||||
mods= (xkb->map->modmap?xkb->map->modmap[key]:0);
|
||||
nSyms= XkbKeyNumSyms(xkb,key);
|
||||
syms= XkbKeySymsPtr(xkb,key);
|
||||
if (nSyms>IBUF_SIZE) {
|
||||
interps= _XkbTypedCalloc(nSyms,XkbSymInterpretPtr);
|
||||
if (interps==NULL) {
|
||||
interps= ibuf;
|
||||
nSyms= IBUF_SIZE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
interps= ibuf;
|
||||
}
|
||||
found= 0;
|
||||
for (n=0;n<nSyms;n++) {
|
||||
unsigned level= (n%XkbKeyGroupsWidth(xkb,key));
|
||||
interps[n]= NULL;
|
||||
if (syms[n]!=NoSymbol) {
|
||||
interps[n]= _XkbFindMatchingInterp(xkb,syms[n],mods,level);
|
||||
if (interps[n]&&interps[n]->act.type!=XkbSA_NoAction)
|
||||
found++;
|
||||
else interps[n]= NULL;
|
||||
}
|
||||
}
|
||||
/* 1/28/96 (ef) -- XXX! WORKING HERE */
|
||||
if (!found) {
|
||||
if (xkb->server->key_acts[key]!=0) {
|
||||
xkb->server->key_acts[key]= 0;
|
||||
changed|= XkbKeyActionsMask;
|
||||
}
|
||||
}
|
||||
else {
|
||||
XkbAction *pActs;
|
||||
unsigned int new_vmodmask;
|
||||
changed|= XkbKeyActionsMask;
|
||||
pActs= XkbResizeKeyActions(xkb,key,nSyms);
|
||||
if (!pActs) {
|
||||
if (nSyms > IBUF_SIZE)
|
||||
free(interps);
|
||||
return False;
|
||||
}
|
||||
new_vmodmask= 0;
|
||||
for (n=0;n<nSyms;n++) {
|
||||
if (interps[n]) {
|
||||
unsigned effMods;
|
||||
|
||||
pActs[n]= *((XkbAction *)&interps[n]->act);
|
||||
if ((n==0)||((interps[n]->match&XkbSI_LevelOneOnly)==0)) {
|
||||
effMods= mods;
|
||||
if (interps[n]->virtual_mod!=XkbNoModifier)
|
||||
new_vmodmask|= (1<<interps[n]->virtual_mod);
|
||||
}
|
||||
else effMods= 0;
|
||||
_XkbSetActionKeyMods(xkb,&pActs[n],effMods);
|
||||
}
|
||||
else pActs[n].type= XkbSA_NoAction;
|
||||
}
|
||||
if (((explicit&XkbExplicitVModMapMask)==0)&&
|
||||
(xkb->server->vmodmap[key]!=new_vmodmask)) {
|
||||
changed|= XkbVirtualModMapMask;
|
||||
xkb->server->vmodmap[key]= new_vmodmask;
|
||||
}
|
||||
if (interps[0]) {
|
||||
if ((interps[0]->flags&XkbSI_LockingKey)&&
|
||||
((explicit&XkbExplicitBehaviorMask)==0)) {
|
||||
xkb->server->behaviors[key].type= XkbKB_Lock;
|
||||
changed|= XkbKeyBehaviorsMask;
|
||||
}
|
||||
if (((explicit&XkbExplicitAutoRepeatMask)==0)&&(xkb->ctrls)) {
|
||||
CARD8 old;
|
||||
old= xkb->ctrls->per_key_repeat[key/8];
|
||||
if (interps[0]->flags&XkbSI_AutoRepeat)
|
||||
xkb->ctrls->per_key_repeat[key/8]|= (1<<(key%8));
|
||||
else xkb->ctrls->per_key_repeat[key/8]&= ~(1<<(key%8));
|
||||
if (changes && (old!=xkb->ctrls->per_key_repeat[key/8]))
|
||||
changes->ctrls.changed_ctrls|= XkbPerKeyRepeatMask;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((!found)||(interps[0]==NULL)) {
|
||||
if (((explicit&XkbExplicitAutoRepeatMask)==0)&&(xkb->ctrls)) {
|
||||
CARD8 old;
|
||||
old= xkb->ctrls->per_key_repeat[key/8];
|
||||
xkb->ctrls->per_key_repeat[key/8]|= (1<<(key%8));
|
||||
if (changes && (old!=xkb->ctrls->per_key_repeat[key/8]))
|
||||
changes->ctrls.changed_ctrls|= XkbPerKeyRepeatMask;
|
||||
}
|
||||
if (((explicit&XkbExplicitBehaviorMask)==0)&&
|
||||
(xkb->server->behaviors[key].type==XkbKB_Lock)) {
|
||||
xkb->server->behaviors[key].type= XkbKB_Default;
|
||||
changed|= XkbKeyBehaviorsMask;
|
||||
}
|
||||
}
|
||||
if (changes) {
|
||||
XkbMapChangesPtr mc;
|
||||
mc= &changes->map;
|
||||
tmp= (changed&mc->changed);
|
||||
if (tmp&XkbKeyActionsMask)
|
||||
_XkbAddKeyChange(&mc->first_key_act,&mc->num_key_acts,key);
|
||||
else if (changed&XkbKeyActionsMask) {
|
||||
mc->changed|= XkbKeyActionsMask;
|
||||
mc->first_key_act= key;
|
||||
mc->num_key_acts= 1;
|
||||
}
|
||||
if (tmp&XkbKeyBehaviorsMask) {
|
||||
_XkbAddKeyChange(&mc->first_key_behavior,&mc->num_key_behaviors,
|
||||
key);
|
||||
}
|
||||
else if (changed&XkbKeyBehaviorsMask) {
|
||||
mc->changed|= XkbKeyBehaviorsMask;
|
||||
mc->first_key_behavior= key;
|
||||
mc->num_key_behaviors= 1;
|
||||
}
|
||||
if (tmp&XkbVirtualModMapMask)
|
||||
_XkbAddKeyChange(&mc->first_vmodmap_key,&mc->num_vmodmap_keys,key);
|
||||
else if (changed&XkbVirtualModMapMask) {
|
||||
mc->changed|= XkbVirtualModMapMask;
|
||||
mc->first_vmodmap_key= key;
|
||||
mc->num_vmodmap_keys= 1;
|
||||
}
|
||||
mc->changed|= changed;
|
||||
}
|
||||
if (interps!=ibuf)
|
||||
_XkbFree(interps);
|
||||
return True;
|
||||
}
|
||||
|
||||
Status
|
||||
XkbChangeTypesOfKey( XkbDescPtr xkb,
|
||||
int key,
|
||||
int nGroups,
|
||||
unsigned groups,
|
||||
int * newTypesIn,
|
||||
XkbMapChangesPtr changes)
|
||||
{
|
||||
XkbKeyTypePtr pOldType,pNewType;
|
||||
register int i;
|
||||
int width,nOldGroups,oldWidth,newTypes[XkbNumKbdGroups];
|
||||
|
||||
if ((!xkb) || (!XkbKeycodeInRange(xkb,key)) || (!xkb->map) ||
|
||||
(!xkb->map->types)||(!newTypesIn)||((groups&XkbAllGroupsMask)==0)||
|
||||
(nGroups>XkbNumKbdGroups)) {
|
||||
return BadMatch;
|
||||
}
|
||||
if (nGroups==0) {
|
||||
for (i=0;i<XkbNumKbdGroups;i++) {
|
||||
xkb->map->key_sym_map[key].kt_index[i]= XkbOneLevelIndex;
|
||||
}
|
||||
i= xkb->map->key_sym_map[key].group_info;
|
||||
i= XkbSetNumGroups(i,0);
|
||||
xkb->map->key_sym_map[key].group_info= i;
|
||||
XkbResizeKeySyms(xkb,key,0);
|
||||
return Success;
|
||||
}
|
||||
|
||||
nOldGroups= XkbKeyNumGroups(xkb,key);
|
||||
oldWidth= XkbKeyGroupsWidth(xkb,key);
|
||||
for (width=i=0;i<nGroups;i++) {
|
||||
if (groups&(1<<i))
|
||||
newTypes[i]= newTypesIn[i];
|
||||
else if (i<nOldGroups)
|
||||
newTypes[i]= XkbKeyKeyTypeIndex(xkb,key,i);
|
||||
else if (nOldGroups>0)
|
||||
newTypes[i]= XkbKeyKeyTypeIndex(xkb,key,XkbGroup1Index);
|
||||
else newTypes[i]= XkbTwoLevelIndex;
|
||||
if (newTypes[i]>xkb->map->num_types)
|
||||
return BadMatch;
|
||||
pNewType= &xkb->map->types[newTypes[i]];
|
||||
if (pNewType->num_levels>width)
|
||||
width= pNewType->num_levels;
|
||||
}
|
||||
if ((xkb->ctrls)&&(nGroups>xkb->ctrls->num_groups))
|
||||
xkb->ctrls->num_groups= nGroups;
|
||||
if ((width!=oldWidth)||(nGroups!=nOldGroups)) {
|
||||
KeySym oldSyms[XkbMaxSymsPerKey],*pSyms;
|
||||
int nCopy;
|
||||
|
||||
if (nOldGroups==0) {
|
||||
pSyms= XkbResizeKeySyms(xkb,key,width*nGroups);
|
||||
if (pSyms!=NULL) {
|
||||
i= xkb->map->key_sym_map[key].group_info;
|
||||
i= XkbSetNumGroups(i,nGroups);
|
||||
xkb->map->key_sym_map[key].group_info= i;
|
||||
xkb->map->key_sym_map[key].width= width;
|
||||
for (i=0;i<nGroups;i++) {
|
||||
xkb->map->key_sym_map[key].kt_index[i]= newTypes[i];
|
||||
}
|
||||
return Success;
|
||||
}
|
||||
return BadAlloc;
|
||||
}
|
||||
pSyms= XkbKeySymsPtr(xkb,key);
|
||||
memcpy(oldSyms,pSyms,XkbKeyNumSyms(xkb,key)*sizeof(KeySym));
|
||||
pSyms= XkbResizeKeySyms(xkb,key,width*nGroups);
|
||||
if (pSyms==NULL)
|
||||
return BadAlloc;
|
||||
bzero(pSyms,width*nGroups*sizeof(KeySym));
|
||||
for (i=0;(i<nGroups)&&(i<nOldGroups);i++) {
|
||||
pOldType= XkbKeyKeyType(xkb,key,i);
|
||||
pNewType= &xkb->map->types[newTypes[i]];
|
||||
if (pNewType->num_levels>pOldType->num_levels)
|
||||
nCopy= pOldType->num_levels;
|
||||
else nCopy= pNewType->num_levels;
|
||||
memcpy(&pSyms[i*width],&oldSyms[i*oldWidth],nCopy*sizeof(KeySym));
|
||||
}
|
||||
if (XkbKeyHasActions(xkb,key)) {
|
||||
XkbAction oldActs[XkbMaxSymsPerKey],*pActs;
|
||||
pActs= XkbKeyActionsPtr(xkb,key);
|
||||
memcpy(oldActs,pActs,XkbKeyNumSyms(xkb,key)*sizeof(XkbAction));
|
||||
pActs= XkbResizeKeyActions(xkb,key,width*nGroups);
|
||||
if (pActs==NULL)
|
||||
return BadAlloc;
|
||||
bzero(pActs,width*nGroups*sizeof(XkbAction));
|
||||
for (i=0;(i<nGroups)&&(i<nOldGroups);i++) {
|
||||
pOldType= XkbKeyKeyType(xkb,key,i);
|
||||
pNewType= &xkb->map->types[newTypes[i]];
|
||||
if (pNewType->num_levels>pOldType->num_levels)
|
||||
nCopy= pOldType->num_levels;
|
||||
else nCopy= pNewType->num_levels;
|
||||
memcpy(&pActs[i*width],&oldActs[i*oldWidth],
|
||||
nCopy*sizeof(XkbAction));
|
||||
}
|
||||
}
|
||||
i= xkb->map->key_sym_map[key].group_info;
|
||||
i= XkbSetNumGroups(i,nGroups);
|
||||
xkb->map->key_sym_map[key].group_info= i;
|
||||
xkb->map->key_sym_map[key].width= width;
|
||||
}
|
||||
width= 0;
|
||||
for (i=0;i<nGroups;i++) {
|
||||
xkb->map->key_sym_map[key].kt_index[i]= newTypes[i];
|
||||
if (xkb->map->types[newTypes[i]].num_levels>width)
|
||||
width= xkb->map->types[newTypes[i]].num_levels;
|
||||
}
|
||||
xkb->map->key_sym_map[key].width= width;
|
||||
if (changes!=NULL) {
|
||||
if (changes->changed&XkbKeySymsMask) {
|
||||
_XkbAddKeyChange(&changes->first_key_sym,&changes->num_key_syms,
|
||||
key);
|
||||
}
|
||||
else {
|
||||
changes->changed|= XkbKeySymsMask;
|
||||
changes->first_key_sym= key;
|
||||
changes->num_key_syms= 1;
|
||||
}
|
||||
}
|
||||
return Success;
|
||||
}
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
Bool
|
||||
XkbVirtualModsToReal(XkbDescPtr xkb,unsigned virtual_mask,unsigned *mask_rtrn)
|
||||
{
|
||||
register int i,bit;
|
||||
register unsigned mask;
|
||||
|
||||
if (xkb==NULL)
|
||||
return False;
|
||||
if (virtual_mask==0) {
|
||||
*mask_rtrn= 0;
|
||||
return True;
|
||||
}
|
||||
if (xkb->server==NULL)
|
||||
return False;
|
||||
for (i=mask=0,bit=1;i<XkbNumVirtualMods;i++,bit<<=1) {
|
||||
if (virtual_mask&bit)
|
||||
mask|= xkb->server->vmods[i];
|
||||
}
|
||||
*mask_rtrn= mask;
|
||||
return True;
|
||||
}
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
static Bool
|
||||
XkbUpdateActionVirtualMods(XkbDescPtr xkb,XkbAction *act,unsigned changed)
|
||||
{
|
||||
unsigned int tmp;
|
||||
|
||||
switch (act->type) {
|
||||
case XkbSA_SetMods: case XkbSA_LatchMods: case XkbSA_LockMods:
|
||||
if (((tmp= XkbModActionVMods(&act->mods))&changed)!=0) {
|
||||
XkbVirtualModsToReal(xkb,tmp,&tmp);
|
||||
act->mods.mask= act->mods.real_mods;
|
||||
act->mods.mask|= tmp;
|
||||
return True;
|
||||
}
|
||||
break;
|
||||
case XkbSA_ISOLock:
|
||||
if ((((tmp= XkbModActionVMods(&act->iso))!=0)&changed)!=0) {
|
||||
XkbVirtualModsToReal(xkb,tmp,&tmp);
|
||||
act->iso.mask= act->iso.real_mods;
|
||||
act->iso.mask|= tmp;
|
||||
return True;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return False;
|
||||
}
|
||||
|
||||
static void
|
||||
XkbUpdateKeyTypeVirtualMods( XkbDescPtr xkb,
|
||||
XkbKeyTypePtr type,
|
||||
unsigned int changed,
|
||||
XkbChangesPtr changes)
|
||||
{
|
||||
register unsigned int i;
|
||||
unsigned int mask = 0;
|
||||
|
||||
XkbVirtualModsToReal(xkb,type->mods.vmods,&mask);
|
||||
type->mods.mask= type->mods.real_mods|mask;
|
||||
if ((type->map_count>0)&&(type->mods.vmods!=0)) {
|
||||
XkbKTMapEntryPtr entry;
|
||||
for (i=0,entry=type->map;i<type->map_count;i++,entry++) {
|
||||
if (entry->mods.vmods!=0) {
|
||||
XkbVirtualModsToReal(xkb,entry->mods.vmods,&mask);
|
||||
entry->mods.mask=entry->mods.real_mods|mask;
|
||||
/* entry is active if vmods are bound*/
|
||||
entry->active= (mask!=0);
|
||||
}
|
||||
else entry->active= 1;
|
||||
}
|
||||
}
|
||||
if (changes) {
|
||||
int type_ndx;
|
||||
type_ndx= type-xkb->map->types;
|
||||
if ((type_ndx<0)||(type_ndx>xkb->map->num_types))
|
||||
return;
|
||||
if (changes->map.changed&XkbKeyTypesMask) {
|
||||
int last;
|
||||
last= changes->map.first_type+changes->map.num_types-1;
|
||||
if (type_ndx<changes->map.first_type) {
|
||||
changes->map.first_type= type_ndx;
|
||||
changes->map.num_types= (last-type_ndx)+1;
|
||||
}
|
||||
else if (type_ndx>last) {
|
||||
changes->map.num_types= (type_ndx-changes->map.first_type)+1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
changes->map.changed|= XkbKeyTypesMask;
|
||||
changes->map.first_type= type_ndx;
|
||||
changes->map.num_types= 1;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Bool
|
||||
XkbApplyVirtualModChanges(XkbDescPtr xkb,unsigned changed,XkbChangesPtr changes)
|
||||
{
|
||||
register int i;
|
||||
unsigned int checkState = 0;
|
||||
|
||||
if ((!xkb) || (!xkb->map) || (changed==0))
|
||||
return False;
|
||||
for (i=0;i<xkb->map->num_types;i++) {
|
||||
if (xkb->map->types[i].mods.vmods & changed)
|
||||
XkbUpdateKeyTypeVirtualMods(xkb,&xkb->map->types[i],changed,changes);
|
||||
}
|
||||
if (changed&xkb->ctrls->internal.vmods) {
|
||||
unsigned int newMask = 0;
|
||||
XkbVirtualModsToReal(xkb,xkb->ctrls->internal.vmods,&newMask);
|
||||
newMask|= xkb->ctrls->internal.real_mods;
|
||||
if (xkb->ctrls->internal.mask!=newMask) {
|
||||
xkb->ctrls->internal.mask= newMask;
|
||||
if (changes) {
|
||||
changes->ctrls.changed_ctrls|= XkbInternalModsMask;
|
||||
checkState= True;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (changed&xkb->ctrls->ignore_lock.vmods) {
|
||||
unsigned int newMask = 0;
|
||||
XkbVirtualModsToReal(xkb,xkb->ctrls->ignore_lock.vmods,&newMask);
|
||||
newMask|= xkb->ctrls->ignore_lock.real_mods;
|
||||
if (xkb->ctrls->ignore_lock.mask!=newMask) {
|
||||
xkb->ctrls->ignore_lock.mask= newMask;
|
||||
if (changes) {
|
||||
changes->ctrls.changed_ctrls|= XkbIgnoreLockModsMask;
|
||||
checkState= True;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (xkb->indicators!=NULL) {
|
||||
XkbIndicatorMapPtr map;
|
||||
map= &xkb->indicators->maps[0];
|
||||
for (i=0;i<XkbNumIndicators;i++,map++) {
|
||||
if (map->mods.vmods&changed) {
|
||||
unsigned int newMask = 0;
|
||||
XkbVirtualModsToReal(xkb,map->mods.vmods,&newMask);
|
||||
newMask|= map->mods.real_mods;
|
||||
if (newMask!=map->mods.mask) {
|
||||
map->mods.mask= newMask;
|
||||
if (changes) {
|
||||
changes->indicators.map_changes|= (1<<i);
|
||||
checkState= True;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (xkb->compat!=NULL) {
|
||||
XkbCompatMapPtr compat;
|
||||
compat= xkb->compat;
|
||||
for (i=0;i<XkbNumKbdGroups;i++) {
|
||||
unsigned int newMask = 0;
|
||||
XkbVirtualModsToReal(xkb,compat->groups[i].vmods,&newMask);
|
||||
newMask|= compat->groups[i].real_mods;
|
||||
if (compat->groups[i].mask!=newMask) {
|
||||
compat->groups[i].mask= newMask;
|
||||
if (changes) {
|
||||
changes->compat.changed_groups|= (1<<i);
|
||||
checkState= True;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (xkb->map && xkb->server) {
|
||||
int highChange = 0, lowChange = -1;
|
||||
for (i=xkb->min_key_code;i<=xkb->max_key_code;i++) {
|
||||
if (XkbKeyHasActions(xkb,i)) {
|
||||
register XkbAction *pAct;
|
||||
register int n;
|
||||
|
||||
pAct= XkbKeyActionsPtr(xkb,i);
|
||||
for (n=XkbKeyNumActions(xkb,i);n>0;n--,pAct++) {
|
||||
if ((pAct->type!=XkbSA_NoAction)&&
|
||||
XkbUpdateActionVirtualMods(xkb,pAct,changed)) {
|
||||
if (lowChange<0)
|
||||
lowChange= i;
|
||||
highChange= i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (changes && (lowChange>0)) { /* something changed */
|
||||
if (changes->map.changed&XkbKeyActionsMask) {
|
||||
int last;
|
||||
if (changes->map.first_key_act<lowChange)
|
||||
lowChange= changes->map.first_key_act;
|
||||
last= changes->map.first_key_act+changes->map.num_key_acts-1;
|
||||
if (last>highChange)
|
||||
highChange= last;
|
||||
}
|
||||
changes->map.changed|= XkbKeyActionsMask;
|
||||
changes->map.first_key_act= lowChange;
|
||||
changes->map.num_key_acts= (highChange-lowChange)+1;
|
||||
}
|
||||
}
|
||||
return checkState;
|
||||
}
|
||||
335
nx-X11/programs/Xserver/xkb/ddxBeep.c
Normal file
335
nx-X11/programs/Xserver/xkb/ddxBeep.c
Normal file
@@ -0,0 +1,335 @@
|
||||
/************************************************************
|
||||
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_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <nx-X11/X.h>
|
||||
#include <nx-X11/Xproto.h>
|
||||
#include <nx-X11/keysym.h>
|
||||
#include "inputstr.h"
|
||||
#include "scrnintstr.h"
|
||||
#include "windowstr.h"
|
||||
#include <xkbsrv.h>
|
||||
#include <nx-X11/extensions/XI.h>
|
||||
|
||||
|
||||
/*#define FALLING_TONE 1*/
|
||||
/*#define RISING_TONE 1*/
|
||||
#define FALLING_TONE 10
|
||||
#define RISING_TONE 10
|
||||
#define SHORT_TONE 50
|
||||
#define SHORT_DELAY 60
|
||||
#define LONG_TONE 75
|
||||
#define VERY_LONG_TONE 100
|
||||
#define LONG_DELAY 85
|
||||
#define CLICK_DURATION 1
|
||||
|
||||
#define DEEP_PITCH 250
|
||||
#define LOW_PITCH 500
|
||||
#define MID_PITCH 1000
|
||||
#define HIGH_PITCH 2000
|
||||
#define CLICK_PITCH 1500
|
||||
|
||||
static unsigned long atomGeneration= 0;
|
||||
static Atom featureOn;
|
||||
static Atom featureOff;
|
||||
static Atom featureChange;
|
||||
static Atom ledOn;
|
||||
static Atom ledOff;
|
||||
static Atom ledChange;
|
||||
static Atom slowWarn;
|
||||
static Atom slowPress;
|
||||
static Atom slowReject;
|
||||
static Atom slowAccept;
|
||||
static Atom slowRelease;
|
||||
static Atom stickyLatch;
|
||||
static Atom stickyLock;
|
||||
static Atom stickyUnlock;
|
||||
static Atom bounceReject;
|
||||
static char doesPitch = 1;
|
||||
|
||||
#define FEATURE_ON "AX_FeatureOn"
|
||||
#define FEATURE_OFF "AX_FeatureOff"
|
||||
#define FEATURE_CHANGE "AX_FeatureChange"
|
||||
#define LED_ON "AX_IndicatorOn"
|
||||
#define LED_OFF "AX_IndicatorOff"
|
||||
#define LED_CHANGE "AX_IndicatorChange"
|
||||
#define SLOW_WARN "AX_SlowKeysWarning"
|
||||
#define SLOW_PRESS "AX_SlowKeyPress"
|
||||
#define SLOW_REJECT "AX_SlowKeyReject"
|
||||
#define SLOW_ACCEPT "AX_SlowKeyAccept"
|
||||
#define SLOW_RELEASE "AX_SlowKeyRelease"
|
||||
#define STICKY_LATCH "AX_StickyLatch"
|
||||
#define STICKY_LOCK "AX_StickyLock"
|
||||
#define STICKY_UNLOCK "AX_StickyUnlock"
|
||||
#define BOUNCE_REJECT "AX_BounceKeyReject"
|
||||
|
||||
#define MAKE_ATOM(a) MakeAtom(a,sizeof(a)-1,True)
|
||||
|
||||
static void
|
||||
_XkbDDXBeepInitAtoms(void)
|
||||
{
|
||||
featureOn= MAKE_ATOM(FEATURE_ON);
|
||||
featureOff= MAKE_ATOM(FEATURE_OFF);
|
||||
featureChange= MAKE_ATOM(FEATURE_CHANGE);
|
||||
ledOn= MAKE_ATOM(LED_ON);
|
||||
ledOff= MAKE_ATOM(LED_OFF);
|
||||
ledChange= MAKE_ATOM(LED_CHANGE);
|
||||
slowWarn= MAKE_ATOM(SLOW_WARN);
|
||||
slowPress= MAKE_ATOM(SLOW_PRESS);
|
||||
slowReject= MAKE_ATOM(SLOW_REJECT);
|
||||
slowAccept= MAKE_ATOM(SLOW_ACCEPT);
|
||||
slowRelease= MAKE_ATOM(SLOW_RELEASE);
|
||||
stickyLatch= MAKE_ATOM(STICKY_LATCH);
|
||||
stickyLock= MAKE_ATOM(STICKY_LOCK);
|
||||
stickyUnlock= MAKE_ATOM(STICKY_UNLOCK);
|
||||
bounceReject= MAKE_ATOM(BOUNCE_REJECT);
|
||||
#if defined(sun)
|
||||
doesPitch = 0;
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
static CARD32
|
||||
_XkbDDXBeepExpire(OsTimerPtr timer,CARD32 now,void * arg)
|
||||
{
|
||||
DeviceIntPtr dev= (DeviceIntPtr)arg;
|
||||
KbdFeedbackPtr feed;
|
||||
KeybdCtrl * ctrl;
|
||||
XkbSrvInfoPtr xkbInfo;
|
||||
CARD32 next;
|
||||
int pitch,duration;
|
||||
int oldPitch,oldDuration;
|
||||
Atom name;
|
||||
|
||||
if ((dev==NULL)||(dev->key==NULL)||(dev->key->xkbInfo==NULL)||
|
||||
(dev->kbdfeed==NULL))
|
||||
return 0;
|
||||
if (atomGeneration!=serverGeneration) {
|
||||
_XkbDDXBeepInitAtoms();
|
||||
atomGeneration= serverGeneration;
|
||||
}
|
||||
|
||||
feed= dev->kbdfeed;
|
||||
ctrl= &feed->ctrl;
|
||||
xkbInfo= dev->key->xkbInfo;
|
||||
next= 0;
|
||||
pitch= oldPitch= ctrl->bell_pitch;
|
||||
duration= oldDuration= ctrl->bell_duration;
|
||||
name= None;
|
||||
switch (xkbInfo->beepType) {
|
||||
default:
|
||||
ErrorF("Unknown beep type %d\n",xkbInfo->beepType);
|
||||
case _BEEP_NONE:
|
||||
duration= 0;
|
||||
break;
|
||||
|
||||
/* When an LED is turned on, we want a high-pitched beep.
|
||||
* When the LED it turned off, we want a low-pitched beep.
|
||||
* If we cannot do pitch, we want a single beep for on and two
|
||||
* beeps for off.
|
||||
*/
|
||||
case _BEEP_LED_ON:
|
||||
if (name==None) name= ledOn;
|
||||
duration= SHORT_TONE;
|
||||
pitch= HIGH_PITCH;
|
||||
break;
|
||||
case _BEEP_LED_OFF:
|
||||
if (name==None) name= ledOff;
|
||||
duration= SHORT_TONE;
|
||||
pitch= LOW_PITCH;
|
||||
if (!doesPitch && xkbInfo->beepCount<1)
|
||||
next = SHORT_DELAY;
|
||||
break;
|
||||
|
||||
/* When a Feature is turned on, we want an up-siren.
|
||||
* When a Feature is turned off, we want a down-siren.
|
||||
* If we cannot do pitch, we want a single beep for on and two
|
||||
* beeps for off.
|
||||
*/
|
||||
case _BEEP_FEATURE_ON:
|
||||
if (name==None) name= featureOn;
|
||||
if (xkbInfo->beepCount<1) {
|
||||
pitch= LOW_PITCH;
|
||||
duration= VERY_LONG_TONE;
|
||||
if (doesPitch)
|
||||
next= SHORT_DELAY;
|
||||
}
|
||||
else {
|
||||
pitch= MID_PITCH;
|
||||
duration= SHORT_TONE;
|
||||
}
|
||||
break;
|
||||
|
||||
case _BEEP_FEATURE_OFF:
|
||||
if (name==None) name= featureOff;
|
||||
if (xkbInfo->beepCount<1) {
|
||||
pitch= MID_PITCH;
|
||||
if (doesPitch)
|
||||
duration= VERY_LONG_TONE;
|
||||
else duration= SHORT_TONE;
|
||||
next= SHORT_DELAY;
|
||||
}
|
||||
else {
|
||||
pitch= LOW_PITCH;
|
||||
duration= SHORT_TONE;
|
||||
}
|
||||
break;
|
||||
|
||||
/* Two high beeps indicate an LED or Feature changed
|
||||
* state, but that another LED or Feature is also on.
|
||||
* [[[WDW - This is not in AccessDOS ]]]
|
||||
*/
|
||||
case _BEEP_LED_CHANGE:
|
||||
if (name==None) name= ledChange;
|
||||
case _BEEP_FEATURE_CHANGE:
|
||||
if (name==None) name= featureChange;
|
||||
duration= SHORT_TONE;
|
||||
pitch= HIGH_PITCH;
|
||||
if (xkbInfo->beepCount<1) {
|
||||
next= SHORT_DELAY;
|
||||
}
|
||||
break;
|
||||
|
||||
/* Three high-pitched beeps are the warning that SlowKeys
|
||||
* is going to be turned on or off.
|
||||
*/
|
||||
case _BEEP_SLOW_WARN:
|
||||
if (name==None) name= slowWarn;
|
||||
duration= SHORT_TONE;
|
||||
pitch= HIGH_PITCH;
|
||||
if (xkbInfo->beepCount<2)
|
||||
next= SHORT_DELAY;
|
||||
break;
|
||||
|
||||
/* Click on SlowKeys press and accept.
|
||||
* Deep pitch when a SlowKey or BounceKey is rejected.
|
||||
* [[[WDW - Rejects are not in AccessDOS ]]]
|
||||
* If we cannot do pitch, we want single beeps.
|
||||
*/
|
||||
case _BEEP_SLOW_PRESS:
|
||||
if (name==None) name= slowPress;
|
||||
case _BEEP_SLOW_ACCEPT:
|
||||
if (name==None) name= slowAccept;
|
||||
case _BEEP_SLOW_RELEASE:
|
||||
if (name==None) name= slowRelease;
|
||||
duration= CLICK_DURATION;
|
||||
pitch= CLICK_PITCH;
|
||||
break;
|
||||
case _BEEP_BOUNCE_REJECT:
|
||||
if (name==None) name= bounceReject;
|
||||
case _BEEP_SLOW_REJECT:
|
||||
if (name==None) name= slowReject;
|
||||
duration= SHORT_TONE;
|
||||
pitch= DEEP_PITCH;
|
||||
break;
|
||||
|
||||
/* Low followed by high pitch when a StickyKey is latched.
|
||||
* High pitch when a StickyKey is locked.
|
||||
* Low pitch when unlocked.
|
||||
* If we cannot do pitch, two beeps for latch, nothing for
|
||||
* lock, and two for unlock.
|
||||
*/
|
||||
case _BEEP_STICKY_LATCH:
|
||||
if (name==None) name= stickyLatch;
|
||||
duration= SHORT_TONE;
|
||||
if (xkbInfo->beepCount<1) {
|
||||
next= SHORT_DELAY;
|
||||
pitch= LOW_PITCH;
|
||||
}
|
||||
else pitch= HIGH_PITCH;
|
||||
break;
|
||||
case _BEEP_STICKY_LOCK:
|
||||
if (name==None) name= stickyLock;
|
||||
if (doesPitch) {
|
||||
duration= SHORT_TONE;
|
||||
pitch= HIGH_PITCH;
|
||||
}
|
||||
break;
|
||||
case _BEEP_STICKY_UNLOCK:
|
||||
if (name==None) name= stickyUnlock;
|
||||
duration= SHORT_TONE;
|
||||
pitch= LOW_PITCH;
|
||||
if (!doesPitch && xkbInfo->beepCount<1)
|
||||
next = SHORT_DELAY;
|
||||
break;
|
||||
}
|
||||
if (timer == NULL && duration>0) {
|
||||
CARD32 starttime = GetTimeInMillis();
|
||||
CARD32 elapsedtime;
|
||||
|
||||
ctrl->bell_duration= duration;
|
||||
ctrl->bell_pitch= pitch;
|
||||
if (xkbInfo->beepCount==0) {
|
||||
XkbHandleBell(0,0,dev,ctrl->bell,(void *)ctrl,KbdFeedbackClass,name,None,
|
||||
NULL);
|
||||
}
|
||||
else if (xkbInfo->desc->ctrls->enabled_ctrls&XkbAudibleBellMask) {
|
||||
(*dev->kbdfeed->BellProc)(ctrl->bell,dev,(void *)ctrl,KbdFeedbackClass);
|
||||
}
|
||||
ctrl->bell_duration= oldDuration;
|
||||
ctrl->bell_pitch= oldPitch;
|
||||
xkbInfo->beepCount++;
|
||||
|
||||
/* Some DDX schedule the beep and return immediately, others don't
|
||||
return until the beep is completed. We measure the time and if
|
||||
it's less than the beep duration, make sure not to schedule the
|
||||
next beep until after the current one finishes. */
|
||||
|
||||
elapsedtime = GetTimeInMillis();
|
||||
if (elapsedtime > starttime) { /* watch out for millisecond counter
|
||||
overflow! */
|
||||
elapsedtime -= starttime;
|
||||
} else {
|
||||
elapsedtime = 0;
|
||||
}
|
||||
if (elapsedtime < duration) {
|
||||
next += duration - elapsedtime;
|
||||
}
|
||||
|
||||
}
|
||||
return next;
|
||||
}
|
||||
|
||||
int
|
||||
XkbDDXAccessXBeep(DeviceIntPtr dev,unsigned what,unsigned which)
|
||||
{
|
||||
XkbSrvInfoRec *xkbInfo= dev->key->xkbInfo;
|
||||
CARD32 next;
|
||||
|
||||
xkbInfo->beepType= what;
|
||||
xkbInfo->beepCount= 0;
|
||||
next= _XkbDDXBeepExpire(NULL,0,(void *)dev);
|
||||
if (next>0) {
|
||||
xkbInfo->beepTimer= TimerSet(xkbInfo->beepTimer,
|
||||
0, next,
|
||||
_XkbDDXBeepExpire, (void *)dev);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
105
nx-X11/programs/Xserver/xkb/ddxCtrls.c
Normal file
105
nx-X11/programs/Xserver/xkb/ddxCtrls.c
Normal file
@@ -0,0 +1,105 @@
|
||||
/************************************************************
|
||||
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_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <nx-X11/X.h>
|
||||
#include <nx-X11/Xproto.h>
|
||||
#include <nx-X11/keysym.h>
|
||||
#include "inputstr.h"
|
||||
#include "scrnintstr.h"
|
||||
#include "windowstr.h"
|
||||
#include <xkbsrv.h>
|
||||
#include <nx-X11/extensions/XI.h>
|
||||
|
||||
void
|
||||
XkbDDXKeybdCtrlProc(DeviceIntPtr dev,KeybdCtrl *ctrl)
|
||||
{
|
||||
int realRepeat;
|
||||
|
||||
realRepeat= ctrl->autoRepeat;
|
||||
if ((dev->kbdfeed)&&(XkbDDXUsesSoftRepeat(dev)))
|
||||
ctrl->autoRepeat= 0;
|
||||
if (dev->key && dev->key->xkbInfo && dev->key->xkbInfo->kbdProc)
|
||||
(*dev->key->xkbInfo->kbdProc)(dev,ctrl);
|
||||
ctrl->autoRepeat= realRepeat;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
XkbDDXUsesSoftRepeat(DeviceIntPtr pXDev)
|
||||
{
|
||||
#ifndef XKB_ALWAYS_USES_SOFT_REPEAT
|
||||
if (pXDev && pXDev->kbdfeed ) {
|
||||
if (pXDev->kbdfeed->ctrl.autoRepeat) {
|
||||
if (pXDev->key && pXDev->key->xkbInfo) {
|
||||
XkbDescPtr xkb;
|
||||
xkb= pXDev->key->xkbInfo->desc;
|
||||
if ((xkb->ctrls->repeat_delay == 660) &&
|
||||
(xkb->ctrls->repeat_interval == 40) &&
|
||||
((xkb->ctrls->enabled_ctrls&(XkbSlowKeysMask|
|
||||
XkbBounceKeysMask|
|
||||
XkbMouseKeysMask))==0)) {
|
||||
return 0;
|
||||
}
|
||||
return ((xkb->ctrls->enabled_ctrls&XkbRepeatKeysMask)!=0);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
#else
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
XkbDDXChangeControls(DeviceIntPtr dev,XkbControlsPtr old,XkbControlsPtr new)
|
||||
{
|
||||
unsigned changed, i;
|
||||
unsigned char *rep_old, *rep_new, *rep_fb;
|
||||
|
||||
changed= new->enabled_ctrls^old->enabled_ctrls;
|
||||
for (rep_old = old->per_key_repeat,
|
||||
rep_new = new->per_key_repeat,
|
||||
rep_fb = dev->kbdfeed->ctrl.autoRepeats,
|
||||
i = 0; i < XkbPerKeyBitArraySize; i++) {
|
||||
if (rep_old[i] != rep_new[i]) {
|
||||
rep_fb[i] = rep_new[i];
|
||||
changed &= XkbPerKeyRepeatMask;
|
||||
}
|
||||
}
|
||||
|
||||
if (changed&XkbPerKeyRepeatMask) {
|
||||
if (dev->kbdfeed->CtrlProc)
|
||||
(*dev->kbdfeed->CtrlProc)(dev,&dev->kbdfeed->ctrl);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
99
nx-X11/programs/Xserver/xkb/ddxDevBtn.c
Normal file
99
nx-X11/programs/Xserver/xkb/ddxDevBtn.c
Normal file
@@ -0,0 +1,99 @@
|
||||
/************************************************************
|
||||
Copyright (c) 1995 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_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <nx-X11/X.h>
|
||||
#include <nx-X11/Xproto.h>
|
||||
#include <nx-X11/keysym.h>
|
||||
#include "inputstr.h"
|
||||
#include "scrnintstr.h"
|
||||
#include "windowstr.h"
|
||||
#include <xkbsrv.h>
|
||||
#include <nx-X11/extensions/XI.h>
|
||||
#include <nx-X11/extensions/XIproto.h>
|
||||
|
||||
extern int DeviceValuator;
|
||||
|
||||
void
|
||||
XkbDDXFakeDeviceButton(DeviceIntPtr dev,Bool press,int button)
|
||||
{
|
||||
int * devVal;
|
||||
INT32 * evVal;
|
||||
xEvent events[2];
|
||||
deviceKeyButtonPointer *btn;
|
||||
deviceValuator * val;
|
||||
int x,y;
|
||||
int nAxes, i, count;
|
||||
|
||||
if ((dev==(DeviceIntPtr)LookupPointerDevice())||(!dev->public.on))
|
||||
return;
|
||||
|
||||
nAxes = (dev->valuator?dev->valuator->numAxes:0);
|
||||
if (nAxes > 6)
|
||||
nAxes = 6;
|
||||
|
||||
GetSpritePosition(&x,&y);
|
||||
btn= (deviceKeyButtonPointer *) &events[0];
|
||||
val= (deviceValuator *) &events[1];
|
||||
if (press) btn->type= DeviceButtonPress;
|
||||
else btn->type= DeviceButtonRelease;
|
||||
btn->detail= button;
|
||||
btn->time= GetTimeInMillis();
|
||||
btn->root_x= x;
|
||||
btn->root_y= y;
|
||||
btn->deviceid= dev->id;
|
||||
count= 1;
|
||||
if (nAxes>0) {
|
||||
btn->deviceid|= 0x80;
|
||||
val->type = DeviceValuator;
|
||||
val->deviceid = dev->id;
|
||||
val->first_valuator = 0;
|
||||
|
||||
evVal= &val->valuator0;
|
||||
devVal= dev->valuator->axisVal;
|
||||
for (i=nAxes;i>0;i--) {
|
||||
*evVal++ = *devVal++;
|
||||
if (evVal > &val->valuator5) {
|
||||
int tmp = val->first_valuator+6;
|
||||
val->num_valuators = 6;
|
||||
val++;
|
||||
evVal= &val->valuator0;
|
||||
val->first_valuator= tmp;
|
||||
}
|
||||
}
|
||||
if ((nAxes % 6) != 0) {
|
||||
val->num_valuators = (nAxes % 6);
|
||||
}
|
||||
count= 1+((nAxes+5)/6);
|
||||
}
|
||||
|
||||
(*dev->public.processInputProc)((xEventPtr)btn, dev, count);
|
||||
return;
|
||||
}
|
||||
58
nx-X11/programs/Xserver/xkb/ddxFakeBtn.c
Normal file
58
nx-X11/programs/Xserver/xkb/ddxFakeBtn.c
Normal file
@@ -0,0 +1,58 @@
|
||||
/************************************************************
|
||||
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_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <nx-X11/X.h>
|
||||
#include <nx-X11/Xproto.h>
|
||||
#include <nx-X11/keysym.h>
|
||||
#include "inputstr.h"
|
||||
#include "scrnintstr.h"
|
||||
#include "windowstr.h"
|
||||
#include <xkbsrv.h>
|
||||
#include <nx-X11/extensions/XI.h>
|
||||
|
||||
void
|
||||
XkbDDXFakePointerButton(int event,int button)
|
||||
{
|
||||
xEvent ev;
|
||||
int x,y;
|
||||
DevicePtr ptr;
|
||||
|
||||
if ((ptr = LookupPointerDevice())==NULL)
|
||||
return;
|
||||
GetSpritePosition(&x,&y);
|
||||
ev.u.u.type = event;
|
||||
ev.u.u.detail = button;
|
||||
ev.u.keyButtonPointer.time = GetTimeInMillis();
|
||||
ev.u.keyButtonPointer.rootX = x;
|
||||
ev.u.keyButtonPointer.rootY = y;
|
||||
(*ptr->processInputProc)( &ev, (DeviceIntPtr)ptr, 1 );
|
||||
return;
|
||||
}
|
||||
118
nx-X11/programs/Xserver/xkb/ddxFakeMtn.c
Normal file
118
nx-X11/programs/Xserver/xkb/ddxFakeMtn.c
Normal file
@@ -0,0 +1,118 @@
|
||||
/************************************************************
|
||||
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_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <nx-X11/X.h>
|
||||
#include <nx-X11/Xproto.h>
|
||||
#include <nx-X11/keysym.h>
|
||||
#include "inputstr.h"
|
||||
#include "scrnintstr.h"
|
||||
#include "windowstr.h"
|
||||
#include <xkbsrv.h>
|
||||
#include <nx-X11/extensions/XI.h>
|
||||
|
||||
#ifdef PANORAMIX
|
||||
#include "panoramiX.h"
|
||||
#include "panoramiXsrv.h"
|
||||
#endif
|
||||
|
||||
#include "mipointer.h"
|
||||
#include "mipointrst.h"
|
||||
|
||||
void
|
||||
XkbDDXFakePointerMotion(unsigned flags,int x,int y)
|
||||
{
|
||||
int oldX,oldY;
|
||||
ScreenPtr pScreen, oldScreen;
|
||||
|
||||
GetSpritePosition(&oldX, &oldY);
|
||||
pScreen = oldScreen = GetSpriteWindow()->drawable.pScreen;
|
||||
|
||||
#ifdef PANORAMIX
|
||||
if (!noPanoramiXExtension) {
|
||||
BoxRec box;
|
||||
int i;
|
||||
|
||||
if(!RegionContainsPoint(&XineramaScreenRegions[pScreen->myNum],
|
||||
oldX, oldY, &box)) {
|
||||
FOR_NSCREENS(i) {
|
||||
if(i == pScreen->myNum)
|
||||
continue;
|
||||
if(RegionContainsPoint(&XineramaScreenRegions[i],
|
||||
oldX, oldY, &box)) {
|
||||
pScreen = screenInfo.screens[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
oldScreen = pScreen;
|
||||
|
||||
if (flags&XkbSA_MoveAbsoluteX)
|
||||
oldX= x;
|
||||
else oldX+= x;
|
||||
if (flags&XkbSA_MoveAbsoluteY)
|
||||
oldY= y;
|
||||
else oldY+= y;
|
||||
|
||||
if(!RegionContainsPoint(&XineramaScreenRegions[pScreen->myNum],
|
||||
oldX, oldY, &box)) {
|
||||
FOR_NSCREENS(i) {
|
||||
if(i == pScreen->myNum)
|
||||
continue;
|
||||
if(RegionContainsPoint(&XineramaScreenRegions[i],
|
||||
oldX, oldY, &box)) {
|
||||
pScreen = screenInfo.screens[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
oldX -= panoramiXdataPtr[pScreen->myNum].x;
|
||||
oldY -= panoramiXdataPtr[pScreen->myNum].y;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if (flags&XkbSA_MoveAbsoluteX)
|
||||
oldX= x;
|
||||
else oldX+= x;
|
||||
if (flags&XkbSA_MoveAbsoluteY)
|
||||
oldY= y;
|
||||
else oldY+= y;
|
||||
|
||||
#define GetScreenPrivate(s) ((miPointerScreenPtr) ((s)->devPrivates[miPointerScreenIndex].ptr))
|
||||
(*(GetScreenPrivate(oldScreen))->screenFuncs->CursorOffScreen)
|
||||
(&pScreen, &oldX, &oldY);
|
||||
}
|
||||
|
||||
if (pScreen != oldScreen)
|
||||
NewCurrentScreen(pScreen, oldX, oldY);
|
||||
if (pScreen->SetCursorPosition)
|
||||
(*pScreen->SetCursorPosition)(pScreen, oldX, oldY, TRUE);
|
||||
}
|
||||
47
nx-X11/programs/Xserver/xkb/ddxKillSrv.c
Normal file
47
nx-X11/programs/Xserver/xkb/ddxKillSrv.c
Normal file
@@ -0,0 +1,47 @@
|
||||
/************************************************************
|
||||
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_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <nx-X11/X.h>
|
||||
#include <nx-X11/Xproto.h>
|
||||
#include <nx-X11/keysym.h>
|
||||
#include "inputstr.h"
|
||||
#include "scrnintstr.h"
|
||||
#include "windowstr.h"
|
||||
#include <xkbsrv.h>
|
||||
|
||||
int
|
||||
XkbDDXTerminateServer(DeviceIntPtr dev,KeyCode key,XkbAction *act)
|
||||
{
|
||||
#ifndef NXAGENT_SERVER
|
||||
GiveUp(1);
|
||||
#endif /* NXAGENT_SERVER */
|
||||
return 0;
|
||||
}
|
||||
71
nx-X11/programs/Xserver/xkb/ddxLEDs.c
Normal file
71
nx-X11/programs/Xserver/xkb/ddxLEDs.c
Normal file
@@ -0,0 +1,71 @@
|
||||
/************************************************************
|
||||
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_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <nx-X11/X.h>
|
||||
#include <nx-X11/Xproto.h>
|
||||
#include <nx-X11/keysym.h>
|
||||
#include "inputstr.h"
|
||||
#include "scrnintstr.h"
|
||||
#include "windowstr.h"
|
||||
#include <xkbsrv.h>
|
||||
#include <nx-X11/extensions/XI.h>
|
||||
|
||||
static void
|
||||
XkbDDXUpdateIndicators(DeviceIntPtr dev,CARD32 new)
|
||||
{
|
||||
dev->kbdfeed->ctrl.leds= new;
|
||||
(*dev->kbdfeed->CtrlProc)(dev,&dev->kbdfeed->ctrl);
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
XkbDDXUpdateDeviceIndicators( DeviceIntPtr dev,
|
||||
XkbSrvLedInfoPtr sli,
|
||||
CARD32 new)
|
||||
{
|
||||
if (sli->fb.kf==dev->kbdfeed)
|
||||
XkbDDXUpdateIndicators(dev,new);
|
||||
else if (sli->class==KbdFeedbackClass) {
|
||||
KbdFeedbackPtr kf;
|
||||
kf= sli->fb.kf;
|
||||
if (kf && kf->CtrlProc) {
|
||||
(*kf->CtrlProc)(dev,&kf->ctrl);
|
||||
}
|
||||
}
|
||||
else if (sli->class==LedFeedbackClass) {
|
||||
LedFeedbackPtr lf;
|
||||
lf= sli->fb.lf;
|
||||
if (lf && lf->CtrlProc) {
|
||||
(*lf->CtrlProc)(dev,&lf->ctrl);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
304
nx-X11/programs/Xserver/xkb/ddxList.c
Normal file
304
nx-X11/programs/Xserver/xkb/ddxList.c
Normal file
@@ -0,0 +1,304 @@
|
||||
/************************************************************
|
||||
Copyright (c) 1995 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_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <nx-X11/X.h>
|
||||
#include <nx-X11/Xos.h>
|
||||
#include <nx-X11/Xproto.h>
|
||||
#include <nx-X11/keysym.h>
|
||||
#include <nx-X11/extensions/XKM.h>
|
||||
#include "inputstr.h"
|
||||
#include "scrnintstr.h"
|
||||
#include "windowstr.h"
|
||||
#include <xkbsrv.h>
|
||||
#include <nx-X11/extensions/XI.h>
|
||||
|
||||
#ifdef WIN32
|
||||
/* from ddxLoad.c */
|
||||
extern const char* Win32TempDir();
|
||||
extern int Win32System(const char *cmdline);
|
||||
#undef System
|
||||
#define System Win32System
|
||||
|
||||
#define W32_tmparg " '%s'"
|
||||
#define W32_tmpfile ,tmpname
|
||||
#define W32_tmplen strlen(tmpname)+3
|
||||
#else
|
||||
#define W32_tmparg
|
||||
#define W32_tmpfile
|
||||
#define W32_tmplen 0
|
||||
#endif
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
static char *componentDirs[_XkbListNumComponents] = {
|
||||
"keymap", "keycodes", "types", "compat", "symbols", "geometry"
|
||||
};
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
static Status
|
||||
_AddListComponent( XkbSrvListInfoPtr list,
|
||||
int what,
|
||||
unsigned flags,
|
||||
char * str,
|
||||
ClientPtr client)
|
||||
{
|
||||
int slen,wlen;
|
||||
unsigned char * wire8;
|
||||
unsigned short *wire16;
|
||||
char * tmp;
|
||||
|
||||
if (list->nTotal>=list->maxRtrn) {
|
||||
list->nTotal++;
|
||||
return Success;
|
||||
}
|
||||
tmp= strchr(str,')');
|
||||
if ((tmp==NULL)&&((tmp=strchr(str,'('))==NULL)) {
|
||||
slen= strlen(str);
|
||||
while ((slen>0) && isspace(str[slen-1])) {
|
||||
slen--;
|
||||
}
|
||||
}
|
||||
else {
|
||||
slen= (tmp-str+1);
|
||||
}
|
||||
wlen= (((slen+1)/2)*2)+4; /* four bytes for flags and length, pad to */
|
||||
/* 2-byte boundary */
|
||||
if ((list->szPool-list->nPool)<wlen) {
|
||||
if (wlen>1024) list->szPool+= XkbPaddedSize(wlen*2);
|
||||
else list->szPool+= 1024;
|
||||
list->pool= _XkbTypedRealloc(list->pool,list->szPool,char);
|
||||
if (!list->pool)
|
||||
return BadAlloc;
|
||||
}
|
||||
wire16= (unsigned short *)&list->pool[list->nPool];
|
||||
wire8= (unsigned char *)&wire16[2];
|
||||
wire16[0]= flags;
|
||||
wire16[1]= slen;
|
||||
memcpy(wire8,str,slen);
|
||||
if (client->swapped) {
|
||||
swaps(&wire16[0]);
|
||||
swaps(&wire16[1]);
|
||||
}
|
||||
list->nPool+= wlen;
|
||||
list->nFound[what]++;
|
||||
list->nTotal++;
|
||||
return Success;
|
||||
}
|
||||
|
||||
/***====================================================================***/
|
||||
static Status
|
||||
XkbDDXListComponent( DeviceIntPtr dev,
|
||||
int what,
|
||||
XkbSrvListInfoPtr list,
|
||||
ClientPtr client)
|
||||
{
|
||||
char *file,*map,*tmp,*buf=NULL;
|
||||
FILE *in;
|
||||
Status status;
|
||||
int rval;
|
||||
Bool haveDir;
|
||||
#ifdef WIN32
|
||||
char tmpname[PATH_MAX];
|
||||
#endif
|
||||
|
||||
if ((list->pattern[what]==NULL)||(list->pattern[what][0]=='\0'))
|
||||
return Success;
|
||||
file= list->pattern[what];
|
||||
map= strrchr(file,'(');
|
||||
if (map!=NULL) {
|
||||
map++;
|
||||
tmp= strrchr(map,')');
|
||||
if ((tmp==NULL)||(tmp[1]!='\0')) {
|
||||
/* illegal pattern. No error, but no match */
|
||||
return Success;
|
||||
}
|
||||
}
|
||||
|
||||
in= NULL;
|
||||
haveDir= True;
|
||||
#ifdef WIN32
|
||||
strcpy(tmpname, Win32TempDir());
|
||||
strcat(tmpname, "\\xkb_XXXXXX");
|
||||
(void) mktemp(tmpname);
|
||||
#endif
|
||||
if (XkbBaseDirectory!=NULL) {
|
||||
if ((list->pattern[what][0]=='*')&&(list->pattern[what][1]=='\0')) {
|
||||
if (asprintf(&buf, "%s/%s.dir", XkbBaseDirectory,
|
||||
componentDirs[what]) == -1)
|
||||
buf = NULL;
|
||||
else
|
||||
in = fopen(buf,"r");
|
||||
}
|
||||
if (!in) {
|
||||
haveDir= False;
|
||||
free(buf);
|
||||
if (asprintf
|
||||
(&buf,
|
||||
"'%s/xkbcomp' '-R%s/%s' -w %ld -l -vlfhpR '%s'" W32_tmparg,
|
||||
XkbBinDirectory, XkbBaseDirectory, componentDirs[what],
|
||||
(long) ((xkbDebugFlags < 2) ? 1 :
|
||||
((xkbDebugFlags > 10) ? 10 : xkbDebugFlags)),
|
||||
file W32_tmpfile
|
||||
) == -1)
|
||||
buf = NULL;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ((list->pattern[what][0]=='*')&&(list->pattern[what][1]=='\0')) {
|
||||
if (asprintf(&buf, "%s.dir", componentDirs[what]) == -1)
|
||||
buf = NULL;
|
||||
else
|
||||
in = fopen(buf,"r");
|
||||
buf = NULL;
|
||||
}
|
||||
if (!in) {
|
||||
haveDir= False;
|
||||
free(buf);
|
||||
if (asprintf
|
||||
(&buf,
|
||||
"xkbcomp -R%s -w %ld -l -vlfhpR '%s'" W32_tmparg,
|
||||
componentDirs[what],
|
||||
(long) ((xkbDebugFlags < 2) ? 1 :
|
||||
((xkbDebugFlags > 10) ? 10 : xkbDebugFlags)),
|
||||
file W32_tmpfile
|
||||
) == -1)
|
||||
buf = NULL;
|
||||
}
|
||||
}
|
||||
status= Success;
|
||||
if (!haveDir)
|
||||
{
|
||||
#ifndef WIN32
|
||||
in= Popen(buf,"r");
|
||||
#else
|
||||
if (xkbDebugFlags)
|
||||
DebugF("xkb executes: %s\n",buf);
|
||||
if (System(buf) < 0)
|
||||
ErrorF("Could not invoke keymap compiler\n");
|
||||
else
|
||||
in= fopen(tmpname, "r");
|
||||
#endif
|
||||
}
|
||||
if (!in)
|
||||
{
|
||||
free (buf);
|
||||
#ifdef WIN32
|
||||
unlink(tmpname);
|
||||
#endif
|
||||
return BadImplementation;
|
||||
}
|
||||
list->nFound[what]= 0;
|
||||
if (buf) {
|
||||
free(buf);
|
||||
buf = NULL;
|
||||
}
|
||||
buf = malloc(PATH_MAX * sizeof(char));
|
||||
if (!buf)
|
||||
return BadAlloc;
|
||||
while ((status==Success)&&((tmp=fgets(buf,PATH_MAX,in))!=NULL)) {
|
||||
unsigned flags;
|
||||
register unsigned int i;
|
||||
if (*tmp=='#') /* comment, skip it */
|
||||
continue;
|
||||
if (!strncmp(tmp, "Warning:", 8) || !strncmp(tmp, " ", 8))
|
||||
/* skip warnings too */
|
||||
continue;
|
||||
flags= 0;
|
||||
/* each line in the listing is supposed to start with two */
|
||||
/* groups of eight characters, which specify the general */
|
||||
/* flags and the flags that are specific to the component */
|
||||
/* if they're missing, fail with BadImplementation */
|
||||
for (i=0;(i<8)&&(status==Success);i++) { /* read the general flags */
|
||||
if (isalpha(*tmp)) flags|= (1L<<i);
|
||||
else if (*tmp!='-') status= BadImplementation;
|
||||
tmp++;
|
||||
}
|
||||
if (status != Success) break;
|
||||
if (!isspace(*tmp)) {
|
||||
status= BadImplementation;
|
||||
break;
|
||||
}
|
||||
else tmp++;
|
||||
for (i=0;(i<8)&&(status==Success);i++) { /* read the component flags */
|
||||
if (isalpha(*tmp)) flags|= (1L<<(i+8));
|
||||
else if (*tmp!='-') status= BadImplementation;
|
||||
tmp++;
|
||||
}
|
||||
if (status != Success) break;
|
||||
if (isspace(*tmp)) {
|
||||
while (isspace(*tmp)) {
|
||||
tmp++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
status= BadImplementation;
|
||||
break;
|
||||
}
|
||||
status= _AddListComponent(list,what,flags,tmp,client);
|
||||
}
|
||||
#ifndef WIN32
|
||||
if (haveDir)
|
||||
fclose(in);
|
||||
else if ((rval=Pclose(in))!=0) {
|
||||
if (xkbDebugFlags)
|
||||
ErrorF("xkbcomp returned exit code %d\n",rval);
|
||||
}
|
||||
#else
|
||||
fclose(in);
|
||||
unlink(tmpname);
|
||||
#endif
|
||||
free (buf);
|
||||
return status;
|
||||
}
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
/* ARGSUSED */
|
||||
Status
|
||||
XkbDDXList(DeviceIntPtr dev,XkbSrvListInfoPtr list,ClientPtr client)
|
||||
{
|
||||
Status status;
|
||||
|
||||
status= XkbDDXListComponent(dev,_XkbListKeymaps,list,client);
|
||||
if (status==Success)
|
||||
status= XkbDDXListComponent(dev,_XkbListKeycodes,list,client);
|
||||
if (status==Success)
|
||||
status= XkbDDXListComponent(dev,_XkbListTypes,list,client);
|
||||
if (status==Success)
|
||||
status= XkbDDXListComponent(dev,_XkbListCompat,list,client);
|
||||
if (status==Success)
|
||||
status= XkbDDXListComponent(dev,_XkbListSymbols,list,client);
|
||||
if (status==Success)
|
||||
status= XkbDDXListComponent(dev,_XkbListGeometry,list,client);
|
||||
return status;
|
||||
}
|
||||
531
nx-X11/programs/Xserver/xkb/ddxLoad.c
Normal file
531
nx-X11/programs/Xserver/xkb/ddxLoad.c
Normal file
@@ -0,0 +1,531 @@
|
||||
/************************************************************
|
||||
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_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_XKB_CONFIG_H
|
||||
#include <xkb-config.h>
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
/* stat() */
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <nx-X11/X.h>
|
||||
#include <nx-X11/Xos.h>
|
||||
#include <nx-X11/Xproto.h>
|
||||
#include <nx-X11/keysym.h>
|
||||
#include <nx-X11/extensions/XKM.h>
|
||||
#include "inputstr.h"
|
||||
#include "scrnintstr.h"
|
||||
#include "windowstr.h"
|
||||
#include <xkbsrv.h>
|
||||
#include <nx-X11/extensions/XI.h>
|
||||
#include "xkb.h"
|
||||
|
||||
#if defined(CSRG_BASED) || defined(linux) || defined(__GNU__)
|
||||
#include <paths.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* If XKM_OUTPUT_DIR specifies a path without a leading slash, it is
|
||||
* relative to the top-level XKB configuration directory.
|
||||
* Making the server write to a subdirectory of that directory
|
||||
* requires some work in the general case (install procedure
|
||||
* has to create links to /var or somesuch on many machines),
|
||||
* so we just compile into /usr/tmp for now.
|
||||
*/
|
||||
#ifndef XKM_OUTPUT_DIR
|
||||
#define XKM_OUTPUT_DIR "compiled/"
|
||||
#endif
|
||||
|
||||
#define PRE_ERROR_MSG "\"The XKEYBOARD keymap compiler (xkbcomp) reports:\""
|
||||
#define ERROR_PREFIX "\"> \""
|
||||
#define POST_ERROR_MSG1 "\"Errors from xkbcomp are not fatal to the X server\""
|
||||
#define POST_ERROR_MSG2 "\"End of messages from xkbcomp\""
|
||||
|
||||
#if defined(WIN32)
|
||||
#define PATHSEPARATOR "\\"
|
||||
#else
|
||||
#define PATHSEPARATOR "/"
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
#include <nx-X11/Xwindows.h>
|
||||
const char*
|
||||
Win32TempDir()
|
||||
{
|
||||
static char buffer[PATH_MAX];
|
||||
if (GetTempPath(sizeof(buffer), buffer))
|
||||
{
|
||||
int len;
|
||||
buffer[sizeof(buffer)-1] = 0;
|
||||
len = strlen(buffer);
|
||||
if (len > 0)
|
||||
if (buffer[len-1] == '\\')
|
||||
buffer[len-1] = 0;
|
||||
return buffer;
|
||||
}
|
||||
if (getenv("TEMP") != NULL)
|
||||
return getenv("TEMP");
|
||||
else if (getenv("TMP") != NULL)
|
||||
return getenv("TEMP");
|
||||
else
|
||||
return "/tmp";
|
||||
}
|
||||
|
||||
int
|
||||
Win32System(const char *cmdline)
|
||||
{
|
||||
STARTUPINFO si;
|
||||
PROCESS_INFORMATION pi;
|
||||
DWORD dwExitCode;
|
||||
char *cmd = xstrdup(cmdline);
|
||||
|
||||
ZeroMemory( &si, sizeof(si) );
|
||||
si.cb = sizeof(si);
|
||||
ZeroMemory( &pi, sizeof(pi) );
|
||||
|
||||
if (!CreateProcess(NULL, cmd, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
|
||||
{
|
||||
LPVOID buffer;
|
||||
if (!FormatMessage(
|
||||
FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||
FORMAT_MESSAGE_FROM_SYSTEM |
|
||||
FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL,
|
||||
GetLastError(),
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
(LPTSTR) &buffer,
|
||||
0,
|
||||
NULL ))
|
||||
{
|
||||
ErrorF("Starting '%s' failed!\n", cmdline);
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorF("Starting '%s' failed: %s", cmdline, (char *)buffer);
|
||||
LocalFree(buffer);
|
||||
}
|
||||
|
||||
free(cmd);
|
||||
return -1;
|
||||
}
|
||||
/* Wait until child process exits. */
|
||||
WaitForSingleObject( pi.hProcess, INFINITE );
|
||||
|
||||
GetExitCodeProcess( pi.hProcess, &dwExitCode);
|
||||
|
||||
/* Close process and thread handles. */
|
||||
CloseHandle( pi.hProcess );
|
||||
CloseHandle( pi.hThread );
|
||||
free(cmd);
|
||||
|
||||
return dwExitCode;
|
||||
}
|
||||
#undef System
|
||||
#define System(x) Win32System(x)
|
||||
#endif
|
||||
|
||||
static void
|
||||
OutputDirectory(
|
||||
char* outdir,
|
||||
size_t size)
|
||||
{
|
||||
#ifndef WIN32
|
||||
if (getuid() == 0 && (strlen(XKM_OUTPUT_DIR) < size))
|
||||
{
|
||||
/* if server running as root it *may* be able to write */
|
||||
/* FIXME: check whether directory is writable at all */
|
||||
(void) strcpy (outdir, XKM_OUTPUT_DIR);
|
||||
} else
|
||||
#else
|
||||
if (strlen(Win32TempDir()) + 1 < size)
|
||||
{
|
||||
(void) strcpy(outdir, Win32TempDir());
|
||||
(void) strcat(outdir, "\\");
|
||||
} else
|
||||
#endif
|
||||
if (strlen("/tmp/") < size)
|
||||
{
|
||||
(void) strcpy (outdir, "/tmp/");
|
||||
}
|
||||
}
|
||||
|
||||
static Bool
|
||||
XkbDDXCompileNamedKeymap( XkbDescPtr xkb,
|
||||
XkbComponentNamesPtr names,
|
||||
char * nameRtrn,
|
||||
int nameRtrnLen)
|
||||
{
|
||||
char *cmd = NULL,file[PATH_MAX],xkm_output_dir[PATH_MAX],*map,*outFile;
|
||||
|
||||
if (names->keymap==NULL)
|
||||
return False;
|
||||
strncpy(file,names->keymap,PATH_MAX); file[PATH_MAX-1]= '\0';
|
||||
if ((map= strrchr(file,'('))!=NULL) {
|
||||
char *tmp;
|
||||
if ((tmp= strrchr(map,')'))!=NULL) {
|
||||
*map++= '\0';
|
||||
*tmp= '\0';
|
||||
}
|
||||
else {
|
||||
map= NULL;
|
||||
}
|
||||
}
|
||||
if ((outFile= strrchr(file,'/'))!=NULL)
|
||||
outFile= Xstrdup(&outFile[1]);
|
||||
else outFile= Xstrdup(file);
|
||||
XkbEnsureSafeMapName(outFile);
|
||||
OutputDirectory(xkm_output_dir, sizeof(xkm_output_dir));
|
||||
|
||||
if (XkbBaseDirectory!=NULL) {
|
||||
|
||||
char *xkbbasedir = XkbBaseDirectory;
|
||||
char *xkbbindir = XkbBinDirectory;
|
||||
|
||||
if (asprintf(&cmd,"\"%s" PATHSEPARATOR "xkbcomp\" -w %d \"-R%s\" -xkm %s%s -em1 %s -emp %s -eml %s keymap/%s \"%s%s.xkm\"",
|
||||
xkbbindir,
|
||||
((xkbDebugFlags<2)?1:((xkbDebugFlags>10)?10:(int)xkbDebugFlags)),
|
||||
xkbbasedir,(map?"-m ":""),(map?map:""),
|
||||
PRE_ERROR_MSG,ERROR_PREFIX,POST_ERROR_MSG1,file,
|
||||
xkm_output_dir,outFile) == -1)
|
||||
cmd = NULL;
|
||||
}
|
||||
else {
|
||||
if (asprintf(&cmd, "xkbcomp -w %d -xkm %s%s -em1 %s -emp %s -eml %s keymap/%s \"%s%s.xkm\"",
|
||||
((xkbDebugFlags<2)?1:((xkbDebugFlags>10)?10:(int)xkbDebugFlags)),
|
||||
(map?"-m ":""),(map?map:""),
|
||||
PRE_ERROR_MSG,ERROR_PREFIX,POST_ERROR_MSG1,file,
|
||||
xkm_output_dir,outFile) == -1)
|
||||
cmd = NULL;
|
||||
}
|
||||
if (xkbDebugFlags) {
|
||||
DebugF("XkbDDXCompileNamedKeymap compiling keymap using:\n");
|
||||
DebugF(" \"cmd\"\n");
|
||||
}
|
||||
if (System(cmd)==0) {
|
||||
if (nameRtrn) {
|
||||
strncpy(nameRtrn,outFile,nameRtrnLen);
|
||||
nameRtrn[nameRtrnLen-1]= '\0';
|
||||
}
|
||||
if (outFile!=NULL)
|
||||
_XkbFree(outFile);
|
||||
if (cmd!=NULL)
|
||||
free(cmd);
|
||||
return True;
|
||||
}
|
||||
DebugF("Error compiling keymap (%s)\n",names->keymap);
|
||||
if (outFile!=NULL)
|
||||
_XkbFree(outFile);
|
||||
if (cmd!=NULL)
|
||||
free(cmd);
|
||||
return False;
|
||||
}
|
||||
|
||||
static Bool
|
||||
XkbDDXCompileKeymapByNames( XkbDescPtr xkb,
|
||||
XkbComponentNamesPtr names,
|
||||
unsigned want,
|
||||
unsigned need,
|
||||
char * nameRtrn,
|
||||
int nameRtrnLen)
|
||||
{
|
||||
FILE * out;
|
||||
char *buf = NULL, keymap[PATH_MAX],xkm_output_dir[PATH_MAX];
|
||||
|
||||
#ifdef WIN32
|
||||
char tmpname[PATH_MAX];
|
||||
#endif
|
||||
if ((names->keymap==NULL)||(names->keymap[0]=='\0')) {
|
||||
sprintf(keymap,"server-%s",display);
|
||||
}
|
||||
else {
|
||||
if (strlen(names->keymap) > PATH_MAX - 1) {
|
||||
ErrorF("name of keymap (%s) exceeds max length\n", names->keymap);
|
||||
return False;
|
||||
}
|
||||
strcpy(keymap,names->keymap);
|
||||
}
|
||||
|
||||
XkbEnsureSafeMapName(keymap);
|
||||
OutputDirectory(xkm_output_dir, sizeof(xkm_output_dir));
|
||||
#ifdef WIN32
|
||||
strcpy(tmpname, Win32TempDir());
|
||||
strcat(tmpname, "\\xkb_XXXXXX");
|
||||
(void) mktemp(tmpname);
|
||||
#endif
|
||||
|
||||
if (XkbBaseDirectory!=NULL) {
|
||||
#ifndef WIN32
|
||||
char *xkmfile = "-";
|
||||
#else
|
||||
/* WIN32 has no popen. The input must be stored in a file which is used as input
|
||||
for xkbcomp. xkbcomp does not read from stdin. */
|
||||
char *xkmfile = tmpname;
|
||||
#endif
|
||||
char *xkbbasedir = XkbBaseDirectory;
|
||||
char *xkbbindir = XkbBinDirectory;
|
||||
|
||||
if (asprintf(&buf,
|
||||
"\"%s" PATHSEPARATOR "xkbcomp\" -w %d \"-R%s\" -xkm \"%s\" -em1 %s -emp %s -eml %s \"%s%s.xkm\"",
|
||||
xkbbindir,
|
||||
((xkbDebugFlags<2)?1:((xkbDebugFlags>10)?10:(int)xkbDebugFlags)),
|
||||
xkbbasedir, xkmfile,
|
||||
PRE_ERROR_MSG,ERROR_PREFIX,POST_ERROR_MSG1,
|
||||
xkm_output_dir,keymap) == -1)
|
||||
buf = NULL;
|
||||
}
|
||||
else {
|
||||
#ifndef WIN32
|
||||
char *xkmfile = "-";
|
||||
#else
|
||||
char *xkmfile = tmpname;
|
||||
#endif
|
||||
if (asprintf(&buf,
|
||||
"xkbcomp -w %d -xkm \"%s\" -em1 %s -emp %s -eml %s \"%s%s.xkm\"",
|
||||
((xkbDebugFlags<2)?1:((xkbDebugFlags>10)?10:(int)xkbDebugFlags)),
|
||||
xkmfile,
|
||||
PRE_ERROR_MSG,ERROR_PREFIX,POST_ERROR_MSG1,
|
||||
xkm_output_dir,keymap) == -1)
|
||||
buf = NULL;
|
||||
}
|
||||
|
||||
#ifdef TEST
|
||||
if (buf != NULL)
|
||||
fprintf(stderr, "XkbDDXCompileKeymapByNames: "
|
||||
"Executing command [%s].\n", buf);
|
||||
else
|
||||
fprintf(stderr, "XkbDDXCompileKeymapByNames: "
|
||||
"Callin Popen() with null command.\n");
|
||||
#endif
|
||||
|
||||
#ifndef WIN32
|
||||
out= Popen(buf,"w");
|
||||
#else
|
||||
out= fopen(tmpname, "w");
|
||||
#endif
|
||||
|
||||
if (out!=NULL) {
|
||||
#ifdef DEBUG
|
||||
if (xkbDebugFlags) {
|
||||
ErrorF("XkbDDXCompileKeymapByNames compiling keymap:\n");
|
||||
XkbWriteXKBKeymapForNames(stderr,names,NULL,xkb,want,need);
|
||||
}
|
||||
#endif
|
||||
XkbWriteXKBKeymapForNames(out,names,NULL,xkb,want,need);
|
||||
#ifndef WIN32
|
||||
#ifdef __sun
|
||||
if (Pclose(out) != 0)
|
||||
{
|
||||
ErrorF("Warning: Spurious failure reported in Pclose() running 'xkbcomp'.\n");
|
||||
}
|
||||
if (1)
|
||||
#else
|
||||
if (Pclose(out)==0)
|
||||
#endif
|
||||
#else
|
||||
if (fclose(out)==0 && System(buf) >= 0)
|
||||
#endif
|
||||
{
|
||||
if (xkbDebugFlags)
|
||||
DebugF("xkb executes: %s\n",buf);
|
||||
if (nameRtrn) {
|
||||
strncpy(nameRtrn,keymap,nameRtrnLen);
|
||||
nameRtrn[nameRtrnLen-1]= '\0';
|
||||
}
|
||||
if (buf != NULL)
|
||||
free (buf);
|
||||
return True;
|
||||
}
|
||||
else
|
||||
DebugF("Error compiling keymap (%s)\n",keymap);
|
||||
#ifdef WIN32
|
||||
/* remove the temporary file */
|
||||
unlink(tmpname);
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
#ifndef WIN32
|
||||
DebugF("Could not invoke keymap compiler\n");
|
||||
#else
|
||||
DebugF("Could not open file %s\n", tmpname);
|
||||
#endif
|
||||
}
|
||||
if (nameRtrn)
|
||||
nameRtrn[0]= '\0';
|
||||
if (buf != NULL)
|
||||
free (buf);
|
||||
return False;
|
||||
}
|
||||
|
||||
static FILE *
|
||||
XkbDDXOpenConfigFile(char *mapName,char *fileNameRtrn,int fileNameRtrnLen)
|
||||
{
|
||||
char buf[PATH_MAX],xkm_output_dir[PATH_MAX];
|
||||
FILE * file;
|
||||
|
||||
buf[0]= '\0';
|
||||
if (mapName!=NULL) {
|
||||
OutputDirectory(xkm_output_dir, sizeof(xkm_output_dir));
|
||||
if ((XkbBaseDirectory!=NULL)&&(xkm_output_dir[0]!='/')
|
||||
#ifdef WIN32
|
||||
&&(!isalpha(xkm_output_dir[0]) || xkm_output_dir[1]!=':')
|
||||
#endif
|
||||
) {
|
||||
if (snprintf(buf, PATH_MAX, "%s/%s%s.xkm", XkbBaseDirectory,
|
||||
xkm_output_dir, mapName) >= PATH_MAX)
|
||||
buf[0] = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
if (snprintf(buf, PATH_MAX, "%s%s.xkm", xkm_output_dir, mapName)
|
||||
>= PATH_MAX)
|
||||
buf[0] = '\0';
|
||||
}
|
||||
if (buf[0] != '\0')
|
||||
file= fopen(buf,"rb");
|
||||
else file= NULL;
|
||||
}
|
||||
else file= NULL;
|
||||
if ((fileNameRtrn!=NULL)&&(fileNameRtrnLen>0)) {
|
||||
strncpy(fileNameRtrn,buf,fileNameRtrnLen);
|
||||
buf[fileNameRtrnLen-1]= '\0';
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
unsigned
|
||||
XkbDDXLoadKeymapByNames( DeviceIntPtr keybd,
|
||||
XkbComponentNamesPtr names,
|
||||
unsigned want,
|
||||
unsigned need,
|
||||
XkbFileInfo * finfoRtrn,
|
||||
char * nameRtrn,
|
||||
int nameRtrnLen)
|
||||
{
|
||||
XkbDescPtr xkb;
|
||||
FILE * file;
|
||||
char fileName[PATH_MAX];
|
||||
unsigned missing;
|
||||
|
||||
bzero(finfoRtrn,sizeof(XkbFileInfo));
|
||||
if ((keybd==NULL)||(keybd->key==NULL)||(keybd->key->xkbInfo==NULL))
|
||||
xkb= NULL;
|
||||
else xkb= keybd->key->xkbInfo->desc;
|
||||
if ((names->keycodes==NULL)&&(names->types==NULL)&&
|
||||
(names->compat==NULL)&&(names->symbols==NULL)&&
|
||||
(names->geometry==NULL)) {
|
||||
if (names->keymap==NULL) {
|
||||
bzero(finfoRtrn,sizeof(XkbFileInfo));
|
||||
if (xkb && XkbDetermineFileType(finfoRtrn,XkbXKMFile,NULL) &&
|
||||
((finfoRtrn->defined&need)==need) ) {
|
||||
finfoRtrn->xkb= xkb;
|
||||
nameRtrn[0]= '\0';
|
||||
return finfoRtrn->defined;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
else if (!XkbDDXCompileNamedKeymap(xkb,names,nameRtrn,nameRtrnLen)) {
|
||||
DebugF("Couldn't compile keymap file\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else if (!XkbDDXCompileKeymapByNames(xkb,names,want,need,
|
||||
nameRtrn,nameRtrnLen)){
|
||||
DebugF("Couldn't compile keymap file\n");
|
||||
return 0;
|
||||
}
|
||||
file= XkbDDXOpenConfigFile(nameRtrn,fileName,PATH_MAX);
|
||||
if (file==NULL) {
|
||||
LogMessage(X_ERROR, "Couldn't open compiled keymap file %s\n",fileName);
|
||||
return 0;
|
||||
}
|
||||
missing= XkmReadFile(file,need,want,finfoRtrn);
|
||||
if (finfoRtrn->xkb==NULL) {
|
||||
LogMessage(X_ERROR, "Error loading keymap %s\n",fileName);
|
||||
fclose(file);
|
||||
(void) unlink (fileName);
|
||||
return 0;
|
||||
}
|
||||
else if (xkbDebugFlags) {
|
||||
DebugF("Loaded %s, defined=0x%x\n",fileName,finfoRtrn->defined);
|
||||
}
|
||||
fclose(file);
|
||||
(void) unlink (fileName);
|
||||
return (need|want)&(~missing);
|
||||
}
|
||||
|
||||
Bool
|
||||
XkbDDXNamesFromRules( DeviceIntPtr keybd,
|
||||
char * rules_name,
|
||||
XkbRF_VarDefsPtr defs,
|
||||
XkbComponentNamesPtr names)
|
||||
{
|
||||
char buf[PATH_MAX];
|
||||
FILE * file;
|
||||
Bool complete;
|
||||
XkbRF_RulesPtr rules;
|
||||
|
||||
if (!rules_name)
|
||||
return False;
|
||||
if (XkbBaseDirectory==NULL) {
|
||||
if (strlen(rules_name)+7 > PATH_MAX)
|
||||
return False;
|
||||
sprintf(buf,"rules/%s",rules_name);
|
||||
}
|
||||
else {
|
||||
if (snprintf(buf, PATH_MAX, "%s/rules/%s", XkbBaseDirectory, rules_name)
|
||||
>= PATH_MAX)
|
||||
return False;
|
||||
}
|
||||
if ((file= fopen(buf,"r"))==NULL)
|
||||
return False;
|
||||
if ((rules= XkbRF_Create(0,0))==NULL) {
|
||||
fclose(file);
|
||||
return False;
|
||||
}
|
||||
if (!XkbRF_LoadRules(file,rules)) {
|
||||
fclose(file);
|
||||
XkbRF_Free(rules,True);
|
||||
return False;
|
||||
}
|
||||
bzero((char *)names,sizeof(XkbComponentNamesRec));
|
||||
complete= XkbRF_GetComponents(rules,defs,names);
|
||||
fclose(file);
|
||||
XkbRF_Free(rules,True);
|
||||
return complete;
|
||||
}
|
||||
|
||||
|
||||
14
nx-X11/programs/Xserver/xkb/ddxPrivate.c
Normal file
14
nx-X11/programs/Xserver/xkb/ddxPrivate.c
Normal file
@@ -0,0 +1,14 @@
|
||||
|
||||
#ifdef HAVE_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#include <nx-X11/X.h>
|
||||
#include "windowstr.h"
|
||||
#include <xkbsrv.h>
|
||||
|
||||
int
|
||||
XkbDDXPrivate(DeviceIntPtr dev,KeyCode key,XkbAction *act)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
44
nx-X11/programs/Xserver/xkb/ddxVT.c
Normal file
44
nx-X11/programs/Xserver/xkb/ddxVT.c
Normal file
@@ -0,0 +1,44 @@
|
||||
/************************************************************
|
||||
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_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <nx-X11/X.h>
|
||||
#include <nx-X11/Xproto.h>
|
||||
#include <nx-X11/keysym.h>
|
||||
#include "inputstr.h"
|
||||
#include "scrnintstr.h"
|
||||
#include "windowstr.h"
|
||||
#include <xkbsrv.h>
|
||||
|
||||
int
|
||||
XkbDDXSwitchScreen(DeviceIntPtr dev,KeyCode key,XkbAction *act)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
1299
nx-X11/programs/Xserver/xkb/maprules.c
Normal file
1299
nx-X11/programs/Xserver/xkb/maprules.c
Normal file
File diff suppressed because it is too large
Load Diff
6113
nx-X11/programs/Xserver/xkb/xkb.c
Normal file
6113
nx-X11/programs/Xserver/xkb/xkb.c
Normal file
File diff suppressed because it is too large
Load Diff
31
nx-X11/programs/Xserver/xkb/xkb.h
Normal file
31
nx-X11/programs/Xserver/xkb/xkb.h
Normal file
@@ -0,0 +1,31 @@
|
||||
extern int ProcXkbUseExtension(ClientPtr client);
|
||||
extern int ProcXkbSelectEvents(ClientPtr client);
|
||||
extern int ProcXkbBell(ClientPtr client);
|
||||
extern int ProcXkbGetState(ClientPtr client);
|
||||
extern int ProcXkbLatchLockState(ClientPtr client);
|
||||
extern int ProcXkbGetControls(ClientPtr client);
|
||||
extern int ProcXkbSetControls(ClientPtr client);
|
||||
extern int ProcXkbGetMap(ClientPtr client);
|
||||
extern int ProcXkbSetMap(ClientPtr client);
|
||||
extern int ProcXkbGetCompatMap(ClientPtr client);
|
||||
extern int ProcXkbSetCompatMap(ClientPtr client);
|
||||
extern int ProcXkbGetIndicatorState(ClientPtr client);
|
||||
extern int ProcXkbGetIndicatorMap(ClientPtr client);
|
||||
extern int ProcXkbSetIndicatorMap(ClientPtr client);
|
||||
extern int ProcXkbGetNamedIndicator(ClientPtr client);
|
||||
extern int ProcXkbSetNamedIndicator(ClientPtr client);
|
||||
extern int ProcXkbGetNames(ClientPtr client);
|
||||
extern int ProcXkbSetNames(ClientPtr client);
|
||||
extern int ProcXkbGetGeometry(ClientPtr client);
|
||||
extern int ProcXkbSetGeometry(ClientPtr client);
|
||||
extern int ProcXkbPerClientFlags(ClientPtr client);
|
||||
extern int ProcXkbListComponents(ClientPtr client);
|
||||
extern int ProcXkbGetKbdByName(ClientPtr client);
|
||||
extern int ProcXkbGetDeviceInfo(ClientPtr client);
|
||||
extern int ProcXkbSetDeviceInfo(ClientPtr client);
|
||||
extern int ProcXkbSetDebuggingFlags(ClientPtr client);
|
||||
|
||||
|
||||
extern void XkbExtensionInit(void);
|
||||
|
||||
extern Bool XkbFilterEvents(ClientPtr pClient, int nEvents, xEvent *xE);
|
||||
738
nx-X11/programs/Xserver/xkb/xkbAccessX.c
Normal file
738
nx-X11/programs/Xserver/xkb/xkbAccessX.c
Normal file
@@ -0,0 +1,738 @@
|
||||
/************************************************************
|
||||
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_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <nx-X11/X.h>
|
||||
#include <nx-X11/Xproto.h>
|
||||
#include <nx-X11/keysym.h>
|
||||
#include "inputstr.h"
|
||||
#include <xkbsrv.h>
|
||||
#if !defined(WIN32)
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
int XkbDfltRepeatDelay= 660;
|
||||
int XkbDfltRepeatInterval= 40;
|
||||
void * XkbLastRepeatEvent= NULL;
|
||||
|
||||
#define DFLT_TIMEOUT_CTRLS (XkbAX_KRGMask|XkbStickyKeysMask|XkbMouseKeysMask)
|
||||
#define DFLT_TIMEOUT_OPTS (XkbAX_IndicatorFBMask)
|
||||
|
||||
unsigned short XkbDfltAccessXTimeout= 120;
|
||||
unsigned int XkbDfltAccessXTimeoutMask= DFLT_TIMEOUT_CTRLS;
|
||||
static unsigned int XkbDfltAccessXTimeoutValues= 0;
|
||||
static unsigned int XkbDfltAccessXTimeoutOptionsMask= DFLT_TIMEOUT_OPTS;
|
||||
static unsigned int XkbDfltAccessXTimeoutOptionsValues= 0;
|
||||
unsigned int XkbDfltAccessXFeedback= XkbAccessXFeedbackMask;
|
||||
unsigned short XkbDfltAccessXOptions= XkbAX_AllOptionsMask & ~(XkbAX_IndicatorFBMask|XkbAX_SKReleaseFBMask|XkbAX_SKRejectFBMask);
|
||||
|
||||
void
|
||||
AccessXComputeCurveFactor(XkbSrvInfoPtr xkbi,XkbControlsPtr ctrls)
|
||||
{
|
||||
xkbi->mouseKeysCurve= 1.0+(((double)ctrls->mk_curve)*0.001);
|
||||
xkbi->mouseKeysCurveFactor= ( ((double)ctrls->mk_max_speed)/
|
||||
pow((double)ctrls->mk_time_to_max,xkbi->mouseKeysCurve));
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
AccessXInit(DeviceIntPtr keybd)
|
||||
{
|
||||
XkbSrvInfoPtr xkbi = keybd->key->xkbInfo;
|
||||
XkbControlsPtr ctrls = xkbi->desc->ctrls;
|
||||
|
||||
xkbi->shiftKeyCount= 0;
|
||||
xkbi->mouseKeysCounter= 0;
|
||||
xkbi->inactiveKey= 0;
|
||||
xkbi->slowKey= 0;
|
||||
xkbi->repeatKey= 0;
|
||||
xkbi->krgTimerActive= _OFF_TIMER;
|
||||
xkbi->beepType= _BEEP_NONE;
|
||||
xkbi->beepCount= 0;
|
||||
xkbi->mouseKeyTimer= NULL;
|
||||
xkbi->slowKeysTimer= NULL;
|
||||
xkbi->bounceKeysTimer= NULL;
|
||||
xkbi->repeatKeyTimer= NULL;
|
||||
xkbi->krgTimer= NULL;
|
||||
xkbi->beepTimer= NULL;
|
||||
ctrls->repeat_delay = XkbDfltRepeatDelay;
|
||||
ctrls->repeat_interval = XkbDfltRepeatInterval;
|
||||
ctrls->debounce_delay = 300;
|
||||
ctrls->slow_keys_delay = 300;
|
||||
ctrls->mk_delay = 160;
|
||||
ctrls->mk_interval = 40;
|
||||
ctrls->mk_time_to_max = 30;
|
||||
ctrls->mk_max_speed = 30;
|
||||
ctrls->mk_curve = 500;
|
||||
ctrls->mk_dflt_btn = 1;
|
||||
ctrls->ax_timeout = XkbDfltAccessXTimeout;
|
||||
ctrls->axt_ctrls_mask = XkbDfltAccessXTimeoutMask;
|
||||
ctrls->axt_ctrls_values = XkbDfltAccessXTimeoutValues;
|
||||
ctrls->axt_opts_mask = XkbDfltAccessXTimeoutOptionsMask;
|
||||
ctrls->axt_opts_values = XkbDfltAccessXTimeoutOptionsValues;
|
||||
if (XkbDfltAccessXTimeout)
|
||||
ctrls->enabled_ctrls |= XkbAccessXTimeoutMask;
|
||||
else
|
||||
ctrls->enabled_ctrls &= ~XkbAccessXTimeoutMask;
|
||||
ctrls->enabled_ctrls |= XkbDfltAccessXFeedback;
|
||||
ctrls->ax_options = XkbDfltAccessXOptions;
|
||||
AccessXComputeCurveFactor(xkbi,ctrls);
|
||||
return;
|
||||
}
|
||||
|
||||
/************************************************************************/
|
||||
/* */
|
||||
/* AccessXKeyboardEvent */
|
||||
/* */
|
||||
/* Generate a synthetic keyboard event. */
|
||||
/* */
|
||||
/************************************************************************/
|
||||
static void
|
||||
AccessXKeyboardEvent(DeviceIntPtr keybd,
|
||||
BYTE type,
|
||||
BYTE keyCode,
|
||||
Bool isRepeat)
|
||||
{
|
||||
xEvent xE;
|
||||
|
||||
xE.u.u.type = type;
|
||||
xE.u.u.detail = keyCode;
|
||||
xE.u.keyButtonPointer.time = GetTimeInMillis();
|
||||
if (xkbDebugFlags&0x8) {
|
||||
DebugF("AXKE: Key %d %s\n",keyCode,(xE.u.u.type==KeyPress?"down":"up"));
|
||||
}
|
||||
|
||||
if (!_XkbIsPressEvent(type) && isRepeat)
|
||||
XkbLastRepeatEvent= (void *)&xE;
|
||||
XkbProcessKeyboardEvent(&xE,keybd,1L);
|
||||
XkbLastRepeatEvent= NULL;
|
||||
return;
|
||||
|
||||
} /* AccessXKeyboardEvent */
|
||||
|
||||
/************************************************************************/
|
||||
/* */
|
||||
/* AccessXKRGTurnOn */
|
||||
/* */
|
||||
/* Turn the keyboard response group on. */
|
||||
/* */
|
||||
/************************************************************************/
|
||||
static void
|
||||
AccessXKRGTurnOn(DeviceIntPtr dev,CARD16 KRGControl,xkbControlsNotify *pCN)
|
||||
{
|
||||
XkbSrvInfoPtr xkbi = dev->key->xkbInfo;
|
||||
XkbControlsPtr ctrls = xkbi->desc->ctrls;
|
||||
XkbControlsRec old;
|
||||
XkbEventCauseRec cause;
|
||||
XkbSrvLedInfoPtr sli;
|
||||
|
||||
old= *ctrls;
|
||||
ctrls->enabled_ctrls |= (KRGControl&XkbAX_KRGMask);
|
||||
if (XkbComputeControlsNotify(dev,&old,ctrls,pCN,False))
|
||||
XkbSendControlsNotify(dev,pCN);
|
||||
cause.kc= pCN->keycode;
|
||||
cause.event= pCN->eventType;
|
||||
cause.mjr= pCN->requestMajor;
|
||||
cause.mnr= pCN->requestMinor;
|
||||
sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,0);
|
||||
XkbUpdateIndicators(dev,sli->usesControls,True,NULL,&cause);
|
||||
if (XkbAX_NeedFeedback(ctrls,XkbAX_FeatureFBMask))
|
||||
XkbDDXAccessXBeep(dev,_BEEP_FEATURE_ON,KRGControl);
|
||||
return;
|
||||
|
||||
} /* AccessXKRGTurnOn */
|
||||
|
||||
/************************************************************************/
|
||||
/* */
|
||||
/* AccessXKRGTurnOff */
|
||||
/* */
|
||||
/* Turn the keyboard response group off. */
|
||||
/* */
|
||||
/************************************************************************/
|
||||
static void
|
||||
AccessXKRGTurnOff(DeviceIntPtr dev,xkbControlsNotify *pCN)
|
||||
{
|
||||
XkbSrvInfoPtr xkbi = dev->key->xkbInfo;
|
||||
XkbControlsPtr ctrls = xkbi->desc->ctrls;
|
||||
XkbControlsRec old;
|
||||
XkbEventCauseRec cause;
|
||||
XkbSrvLedInfoPtr sli;
|
||||
|
||||
old = *ctrls;
|
||||
ctrls->enabled_ctrls &= ~XkbAX_KRGMask;
|
||||
if (XkbComputeControlsNotify(dev,&old,ctrls,pCN,False))
|
||||
XkbSendControlsNotify(dev,pCN);
|
||||
cause.kc= pCN->keycode;
|
||||
cause.event= pCN->eventType;
|
||||
cause.mjr= pCN->requestMajor;
|
||||
cause.mnr= pCN->requestMinor;
|
||||
sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,0);
|
||||
XkbUpdateIndicators(dev,sli->usesControls,True,NULL,&cause);
|
||||
if (XkbAX_NeedFeedback(ctrls,XkbAX_FeatureFBMask)) {
|
||||
unsigned changes= old.enabled_ctrls^ctrls->enabled_ctrls;
|
||||
XkbDDXAccessXBeep(dev,_BEEP_FEATURE_OFF,changes);
|
||||
}
|
||||
return;
|
||||
|
||||
} /* AccessXKRGTurnOff */
|
||||
|
||||
/************************************************************************/
|
||||
/* */
|
||||
/* AccessXStickyKeysTurnOn */
|
||||
/* */
|
||||
/* Turn StickyKeys on. */
|
||||
/* */
|
||||
/************************************************************************/
|
||||
static void
|
||||
AccessXStickyKeysTurnOn(DeviceIntPtr dev,xkbControlsNotify *pCN)
|
||||
{
|
||||
XkbSrvInfoPtr xkbi = dev->key->xkbInfo;
|
||||
XkbControlsPtr ctrls = xkbi->desc->ctrls;
|
||||
XkbControlsRec old;
|
||||
XkbEventCauseRec cause;
|
||||
XkbSrvLedInfoPtr sli;
|
||||
|
||||
old = *ctrls;
|
||||
ctrls->enabled_ctrls |= XkbStickyKeysMask;
|
||||
xkbi->shiftKeyCount = 0;
|
||||
if (XkbComputeControlsNotify(dev,&old,ctrls,pCN,False))
|
||||
XkbSendControlsNotify(dev,pCN);
|
||||
cause.kc= pCN->keycode;
|
||||
cause.event= pCN->eventType;
|
||||
cause.mjr= pCN->requestMajor;
|
||||
cause.mnr= pCN->requestMinor;
|
||||
sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,0);
|
||||
XkbUpdateIndicators(dev,sli->usesControls,True,NULL,&cause);
|
||||
if (XkbAX_NeedFeedback(ctrls,XkbAX_FeatureFBMask)) {
|
||||
XkbDDXAccessXBeep(dev,_BEEP_FEATURE_ON,XkbStickyKeysMask);
|
||||
}
|
||||
return;
|
||||
|
||||
} /* AccessXStickyKeysTurnOn */
|
||||
|
||||
/************************************************************************/
|
||||
/* */
|
||||
/* AccessXStickyKeysTurnOff */
|
||||
/* */
|
||||
/* Turn StickyKeys off. */
|
||||
/* */
|
||||
/************************************************************************/
|
||||
static void
|
||||
AccessXStickyKeysTurnOff(DeviceIntPtr dev,xkbControlsNotify *pCN)
|
||||
{
|
||||
XkbSrvInfoPtr xkbi = dev->key->xkbInfo;
|
||||
XkbControlsPtr ctrls = xkbi->desc->ctrls;
|
||||
XkbControlsRec old;
|
||||
XkbEventCauseRec cause;
|
||||
XkbSrvLedInfoPtr sli;
|
||||
|
||||
old = *ctrls;
|
||||
ctrls->enabled_ctrls &= ~XkbStickyKeysMask;
|
||||
xkbi->shiftKeyCount = 0;
|
||||
if (XkbComputeControlsNotify(dev,&old,ctrls,pCN,False))
|
||||
XkbSendControlsNotify(dev,pCN);
|
||||
|
||||
cause.kc= pCN->keycode;
|
||||
cause.event= pCN->eventType;
|
||||
cause.mjr= pCN->requestMajor;
|
||||
cause.mnr= pCN->requestMinor;
|
||||
sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,0);
|
||||
XkbUpdateIndicators(dev,sli->usesControls,True,NULL,&cause);
|
||||
if (XkbAX_NeedFeedback(ctrls,XkbAX_FeatureFBMask)) {
|
||||
XkbDDXAccessXBeep(dev,_BEEP_FEATURE_OFF,XkbStickyKeysMask);
|
||||
}
|
||||
#ifndef NO_CLEAR_LATCHES_FOR_STICKY_KEYS_OFF
|
||||
XkbClearAllLatchesAndLocks(dev,xkbi,False,&cause);
|
||||
#endif
|
||||
return;
|
||||
} /* AccessXStickyKeysTurnOff */
|
||||
|
||||
static CARD32
|
||||
AccessXKRGExpire(OsTimerPtr timer,CARD32 now,void * arg)
|
||||
{
|
||||
XkbSrvInfoPtr xkbi= ((DeviceIntPtr)arg)->key->xkbInfo;
|
||||
xkbControlsNotify cn;
|
||||
|
||||
if (xkbi->krgTimerActive==_KRG_WARN_TIMER) {
|
||||
XkbDDXAccessXBeep((DeviceIntPtr)arg,_BEEP_SLOW_WARN,XkbStickyKeysMask);
|
||||
xkbi->krgTimerActive= _KRG_TIMER;
|
||||
return 4000;
|
||||
}
|
||||
xkbi->krgTimerActive= _OFF_TIMER;
|
||||
cn.keycode = 0;
|
||||
cn.eventType = 0;
|
||||
cn.requestMajor = 0;
|
||||
cn.requestMinor = 0;
|
||||
if (xkbi->desc->ctrls->enabled_ctrls&XkbSlowKeysMask)
|
||||
AccessXKRGTurnOff((DeviceIntPtr)arg,&cn);
|
||||
else AccessXKRGTurnOn((DeviceIntPtr)arg,XkbSlowKeysMask,&cn);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static CARD32
|
||||
AccessXRepeatKeyExpire(OsTimerPtr timer,CARD32 now,void * arg)
|
||||
{
|
||||
XkbSrvInfoPtr xkbi= ((DeviceIntPtr)arg)->key->xkbInfo;
|
||||
KeyCode key;
|
||||
|
||||
if (xkbi->repeatKey==0)
|
||||
return 0;
|
||||
key= xkbi->repeatKey;
|
||||
AccessXKeyboardEvent((DeviceIntPtr)arg,KeyRelease,key,True);
|
||||
AccessXKeyboardEvent((DeviceIntPtr)arg,KeyPress,key,True);
|
||||
return xkbi->desc->ctrls->repeat_interval;
|
||||
}
|
||||
|
||||
void
|
||||
AccessXCancelRepeatKey(XkbSrvInfoPtr xkbi,KeyCode key)
|
||||
{
|
||||
if (xkbi->repeatKey==key)
|
||||
xkbi->repeatKey= 0;
|
||||
return;
|
||||
}
|
||||
|
||||
static CARD32
|
||||
AccessXSlowKeyExpire(OsTimerPtr timer,CARD32 now,void * arg)
|
||||
{
|
||||
DeviceIntPtr keybd;
|
||||
XkbSrvInfoPtr xkbi;
|
||||
XkbDescPtr xkb;
|
||||
XkbControlsPtr ctrls;
|
||||
|
||||
keybd= (DeviceIntPtr)arg;
|
||||
xkbi= keybd->key->xkbInfo;
|
||||
xkb= xkbi->desc;
|
||||
ctrls= xkb->ctrls;
|
||||
if (xkbi->slowKey!=0) {
|
||||
xkbAccessXNotify ev;
|
||||
KeySym *sym= XkbKeySymsPtr(xkb,xkbi->slowKey);
|
||||
ev.detail= XkbAXN_SKAccept;
|
||||
ev.keycode= xkbi->slowKey;
|
||||
ev.slowKeysDelay= ctrls->slow_keys_delay;
|
||||
ev.debounceDelay= ctrls->debounce_delay;
|
||||
XkbSendAccessXNotify(keybd,&ev);
|
||||
if (XkbAX_NeedFeedback(ctrls,XkbAX_SKAcceptFBMask))
|
||||
XkbDDXAccessXBeep(keybd,_BEEP_SLOW_ACCEPT,XkbSlowKeysMask);
|
||||
AccessXKeyboardEvent(keybd,KeyPress,xkbi->slowKey,False);
|
||||
/* check for magic sequences */
|
||||
if ((ctrls->enabled_ctrls&XkbAccessXKeysMask) &&
|
||||
((sym[0]==XK_Shift_R)||(sym[0]==XK_Shift_L)))
|
||||
xkbi->shiftKeyCount++;
|
||||
|
||||
/* Start repeating if necessary. Stop autorepeating if the user
|
||||
* presses a non-modifier key that doesn't autorepeat.
|
||||
*/
|
||||
if (keybd->kbdfeed->ctrl.autoRepeat &&
|
||||
((xkbi->slowKey != xkbi->mouseKey) || (!xkbi->mouseKeysAccel)) &&
|
||||
(ctrls->enabled_ctrls&XkbRepeatKeysMask)) {
|
||||
if (BitIsOn(keybd->kbdfeed->ctrl.autoRepeats,xkbi->slowKey))
|
||||
{
|
||||
xkbi->repeatKey = xkbi->slowKey;
|
||||
xkbi->repeatKeyTimer= TimerSet(xkbi->repeatKeyTimer,
|
||||
0, ctrls->repeat_delay,
|
||||
AccessXRepeatKeyExpire, (void *)keybd);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static CARD32
|
||||
AccessXBounceKeyExpire(OsTimerPtr timer,CARD32 now,void * arg)
|
||||
{
|
||||
XkbSrvInfoPtr xkbi= ((DeviceIntPtr)arg)->key->xkbInfo;
|
||||
|
||||
xkbi->inactiveKey= 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static CARD32
|
||||
AccessXTimeoutExpire(OsTimerPtr timer,CARD32 now,void * arg)
|
||||
{
|
||||
DeviceIntPtr dev = (DeviceIntPtr)arg;
|
||||
XkbSrvInfoPtr xkbi= dev->key->xkbInfo;
|
||||
XkbControlsPtr ctrls= xkbi->desc->ctrls;
|
||||
XkbControlsRec old;
|
||||
xkbControlsNotify cn;
|
||||
XkbEventCauseRec cause;
|
||||
XkbSrvLedInfoPtr sli;
|
||||
|
||||
if (xkbi->lastPtrEventTime) {
|
||||
unsigned timeToWait = (ctrls->ax_timeout*1000);
|
||||
unsigned timeElapsed = (now-xkbi->lastPtrEventTime);
|
||||
|
||||
if (timeToWait > timeElapsed)
|
||||
return (timeToWait - timeElapsed);
|
||||
}
|
||||
old= *ctrls;
|
||||
xkbi->shiftKeyCount= 0;
|
||||
ctrls->enabled_ctrls&= ~ctrls->axt_ctrls_mask;
|
||||
ctrls->enabled_ctrls|=
|
||||
(ctrls->axt_ctrls_values&ctrls->axt_ctrls_mask);
|
||||
if (ctrls->axt_opts_mask) {
|
||||
ctrls->ax_options&= ~ctrls->axt_opts_mask;
|
||||
ctrls->ax_options|= (ctrls->axt_opts_values&ctrls->axt_opts_mask);
|
||||
}
|
||||
if (XkbComputeControlsNotify(dev,&old,ctrls,&cn,False)) {
|
||||
cn.keycode = 0;
|
||||
cn.eventType = 0;
|
||||
cn.requestMajor = 0;
|
||||
cn.requestMinor = 0;
|
||||
XkbSendControlsNotify(dev,&cn);
|
||||
}
|
||||
XkbSetCauseUnknown(&cause);
|
||||
sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,0);
|
||||
XkbUpdateIndicators(dev,sli->usesControls,True,NULL,&cause);
|
||||
if (ctrls->ax_options!=old.ax_options) {
|
||||
unsigned set,cleared,bell;
|
||||
set= ctrls->ax_options&(~old.ax_options);
|
||||
cleared= (~ctrls->ax_options)&old.ax_options;
|
||||
if (set && cleared) bell= _BEEP_FEATURE_CHANGE;
|
||||
else if (set) bell= _BEEP_FEATURE_ON;
|
||||
else bell= _BEEP_FEATURE_OFF;
|
||||
XkbDDXAccessXBeep(dev,bell,XkbAccessXTimeoutMask);
|
||||
}
|
||||
xkbi->krgTimerActive= _OFF_TIMER;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************/
|
||||
/* */
|
||||
/* AccessXFilterPressEvent */
|
||||
/* */
|
||||
/* Filter events before they get any further if SlowKeys is turned on. */
|
||||
/* In addition, this routine handles the ever so popular magic key */
|
||||
/* acts for turning various accessibility features on/off. */
|
||||
/* */
|
||||
/* Returns TRUE if this routine has discarded the event. */
|
||||
/* Returns FALSE if the event needs further processing. */
|
||||
/* */
|
||||
/************************************************************************/
|
||||
Bool
|
||||
AccessXFilterPressEvent( register xEvent * xE,
|
||||
register DeviceIntPtr keybd,
|
||||
int count)
|
||||
{
|
||||
XkbSrvInfoPtr xkbi = keybd->key->xkbInfo;
|
||||
XkbControlsPtr ctrls = xkbi->desc->ctrls;
|
||||
Bool ignoreKeyEvent = FALSE;
|
||||
KeyCode key = xE->u.u.detail;
|
||||
KeySym * sym = XkbKeySymsPtr(xkbi->desc,key);
|
||||
|
||||
if (ctrls->enabled_ctrls&XkbAccessXKeysMask) {
|
||||
/* check for magic sequences */
|
||||
if ((sym[0]==XK_Shift_R)||(sym[0]==XK_Shift_L)) {
|
||||
if (XkbAX_NeedFeedback(ctrls,XkbAX_SlowWarnFBMask)) {
|
||||
xkbi->krgTimerActive = _KRG_WARN_TIMER;
|
||||
xkbi->krgTimer= TimerSet(xkbi->krgTimer, 0, 4000,
|
||||
AccessXKRGExpire, (void *)keybd);
|
||||
}
|
||||
else {
|
||||
xkbi->krgTimerActive = _KRG_TIMER;
|
||||
xkbi->krgTimer= TimerSet(xkbi->krgTimer, 0, 8000,
|
||||
AccessXKRGExpire, (void *)keybd);
|
||||
}
|
||||
if (!(ctrls->enabled_ctrls & XkbSlowKeysMask)) {
|
||||
CARD32 now= GetTimeInMillis();
|
||||
if ((now-xkbi->lastShiftEventTime)>15000)
|
||||
xkbi->shiftKeyCount= 1;
|
||||
else xkbi->shiftKeyCount++;
|
||||
xkbi->lastShiftEventTime= now;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (xkbi->krgTimerActive) {
|
||||
xkbi->krgTimer= TimerSet(xkbi->krgTimer,0, 0, NULL, NULL);
|
||||
xkbi->krgTimerActive= _OFF_TIMER;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Don't transmit the KeyPress if SlowKeys is turned on;
|
||||
* The wakeup handler will synthesize one for us if the user
|
||||
* has held the key long enough.
|
||||
*/
|
||||
if (ctrls->enabled_ctrls & XkbSlowKeysMask) {
|
||||
xkbAccessXNotify ev;
|
||||
/* If key was already pressed, ignore subsequent press events
|
||||
* from the server's autorepeat
|
||||
*/
|
||||
if(xkbi->slowKey == key)
|
||||
return TRUE;
|
||||
ev.detail= XkbAXN_SKPress;
|
||||
ev.keycode= key;
|
||||
ev.slowKeysDelay= ctrls->slow_keys_delay;
|
||||
ev.debounceDelay= ctrls->debounce_delay;
|
||||
XkbSendAccessXNotify(keybd,&ev);
|
||||
if (XkbAX_NeedFeedback(ctrls,XkbAX_SKPressFBMask))
|
||||
XkbDDXAccessXBeep(keybd,_BEEP_SLOW_PRESS,XkbSlowKeysMask);
|
||||
xkbi->slowKey= key;
|
||||
xkbi->slowKeysTimer = TimerSet(xkbi->slowKeysTimer,
|
||||
0, ctrls->slow_keys_delay,
|
||||
AccessXSlowKeyExpire, (void *)keybd);
|
||||
ignoreKeyEvent = TRUE;
|
||||
}
|
||||
|
||||
/* Don't transmit the KeyPress if BounceKeys is turned on
|
||||
* and the user pressed the same key within a given time period
|
||||
* from the last release.
|
||||
*/
|
||||
else if ((ctrls->enabled_ctrls & XkbBounceKeysMask) &&
|
||||
(key == xkbi->inactiveKey)) {
|
||||
if (XkbAX_NeedFeedback(ctrls,XkbAX_BKRejectFBMask))
|
||||
XkbDDXAccessXBeep(keybd,_BEEP_BOUNCE_REJECT,XkbBounceKeysMask);
|
||||
ignoreKeyEvent = TRUE;
|
||||
}
|
||||
|
||||
/* Start repeating if necessary. Stop autorepeating if the user
|
||||
* presses a non-modifier key that doesn't autorepeat.
|
||||
*/
|
||||
if (XkbDDXUsesSoftRepeat(keybd)) {
|
||||
if ((keybd->kbdfeed->ctrl.autoRepeat) &&
|
||||
((ctrls->enabled_ctrls&(XkbSlowKeysMask|XkbRepeatKeysMask))==
|
||||
XkbRepeatKeysMask)) {
|
||||
if (BitIsOn(keybd->kbdfeed->ctrl.autoRepeats,key))
|
||||
{
|
||||
if (xkbDebugFlags&0x10)
|
||||
DebugF("Starting software autorepeat...\n");
|
||||
xkbi->repeatKey = key;
|
||||
xkbi->repeatKeyTimer= TimerSet(xkbi->repeatKeyTimer,
|
||||
0, ctrls->repeat_delay,
|
||||
AccessXRepeatKeyExpire, (void *)keybd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Check for two keys being pressed at the same time. This section
|
||||
* essentially says the following:
|
||||
*
|
||||
* If StickyKeys is on, and a modifier is currently being held down,
|
||||
* and one of the following is true: the current key is not a modifier
|
||||
* or the currentKey is a modifier, but not the only modifier being
|
||||
* held down, turn StickyKeys off if the TwoKeys off ctrl is set.
|
||||
*/
|
||||
if ((ctrls->enabled_ctrls & XkbStickyKeysMask) &&
|
||||
(xkbi->state.base_mods!=0) &&
|
||||
(XkbAX_NeedOption(ctrls,XkbAX_TwoKeysMask))) {
|
||||
xkbControlsNotify cn;
|
||||
cn.keycode = key;
|
||||
cn.eventType = KeyPress;
|
||||
cn.requestMajor = 0;
|
||||
cn.requestMinor = 0;
|
||||
AccessXStickyKeysTurnOff(keybd,&cn);
|
||||
}
|
||||
|
||||
if (!ignoreKeyEvent)
|
||||
XkbProcessKeyboardEvent(xE,keybd,count);
|
||||
return ignoreKeyEvent;
|
||||
} /* AccessXFilterPressEvent */
|
||||
|
||||
/************************************************************************/
|
||||
/* */
|
||||
/* AccessXFilterReleaseEvent */
|
||||
/* */
|
||||
/* Filter events before they get any further if SlowKeys is turned on. */
|
||||
/* In addition, this routine handles the ever so popular magic key */
|
||||
/* acts for turning various accessibility features on/off. */
|
||||
/* */
|
||||
/* Returns TRUE if this routine has discarded the event. */
|
||||
/* Returns FALSE if the event needs further processing. */
|
||||
/* */
|
||||
/************************************************************************/
|
||||
Bool
|
||||
AccessXFilterReleaseEvent( register xEvent * xE,
|
||||
register DeviceIntPtr keybd,
|
||||
int count)
|
||||
{
|
||||
XkbSrvInfoPtr xkbi = keybd->key->xkbInfo;
|
||||
XkbControlsPtr ctrls = xkbi->desc->ctrls;
|
||||
KeyCode key = xE->u.u.detail;
|
||||
Bool ignoreKeyEvent = FALSE;
|
||||
|
||||
/* Don't transmit the KeyRelease if BounceKeys is on and
|
||||
* this is the release of a key that was ignored due to
|
||||
* BounceKeys.
|
||||
*/
|
||||
if (ctrls->enabled_ctrls & XkbBounceKeysMask) {
|
||||
if ((key!=xkbi->mouseKey)&&(!BitIsOn(keybd->key->down,key)))
|
||||
ignoreKeyEvent = TRUE;
|
||||
xkbi->inactiveKey= key;
|
||||
xkbi->bounceKeysTimer= TimerSet(xkbi->bounceKeysTimer, 0,
|
||||
ctrls->debounce_delay,
|
||||
AccessXBounceKeyExpire, (void *)keybd);
|
||||
}
|
||||
|
||||
/* Don't transmit the KeyRelease if SlowKeys is turned on and
|
||||
* the user didn't hold the key long enough. We know we passed
|
||||
* the key if the down bit was set by CoreProcessKeyboadEvent.
|
||||
*/
|
||||
if (ctrls->enabled_ctrls & XkbSlowKeysMask) {
|
||||
xkbAccessXNotify ev;
|
||||
unsigned beep_type;
|
||||
ev.keycode= key;
|
||||
ev.slowKeysDelay= ctrls->slow_keys_delay;
|
||||
ev.debounceDelay= ctrls->debounce_delay;
|
||||
if (BitIsOn(keybd->key->down,key) || (xkbi->mouseKey == key)) {
|
||||
ev.detail= XkbAXN_SKRelease;
|
||||
beep_type= _BEEP_SLOW_RELEASE;
|
||||
}
|
||||
else {
|
||||
ev.detail= XkbAXN_SKReject;
|
||||
beep_type= _BEEP_SLOW_REJECT;
|
||||
ignoreKeyEvent = TRUE;
|
||||
}
|
||||
XkbSendAccessXNotify(keybd,&ev);
|
||||
if (XkbAX_NeedFeedback(ctrls,XkbAX_SKRejectFBMask)) {
|
||||
XkbDDXAccessXBeep(keybd,beep_type,XkbSlowKeysMask);
|
||||
}
|
||||
if (xkbi->slowKey==key)
|
||||
xkbi->slowKey= 0;
|
||||
}
|
||||
|
||||
/* Stop Repeating if the user releases the key that is currently
|
||||
* repeating.
|
||||
*/
|
||||
if (xkbi->repeatKey==key) {
|
||||
xkbi->repeatKey= 0;
|
||||
}
|
||||
|
||||
if ((ctrls->enabled_ctrls&XkbAccessXTimeoutMask)&&(ctrls->ax_timeout>0)) {
|
||||
xkbi->lastPtrEventTime= 0;
|
||||
xkbi->krgTimer= TimerSet(xkbi->krgTimer, 0,
|
||||
ctrls->ax_timeout*1000,
|
||||
AccessXTimeoutExpire, (void *)keybd);
|
||||
xkbi->krgTimerActive= _ALL_TIMEOUT_TIMER;
|
||||
}
|
||||
else if (xkbi->krgTimerActive!=_OFF_TIMER) {
|
||||
xkbi->krgTimer= TimerSet(xkbi->krgTimer, 0, 0, NULL, NULL);
|
||||
xkbi->krgTimerActive= _OFF_TIMER;
|
||||
}
|
||||
|
||||
/* Keep track of how many times the Shift key has been pressed.
|
||||
* If it has been pressed and released 5 times in a row, toggle
|
||||
* the state of StickyKeys.
|
||||
*/
|
||||
if ((!ignoreKeyEvent)&&(xkbi->shiftKeyCount)) {
|
||||
KeySym *pSym= XkbKeySymsPtr(xkbi->desc,key);
|
||||
if ((pSym[0]!=XK_Shift_L)&&(pSym[0]!=XK_Shift_R)) {
|
||||
xkbi->shiftKeyCount= 0;
|
||||
}
|
||||
else if (xkbi->shiftKeyCount>=5) {
|
||||
xkbControlsNotify cn;
|
||||
cn.keycode = key;
|
||||
cn.eventType = KeyPress;
|
||||
cn.requestMajor = 0;
|
||||
cn.requestMinor = 0;
|
||||
if (ctrls->enabled_ctrls & XkbStickyKeysMask)
|
||||
AccessXStickyKeysTurnOff(keybd,&cn);
|
||||
else
|
||||
AccessXStickyKeysTurnOn(keybd,&cn);
|
||||
xkbi->shiftKeyCount= 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ignoreKeyEvent)
|
||||
XkbProcessKeyboardEvent(xE,keybd,count);
|
||||
return ignoreKeyEvent;
|
||||
|
||||
} /* AccessXFilterReleaseEvent */
|
||||
|
||||
/************************************************************************/
|
||||
/* */
|
||||
/* ProcessPointerEvent */
|
||||
/* */
|
||||
/* This routine merely sets the shiftKeyCount and clears the keyboard */
|
||||
/* response group timer (if necessary) on a mouse event. This is so */
|
||||
/* multiple shifts with just the mouse and shift-drags with the mouse */
|
||||
/* don't accidentally turn on StickyKeys or the Keyboard Response Group.*/
|
||||
/* */
|
||||
/************************************************************************/
|
||||
void
|
||||
ProcessPointerEvent( register xEvent * xE,
|
||||
register DeviceIntPtr mouse,
|
||||
int count)
|
||||
{
|
||||
DeviceIntPtr dev = (DeviceIntPtr)LookupKeyboardDevice();
|
||||
XkbSrvInfoPtr xkbi = dev->key->xkbInfo;
|
||||
unsigned changed = 0;
|
||||
|
||||
xkbi->shiftKeyCount = 0;
|
||||
xkbi->lastPtrEventTime= xE->u.keyButtonPointer.time;
|
||||
|
||||
if (xE->u.u.type==ButtonPress) {
|
||||
changed |= XkbPointerButtonMask;
|
||||
}
|
||||
else if (xE->u.u.type==ButtonRelease) {
|
||||
xkbi->lockedPtrButtons&= ~(1<<(xE->u.u.detail&0x7));
|
||||
changed |= XkbPointerButtonMask;
|
||||
}
|
||||
CoreProcessPointerEvent(xE,mouse,count);
|
||||
|
||||
xkbi->state.ptr_buttons = mouse->button->state;
|
||||
|
||||
/* clear any latched modifiers */
|
||||
if ( xkbi->state.latched_mods && (xE->u.u.type==ButtonRelease) ) {
|
||||
unsigned changed_leds;
|
||||
XkbStateRec oldState;
|
||||
XkbSrvLedInfoPtr sli;
|
||||
|
||||
sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,0);
|
||||
oldState= xkbi->state;
|
||||
XkbLatchModifiers(dev,0xFF,0x00);
|
||||
|
||||
XkbComputeDerivedState(xkbi);
|
||||
changed |= XkbStateChangedFlags(&oldState,&xkbi->state);
|
||||
if (changed&sli->usedComponents) {
|
||||
changed_leds= XkbIndicatorsToUpdate(dev,changed,False);
|
||||
if (changed_leds) {
|
||||
XkbEventCauseRec cause;
|
||||
XkbSetCauseKey(&cause,(xE->u.u.detail&0x7),xE->u.u.type);
|
||||
XkbUpdateIndicators(dev,changed_leds,True,NULL,&cause);
|
||||
}
|
||||
}
|
||||
dev->key->state= XkbStateFieldFromRec(&xkbi->state);
|
||||
}
|
||||
|
||||
if (((xkbi->flags&_XkbStateNotifyInProgress)==0)&&(changed!=0)) {
|
||||
xkbStateNotify sn;
|
||||
sn.keycode= xE->u.u.detail;
|
||||
sn.eventType= xE->u.u.type;
|
||||
sn.requestMajor = sn.requestMinor = 0;
|
||||
sn.changed= changed;
|
||||
XkbSendStateNotify(dev,&sn);
|
||||
}
|
||||
|
||||
} /* ProcessPointerEvent */
|
||||
|
||||
|
||||
|
||||
|
||||
1437
nx-X11/programs/Xserver/xkb/xkbActions.c
Normal file
1437
nx-X11/programs/Xserver/xkb/xkbActions.c
Normal file
File diff suppressed because it is too large
Load Diff
480
nx-X11/programs/Xserver/xkb/xkbDflts.h
Normal file
480
nx-X11/programs/Xserver/xkb/xkbDflts.h
Normal file
@@ -0,0 +1,480 @@
|
||||
/* This file generated automatically by xkbcomp */
|
||||
/* DO NOT EDIT */
|
||||
#ifdef HAVE_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#ifndef DEFAULT_H
|
||||
#define DEFAULT_H 1
|
||||
|
||||
#define GET_ATOM(d,s) MakeAtom(s,strlen(s),1)
|
||||
#define DPYTYPE char *
|
||||
#define NUM_KEYS 1
|
||||
|
||||
#define vmod_NumLock 0
|
||||
#define vmod_Alt 1
|
||||
#define vmod_LevelThree 2
|
||||
#define vmod_AltGr 3
|
||||
#define vmod_ScrollLock 4
|
||||
|
||||
#define vmod_NumLockMask (1<<0)
|
||||
#define vmod_AltMask (1<<1)
|
||||
#define vmod_LevelThreeMask (1<<2)
|
||||
#define vmod_AltGrMask (1<<3)
|
||||
#define vmod_ScrollLockMask (1<<4)
|
||||
|
||||
/* types name is "default" */
|
||||
static Atom lnames_ONE_LEVEL[1];
|
||||
|
||||
static XkbKTMapEntryRec map_TWO_LEVEL[1]= {
|
||||
{ 1, 1, { ShiftMask, ShiftMask, 0 } }
|
||||
};
|
||||
static Atom lnames_TWO_LEVEL[2];
|
||||
|
||||
static XkbKTMapEntryRec map_ALPHABETIC[2]= {
|
||||
{ 1, 1, { ShiftMask, ShiftMask, 0 } },
|
||||
{ 1, 0, { LockMask, LockMask, 0 } }
|
||||
};
|
||||
static XkbModsRec preserve_ALPHABETIC[2]= {
|
||||
{ 0, 0, 0 },
|
||||
{ LockMask, LockMask, 0 }
|
||||
};
|
||||
static Atom lnames_ALPHABETIC[2];
|
||||
|
||||
static XkbKTMapEntryRec map_KEYPAD[2]= {
|
||||
{ 1, 1, { ShiftMask, ShiftMask, 0 } },
|
||||
{ 0, 1, { 0, 0, vmod_NumLockMask } }
|
||||
};
|
||||
static Atom lnames_KEYPAD[2];
|
||||
|
||||
static XkbKTMapEntryRec map_PC_BREAK[1]= {
|
||||
{ 1, 1, { ControlMask, ControlMask, 0 } }
|
||||
};
|
||||
static Atom lnames_PC_BREAK[2];
|
||||
|
||||
static XkbKTMapEntryRec map_PC_SYSRQ[1]= {
|
||||
{ 0, 1, { 0, 0, vmod_AltMask } }
|
||||
};
|
||||
static Atom lnames_PC_SYSRQ[2];
|
||||
|
||||
static XkbKTMapEntryRec map_CTRL_ALT[1]= {
|
||||
{ 0, 1, { ControlMask, ControlMask, vmod_AltMask } }
|
||||
};
|
||||
static Atom lnames_CTRL_ALT[2];
|
||||
|
||||
static XkbKTMapEntryRec map_THREE_LEVEL[3]= {
|
||||
{ 1, 1, { ShiftMask, ShiftMask, 0 } },
|
||||
{ 0, 2, { 0, 0, vmod_LevelThreeMask } },
|
||||
{ 0, 2, { ShiftMask, ShiftMask, vmod_LevelThreeMask } }
|
||||
};
|
||||
static Atom lnames_THREE_LEVEL[3];
|
||||
|
||||
static XkbKTMapEntryRec map_SHIFT_ALT[1]= {
|
||||
{ 0, 1, { ShiftMask, ShiftMask, vmod_AltMask } }
|
||||
};
|
||||
static Atom lnames_SHIFT_ALT[2];
|
||||
|
||||
static XkbKeyTypeRec dflt_types[]= {
|
||||
{
|
||||
{ 0, 0, 0 },
|
||||
1,
|
||||
0, NULL, NULL,
|
||||
None, lnames_ONE_LEVEL
|
||||
},
|
||||
{
|
||||
{ ShiftMask, ShiftMask, 0 },
|
||||
2,
|
||||
1, map_TWO_LEVEL, NULL,
|
||||
None, lnames_TWO_LEVEL
|
||||
},
|
||||
{
|
||||
{ ShiftMask|LockMask, ShiftMask|LockMask, 0 },
|
||||
2,
|
||||
2, map_ALPHABETIC, preserve_ALPHABETIC,
|
||||
None, lnames_ALPHABETIC
|
||||
},
|
||||
{
|
||||
{ ShiftMask, ShiftMask, vmod_NumLockMask },
|
||||
2,
|
||||
2, map_KEYPAD, NULL,
|
||||
None, lnames_KEYPAD
|
||||
},
|
||||
{
|
||||
{ ControlMask, ControlMask, 0 },
|
||||
2,
|
||||
1, map_PC_BREAK, NULL,
|
||||
None, lnames_PC_BREAK
|
||||
},
|
||||
{
|
||||
{ 0, 0, vmod_AltMask },
|
||||
2,
|
||||
1, map_PC_SYSRQ, NULL,
|
||||
None, lnames_PC_SYSRQ
|
||||
},
|
||||
{
|
||||
{ ControlMask, ControlMask, vmod_AltMask },
|
||||
2,
|
||||
1, map_CTRL_ALT, NULL,
|
||||
None, lnames_CTRL_ALT
|
||||
},
|
||||
{
|
||||
{ ShiftMask, ShiftMask, vmod_LevelThreeMask },
|
||||
3,
|
||||
3, map_THREE_LEVEL, NULL,
|
||||
None, lnames_THREE_LEVEL
|
||||
},
|
||||
{
|
||||
{ ShiftMask, ShiftMask, vmod_AltMask },
|
||||
2,
|
||||
1, map_SHIFT_ALT, NULL,
|
||||
None, lnames_SHIFT_ALT
|
||||
}
|
||||
};
|
||||
#define num_dflt_types (sizeof(dflt_types)/sizeof(XkbKeyTypeRec))
|
||||
|
||||
|
||||
static void
|
||||
initTypeNames(DPYTYPE dpy)
|
||||
{
|
||||
dflt_types[0].name= GET_ATOM(dpy,"ONE_LEVEL");
|
||||
lnames_ONE_LEVEL[0]= GET_ATOM(dpy,"Any");
|
||||
dflt_types[1].name= GET_ATOM(dpy,"TWO_LEVEL");
|
||||
lnames_TWO_LEVEL[0]= GET_ATOM(dpy,"Base");
|
||||
lnames_TWO_LEVEL[1]= GET_ATOM(dpy,"Shift");
|
||||
dflt_types[2].name= GET_ATOM(dpy,"ALPHABETIC");
|
||||
lnames_ALPHABETIC[0]= GET_ATOM(dpy,"Base");
|
||||
lnames_ALPHABETIC[1]= GET_ATOM(dpy,"Caps");
|
||||
dflt_types[3].name= GET_ATOM(dpy,"KEYPAD");
|
||||
lnames_KEYPAD[0]= GET_ATOM(dpy,"Base");
|
||||
lnames_KEYPAD[1]= GET_ATOM(dpy,"Number");
|
||||
dflt_types[4].name= GET_ATOM(dpy,"PC_BREAK");
|
||||
lnames_PC_BREAK[0]= GET_ATOM(dpy,"Base");
|
||||
lnames_PC_BREAK[1]= GET_ATOM(dpy,"Control");
|
||||
dflt_types[5].name= GET_ATOM(dpy,"PC_SYSRQ");
|
||||
lnames_PC_SYSRQ[0]= GET_ATOM(dpy,"Base");
|
||||
lnames_PC_SYSRQ[1]= GET_ATOM(dpy,"Alt");
|
||||
dflt_types[6].name= GET_ATOM(dpy,"CTRL+ALT");
|
||||
lnames_CTRL_ALT[0]= GET_ATOM(dpy,"Base");
|
||||
lnames_CTRL_ALT[1]= GET_ATOM(dpy,"Ctrl+Alt");
|
||||
dflt_types[7].name= GET_ATOM(dpy,"THREE_LEVEL");
|
||||
lnames_THREE_LEVEL[0]= GET_ATOM(dpy,"Base");
|
||||
lnames_THREE_LEVEL[1]= GET_ATOM(dpy,"Shift");
|
||||
lnames_THREE_LEVEL[2]= GET_ATOM(dpy,"Level3");
|
||||
dflt_types[8].name= GET_ATOM(dpy,"SHIFT+ALT");
|
||||
lnames_SHIFT_ALT[0]= GET_ATOM(dpy,"Base");
|
||||
lnames_SHIFT_ALT[1]= GET_ATOM(dpy,"Shift+Alt");
|
||||
}
|
||||
/* compat name is "default" */
|
||||
static XkbSymInterpretRec dfltSI[69]= {
|
||||
{ XK_ISO_Level2_Latch, 0x0000,
|
||||
XkbSI_LevelOneOnly|XkbSI_Exactly, ShiftMask,
|
||||
255,
|
||||
{ XkbSA_LatchMods, { 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00 } } },
|
||||
{ XK_Eisu_Shift, 0x0000,
|
||||
XkbSI_Exactly, LockMask,
|
||||
255,
|
||||
{ XkbSA_NoAction, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
|
||||
{ XK_Eisu_toggle, 0x0000,
|
||||
XkbSI_Exactly, LockMask,
|
||||
255,
|
||||
{ XkbSA_NoAction, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
|
||||
{ XK_Kana_Shift, 0x0000,
|
||||
XkbSI_Exactly, LockMask,
|
||||
255,
|
||||
{ XkbSA_NoAction, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
|
||||
{ XK_Kana_Lock, 0x0000,
|
||||
XkbSI_Exactly, LockMask,
|
||||
255,
|
||||
{ XkbSA_NoAction, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
|
||||
{ XK_Shift_Lock, 0x0000,
|
||||
XkbSI_AnyOf, ShiftMask|LockMask,
|
||||
255,
|
||||
{ XkbSA_LockMods, { 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00 } } },
|
||||
{ XK_Num_Lock, 0x0000,
|
||||
XkbSI_AnyOf, 0xff,
|
||||
0,
|
||||
{ XkbSA_LockMods, { 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00 } } },
|
||||
{ XK_Alt_L, 0x0000,
|
||||
XkbSI_AnyOf, 0xff,
|
||||
1,
|
||||
{ XkbSA_SetMods, { 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
|
||||
{ XK_Alt_R, 0x0000,
|
||||
XkbSI_AnyOf, 0xff,
|
||||
1,
|
||||
{ XkbSA_SetMods, { 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
|
||||
{ XK_Scroll_Lock, 0x0000,
|
||||
XkbSI_AnyOf, 0xff,
|
||||
4,
|
||||
{ XkbSA_LockMods, { 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
|
||||
{ XK_ISO_Lock, 0x0000,
|
||||
XkbSI_AnyOf, 0xff,
|
||||
255,
|
||||
{ XkbSA_ISOLock, { 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
|
||||
{ XK_ISO_Level3_Shift, 0x0000,
|
||||
XkbSI_LevelOneOnly|XkbSI_AnyOf, 0xff,
|
||||
2,
|
||||
{ XkbSA_SetMods, { 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00 } } },
|
||||
{ XK_ISO_Level3_Latch, 0x0000,
|
||||
XkbSI_LevelOneOnly|XkbSI_AnyOf, 0xff,
|
||||
2,
|
||||
{ XkbSA_LatchMods, { 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00 } } },
|
||||
{ XK_Mode_switch, 0x0000,
|
||||
XkbSI_LevelOneOnly|XkbSI_AnyOfOrNone, 0xff,
|
||||
3,
|
||||
{ XkbSA_SetGroup, { 0x05, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
|
||||
{ XK_KP_1, 0x0001,
|
||||
XkbSI_AnyOfOrNone, 0xff,
|
||||
255,
|
||||
{ XkbSA_MovePtr, { 0x00, 0xff, 0xff, 0x00, 0x01, 0x00, 0x00 } } },
|
||||
{ XK_KP_End, 0x0001,
|
||||
XkbSI_AnyOfOrNone, 0xff,
|
||||
255,
|
||||
{ XkbSA_MovePtr, { 0x00, 0xff, 0xff, 0x00, 0x01, 0x00, 0x00 } } },
|
||||
{ XK_KP_2, 0x0001,
|
||||
XkbSI_AnyOfOrNone, 0xff,
|
||||
255,
|
||||
{ XkbSA_MovePtr, { 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00 } } },
|
||||
{ XK_KP_Down, 0x0001,
|
||||
XkbSI_AnyOfOrNone, 0xff,
|
||||
255,
|
||||
{ XkbSA_MovePtr, { 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00 } } },
|
||||
{ XK_KP_3, 0x0001,
|
||||
XkbSI_AnyOfOrNone, 0xff,
|
||||
255,
|
||||
{ XkbSA_MovePtr, { 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00 } } },
|
||||
{ XK_KP_Next, 0x0001,
|
||||
XkbSI_AnyOfOrNone, 0xff,
|
||||
255,
|
||||
{ XkbSA_MovePtr, { 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00 } } },
|
||||
{ XK_KP_4, 0x0001,
|
||||
XkbSI_AnyOfOrNone, 0xff,
|
||||
255,
|
||||
{ XkbSA_MovePtr, { 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 } } },
|
||||
{ XK_KP_Left, 0x0001,
|
||||
XkbSI_AnyOfOrNone, 0xff,
|
||||
255,
|
||||
{ XkbSA_MovePtr, { 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 } } },
|
||||
{ XK_KP_6, 0x0001,
|
||||
XkbSI_AnyOfOrNone, 0xff,
|
||||
255,
|
||||
{ XkbSA_MovePtr, { 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 } } },
|
||||
{ XK_KP_Right, 0x0001,
|
||||
XkbSI_AnyOfOrNone, 0xff,
|
||||
255,
|
||||
{ XkbSA_MovePtr, { 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 } } },
|
||||
{ XK_KP_7, 0x0001,
|
||||
XkbSI_AnyOfOrNone, 0xff,
|
||||
255,
|
||||
{ XkbSA_MovePtr, { 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00 } } },
|
||||
{ XK_KP_Home, 0x0001,
|
||||
XkbSI_AnyOfOrNone, 0xff,
|
||||
255,
|
||||
{ XkbSA_MovePtr, { 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00 } } },
|
||||
{ XK_KP_8, 0x0001,
|
||||
XkbSI_AnyOfOrNone, 0xff,
|
||||
255,
|
||||
{ XkbSA_MovePtr, { 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00 } } },
|
||||
{ XK_KP_Up, 0x0001,
|
||||
XkbSI_AnyOfOrNone, 0xff,
|
||||
255,
|
||||
{ XkbSA_MovePtr, { 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00 } } },
|
||||
{ XK_KP_9, 0x0001,
|
||||
XkbSI_AnyOfOrNone, 0xff,
|
||||
255,
|
||||
{ XkbSA_MovePtr, { 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00 } } },
|
||||
{ XK_KP_Prior, 0x0001,
|
||||
XkbSI_AnyOfOrNone, 0xff,
|
||||
255,
|
||||
{ XkbSA_MovePtr, { 0x00, 0x00, 0x01, 0xff, 0xff, 0x00, 0x00 } } },
|
||||
{ XK_KP_5, 0x0001,
|
||||
XkbSI_AnyOfOrNone, 0xff,
|
||||
255,
|
||||
{ XkbSA_PtrBtn, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
|
||||
{ XK_KP_Begin, 0x0001,
|
||||
XkbSI_AnyOfOrNone, 0xff,
|
||||
255,
|
||||
{ XkbSA_PtrBtn, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
|
||||
{ XK_KP_F1, 0x0001,
|
||||
XkbSI_AnyOfOrNone, 0xff,
|
||||
255,
|
||||
{ XkbSA_SetPtrDflt, { 0x04, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00 } } },
|
||||
{ XK_KP_Divide, 0x0001,
|
||||
XkbSI_AnyOfOrNone, 0xff,
|
||||
255,
|
||||
{ XkbSA_SetPtrDflt, { 0x04, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00 } } },
|
||||
{ XK_KP_F2, 0x0001,
|
||||
XkbSI_AnyOfOrNone, 0xff,
|
||||
255,
|
||||
{ XkbSA_SetPtrDflt, { 0x04, 0x01, 0x02, 0x00, 0x00, 0x00, 0x00 } } },
|
||||
{ XK_KP_Multiply, 0x0001,
|
||||
XkbSI_AnyOfOrNone, 0xff,
|
||||
255,
|
||||
{ XkbSA_SetPtrDflt, { 0x04, 0x01, 0x02, 0x00, 0x00, 0x00, 0x00 } } },
|
||||
{ XK_KP_F3, 0x0001,
|
||||
XkbSI_AnyOfOrNone, 0xff,
|
||||
255,
|
||||
{ XkbSA_SetPtrDflt, { 0x04, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00 } } },
|
||||
{ XK_KP_Subtract, 0x0001,
|
||||
XkbSI_AnyOfOrNone, 0xff,
|
||||
255,
|
||||
{ XkbSA_SetPtrDflt, { 0x04, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00 } } },
|
||||
{ XK_KP_Separator, 0x0001,
|
||||
XkbSI_AnyOfOrNone, 0xff,
|
||||
255,
|
||||
{ XkbSA_PtrBtn, { 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
|
||||
{ XK_KP_Add, 0x0001,
|
||||
XkbSI_AnyOfOrNone, 0xff,
|
||||
255,
|
||||
{ XkbSA_PtrBtn, { 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
|
||||
{ XK_KP_0, 0x0001,
|
||||
XkbSI_AnyOfOrNone, 0xff,
|
||||
255,
|
||||
{ XkbSA_LockPtrBtn, { 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
|
||||
{ XK_KP_Insert, 0x0001,
|
||||
XkbSI_AnyOfOrNone, 0xff,
|
||||
255,
|
||||
{ XkbSA_LockPtrBtn, { 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
|
||||
{ XK_KP_Decimal, 0x0001,
|
||||
XkbSI_AnyOfOrNone, 0xff,
|
||||
255,
|
||||
{ XkbSA_LockPtrBtn, { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
|
||||
{ XK_KP_Delete, 0x0001,
|
||||
XkbSI_AnyOfOrNone, 0xff,
|
||||
255,
|
||||
{ XkbSA_LockPtrBtn, { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
|
||||
{ XK_Pointer_Button_Dflt, 0x0000,
|
||||
XkbSI_AnyOfOrNone, 0xff,
|
||||
255,
|
||||
{ XkbSA_PtrBtn, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
|
||||
{ XK_Pointer_Button1, 0x0000,
|
||||
XkbSI_AnyOfOrNone, 0xff,
|
||||
255,
|
||||
{ XkbSA_PtrBtn, { 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 } } },
|
||||
{ XK_Pointer_Button2, 0x0000,
|
||||
XkbSI_AnyOfOrNone, 0xff,
|
||||
255,
|
||||
{ XkbSA_PtrBtn, { 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00 } } },
|
||||
{ XK_Pointer_Button3, 0x0000,
|
||||
XkbSI_AnyOfOrNone, 0xff,
|
||||
255,
|
||||
{ XkbSA_PtrBtn, { 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00 } } },
|
||||
{ XK_Pointer_DblClick_Dflt, 0x0000,
|
||||
XkbSI_AnyOfOrNone, 0xff,
|
||||
255,
|
||||
{ XkbSA_PtrBtn, { 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
|
||||
{ XK_Pointer_DblClick1, 0x0000,
|
||||
XkbSI_AnyOfOrNone, 0xff,
|
||||
255,
|
||||
{ XkbSA_PtrBtn, { 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00 } } },
|
||||
{ XK_Pointer_DblClick2, 0x0000,
|
||||
XkbSI_AnyOfOrNone, 0xff,
|
||||
255,
|
||||
{ XkbSA_PtrBtn, { 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00 } } },
|
||||
{ XK_Pointer_DblClick3, 0x0000,
|
||||
XkbSI_AnyOfOrNone, 0xff,
|
||||
255,
|
||||
{ XkbSA_PtrBtn, { 0x00, 0x02, 0x03, 0x00, 0x00, 0x00, 0x00 } } },
|
||||
{ XK_Pointer_Drag_Dflt, 0x0000,
|
||||
XkbSI_AnyOfOrNone, 0xff,
|
||||
255,
|
||||
{ XkbSA_LockPtrBtn, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
|
||||
{ XK_Pointer_Drag1, 0x0000,
|
||||
XkbSI_AnyOfOrNone, 0xff,
|
||||
255,
|
||||
{ XkbSA_LockPtrBtn, { 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 } } },
|
||||
{ XK_Pointer_Drag2, 0x0000,
|
||||
XkbSI_AnyOfOrNone, 0xff,
|
||||
255,
|
||||
{ XkbSA_LockPtrBtn, { 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00 } } },
|
||||
{ XK_Pointer_Drag3, 0x0000,
|
||||
XkbSI_AnyOfOrNone, 0xff,
|
||||
255,
|
||||
{ XkbSA_LockPtrBtn, { 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00 } } },
|
||||
{ XK_Pointer_EnableKeys, 0x0000,
|
||||
XkbSI_AnyOfOrNone, 0xff,
|
||||
255,
|
||||
{ XkbSA_LockControls, { 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00 } } },
|
||||
{ XK_Pointer_Accelerate, 0x0000,
|
||||
XkbSI_AnyOfOrNone, 0xff,
|
||||
255,
|
||||
{ XkbSA_LockControls, { 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00 } } },
|
||||
{ XK_Pointer_DfltBtnNext, 0x0000,
|
||||
XkbSI_AnyOfOrNone, 0xff,
|
||||
255,
|
||||
{ XkbSA_SetPtrDflt, { 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00 } } },
|
||||
{ XK_Pointer_DfltBtnPrev, 0x0000,
|
||||
XkbSI_AnyOfOrNone, 0xff,
|
||||
255,
|
||||
{ XkbSA_SetPtrDflt, { 0x00, 0x01, 0xff, 0x00, 0x00, 0x00, 0x00 } } },
|
||||
{ XK_AccessX_Enable, 0x0000,
|
||||
XkbSI_AnyOfOrNone, 0xff,
|
||||
255,
|
||||
{ XkbSA_LockControls, { 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00 } } },
|
||||
|
||||
#ifndef NXAGENT_SERVER
|
||||
|
||||
/*
|
||||
* Make sure that the server can't be killed
|
||||
* by pressing this key-sequence.
|
||||
*/
|
||||
|
||||
{ XK_Terminate_Server, 0x0000,
|
||||
XkbSI_AnyOfOrNone, 0xff,
|
||||
255,
|
||||
{ XkbSA_Terminate, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
|
||||
|
||||
#endif
|
||||
|
||||
{ XK_ISO_Group_Latch, 0x0000,
|
||||
XkbSI_LevelOneOnly|XkbSI_AnyOfOrNone, 0xff,
|
||||
3,
|
||||
{ XkbSA_LatchGroup, { 0x04, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
|
||||
{ XK_ISO_Next_Group, 0x0000,
|
||||
XkbSI_LevelOneOnly|XkbSI_AnyOfOrNone, 0xff,
|
||||
3,
|
||||
{ XkbSA_LockGroup, { 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
|
||||
{ XK_ISO_Prev_Group, 0x0000,
|
||||
XkbSI_LevelOneOnly|XkbSI_AnyOfOrNone, 0xff,
|
||||
3,
|
||||
{ XkbSA_LockGroup, { 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
|
||||
{ XK_ISO_First_Group, 0x0000,
|
||||
XkbSI_AnyOfOrNone, 0xff,
|
||||
255,
|
||||
{ XkbSA_LockGroup, { 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
|
||||
{ XK_ISO_Last_Group, 0x0000,
|
||||
XkbSI_AnyOfOrNone, 0xff,
|
||||
255,
|
||||
{ XkbSA_LockGroup, { 0x04, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
|
||||
{ NoSymbol, 0x0000,
|
||||
XkbSI_Exactly, LockMask,
|
||||
255,
|
||||
{ XkbSA_LockMods, { 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00 } } },
|
||||
{ NoSymbol, 0x0000,
|
||||
XkbSI_AnyOf, 0xff,
|
||||
255,
|
||||
{ XkbSA_SetMods, { 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } }
|
||||
};
|
||||
#define num_dfltSI (sizeof(dfltSI)/sizeof(XkbSymInterpretRec))
|
||||
|
||||
static XkbCompatMapRec compatMap= {
|
||||
dfltSI,
|
||||
{ /* group compatibility */
|
||||
{ 0, 0, 0 },
|
||||
{ 0, 0, vmod_AltGrMask },
|
||||
{ 0, 0, vmod_AltGrMask },
|
||||
{ 0, 0, vmod_AltGrMask }
|
||||
},
|
||||
num_dfltSI, num_dfltSI
|
||||
};
|
||||
|
||||
static void
|
||||
initIndicatorNames(DPYTYPE dpy,XkbDescPtr xkb)
|
||||
{
|
||||
xkb->names->indicators[ 0]= GET_ATOM(dpy,"Caps Lock");
|
||||
xkb->names->indicators[ 1]= GET_ATOM(dpy,"Num Lock");
|
||||
xkb->names->indicators[ 2]= GET_ATOM(dpy,"Shift Lock");
|
||||
xkb->names->indicators[ 3]= GET_ATOM(dpy,"Mouse Keys");
|
||||
xkb->names->indicators[ 4]= GET_ATOM(dpy,"Scroll Lock");
|
||||
xkb->names->indicators[ 5]= GET_ATOM(dpy,"Group 2");
|
||||
}
|
||||
#endif /* DEFAULT_H */
|
||||
1001
nx-X11/programs/Xserver/xkb/xkbEvents.c
Normal file
1001
nx-X11/programs/Xserver/xkb/xkbEvents.c
Normal file
File diff suppressed because it is too large
Load Diff
919
nx-X11/programs/Xserver/xkb/xkbInit.c
Normal file
919
nx-X11/programs/Xserver/xkb/xkbInit.c
Normal file
@@ -0,0 +1,919 @@
|
||||
/************************************************************
|
||||
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_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_XKB_CONFIG_H
|
||||
#include <xkb-config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <unistd.h>
|
||||
#include <math.h>
|
||||
#include <nx-X11/X.h>
|
||||
#include <nx-X11/Xproto.h>
|
||||
#include <nx-X11/keysym.h>
|
||||
#include <nx-X11/Xatom.h>
|
||||
#include "misc.h"
|
||||
#include "inputstr.h"
|
||||
#include "opaque.h"
|
||||
#include "property.h"
|
||||
#include "scrnintstr.h"
|
||||
#include <xkbsrv.h>
|
||||
#include "xkbgeom.h"
|
||||
#include <nx-X11/extensions/XKMformat.h>
|
||||
#include "xkbfile.h"
|
||||
#include "xkb.h"
|
||||
|
||||
#define CREATE_ATOM(s) MakeAtom(s,sizeof(s)-1,1)
|
||||
|
||||
#ifdef sun
|
||||
#define LED_NUM 1
|
||||
#define LED_SCROLL 2
|
||||
#define LED_COMPOSE 3
|
||||
#define LED_CAPS 4
|
||||
#define PHYS_LEDS 0x0f
|
||||
#else
|
||||
#define LED_CAPS 1
|
||||
#define LED_NUM 2
|
||||
#define LED_SCROLL 3
|
||||
#define PHYS_LEDS 0x07
|
||||
#endif
|
||||
|
||||
#define MAX_TOC 16
|
||||
typedef struct _SrvXkmInfo {
|
||||
DeviceIntPtr dev;
|
||||
FILE * file;
|
||||
XkbFileInfo xkbinfo;
|
||||
} SrvXkmInfo;
|
||||
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
#ifndef XKB_BASE_DIRECTORY
|
||||
#define XKB_BASE_DIRECTORY "/usr/lib/X11/xkb"
|
||||
#endif
|
||||
#ifndef XKB_BIN_DIRECTORY
|
||||
#define XKB_BIN_DIRECTORY XKB_BASE_DIRECTORY
|
||||
#endif
|
||||
#ifndef XKB_DFLT_RULES_FILE
|
||||
#define XKB_DFLT_RULES_FILE "base"
|
||||
#endif
|
||||
#ifndef XKB_DFLT_KB_LAYOUT
|
||||
#define XKB_DFLT_KB_LAYOUT "us"
|
||||
#endif
|
||||
#ifndef XKB_DFLT_KB_MODEL
|
||||
#define XKB_DFLT_KB_MODEL "dflt"
|
||||
#endif
|
||||
#ifndef XKB_DFLT_KB_VARIANT
|
||||
#define XKB_DFLT_KB_VARIANT NULL
|
||||
#endif
|
||||
#ifndef XKB_DFLT_KB_OPTIONS
|
||||
#define XKB_DFLT_KB_OPTIONS NULL
|
||||
#endif
|
||||
#ifndef XKB_DFLT_DISABLED
|
||||
#define XKB_DFLT_DISABLED True
|
||||
#endif
|
||||
#ifndef XKB_DFLT_RULES_PROP
|
||||
#define XKB_DFLT_RULES_PROP True
|
||||
#endif
|
||||
|
||||
char * XkbBaseDirectory= XKB_BASE_DIRECTORY;
|
||||
char * XkbBinDirectory= XKB_BIN_DIRECTORY;
|
||||
|
||||
static int XkbWantAccessX= 0;
|
||||
static XkbFileInfo * _XkbInitFileInfo= NULL;
|
||||
|
||||
static Bool rulesDefined= False;
|
||||
static char * XkbRulesFile= NULL;
|
||||
static char * XkbModelDflt= NULL;
|
||||
static char * XkbLayoutDflt= NULL;
|
||||
static char * XkbVariantDflt= NULL;
|
||||
static char * XkbOptionsDflt= NULL;
|
||||
|
||||
static char * XkbModelUsed= NULL;
|
||||
static char * XkbLayoutUsed= NULL;
|
||||
static char * XkbVariantUsed= NULL;
|
||||
static char * XkbOptionsUsed= NULL;
|
||||
|
||||
Bool noXkbExtension= XKB_DFLT_DISABLED;
|
||||
static Bool XkbWantRulesProp= XKB_DFLT_RULES_PROP;
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
static char *
|
||||
XkbGetRulesDflts(XkbRF_VarDefsPtr defs)
|
||||
{
|
||||
if (XkbModelDflt) defs->model= XkbModelDflt;
|
||||
else defs->model= XKB_DFLT_KB_MODEL;
|
||||
if (XkbLayoutDflt) defs->layout= XkbLayoutDflt;
|
||||
else defs->layout= XKB_DFLT_KB_LAYOUT;
|
||||
if (XkbVariantDflt) defs->variant= XkbVariantDflt;
|
||||
else defs->variant= XKB_DFLT_KB_VARIANT;
|
||||
if (XkbOptionsDflt) defs->options= XkbOptionsDflt;
|
||||
else defs->options= XKB_DFLT_KB_OPTIONS;
|
||||
return (rulesDefined?XkbRulesFile:XKB_DFLT_RULES_FILE);
|
||||
}
|
||||
|
||||
static Bool
|
||||
XkbWriteRulesProp(ClientPtr client, void * closure)
|
||||
{
|
||||
int len,out;
|
||||
Atom name;
|
||||
char * pval;
|
||||
|
||||
if (rulesDefined && (!XkbRulesFile))
|
||||
return False;
|
||||
len= (XkbRulesFile?strlen(XkbRulesFile):strlen(XKB_DFLT_RULES_FILE));
|
||||
len+= (XkbModelUsed?strlen(XkbModelUsed):0);
|
||||
len+= (XkbLayoutUsed?strlen(XkbLayoutUsed):0);
|
||||
len+= (XkbVariantUsed?strlen(XkbVariantUsed):0);
|
||||
len+= (XkbOptionsUsed?strlen(XkbOptionsUsed):0);
|
||||
if (len<1)
|
||||
return True;
|
||||
|
||||
len+= 5; /* trailing NULs */
|
||||
|
||||
name= MakeAtom(_XKB_RF_NAMES_PROP_ATOM,strlen(_XKB_RF_NAMES_PROP_ATOM),1);
|
||||
if (name==None) {
|
||||
ErrorF("Atom error: %s not created\n",_XKB_RF_NAMES_PROP_ATOM);
|
||||
return True;
|
||||
}
|
||||
pval= (char*) malloc(len);
|
||||
if (!pval) {
|
||||
ErrorF("Allocation error: %s proprerty not created\n",
|
||||
_XKB_RF_NAMES_PROP_ATOM);
|
||||
return True;
|
||||
}
|
||||
out= 0;
|
||||
if (XkbRulesFile) {
|
||||
strcpy(&pval[out],XkbRulesFile);
|
||||
out+= strlen(XkbRulesFile);
|
||||
} else {
|
||||
strcpy(&pval[out],XKB_DFLT_RULES_FILE);
|
||||
out+= strlen(XKB_DFLT_RULES_FILE);
|
||||
}
|
||||
pval[out++]= '\0';
|
||||
if (XkbModelUsed) {
|
||||
strcpy(&pval[out],XkbModelUsed);
|
||||
out+= strlen(XkbModelUsed);
|
||||
}
|
||||
pval[out++]= '\0';
|
||||
if (XkbLayoutUsed) {
|
||||
strcpy(&pval[out],XkbLayoutUsed);
|
||||
out+= strlen(XkbLayoutUsed);
|
||||
}
|
||||
pval[out++]= '\0';
|
||||
if (XkbVariantUsed) {
|
||||
strcpy(&pval[out],XkbVariantUsed);
|
||||
out+= strlen(XkbVariantUsed);
|
||||
}
|
||||
pval[out++]= '\0';
|
||||
if (XkbOptionsUsed) {
|
||||
strcpy(&pval[out],XkbOptionsUsed);
|
||||
out+= strlen(XkbOptionsUsed);
|
||||
}
|
||||
pval[out++]= '\0';
|
||||
if (out!=len) {
|
||||
ErrorF("Internal Error! bad size (%d!=%d) for _XKB_RULES_NAMES\n",
|
||||
out,len);
|
||||
}
|
||||
ChangeWindowProperty(screenInfo.screens[0]->root,name,XA_STRING,8,PropModeReplace,
|
||||
len,pval,True);
|
||||
free(pval);
|
||||
return True;
|
||||
}
|
||||
|
||||
static void
|
||||
XkbSetRulesUsed(XkbRF_VarDefsPtr defs)
|
||||
{
|
||||
if (XkbModelUsed)
|
||||
_XkbFree(XkbModelUsed);
|
||||
XkbModelUsed= (defs->model?Xstrdup(defs->model):NULL);
|
||||
if (XkbLayoutUsed)
|
||||
_XkbFree(XkbLayoutUsed);
|
||||
XkbLayoutUsed= (defs->layout?Xstrdup(defs->layout):NULL);
|
||||
if (XkbVariantUsed)
|
||||
_XkbFree(XkbVariantUsed);
|
||||
XkbVariantUsed= (defs->variant?Xstrdup(defs->variant):NULL);
|
||||
if (XkbOptionsUsed)
|
||||
_XkbFree(XkbOptionsUsed);
|
||||
XkbOptionsUsed= (defs->options?Xstrdup(defs->options):NULL);
|
||||
if (XkbWantRulesProp)
|
||||
QueueWorkProc(XkbWriteRulesProp,NULL,NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default RMLVO for the next device to be initialised.
|
||||
* If a parameter is NULL, the previous setting will be used. Use empty
|
||||
* strings if you want to delete a previous setting.
|
||||
*
|
||||
* If @rulesFile is NULL and no previous @rulesFile has been set, the
|
||||
* built-in default is chosen as default.
|
||||
*/
|
||||
|
||||
void
|
||||
XkbSetRulesDflts(char *rulesFile,char *model,char *layout,
|
||||
char *variant,char *options)
|
||||
{
|
||||
if (!rulesFile && !XkbRulesFile)
|
||||
{
|
||||
LogMessage(X_WARNING, "[xkb] No rule given, and no previous rule "
|
||||
"defined. Defaulting to '%s'.\n",
|
||||
XKB_DFLT_RULES_FILE);
|
||||
rulesFile = XKB_DFLT_RULES_FILE;
|
||||
}
|
||||
|
||||
if (rulesFile) {
|
||||
if (XkbRulesFile)
|
||||
_XkbFree(XkbRulesFile);
|
||||
XkbRulesFile= Xstrdup(rulesFile);
|
||||
rulesDefined= True;
|
||||
}
|
||||
|
||||
if (model) {
|
||||
if (XkbModelDflt)
|
||||
_XkbFree(XkbModelDflt);
|
||||
XkbModelDflt= Xstrdup(model);
|
||||
}
|
||||
if (layout) {
|
||||
if (XkbLayoutDflt)
|
||||
_XkbFree(XkbLayoutDflt);
|
||||
XkbLayoutDflt= Xstrdup(layout);
|
||||
}
|
||||
if (variant) {
|
||||
if (XkbVariantDflt)
|
||||
_XkbFree(XkbVariantDflt);
|
||||
XkbVariantDflt= Xstrdup(variant);
|
||||
}
|
||||
if (options) {
|
||||
if (XkbOptionsDflt)
|
||||
_XkbFree(XkbOptionsDflt);
|
||||
XkbOptionsDflt= Xstrdup(options);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
#include "xkbDflts.h"
|
||||
|
||||
static Bool
|
||||
XkbInitKeyTypes(XkbDescPtr xkb,SrvXkmInfo *file)
|
||||
{
|
||||
if (file->xkbinfo.defined&XkmTypesMask)
|
||||
return True;
|
||||
initTypeNames(NULL);
|
||||
if (XkbAllocClientMap(xkb,XkbKeyTypesMask,num_dflt_types)!=Success)
|
||||
return False;
|
||||
if (XkbCopyKeyTypes(dflt_types,xkb->map->types,num_dflt_types)!=
|
||||
Success) {
|
||||
return False;
|
||||
}
|
||||
xkb->map->size_types= xkb->map->num_types= num_dflt_types;
|
||||
return True;
|
||||
}
|
||||
|
||||
static void
|
||||
XkbInitRadioGroups(XkbSrvInfoPtr xkbi,SrvXkmInfo *file)
|
||||
{
|
||||
xkbi->nRadioGroups = 0;
|
||||
xkbi->radioGroups = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
static Status
|
||||
XkbInitCompatStructs(XkbDescPtr xkb,SrvXkmInfo *file)
|
||||
{
|
||||
register int i;
|
||||
XkbCompatMapPtr compat;
|
||||
|
||||
if (file->xkbinfo.defined&XkmCompatMapMask)
|
||||
return Success;
|
||||
if (XkbAllocCompatMap(xkb,XkbAllCompatMask,num_dfltSI)!=Success)
|
||||
return BadAlloc;
|
||||
compat = xkb->compat;
|
||||
if (compat->sym_interpret) {
|
||||
compat->num_si = num_dfltSI;
|
||||
memcpy((char *)compat->sym_interpret,(char *)dfltSI,sizeof(dfltSI));
|
||||
}
|
||||
for (i=0;i<XkbNumKbdGroups;i++) {
|
||||
compat->groups[i]= compatMap.groups[i];
|
||||
if (compat->groups[i].vmods!=0) {
|
||||
unsigned mask;
|
||||
mask= XkbMaskForVMask(xkb,compat->groups[i].vmods);
|
||||
compat->groups[i].mask= compat->groups[i].real_mods|mask;
|
||||
}
|
||||
else compat->groups[i].mask= compat->groups[i].real_mods;
|
||||
}
|
||||
return Success;
|
||||
}
|
||||
|
||||
static void
|
||||
XkbInitSemantics(XkbDescPtr xkb,SrvXkmInfo *file)
|
||||
{
|
||||
XkbInitKeyTypes(xkb,file);
|
||||
XkbInitCompatStructs(xkb,file);
|
||||
return;
|
||||
}
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
static Status
|
||||
XkbInitNames(XkbSrvInfoPtr xkbi,SrvXkmInfo *file)
|
||||
{
|
||||
XkbDescPtr xkb;
|
||||
XkbNamesPtr names;
|
||||
Status rtrn;
|
||||
Atom unknown;
|
||||
|
||||
xkb= xkbi->desc;
|
||||
if ((rtrn=XkbAllocNames(xkb,XkbAllNamesMask,0,0))!=Success)
|
||||
return rtrn;
|
||||
unknown= CREATE_ATOM("unknown");
|
||||
names = xkb->names;
|
||||
if (names->keycodes==None) names->keycodes= unknown;
|
||||
if (names->geometry==None) names->geometry= unknown;
|
||||
if (names->phys_symbols==None) names->phys_symbols= unknown;
|
||||
if (names->symbols==None) names->symbols= unknown;
|
||||
if (names->types==None) names->types= unknown;
|
||||
if (names->compat==None) names->compat= unknown;
|
||||
if ((file->xkbinfo.defined&XkmVirtualModsMask)==0) {
|
||||
if (names->vmods[vmod_NumLock]==None)
|
||||
names->vmods[vmod_NumLock]= CREATE_ATOM("NumLock");
|
||||
if (names->vmods[vmod_Alt]==None)
|
||||
names->vmods[vmod_Alt]= CREATE_ATOM("Alt");
|
||||
if (names->vmods[vmod_AltGr]==None)
|
||||
names->vmods[vmod_AltGr]= CREATE_ATOM("ModeSwitch");
|
||||
}
|
||||
|
||||
if (((file->xkbinfo.defined&XkmIndicatorsMask)==0)||
|
||||
((file->xkbinfo.defined&XkmGeometryMask)==0)) {
|
||||
initIndicatorNames(NULL,xkb);
|
||||
if (names->indicators[LED_CAPS-1]==None)
|
||||
names->indicators[LED_CAPS-1] = CREATE_ATOM("Caps Lock");
|
||||
if (names->indicators[LED_NUM-1]==None)
|
||||
names->indicators[LED_NUM-1] = CREATE_ATOM("Num Lock");
|
||||
if (names->indicators[LED_SCROLL-1]==None)
|
||||
names->indicators[LED_SCROLL-1] = CREATE_ATOM("Scroll Lock");
|
||||
#ifdef LED_COMPOSE
|
||||
if (names->indicators[LED_COMPOSE-1]==None)
|
||||
names->indicators[LED_COMPOSE-1] = CREATE_ATOM("Compose");
|
||||
#endif
|
||||
}
|
||||
if (xkb->geom!=NULL)
|
||||
names->geometry= xkb->geom->name;
|
||||
else names->geometry= unknown;
|
||||
return Success;
|
||||
}
|
||||
|
||||
static Status
|
||||
XkbInitIndicatorMap(XkbSrvInfoPtr xkbi,SrvXkmInfo *file)
|
||||
{
|
||||
XkbDescPtr xkb;
|
||||
XkbIndicatorPtr map;
|
||||
XkbSrvLedInfoPtr sli;
|
||||
|
||||
xkb= xkbi->desc;
|
||||
if (XkbAllocIndicatorMaps(xkb)!=Success)
|
||||
return BadAlloc;
|
||||
if ((file->xkbinfo.defined&XkmIndicatorsMask)==0) {
|
||||
map= xkb->indicators;
|
||||
map->phys_indicators = PHYS_LEDS;
|
||||
map->maps[LED_CAPS-1].flags= XkbIM_NoExplicit;
|
||||
map->maps[LED_CAPS-1].which_mods= XkbIM_UseLocked;
|
||||
map->maps[LED_CAPS-1].mods.mask= LockMask;
|
||||
map->maps[LED_CAPS-1].mods.real_mods= LockMask;
|
||||
|
||||
map->maps[LED_NUM-1].flags= XkbIM_NoExplicit;
|
||||
map->maps[LED_NUM-1].which_mods= XkbIM_UseLocked;
|
||||
map->maps[LED_NUM-1].mods.mask= 0;
|
||||
map->maps[LED_NUM-1].mods.real_mods= 0;
|
||||
map->maps[LED_NUM-1].mods.vmods= vmod_NumLockMask;
|
||||
|
||||
/* Metro Link */
|
||||
map->maps[LED_SCROLL-1].flags= XkbIM_NoExplicit;
|
||||
map->maps[LED_SCROLL-1].which_mods= XkbIM_UseLocked;
|
||||
map->maps[LED_SCROLL-1].mods.mask= Mod3Mask;
|
||||
map->maps[LED_SCROLL-1].mods.real_mods= Mod3Mask;
|
||||
/* Metro Link */
|
||||
}
|
||||
sli= XkbFindSrvLedInfo(xkbi->device,XkbDfltXIClass,XkbDfltXIId,0);
|
||||
if (sli)
|
||||
XkbCheckIndicatorMaps(xkbi->device,sli,XkbAllIndicatorsMask);
|
||||
return Success;
|
||||
}
|
||||
|
||||
static Status
|
||||
XkbInitControls(DeviceIntPtr pXDev,XkbSrvInfoPtr xkbi,SrvXkmInfo *file)
|
||||
{
|
||||
XkbDescPtr xkb;
|
||||
XkbControlsPtr ctrls;
|
||||
|
||||
xkb= xkbi->desc;
|
||||
/* 12/31/94 (ef) -- XXX! Should check if controls loaded from file */
|
||||
if (XkbAllocControls(xkb,XkbAllControlsMask)!=Success)
|
||||
FatalError("Couldn't allocate keyboard controls\n");
|
||||
ctrls= xkb->ctrls;
|
||||
if ((file->xkbinfo.defined&XkmSymbolsMask)==0)
|
||||
ctrls->num_groups = 1;
|
||||
ctrls->groups_wrap = XkbSetGroupInfo(1,XkbWrapIntoRange,0);
|
||||
ctrls->internal.mask = 0;
|
||||
ctrls->internal.real_mods = 0;
|
||||
ctrls->internal.vmods = 0;
|
||||
ctrls->ignore_lock.mask = 0;
|
||||
ctrls->ignore_lock.real_mods = 0;
|
||||
ctrls->ignore_lock.vmods = 0;
|
||||
ctrls->enabled_ctrls = XkbAccessXTimeoutMask|XkbRepeatKeysMask|
|
||||
XkbMouseKeysAccelMask|XkbAudibleBellMask|
|
||||
XkbIgnoreGroupLockMask;
|
||||
if (XkbWantAccessX)
|
||||
ctrls->enabled_ctrls|= XkbAccessXKeysMask;
|
||||
AccessXInit(pXDev);
|
||||
return Success;
|
||||
}
|
||||
|
||||
void
|
||||
XkbInitDevice(DeviceIntPtr pXDev)
|
||||
{
|
||||
int i;
|
||||
XkbSrvInfoPtr xkbi;
|
||||
XkbChangesRec changes;
|
||||
SrvXkmInfo file;
|
||||
unsigned check;
|
||||
XkbEventCauseRec cause;
|
||||
|
||||
file.dev= pXDev;
|
||||
file.file=NULL;
|
||||
bzero(&file.xkbinfo,sizeof(XkbFileInfo));
|
||||
bzero(&changes,sizeof(XkbChangesRec));
|
||||
pXDev->key->xkbInfo= xkbi= _XkbTypedCalloc(1,XkbSrvInfoRec);
|
||||
if ( xkbi ) {
|
||||
XkbDescPtr xkb;
|
||||
if ((_XkbInitFileInfo!=NULL)&&(_XkbInitFileInfo->xkb!=NULL)) {
|
||||
file.xkbinfo= *_XkbInitFileInfo;
|
||||
xkbi->desc= _XkbInitFileInfo->xkb;
|
||||
_XkbInitFileInfo= NULL;
|
||||
}
|
||||
else {
|
||||
xkbi->desc= XkbAllocKeyboard();
|
||||
if (!xkbi->desc)
|
||||
FatalError("Couldn't allocate keyboard description\n");
|
||||
xkbi->desc->min_key_code = pXDev->key->curKeySyms.minKeyCode;
|
||||
xkbi->desc->max_key_code = pXDev->key->curKeySyms.maxKeyCode;
|
||||
}
|
||||
xkb= xkbi->desc;
|
||||
if (xkb->min_key_code == 0)
|
||||
xkb->min_key_code = pXDev->key->curKeySyms.minKeyCode;
|
||||
if (xkb->max_key_code == 0)
|
||||
xkb->max_key_code = pXDev->key->curKeySyms.maxKeyCode;
|
||||
if ((pXDev->key->curKeySyms.minKeyCode!=xkbi->desc->min_key_code)||
|
||||
(pXDev->key->curKeySyms.maxKeyCode!=xkbi->desc->max_key_code)) {
|
||||
/* 12/9/95 (ef) -- XXX! Maybe we should try to fix up one or */
|
||||
/* the other here, but for now just complain */
|
||||
/* can't just update the core range without */
|
||||
/* reallocating the KeySymsRec (pain) */
|
||||
ErrorF("Internal Error!! XKB and core keymap have different range\n");
|
||||
}
|
||||
if (XkbAllocClientMap(xkb,XkbAllClientInfoMask,0)!=Success)
|
||||
FatalError("Couldn't allocate client map in XkbInitDevice\n");
|
||||
i= XkbNumKeys(xkb)/3+1;
|
||||
if (XkbAllocServerMap(xkb,XkbAllServerInfoMask,i)!=Success)
|
||||
FatalError("Couldn't allocate server map in XkbInitDevice\n");
|
||||
|
||||
xkbi->dfltPtrDelta=1;
|
||||
xkbi->device = pXDev;
|
||||
|
||||
file.xkbinfo.xkb= xkb;
|
||||
XkbInitSemantics(xkb,&file);
|
||||
XkbInitNames(xkbi,&file);
|
||||
XkbInitRadioGroups(xkbi,&file);
|
||||
|
||||
/* 12/31/94 (ef) -- XXX! Should check if state loaded from file */
|
||||
bzero(&xkbi->state,sizeof(XkbStateRec));
|
||||
|
||||
XkbInitControls(pXDev,xkbi,&file);
|
||||
|
||||
if (file.xkbinfo.defined&XkmSymbolsMask)
|
||||
memcpy(pXDev->key->modifierMap,xkb->map->modmap,xkb->max_key_code+1);
|
||||
else
|
||||
memcpy(xkb->map->modmap,pXDev->key->modifierMap,xkb->max_key_code+1);
|
||||
|
||||
XkbInitIndicatorMap(xkbi,&file);
|
||||
|
||||
if (!(file.xkbinfo.defined&XkmSymbolsMask)) {
|
||||
XkbUpdateKeyTypesFromCore(pXDev,xkb->min_key_code,XkbNumKeys(xkb),
|
||||
&changes);
|
||||
}
|
||||
else {
|
||||
XkbUpdateCoreDescription(pXDev,True);
|
||||
}
|
||||
XkbSetCauseUnknown(&cause);
|
||||
XkbUpdateActions(pXDev,xkb->min_key_code, XkbNumKeys(xkb),&changes,
|
||||
&check,&cause);
|
||||
/* For sanity. The first time the connection
|
||||
* is opened, the client side min and max are set
|
||||
* using QueryMinMaxKeyCodes() which grabs them
|
||||
* from pXDev.
|
||||
*/
|
||||
pXDev->key->curKeySyms.minKeyCode = xkb->min_key_code;
|
||||
pXDev->key->curKeySyms.maxKeyCode = xkb->max_key_code;
|
||||
}
|
||||
if (file.file!=NULL)
|
||||
fclose(file.file);
|
||||
return;
|
||||
}
|
||||
|
||||
#if MAP_LENGTH > XkbMaxKeyCount
|
||||
#undef XkbMaxKeyCount
|
||||
#define XkbMaxKeyCount MAP_LENGTH
|
||||
#endif
|
||||
|
||||
Bool
|
||||
XkbInitKeyboardDeviceStruct(
|
||||
DeviceIntPtr dev,
|
||||
XkbComponentNamesPtr names,
|
||||
KeySymsPtr pSymsIn,
|
||||
CARD8 pModsIn[],
|
||||
void (*bellProc)(
|
||||
int /*percent*/,
|
||||
DeviceIntPtr /*device*/,
|
||||
void * /*ctrl*/,
|
||||
int),
|
||||
void (*ctrlProc)(
|
||||
DeviceIntPtr /*device*/,
|
||||
KeybdCtrl * /*ctrl*/))
|
||||
{
|
||||
XkbFileInfo finfo;
|
||||
KeySymsRec tmpSyms,*pSyms;
|
||||
CARD8 tmpMods[XkbMaxLegalKeyCode+1],*pMods;
|
||||
char name[PATH_MAX],*rules;
|
||||
Bool ok=False;
|
||||
XkbRF_VarDefsRec defs;
|
||||
|
||||
if ((dev->key!=NULL)||(dev->kbdfeed!=NULL))
|
||||
return False;
|
||||
pSyms= pSymsIn;
|
||||
pMods= pModsIn;
|
||||
bzero(&defs,sizeof(XkbRF_VarDefsRec));
|
||||
rules= XkbGetRulesDflts(&defs);
|
||||
|
||||
/*
|
||||
* The strings are duplicated because it is not guaranteed that
|
||||
* they are allocated, or that they are allocated for every server
|
||||
* generation. Eventually they will be freed at the end of this
|
||||
* function.
|
||||
*/
|
||||
if (names->keymap) names->keymap = Xstrdup(names->keymap);
|
||||
if (names->keycodes) names->keycodes = Xstrdup(names->keycodes);
|
||||
if (names->types) names->types = Xstrdup(names->types);
|
||||
if (names->compat) names->compat = Xstrdup(names->compat);
|
||||
if (names->geometry) names->geometry = Xstrdup(names->geometry);
|
||||
if (names->symbols) names->symbols = Xstrdup(names->symbols);
|
||||
|
||||
if (defs.model && defs.layout && rules) {
|
||||
XkbComponentNamesRec rNames;
|
||||
bzero(&rNames,sizeof(XkbComponentNamesRec));
|
||||
if (XkbDDXNamesFromRules(dev,rules,&defs,&rNames)) {
|
||||
if (rNames.keymap) {
|
||||
if (!names->keymap)
|
||||
names->keymap = rNames.keymap;
|
||||
else _XkbFree(rNames.keymap);
|
||||
}
|
||||
if (rNames.keycodes) {
|
||||
if (!names->keycodes)
|
||||
names->keycodes = rNames.keycodes;
|
||||
else
|
||||
_XkbFree(rNames.keycodes);
|
||||
}
|
||||
if (rNames.types) {
|
||||
if (!names->types)
|
||||
names->types = rNames.types;
|
||||
else _XkbFree(rNames.types);
|
||||
}
|
||||
if (rNames.compat) {
|
||||
if (!names->compat)
|
||||
names->compat = rNames.compat;
|
||||
else _XkbFree(rNames.compat);
|
||||
}
|
||||
if (rNames.symbols) {
|
||||
if (!names->symbols)
|
||||
names->symbols = rNames.symbols;
|
||||
else _XkbFree(rNames.symbols);
|
||||
}
|
||||
if (rNames.geometry) {
|
||||
if (!names->geometry)
|
||||
names->geometry = rNames.geometry;
|
||||
else _XkbFree(rNames.geometry);
|
||||
}
|
||||
XkbSetRulesUsed(&defs);
|
||||
}
|
||||
}
|
||||
|
||||
if (names->keymap) {
|
||||
XkbComponentNamesRec tmpNames;
|
||||
bzero(&tmpNames,sizeof(XkbComponentNamesRec));
|
||||
tmpNames.keymap = names->keymap;
|
||||
ok = (Bool) XkbDDXLoadKeymapByNames(dev,&tmpNames,XkmAllIndicesMask,0,
|
||||
&finfo,name,PATH_MAX);
|
||||
}
|
||||
if (!(ok && (finfo.xkb!=NULL)))
|
||||
ok = (Bool) XkbDDXLoadKeymapByNames(dev,names,XkmAllIndicesMask,0,
|
||||
&finfo,name,PATH_MAX);
|
||||
|
||||
if (ok && (finfo.xkb!=NULL)) {
|
||||
XkbDescPtr xkb;
|
||||
KeyCode minKC,maxKC;
|
||||
|
||||
xkb= finfo.xkb;
|
||||
minKC= xkb->min_key_code;
|
||||
maxKC= xkb->max_key_code;
|
||||
if (XkbIsLegalKeycode(minKC)&&XkbIsLegalKeycode(maxKC)&&(minKC<=maxKC)&&
|
||||
((minKC!=pSyms->minKeyCode)||(maxKC!=pSyms->maxKeyCode))) {
|
||||
if (xkb->map!=NULL) {
|
||||
KeySym *inSym,*outSym;
|
||||
int width= pSymsIn->mapWidth;
|
||||
|
||||
tmpSyms.minKeyCode= minKC;
|
||||
tmpSyms.maxKeyCode= maxKC;
|
||||
|
||||
if (minKC<pSymsIn->minKeyCode)
|
||||
minKC= pSymsIn->minKeyCode;
|
||||
if (maxKC>pSymsIn->maxKeyCode)
|
||||
maxKC= pSymsIn->maxKeyCode;
|
||||
|
||||
tmpSyms.mapWidth= width;
|
||||
tmpSyms.map= _XkbTypedCalloc(width*XkbNumKeys(xkb),KeySym);
|
||||
inSym= &pSymsIn->map[(minKC-pSymsIn->minKeyCode)*width];
|
||||
outSym= &tmpSyms.map[(minKC-tmpSyms.minKeyCode)*width];
|
||||
memcpy(outSym,inSym,((maxKC-minKC+1)*width)*sizeof(KeySym));
|
||||
pSyms= &tmpSyms;
|
||||
}
|
||||
if ((xkb->map!=NULL)&&(xkb->map->modmap!=NULL)) {
|
||||
bzero(tmpMods,XkbMaxKeyCount);
|
||||
memcpy(tmpMods,xkb->map->modmap,maxKC+1);
|
||||
pMods= tmpMods;
|
||||
}
|
||||
}
|
||||
_XkbInitFileInfo= &finfo;
|
||||
}
|
||||
else {
|
||||
LogMessage(X_WARNING, "Couldn't load XKB keymap, falling back to pre-XKB keymap\n");
|
||||
}
|
||||
ok= InitKeyboardDeviceStruct((DevicePtr)dev,pSyms,pMods,bellProc,ctrlProc);
|
||||
_XkbInitFileInfo= NULL;
|
||||
if ((pSyms==&tmpSyms)&&(pSyms->map!=NULL)) {
|
||||
_XkbFree(pSyms->map);
|
||||
pSyms->map= NULL;
|
||||
}
|
||||
|
||||
if (names->keymap) _XkbFree(names->keymap);
|
||||
names->keymap = NULL;
|
||||
if (names->keycodes) _XkbFree(names->keycodes);
|
||||
names->keycodes = NULL;
|
||||
if (names->types) _XkbFree(names->types);
|
||||
names->types = NULL;
|
||||
if (names->compat) _XkbFree(names->compat);
|
||||
names->compat = NULL;
|
||||
if (names->geometry) _XkbFree(names->geometry);
|
||||
names->geometry = NULL;
|
||||
if (names->symbols) _XkbFree(names->symbols);
|
||||
names->symbols = NULL;
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
/*
|
||||
* InitKeyClassDeviceStruct initializes the key class before it
|
||||
* initializes the keyboard feedback class for a device.
|
||||
* UpdateActions can't set up the correct autorepeat for keyboard
|
||||
* initialization because the keyboard feedback isn't created yet.
|
||||
* Instead, UpdateActions notes the "correct" autorepeat in the
|
||||
* SrvInfo structure and InitKbdFeedbackClass calls UpdateAutoRepeat
|
||||
* to apply the computed autorepeat once the feedback class exists.
|
||||
*
|
||||
* DIX will apply the changed autorepeat, so there's no need to
|
||||
* do so here. This function returns True if both RepeatKeys and
|
||||
* the core protocol autorepeat ctrls are set (i.e. should use
|
||||
* software autorepeat), false otherwise.
|
||||
*
|
||||
* This function also computes the autorepeat accelerators for the
|
||||
* default indicator feedback.
|
||||
*/
|
||||
int
|
||||
XkbFinishDeviceInit(DeviceIntPtr pXDev)
|
||||
{
|
||||
XkbSrvInfoPtr xkbi;
|
||||
XkbDescPtr xkb;
|
||||
int softRepeat;
|
||||
XkbSrvLedInfoPtr sli;
|
||||
|
||||
xkbi = NULL;
|
||||
if (pXDev && pXDev->key && pXDev->key->xkbInfo && pXDev->kbdfeed) {
|
||||
xkbi= pXDev->key->xkbInfo;
|
||||
xkb= xkbi->desc;
|
||||
if (pXDev->kbdfeed) {
|
||||
xkbi->kbdProc= pXDev->kbdfeed->CtrlProc;
|
||||
pXDev->kbdfeed->CtrlProc= XkbDDXKeybdCtrlProc;
|
||||
}
|
||||
if (pXDev->kbdfeed->ctrl.autoRepeat)
|
||||
xkb->ctrls->enabled_ctrls|= XkbRepeatKeysMask;
|
||||
softRepeat= (xkb->ctrls->enabled_ctrls&XkbRepeatKeysMask)!=0;
|
||||
if (pXDev->kbdfeed) {
|
||||
memcpy(pXDev->kbdfeed->ctrl.autoRepeats,
|
||||
xkb->ctrls->per_key_repeat,XkbPerKeyBitArraySize);
|
||||
softRepeat= softRepeat&&pXDev->kbdfeed->ctrl.autoRepeat;
|
||||
}
|
||||
}
|
||||
else softRepeat= 0;
|
||||
sli= XkbFindSrvLedInfo(pXDev,XkbDfltXIClass,XkbDfltXIId,0);
|
||||
if (sli && xkbi)
|
||||
XkbCheckIndicatorMaps(xkbi->device,sli,XkbAllIndicatorsMask);
|
||||
else DebugF("No indicator feedback in XkbFinishInit (shouldn't happen)!\n");
|
||||
return softRepeat;
|
||||
}
|
||||
|
||||
/*
|
||||
* Be very careful about what does and doesn't get freed by this
|
||||
* function. To reduce fragmentation, XkbInitDevice allocates a
|
||||
* single huge block per device and divides it up into most of the
|
||||
* fixed-size structures for the device. Don't free anything that
|
||||
* is part of this larger block.
|
||||
*/
|
||||
void
|
||||
XkbFreeInfo(XkbSrvInfoPtr xkbi)
|
||||
{
|
||||
if (xkbi->radioGroups) {
|
||||
_XkbFree(xkbi->radioGroups);
|
||||
xkbi->radioGroups= NULL;
|
||||
}
|
||||
if (xkbi->mouseKeyTimer) {
|
||||
TimerFree(xkbi->mouseKeyTimer);
|
||||
xkbi->mouseKeyTimer= NULL;
|
||||
}
|
||||
if (xkbi->slowKeysTimer) {
|
||||
TimerFree(xkbi->slowKeysTimer);
|
||||
xkbi->slowKeysTimer= NULL;
|
||||
}
|
||||
if (xkbi->bounceKeysTimer) {
|
||||
TimerFree(xkbi->bounceKeysTimer);
|
||||
xkbi->bounceKeysTimer= NULL;
|
||||
}
|
||||
if (xkbi->repeatKeyTimer) {
|
||||
TimerFree(xkbi->repeatKeyTimer);
|
||||
xkbi->repeatKeyTimer= NULL;
|
||||
}
|
||||
if (xkbi->krgTimer) {
|
||||
TimerFree(xkbi->krgTimer);
|
||||
xkbi->krgTimer= NULL;
|
||||
}
|
||||
xkbi->beepType= _BEEP_NONE;
|
||||
if (xkbi->beepTimer) {
|
||||
TimerFree(xkbi->beepTimer);
|
||||
xkbi->beepTimer= NULL;
|
||||
}
|
||||
if (xkbi->desc) {
|
||||
XkbFreeKeyboard(xkbi->desc,XkbAllComponentsMask,True);
|
||||
xkbi->desc= NULL;
|
||||
}
|
||||
_XkbFree(xkbi);
|
||||
return;
|
||||
}
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
extern int XkbDfltRepeatDelay;
|
||||
extern int XkbDfltRepeatInterval;
|
||||
|
||||
extern unsigned short XkbDfltAccessXTimeout;
|
||||
extern unsigned int XkbDfltAccessXTimeoutMask;
|
||||
extern unsigned int XkbDfltAccessXFeedback;
|
||||
extern unsigned char XkbDfltAccessXOptions;
|
||||
|
||||
int
|
||||
XkbProcessArguments(int argc,char *argv[],int i)
|
||||
{
|
||||
if (strcmp(argv[i],"-kb")==0) {
|
||||
noXkbExtension= True;
|
||||
return 1;
|
||||
}
|
||||
else if (strcmp(argv[i],"+kb")==0) {
|
||||
noXkbExtension= False;
|
||||
return 1;
|
||||
}
|
||||
else if (strncmp(argv[i], "-xkbdir", 7) == 0) {
|
||||
if(++i < argc) {
|
||||
#if !defined(WIN32) && !defined(__CYGWIN__)
|
||||
if (getuid() != geteuid()) {
|
||||
LogMessage(X_WARNING, "-xkbdir is not available for setuid X servers\n");
|
||||
return -1;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
if (strlen(argv[i]) < PATH_MAX) {
|
||||
XkbBaseDirectory= argv[i];
|
||||
return 2;
|
||||
} else {
|
||||
LogMessage(X_ERROR, "-xkbdir pathname too long\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else if ((strncmp(argv[i],"-accessx",8)==0)||
|
||||
(strncmp(argv[i],"+accessx",8)==0)) {
|
||||
int j=1;
|
||||
if (argv[i][0]=='-')
|
||||
XkbWantAccessX= 0;
|
||||
else {
|
||||
XkbWantAccessX= 1;
|
||||
|
||||
if ( ((i+1)<argc) && (isdigit(argv[i+1][0])) ) {
|
||||
XkbDfltAccessXTimeout = atoi(argv[++i]);
|
||||
j++;
|
||||
|
||||
if ( ((i+1)<argc) && (isdigit(argv[i+1][0])) ) {
|
||||
/*
|
||||
* presumption that the reasonably useful range of
|
||||
* values fits in 0..MAXINT since SunOS 4 doesn't
|
||||
* have strtoul.
|
||||
*/
|
||||
XkbDfltAccessXTimeoutMask=(unsigned int)
|
||||
strtol(argv[++i],NULL,16);
|
||||
j++;
|
||||
}
|
||||
if ( ((i+1)<argc) && (isdigit(argv[i+1][0])) ) {
|
||||
if (argv[++i][0] == '1' )
|
||||
XkbDfltAccessXFeedback=XkbAccessXFeedbackMask;
|
||||
else
|
||||
XkbDfltAccessXFeedback=0;
|
||||
j++;
|
||||
}
|
||||
if ( ((i+1)<argc) && (isdigit(argv[i+1][0])) ) {
|
||||
XkbDfltAccessXOptions=(unsigned char)
|
||||
strtol(argv[++i],NULL,16);
|
||||
j++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return j;
|
||||
}
|
||||
if ((strcmp(argv[i], "-ardelay") == 0) ||
|
||||
(strcmp (argv[i], "-ar1") == 0)) { /* -ardelay int */
|
||||
if (++i >= argc) UseMsg ();
|
||||
XkbDfltRepeatDelay = (long)atoi(argv[i]);
|
||||
return 2;
|
||||
}
|
||||
if ((strcmp(argv[i], "-arinterval") == 0) ||
|
||||
(strcmp (argv[i], "-ar2") == 0)) { /* -arinterval int */
|
||||
if (++i >= argc) UseMsg ();
|
||||
XkbDfltRepeatInterval = (long)atoi(argv[i]);
|
||||
return 2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
XkbUseMsg(void)
|
||||
{
|
||||
ErrorF("-kb disable the X Keyboard Extension\n");
|
||||
ErrorF("+kb enable the X Keyboard Extension\n");
|
||||
ErrorF("[+-]accessx [ timeout [ timeout_mask [ feedback [ options_mask] ] ] ]\n");
|
||||
ErrorF(" enable/disable accessx key sequences\n");
|
||||
ErrorF("-ardelay set XKB autorepeat delay\n");
|
||||
ErrorF("-arinterval set XKB autorepeat interval\n");
|
||||
}
|
||||
928
nx-X11/programs/Xserver/xkb/xkbLEDs.c
Normal file
928
nx-X11/programs/Xserver/xkb/xkbLEDs.c
Normal file
@@ -0,0 +1,928 @@
|
||||
/************************************************************
|
||||
Copyright (c) 1995 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_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <math.h>
|
||||
#include <nx-X11/X.h>
|
||||
#include <nx-X11/Xproto.h>
|
||||
#include "misc.h"
|
||||
#include "inputstr.h"
|
||||
|
||||
#include <nx-X11/extensions/XI.h>
|
||||
#include <xkbsrv.h>
|
||||
#include "xkb.h"
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
/*
|
||||
* unsigned
|
||||
* XkbIndicatorsToUpdate(dev,changed,check_devs_rtrn)
|
||||
*
|
||||
* Given a keyboard and a set of state components that have changed,
|
||||
* this function returns the indicators on the default keyboard
|
||||
* feedback that might be affected. It also reports whether or not
|
||||
* any extension devices might be affected in check_devs_rtrn.
|
||||
*/
|
||||
|
||||
unsigned
|
||||
XkbIndicatorsToUpdate( DeviceIntPtr dev,
|
||||
unsigned long state_changes,
|
||||
Bool enable_changes)
|
||||
{
|
||||
register unsigned update= 0;
|
||||
XkbSrvLedInfoPtr sli;
|
||||
|
||||
sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,0);
|
||||
|
||||
if (state_changes&(XkbModifierStateMask|XkbGroupStateMask))
|
||||
update|= sli->usesEffective;
|
||||
if (state_changes&(XkbModifierBaseMask|XkbGroupBaseMask))
|
||||
update|= sli->usesBase;
|
||||
if (state_changes&(XkbModifierLatchMask|XkbGroupLatchMask))
|
||||
update|= sli->usesLatched;
|
||||
if (state_changes&(XkbModifierLockMask|XkbGroupLockMask))
|
||||
update|= sli->usesLocked;
|
||||
if (state_changes&XkbCompatStateMask)
|
||||
update|= sli->usesCompat;
|
||||
if (enable_changes)
|
||||
update|= sli->usesControls;
|
||||
return update;
|
||||
}
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
/*
|
||||
* Bool
|
||||
* XkbApplyLEDChangeToKeyboard(xkbi,map,on,change)
|
||||
*
|
||||
* Some indicators "drive" the keyboard when their state is explicitly
|
||||
* changed, as described in section 9.2.1 of the XKB protocol spec.
|
||||
* This function updates the state and controls for the keyboard
|
||||
* specified by 'xkbi' to reflect any changes that are required
|
||||
* when the indicator described by 'map' is turned on or off. The
|
||||
* extent of the changes is reported in change, which must be defined.
|
||||
*/
|
||||
static Bool
|
||||
XkbApplyLEDChangeToKeyboard( XkbSrvInfoPtr xkbi,
|
||||
XkbIndicatorMapPtr map,
|
||||
Bool on,
|
||||
XkbChangesPtr change)
|
||||
{
|
||||
Bool ctrlChange,stateChange;
|
||||
XkbStatePtr state;
|
||||
|
||||
if ((map->flags&XkbIM_NoExplicit)||((map->flags&XkbIM_LEDDrivesKB)==0))
|
||||
return False;
|
||||
ctrlChange= stateChange= False;
|
||||
if (map->ctrls) {
|
||||
XkbControlsPtr ctrls= xkbi->desc->ctrls;
|
||||
unsigned old;
|
||||
|
||||
old= ctrls->enabled_ctrls;
|
||||
if (on) ctrls->enabled_ctrls|= map->ctrls;
|
||||
else ctrls->enabled_ctrls&= ~map->ctrls;
|
||||
if (old!=ctrls->enabled_ctrls) {
|
||||
change->ctrls.changed_ctrls= XkbControlsEnabledMask;
|
||||
change->ctrls.enabled_ctrls_changes= old^ctrls->enabled_ctrls;
|
||||
ctrlChange= True;
|
||||
}
|
||||
}
|
||||
state= &xkbi->state;
|
||||
if ((map->groups)&&((map->which_groups&(~XkbIM_UseBase))!=0)) {
|
||||
register int i;
|
||||
register unsigned bit,match;
|
||||
|
||||
if (on) match= (map->groups)&XkbAllGroupsMask;
|
||||
else match= (~map->groups)&XkbAllGroupsMask;
|
||||
if (map->which_groups&(XkbIM_UseLocked|XkbIM_UseEffective)) {
|
||||
for (i=0,bit=1;i<XkbNumKbdGroups;i++,bit<<=1) {
|
||||
if (bit&match)
|
||||
break;
|
||||
}
|
||||
if (map->which_groups&XkbIM_UseLatched)
|
||||
XkbLatchGroup(xkbi->device,0); /* unlatch group */
|
||||
state->locked_group= i;
|
||||
stateChange= True;
|
||||
}
|
||||
else if (map->which_groups&(XkbIM_UseLatched|XkbIM_UseEffective)) {
|
||||
for (i=0,bit=1;i<XkbNumKbdGroups;i++,bit<<=1) {
|
||||
if (bit&match)
|
||||
break;
|
||||
}
|
||||
state->locked_group= 0;
|
||||
XkbLatchGroup(xkbi->device,i);
|
||||
stateChange= True;
|
||||
}
|
||||
}
|
||||
if ((map->mods.mask)&&((map->which_mods&(~XkbIM_UseBase))!=0)) {
|
||||
if (map->which_mods&(XkbIM_UseLocked|XkbIM_UseEffective)) {
|
||||
register unsigned long old;
|
||||
old= state->locked_mods;
|
||||
if (on) state->locked_mods|= map->mods.mask;
|
||||
else state->locked_mods&= ~map->mods.mask;
|
||||
if (state->locked_mods!=old)
|
||||
stateChange= True;
|
||||
}
|
||||
if (map->which_mods&(XkbIM_UseLatched|XkbIM_UseEffective)) {
|
||||
register unsigned long newmods;
|
||||
newmods= state->latched_mods;
|
||||
if (on) newmods|= map->mods.mask;
|
||||
else newmods&= ~map->mods.mask;
|
||||
if (newmods!=state->locked_mods) {
|
||||
newmods&= map->mods.mask;
|
||||
XkbLatchModifiers(xkbi->device,map->mods.mask,newmods);
|
||||
stateChange= True;
|
||||
}
|
||||
}
|
||||
}
|
||||
return (stateChange || ctrlChange);
|
||||
}
|
||||
|
||||
/*
|
||||
* Bool
|
||||
* ComputeAutoState(map,state,ctrls)
|
||||
*
|
||||
* This function reports the effect of applying the specified
|
||||
* indicator map given the specified state and controls, as
|
||||
* described in section 9.2 of the XKB protocol specification.
|
||||
*/
|
||||
|
||||
static Bool
|
||||
ComputeAutoState( XkbIndicatorMapPtr map,
|
||||
XkbStatePtr state,
|
||||
XkbControlsPtr ctrls)
|
||||
{
|
||||
Bool on;
|
||||
CARD8 mods,group;
|
||||
|
||||
on= False;
|
||||
mods= group= 0;
|
||||
if (map->which_mods&XkbIM_UseAnyMods) {
|
||||
if (map->which_mods&XkbIM_UseBase)
|
||||
mods|= state->base_mods;
|
||||
if (map->which_mods&XkbIM_UseLatched)
|
||||
mods|= state->latched_mods;
|
||||
if (map->which_mods&XkbIM_UseLocked)
|
||||
mods|= state->locked_mods;
|
||||
if (map->which_mods&XkbIM_UseEffective)
|
||||
mods|= state->mods;
|
||||
if (map->which_mods&XkbIM_UseCompat)
|
||||
mods|= state->compat_state;
|
||||
on = ((map->mods.mask&mods)!=0);
|
||||
on = on||((mods==0)&&(map->mods.mask==0)&&(map->mods.vmods==0));
|
||||
}
|
||||
if (map->which_groups&XkbIM_UseAnyGroup) {
|
||||
if (map->which_groups&XkbIM_UseBase)
|
||||
group|= (1L << state->base_group);
|
||||
if (map->which_groups&XkbIM_UseLatched)
|
||||
group|= (1L << state->latched_group);
|
||||
if (map->which_groups&XkbIM_UseLocked)
|
||||
group|= (1L << state->locked_group);
|
||||
if (map->which_groups&XkbIM_UseEffective)
|
||||
group|= (1L << state->group);
|
||||
on = on||(((map->groups&group)!=0)||(map->groups==0));
|
||||
}
|
||||
if (map->ctrls)
|
||||
on = on||(ctrls->enabled_ctrls&map->ctrls);
|
||||
return on;
|
||||
}
|
||||
|
||||
static void
|
||||
XkbUpdateLedAutoState( DeviceIntPtr dev,
|
||||
XkbSrvLedInfoPtr sli,
|
||||
unsigned maps_to_check,
|
||||
xkbExtensionDeviceNotify * ed,
|
||||
XkbChangesPtr changes,
|
||||
XkbEventCausePtr cause)
|
||||
{
|
||||
DeviceIntPtr kbd;
|
||||
XkbStatePtr state;
|
||||
XkbControlsPtr ctrls;
|
||||
XkbChangesRec my_changes;
|
||||
xkbExtensionDeviceNotify my_ed;
|
||||
register unsigned i,bit,affected;
|
||||
register XkbIndicatorMapPtr map;
|
||||
unsigned oldState;
|
||||
|
||||
if ((maps_to_check==0)||(sli->maps==NULL)||(sli->mapsPresent==0))
|
||||
return;
|
||||
|
||||
if (dev->key && dev->key->xkbInfo)
|
||||
kbd= dev;
|
||||
else kbd= (DeviceIntPtr)LookupKeyboardDevice();
|
||||
|
||||
state= &kbd->key->xkbInfo->state;
|
||||
ctrls= kbd->key->xkbInfo->desc->ctrls;
|
||||
affected= maps_to_check;
|
||||
oldState= sli->effectiveState;
|
||||
sli->autoState&= ~affected;
|
||||
for (i=0,bit=1;(i<XkbNumIndicators)&&(affected);i++,bit<<=1) {
|
||||
if ((affected&bit)==0)
|
||||
continue;
|
||||
affected&= ~bit;
|
||||
map= &sli->maps[i];
|
||||
if((!(map->flags&XkbIM_NoAutomatic))&&ComputeAutoState(map,state,ctrls))
|
||||
sli->autoState|= bit;
|
||||
}
|
||||
sli->effectiveState= (sli->autoState|sli->explicitState);
|
||||
affected= sli->effectiveState^oldState;
|
||||
if (affected==0)
|
||||
return;
|
||||
|
||||
if (ed==NULL) {
|
||||
ed= &my_ed;
|
||||
bzero((char *)ed,sizeof(xkbExtensionDeviceNotify));
|
||||
}
|
||||
else if ((ed->reason&XkbXI_IndicatorsMask)&&
|
||||
((ed->ledClass!=sli->class)||(ed->ledID!=sli->id))) {
|
||||
XkbFlushLedEvents(dev,kbd,sli,ed,changes,cause);
|
||||
}
|
||||
|
||||
if ((kbd==dev)&&(sli->flags&XkbSLI_IsDefault)) {
|
||||
if (changes==NULL) {
|
||||
changes= &my_changes;
|
||||
bzero((char *)changes,sizeof(XkbChangesRec));
|
||||
}
|
||||
changes->indicators.state_changes|= affected;
|
||||
}
|
||||
|
||||
ed->reason|= (XkbXI_IndicatorStateMask&(~XkbXI_KeyboardsMask));
|
||||
ed->ledClass= sli->class;
|
||||
ed->ledID= sli->id;
|
||||
ed->ledsDefined= sli->namesPresent|sli->mapsPresent;
|
||||
ed->ledState= sli->effectiveState;
|
||||
ed->unsupported|= XkbXI_KeyboardsMask&XkbXI_IndicatorStateMask;
|
||||
ed->supported= XkbXI_AllFeaturesMask&(~XkbXI_KeyboardsMask);
|
||||
|
||||
if (changes!=&my_changes) changes= NULL;
|
||||
if (ed!=&my_ed) ed= NULL;
|
||||
if (changes || ed)
|
||||
XkbFlushLedEvents(dev,kbd,sli,ed,changes,cause);
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
XkbUpdateAllDeviceIndicators(XkbChangesPtr changes,XkbEventCausePtr cause)
|
||||
{
|
||||
DeviceIntPtr edev;
|
||||
XkbSrvLedInfoPtr sli;
|
||||
|
||||
for (edev=inputInfo.devices;edev!=NULL;edev=edev->next) {
|
||||
if (edev->kbdfeed) {
|
||||
KbdFeedbackPtr kf;
|
||||
for (kf=edev->kbdfeed;kf!=NULL;kf=kf->next) {
|
||||
if ((kf->xkb_sli==NULL)||(kf->xkb_sli->maps==NULL))
|
||||
continue;
|
||||
sli= kf->xkb_sli;
|
||||
XkbUpdateLedAutoState(edev,sli,sli->mapsPresent,NULL,
|
||||
changes,cause);
|
||||
}
|
||||
}
|
||||
if (edev->leds) {
|
||||
LedFeedbackPtr lf;
|
||||
for (lf=edev->leds;lf!=NULL;lf=lf->next) {
|
||||
if ((lf->xkb_sli==NULL)||(lf->xkb_sli->maps==NULL))
|
||||
continue;
|
||||
sli= lf->xkb_sli;
|
||||
XkbUpdateLedAutoState(edev,sli,sli->mapsPresent,NULL,
|
||||
changes,cause);
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
/*
|
||||
* void
|
||||
* XkbSetIndicators(dev,affect,values,cause)
|
||||
*
|
||||
* Attempts to change the indicators specified in 'affect' to the
|
||||
* states specified in 'values' for the default keyboard feedback
|
||||
* on the keyboard specified by 'dev.' Attempts to change indicator
|
||||
* state might be ignored or have no affect, depending on the XKB
|
||||
* indicator map for any affected indicators, as described in section
|
||||
* 9.2 of the XKB protocol specification.
|
||||
*
|
||||
* If 'changes' is non-NULL, this function notes any changes to the
|
||||
* keyboard state, controls, or indicator state that result from this
|
||||
* attempted change. If 'changes' is NULL, this function generates
|
||||
* XKB events to report any such changes to interested clients.
|
||||
*
|
||||
* If 'cause' is non-NULL, it specifies the reason for the change,
|
||||
* as reported in some XKB events. If it is NULL, this function
|
||||
* assumes that the change is the result of a core protocol
|
||||
* ChangeKeyboardMapping request.
|
||||
*/
|
||||
|
||||
void
|
||||
XkbSetIndicators( DeviceIntPtr dev,
|
||||
CARD32 affect,
|
||||
CARD32 values,
|
||||
XkbEventCausePtr cause)
|
||||
{
|
||||
XkbSrvLedInfoPtr sli;
|
||||
XkbChangesRec changes;
|
||||
xkbExtensionDeviceNotify ed;
|
||||
unsigned side_affected;
|
||||
|
||||
bzero((char *)&changes,sizeof(XkbChangesRec));
|
||||
bzero((char *)&ed,sizeof(xkbExtensionDeviceNotify));
|
||||
sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,0);
|
||||
sli->explicitState&= ~affect;
|
||||
sli->explicitState|= (affect&values);
|
||||
XkbApplyLedStateChanges(dev,sli,affect,&ed,&changes,cause);
|
||||
|
||||
side_affected= 0;
|
||||
if (changes.state_changes!=0)
|
||||
side_affected|= XkbIndicatorsToUpdate(dev,changes.state_changes,False);
|
||||
if (changes.ctrls.enabled_ctrls_changes)
|
||||
side_affected|= sli->usesControls;
|
||||
|
||||
if (side_affected) {
|
||||
XkbUpdateLedAutoState(dev,sli,side_affected,&ed,&changes,cause);
|
||||
affect|= side_affected;
|
||||
}
|
||||
if (changes.state_changes || changes.ctrls.enabled_ctrls_changes)
|
||||
XkbUpdateAllDeviceIndicators(NULL,cause);
|
||||
|
||||
XkbFlushLedEvents(dev,dev,sli,&ed,&changes,cause);
|
||||
return;
|
||||
}
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
/*
|
||||
* void
|
||||
* XkbUpdateIndicators(dev,update,check_edevs,changes,cause)
|
||||
*
|
||||
* Applies the indicator maps for any indicators specified in
|
||||
* 'update' from the default keyboard feedback on the device
|
||||
* specified by 'dev.'
|
||||
*
|
||||
* If 'changes' is NULL, this function generates and XKB events
|
||||
* required to report the necessary changes, otherwise it simply
|
||||
* notes the indicators with changed state.
|
||||
*
|
||||
* If 'check_edevs' is True, this function also checks the indicator
|
||||
* maps for any open extension devices that have them, and updates
|
||||
* the state of any extension device indicators as necessary.
|
||||
*/
|
||||
|
||||
void
|
||||
XkbUpdateIndicators( DeviceIntPtr dev,
|
||||
register CARD32 update,
|
||||
Bool check_edevs,
|
||||
XkbChangesPtr changes,
|
||||
XkbEventCausePtr cause)
|
||||
{
|
||||
XkbSrvLedInfoPtr sli;
|
||||
|
||||
sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,0);
|
||||
XkbUpdateLedAutoState(dev,sli,update,NULL,changes,cause);
|
||||
if (check_edevs)
|
||||
XkbUpdateAllDeviceIndicators(changes,cause);
|
||||
return;
|
||||
}
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
/*
|
||||
* void
|
||||
* XkbCheckIndicatorMaps(dev,sli,which)
|
||||
*
|
||||
* Updates the 'indicator accelerators' for the indicators specified
|
||||
* by 'which' in the feedback specified by 'sli.' The indicator
|
||||
* accelerators are internal to the server and are used to simplify
|
||||
* and speed up the process of figuring out which indicators might
|
||||
* be affected by a particular change in keyboard state or controls.
|
||||
*/
|
||||
|
||||
void
|
||||
XkbCheckIndicatorMaps(DeviceIntPtr dev,XkbSrvLedInfoPtr sli,unsigned which)
|
||||
{
|
||||
register unsigned i,bit;
|
||||
XkbIndicatorMapPtr map;
|
||||
XkbDescPtr xkb;
|
||||
|
||||
if ((sli->flags&XkbSLI_HasOwnState)==0)
|
||||
dev= (DeviceIntPtr)LookupKeyboardDevice();
|
||||
|
||||
sli->usesBase&= ~which;
|
||||
sli->usesLatched&= ~which;
|
||||
sli->usesLocked&= ~which;
|
||||
sli->usesEffective&= ~which;
|
||||
sli->usesCompat&= ~which;
|
||||
sli->usesControls&= ~which;
|
||||
sli->mapsPresent&= ~which;
|
||||
|
||||
xkb= dev->key->xkbInfo->desc;
|
||||
for (i=0,bit=1,map=sli->maps;i<XkbNumIndicators;i++,bit<<=1,map++) {
|
||||
if (which&bit) {
|
||||
CARD8 what;
|
||||
|
||||
if (!XkbIM_InUse(map))
|
||||
continue;
|
||||
sli->mapsPresent|= bit;
|
||||
|
||||
what= (map->which_mods|map->which_groups);
|
||||
if (what&XkbIM_UseBase)
|
||||
sli->usesBase|= bit;
|
||||
if (what&XkbIM_UseLatched)
|
||||
sli->usesLatched|= bit;
|
||||
if (what&XkbIM_UseLocked)
|
||||
sli->usesLocked|= bit;
|
||||
if (what&XkbIM_UseEffective)
|
||||
sli->usesEffective|= bit;
|
||||
if (what&XkbIM_UseCompat)
|
||||
sli->usesCompat|= bit;
|
||||
if (map->ctrls)
|
||||
sli->usesControls|= bit;
|
||||
|
||||
map->mods.mask= map->mods.real_mods;
|
||||
if (map->mods.vmods!=0) {
|
||||
map->mods.mask|= XkbMaskForVMask(xkb,map->mods.vmods);
|
||||
}
|
||||
}
|
||||
}
|
||||
sli->usedComponents= 0;
|
||||
if (sli->usesBase)
|
||||
sli->usedComponents|= XkbModifierBaseMask|XkbGroupBaseMask;
|
||||
if (sli->usesLatched)
|
||||
sli->usedComponents|= XkbModifierLatchMask|XkbGroupLatchMask;
|
||||
if (sli->usesLocked)
|
||||
sli->usedComponents|= XkbModifierLockMask|XkbGroupLockMask;
|
||||
if (sli->usesEffective)
|
||||
sli->usedComponents|= XkbModifierStateMask|XkbGroupStateMask;
|
||||
if (sli->usesCompat)
|
||||
sli->usedComponents|= XkbCompatStateMask;
|
||||
return;
|
||||
}
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
/*
|
||||
* XkbSrvLedInfoPtr
|
||||
* XkbAllocSrvLedInfo(dev,kf,lf,needed_parts)
|
||||
*
|
||||
* Allocates an XkbSrvLedInfoPtr for the feedback specified by either
|
||||
* 'kf' or 'lf' on the keyboard specified by 'dev.'
|
||||
*
|
||||
* If 'needed_parts' is non-zero, this function makes sure that any
|
||||
* of the parts speicified therein are allocated.
|
||||
*/
|
||||
XkbSrvLedInfoPtr
|
||||
XkbAllocSrvLedInfo( DeviceIntPtr dev,
|
||||
KbdFeedbackPtr kf,
|
||||
LedFeedbackPtr lf,
|
||||
unsigned needed_parts)
|
||||
{
|
||||
XkbSrvLedInfoPtr sli;
|
||||
Bool checkAccel;
|
||||
Bool checkNames;
|
||||
|
||||
sli= NULL;
|
||||
checkAccel= checkNames= False;
|
||||
if ((kf!=NULL)&&(kf->xkb_sli==NULL)) {
|
||||
kf->xkb_sli= sli= _XkbTypedCalloc(1,XkbSrvLedInfoRec);
|
||||
if (sli==NULL)
|
||||
return NULL; /* ALLOCATION ERROR */
|
||||
if (dev->key && dev->key->xkbInfo)
|
||||
sli->flags= XkbSLI_HasOwnState;
|
||||
else sli->flags= 0;
|
||||
sli->class= KbdFeedbackClass;
|
||||
sli->id= kf->ctrl.id;
|
||||
sli->fb.kf= kf;
|
||||
|
||||
sli->autoState= 0;
|
||||
sli->explicitState= kf->ctrl.leds;
|
||||
sli->effectiveState= kf->ctrl.leds;
|
||||
|
||||
if ((kf==dev->kbdfeed) && (dev->key) && (dev->key->xkbInfo)) {
|
||||
XkbDescPtr xkb;
|
||||
xkb= dev->key->xkbInfo->desc;
|
||||
sli->flags|= XkbSLI_IsDefault;
|
||||
sli->physIndicators= xkb->indicators->phys_indicators;
|
||||
sli->names= xkb->names->indicators;
|
||||
sli->maps= xkb->indicators->maps;
|
||||
checkNames= checkAccel= True;
|
||||
}
|
||||
else {
|
||||
sli->physIndicators= XkbAllIndicatorsMask;
|
||||
sli->names= NULL;
|
||||
sli->maps= NULL;
|
||||
}
|
||||
}
|
||||
else if ((kf!=NULL)&&((kf->xkb_sli->flags&XkbSLI_IsDefault)!=0)) {
|
||||
XkbDescPtr xkb;
|
||||
xkb= dev->key->xkbInfo->desc;
|
||||
sli->physIndicators= xkb->indicators->phys_indicators;
|
||||
if (xkb->names->indicators!=sli->names) {
|
||||
checkNames= True;
|
||||
sli->names= xkb->names->indicators;
|
||||
}
|
||||
if (xkb->indicators->maps!=sli->maps) {
|
||||
checkAccel= True;
|
||||
sli->maps= xkb->indicators->maps;
|
||||
}
|
||||
}
|
||||
else if ((lf!=NULL)&&(lf->xkb_sli==NULL)) {
|
||||
lf->xkb_sli= sli= _XkbTypedCalloc(1,XkbSrvLedInfoRec);
|
||||
if (sli==NULL)
|
||||
return NULL; /* ALLOCATION ERROR */
|
||||
if (dev->key && dev->key->xkbInfo)
|
||||
sli->flags= XkbSLI_HasOwnState;
|
||||
else sli->flags= 0;
|
||||
sli->class= LedFeedbackClass;
|
||||
sli->id= lf->ctrl.id;
|
||||
sli->fb.lf= lf;
|
||||
|
||||
sli->physIndicators= lf->ctrl.led_mask;
|
||||
sli->autoState= 0;
|
||||
sli->explicitState= lf->ctrl.led_values;
|
||||
sli->effectiveState= lf->ctrl.led_values;
|
||||
sli->maps= NULL;
|
||||
sli->names= NULL;
|
||||
}
|
||||
if ((sli->names==NULL)&&(needed_parts&XkbXI_IndicatorNamesMask))
|
||||
sli->names= _XkbTypedCalloc(XkbNumIndicators,Atom);
|
||||
if ((sli->maps==NULL)&&(needed_parts&XkbXI_IndicatorMapsMask))
|
||||
sli->maps= _XkbTypedCalloc(XkbNumIndicators,XkbIndicatorMapRec);
|
||||
if (checkNames) {
|
||||
register unsigned i,bit;
|
||||
sli->namesPresent= 0;
|
||||
for (i=0,bit=1;i<XkbNumIndicators;i++,bit<<=1) {
|
||||
if (sli->names[i]!=None)
|
||||
sli->namesPresent|= bit;
|
||||
}
|
||||
}
|
||||
if (checkAccel)
|
||||
XkbCheckIndicatorMaps(dev,sli,XkbAllIndicatorsMask);
|
||||
return sli;
|
||||
}
|
||||
|
||||
void
|
||||
XkbFreeSrvLedInfo(XkbSrvLedInfoPtr sli)
|
||||
{
|
||||
if ((sli->flags&XkbSLI_IsDefault)==0) {
|
||||
if (sli->maps) _XkbFree(sli->maps);
|
||||
if (sli->names) _XkbFree(sli->names);
|
||||
}
|
||||
sli->maps= NULL;
|
||||
sli->names= NULL;
|
||||
_XkbFree(sli);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
/*
|
||||
* XkbSrvLedInfoPtr
|
||||
* XkbFindSrvLedInfo(dev,class,id,needed_parts)
|
||||
*
|
||||
* Finds the XkbSrvLedInfoPtr for the specified 'class' and 'id'
|
||||
* on the device specified by 'dev.' If the class and id specify
|
||||
* a valid device feedback, this function returns the existing
|
||||
* feedback or allocates a new one.
|
||||
*
|
||||
*/
|
||||
|
||||
XkbSrvLedInfoPtr
|
||||
XkbFindSrvLedInfo( DeviceIntPtr dev,
|
||||
unsigned class,
|
||||
unsigned id,
|
||||
unsigned needed_parts)
|
||||
{
|
||||
XkbSrvLedInfoPtr sli;
|
||||
|
||||
/* optimization to check for most common case */
|
||||
if (((class==XkbDfltXIClass)&&(id==XkbDfltXIId))&&(dev->kbdfeed)) {
|
||||
if (dev->kbdfeed->xkb_sli==NULL) {
|
||||
dev->kbdfeed->xkb_sli=
|
||||
XkbAllocSrvLedInfo(dev,dev->kbdfeed,NULL,needed_parts);
|
||||
}
|
||||
return dev->kbdfeed->xkb_sli;
|
||||
}
|
||||
|
||||
sli= NULL;
|
||||
if (class==XkbDfltXIClass) {
|
||||
if (dev->kbdfeed) class= KbdFeedbackClass;
|
||||
else if (dev->leds) class= LedFeedbackClass;
|
||||
else return NULL;
|
||||
}
|
||||
if (class==KbdFeedbackClass) {
|
||||
KbdFeedbackPtr kf;
|
||||
for (kf=dev->kbdfeed;kf!=NULL;kf=kf->next) {
|
||||
if ((id==XkbDfltXIId)||(id==kf->ctrl.id)) {
|
||||
if (kf->xkb_sli==NULL)
|
||||
kf->xkb_sli= XkbAllocSrvLedInfo(dev,kf,NULL,needed_parts);
|
||||
sli= kf->xkb_sli;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (class==LedFeedbackClass) {
|
||||
LedFeedbackPtr lf;
|
||||
for (lf=dev->leds;lf!=NULL;lf=lf->next) {
|
||||
if ((id==XkbDfltXIId)||(id==lf->ctrl.id)) {
|
||||
if (lf->xkb_sli==NULL)
|
||||
lf->xkb_sli= XkbAllocSrvLedInfo(dev,NULL,lf,needed_parts);
|
||||
sli= lf->xkb_sli;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((sli->names==NULL)&&(needed_parts&XkbXI_IndicatorNamesMask))
|
||||
sli->names= _XkbTypedCalloc(XkbNumIndicators,Atom);
|
||||
if ((sli->maps==NULL)&&(needed_parts&XkbXI_IndicatorMapsMask))
|
||||
sli->maps= _XkbTypedCalloc(XkbNumIndicators,XkbIndicatorMapRec);
|
||||
return sli;
|
||||
}
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
void
|
||||
XkbFlushLedEvents( DeviceIntPtr dev,
|
||||
DeviceIntPtr kbd,
|
||||
XkbSrvLedInfoPtr sli,
|
||||
xkbExtensionDeviceNotify * ed,
|
||||
XkbChangesPtr changes,
|
||||
XkbEventCausePtr cause)
|
||||
{
|
||||
if (changes) {
|
||||
if (changes->indicators.state_changes)
|
||||
XkbDDXUpdateDeviceIndicators(dev,sli,sli->effectiveState);
|
||||
XkbSendNotification(kbd,changes,cause);
|
||||
bzero((char *)changes,sizeof(XkbChangesRec));
|
||||
|
||||
if (XkbAX_NeedFeedback(kbd->key->xkbInfo->desc->ctrls, XkbAX_IndicatorFBMask)) {
|
||||
if (sli->effectiveState)
|
||||
/* it appears that the which parameter is not used */
|
||||
XkbDDXAccessXBeep(dev, _BEEP_LED_ON, XkbAccessXFeedbackMask);
|
||||
else
|
||||
XkbDDXAccessXBeep(dev, _BEEP_LED_OFF, XkbAccessXFeedbackMask);
|
||||
}
|
||||
}
|
||||
if (ed && (ed->reason)) {
|
||||
if ((dev!=kbd)&&(ed->reason&XkbXI_IndicatorStateMask))
|
||||
XkbDDXUpdateDeviceIndicators(dev,sli,sli->effectiveState);
|
||||
XkbSendExtensionDeviceNotify(dev,cause->client,ed);
|
||||
}
|
||||
bzero((char *)ed,sizeof(XkbExtensionDeviceNotify));
|
||||
return;
|
||||
}
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
void
|
||||
XkbApplyLedNameChanges( DeviceIntPtr dev,
|
||||
XkbSrvLedInfoPtr sli,
|
||||
unsigned changed_names,
|
||||
xkbExtensionDeviceNotify * ed,
|
||||
XkbChangesPtr changes,
|
||||
XkbEventCausePtr cause)
|
||||
{
|
||||
DeviceIntPtr kbd;
|
||||
XkbChangesRec my_changes;
|
||||
xkbExtensionDeviceNotify my_ed;
|
||||
|
||||
if (changed_names==0)
|
||||
return;
|
||||
if (dev->key && dev->key->xkbInfo)
|
||||
kbd= dev;
|
||||
else kbd= (DeviceIntPtr)LookupKeyboardDevice();
|
||||
|
||||
if (ed==NULL) {
|
||||
ed= &my_ed;
|
||||
bzero((char *)ed,sizeof(xkbExtensionDeviceNotify));
|
||||
}
|
||||
else if ((ed->reason&XkbXI_IndicatorsMask)&&
|
||||
((ed->ledClass!=sli->class)||(ed->ledID!=sli->id))) {
|
||||
XkbFlushLedEvents(dev,kbd,sli,ed,changes,cause);
|
||||
}
|
||||
|
||||
if ((kbd==dev)&&(sli->flags&XkbSLI_IsDefault)) {
|
||||
if (changes==NULL) {
|
||||
changes= &my_changes;
|
||||
bzero((char *)changes,sizeof(XkbChangesRec));
|
||||
}
|
||||
changes->names.changed|= XkbIndicatorNamesMask;
|
||||
changes->names.changed_indicators|= changed_names;
|
||||
}
|
||||
|
||||
ed->reason|= (XkbXI_IndicatorNamesMask&(~XkbXI_KeyboardsMask));
|
||||
ed->ledClass= sli->class;
|
||||
ed->ledID= sli->id;
|
||||
ed->ledsDefined= sli->namesPresent|sli->mapsPresent;
|
||||
ed->ledState= sli->effectiveState;
|
||||
ed->unsupported= XkbXI_KeyboardsMask;
|
||||
ed->supported= XkbXI_AllFeaturesMask&(~XkbXI_KeyboardsMask);
|
||||
|
||||
if (changes!=&my_changes) changes= NULL;
|
||||
if (ed!=&my_ed) ed= NULL;
|
||||
if (changes || ed)
|
||||
XkbFlushLedEvents(dev,kbd,sli,ed,changes,cause);
|
||||
return;
|
||||
}
|
||||
/***====================================================================***/
|
||||
|
||||
/*
|
||||
* void
|
||||
* XkbApplyLedMapChanges(dev,sli,changed_maps,changes,cause)
|
||||
*
|
||||
* Handles all of the secondary effects of the changes to the
|
||||
* feedback specified by 'sli' on the device specified by 'dev.'
|
||||
*
|
||||
* If 'changed_maps' specifies any indicators, this function generates
|
||||
* XkbExtensionDeviceNotify events and possibly IndicatorMapNotify
|
||||
* events to report the changes, and recalculates the effective
|
||||
* state of each indicator with a changed map. If any indicators
|
||||
* change state, the server generates XkbExtensionDeviceNotify and
|
||||
* XkbIndicatorStateNotify events as appropriate.
|
||||
*
|
||||
* If 'changes' is non-NULL, this function updates it to reflect
|
||||
* any changes to the keyboard state or controls or to the 'core'
|
||||
* indicator names, maps, or state. If 'changes' is NULL, this
|
||||
* function generates XKB events as needed to report the changes.
|
||||
* If 'dev' is not a keyboard device, any changes are reported
|
||||
* for the core keyboard.
|
||||
*
|
||||
* The 'cause' specifies the reason for the event (key event or
|
||||
* request) for the change, as reported in some XKB events.
|
||||
*/
|
||||
|
||||
void
|
||||
XkbApplyLedMapChanges( DeviceIntPtr dev,
|
||||
XkbSrvLedInfoPtr sli,
|
||||
unsigned changed_maps,
|
||||
xkbExtensionDeviceNotify * ed,
|
||||
XkbChangesPtr changes,
|
||||
XkbEventCausePtr cause)
|
||||
{
|
||||
DeviceIntPtr kbd;
|
||||
XkbChangesRec my_changes;
|
||||
xkbExtensionDeviceNotify my_ed;
|
||||
|
||||
if (changed_maps==0)
|
||||
return;
|
||||
if (dev->key && dev->key->xkbInfo)
|
||||
kbd= dev;
|
||||
else kbd= (DeviceIntPtr)LookupKeyboardDevice();
|
||||
|
||||
if (ed==NULL) {
|
||||
ed= &my_ed;
|
||||
bzero((char *)ed,sizeof(xkbExtensionDeviceNotify));
|
||||
}
|
||||
else if ((ed->reason&XkbXI_IndicatorsMask)&&
|
||||
((ed->ledClass!=sli->class)||(ed->ledID!=sli->id))) {
|
||||
XkbFlushLedEvents(dev,kbd,sli,ed,changes,cause);
|
||||
}
|
||||
|
||||
if ((kbd==dev)&&(sli->flags&XkbSLI_IsDefault)) {
|
||||
if (changes==NULL) {
|
||||
changes= &my_changes;
|
||||
bzero((char *)changes,sizeof(XkbChangesRec));
|
||||
}
|
||||
changes->indicators.map_changes|= changed_maps;
|
||||
}
|
||||
|
||||
XkbCheckIndicatorMaps(dev,sli,changed_maps);
|
||||
|
||||
ed->reason|= (XkbXI_IndicatorMapsMask&(~XkbXI_KeyboardsMask));
|
||||
ed->ledClass= sli->class;
|
||||
ed->ledID= sli->id;
|
||||
ed->ledsDefined= sli->namesPresent|sli->mapsPresent;
|
||||
ed->ledState= sli->effectiveState;
|
||||
ed->unsupported|= XkbXI_KeyboardsMask&XkbXI_IndicatorMapsMask;
|
||||
ed->supported= XkbXI_AllFeaturesMask&(~XkbXI_KeyboardsMask);
|
||||
|
||||
XkbUpdateLedAutoState(dev,sli,changed_maps,ed,changes,cause);
|
||||
|
||||
if (changes!=&my_changes) changes= NULL;
|
||||
if (ed!=&my_ed) ed= NULL;
|
||||
if (changes || ed)
|
||||
XkbFlushLedEvents(dev,kbd,sli,ed,changes,cause);
|
||||
return;
|
||||
}
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
void
|
||||
XkbApplyLedStateChanges(DeviceIntPtr dev,
|
||||
XkbSrvLedInfoPtr sli,
|
||||
unsigned changed_leds,
|
||||
xkbExtensionDeviceNotify * ed,
|
||||
XkbChangesPtr changes,
|
||||
XkbEventCausePtr cause)
|
||||
{
|
||||
XkbSrvInfoPtr xkbi;
|
||||
DeviceIntPtr kbd;
|
||||
XkbChangesRec my_changes;
|
||||
xkbExtensionDeviceNotify my_ed;
|
||||
register unsigned i,bit,affected;
|
||||
XkbIndicatorMapPtr map;
|
||||
unsigned oldState;
|
||||
Bool kb_changed;
|
||||
|
||||
if (changed_leds==0)
|
||||
return;
|
||||
if (dev->key && dev->key->xkbInfo)
|
||||
kbd= dev;
|
||||
else kbd= (DeviceIntPtr)LookupKeyboardDevice();
|
||||
xkbi= kbd->key->xkbInfo;
|
||||
|
||||
if (changes==NULL) {
|
||||
changes= &my_changes;
|
||||
bzero((char *)changes,sizeof(XkbChangesRec));
|
||||
}
|
||||
|
||||
kb_changed= False;
|
||||
affected= changed_leds;
|
||||
oldState= sli->effectiveState;
|
||||
for (i=0,bit=1;(i<XkbNumIndicators)&&(affected);i++,bit<<=1) {
|
||||
if ((affected&bit)==0)
|
||||
continue;
|
||||
affected&= ~bit;
|
||||
map= &sli->maps[i];
|
||||
if (map->flags&XkbIM_NoExplicit) {
|
||||
sli->explicitState&= ~bit;
|
||||
continue;
|
||||
}
|
||||
if (map->flags&XkbIM_LEDDrivesKB) {
|
||||
Bool on= ((sli->explicitState&bit)!=0);
|
||||
if (XkbApplyLEDChangeToKeyboard(xkbi,map,on,changes))
|
||||
kb_changed= True;
|
||||
}
|
||||
}
|
||||
sli->effectiveState= (sli->autoState|sli->explicitState);
|
||||
affected= sli->effectiveState^oldState;
|
||||
|
||||
if (ed==NULL) {
|
||||
ed= &my_ed;
|
||||
bzero((char *)ed,sizeof(xkbExtensionDeviceNotify));
|
||||
}
|
||||
else if (affected&&(ed->reason&XkbXI_IndicatorsMask)&&
|
||||
((ed->ledClass!=sli->class)||(ed->ledID!=sli->id))) {
|
||||
XkbFlushLedEvents(dev,kbd,sli,ed,changes,cause);
|
||||
}
|
||||
|
||||
if ((kbd==dev)&&(sli->flags&XkbSLI_IsDefault))
|
||||
changes->indicators.state_changes|= affected;
|
||||
if (affected) {
|
||||
ed->reason|= (XkbXI_IndicatorStateMask&(~XkbXI_KeyboardsMask));
|
||||
ed->ledClass= sli->class;
|
||||
ed->ledID= sli->id;
|
||||
ed->ledsDefined= sli->namesPresent|sli->mapsPresent;
|
||||
ed->ledState= sli->effectiveState;
|
||||
ed->unsupported|= XkbXI_KeyboardsMask&XkbXI_IndicatorStateMask;
|
||||
ed->supported= XkbXI_AllFeaturesMask&(~XkbXI_KeyboardsMask);
|
||||
}
|
||||
|
||||
if (kb_changed) {
|
||||
XkbComputeDerivedState(kbd->key->xkbInfo);
|
||||
XkbUpdateLedAutoState(dev,sli,sli->mapsPresent,ed,changes,cause);
|
||||
}
|
||||
|
||||
if (changes!=&my_changes) changes= NULL;
|
||||
if (ed!=&my_ed) ed= NULL;
|
||||
if (changes || ed)
|
||||
XkbFlushLedEvents(dev,kbd,sli,ed,changes,cause);
|
||||
if (kb_changed)
|
||||
XkbUpdateAllDeviceIndicators(NULL,cause);
|
||||
return;
|
||||
}
|
||||
|
||||
/***====================================================================***/
|
||||
179
nx-X11/programs/Xserver/xkb/xkbPrKeyEv.c
Normal file
179
nx-X11/programs/Xserver/xkb/xkbPrKeyEv.c
Normal file
@@ -0,0 +1,179 @@
|
||||
/************************************************************
|
||||
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_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <nx-X11/X.h>
|
||||
#include <nx-X11/Xproto.h>
|
||||
#include <nx-X11/keysym.h>
|
||||
#include "misc.h"
|
||||
#include "inputstr.h"
|
||||
#include <xkbsrv.h>
|
||||
#include <ctype.h>
|
||||
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
void
|
||||
XkbProcessKeyboardEvent(xEvent *xE,DeviceIntPtr keybd,int count)
|
||||
{
|
||||
KeyClassPtr keyc = keybd->key;
|
||||
XkbSrvInfoPtr xkbi;
|
||||
int key;
|
||||
XkbBehavior behavior;
|
||||
unsigned ndx;
|
||||
|
||||
xkbi= keyc->xkbInfo;
|
||||
key= xE->u.u.detail;
|
||||
if (xkbDebugFlags&0x8) {
|
||||
DebugF("XkbPKE: Key %d %s\n",key,(xE->u.u.type==KeyPress?"down":"up"));
|
||||
}
|
||||
|
||||
if ( (xkbi->repeatKey==key) && (xE->u.u.type==KeyRelease) &&
|
||||
((xkbi->desc->ctrls->enabled_ctrls&XkbRepeatKeysMask)==0) ) {
|
||||
AccessXCancelRepeatKey(xkbi,key);
|
||||
}
|
||||
|
||||
behavior= xkbi->desc->server->behaviors[key];
|
||||
/* The "permanent" flag indicates a hard-wired behavior that occurs */
|
||||
/* below XKB, such as a key that physically locks. XKB does not */
|
||||
/* do anything to implement the behavior, but it *does* report that */
|
||||
/* key is hardwired */
|
||||
if ((behavior.type&XkbKB_Permanent)==0) {
|
||||
switch (behavior.type) {
|
||||
case XkbKB_Default:
|
||||
if (( xE->u.u.type == KeyPress ) &&
|
||||
(keyc->down[key>>3] & (1<<(key&7)))) {
|
||||
XkbLastRepeatEvent= (void *)xE;
|
||||
xE->u.u.type = KeyRelease;
|
||||
XkbHandleActions(keybd,keybd,xE,count);
|
||||
xE->u.u.type = KeyPress;
|
||||
XkbHandleActions(keybd,keybd,xE,count);
|
||||
XkbLastRepeatEvent= NULL;
|
||||
return;
|
||||
}
|
||||
else if ((xE->u.u.type==KeyRelease) &&
|
||||
(!(keyc->down[key>>3]&(1<<(key&7))))) {
|
||||
XkbLastRepeatEvent= (void *)&xE;
|
||||
xE->u.u.type = KeyPress;
|
||||
XkbHandleActions(keybd,keybd,xE,count);
|
||||
xE->u.u.type = KeyRelease;
|
||||
XkbHandleActions(keybd,keybd,xE,count);
|
||||
XkbLastRepeatEvent= NULL;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case XkbKB_Lock:
|
||||
if ( xE->u.u.type == KeyRelease )
|
||||
return;
|
||||
else {
|
||||
int bit= 1<<(key&7);
|
||||
if ( keyc->down[key>>3]&bit )
|
||||
xE->u.u.type= KeyRelease;
|
||||
}
|
||||
break;
|
||||
case XkbKB_RadioGroup:
|
||||
ndx= (behavior.data&(~XkbKB_RGAllowNone));
|
||||
if ( ndx<xkbi->nRadioGroups ) {
|
||||
XkbRadioGroupPtr rg;
|
||||
|
||||
if ( xE->u.u.type == KeyRelease )
|
||||
return;
|
||||
|
||||
rg = &xkbi->radioGroups[ndx];
|
||||
if ( rg->currentDown == xE->u.u.detail ) {
|
||||
if (behavior.data&XkbKB_RGAllowNone) {
|
||||
xE->u.u.type = KeyRelease;
|
||||
XkbHandleActions(keybd,keybd,xE,count);
|
||||
rg->currentDown= 0;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if ( rg->currentDown!=0 ) {
|
||||
int tmpkey = xE->u.u.detail;
|
||||
xE->u.u.type= KeyRelease;
|
||||
xE->u.u.detail= rg->currentDown;
|
||||
XkbHandleActions(keybd,keybd,xE,count);
|
||||
xE->u.u.type= KeyPress;
|
||||
xE->u.u.detail= tmpkey;
|
||||
}
|
||||
rg->currentDown= key;
|
||||
}
|
||||
else ErrorF("InternalError! Illegal radio group %d\n",ndx);
|
||||
break;
|
||||
case XkbKB_Overlay1: case XkbKB_Overlay2:
|
||||
{
|
||||
unsigned which;
|
||||
if (behavior.type==XkbKB_Overlay1) which= XkbOverlay1Mask;
|
||||
else which= XkbOverlay2Mask;
|
||||
if ( (xkbi->desc->ctrls->enabled_ctrls&which)==0 )
|
||||
break;
|
||||
if ((behavior.data>=xkbi->desc->min_key_code)&&
|
||||
(behavior.data<=xkbi->desc->max_key_code)) {
|
||||
xE->u.u.detail= behavior.data;
|
||||
/* 9/11/94 (ef) -- XXX! need to match release with */
|
||||
/* press even if the state of the */
|
||||
/* corresponding overlay control */
|
||||
/* changes while the key is down */
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ErrorF("unknown key behavior 0x%04x\n",behavior.type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
XkbHandleActions(keybd,keybd,xE,count);
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
ProcessKeyboardEvent(xEvent *xE,DeviceIntPtr keybd,int count)
|
||||
{
|
||||
KeyClassPtr keyc = keybd->key;
|
||||
XkbSrvInfoPtr xkbi;
|
||||
|
||||
xkbi= keyc->xkbInfo;
|
||||
|
||||
#ifdef DEBUG
|
||||
if (xkbDebugFlags&0x8) {
|
||||
int key= xE->u.u.detail;
|
||||
ErrorF("PKE: Key %d %s\n",key,(xE->u.u.type==KeyPress?"down":"up"));
|
||||
}
|
||||
#endif
|
||||
if ((xkbi->desc->ctrls->enabled_ctrls&XkbAllFilteredEventsMask)==0)
|
||||
XkbProcessKeyboardEvent(xE,keybd,count);
|
||||
else if (xE->u.u.type==KeyPress)
|
||||
AccessXFilterPressEvent(xE,keybd,count);
|
||||
else if (xE->u.u.type==KeyRelease)
|
||||
AccessXFilterReleaseEvent(xE,keybd,count);
|
||||
return;
|
||||
}
|
||||
|
||||
81
nx-X11/programs/Xserver/xkb/xkbPrOtherEv.c
Normal file
81
nx-X11/programs/Xserver/xkb/xkbPrOtherEv.c
Normal file
@@ -0,0 +1,81 @@
|
||||
/************************************************************
|
||||
Copyright (c) 1995 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_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <nx-X11/X.h>
|
||||
#include <nx-X11/Xproto.h>
|
||||
#include <nx-X11/keysym.h>
|
||||
#include "misc.h"
|
||||
#include "inputstr.h"
|
||||
#include <xkbsrv.h>
|
||||
|
||||
#include <nx-X11/extensions/XI.h>
|
||||
#include <nx-X11/extensions/XIproto.h>
|
||||
|
||||
extern void ProcessOtherEvent(
|
||||
xEvent * /* xE */,
|
||||
DeviceIntPtr /* dev */,
|
||||
int /* count */
|
||||
);
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
void
|
||||
XkbProcessOtherEvent(xEvent *xE,DeviceIntPtr dev,int count)
|
||||
{
|
||||
Bool xkbCares,isBtn;
|
||||
|
||||
xkbCares= True;
|
||||
isBtn= False;
|
||||
switch ( xE->u.u.type ) {
|
||||
case KeyPress: xE->u.u.type= DeviceKeyPress; break;
|
||||
case KeyRelease: xE->u.u.type= DeviceKeyRelease; break;
|
||||
case ButtonPress: xE->u.u.type= DeviceButtonPress;
|
||||
isBtn= True;
|
||||
break;
|
||||
case ButtonRelease: xE->u.u.type= DeviceButtonRelease;
|
||||
isBtn= True;
|
||||
break;
|
||||
default: xkbCares= False; break;
|
||||
}
|
||||
if (xkbCares) {
|
||||
if ((!isBtn)||((dev->button)&&(dev->button->xkb_acts))) {
|
||||
DeviceIntPtr kbd;
|
||||
if (dev->key) kbd= dev;
|
||||
else kbd= (DeviceIntPtr)LookupKeyboardDevice();
|
||||
XkbHandleActions(dev,kbd,xE,count);
|
||||
return;
|
||||
}
|
||||
}
|
||||
ProcessOtherEvent(xE,dev,count);
|
||||
return;
|
||||
}
|
||||
|
||||
543
nx-X11/programs/Xserver/xkb/xkbSwap.c
Normal file
543
nx-X11/programs/Xserver/xkb/xkbSwap.c
Normal file
@@ -0,0 +1,543 @@
|
||||
/************************************************************
|
||||
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_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#include "stdio.h"
|
||||
#include <nx-X11/X.h>
|
||||
#include <nx-X11/Xproto.h>
|
||||
#include "misc.h"
|
||||
#include "inputstr.h"
|
||||
#include <xkbsrv.h>
|
||||
#include "xkbstr.h"
|
||||
#include "extnsionst.h"
|
||||
#include "xkb.h"
|
||||
|
||||
/*
|
||||
* REQUEST SWAPPING
|
||||
*/
|
||||
static int
|
||||
SProcXkbUseExtension(ClientPtr client)
|
||||
{
|
||||
|
||||
REQUEST(xkbUseExtensionReq);
|
||||
|
||||
swaps(&stuff->length);
|
||||
REQUEST_SIZE_MATCH(xkbUseExtensionReq);
|
||||
swaps(&stuff->wantedMajor);
|
||||
swaps(&stuff->wantedMinor);
|
||||
return ProcXkbUseExtension(client);
|
||||
}
|
||||
|
||||
static int
|
||||
SProcXkbSelectEvents(ClientPtr client)
|
||||
{
|
||||
|
||||
REQUEST(xkbSelectEventsReq);
|
||||
|
||||
swaps(&stuff->length);
|
||||
REQUEST_AT_LEAST_SIZE(xkbSelectEventsReq);
|
||||
swaps(&stuff->deviceSpec);
|
||||
swaps(&stuff->affectWhich);
|
||||
swaps(&stuff->clear);
|
||||
swaps(&stuff->selectAll);
|
||||
swaps(&stuff->affectMap);
|
||||
swaps(&stuff->map);
|
||||
if ((stuff->affectWhich&(~XkbMapNotifyMask))!=0) {
|
||||
union {
|
||||
BOOL *b;
|
||||
CARD8 *c8;
|
||||
CARD16 *c16;
|
||||
CARD32 *c32;
|
||||
} from;
|
||||
register unsigned bit,ndx,maskLeft,dataLeft,size;
|
||||
|
||||
from.c8= (CARD8 *)&stuff[1];
|
||||
dataLeft= (stuff->length*4)-SIZEOF(xkbSelectEventsReq);
|
||||
maskLeft= (stuff->affectWhich&(~XkbMapNotifyMask));
|
||||
for (ndx=0,bit=1; (maskLeft!=0); ndx++, bit<<=1) {
|
||||
if (((bit&maskLeft)==0)||(ndx==XkbMapNotify))
|
||||
continue;
|
||||
maskLeft&= ~bit;
|
||||
if ((stuff->selectAll&bit)||(stuff->clear&bit))
|
||||
continue;
|
||||
switch (ndx) {
|
||||
case XkbNewKeyboardNotify:
|
||||
case XkbStateNotify:
|
||||
case XkbNamesNotify:
|
||||
case XkbAccessXNotify:
|
||||
case XkbExtensionDeviceNotify:
|
||||
size= 2;
|
||||
break;
|
||||
case XkbControlsNotify:
|
||||
case XkbIndicatorStateNotify:
|
||||
case XkbIndicatorMapNotify:
|
||||
size= 4;
|
||||
break;
|
||||
case XkbBellNotify:
|
||||
case XkbActionMessage:
|
||||
case XkbCompatMapNotify:
|
||||
size= 1;
|
||||
break;
|
||||
default:
|
||||
client->errorValue = _XkbErrCode2(0x1,bit);
|
||||
return BadValue;
|
||||
}
|
||||
if (dataLeft<(size*2))
|
||||
return BadLength;
|
||||
if (size==2) {
|
||||
swaps(&from.c16[0]);
|
||||
swaps(&from.c16[1]);
|
||||
}
|
||||
else if (size==4) {
|
||||
swapl(&from.c32[0]);
|
||||
swapl(&from.c32[1]);
|
||||
}
|
||||
else {
|
||||
size= 2;
|
||||
}
|
||||
from.c8+= (size*2);
|
||||
dataLeft-= (size*2);
|
||||
}
|
||||
if (dataLeft>2) {
|
||||
ErrorF("Extra data (%d bytes) after SelectEvents\n",dataLeft);
|
||||
return BadLength;
|
||||
}
|
||||
}
|
||||
return ProcXkbSelectEvents(client);
|
||||
}
|
||||
|
||||
static int
|
||||
SProcXkbBell(ClientPtr client)
|
||||
{
|
||||
REQUEST(xkbBellReq);
|
||||
|
||||
swaps(&stuff->length);
|
||||
REQUEST_SIZE_MATCH(xkbBellReq);
|
||||
swaps(&stuff->deviceSpec);
|
||||
swaps(&stuff->bellClass);
|
||||
swaps(&stuff->bellID);
|
||||
swapl(&stuff->name);
|
||||
swapl(&stuff->window);
|
||||
swaps(&stuff->pitch);
|
||||
swaps(&stuff->duration);
|
||||
return ProcXkbBell(client);
|
||||
}
|
||||
|
||||
static int
|
||||
SProcXkbGetState(ClientPtr client)
|
||||
{
|
||||
REQUEST(xkbGetStateReq);
|
||||
|
||||
swaps(&stuff->length);
|
||||
REQUEST_SIZE_MATCH(xkbGetStateReq);
|
||||
swaps(&stuff->deviceSpec);
|
||||
return ProcXkbGetState(client);
|
||||
}
|
||||
|
||||
static int
|
||||
SProcXkbLatchLockState(ClientPtr client)
|
||||
{
|
||||
REQUEST(xkbLatchLockStateReq);
|
||||
|
||||
swaps(&stuff->length);
|
||||
REQUEST_SIZE_MATCH(xkbLatchLockStateReq);
|
||||
swaps(&stuff->deviceSpec);
|
||||
swaps(&stuff->groupLatch);
|
||||
return ProcXkbLatchLockState(client);
|
||||
}
|
||||
|
||||
static int
|
||||
SProcXkbGetControls(ClientPtr client)
|
||||
{
|
||||
REQUEST(xkbGetControlsReq);
|
||||
|
||||
swaps(&stuff->length);
|
||||
REQUEST_SIZE_MATCH(xkbGetControlsReq);
|
||||
swaps(&stuff->deviceSpec);
|
||||
return ProcXkbGetControls(client);
|
||||
}
|
||||
|
||||
static int
|
||||
SProcXkbSetControls(ClientPtr client)
|
||||
{
|
||||
REQUEST(xkbSetControlsReq);
|
||||
|
||||
swaps(&stuff->length);
|
||||
REQUEST_SIZE_MATCH(xkbSetControlsReq);
|
||||
swaps(&stuff->deviceSpec);
|
||||
swaps(&stuff->affectInternalVMods);
|
||||
swaps(&stuff->internalVMods);
|
||||
swaps(&stuff->affectIgnoreLockVMods);
|
||||
swaps(&stuff->ignoreLockVMods);
|
||||
swaps(&stuff->axOptions);
|
||||
swapl(&stuff->affectEnabledCtrls);
|
||||
swapl(&stuff->enabledCtrls);
|
||||
swapl(&stuff->changeCtrls);
|
||||
swaps(&stuff->repeatDelay);
|
||||
swaps(&stuff->repeatInterval);
|
||||
swaps(&stuff->slowKeysDelay);
|
||||
swaps(&stuff->debounceDelay);
|
||||
swaps(&stuff->mkDelay);
|
||||
swaps(&stuff->mkInterval);
|
||||
swaps(&stuff->mkTimeToMax);
|
||||
swaps(&stuff->mkMaxSpeed);
|
||||
swaps(&stuff->mkCurve);
|
||||
swaps(&stuff->axTimeout);
|
||||
swapl(&stuff->axtCtrlsMask);
|
||||
swapl(&stuff->axtCtrlsValues);
|
||||
swaps(&stuff->axtOptsMask);
|
||||
swaps(&stuff->axtOptsValues);
|
||||
return ProcXkbSetControls(client);
|
||||
}
|
||||
|
||||
static int
|
||||
SProcXkbGetMap(ClientPtr client)
|
||||
{
|
||||
REQUEST(xkbGetMapReq);
|
||||
|
||||
swaps(&stuff->length);
|
||||
REQUEST_SIZE_MATCH(xkbGetMapReq);
|
||||
swaps(&stuff->deviceSpec);
|
||||
swaps(&stuff->full);
|
||||
swaps(&stuff->partial);
|
||||
swaps(&stuff->virtualMods);
|
||||
return ProcXkbGetMap(client);
|
||||
}
|
||||
|
||||
static int
|
||||
SProcXkbSetMap(ClientPtr client)
|
||||
{
|
||||
REQUEST(xkbSetMapReq);
|
||||
|
||||
swaps(&stuff->length);
|
||||
REQUEST_AT_LEAST_SIZE(xkbSetMapReq);
|
||||
swaps(&stuff->deviceSpec);
|
||||
swaps(&stuff->present);
|
||||
swaps(&stuff->flags);
|
||||
swaps(&stuff->totalSyms);
|
||||
swaps(&stuff->totalActs);
|
||||
swaps(&stuff->virtualMods);
|
||||
return ProcXkbSetMap(client);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
SProcXkbGetCompatMap(ClientPtr client)
|
||||
{
|
||||
REQUEST(xkbGetCompatMapReq);
|
||||
|
||||
swaps(&stuff->length);
|
||||
REQUEST_SIZE_MATCH(xkbGetCompatMapReq);
|
||||
swaps(&stuff->deviceSpec);
|
||||
swaps(&stuff->firstSI);
|
||||
swaps(&stuff->nSI);
|
||||
return ProcXkbGetCompatMap(client);
|
||||
}
|
||||
|
||||
static int
|
||||
SProcXkbSetCompatMap(ClientPtr client)
|
||||
{
|
||||
REQUEST(xkbSetCompatMapReq);
|
||||
|
||||
swaps(&stuff->length);
|
||||
REQUEST_AT_LEAST_SIZE(xkbSetCompatMapReq);
|
||||
swaps(&stuff->deviceSpec);
|
||||
swaps(&stuff->firstSI);
|
||||
swaps(&stuff->nSI);
|
||||
return ProcXkbSetCompatMap(client);
|
||||
}
|
||||
|
||||
static int
|
||||
SProcXkbGetIndicatorState(ClientPtr client)
|
||||
{
|
||||
REQUEST(xkbGetIndicatorStateReq);
|
||||
|
||||
swaps(&stuff->length);
|
||||
REQUEST_SIZE_MATCH(xkbGetIndicatorStateReq);
|
||||
swaps(&stuff->deviceSpec);
|
||||
return ProcXkbGetIndicatorState(client);
|
||||
}
|
||||
|
||||
static int
|
||||
SProcXkbGetIndicatorMap(ClientPtr client)
|
||||
{
|
||||
REQUEST(xkbGetIndicatorMapReq);
|
||||
|
||||
swaps(&stuff->length);
|
||||
REQUEST_SIZE_MATCH(xkbGetIndicatorMapReq);
|
||||
swaps(&stuff->deviceSpec);
|
||||
swapl(&stuff->which);
|
||||
return ProcXkbGetIndicatorMap(client);
|
||||
}
|
||||
|
||||
static int
|
||||
SProcXkbSetIndicatorMap(ClientPtr client)
|
||||
{
|
||||
REQUEST(xkbSetIndicatorMapReq);
|
||||
|
||||
swaps(&stuff->length);
|
||||
REQUEST_AT_LEAST_SIZE(xkbSetIndicatorMapReq);
|
||||
swaps(&stuff->deviceSpec);
|
||||
swapl(&stuff->which);
|
||||
return ProcXkbSetIndicatorMap(client);
|
||||
}
|
||||
|
||||
static int
|
||||
SProcXkbGetNamedIndicator(ClientPtr client)
|
||||
{
|
||||
REQUEST(xkbGetNamedIndicatorReq);
|
||||
|
||||
swaps(&stuff->length);
|
||||
REQUEST_SIZE_MATCH(xkbGetNamedIndicatorReq);
|
||||
swaps(&stuff->deviceSpec);
|
||||
swaps(&stuff->ledClass);
|
||||
swaps(&stuff->ledID);
|
||||
swapl(&stuff->indicator);
|
||||
return ProcXkbGetNamedIndicator(client);
|
||||
}
|
||||
|
||||
static int
|
||||
SProcXkbSetNamedIndicator(ClientPtr client)
|
||||
{
|
||||
REQUEST(xkbSetNamedIndicatorReq);
|
||||
|
||||
swaps(&stuff->length);
|
||||
REQUEST_SIZE_MATCH(xkbSetNamedIndicatorReq);
|
||||
swaps(&stuff->deviceSpec);
|
||||
swaps(&stuff->ledClass);
|
||||
swaps(&stuff->ledID);
|
||||
swapl(&stuff->indicator);
|
||||
swaps(&stuff->virtualMods);
|
||||
swapl(&stuff->ctrls);
|
||||
return ProcXkbSetNamedIndicator(client);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
SProcXkbGetNames(ClientPtr client)
|
||||
{
|
||||
REQUEST(xkbGetNamesReq);
|
||||
|
||||
swaps(&stuff->length);
|
||||
REQUEST_SIZE_MATCH(xkbGetNamesReq);
|
||||
swaps(&stuff->deviceSpec);
|
||||
swapl(&stuff->which);
|
||||
return ProcXkbGetNames(client);
|
||||
}
|
||||
|
||||
static int
|
||||
SProcXkbSetNames(ClientPtr client)
|
||||
{
|
||||
REQUEST(xkbSetNamesReq);
|
||||
|
||||
swaps(&stuff->length);
|
||||
REQUEST_AT_LEAST_SIZE(xkbSetNamesReq);
|
||||
swaps(&stuff->deviceSpec);
|
||||
swaps(&stuff->virtualMods);
|
||||
swapl(&stuff->which);
|
||||
swapl(&stuff->indicators);
|
||||
swaps(&stuff->totalKTLevelNames);
|
||||
return ProcXkbSetNames(client);
|
||||
}
|
||||
|
||||
static int
|
||||
SProcXkbGetGeometry(ClientPtr client)
|
||||
{
|
||||
REQUEST(xkbGetGeometryReq);
|
||||
|
||||
swaps(&stuff->length);
|
||||
REQUEST_SIZE_MATCH(xkbGetGeometryReq);
|
||||
swaps(&stuff->deviceSpec);
|
||||
swapl(&stuff->name);
|
||||
return ProcXkbGetGeometry(client);
|
||||
}
|
||||
|
||||
static int
|
||||
SProcXkbSetGeometry(ClientPtr client)
|
||||
{
|
||||
REQUEST(xkbSetGeometryReq);
|
||||
|
||||
swaps(&stuff->length);
|
||||
REQUEST_AT_LEAST_SIZE(xkbSetGeometryReq);
|
||||
swaps(&stuff->deviceSpec);
|
||||
swapl(&stuff->name);
|
||||
swaps(&stuff->widthMM);
|
||||
swaps(&stuff->heightMM);
|
||||
swaps(&stuff->nProperties);
|
||||
swaps(&stuff->nColors);
|
||||
swaps(&stuff->nDoodads);
|
||||
swaps(&stuff->nKeyAliases);
|
||||
return ProcXkbSetGeometry(client);
|
||||
}
|
||||
|
||||
static int
|
||||
SProcXkbPerClientFlags(ClientPtr client)
|
||||
{
|
||||
REQUEST(xkbPerClientFlagsReq);
|
||||
|
||||
swaps(&stuff->length);
|
||||
REQUEST_SIZE_MATCH(xkbPerClientFlagsReq);
|
||||
swaps(&stuff->deviceSpec);
|
||||
swapl(&stuff->change);
|
||||
swapl(&stuff->value);
|
||||
swapl(&stuff->ctrlsToChange);
|
||||
swapl(&stuff->autoCtrls);
|
||||
swapl(&stuff->autoCtrlValues);
|
||||
return ProcXkbPerClientFlags(client);
|
||||
}
|
||||
|
||||
static int
|
||||
SProcXkbListComponents(ClientPtr client)
|
||||
{
|
||||
REQUEST(xkbListComponentsReq);
|
||||
|
||||
swaps(&stuff->length);
|
||||
REQUEST_AT_LEAST_SIZE(xkbListComponentsReq);
|
||||
swaps(&stuff->deviceSpec);
|
||||
swaps(&stuff->maxNames);
|
||||
return ProcXkbListComponents(client);
|
||||
}
|
||||
|
||||
static int
|
||||
SProcXkbGetKbdByName(ClientPtr client)
|
||||
{
|
||||
REQUEST(xkbGetKbdByNameReq);
|
||||
|
||||
swaps(&stuff->length);
|
||||
REQUEST_AT_LEAST_SIZE(xkbGetKbdByNameReq);
|
||||
swaps(&stuff->deviceSpec);
|
||||
swaps(&stuff->want);
|
||||
swaps(&stuff->need);
|
||||
return ProcXkbGetKbdByName(client);
|
||||
}
|
||||
|
||||
static int
|
||||
SProcXkbGetDeviceInfo(ClientPtr client)
|
||||
{
|
||||
REQUEST(xkbGetDeviceInfoReq);
|
||||
|
||||
swaps(&stuff->length);
|
||||
REQUEST_SIZE_MATCH(xkbGetDeviceInfoReq);
|
||||
swaps(&stuff->deviceSpec);
|
||||
swaps(&stuff->wanted);
|
||||
swaps(&stuff->ledClass);
|
||||
swaps(&stuff->ledID);
|
||||
return ProcXkbGetDeviceInfo(client);
|
||||
}
|
||||
|
||||
static int
|
||||
SProcXkbSetDeviceInfo(ClientPtr client)
|
||||
{
|
||||
REQUEST(xkbSetDeviceInfoReq);
|
||||
|
||||
swaps(&stuff->length);
|
||||
REQUEST_AT_LEAST_SIZE(xkbSetDeviceInfoReq);
|
||||
swaps(&stuff->deviceSpec);
|
||||
swaps(&stuff->change);
|
||||
swaps(&stuff->nDeviceLedFBs);
|
||||
return ProcXkbSetDeviceInfo(client);
|
||||
}
|
||||
|
||||
static int
|
||||
SProcXkbSetDebuggingFlags(ClientPtr client)
|
||||
{
|
||||
REQUEST(xkbSetDebuggingFlagsReq);
|
||||
|
||||
swaps(&stuff->length);
|
||||
REQUEST_AT_LEAST_SIZE(xkbSetDebuggingFlagsReq);
|
||||
swapl(&stuff->affectFlags);
|
||||
swapl(&stuff->flags);
|
||||
swapl(&stuff->affectCtrls);
|
||||
swapl(&stuff->ctrls);
|
||||
swaps(&stuff->msgLength);
|
||||
return ProcXkbSetDebuggingFlags(client);
|
||||
}
|
||||
|
||||
int
|
||||
SProcXkbDispatch (ClientPtr client)
|
||||
{
|
||||
REQUEST(xReq);
|
||||
switch (stuff->data)
|
||||
{
|
||||
case X_kbUseExtension:
|
||||
return SProcXkbUseExtension(client);
|
||||
case X_kbSelectEvents:
|
||||
return SProcXkbSelectEvents(client);
|
||||
case X_kbBell:
|
||||
return SProcXkbBell(client);
|
||||
case X_kbGetState:
|
||||
return SProcXkbGetState(client);
|
||||
case X_kbLatchLockState:
|
||||
return SProcXkbLatchLockState(client);
|
||||
case X_kbGetControls:
|
||||
return SProcXkbGetControls(client);
|
||||
case X_kbSetControls:
|
||||
return SProcXkbSetControls(client);
|
||||
case X_kbGetMap:
|
||||
return SProcXkbGetMap(client);
|
||||
case X_kbSetMap:
|
||||
return SProcXkbSetMap(client);
|
||||
case X_kbGetCompatMap:
|
||||
return SProcXkbGetCompatMap(client);
|
||||
case X_kbSetCompatMap:
|
||||
return SProcXkbSetCompatMap(client);
|
||||
case X_kbGetIndicatorState:
|
||||
return SProcXkbGetIndicatorState(client);
|
||||
case X_kbGetIndicatorMap:
|
||||
return SProcXkbGetIndicatorMap(client);
|
||||
case X_kbSetIndicatorMap:
|
||||
return SProcXkbSetIndicatorMap(client);
|
||||
case X_kbGetNamedIndicator:
|
||||
return SProcXkbGetNamedIndicator(client);
|
||||
case X_kbSetNamedIndicator:
|
||||
return SProcXkbSetNamedIndicator(client);
|
||||
case X_kbGetNames:
|
||||
return SProcXkbGetNames(client);
|
||||
case X_kbSetNames:
|
||||
return SProcXkbSetNames(client);
|
||||
case X_kbGetGeometry:
|
||||
return SProcXkbGetGeometry(client);
|
||||
case X_kbSetGeometry:
|
||||
return SProcXkbSetGeometry(client);
|
||||
case X_kbPerClientFlags:
|
||||
return SProcXkbPerClientFlags(client);
|
||||
case X_kbListComponents:
|
||||
return SProcXkbListComponents(client);
|
||||
case X_kbGetKbdByName:
|
||||
return SProcXkbGetKbdByName(client);
|
||||
case X_kbGetDeviceInfo:
|
||||
return SProcXkbGetDeviceInfo(client);
|
||||
case X_kbSetDeviceInfo:
|
||||
return SProcXkbSetDeviceInfo(client);
|
||||
case X_kbSetDebuggingFlags:
|
||||
return SProcXkbSetDebuggingFlags(client);
|
||||
default:
|
||||
return BadRequest;
|
||||
}
|
||||
}
|
||||
910
nx-X11/programs/Xserver/xkb/xkbUtils.c
Normal file
910
nx-X11/programs/Xserver/xkb/xkbUtils.c
Normal file
@@ -0,0 +1,910 @@
|
||||
/************************************************************
|
||||
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_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <math.h>
|
||||
#include <nx-X11/X.h>
|
||||
#include <nx-X11/Xproto.h>
|
||||
#define XK_CYRILLIC
|
||||
#include <nx-X11/keysym.h>
|
||||
#include "misc.h"
|
||||
#include "inputstr.h"
|
||||
|
||||
#include <xkbsrv.h>
|
||||
#include "xkbgeom.h"
|
||||
#include "xkb.h"
|
||||
|
||||
#ifdef MODE_SWITCH
|
||||
extern Bool noKME; /* defined in os/utils.c */
|
||||
#endif
|
||||
|
||||
int XkbDisableLockActions = 0;
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
#ifndef RETURN_SHOULD_REPEAT
|
||||
#define RETURN_SHOULD_REPEAT 0
|
||||
#endif
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
DeviceIntPtr
|
||||
_XkbLookupAnyDevice(int id,int *why_rtrn)
|
||||
{
|
||||
DeviceIntPtr dev = NULL;
|
||||
|
||||
dev= (DeviceIntPtr)LookupKeyboardDevice();
|
||||
if ((id==XkbUseCoreKbd)||(dev->id==id))
|
||||
return dev;
|
||||
|
||||
dev= (DeviceIntPtr)LookupPointerDevice();
|
||||
if ((id==XkbUseCorePtr)||(dev->id==id))
|
||||
return dev;
|
||||
|
||||
if (id&(~0xff))
|
||||
dev = NULL;
|
||||
|
||||
dev= (DeviceIntPtr)LookupDevice(id);
|
||||
if (dev!=NULL)
|
||||
return dev;
|
||||
if ((!dev)&&(why_rtrn))
|
||||
*why_rtrn= XkbErr_BadDevice;
|
||||
return dev;
|
||||
}
|
||||
|
||||
DeviceIntPtr
|
||||
_XkbLookupKeyboard(int id,int *why_rtrn)
|
||||
{
|
||||
DeviceIntPtr dev = NULL;
|
||||
|
||||
if ((dev= _XkbLookupAnyDevice(id,why_rtrn))==NULL)
|
||||
return NULL;
|
||||
else if ((!dev->key)||(!dev->key->xkbInfo)) {
|
||||
if (why_rtrn)
|
||||
*why_rtrn= XkbErr_BadClass;
|
||||
return NULL;
|
||||
}
|
||||
return dev;
|
||||
}
|
||||
|
||||
DeviceIntPtr
|
||||
_XkbLookupBellDevice(int id,int *why_rtrn)
|
||||
{
|
||||
DeviceIntPtr dev = NULL;
|
||||
|
||||
if ((dev= _XkbLookupAnyDevice(id,why_rtrn))==NULL)
|
||||
return NULL;
|
||||
else if ((!dev->kbdfeed)&&(!dev->bell)) {
|
||||
if (why_rtrn)
|
||||
*why_rtrn= XkbErr_BadClass;
|
||||
return NULL;
|
||||
}
|
||||
return dev;
|
||||
}
|
||||
|
||||
DeviceIntPtr
|
||||
_XkbLookupLedDevice(int id,int *why_rtrn)
|
||||
{
|
||||
DeviceIntPtr dev = NULL;
|
||||
|
||||
if ((dev= _XkbLookupAnyDevice(id,why_rtrn))==NULL)
|
||||
return NULL;
|
||||
else if ((!dev->kbdfeed)&&(!dev->leds)) {
|
||||
if (why_rtrn)
|
||||
*why_rtrn= XkbErr_BadClass;
|
||||
return NULL;
|
||||
}
|
||||
return dev;
|
||||
}
|
||||
|
||||
DeviceIntPtr
|
||||
_XkbLookupButtonDevice(int id,int *why_rtrn)
|
||||
{
|
||||
DeviceIntPtr dev = NULL;
|
||||
|
||||
if ((dev= _XkbLookupAnyDevice(id,why_rtrn))==NULL)
|
||||
return NULL;
|
||||
else if (!dev->button) {
|
||||
if (why_rtrn)
|
||||
*why_rtrn= XkbErr_BadClass;
|
||||
return NULL;
|
||||
}
|
||||
return dev;
|
||||
}
|
||||
|
||||
void
|
||||
XkbSetActionKeyMods(XkbDescPtr xkb,XkbAction *act,unsigned mods)
|
||||
{
|
||||
register unsigned tmp;
|
||||
|
||||
switch (act->type) {
|
||||
case XkbSA_SetMods: case XkbSA_LatchMods: case XkbSA_LockMods:
|
||||
if (act->mods.flags&XkbSA_UseModMapMods)
|
||||
act->mods.real_mods= act->mods.mask= mods;
|
||||
if ((tmp= XkbModActionVMods(&act->mods))!=0)
|
||||
act->mods.mask|= XkbMaskForVMask(xkb,tmp);
|
||||
break;
|
||||
case XkbSA_ISOLock:
|
||||
if (act->iso.flags&XkbSA_UseModMapMods)
|
||||
act->iso.real_mods= act->iso.mask= mods;
|
||||
if ((tmp= XkbModActionVMods(&act->iso))!=0)
|
||||
act->iso.mask|= XkbMaskForVMask(xkb,tmp);
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned
|
||||
XkbMaskForVMask(XkbDescPtr xkb,unsigned vmask)
|
||||
{
|
||||
register int i,bit;
|
||||
register unsigned mask;
|
||||
|
||||
for (mask=i=0,bit=1;i<XkbNumVirtualMods;i++,bit<<=1) {
|
||||
if (vmask&bit)
|
||||
mask|= xkb->server->vmods[i];
|
||||
}
|
||||
return mask;
|
||||
}
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
void
|
||||
XkbUpdateKeyTypesFromCore( DeviceIntPtr pXDev,
|
||||
KeyCode first,
|
||||
CARD8 num,
|
||||
XkbChangesPtr changes)
|
||||
{
|
||||
XkbDescPtr xkb;
|
||||
unsigned key,nG,explicit;
|
||||
KeySymsPtr pCore;
|
||||
int types[XkbNumKbdGroups];
|
||||
KeySym tsyms[XkbMaxSymsPerKey] = {NoSymbol},*syms;
|
||||
XkbMapChangesPtr mc;
|
||||
|
||||
xkb= pXDev->key->xkbInfo->desc;
|
||||
if (first+num-1>xkb->max_key_code) {
|
||||
/* 1/12/95 (ef) -- XXX! should allow XKB structures to grow */
|
||||
num= xkb->max_key_code-first+1;
|
||||
}
|
||||
|
||||
mc= (changes?(&changes->map):NULL);
|
||||
|
||||
pCore= &pXDev->key->curKeySyms;
|
||||
syms= &pCore->map[(first-xkb->min_key_code)*pCore->mapWidth];
|
||||
for (key=first; key<(first+num); key++,syms+= pCore->mapWidth) {
|
||||
explicit= xkb->server->explicit[key]&XkbExplicitKeyTypesMask;
|
||||
types[XkbGroup1Index]= XkbKeyKeyTypeIndex(xkb,key,XkbGroup1Index);
|
||||
types[XkbGroup2Index]= XkbKeyKeyTypeIndex(xkb,key,XkbGroup2Index);
|
||||
types[XkbGroup3Index]= XkbKeyKeyTypeIndex(xkb,key,XkbGroup3Index);
|
||||
types[XkbGroup4Index]= XkbKeyKeyTypeIndex(xkb,key,XkbGroup4Index);
|
||||
nG= XkbKeyTypesForCoreSymbols(xkb,pCore->mapWidth,syms,explicit,types,
|
||||
tsyms);
|
||||
XkbChangeTypesOfKey(xkb,key,nG,XkbAllGroupsMask,types,mc);
|
||||
memcpy((char *)XkbKeySymsPtr(xkb,key),(char *)tsyms,
|
||||
XkbKeyNumSyms(xkb,key)*sizeof(KeySym));
|
||||
}
|
||||
if (changes->map.changed&XkbKeySymsMask) {
|
||||
CARD8 oldLast,newLast;
|
||||
oldLast = changes->map.first_key_sym+changes->map.num_key_syms-1;
|
||||
newLast = first+num-1;
|
||||
|
||||
if (first<changes->map.first_key_sym)
|
||||
changes->map.first_key_sym = first;
|
||||
if (oldLast>newLast)
|
||||
newLast= oldLast;
|
||||
changes->map.num_key_syms = newLast-changes->map.first_key_sym+1;
|
||||
}
|
||||
else {
|
||||
changes->map.changed|= XkbKeySymsMask;
|
||||
changes->map.first_key_sym = first;
|
||||
changes->map.num_key_syms = num;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
XkbUpdateDescActions( XkbDescPtr xkb,
|
||||
KeyCode first,
|
||||
CARD8 num,
|
||||
XkbChangesPtr changes)
|
||||
{
|
||||
register unsigned key;
|
||||
|
||||
for (key=first;key<(first+num);key++) {
|
||||
XkbApplyCompatMapToKey(xkb,key,changes);
|
||||
}
|
||||
|
||||
if (changes->map.changed&(XkbVirtualModMapMask|XkbModifierMapMask)) {
|
||||
unsigned char newVMods[XkbNumVirtualMods];
|
||||
register unsigned bit,i;
|
||||
unsigned present;
|
||||
|
||||
bzero(newVMods,XkbNumVirtualMods);
|
||||
present= 0;
|
||||
for (key=xkb->min_key_code;key<=xkb->max_key_code;key++) {
|
||||
if (xkb->server->vmodmap[key]==0)
|
||||
continue;
|
||||
for (i=0,bit=1;i<XkbNumVirtualMods;i++,bit<<=1) {
|
||||
if (bit&xkb->server->vmodmap[key]) {
|
||||
present|= bit;
|
||||
newVMods[i]|= xkb->map->modmap[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
for (i=0,bit=1;i<XkbNumVirtualMods;i++,bit<<=1) {
|
||||
if ((bit&present)&&(newVMods[i]!=xkb->server->vmods[i])) {
|
||||
changes->map.changed|= XkbVirtualModsMask;
|
||||
changes->map.vmods|= bit;
|
||||
xkb->server->vmods[i]= newVMods[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (changes->map.changed&XkbVirtualModsMask)
|
||||
XkbApplyVirtualModChanges(xkb,changes->map.vmods,changes);
|
||||
|
||||
if (changes->map.changed&XkbKeyActionsMask) {
|
||||
CARD8 oldLast,newLast;
|
||||
oldLast= changes->map.first_key_act+changes->map.num_key_acts-1;
|
||||
newLast = first+num-1;
|
||||
|
||||
if (first<changes->map.first_key_act)
|
||||
changes->map.first_key_act = first;
|
||||
if (newLast>oldLast)
|
||||
newLast= oldLast;
|
||||
changes->map.num_key_acts= newLast-changes->map.first_key_act+1;
|
||||
}
|
||||
else {
|
||||
changes->map.changed|= XkbKeyActionsMask;
|
||||
changes->map.first_key_act = first;
|
||||
changes->map.num_key_acts = num;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
XkbUpdateActions( DeviceIntPtr pXDev,
|
||||
KeyCode first,
|
||||
CARD8 num,
|
||||
XkbChangesPtr changes,
|
||||
unsigned * needChecksRtrn,
|
||||
XkbEventCausePtr cause)
|
||||
{
|
||||
XkbSrvInfoPtr xkbi;
|
||||
XkbDescPtr xkb;
|
||||
CARD8 * repeat;
|
||||
|
||||
if (needChecksRtrn)
|
||||
*needChecksRtrn= 0;
|
||||
xkbi= pXDev->key->xkbInfo;
|
||||
xkb= xkbi->desc;
|
||||
repeat= xkb->ctrls->per_key_repeat;
|
||||
|
||||
if (pXDev->kbdfeed)
|
||||
memcpy(repeat,pXDev->kbdfeed->ctrl.autoRepeats,32);
|
||||
|
||||
XkbUpdateDescActions(xkb,first,num,changes);
|
||||
|
||||
if ((pXDev->kbdfeed)&&
|
||||
(changes->ctrls.enabled_ctrls_changes&XkbPerKeyRepeatMask)) {
|
||||
memcpy(pXDev->kbdfeed->ctrl.autoRepeats,repeat, 32);
|
||||
(*pXDev->kbdfeed->CtrlProc)(pXDev, &pXDev->kbdfeed->ctrl);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
XkbUpdateCoreDescription(DeviceIntPtr keybd,Bool resize)
|
||||
{
|
||||
register int key,tmp;
|
||||
int maxSymsPerKey,maxKeysPerMod;
|
||||
int first,last,firstCommon,lastCommon;
|
||||
XkbDescPtr xkb;
|
||||
KeyClassPtr keyc;
|
||||
CARD8 keysPerMod[XkbNumModifiers];
|
||||
|
||||
if (!keybd || !keybd->key || !keybd->key->xkbInfo)
|
||||
return;
|
||||
xkb= keybd->key->xkbInfo->desc;
|
||||
keyc= keybd->key;
|
||||
maxSymsPerKey= maxKeysPerMod= 0;
|
||||
bzero(keysPerMod,sizeof(keysPerMod));
|
||||
memcpy(keyc->modifierMap,xkb->map->modmap,xkb->max_key_code+1);
|
||||
if ((xkb->min_key_code==keyc->curKeySyms.minKeyCode)&&
|
||||
(xkb->max_key_code==keyc->curKeySyms.maxKeyCode)) {
|
||||
first= firstCommon= xkb->min_key_code;
|
||||
last= lastCommon= xkb->max_key_code;
|
||||
}
|
||||
else if (resize) {
|
||||
keyc->curKeySyms.minKeyCode= xkb->min_key_code;
|
||||
keyc->curKeySyms.maxKeyCode= xkb->max_key_code;
|
||||
tmp= keyc->curKeySyms.mapWidth*_XkbCoreNumKeys(keyc);
|
||||
keyc->curKeySyms.map= _XkbTypedRealloc(keyc->curKeySyms.map,tmp,KeySym);
|
||||
if (!keyc->curKeySyms.map)
|
||||
FatalError("Couldn't allocate keysyms\n");
|
||||
first= firstCommon= xkb->min_key_code;
|
||||
last= lastCommon= xkb->max_key_code;
|
||||
}
|
||||
else {
|
||||
if (xkb->min_key_code<keyc->curKeySyms.minKeyCode) {
|
||||
first= xkb->min_key_code;
|
||||
firstCommon= keyc->curKeySyms.minKeyCode;
|
||||
}
|
||||
else {
|
||||
firstCommon= xkb->min_key_code;
|
||||
first= keyc->curKeySyms.minKeyCode;
|
||||
}
|
||||
if (xkb->max_key_code>keyc->curKeySyms.maxKeyCode) {
|
||||
lastCommon= keyc->curKeySyms.maxKeyCode;
|
||||
last= xkb->max_key_code;
|
||||
}
|
||||
else {
|
||||
lastCommon= xkb->max_key_code;
|
||||
last= keyc->curKeySyms.maxKeyCode;
|
||||
}
|
||||
}
|
||||
|
||||
/* determine sizes */
|
||||
for (key=first;key<=last;key++) {
|
||||
if (XkbKeycodeInRange(xkb,key)) {
|
||||
int nGroups;
|
||||
int w;
|
||||
nGroups= XkbKeyNumGroups(xkb,key);
|
||||
tmp= 0;
|
||||
if (nGroups>0) {
|
||||
if ((w=XkbKeyGroupWidth(xkb,key,XkbGroup1Index))<=2)
|
||||
tmp+= 2;
|
||||
else tmp+= w + 2;
|
||||
}
|
||||
if (nGroups>1) {
|
||||
if (tmp <= 2) {
|
||||
if ((w=XkbKeyGroupWidth(xkb,key,XkbGroup2Index))<2)
|
||||
tmp+= 2;
|
||||
else tmp+= w;
|
||||
} else {
|
||||
if ((w=XkbKeyGroupWidth(xkb,key,XkbGroup2Index))>2)
|
||||
tmp+= w - 2;
|
||||
}
|
||||
}
|
||||
if (nGroups>2)
|
||||
tmp+= XkbKeyGroupWidth(xkb,key,XkbGroup3Index);
|
||||
if (nGroups>3)
|
||||
tmp+= XkbKeyGroupWidth(xkb,key,XkbGroup4Index);
|
||||
if (tmp>maxSymsPerKey)
|
||||
maxSymsPerKey= tmp;
|
||||
}
|
||||
if (_XkbCoreKeycodeInRange(keyc,key)) {
|
||||
if (keyc->modifierMap[key]!=0) {
|
||||
register unsigned bit,i,mask;
|
||||
mask= keyc->modifierMap[key];
|
||||
for (i=0,bit=1;i<XkbNumModifiers;i++,bit<<=1) {
|
||||
if (mask&bit) {
|
||||
keysPerMod[i]++;
|
||||
if (keysPerMod[i]>maxKeysPerMod)
|
||||
maxKeysPerMod= keysPerMod[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (maxKeysPerMod>0) {
|
||||
tmp= maxKeysPerMod*XkbNumModifiers;
|
||||
if (keyc->modifierKeyMap==NULL)
|
||||
keyc->modifierKeyMap= (KeyCode *)_XkbCalloc(1, tmp);
|
||||
else if (keyc->maxKeysPerModifier<maxKeysPerMod)
|
||||
keyc->modifierKeyMap= (KeyCode *)_XkbRealloc(keyc->modifierKeyMap,tmp);
|
||||
if (keyc->modifierKeyMap==NULL)
|
||||
FatalError("Couldn't allocate modifierKeyMap in UpdateCore\n");
|
||||
bzero(keyc->modifierKeyMap,tmp);
|
||||
}
|
||||
else if ((keyc->maxKeysPerModifier>0)&&(keyc->modifierKeyMap!=NULL)) {
|
||||
_XkbFree(keyc->modifierKeyMap);
|
||||
keyc->modifierKeyMap= NULL;
|
||||
}
|
||||
keyc->maxKeysPerModifier= maxKeysPerMod;
|
||||
|
||||
if (maxSymsPerKey>0) {
|
||||
tmp= maxSymsPerKey*_XkbCoreNumKeys(keyc);
|
||||
keyc->curKeySyms.map= _XkbTypedRealloc(keyc->curKeySyms.map,tmp,KeySym);
|
||||
if (keyc->curKeySyms.map==NULL)
|
||||
FatalError("Couldn't allocate symbols map in UpdateCore\n");
|
||||
}
|
||||
else if ((keyc->curKeySyms.mapWidth>0)&&(keyc->curKeySyms.map!=NULL)) {
|
||||
_XkbFree(keyc->curKeySyms.map);
|
||||
keyc->curKeySyms.map= NULL;
|
||||
}
|
||||
keyc->curKeySyms.mapWidth= maxSymsPerKey;
|
||||
|
||||
bzero(keysPerMod,sizeof(keysPerMod));
|
||||
for (key=firstCommon;key<=lastCommon;key++) {
|
||||
if (keyc->curKeySyms.map!=NULL) {
|
||||
KeySym *pCore,*pXKB;
|
||||
unsigned nGroups,groupWidth,n,nOut;
|
||||
|
||||
nGroups= XkbKeyNumGroups(xkb,key);
|
||||
n= (key-keyc->curKeySyms.minKeyCode)*maxSymsPerKey;
|
||||
pCore= &keyc->curKeySyms.map[n];
|
||||
bzero(pCore,maxSymsPerKey*sizeof(KeySym));
|
||||
pXKB= XkbKeySymsPtr(xkb,key);
|
||||
nOut= 2;
|
||||
if (nGroups>0) {
|
||||
groupWidth= XkbKeyGroupWidth(xkb,key,XkbGroup1Index);
|
||||
if (groupWidth>0) pCore[0]= pXKB[0];
|
||||
if (groupWidth>1) pCore[1]= pXKB[1];
|
||||
for (n=2;n<groupWidth;n++) {
|
||||
pCore[2+n]= pXKB[n];
|
||||
}
|
||||
if (groupWidth>2)
|
||||
nOut= groupWidth;
|
||||
}
|
||||
pXKB+= XkbKeyGroupsWidth(xkb,key);
|
||||
nOut+= 2;
|
||||
if (nGroups>1) {
|
||||
groupWidth= XkbKeyGroupWidth(xkb,key,XkbGroup2Index);
|
||||
if (groupWidth>0) pCore[2]= pXKB[0];
|
||||
if (groupWidth>1) pCore[3]= pXKB[1];
|
||||
for (n=2;n<groupWidth;n++) {
|
||||
pCore[nOut+(n-2)]= pXKB[n];
|
||||
}
|
||||
if (groupWidth>2)
|
||||
nOut+= (groupWidth-2);
|
||||
}
|
||||
pXKB+= XkbKeyGroupsWidth(xkb,key);
|
||||
for (n=XkbGroup3Index;n<nGroups;n++) {
|
||||
register int s;
|
||||
groupWidth= XkbKeyGroupWidth(xkb,key,n);
|
||||
for (s=0;s<groupWidth;s++) {
|
||||
pCore[nOut++]= pXKB[s];
|
||||
}
|
||||
pXKB+= XkbKeyGroupsWidth(xkb,key);
|
||||
}
|
||||
if (!pCore[2] && !pCore[3] && maxSymsPerKey >= 6 &&
|
||||
(pCore[4] || pCore[5])) {
|
||||
pCore[2] = pCore[4];
|
||||
pCore[3] = pCore[5];
|
||||
}
|
||||
}
|
||||
if (keyc->modifierMap[key]!=0) {
|
||||
register unsigned bit,i,mask;
|
||||
mask= keyc->modifierMap[key];
|
||||
for (i=0,bit=1;i<XkbNumModifiers;i++,bit<<=1) {
|
||||
if (mask&bit) {
|
||||
tmp= i*maxKeysPerMod+keysPerMod[i];
|
||||
keyc->modifierKeyMap[tmp]= key;
|
||||
keysPerMod[i]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef MODE_SWITCH
|
||||
/* Fix up any of the KME stuff if we changed the core description.
|
||||
*/
|
||||
if (!noKME)
|
||||
HandleKeyBinding(keyc, &keyc->curKeySyms);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
XkbSetRepeatKeys(DeviceIntPtr pXDev,int key,int onoff)
|
||||
{
|
||||
if (pXDev && pXDev->key && pXDev->key->xkbInfo) {
|
||||
xkbControlsNotify cn;
|
||||
XkbControlsPtr ctrls = pXDev->key->xkbInfo->desc->ctrls;
|
||||
XkbControlsRec old;
|
||||
old = *ctrls;
|
||||
|
||||
if (key== -1) { /* global autorepeat setting changed */
|
||||
if (onoff) ctrls->enabled_ctrls |= XkbRepeatKeysMask;
|
||||
else ctrls->enabled_ctrls &= ~XkbRepeatKeysMask;
|
||||
}
|
||||
else if (pXDev->kbdfeed) {
|
||||
ctrls->per_key_repeat[key/8] =
|
||||
pXDev->kbdfeed->ctrl.autoRepeats[key/8];
|
||||
}
|
||||
|
||||
if (XkbComputeControlsNotify(pXDev,&old,ctrls,&cn,True))
|
||||
XkbSendControlsNotify(pXDev,&cn);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
XkbApplyMappingChange( DeviceIntPtr kbd,
|
||||
CARD8 request,
|
||||
KeyCode firstKey,
|
||||
CARD8 num,
|
||||
ClientPtr client)
|
||||
{
|
||||
XkbEventCauseRec cause;
|
||||
XkbChangesRec changes;
|
||||
unsigned check;
|
||||
|
||||
if (kbd->key->xkbInfo==NULL)
|
||||
XkbInitDevice(kbd);
|
||||
bzero(&changes,sizeof(XkbChangesRec));
|
||||
check= 0;
|
||||
if (request==MappingKeyboard) {
|
||||
XkbSetCauseCoreReq(&cause,X_ChangeKeyboardMapping,client);
|
||||
XkbUpdateKeyTypesFromCore(kbd,firstKey,num,&changes);
|
||||
XkbUpdateActions(kbd,firstKey,num,&changes,&check,&cause);
|
||||
if (check)
|
||||
XkbCheckSecondaryEffects(kbd->key->xkbInfo,check,&changes,&cause);
|
||||
}
|
||||
else if (request==MappingModifier) {
|
||||
XkbDescPtr xkb= kbd->key->xkbInfo->desc;
|
||||
|
||||
XkbSetCauseCoreReq(&cause,X_SetModifierMapping,client);
|
||||
|
||||
num = xkb->max_key_code-xkb->min_key_code+1;
|
||||
memcpy(xkb->map->modmap,kbd->key->modifierMap,xkb->max_key_code+1);
|
||||
|
||||
changes.map.changed|= XkbModifierMapMask;
|
||||
changes.map.first_modmap_key= xkb->min_key_code;
|
||||
changes.map.num_modmap_keys= num;
|
||||
XkbUpdateActions(kbd,xkb->min_key_code,num,&changes,&check,&cause);
|
||||
if (check)
|
||||
XkbCheckSecondaryEffects(kbd->key->xkbInfo,check,&changes,&cause);
|
||||
}
|
||||
/* 3/26/94 (ef) -- XXX! Doesn't deal with input extension requests */
|
||||
XkbSendNotification(kbd,&changes,&cause);
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
XkbDisableComputedAutoRepeats(DeviceIntPtr dev,unsigned key)
|
||||
{
|
||||
XkbSrvInfoPtr xkbi = dev->key->xkbInfo;
|
||||
xkbMapNotify mn;
|
||||
|
||||
xkbi->desc->server->explicit[key]|= XkbExplicitAutoRepeatMask;
|
||||
bzero(&mn,sizeof(mn));
|
||||
mn.changed= XkbExplicitComponentsMask;
|
||||
mn.firstKeyExplicit= key;
|
||||
mn.nKeyExplicit= 1;
|
||||
XkbSendMapNotify(dev,&mn);
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned
|
||||
XkbStateChangedFlags(XkbStatePtr old,XkbStatePtr new)
|
||||
{
|
||||
int changed;
|
||||
|
||||
changed=(old->group!=new->group?XkbGroupStateMask:0);
|
||||
changed|=(old->base_group!=new->base_group?XkbGroupBaseMask:0);
|
||||
changed|=(old->latched_group!=new->latched_group?XkbGroupLatchMask:0);
|
||||
changed|=(old->locked_group!=new->locked_group?XkbGroupLockMask:0);
|
||||
changed|=(old->mods!=new->mods?XkbModifierStateMask:0);
|
||||
changed|=(old->base_mods!=new->base_mods?XkbModifierBaseMask:0);
|
||||
changed|=(old->latched_mods!=new->latched_mods?XkbModifierLatchMask:0);
|
||||
changed|=(old->locked_mods!=new->locked_mods?XkbModifierLockMask:0);
|
||||
changed|=(old->compat_state!=new->compat_state?XkbCompatStateMask:0);
|
||||
changed|=(old->grab_mods!=new->grab_mods?XkbGrabModsMask:0);
|
||||
if (old->compat_grab_mods!=new->compat_grab_mods)
|
||||
changed|= XkbCompatGrabModsMask;
|
||||
changed|=(old->lookup_mods!=new->lookup_mods?XkbLookupModsMask:0);
|
||||
if (old->compat_lookup_mods!=new->compat_lookup_mods)
|
||||
changed|= XkbCompatLookupModsMask;
|
||||
changed|=(old->ptr_buttons!=new->ptr_buttons?XkbPointerButtonMask:0);
|
||||
return changed;
|
||||
}
|
||||
|
||||
void
|
||||
XkbComputeCompatState(XkbSrvInfoPtr xkbi)
|
||||
{
|
||||
CARD16 grp_mask;
|
||||
XkbStatePtr state= &xkbi->state;
|
||||
XkbCompatMapPtr map;
|
||||
|
||||
if (!state || !xkbi->desc || !xkbi->desc->ctrls || !xkbi->desc->compat)
|
||||
return;
|
||||
|
||||
map= xkbi->desc->compat;
|
||||
grp_mask= map->groups[state->group].mask;
|
||||
state->compat_state = state->mods|grp_mask;
|
||||
state->compat_lookup_mods= state->lookup_mods|grp_mask;
|
||||
|
||||
if (xkbi->desc->ctrls->enabled_ctrls&XkbIgnoreGroupLockMask)
|
||||
grp_mask= map->groups[state->base_group].mask;
|
||||
state->compat_grab_mods= state->grab_mods|grp_mask;
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned
|
||||
XkbAdjustGroup(int group,XkbControlsPtr ctrls)
|
||||
{
|
||||
unsigned act;
|
||||
|
||||
act= XkbOutOfRangeGroupAction(ctrls->groups_wrap);
|
||||
if (group<0) {
|
||||
while ( group < 0 ) {
|
||||
if (act==XkbClampIntoRange) {
|
||||
group= XkbGroup1Index;
|
||||
}
|
||||
else if (act==XkbRedirectIntoRange) {
|
||||
int newGroup;
|
||||
newGroup= XkbOutOfRangeGroupNumber(ctrls->groups_wrap);
|
||||
if (newGroup>=ctrls->num_groups)
|
||||
group= XkbGroup1Index;
|
||||
else group= newGroup;
|
||||
}
|
||||
else {
|
||||
group+= ctrls->num_groups;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (group>=ctrls->num_groups) {
|
||||
if (act==XkbClampIntoRange) {
|
||||
group= ctrls->num_groups-1;
|
||||
}
|
||||
else if (act==XkbRedirectIntoRange) {
|
||||
int newGroup;
|
||||
newGroup= XkbOutOfRangeGroupNumber(ctrls->groups_wrap);
|
||||
if (newGroup>=ctrls->num_groups)
|
||||
group= XkbGroup1Index;
|
||||
else group= newGroup;
|
||||
}
|
||||
else {
|
||||
#ifdef NXAGENT_SERVER
|
||||
/*
|
||||
* we have seen division by zero here - see
|
||||
* https://github.com/ArcticaProject/nx-libs/issues/808 for
|
||||
* details and xorg upstream bug report
|
||||
*/
|
||||
if (ctrls->num_groups != 0)
|
||||
#endif
|
||||
group%= ctrls->num_groups;
|
||||
}
|
||||
}
|
||||
return group;
|
||||
}
|
||||
|
||||
void
|
||||
XkbComputeDerivedState(XkbSrvInfoPtr xkbi)
|
||||
{
|
||||
XkbStatePtr state= &xkbi->state;
|
||||
XkbControlsPtr ctrls= xkbi->desc->ctrls;
|
||||
unsigned char grp;
|
||||
|
||||
if (!state || !ctrls)
|
||||
return;
|
||||
|
||||
state->mods= (state->base_mods|state->latched_mods);
|
||||
state->mods|= state->locked_mods;
|
||||
state->lookup_mods= state->mods&(~ctrls->internal.mask);
|
||||
state->grab_mods= state->lookup_mods&(~ctrls->ignore_lock.mask);
|
||||
state->grab_mods|=
|
||||
((state->base_mods|state->latched_mods)&ctrls->ignore_lock.mask);
|
||||
|
||||
|
||||
grp= state->locked_group;
|
||||
if (grp>=ctrls->num_groups)
|
||||
state->locked_group= XkbAdjustGroup(XkbCharToInt(grp),ctrls);
|
||||
|
||||
grp= state->locked_group+state->base_group+state->latched_group;
|
||||
if (grp>=ctrls->num_groups)
|
||||
state->group= XkbAdjustGroup(XkbCharToInt(grp),ctrls);
|
||||
else state->group= grp;
|
||||
XkbComputeCompatState(xkbi);
|
||||
return;
|
||||
}
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
void
|
||||
XkbCheckSecondaryEffects( XkbSrvInfoPtr xkbi,
|
||||
unsigned which,
|
||||
XkbChangesPtr changes,
|
||||
XkbEventCausePtr cause)
|
||||
{
|
||||
if (which&XkbStateNotifyMask) {
|
||||
XkbStateRec old;
|
||||
old= xkbi->state;
|
||||
changes->state_changes|= XkbStateChangedFlags(&old,&xkbi->state);
|
||||
XkbComputeDerivedState(xkbi);
|
||||
}
|
||||
if (which&XkbIndicatorStateNotifyMask)
|
||||
XkbUpdateIndicators(xkbi->device,XkbAllIndicatorsMask,True,changes,
|
||||
cause);
|
||||
return;
|
||||
}
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
Bool
|
||||
XkbEnableDisableControls( XkbSrvInfoPtr xkbi,
|
||||
unsigned long change,
|
||||
unsigned long newValues,
|
||||
XkbChangesPtr changes,
|
||||
XkbEventCausePtr cause)
|
||||
{
|
||||
XkbControlsPtr ctrls;
|
||||
unsigned old;
|
||||
XkbSrvLedInfoPtr sli;
|
||||
|
||||
ctrls= xkbi->desc->ctrls;
|
||||
old= ctrls->enabled_ctrls;
|
||||
ctrls->enabled_ctrls&= ~change;
|
||||
ctrls->enabled_ctrls|= (change&newValues);
|
||||
if (old==ctrls->enabled_ctrls)
|
||||
return False;
|
||||
if (cause!=NULL) {
|
||||
xkbControlsNotify cn;
|
||||
cn.numGroups= ctrls->num_groups;
|
||||
cn.changedControls= XkbControlsEnabledMask;
|
||||
cn.enabledControls= ctrls->enabled_ctrls;
|
||||
cn.enabledControlChanges= (ctrls->enabled_ctrls^old);
|
||||
cn.keycode= cause->kc;
|
||||
cn.eventType= cause->event;
|
||||
cn.requestMajor= cause->mjr;
|
||||
cn.requestMinor= cause->mnr;
|
||||
XkbSendControlsNotify(xkbi->device,&cn);
|
||||
}
|
||||
else {
|
||||
/* Yes, this really should be an XOR. If ctrls->enabled_ctrls_changes*/
|
||||
/* is non-zero, the controls in question changed already in "this" */
|
||||
/* request and this change merely undoes the previous one. By the */
|
||||
/* same token, we have to figure out whether or not ControlsEnabled */
|
||||
/* should be set or not in the changes structure */
|
||||
changes->ctrls.enabled_ctrls_changes^= (ctrls->enabled_ctrls^old);
|
||||
if (changes->ctrls.enabled_ctrls_changes)
|
||||
changes->ctrls.changed_ctrls|= XkbControlsEnabledMask;
|
||||
else changes->ctrls.changed_ctrls&= ~XkbControlsEnabledMask;
|
||||
}
|
||||
sli= XkbFindSrvLedInfo(xkbi->device,XkbDfltXIClass,XkbDfltXIId,0);
|
||||
XkbUpdateIndicators(xkbi->device,sli->usesControls,True,changes,cause);
|
||||
return True;
|
||||
}
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
#define MAX_TOC 16
|
||||
|
||||
XkbGeometryPtr
|
||||
XkbLookupNamedGeometry(DeviceIntPtr dev,Atom name,Bool *shouldFree)
|
||||
{
|
||||
XkbSrvInfoPtr xkbi= dev->key->xkbInfo;
|
||||
XkbDescPtr xkb= xkbi->desc;
|
||||
|
||||
*shouldFree= 0;
|
||||
if (name==None) {
|
||||
if (xkb->geom!=NULL)
|
||||
return xkb->geom;
|
||||
name= xkb->names->geometry;
|
||||
}
|
||||
if ((xkb->geom!=NULL)&&(xkb->geom->name==name))
|
||||
return xkb->geom;
|
||||
*shouldFree= 1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
XkbConvertCase(register KeySym sym, KeySym *lower, KeySym *upper)
|
||||
{
|
||||
*lower = sym;
|
||||
*upper = sym;
|
||||
switch(sym >> 8) {
|
||||
case 0: /* Latin 1 */
|
||||
if ((sym >= XK_A) && (sym <= XK_Z))
|
||||
*lower += (XK_a - XK_A);
|
||||
else if ((sym >= XK_a) && (sym <= XK_z))
|
||||
*upper -= (XK_a - XK_A);
|
||||
else if ((sym >= XK_Agrave) && (sym <= XK_Odiaeresis))
|
||||
*lower += (XK_agrave - XK_Agrave);
|
||||
else if ((sym >= XK_agrave) && (sym <= XK_odiaeresis))
|
||||
*upper -= (XK_agrave - XK_Agrave);
|
||||
else if ((sym >= XK_Ooblique) && (sym <= XK_Thorn))
|
||||
*lower += (XK_oslash - XK_Ooblique);
|
||||
else if ((sym >= XK_oslash) && (sym <= XK_thorn))
|
||||
*upper -= (XK_oslash - XK_Ooblique);
|
||||
break;
|
||||
case 1: /* Latin 2 */
|
||||
/* Assume the KeySym is a legal value (ignore discontinuities) */
|
||||
if (sym == XK_Aogonek)
|
||||
*lower = XK_aogonek;
|
||||
else if (sym >= XK_Lstroke && sym <= XK_Sacute)
|
||||
*lower += (XK_lstroke - XK_Lstroke);
|
||||
else if (sym >= XK_Scaron && sym <= XK_Zacute)
|
||||
*lower += (XK_scaron - XK_Scaron);
|
||||
else if (sym >= XK_Zcaron && sym <= XK_Zabovedot)
|
||||
*lower += (XK_zcaron - XK_Zcaron);
|
||||
else if (sym == XK_aogonek)
|
||||
*upper = XK_Aogonek;
|
||||
else if (sym >= XK_lstroke && sym <= XK_sacute)
|
||||
*upper -= (XK_lstroke - XK_Lstroke);
|
||||
else if (sym >= XK_scaron && sym <= XK_zacute)
|
||||
*upper -= (XK_scaron - XK_Scaron);
|
||||
else if (sym >= XK_zcaron && sym <= XK_zabovedot)
|
||||
*upper -= (XK_zcaron - XK_Zcaron);
|
||||
else if (sym >= XK_Racute && sym <= XK_Tcedilla)
|
||||
*lower += (XK_racute - XK_Racute);
|
||||
else if (sym >= XK_racute && sym <= XK_tcedilla)
|
||||
*upper -= (XK_racute - XK_Racute);
|
||||
break;
|
||||
case 2: /* Latin 3 */
|
||||
/* Assume the KeySym is a legal value (ignore discontinuities) */
|
||||
if (sym >= XK_Hstroke && sym <= XK_Hcircumflex)
|
||||
*lower += (XK_hstroke - XK_Hstroke);
|
||||
else if (sym >= XK_Gbreve && sym <= XK_Jcircumflex)
|
||||
*lower += (XK_gbreve - XK_Gbreve);
|
||||
else if (sym >= XK_hstroke && sym <= XK_hcircumflex)
|
||||
*upper -= (XK_hstroke - XK_Hstroke);
|
||||
else if (sym >= XK_gbreve && sym <= XK_jcircumflex)
|
||||
*upper -= (XK_gbreve - XK_Gbreve);
|
||||
else if (sym >= XK_Cabovedot && sym <= XK_Scircumflex)
|
||||
*lower += (XK_cabovedot - XK_Cabovedot);
|
||||
else if (sym >= XK_cabovedot && sym <= XK_scircumflex)
|
||||
*upper -= (XK_cabovedot - XK_Cabovedot);
|
||||
break;
|
||||
case 3: /* Latin 4 */
|
||||
/* Assume the KeySym is a legal value (ignore discontinuities) */
|
||||
if (sym >= XK_Rcedilla && sym <= XK_Tslash)
|
||||
*lower += (XK_rcedilla - XK_Rcedilla);
|
||||
else if (sym >= XK_rcedilla && sym <= XK_tslash)
|
||||
*upper -= (XK_rcedilla - XK_Rcedilla);
|
||||
else if (sym == XK_ENG)
|
||||
*lower = XK_eng;
|
||||
else if (sym == XK_eng)
|
||||
*upper = XK_ENG;
|
||||
else if (sym >= XK_Amacron && sym <= XK_Umacron)
|
||||
*lower += (XK_amacron - XK_Amacron);
|
||||
else if (sym >= XK_amacron && sym <= XK_umacron)
|
||||
*upper -= (XK_amacron - XK_Amacron);
|
||||
break;
|
||||
case 6: /* Cyrillic */
|
||||
/* Assume the KeySym is a legal value (ignore discontinuities) */
|
||||
if (sym >= XK_Serbian_DJE && sym <= XK_Serbian_DZE)
|
||||
*lower -= (XK_Serbian_DJE - XK_Serbian_dje);
|
||||
else if (sym >= XK_Serbian_dje && sym <= XK_Serbian_dze)
|
||||
*upper += (XK_Serbian_DJE - XK_Serbian_dje);
|
||||
else if (sym >= XK_Cyrillic_YU && sym <= XK_Cyrillic_HARDSIGN)
|
||||
*lower -= (XK_Cyrillic_YU - XK_Cyrillic_yu);
|
||||
else if (sym >= XK_Cyrillic_yu && sym <= XK_Cyrillic_hardsign)
|
||||
*upper += (XK_Cyrillic_YU - XK_Cyrillic_yu);
|
||||
break;
|
||||
case 7: /* Greek */
|
||||
/* Assume the KeySym is a legal value (ignore discontinuities) */
|
||||
if (sym >= XK_Greek_ALPHAaccent && sym <= XK_Greek_OMEGAaccent)
|
||||
*lower += (XK_Greek_alphaaccent - XK_Greek_ALPHAaccent);
|
||||
else if (sym >= XK_Greek_alphaaccent && sym <= XK_Greek_omegaaccent &&
|
||||
sym != XK_Greek_iotaaccentdieresis &&
|
||||
sym != XK_Greek_upsilonaccentdieresis)
|
||||
*upper -= (XK_Greek_alphaaccent - XK_Greek_ALPHAaccent);
|
||||
else if (sym >= XK_Greek_ALPHA && sym <= XK_Greek_OMEGA)
|
||||
*lower += (XK_Greek_alpha - XK_Greek_ALPHA);
|
||||
else if (sym >= XK_Greek_alpha && sym <= XK_Greek_omega &&
|
||||
sym != XK_Greek_finalsmallsigma)
|
||||
*upper -= (XK_Greek_alpha - XK_Greek_ALPHA);
|
||||
break;
|
||||
}
|
||||
}
|
||||
37
nx-X11/programs/Xserver/xkb/xkberrs.c
Normal file
37
nx-X11/programs/Xserver/xkb/xkberrs.c
Normal file
@@ -0,0 +1,37 @@
|
||||
/************************************************************
|
||||
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
|
||||
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_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
unsigned _XkbErrCode;
|
||||
char * _XkbErrLocation= NULL;
|
||||
unsigned _XkbErrData;
|
||||
643
nx-X11/programs/Xserver/xkb/xkbfmisc.c
Normal file
643
nx-X11/programs/Xserver/xkb/xkbfmisc.c
Normal file
@@ -0,0 +1,643 @@
|
||||
/************************************************************
|
||||
Copyright (c) 1995 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_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <nx-X11/Xos.h>
|
||||
#include <nx-X11/Xfuncs.h>
|
||||
|
||||
#include <nx-X11/X.h>
|
||||
#include <nx-X11/keysym.h>
|
||||
#include <nx-X11/Xproto.h>
|
||||
#include "misc.h"
|
||||
#include "inputstr.h"
|
||||
#include "dix.h"
|
||||
#include "xkbstr.h"
|
||||
#include <xkbsrv.h>
|
||||
#include "xkbgeom.h"
|
||||
#include "xkb.h"
|
||||
|
||||
unsigned
|
||||
_XkbKSCheckCase(KeySym ks)
|
||||
{
|
||||
unsigned set,rtrn;
|
||||
|
||||
set= (ks & (~0xff)) >> 8;
|
||||
rtrn= 0;
|
||||
switch (set) {
|
||||
case 0: /* latin 1 */
|
||||
if (((ks>=XK_A)&&(ks<=XK_Z))||
|
||||
((ks>=XK_Agrave)&&(ks<=XK_THORN)&&(ks!=XK_multiply))) {
|
||||
rtrn|= _XkbKSUpper;
|
||||
}
|
||||
if (((ks>=XK_a)&&(ks<=XK_z))||
|
||||
((ks>=XK_agrave)&&(ks<=XK_ydiaeresis))) {
|
||||
rtrn|= _XkbKSLower;
|
||||
}
|
||||
break;
|
||||
case 1: /* latin 2 */
|
||||
if (((ks>=XK_Aogonek)&&(ks<=XK_Zabovedot)&&(ks!=XK_breve))||
|
||||
((ks>=XK_Racute)&&(ks<=XK_Tcedilla))) {
|
||||
rtrn|= _XkbKSUpper;
|
||||
}
|
||||
if (((ks>=XK_aogonek)&&(ks<=XK_zabovedot)&&(ks!=XK_caron))||
|
||||
((ks>=XK_racute)&&(ks<=XK_tcedilla))) {
|
||||
rtrn|= _XkbKSLower;
|
||||
}
|
||||
break;
|
||||
case 2: /* latin 3 */
|
||||
if (((ks>=XK_Hstroke)&&(ks<=XK_Jcircumflex))||
|
||||
((ks>=XK_Cabovedot)&&(ks<=XK_Scircumflex))) {
|
||||
rtrn|= _XkbKSUpper;
|
||||
}
|
||||
if (((ks>=XK_hstroke)&&(ks<=XK_jcircumflex))||
|
||||
((ks>=XK_cabovedot)&&(ks<=XK_scircumflex))) {
|
||||
rtrn|= _XkbKSLower;
|
||||
}
|
||||
break;
|
||||
case 3: /* latin 4 */
|
||||
if (((ks>=XK_Rcedilla)&&(ks<=XK_Tslash))||
|
||||
(ks==XK_ENG)||
|
||||
((ks>=XK_Amacron)&&(ks<=XK_Umacron))) {
|
||||
rtrn|= _XkbKSUpper;
|
||||
}
|
||||
if (((ks>=XK_rcedilla)&&(ks<=XK_tslash))||
|
||||
(ks==XK_eng)||
|
||||
((ks>=XK_amacron)&&(ks<=XK_umacron))) {
|
||||
rtrn|= _XkbKSLower;
|
||||
}
|
||||
break;
|
||||
case 18: /* latin 8 */
|
||||
if ((ks==XK_Babovedot)||
|
||||
((ks>=XK_Dabovedot)&&(ks<=XK_Wacute))||
|
||||
((ks>=XK_Ygrave)&&(ks<=XK_Fabovedot))||
|
||||
(ks==XK_Mabovedot)||
|
||||
(ks==XK_Pabovedot)||
|
||||
(ks==XK_Sabovedot)||
|
||||
(ks==XK_Wdiaeresis)||
|
||||
((ks>=XK_Wcircumflex)&&(ks<=XK_Ycircumflex))) {
|
||||
rtrn|= _XkbKSUpper;
|
||||
}
|
||||
if ((ks==XK_babovedot)||
|
||||
(ks==XK_dabovedot)||
|
||||
(ks==XK_fabovedot)||
|
||||
(ks==XK_mabovedot)||
|
||||
((ks>=XK_wgrave)&&(ks<=XK_wacute))||
|
||||
(ks==XK_ygrave)||
|
||||
((ks>=XK_wdiaeresis)&&(ks<=XK_ycircumflex))) {
|
||||
rtrn|= _XkbKSLower;
|
||||
}
|
||||
break;
|
||||
case 19: /* latin 9 */
|
||||
if ((ks==XK_OE)||(ks==XK_Ydiaeresis)) {
|
||||
rtrn|= _XkbKSUpper;
|
||||
}
|
||||
if (ks==XK_oe) {
|
||||
rtrn|= _XkbKSLower;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return rtrn;
|
||||
}
|
||||
|
||||
/***===================================================================***/
|
||||
|
||||
Bool
|
||||
XkbLookupGroupAndLevel( XkbDescPtr xkb,
|
||||
int key,
|
||||
int * mods_inout,
|
||||
int * grp_inout,
|
||||
int * lvl_rtrn)
|
||||
{
|
||||
int nG,eG;
|
||||
|
||||
if ((!xkb)||(!XkbKeycodeInRange(xkb,key))||(!grp_inout))
|
||||
return False;
|
||||
|
||||
nG= XkbKeyNumGroups(xkb,key);
|
||||
eG= *grp_inout;
|
||||
|
||||
if ( nG==0 ) {
|
||||
*grp_inout= 0;
|
||||
if (lvl_rtrn!=NULL)
|
||||
*lvl_rtrn= 0;
|
||||
return False;
|
||||
}
|
||||
else if ( nG==1 ) {
|
||||
eG= 0;
|
||||
}
|
||||
else if ( eG>=nG ) {
|
||||
unsigned gI= XkbKeyGroupInfo(xkb,key);
|
||||
switch (XkbOutOfRangeGroupAction(gI)) {
|
||||
default:
|
||||
eG %= nG;
|
||||
break;
|
||||
case XkbClampIntoRange:
|
||||
eG = nG-1;
|
||||
break;
|
||||
case XkbRedirectIntoRange:
|
||||
eG = XkbOutOfRangeGroupNumber(gI);
|
||||
if (eG>=nG)
|
||||
eG= 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
*grp_inout= eG;
|
||||
if (mods_inout!=NULL) {
|
||||
XkbKeyTypePtr type;
|
||||
int preserve;
|
||||
|
||||
type = XkbKeyKeyType(xkb,key,eG);
|
||||
if (lvl_rtrn!=NULL)
|
||||
*lvl_rtrn= 0;
|
||||
preserve= 0;
|
||||
if (type->map) { /* find the shift level */
|
||||
register int i;
|
||||
register XkbKTMapEntryPtr entry;
|
||||
for (i=0,entry=type->map;i<type->map_count;i++,entry++) {
|
||||
if ((entry->active)&&
|
||||
(((*mods_inout)&type->mods.mask)==entry->mods.mask)){
|
||||
if (lvl_rtrn!=NULL)
|
||||
*lvl_rtrn= entry->level;
|
||||
if (type->preserve)
|
||||
preserve= type->preserve[i].mask;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
(*mods_inout)&= ~(type->mods.mask&(~preserve));
|
||||
}
|
||||
return True;
|
||||
}
|
||||
|
||||
/***===================================================================***/
|
||||
|
||||
static Bool
|
||||
XkbWriteSectionFromName(FILE *file,char *sectionName,char *name)
|
||||
{
|
||||
fprintf(file," xkb_%-20s { include \"%s\" };\n",sectionName,name);
|
||||
return True;
|
||||
}
|
||||
|
||||
#define NEED_DESC(n) ((!n)||((n)[0]=='+')||((n)[0]=='|')||(strchr((n),'%')))
|
||||
#define COMPLETE(n) ((n)&&(!NEED_DESC(n)))
|
||||
|
||||
/* ARGSUSED */
|
||||
static void
|
||||
_AddIncl( FILE * file,
|
||||
XkbFileInfo * result,
|
||||
Bool topLevel,
|
||||
Bool showImplicit,
|
||||
int index,
|
||||
void * priv)
|
||||
{
|
||||
if ((priv)&&(strcmp((char *)priv,"%")!=0))
|
||||
fprintf(file," include \"%s\"\n",(char *)priv);
|
||||
return;
|
||||
}
|
||||
|
||||
Bool
|
||||
XkbWriteXKBKeymapForNames( FILE * file,
|
||||
XkbComponentNamesPtr names,
|
||||
Display * dpy,
|
||||
XkbDescPtr xkb,
|
||||
unsigned want,
|
||||
unsigned need)
|
||||
{
|
||||
char * name;
|
||||
const char * tmp;
|
||||
unsigned complete;
|
||||
XkbNamesPtr old_names;
|
||||
int multi_section;
|
||||
unsigned wantNames,wantConfig,wantDflts;
|
||||
XkbFileInfo finfo;
|
||||
|
||||
bzero(&finfo,sizeof(XkbFileInfo));
|
||||
|
||||
complete= 0;
|
||||
if ((name=names->keymap)==NULL) name= "default";
|
||||
if (COMPLETE(names->keycodes)) complete|= XkmKeyNamesMask;
|
||||
if (COMPLETE(names->types)) complete|= XkmTypesMask;
|
||||
if (COMPLETE(names->compat)) complete|= XkmCompatMapMask;
|
||||
if (COMPLETE(names->symbols)) complete|= XkmSymbolsMask;
|
||||
if (COMPLETE(names->geometry)) complete|= XkmGeometryMask;
|
||||
want|= (complete|need);
|
||||
if (want&XkmSymbolsMask)
|
||||
want|= XkmKeyNamesMask|XkmTypesMask;
|
||||
|
||||
if (want==0)
|
||||
return False;
|
||||
|
||||
if (xkb!=NULL) {
|
||||
old_names= xkb->names;
|
||||
finfo.type= 0;
|
||||
finfo.defined= 0;
|
||||
finfo.xkb= xkb;
|
||||
if (!XkbDetermineFileType(&finfo,XkbXKBFile,NULL))
|
||||
return False;
|
||||
}
|
||||
else old_names= NULL;
|
||||
|
||||
wantConfig= want&(~complete);
|
||||
if (xkb!=NULL) {
|
||||
if (wantConfig&XkmTypesMask) {
|
||||
if ((!xkb->map) || (xkb->map->num_types<XkbNumRequiredTypes))
|
||||
wantConfig&= ~XkmTypesMask;
|
||||
}
|
||||
if (wantConfig&XkmCompatMapMask) {
|
||||
if ((!xkb->compat) || (xkb->compat->num_si<1))
|
||||
wantConfig&= ~XkmCompatMapMask;
|
||||
}
|
||||
if (wantConfig&XkmSymbolsMask) {
|
||||
if ((!xkb->map) || (!xkb->map->key_sym_map))
|
||||
wantConfig&= ~XkmSymbolsMask;
|
||||
}
|
||||
if (wantConfig&XkmIndicatorsMask) {
|
||||
if (!xkb->indicators)
|
||||
wantConfig&= ~XkmIndicatorsMask;
|
||||
}
|
||||
if (wantConfig&XkmKeyNamesMask) {
|
||||
if ((!xkb->names)||(!xkb->names->keys))
|
||||
wantConfig&= ~XkmKeyNamesMask;
|
||||
}
|
||||
if ((wantConfig&XkmGeometryMask)&&(!xkb->geom))
|
||||
wantConfig&= ~XkmGeometryMask;
|
||||
}
|
||||
else {
|
||||
wantConfig= 0;
|
||||
}
|
||||
complete|= wantConfig;
|
||||
|
||||
wantDflts= 0;
|
||||
wantNames= want&(~complete);
|
||||
if ((xkb!=NULL) && (old_names!=NULL)) {
|
||||
if (wantNames&XkmTypesMask) {
|
||||
if (old_names->types!=None) {
|
||||
tmp= NameForAtom(old_names->types);
|
||||
names->types= Xstrdup(tmp);
|
||||
}
|
||||
else {
|
||||
wantDflts|= XkmTypesMask;
|
||||
}
|
||||
complete|= XkmTypesMask;
|
||||
}
|
||||
if (wantNames&XkmCompatMapMask) {
|
||||
if (old_names->compat!=None) {
|
||||
tmp= NameForAtom(old_names->compat);
|
||||
names->compat= Xstrdup(tmp);
|
||||
}
|
||||
else wantDflts|= XkmCompatMapMask;
|
||||
complete|= XkmCompatMapMask;
|
||||
}
|
||||
if (wantNames&XkmSymbolsMask) {
|
||||
if (old_names->symbols==None)
|
||||
return False;
|
||||
tmp= NameForAtom(old_names->symbols);
|
||||
names->symbols= Xstrdup(tmp);
|
||||
complete|= XkmSymbolsMask;
|
||||
}
|
||||
if (wantNames&XkmKeyNamesMask) {
|
||||
if (old_names->keycodes!=None) {
|
||||
tmp= NameForAtom(old_names->keycodes);
|
||||
names->keycodes= Xstrdup(tmp);
|
||||
}
|
||||
else wantDflts|= XkmKeyNamesMask;
|
||||
complete|= XkmKeyNamesMask;
|
||||
}
|
||||
if (wantNames&XkmGeometryMask) {
|
||||
if (old_names->geometry==None)
|
||||
return False;
|
||||
tmp= NameForAtom(old_names->geometry);
|
||||
names->geometry= Xstrdup(tmp);
|
||||
complete|= XkmGeometryMask;
|
||||
wantNames&= ~XkmGeometryMask;
|
||||
}
|
||||
}
|
||||
if (complete&XkmCompatMapMask)
|
||||
complete|= XkmIndicatorsMask|XkmVirtualModsMask;
|
||||
else if (complete&(XkmSymbolsMask|XkmTypesMask))
|
||||
complete|= XkmVirtualModsMask;
|
||||
if (need & (~complete))
|
||||
return False;
|
||||
if ((complete&XkmSymbolsMask)&&((XkmKeyNamesMask|XkmTypesMask)&(~complete)))
|
||||
return False;
|
||||
|
||||
multi_section= 1;
|
||||
if (((complete&XkmKeymapRequired)==XkmKeymapRequired)&&
|
||||
((complete&(~XkmKeymapLegal))==0)) {
|
||||
fprintf(file,"xkb_keymap \"%s\" {\n",name);
|
||||
}
|
||||
else if (((complete&XkmSemanticsRequired)==XkmSemanticsRequired)&&
|
||||
((complete&(~XkmSemanticsLegal))==0)) {
|
||||
fprintf(file,"xkb_semantics \"%s\" {\n",name);
|
||||
}
|
||||
else if (((complete&XkmLayoutRequired)==XkmLayoutRequired)&&
|
||||
((complete&(~XkmLayoutLegal))==0)) {
|
||||
fprintf(file,"xkb_layout \"%s\" {\n",name);
|
||||
}
|
||||
else if (XkmSingleSection(complete&(~XkmVirtualModsMask))) {
|
||||
multi_section= 0;
|
||||
}
|
||||
else {
|
||||
return False;
|
||||
}
|
||||
|
||||
wantNames= complete&(~(wantConfig|wantDflts));
|
||||
name= names->keycodes;
|
||||
if (wantConfig&XkmKeyNamesMask)
|
||||
XkbWriteXKBKeycodes(file,&finfo,False,False,_AddIncl,name);
|
||||
else if (wantDflts&XkmKeyNamesMask)
|
||||
fprintf(stderr,"Default symbols not implemented yet!\n");
|
||||
else if (wantNames&XkmKeyNamesMask)
|
||||
XkbWriteSectionFromName(file,"keycodes",name);
|
||||
|
||||
name= names->types;
|
||||
if (wantConfig&XkmTypesMask)
|
||||
XkbWriteXKBKeyTypes(file,&finfo,False,False,_AddIncl,name);
|
||||
else if (wantDflts&XkmTypesMask)
|
||||
fprintf(stderr,"Default types not implemented yet!\n");
|
||||
else if (wantNames&XkmTypesMask)
|
||||
XkbWriteSectionFromName(file,"types",name);
|
||||
|
||||
name= names->compat;
|
||||
if (wantConfig&XkmCompatMapMask)
|
||||
XkbWriteXKBCompatMap(file,&finfo,False,False,_AddIncl,name);
|
||||
else if (wantDflts&XkmCompatMapMask)
|
||||
fprintf(stderr,"Default interps not implemented yet!\n");
|
||||
else if (wantNames&XkmCompatMapMask)
|
||||
XkbWriteSectionFromName(file,"compatibility",name);
|
||||
|
||||
name= names->symbols;
|
||||
if (wantConfig&XkmSymbolsMask)
|
||||
XkbWriteXKBSymbols(file,&finfo,False,False,_AddIncl,name);
|
||||
else if (wantNames&XkmSymbolsMask)
|
||||
XkbWriteSectionFromName(file,"symbols",name);
|
||||
|
||||
name= names->geometry;
|
||||
if (wantConfig&XkmGeometryMask)
|
||||
XkbWriteXKBGeometry(file,&finfo,False,False,_AddIncl,name);
|
||||
else if (wantNames&XkmGeometryMask)
|
||||
XkbWriteSectionFromName(file,"geometry",name);
|
||||
|
||||
if (multi_section)
|
||||
fprintf(file,"};\n");
|
||||
return True;
|
||||
}
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
/*ARGSUSED*/
|
||||
Status
|
||||
XkbMergeFile(XkbDescPtr xkb,XkbFileInfo finfo)
|
||||
{
|
||||
return BadImplementation;
|
||||
}
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
int
|
||||
XkbFindKeycodeByName(XkbDescPtr xkb,char *name,Bool use_aliases)
|
||||
{
|
||||
register int i;
|
||||
|
||||
if ((!xkb)||(!xkb->names)||(!xkb->names->keys))
|
||||
return 0;
|
||||
for (i=xkb->min_key_code;i<=xkb->max_key_code;i++) {
|
||||
if (strncmp(xkb->names->keys[i].name,name,XkbKeyNameLength)==0)
|
||||
return i;
|
||||
}
|
||||
if (!use_aliases)
|
||||
return 0;
|
||||
if (xkb->geom && xkb->geom->key_aliases) {
|
||||
XkbKeyAliasPtr a;
|
||||
a= xkb->geom->key_aliases;
|
||||
for (i=0;i<xkb->geom->num_key_aliases;i++,a++) {
|
||||
if (strncmp(name,a->alias,XkbKeyNameLength)==0)
|
||||
return XkbFindKeycodeByName(xkb,a->real,False);
|
||||
}
|
||||
}
|
||||
if (xkb->names && xkb->names->key_aliases) {
|
||||
XkbKeyAliasPtr a;
|
||||
a= xkb->names->key_aliases;
|
||||
for (i=0;i<xkb->names->num_key_aliases;i++,a++) {
|
||||
if (strncmp(name,a->alias,XkbKeyNameLength)==0)
|
||||
return XkbFindKeycodeByName(xkb,a->real,False);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
unsigned
|
||||
XkbConvertGetByNameComponents(Bool toXkm,unsigned orig)
|
||||
{
|
||||
unsigned rtrn;
|
||||
|
||||
rtrn= 0;
|
||||
if (toXkm) {
|
||||
if (orig&XkbGBN_TypesMask) rtrn|= XkmTypesMask;
|
||||
if (orig&XkbGBN_CompatMapMask) rtrn|= XkmCompatMapMask;
|
||||
if (orig&XkbGBN_SymbolsMask) rtrn|= XkmSymbolsMask;
|
||||
if (orig&XkbGBN_IndicatorMapMask) rtrn|= XkmIndicatorsMask;
|
||||
if (orig&XkbGBN_KeyNamesMask) rtrn|= XkmKeyNamesMask;
|
||||
if (orig&XkbGBN_GeometryMask) rtrn|= XkmGeometryMask;
|
||||
}
|
||||
else {
|
||||
if (orig&XkmTypesMask) rtrn|= XkbGBN_TypesMask;
|
||||
if (orig&XkmCompatMapMask) rtrn|= XkbGBN_CompatMapMask;
|
||||
if (orig&XkmSymbolsMask) rtrn|= XkbGBN_SymbolsMask;
|
||||
if (orig&XkmIndicatorsMask) rtrn|= XkbGBN_IndicatorMapMask;
|
||||
if (orig&XkmKeyNamesMask) rtrn|= XkbGBN_KeyNamesMask;
|
||||
if (orig&XkmGeometryMask) rtrn|= XkbGBN_GeometryMask;
|
||||
if (orig!=0) rtrn|= XkbGBN_OtherNamesMask;
|
||||
}
|
||||
return rtrn;
|
||||
}
|
||||
|
||||
unsigned
|
||||
XkbConvertXkbComponents(Bool toXkm,unsigned orig)
|
||||
{
|
||||
unsigned rtrn;
|
||||
|
||||
rtrn= 0;
|
||||
if (toXkm) {
|
||||
if (orig&XkbClientMapMask) rtrn|= XkmTypesMask|XkmSymbolsMask;
|
||||
if (orig&XkbServerMapMask) rtrn|= XkmTypesMask|XkmSymbolsMask;
|
||||
if (orig&XkbCompatMapMask) rtrn|= XkmCompatMapMask;
|
||||
if (orig&XkbIndicatorMapMask) rtrn|= XkmIndicatorsMask;
|
||||
if (orig&XkbNamesMask) rtrn|= XkmKeyNamesMask;
|
||||
if (orig&XkbGeometryMask) rtrn|= XkmGeometryMask;
|
||||
}
|
||||
else {
|
||||
if (orig!=0) rtrn|= XkbNamesMask;
|
||||
if (orig&XkmTypesMask) rtrn|= XkbClientMapMask;
|
||||
if (orig&XkmCompatMapMask)
|
||||
rtrn|= XkbCompatMapMask|XkbIndicatorMapMask;
|
||||
if (orig&XkmSymbolsMask) rtrn|=XkbClientMapMask|XkbServerMapMask;
|
||||
if (orig&XkmIndicatorsMask) rtrn|= XkbIndicatorMapMask;
|
||||
if (orig&XkmKeyNamesMask)
|
||||
rtrn|= XkbNamesMask|XkbIndicatorMapMask;
|
||||
if (orig&XkmGeometryMask) rtrn|= XkbGeometryMask;
|
||||
}
|
||||
return rtrn;
|
||||
}
|
||||
|
||||
Bool
|
||||
XkbDetermineFileType(XkbFileInfoPtr finfo,int format,int *opts_missing)
|
||||
{
|
||||
unsigned present;
|
||||
XkbDescPtr xkb;
|
||||
|
||||
if ((!finfo)||(!finfo->xkb))
|
||||
return False;
|
||||
if (opts_missing)
|
||||
*opts_missing= 0;
|
||||
xkb= finfo->xkb;
|
||||
present= 0;
|
||||
if ((xkb->names)&&(xkb->names->keys)) present|= XkmKeyNamesMask;
|
||||
if ((xkb->map)&&(xkb->map->types)) present|= XkmTypesMask;
|
||||
if (xkb->compat) present|= XkmCompatMapMask;
|
||||
if ((xkb->map)&&(xkb->map->num_syms>1)) present|= XkmSymbolsMask;
|
||||
if (xkb->indicators) present|= XkmIndicatorsMask;
|
||||
if (xkb->geom) present|= XkmGeometryMask;
|
||||
if (!present)
|
||||
return False;
|
||||
else switch (present) {
|
||||
case XkmKeyNamesMask:
|
||||
finfo->type= XkmKeyNamesIndex;
|
||||
finfo->defined= present;
|
||||
return True;
|
||||
case XkmTypesMask:
|
||||
finfo->type= XkmTypesIndex;
|
||||
finfo->defined= present;
|
||||
return True;
|
||||
case XkmCompatMapMask:
|
||||
finfo->type= XkmCompatMapIndex;
|
||||
finfo->defined= present;
|
||||
return True;
|
||||
case XkmSymbolsMask:
|
||||
if (format!=XkbXKMFile) {
|
||||
finfo->type= XkmSymbolsIndex;
|
||||
finfo->defined= present;
|
||||
return True;
|
||||
}
|
||||
break;
|
||||
case XkmGeometryMask:
|
||||
finfo->type= XkmGeometryIndex;
|
||||
finfo->defined= present;
|
||||
return True;
|
||||
}
|
||||
if ((present&(~XkmSemanticsLegal))==0) {
|
||||
if ((XkmSemanticsRequired&present)==XkmSemanticsRequired) {
|
||||
if (opts_missing)
|
||||
*opts_missing= XkmSemanticsOptional&(~present);
|
||||
finfo->type= XkmSemanticsFile;
|
||||
finfo->defined= present;
|
||||
return True;
|
||||
}
|
||||
}
|
||||
else if ((present&(~XkmLayoutLegal))==0) {
|
||||
if ((XkmLayoutRequired&present)==XkmLayoutRequired) {
|
||||
if (opts_missing)
|
||||
*opts_missing= XkmLayoutOptional&(~present);
|
||||
finfo->type= XkmLayoutFile;
|
||||
finfo->defined= present;
|
||||
return True;
|
||||
}
|
||||
}
|
||||
else if ((present&(~XkmKeymapLegal))==0) {
|
||||
if ((XkmKeymapRequired&present)==XkmKeymapRequired) {
|
||||
if (opts_missing)
|
||||
*opts_missing= XkmKeymapOptional&(~present);
|
||||
finfo->type= XkmKeymapFile;
|
||||
finfo->defined= present;
|
||||
return True;
|
||||
}
|
||||
}
|
||||
return False;
|
||||
}
|
||||
|
||||
/* all latin-1 alphanumerics, plus parens, slash, minus, underscore and */
|
||||
/* wildcards */
|
||||
|
||||
static unsigned char componentSpecLegal[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xa7, 0xff, 0x83,
|
||||
0xfe, 0xff, 0xff, 0x87, 0xfe, 0xff, 0xff, 0x07,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0x7f, 0xff
|
||||
};
|
||||
|
||||
void
|
||||
XkbEnsureSafeMapName(char *name)
|
||||
{
|
||||
if (name==NULL)
|
||||
return;
|
||||
while (*name!='\0') {
|
||||
if ((componentSpecLegal[(*name)/8]&(1<<((*name)%8)))==0)
|
||||
*name= '_';
|
||||
name++;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
#define UNMATCHABLE(c) (((c)=='(')||((c)==')')||((c)=='/'))
|
||||
|
||||
Bool
|
||||
XkbNameMatchesPattern(char *name,char *ptrn)
|
||||
{
|
||||
while (ptrn[0]!='\0') {
|
||||
if (name[0]=='\0') {
|
||||
if (ptrn[0]=='*') {
|
||||
ptrn++;
|
||||
continue;
|
||||
}
|
||||
return False;
|
||||
}
|
||||
if (ptrn[0]=='?') {
|
||||
if (UNMATCHABLE(name[0]))
|
||||
return False;
|
||||
}
|
||||
else if (ptrn[0]=='*') {
|
||||
if ((!UNMATCHABLE(name[0]))&&XkbNameMatchesPattern(name+1,ptrn))
|
||||
return True;
|
||||
return XkbNameMatchesPattern(name,ptrn+1);
|
||||
}
|
||||
else if (ptrn[0]!=name[0])
|
||||
return False;
|
||||
name++;
|
||||
ptrn++;
|
||||
}
|
||||
/* if we get here, the pattern is exhausted (-:just like me:-) */
|
||||
return (name[0]=='\0');
|
||||
}
|
||||
655
nx-X11/programs/Xserver/xkb/xkbgeom.h
Normal file
655
nx-X11/programs/Xserver/xkb/xkbgeom.h
Normal file
@@ -0,0 +1,655 @@
|
||||
/************************************************************
|
||||
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.
|
||||
|
||||
********************************************************/
|
||||
|
||||
#ifndef _XKBGEOM_H_
|
||||
#define _XKBGEOM_H_
|
||||
|
||||
#include "xkbstr.h"
|
||||
|
||||
#define XkbAddGeomKeyAlias SrvXkbAddGeomKeyAlias
|
||||
#define XkbAddGeomColor SrvXkbAddGeomColor
|
||||
#define XkbAddGeomDoodad SrvXkbAddGeomDoodad
|
||||
#define XkbAddGeomKey SrvXkbAddGeomKey
|
||||
#define XkbAddGeomOutline SrvXkbAddGeomOutline
|
||||
#define XkbAddGeomOverlay SrvXkbAddGeomOverlay
|
||||
#define XkbAddGeomOverlayRow SrvXkbAddGeomOverlayRow
|
||||
#define XkbAddGeomOverlayKey SrvXkbAddGeomOverlayKey
|
||||
#define XkbAddGeomProperty SrvXkbAddGeomProperty
|
||||
#define XkbAddGeomRow SrvXkbAddGeomRow
|
||||
#define XkbAddGeomSection SrvXkbAddGeomSection
|
||||
#define XkbAddGeomShape SrvXkbAddGeomShape
|
||||
#define XkbAllocGeomKeyAliases SrvXkbAllocGeomKeyAliases
|
||||
#define XkbAllocGeomColors SrvXkbAllocGeomColors
|
||||
#define XkbAllocGeomDoodads SrvXkbAllocGeomDoodads
|
||||
#define XkbAllocGeomKeys SrvXkbAllocGeomKeys
|
||||
#define XkbAllocGeomOutlines SrvXkbAllocGeomOutlines
|
||||
#define XkbAllocGeomPoints SrvXkbAllocGeomPoints
|
||||
#define XkbAllocGeomProps SrvXkbAllocGeomProps
|
||||
#define XkbAllocGeomRows SrvXkbAllocGeomRows
|
||||
#define XkbAllocGeomSectionDoodads SrvXkbAllocGeomSectionDoodads
|
||||
#define XkbAllocGeomSections SrvXkbAllocGeomSections
|
||||
#define XkbAllocGeomOverlays SrvXkbAllocGeomOverlays
|
||||
#define XkbAllocGeomOverlayRows SrvXkbAllocGeomOverlayRows
|
||||
#define XkbAllocGeomOverlayKeys SrvXkbAllocGeomOverlayKeys
|
||||
#define XkbAllocGeomShapes SrvXkbAllocGeomShapes
|
||||
#define XkbAllocGeometry SrvXkbAllocGeometry
|
||||
#define XkbFreeGeomKeyAliases SrvXkbFreeGeomKeyAliases
|
||||
#define XkbFreeGeomColors SrvXkbFreeGeomColors
|
||||
#define XkbFreeGeomDoodads SrvXkbFreeGeomDoodads
|
||||
#define XkbFreeGeomProperties SrvXkbFreeGeomProperties
|
||||
#define XkbFreeGeomOverlayKeys SrvXkbFreeGeomOverlayKeys
|
||||
#define XkbFreeGeomOverlayRows SrvXkbFreeGeomOverlayRows
|
||||
#define XkbFreeGeomOverlays SrvXkbFreeGeomOverlays
|
||||
#define XkbFreeGeomKeys SrvXkbFreeGeomKeys
|
||||
#define XkbFreeGeomRows SrvXkbFreeGeomRows
|
||||
#define XkbFreeGeomSections SrvXkbFreeGeomSections
|
||||
#define XkbFreeGeomPoints SrvXkbFreeGeomPoints
|
||||
#define XkbFreeGeomOutlines SrvXkbFreeGeomOutlines
|
||||
#define XkbFreeGeomShapes SrvXkbFreeGeomShapes
|
||||
#define XkbFreeGeometry SrvXkbFreeGeometry
|
||||
|
||||
typedef struct _XkbProperty {
|
||||
char *name;
|
||||
char *value;
|
||||
} XkbPropertyRec,*XkbPropertyPtr;
|
||||
|
||||
typedef struct _XkbColor {
|
||||
unsigned int pixel;
|
||||
char * spec;
|
||||
} XkbColorRec,*XkbColorPtr;
|
||||
|
||||
typedef struct _XkbPoint {
|
||||
short x;
|
||||
short y;
|
||||
} XkbPointRec, *XkbPointPtr;
|
||||
|
||||
typedef struct _XkbBounds {
|
||||
short x1,y1;
|
||||
short x2,y2;
|
||||
} XkbBoundsRec, *XkbBoundsPtr;
|
||||
#define XkbBoundsWidth(b) (((b)->x2)-((b)->x1))
|
||||
#define XkbBoundsHeight(b) (((b)->y2)-((b)->y1))
|
||||
|
||||
typedef struct _XkbOutline {
|
||||
unsigned short num_points;
|
||||
unsigned short sz_points;
|
||||
unsigned short corner_radius;
|
||||
XkbPointPtr points;
|
||||
} XkbOutlineRec, *XkbOutlinePtr;
|
||||
|
||||
typedef struct _XkbShape {
|
||||
Atom name;
|
||||
unsigned short num_outlines;
|
||||
unsigned short sz_outlines;
|
||||
XkbOutlinePtr outlines;
|
||||
XkbOutlinePtr approx;
|
||||
XkbOutlinePtr primary;
|
||||
XkbBoundsRec bounds;
|
||||
} XkbShapeRec, *XkbShapePtr;
|
||||
#define XkbOutlineIndex(s,o) ((int)((o)-&(s)->outlines[0]))
|
||||
|
||||
typedef struct _XkbShapeDoodad {
|
||||
Atom name;
|
||||
unsigned char type;
|
||||
unsigned char priority;
|
||||
short top;
|
||||
short left;
|
||||
short angle;
|
||||
unsigned short color_ndx;
|
||||
unsigned short shape_ndx;
|
||||
} XkbShapeDoodadRec, *XkbShapeDoodadPtr;
|
||||
#define XkbShapeDoodadColor(g,d) (&(g)->colors[(d)->color_ndx])
|
||||
#define XkbShapeDoodadShape(g,d) (&(g)->shapes[(d)->shape_ndx])
|
||||
#define XkbSetShapeDoodadColor(g,d,c) ((d)->color_ndx= (c)-&(g)->colors[0])
|
||||
#define XkbSetShapeDoodadShape(g,d,s) ((d)->shape_ndx= (s)-&(g)->shapes[0])
|
||||
|
||||
typedef struct _XkbTextDoodad {
|
||||
Atom name;
|
||||
unsigned char type;
|
||||
unsigned char priority;
|
||||
short top;
|
||||
short left;
|
||||
short angle;
|
||||
short width;
|
||||
short height;
|
||||
unsigned short color_ndx;
|
||||
char * text;
|
||||
char * font;
|
||||
} XkbTextDoodadRec, *XkbTextDoodadPtr;
|
||||
#define XkbTextDoodadColor(g,d) (&(g)->colors[(d)->color_ndx])
|
||||
#define XkbSetTextDoodadColor(g,d,c) ((d)->color_ndx= (c)-&(g)->colors[0])
|
||||
|
||||
typedef struct _XkbIndicatorDoodad {
|
||||
Atom name;
|
||||
unsigned char type;
|
||||
unsigned char priority;
|
||||
short top;
|
||||
short left;
|
||||
short angle;
|
||||
unsigned short shape_ndx;
|
||||
unsigned short on_color_ndx;
|
||||
unsigned short off_color_ndx;
|
||||
} XkbIndicatorDoodadRec, *XkbIndicatorDoodadPtr;
|
||||
#define XkbIndicatorDoodadShape(g,d) (&(g)->shapes[(d)->shape_ndx])
|
||||
#define XkbIndicatorDoodadOnColor(g,d) (&(g)->colors[(d)->on_color_ndx])
|
||||
#define XkbIndicatorDoodadOffColor(g,d) (&(g)->colors[(d)->off_color_ndx])
|
||||
#define XkbSetIndicatorDoodadOnColor(g,d,c) \
|
||||
((d)->on_color_ndx= (c)-&(g)->colors[0])
|
||||
#define XkbSetIndicatorDoodadOffColor(g,d,c) \
|
||||
((d)->off_color_ndx= (c)-&(g)->colors[0])
|
||||
#define XkbSetIndicatorDoodadShape(g,d,s) \
|
||||
((d)->shape_ndx= (s)-&(g)->shapes[0])
|
||||
|
||||
typedef struct _XkbLogoDoodad {
|
||||
Atom name;
|
||||
unsigned char type;
|
||||
unsigned char priority;
|
||||
short top;
|
||||
short left;
|
||||
short angle;
|
||||
unsigned short color_ndx;
|
||||
unsigned short shape_ndx;
|
||||
char * logo_name;
|
||||
} XkbLogoDoodadRec, *XkbLogoDoodadPtr;
|
||||
#define XkbLogoDoodadColor(g,d) (&(g)->colors[(d)->color_ndx])
|
||||
#define XkbLogoDoodadShape(g,d) (&(g)->shapes[(d)->shape_ndx])
|
||||
#define XkbSetLogoDoodadColor(g,d,c) ((d)->color_ndx= (c)-&(g)->colors[0])
|
||||
#define XkbSetLogoDoodadShape(g,d,s) ((d)->shape_ndx= (s)-&(g)->shapes[0])
|
||||
|
||||
typedef struct _XkbAnyDoodad {
|
||||
Atom name;
|
||||
unsigned char type;
|
||||
unsigned char priority;
|
||||
short top;
|
||||
short left;
|
||||
short angle;
|
||||
} XkbAnyDoodadRec, *XkbAnyDoodadPtr;
|
||||
|
||||
typedef union _XkbDoodad {
|
||||
XkbAnyDoodadRec any;
|
||||
XkbShapeDoodadRec shape;
|
||||
XkbTextDoodadRec text;
|
||||
XkbIndicatorDoodadRec indicator;
|
||||
XkbLogoDoodadRec logo;
|
||||
} XkbDoodadRec, *XkbDoodadPtr;
|
||||
|
||||
#define XkbUnknownDoodad 0
|
||||
#define XkbOutlineDoodad 1
|
||||
#define XkbSolidDoodad 2
|
||||
#define XkbTextDoodad 3
|
||||
#define XkbIndicatorDoodad 4
|
||||
#define XkbLogoDoodad 5
|
||||
|
||||
typedef struct _XkbKey {
|
||||
XkbKeyNameRec name;
|
||||
short gap;
|
||||
unsigned char shape_ndx;
|
||||
unsigned char color_ndx;
|
||||
} XkbKeyRec, *XkbKeyPtr;
|
||||
#define XkbKeyShape(g,k) (&(g)->shapes[(k)->shape_ndx])
|
||||
#define XkbKeyColor(g,k) (&(g)->colors[(k)->color_ndx])
|
||||
#define XkbSetKeyShape(g,k,s) ((k)->shape_ndx= (s)-&(g)->shapes[0])
|
||||
#define XkbSetKeyColor(g,k,c) ((k)->color_ndx= (c)-&(g)->colors[0])
|
||||
|
||||
typedef struct _XkbRow {
|
||||
short top;
|
||||
short left;
|
||||
unsigned short num_keys;
|
||||
unsigned short sz_keys;
|
||||
int vertical;
|
||||
XkbKeyPtr keys;
|
||||
XkbBoundsRec bounds;
|
||||
} XkbRowRec, *XkbRowPtr;
|
||||
|
||||
typedef struct _XkbSection {
|
||||
Atom name;
|
||||
unsigned char priority;
|
||||
short top;
|
||||
short left;
|
||||
unsigned short width;
|
||||
unsigned short height;
|
||||
short angle;
|
||||
unsigned short num_rows;
|
||||
unsigned short num_doodads;
|
||||
unsigned short num_overlays;
|
||||
unsigned short sz_rows;
|
||||
unsigned short sz_doodads;
|
||||
unsigned short sz_overlays;
|
||||
XkbRowPtr rows;
|
||||
XkbDoodadPtr doodads;
|
||||
XkbBoundsRec bounds;
|
||||
struct _XkbOverlay *overlays;
|
||||
} XkbSectionRec, *XkbSectionPtr;
|
||||
|
||||
typedef struct _XkbOverlayKey {
|
||||
XkbKeyNameRec over;
|
||||
XkbKeyNameRec under;
|
||||
} XkbOverlayKeyRec,*XkbOverlayKeyPtr;
|
||||
|
||||
typedef struct _XkbOverlayRow {
|
||||
unsigned short row_under;
|
||||
unsigned short num_keys;
|
||||
unsigned short sz_keys;
|
||||
XkbOverlayKeyPtr keys;
|
||||
} XkbOverlayRowRec,*XkbOverlayRowPtr;
|
||||
|
||||
typedef struct _XkbOverlay {
|
||||
Atom name;
|
||||
XkbSectionPtr section_under;
|
||||
unsigned short num_rows;
|
||||
unsigned short sz_rows;
|
||||
XkbOverlayRowPtr rows;
|
||||
XkbBoundsPtr bounds;
|
||||
} XkbOverlayRec,*XkbOverlayPtr;
|
||||
|
||||
typedef struct _XkbGeometry {
|
||||
Atom name;
|
||||
unsigned short width_mm;
|
||||
unsigned short height_mm;
|
||||
char * label_font;
|
||||
XkbColorPtr label_color;
|
||||
XkbColorPtr base_color;
|
||||
unsigned short sz_properties;
|
||||
unsigned short sz_colors;
|
||||
unsigned short sz_shapes;
|
||||
unsigned short sz_sections;
|
||||
unsigned short sz_doodads;
|
||||
unsigned short sz_key_aliases;
|
||||
unsigned short num_properties;
|
||||
unsigned short num_colors;
|
||||
unsigned short num_shapes;
|
||||
unsigned short num_sections;
|
||||
unsigned short num_doodads;
|
||||
unsigned short num_key_aliases;
|
||||
XkbPropertyPtr properties;
|
||||
XkbColorPtr colors;
|
||||
XkbShapePtr shapes;
|
||||
XkbSectionPtr sections;
|
||||
XkbDoodadPtr doodads;
|
||||
XkbKeyAliasPtr key_aliases;
|
||||
} XkbGeometryRec;
|
||||
#define XkbGeomColorIndex(g,c) ((int)((c)-&(g)->colors[0]))
|
||||
|
||||
#define XkbGeomPropertiesMask (1<<0)
|
||||
#define XkbGeomColorsMask (1<<1)
|
||||
#define XkbGeomShapesMask (1<<2)
|
||||
#define XkbGeomSectionsMask (1<<3)
|
||||
#define XkbGeomDoodadsMask (1<<4)
|
||||
#define XkbGeomKeyAliasesMask (1<<5)
|
||||
#define XkbGeomAllMask (0x3f)
|
||||
|
||||
typedef struct _XkbGeometrySizes {
|
||||
unsigned int which;
|
||||
unsigned short num_properties;
|
||||
unsigned short num_colors;
|
||||
unsigned short num_shapes;
|
||||
unsigned short num_sections;
|
||||
unsigned short num_doodads;
|
||||
unsigned short num_key_aliases;
|
||||
} XkbGeometrySizesRec,*XkbGeometrySizesPtr;
|
||||
|
||||
_XFUNCPROTOBEGIN
|
||||
|
||||
extern XkbPropertyPtr
|
||||
XkbAddGeomProperty(
|
||||
XkbGeometryPtr /* geom */,
|
||||
char * /* name */,
|
||||
char * /* value */
|
||||
);
|
||||
|
||||
extern XkbKeyAliasPtr
|
||||
XkbAddGeomKeyAlias(
|
||||
XkbGeometryPtr /* geom */,
|
||||
char * /* alias */,
|
||||
char * /* real */
|
||||
);
|
||||
|
||||
extern XkbColorPtr
|
||||
XkbAddGeomColor(
|
||||
XkbGeometryPtr /* geom */,
|
||||
char * /* spec */,
|
||||
unsigned int /* pixel */
|
||||
);
|
||||
|
||||
extern XkbOutlinePtr
|
||||
XkbAddGeomOutline(
|
||||
XkbShapePtr /* shape */,
|
||||
int /* sz_points */
|
||||
);
|
||||
|
||||
extern XkbShapePtr
|
||||
XkbAddGeomShape(
|
||||
XkbGeometryPtr /* geom */,
|
||||
Atom /* name */,
|
||||
int /* sz_outlines */
|
||||
);
|
||||
|
||||
extern XkbKeyPtr
|
||||
XkbAddGeomKey(
|
||||
XkbRowPtr /* row */
|
||||
);
|
||||
|
||||
extern XkbRowPtr
|
||||
XkbAddGeomRow(
|
||||
XkbSectionPtr /* section */,
|
||||
int /* sz_keys */
|
||||
);
|
||||
|
||||
extern XkbSectionPtr
|
||||
XkbAddGeomSection(
|
||||
XkbGeometryPtr /* geom */,
|
||||
Atom /* name */,
|
||||
int /* sz_rows */,
|
||||
int /* sz_doodads */,
|
||||
int /* sz_overlays */
|
||||
);
|
||||
|
||||
extern XkbOverlayPtr
|
||||
XkbAddGeomOverlay(
|
||||
XkbSectionPtr /* section */,
|
||||
Atom /* name */,
|
||||
int /* sz_rows */
|
||||
);
|
||||
|
||||
extern XkbOverlayRowPtr
|
||||
XkbAddGeomOverlayRow(
|
||||
XkbOverlayPtr /* overlay */,
|
||||
int /* row_under */,
|
||||
int /* sz_keys */
|
||||
);
|
||||
|
||||
extern XkbOverlayKeyPtr
|
||||
XkbAddGeomOverlayKey(
|
||||
XkbOverlayPtr /* overlay */,
|
||||
XkbOverlayRowPtr /* row */,
|
||||
char * /* over */,
|
||||
char * /* under */
|
||||
);
|
||||
|
||||
extern XkbDoodadPtr
|
||||
XkbAddGeomDoodad(
|
||||
XkbGeometryPtr /* geom */,
|
||||
XkbSectionPtr /* section */,
|
||||
Atom /* name */
|
||||
);
|
||||
|
||||
|
||||
extern void
|
||||
XkbFreeGeomKeyAliases(
|
||||
XkbGeometryPtr /* geom */,
|
||||
int /* first */,
|
||||
int /* count */,
|
||||
Bool /* freeAll */
|
||||
);
|
||||
|
||||
extern void
|
||||
XkbFreeGeomColors(
|
||||
XkbGeometryPtr /* geom */,
|
||||
int /* first */,
|
||||
int /* count */,
|
||||
Bool /* freeAll */
|
||||
);
|
||||
|
||||
extern void
|
||||
XkbFreeGeomDoodads(
|
||||
XkbDoodadPtr /* doodads */,
|
||||
int /* nDoodads */,
|
||||
Bool /* freeAll */
|
||||
);
|
||||
|
||||
|
||||
extern void
|
||||
XkbFreeGeomProperties(
|
||||
XkbGeometryPtr /* geom */,
|
||||
int /* first */,
|
||||
int /* count */,
|
||||
Bool /* freeAll */
|
||||
);
|
||||
|
||||
extern void
|
||||
XkbFreeGeomOverlayKeys(
|
||||
XkbOverlayRowPtr /* row */,
|
||||
int /* first */,
|
||||
int /* count */,
|
||||
Bool /* freeAll */
|
||||
);
|
||||
|
||||
extern void
|
||||
XkbFreeGeomOverlayRows(
|
||||
XkbOverlayPtr /* overlay */,
|
||||
int /* first */,
|
||||
int /* count */,
|
||||
Bool /* freeAll */
|
||||
);
|
||||
|
||||
extern void
|
||||
XkbFreeGeomOverlays(
|
||||
XkbSectionPtr /* section */,
|
||||
int /* first */,
|
||||
int /* count */,
|
||||
Bool /* freeAll */
|
||||
);
|
||||
|
||||
extern void
|
||||
XkbFreeGeomKeys(
|
||||
XkbRowPtr /* row */,
|
||||
int /* first */,
|
||||
int /* count */,
|
||||
Bool /* freeAll */
|
||||
);
|
||||
|
||||
extern void
|
||||
XkbFreeGeomRows(
|
||||
XkbSectionPtr /* section */,
|
||||
int /* first */,
|
||||
int /* count */,
|
||||
Bool /* freeAll */
|
||||
);
|
||||
|
||||
extern void
|
||||
XkbFreeGeomSections(
|
||||
XkbGeometryPtr /* geom */,
|
||||
int /* first */,
|
||||
int /* count */,
|
||||
Bool /* freeAll */
|
||||
);
|
||||
|
||||
|
||||
extern void
|
||||
XkbFreeGeomPoints(
|
||||
XkbOutlinePtr /* outline */,
|
||||
int /* first */,
|
||||
int /* count */,
|
||||
Bool /* freeAll */
|
||||
);
|
||||
|
||||
extern void
|
||||
XkbFreeGeomOutlines(
|
||||
XkbShapePtr /* shape */,
|
||||
int /* first */,
|
||||
int /* count */,
|
||||
Bool /* freeAll */
|
||||
);
|
||||
|
||||
extern void
|
||||
XkbFreeGeomShapes(
|
||||
XkbGeometryPtr /* geom */,
|
||||
int /* first */,
|
||||
int /* count */,
|
||||
Bool /* freeAll */
|
||||
);
|
||||
|
||||
extern void
|
||||
XkbFreeGeometry(
|
||||
XkbGeometryPtr /* geom */,
|
||||
unsigned int /* which */,
|
||||
Bool /* freeMap */
|
||||
);
|
||||
|
||||
extern Status
|
||||
XkbAllocGeomProps(
|
||||
XkbGeometryPtr /* geom */,
|
||||
int /* nProps */
|
||||
);
|
||||
|
||||
extern Status
|
||||
XkbAllocGeomKeyAliases(
|
||||
XkbGeometryPtr /* geom */,
|
||||
int /* nAliases */
|
||||
);
|
||||
|
||||
extern Status
|
||||
XkbAllocGeomColors(
|
||||
XkbGeometryPtr /* geom */,
|
||||
int /* nColors */
|
||||
);
|
||||
|
||||
extern Status
|
||||
XkbAllocGeomShapes(
|
||||
XkbGeometryPtr /* geom */,
|
||||
int /* nShapes */
|
||||
);
|
||||
|
||||
extern Status
|
||||
XkbAllocGeomSections(
|
||||
XkbGeometryPtr /* geom */,
|
||||
int /* nSections */
|
||||
);
|
||||
|
||||
extern Status
|
||||
XkbAllocGeomOverlays(
|
||||
XkbSectionPtr /* section */,
|
||||
int /* num_needed */
|
||||
);
|
||||
|
||||
extern Status
|
||||
XkbAllocGeomOverlayRows(
|
||||
XkbOverlayPtr /* overlay */,
|
||||
int /* num_needed */
|
||||
);
|
||||
|
||||
extern Status
|
||||
XkbAllocGeomOverlayKeys(
|
||||
XkbOverlayRowPtr /* row */,
|
||||
int /* num_needed */
|
||||
);
|
||||
|
||||
extern Status
|
||||
XkbAllocGeomDoodads(
|
||||
XkbGeometryPtr /* geom */,
|
||||
int /* nDoodads */
|
||||
);
|
||||
|
||||
extern Status
|
||||
XkbAllocGeomSectionDoodads(
|
||||
XkbSectionPtr /* section */,
|
||||
int /* nDoodads */
|
||||
);
|
||||
|
||||
extern Status
|
||||
XkbAllocGeomOutlines(
|
||||
XkbShapePtr /* shape */,
|
||||
int /* nOL */
|
||||
);
|
||||
|
||||
extern Status
|
||||
XkbAllocGeomRows(
|
||||
XkbSectionPtr /* section */,
|
||||
int /* nRows */
|
||||
);
|
||||
|
||||
extern Status
|
||||
XkbAllocGeomPoints(
|
||||
XkbOutlinePtr /* ol */,
|
||||
int /* nPts */
|
||||
);
|
||||
|
||||
extern Status
|
||||
XkbAllocGeomKeys(
|
||||
XkbRowPtr /* row */,
|
||||
int /* nKeys */
|
||||
);
|
||||
|
||||
extern Status
|
||||
XkbAllocGeometry(
|
||||
XkbDescPtr /* xkb */,
|
||||
XkbGeometrySizesPtr /* sizes */
|
||||
);
|
||||
|
||||
extern Status
|
||||
XkbSetGeometry(
|
||||
Display * /* dpy */,
|
||||
unsigned /* deviceSpec */,
|
||||
XkbGeometryPtr /* geom */
|
||||
);
|
||||
|
||||
extern Bool
|
||||
XkbComputeShapeTop(
|
||||
XkbShapePtr /* shape */,
|
||||
XkbBoundsPtr /* bounds */
|
||||
);
|
||||
|
||||
extern Bool
|
||||
XkbComputeShapeBounds(
|
||||
XkbShapePtr /* shape */
|
||||
);
|
||||
|
||||
extern Bool
|
||||
XkbComputeRowBounds(
|
||||
XkbGeometryPtr /* geom */,
|
||||
XkbSectionPtr /* section */,
|
||||
XkbRowPtr /* row */
|
||||
);
|
||||
|
||||
extern Bool
|
||||
XkbComputeSectionBounds(
|
||||
XkbGeometryPtr /* geom */,
|
||||
XkbSectionPtr /* section */
|
||||
);
|
||||
|
||||
extern char *
|
||||
XkbFindOverlayForKey(
|
||||
XkbGeometryPtr /* geom */,
|
||||
XkbSectionPtr /* wanted */,
|
||||
char * /* under */
|
||||
);
|
||||
|
||||
extern Status
|
||||
XkbGetGeometry(
|
||||
Display * /* dpy */,
|
||||
XkbDescPtr /* xkb */
|
||||
);
|
||||
|
||||
extern Status
|
||||
XkbGetNamedGeometry(
|
||||
Display * /* dpy */,
|
||||
XkbDescPtr /* xkb */,
|
||||
Atom /* name */
|
||||
);
|
||||
|
||||
_XFUNCPROTOEND
|
||||
|
||||
#endif /* _XKBSTR_H_ */
|
||||
1047
nx-X11/programs/Xserver/xkb/xkbout.c
Normal file
1047
nx-X11/programs/Xserver/xkb/xkbout.c
Normal file
File diff suppressed because it is too large
Load Diff
1324
nx-X11/programs/Xserver/xkb/xkbtext.c
Normal file
1324
nx-X11/programs/Xserver/xkb/xkbtext.c
Normal file
File diff suppressed because it is too large
Load Diff
1262
nx-X11/programs/Xserver/xkb/xkmread.c
Normal file
1262
nx-X11/programs/Xserver/xkb/xkmread.c
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user