diff options
author | marha <marha@users.sourceforge.net> | 2009-09-06 18:48:27 +0000 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2009-09-06 18:48:27 +0000 |
commit | a915739887477b28d924ecc8417ee107d125bd6c (patch) | |
tree | c02f315476b61892d1fd89182e18943dce8d6277 /xorg-server/xkb | |
parent | 6f25a23db1df27e992c34f6fd4c82e83c44fc2e2 (diff) | |
download | vcxsrv-a915739887477b28d924ecc8417ee107d125bd6c.tar.gz vcxsrv-a915739887477b28d924ecc8417ee107d125bd6c.tar.bz2 vcxsrv-a915739887477b28d924ecc8417ee107d125bd6c.zip |
Switched to xorg-server-1.6.99.900.tar.gz
Diffstat (limited to 'xorg-server/xkb')
32 files changed, 1312 insertions, 1857 deletions
diff --git a/xorg-server/xkb/Makefile.am b/xorg-server/xkb/Makefile.am index 5967f42ff..b85ee8a41 100644 --- a/xorg-server/xkb/Makefile.am +++ b/xorg-server/xkb/Makefile.am @@ -7,8 +7,6 @@ DDX_SRCS = \ ddxBeep.c \ ddxCtrls.c \ ddxFakeMtn.c \ - ddxInit.c \ - ddxKeyClick.c \ ddxLEDs.c \ ddxLoad.c \ ddxList.c \ @@ -39,11 +37,7 @@ X11_SRCS = \ XKBGAlloc.c \ XKBMAlloc.c -# ends up unused... -# XI_SRCS = xkbPrOtherEv.c - -libxkb_la_SOURCES = $(DDX_SRCS) $(DIX_SRCS) $(XI_SRCS) $(XKBFILE_SRCS) \ - $(X11_SRCS) +libxkb_la_SOURCES = $(DDX_SRCS) $(DIX_SRCS) $(XKBFILE_SRCS) $(X11_SRCS) libxkbstubs_la_SOURCES = ddxVT.c ddxPrivate.c ddxKillSrv.c EXTRA_DIST = xkbDflts.h xkbgeom.h xkb.h diff --git a/xorg-server/xkb/Makefile.in b/xorg-server/xkb/Makefile.in index 53abf0be8..d2d77a3a4 100644 --- a/xorg-server/xkb/Makefile.in +++ b/xorg-server/xkb/Makefile.in @@ -39,8 +39,11 @@ subdir = xkb DIST_COMMON = $(dist_xkbcompiled_DATA) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ - $(top_srcdir)/configure.ac +am__aclocal_m4_deps = $(top_srcdir)/m4/ac_define_dir.m4 \ + $(top_srcdir)/m4/dolt.m4 $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ + $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ + $(top_srcdir)/m4/shave.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d @@ -50,13 +53,14 @@ CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ $(top_builddir)/include/xorg-config.h \ $(top_builddir)/include/xkb-config.h \ $(top_builddir)/include/xwin-config.h \ - $(top_builddir)/include/kdrive-config.h + $(top_builddir)/include/kdrive-config.h \ + $(top_builddir)/include/version-config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libxkb_la_LIBADD = -am__objects_1 = ddxBeep.lo ddxCtrls.lo ddxFakeMtn.lo ddxInit.lo \ - ddxKeyClick.lo ddxLEDs.lo ddxLoad.lo ddxList.lo ddxDevBtn.lo +am__objects_1 = ddxBeep.lo ddxCtrls.lo ddxFakeMtn.lo ddxLEDs.lo \ + ddxLoad.lo ddxList.lo ddxDevBtn.lo am__objects_2 = xkb.lo xkbUtils.lo xkbEvents.lo xkbAccessX.lo \ xkbSwap.lo xkbLEDs.lo xkbInit.lo xkbActions.lo xkbPrKeyEv.lo am__objects_3 = maprules.lo xkmread.lo xkbtext.lo xkbfmisc.lo \ @@ -111,6 +115,7 @@ ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ ALLOCA = @ALLOCA@ AMTAR = @AMTAR@ +AM_MAKEFLAGS = @AM_MAKEFLAGS@ APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ APPLE_APPLICATION_ID = @APPLE_APPLICATION_ID@ APPLE_APPLICATION_NAME = @APPLE_APPLICATION_NAME@ @@ -131,9 +136,12 @@ CCASDEPMODE = @CCASDEPMODE@ CCASFLAGS = @CCASFLAGS@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ +CHANGELOG_CMD = @CHANGELOG_CMD@ COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ +CWARNFLAGS = @CWARNFLAGS@ +CXX = @CXX@ CYGPATH_W = @CYGPATH_W@ DARWIN_LIBS = @DARWIN_LIBS@ DBUS_CFLAGS = @DBUS_CFLAGS@ @@ -162,7 +170,9 @@ DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ DRIPROTO_LIBS = @DRIPROTO_LIBS@ DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRI_CFLAGS = @DRI_CFLAGS@ DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ +DRI_LIBS = @DRI_LIBS@ DSYMUTIL = @DSYMUTIL@ DTRACE = @DTRACE@ DUMPBIN = @DUMPBIN@ @@ -171,9 +181,13 @@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ +F77 = @F77@ +FC = @FC@ FGREP = @FGREP@ FILE_MAN_DIR = @FILE_MAN_DIR@ FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +GLIB_CFLAGS = @GLIB_CFLAGS@ +GLIB_LIBS = @GLIB_LIBS@ GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ GLX_DEFINES = @GLX_DEFINES@ GL_CFLAGS = @GL_CFLAGS@ @@ -212,12 +226,13 @@ LTCOMPILE = @LTCOMPILE@ LTCXXCOMPILE = @LTCXXCOMPILE@ LTLIBOBJS = @LTLIBOBJS@ MAINT = @MAINT@ +MAIN_LIB = @MAIN_LIB@ +MAKEFLAGS = @MAKEFLAGS@ MAKEINFO = @MAKEINFO@ MAKE_HTML = @MAKE_HTML@ MAKE_PDF = @MAKE_PDF@ MAKE_PS = @MAKE_PS@ MAKE_TEXT = @MAKE_TEXT@ -MESA_SOURCE = @MESA_SOURCE@ MISC_MAN_DIR = @MISC_MAN_DIR@ MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ MKDIR_P = @MKDIR_P@ @@ -237,7 +252,6 @@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ @@ -247,6 +261,7 @@ PERL = @PERL@ PKG_CONFIG = @PKG_CONFIG@ PROJECTROOT = @PROJECTROOT@ PS2PDF = @PS2PDF@ +Q = @Q@ RANLIB = @RANLIB@ RAWCPP = @RAWCPP@ RAWCPPFLAGS = @RAWCPPFLAGS@ @@ -260,11 +275,10 @@ STRIP = @STRIP@ TSLIB_CFLAGS = @TSLIB_CFLAGS@ TSLIB_LIBS = @TSLIB_LIBS@ UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ -VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@ -VENDOR_NAME = @VENDOR_NAME@ +V = @V@ VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ -VENDOR_RELEASE = @VENDOR_RELEASE@ VERSION = @VERSION@ +WINDRES = @WINDRES@ X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ XDMCP_CFLAGS = @XDMCP_CFLAGS@ @@ -300,6 +314,7 @@ XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ XORG_SYS_LIBS = @XORG_SYS_LIBS@ XPBPROXY_CFLAGS = @XPBPROXY_CFLAGS@ XPBPROXY_LIBS = @XPBPROXY_LIBS@ +XQUARTZ_SPARKLE = @XQUARTZ_SPARKLE@ XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ XSDL_INCS = @XSDL_INCS@ @@ -324,7 +339,6 @@ YFLAGS = @YFLAGS@ __XCONFIGFILE__ = @__XCONFIGFILE__@ abi_ansic = @abi_ansic@ abi_extension = @abi_extension@ -abi_font = @abi_font@ abi_videodrv = @abi_videodrv@ abi_xinput = @abi_xinput@ abs_builddir = @abs_builddir@ @@ -347,6 +361,7 @@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ +distcleancheck_listfiles = @distcleancheck_listfiles@ docdir = @docdir@ driverdir = @driverdir@ dvidir = @dvidir@ @@ -378,7 +393,9 @@ psdir = @psdir@ sbindir = @sbindir@ sdkdir = @sdkdir@ sharedstatedir = @sharedstatedir@ +shavedir = @shavedir@ srcdir = @srcdir@ +symbol_visibility = @symbol_visibility@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ @@ -392,8 +409,6 @@ DDX_SRCS = \ ddxBeep.c \ ddxCtrls.c \ ddxFakeMtn.c \ - ddxInit.c \ - ddxKeyClick.c \ ddxLEDs.c \ ddxLoad.c \ ddxList.c \ @@ -425,12 +440,7 @@ X11_SRCS = \ XKBGAlloc.c \ XKBMAlloc.c - -# ends up unused... -# XI_SRCS = xkbPrOtherEv.c -libxkb_la_SOURCES = $(DDX_SRCS) $(DIX_SRCS) $(XI_SRCS) $(XKBFILE_SRCS) \ - $(X11_SRCS) - +libxkb_la_SOURCES = $(DDX_SRCS) $(DIX_SRCS) $(XKBFILE_SRCS) $(X11_SRCS) libxkbstubs_la_SOURCES = ddxVT.c ddxPrivate.c ddxKillSrv.c EXTRA_DIST = xkbDflts.h xkbgeom.h xkb.h xkbcompileddir = $(XKB_COMPILED_DIR) @@ -497,8 +507,6 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ddxCtrls.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ddxDevBtn.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ddxFakeMtn.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ddxInit.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ddxKeyClick.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ddxKillSrv.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ddxLEDs.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ddxList.Plo@am__quote@ diff --git a/xorg-server/xkb/XKBAlloc.c b/xorg-server/xkb/XKBAlloc.c index 790aede92..7265d83f2 100644 --- a/xorg-server/xkb/XKBAlloc.c +++ b/xorg-server/xkb/XKBAlloc.c @@ -30,8 +30,6 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include <stdio.h> #include <X11/X.h> -#define NEED_EVENTS -#define NEED_REPLIES #include <X11/Xproto.h> #include "misc.h" #include "inputstr.h" @@ -60,7 +58,7 @@ XkbSymInterpretRec *prev_interpret; compat->sym_interpret= _XkbTypedRealloc(compat->sym_interpret, nSI,XkbSymInterpretRec); if (compat->sym_interpret==NULL) { - _XkbFree(prev_interpret); + xfree(prev_interpret); compat->size_si= compat->num_si= 0; return BadAlloc; } @@ -76,7 +74,7 @@ XkbSymInterpretRec *prev_interpret; if (nSI>0) { compat->sym_interpret= _XkbTypedCalloc(nSI,XkbSymInterpretRec); if (!compat->sym_interpret) { - _XkbFree(compat); + xfree(compat); return BadAlloc; } } @@ -102,12 +100,12 @@ register XkbCompatMapPtr compat; bzero((char *)&compat->groups[0],XkbNumKbdGroups*sizeof(XkbModsRec)); if (which&XkbSymInterpMask) { if ((compat->sym_interpret)&&(compat->size_si>0)) - _XkbFree(compat->sym_interpret); + xfree(compat->sym_interpret); compat->size_si= compat->num_si= 0; compat->sym_interpret= NULL; } if (freeMap) { - _XkbFree(compat); + xfree(compat); xkb->compat= NULL; } return; @@ -163,7 +161,7 @@ XkbNamesPtr names; _XkbClearElems(names->key_aliases,names->num_key_aliases, nTotalAliases-1,XkbKeyAliasRec); } else { - _XkbFree(prev_aliases); + xfree(prev_aliases); } } if (names->key_aliases==NULL) { @@ -185,7 +183,7 @@ XkbNamesPtr names; _XkbClearElems(names->radio_groups,names->num_rg,nTotalRG-1, Atom); } else { - _XkbFree(prev_radio_groups); + xfree(prev_radio_groups); } } if (names->radio_groups==NULL) @@ -213,29 +211,29 @@ XkbNamesPtr names; type= map->types; for (i=0;i<map->num_types;i++,type++) { if (type->level_names!=NULL) { - _XkbFree(type->level_names); + xfree(type->level_names); type->level_names= NULL; } } } } if ((which&XkbKeyNamesMask)&&(names->keys!=NULL)) { - _XkbFree(names->keys); + xfree(names->keys); names->keys= NULL; names->num_keys= 0; } if ((which&XkbKeyAliasesMask)&&(names->key_aliases)){ - _XkbFree(names->key_aliases); + xfree(names->key_aliases); names->key_aliases=NULL; names->num_key_aliases=0; } if ((which&XkbRGNamesMask)&&(names->radio_groups)) { - _XkbFree(names->radio_groups); + xfree(names->radio_groups); names->radio_groups= NULL; names->num_rg= 0; } if (freeMap) { - _XkbFree(names); + xfree(names); xkb->names= NULL; } return; @@ -263,7 +261,7 @@ static void XkbFreeControls(XkbDescPtr xkb,unsigned which,Bool freeMap) { if (freeMap && (xkb!=NULL) && (xkb->ctrls!=NULL)) { - _XkbFree(xkb->ctrls); + xfree(xkb->ctrls); xkb->ctrls= NULL; } return; @@ -271,7 +269,7 @@ XkbFreeControls(XkbDescPtr xkb,unsigned which,Bool freeMap) /***===================================================================***/ -Status +Status XkbAllocIndicatorMaps(XkbDescPtr xkb) { if (xkb==NULL) @@ -288,7 +286,7 @@ static void XkbFreeIndicatorMaps(XkbDescPtr xkb) { if ((xkb!=NULL)&&(xkb->indicators!=NULL)) { - _XkbFree(xkb->indicators); + xfree(xkb->indicators); xkb->indicators= NULL; } return; @@ -332,6 +330,6 @@ XkbFreeKeyboard(XkbDescPtr xkb,unsigned which,Bool freeAll) if (which&XkbControlsMask) XkbFreeControls(xkb,XkbAllControlsMask,True); if (freeAll) - _XkbFree(xkb); + xfree(xkb); return; } diff --git a/xorg-server/xkb/XKBGAlloc.c b/xorg-server/xkb/XKBGAlloc.c index c37f49a55..752b11a94 100644 --- a/xorg-server/xkb/XKBGAlloc.c +++ b/xorg-server/xkb/XKBGAlloc.c @@ -28,8 +28,6 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include <dix-config.h> #endif -#define NEED_EVENTS -#define NEED_REPLIES #include <stdio.h> #include <X11/X.h> @@ -53,7 +51,7 @@ _XkbFreeGeomLeafElems( Bool freeAll, if ((freeAll)||(*elems==NULL)) { *num_inout= *sz_inout= 0; if (*elems!=NULL) { - _XkbFree(*elems); + xfree(*elems); *elems= NULL; } return; @@ -117,7 +115,7 @@ register char *ptr; if (freeAll) { (*num_inout)= (*sz_inout)= 0; if (*elems) { - _XkbFree(*elems); + xfree(*elems); *elems= NULL; } } @@ -140,11 +138,11 @@ _XkbClearProperty(char *prop_in) XkbPropertyPtr prop= (XkbPropertyPtr)prop_in; if (prop->name) { - _XkbFree(prop->name); + xfree(prop->name); prop->name= NULL; } if (prop->value) { - _XkbFree(prop->value); + xfree(prop->value); prop->value= NULL; } return; @@ -186,7 +184,7 @@ _XkbClearColor(char *color_in) XkbColorPtr color= (XkbColorPtr)color_in; if (color->spec) - _XkbFree(color->spec); + xfree(color->spec); return; } @@ -383,11 +381,11 @@ XkbDoodadPtr doodad= (XkbDoodadPtr)doodad_in; case XkbTextDoodad: { if (doodad->text.text!=NULL) { - _XkbFree(doodad->text.text); + xfree(doodad->text.text); doodad->text.text= NULL; } if (doodad->text.font!=NULL) { - _XkbFree(doodad->text.font); + xfree(doodad->text.font); doodad->text.font= NULL; } } @@ -395,7 +393,7 @@ XkbDoodadPtr doodad= (XkbDoodadPtr)doodad_in; case XkbLogoDoodad: { if (doodad->logo.logo_name!=NULL) { - _XkbFree(doodad->logo.logo_name); + xfree(doodad->logo.logo_name); doodad->logo.logo_name= NULL; } } @@ -415,7 +413,7 @@ register XkbDoodadPtr doodad; _XkbClearDoodad((char *)doodad); } if (freeAll) - _XkbFree(doodads); + xfree(doodads); } return; } @@ -444,10 +442,10 @@ XkbFreeGeometry(XkbGeometryPtr geom,unsigned which,Bool freeMap) XkbFreeGeomKeyAliases(geom,0,geom->num_key_aliases,True); if (freeMap) { if (geom->label_font!=NULL) { - _XkbFree(geom->label_font); + xfree(geom->label_font); geom->label_font= NULL; } - _XkbFree(geom); + xfree(geom); } return; } @@ -471,8 +469,8 @@ _XkbGeomAlloc( void ** old, *total= (*num)+num_new; if ((*old)!=NULL) - (*old)= _XkbRealloc((*old),(*total)*sz_elem); - else (*old)= _XkbCalloc((*total),sz_elem); + (*old)= xrealloc((*old),(*total)*sz_elem); + else (*old)= xcalloc((*total),sz_elem); if ((*old)==NULL) { *total= *num= 0; return BadAlloc; @@ -666,8 +664,8 @@ register XkbPropertyPtr prop; 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); + xfree(prop->value); + prop->value= xalloc(strlen(value)+1); if (prop->value) strcpy(prop->value,value); return prop; @@ -678,13 +676,13 @@ register XkbPropertyPtr prop; return NULL; } prop= &geom->properties[geom->num_properties]; - prop->name= (char *)_XkbAlloc(strlen(name)+1); + prop->name= xalloc(strlen(name)+1); if (!name) return NULL; strcpy(prop->name,name); - prop->value= (char *)_XkbAlloc(strlen(value)+1); + prop->value= xalloc(strlen(value)+1); if (!value) { - _XkbFree(prop->name); + xfree(prop->name); prop->name= NULL; return NULL; } @@ -740,7 +738,7 @@ register XkbColorPtr color; } color= &geom->colors[geom->num_colors]; color->pixel= pixel; - color->spec= (char *)_XkbAlloc(strlen(spec)+1); + color->spec= xalloc(strlen(spec)+1); if (!color->spec) return NULL; strcpy(color->spec,spec); @@ -854,7 +852,7 @@ XkbSectionPtr section; return NULL; if ((sz_doodads>0)&&(_XkbAllocDoodads(section,sz_doodads)!=Success)) { if (section->rows) { - _XkbFree(section->rows); + xfree(section->rows); section->rows= NULL; section->sz_rows= section->num_rows= 0; } diff --git a/xorg-server/xkb/XKBMAlloc.c b/xorg-server/xkb/XKBMAlloc.c index 178b5b89a..728c0297b 100644 --- a/xorg-server/xkb/XKBMAlloc.c +++ b/xorg-server/xkb/XKBMAlloc.c @@ -32,8 +32,6 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include <stdio.h> #include <X11/X.h> -#define NEED_EVENTS -#define NEED_REPLIES #include <X11/Xproto.h> #include "misc.h" #include "inputstr.h" @@ -81,7 +79,7 @@ XkbClientMapPtr map; map->types= _XkbTypedRealloc(map->types,nTotalTypes,XkbKeyTypeRec); if (map->types==NULL) { - _XkbFree(prev_types); + xfree(prev_types); map->num_types= map->size_types= 0; return BadAlloc; } @@ -174,7 +172,7 @@ XkbServerMapPtr map; need= map->num_acts+nNewActions; map->acts= _XkbTypedRealloc(map->acts,need,XkbAction); if (map->acts==NULL) { - _XkbFree(prev_acts); + xfree(prev_acts); map->num_acts= map->size_acts= 0; return BadAlloc; } @@ -224,15 +222,15 @@ XkbCopyKeyType(XkbKeyTypePtr from,XkbKeyTypePtr into) if ((!from)||(!into)) return BadMatch; if (into->map) { - _XkbFree(into->map); + xfree(into->map); into->map= NULL; } if (into->preserve) { - _XkbFree(into->preserve); + xfree(into->preserve); into->preserve= NULL; } if (into->level_names) { - _XkbFree(into->level_names); + xfree(into->level_names); into->level_names= NULL; } *into= *from; @@ -301,10 +299,10 @@ KeyCode matchingKeys[XkbMaxKeyCount],nMatchingKeys; type= &xkb->map->types[type_ndx]; if (map_count==0) { if (type->map!=NULL) - _XkbFree(type->map); + xfree(type->map); type->map= NULL; if (type->preserve!=NULL) - _XkbFree(type->preserve); + xfree(type->preserve); type->preserve= NULL; type->map_count= 0; } @@ -315,7 +313,7 @@ KeyCode matchingKeys[XkbMaxKeyCount],nMatchingKeys; type->map=_XkbTypedRealloc(type->map,map_count,XkbKTMapEntryRec); if (!type->map) { if (prev_map) - _XkbFree(prev_map); + xfree(prev_map); return BadAlloc; } if (want_preserve) { @@ -327,12 +325,12 @@ KeyCode matchingKeys[XkbMaxKeyCount],nMatchingKeys; } if (!type->preserve) { if (prev_preserve) - _XkbFree(prev_preserve); + xfree(prev_preserve); return BadAlloc; } } else if (type->preserve!=NULL) { - _XkbFree(type->preserve); + xfree(type->preserve); type->preserve= NULL; } type->map_count= map_count; @@ -344,7 +342,7 @@ KeyCode matchingKeys[XkbMaxKeyCount],nMatchingKeys; type->level_names=_XkbTypedRealloc(type->level_names,new_num_lvls,Atom); if (!type->level_names) { if (prev_level_names) - _XkbFree(prev_level_names); + xfree(prev_level_names); return BadAlloc; } } @@ -424,7 +422,7 @@ KeyCode matchingKeys[XkbMaxKeyCount],nMatchingKeys; } } type->num_levels= new_num_lvls; - _XkbFree(xkb->map->syms); + xfree(xkb->map->syms); xkb->map->syms= newSyms; xkb->map->num_syms= nSyms; return Success; @@ -520,7 +518,7 @@ KeySym *newSyms; xkb->map->key_sym_map[i].offset = nSyms; nSyms+= nKeySyms; } - _XkbFree(xkb->map->syms); + xfree(xkb->map->syms); xkb->map->syms = newSyms; xkb->map->num_syms = nSyms; return &xkb->map->syms[xkb->map->key_sym_map[key].offset]; @@ -642,7 +640,7 @@ int tmp; 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); + xfree(prev_key_sym_map); return BadAlloc; } bzero((char *)&xkb->map->key_sym_map[xkb->max_key_code], @@ -660,7 +658,7 @@ int tmp; xkb->map->modmap= _XkbTypedRealloc(xkb->map->modmap, (maxKC+1),unsigned char); if (!xkb->map->modmap) { - _XkbFree(prev_modmap); + xfree(prev_modmap); return BadAlloc; } bzero((char *)&xkb->map->modmap[xkb->max_key_code],tmp); @@ -679,7 +677,7 @@ int tmp; xkb->server->behaviors=_XkbTypedRealloc(xkb->server->behaviors, (maxKC+1),XkbBehavior); if (!xkb->server->behaviors) { - _XkbFree(prev_behaviors); + xfree(prev_behaviors); return BadAlloc; } bzero((char *)&xkb->server->behaviors[xkb->max_key_code], @@ -697,7 +695,7 @@ int tmp; xkb->server->key_acts= _XkbTypedRealloc(xkb->server->key_acts, (maxKC+1),unsigned short); if (!xkb->server->key_acts) { - _XkbFree(prev_key_acts); + xfree(prev_key_acts); return BadAlloc; } bzero((char *)&xkb->server->key_acts[xkb->max_key_code], @@ -715,7 +713,7 @@ int tmp; xkb->server->vmodmap= _XkbTypedRealloc(xkb->server->vmodmap, (maxKC+1),unsigned short); if (!xkb->server->vmodmap) { - _XkbFree(prev_vmodmap); + xfree(prev_vmodmap); return BadAlloc; } bzero((char *)&xkb->server->vmodmap[xkb->max_key_code], @@ -734,7 +732,7 @@ int tmp; xkb->names->keys= _XkbTypedRealloc(xkb->names->keys, (maxKC+1),XkbKeyNameRec); if (!xkb->names->keys) { - _XkbFree(prev_keys); + xfree(prev_keys); return BadAlloc; } bzero((char *)&xkb->names->keys[xkb->max_key_code], @@ -795,7 +793,7 @@ XkbAction *newActs; xkb->server->key_acts[i]= nActs; nActs+= nKeyActs; } - _XkbFree(xkb->server->acts); + xfree(xkb->server->acts); xkb->server->acts = newActs; xkb->server->num_acts= nActs; return &xkb->server->acts[xkb->server->key_acts[key]]; @@ -818,42 +816,42 @@ XkbClientMapPtr map; XkbKeyTypePtr type; for (i=0,type=map->types;i<map->num_types;i++,type++) { if (type->map!=NULL) { - _XkbFree(type->map); + xfree(type->map); type->map= NULL; } if (type->preserve!=NULL) { - _XkbFree(type->preserve); + xfree(type->preserve); type->preserve= NULL; } type->map_count= 0; if (type->level_names!=NULL) { - _XkbFree(type->level_names); + xfree(type->level_names); type->level_names= NULL; } } } - _XkbFree(map->types); + xfree(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); + xfree(map->key_sym_map); map->key_sym_map= NULL; } if (map->syms!=NULL) { - _XkbFree(map->syms); + xfree(map->syms); map->size_syms= map->num_syms= 0; map->syms= NULL; } } if ((what&XkbModifierMapMask)&&(map->modmap!=NULL)) { - _XkbFree(map->modmap); + xfree(map->modmap); map->modmap= NULL; } if (freeMap) { - _XkbFree(xkb->map); + xfree(xkb->map); xkb->map= NULL; } return; @@ -870,31 +868,31 @@ XkbServerMapPtr map; what= XkbAllServerInfoMask; map= xkb->server; if ((what&XkbExplicitComponentsMask)&&(map->explicit!=NULL)) { - _XkbFree(map->explicit); + xfree(map->explicit); map->explicit= NULL; } if (what&XkbKeyActionsMask) { if (map->key_acts!=NULL) { - _XkbFree(map->key_acts); + xfree(map->key_acts); map->key_acts= NULL; } if (map->acts!=NULL) { - _XkbFree(map->acts); + xfree(map->acts); map->num_acts= map->size_acts= 0; map->acts= NULL; } } if ((what&XkbKeyBehaviorsMask)&&(map->behaviors!=NULL)) { - _XkbFree(map->behaviors); + xfree(map->behaviors); map->behaviors= NULL; } if ((what&XkbVirtualModMapMask)&&(map->vmodmap!=NULL)) { - _XkbFree(map->vmodmap); + xfree(map->vmodmap); map->vmodmap= NULL; } if (freeMap) { - _XkbFree(xkb->server); + xfree(xkb->server); xkb->server= NULL; } return; diff --git a/xorg-server/xkb/XKBMisc.c b/xorg-server/xkb/XKBMisc.c index a9d8b17c0..867906046 100644 --- a/xorg-server/xkb/XKBMisc.c +++ b/xorg-server/xkb/XKBMisc.c @@ -32,8 +32,6 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include <stdio.h> #include <X11/X.h> -#define NEED_EVENTS -#define NEED_REPLIES #include <X11/Xproto.h> #include "misc.h" #include "inputstr.h" @@ -58,6 +56,7 @@ register int i; unsigned int empty; int nSyms[XkbNumKbdGroups]; int nGroups,tmp,groupsWidth; +BOOL replicated = FALSE; /* Section 12.2 of the protocol describes this process in more detail */ /* Step 1: find the # of symbols in the core mapping per group */ @@ -91,27 +90,70 @@ int nGroups,tmp,groupsWidth; 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)) { + + /* Special case: if only the first group is explicit, and the symbols + * replicate across all groups, then we have a Section 12.4 replication */ + if ((protected & ~XkbExplicitKeyType1Mask) == 0) + { + int j, width = nSyms[XkbGroup1Index]; + + replicated = TRUE; + + /* Check ABAB in ABABCDECDEABCDE */ + if ((width > 0 && CORE_SYM(0) != CORE_SYM(2)) || + (width > 1 && CORE_SYM(1) != CORE_SYM(3))) + replicated = FALSE; + + /* Check CDECDE in ABABCDECDEABCDE */ + for (i = 2; i < width && replicated; i++) + { + if (CORE_SYM(2 + i) != CORE_SYM(i + width)) + replicated = FALSE; + } + + /* Check ABCDE in ABABCDECDEABCDE */ + for (j = 2; replicated && + j < XkbNumKbdGroups && + map_width >= width * (j + 1); j++) + { + for (i = 0; i < width && replicated; i++) + { + if (CORE_SYM(((i < 2) ? i : 2 + i)) != CORE_SYM(i + width * j)) + replicated = FALSE; + } + } + } + + if (replicated) + { + nSyms[XkbGroup2Index]= 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; - } + nGroups= 1; + } else + { + 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; @@ -200,6 +242,8 @@ int nGroups,tmp,groupsWidth; Bool identical; for (i=1,identical=True;identical&&(i<nGroups);i++) { KeySym *syms; + if (nSyms[i] != nSyms[XkbGroup1Index]) + identical = False; syms= &xkb_syms_rtrn[XKB_OFFSET(i,0)]; for (s=0;identical&&(s<nSyms[i]);s++) { if (syms[s]!=xkb_syms_rtrn[s]) @@ -463,7 +507,7 @@ unsigned changed,tmp; mc->changed|= changed; } if (interps!=ibuf) - _XkbFree(interps); + xfree(interps); return True; } diff --git a/xorg-server/xkb/ddxBeep.c b/xorg-server/xkb/ddxBeep.c index 74d868c0e..10a731724 100644 --- a/xorg-server/xkb/ddxBeep.c +++ b/xorg-server/xkb/ddxBeep.c @@ -29,7 +29,6 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #endif #include <stdio.h> -#define NEED_EVENTS 1 #include <X11/X.h> #include <X11/Xproto.h> #include <X11/keysym.h> diff --git a/xorg-server/xkb/ddxCtrls.c b/xorg-server/xkb/ddxCtrls.c index be269c2af..04de608df 100644 --- a/xorg-server/xkb/ddxCtrls.c +++ b/xorg-server/xkb/ddxCtrls.c @@ -29,7 +29,6 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #endif #include <stdio.h> -#define NEED_EVENTS 1 #include <X11/X.h> #include <X11/Xproto.h> #include <X11/keysym.h> diff --git a/xorg-server/xkb/ddxDevBtn.c b/xorg-server/xkb/ddxDevBtn.c index 44ee75f5d..94630d1c9 100644 --- a/xorg-server/xkb/ddxDevBtn.c +++ b/xorg-server/xkb/ddxDevBtn.c @@ -29,101 +29,49 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #endif #include <stdio.h> -#define NEED_EVENTS 1 #include <X11/X.h> #include <X11/Xproto.h> #include <X11/keysym.h> #include "inputstr.h" #include "scrnintstr.h" #include "windowstr.h" +#include "eventstr.h" #include <xkbsrv.h> +#include "mi.h" #include <X11/extensions/XI.h> #include <X11/extensions/XIproto.h> -extern int DeviceValuator; - -static EventListPtr masterEvents = NULL; - 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; -DeviceIntPtr master = NULL; - - if (dev == inputInfo.pointer || !dev->public.on) - return; - - nAxes = (dev->valuator?dev->valuator->numAxes:0); - if (nAxes > 6) - nAxes = 6; - - GetSpritePosition(dev, &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; + EventListPtr events; + int nevents, i; + DeviceIntPtr ptr; - 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); - } - - /* XXX: This is obnoxious. ProcessOtherEvent updates the DIX device state, - * but may not do anything if the device state is invalid. This happens if - * we post a mouse event from a pure keyboard device. So we need to hack - * around that by getting the master, then posting the event for the - * pointer paired with the master. + /* If dev is a slave device, and the SD is attached, do nothing. If we'd + * post through the attached master pointer we'd get duplicate events. + * + * if dev is a master keyboard, post through the master pointer. * - * Note:the DeviceButtonEvent on the SD itself will do nothing in most - * cases, unless dev is both a keyboard and a mouse. + * if dev is a floating slave, post through the device itself. */ - if (!dev->isMaster && dev->u.master) { - if (!masterEvents) - { - masterEvents = InitEventList(1); - SetMinimumEventSize(masterEvents, 1, (1 + MAX_VALUATOR_EVENTS) * sizeof(xEvent)); - } - master = dev->u.master; - if (!IsPointerDevice(master)) - master = GetPairedDevice(dev->u.master); - CopyGetMasterEvent(master, dev, &events, masterEvents, count); - } + if (IsMaster(dev)) + ptr = GetMaster(dev, MASTER_POINTER); + else if (!dev->u.master) + ptr = dev; + else + return; + + events = InitEventList(GetMaximumEventsNum()); + nevents = GetPointerEvents(events, ptr, + press ? ButtonPress : ButtonRelease, button, + 0 /* flags */, 0 /* first */, + 0 /* num_val */, NULL); + - (*dev->public.processInputProc)((xEventPtr)btn, dev, count); + for (i = 0; i < nevents; i++) + mieqProcessDeviceEvent(ptr, (InternalEvent*)events[i].event, NULL); - if (master) { - (*master->public.processInputProc)(masterEvents->event, master, count); - } - return; + FreeEventList(events, GetMaximumEventsNum()); } diff --git a/xorg-server/xkb/ddxFakeMtn.c b/xorg-server/xkb/ddxFakeMtn.c index 3f010f9ce..f90d2099a 100644 --- a/xorg-server/xkb/ddxFakeMtn.c +++ b/xorg-server/xkb/ddxFakeMtn.c @@ -29,7 +29,6 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #endif #include <stdio.h> -#define NEED_EVENTS 1 #include <X11/X.h> #include <X11/Xproto.h> #include <X11/keysym.h> diff --git a/xorg-server/xkb/ddxKillSrv.c b/xorg-server/xkb/ddxKillSrv.c index 3b5fd5353..106b39587 100644 --- a/xorg-server/xkb/ddxKillSrv.c +++ b/xorg-server/xkb/ddxKillSrv.c @@ -29,7 +29,6 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #endif #include <stdio.h> -#define NEED_EVENTS #include <X11/X.h> #include <X11/Xproto.h> #include <X11/keysym.h> diff --git a/xorg-server/xkb/ddxLEDs.c b/xorg-server/xkb/ddxLEDs.c index b4c8086f5..246d58c31 100644 --- a/xorg-server/xkb/ddxLEDs.c +++ b/xorg-server/xkb/ddxLEDs.c @@ -29,7 +29,6 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #endif #include <stdio.h> -#define NEED_EVENTS 1 #include <X11/X.h> #include <X11/Xproto.h> #include <X11/keysym.h> diff --git a/xorg-server/xkb/ddxList.c b/xorg-server/xkb/ddxList.c index ae3a7f7e0..3ff3d81b4 100644 --- a/xorg-server/xkb/ddxList.c +++ b/xorg-server/xkb/ddxList.c @@ -30,7 +30,6 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include <stdio.h> #include <ctype.h> -#define NEED_EVENTS 1 #include <X11/X.h> #include <X11/Xos.h> #include <X11/Xproto.h> @@ -62,7 +61,7 @@ extern int Win32System(const char *cmdline); /***====================================================================***/ static char *componentDirs[_XkbListNumComponents] = { - "keymap", "keycodes", "types", "compat", "symbols", "geometry" + "keycodes", "types", "compat", "symbols", "geometry" }; /***====================================================================***/ @@ -281,9 +280,7 @@ XkbDDXList(DeviceIntPtr dev,XkbSrvListInfoPtr list,ClientPtr client) { Status status; - status= XkbDDXListComponent(dev,_XkbListKeymaps,list,client); - if (status==Success) - status= XkbDDXListComponent(dev,_XkbListKeycodes,list,client); + status= XkbDDXListComponent(dev,_XkbListKeycodes,list,client); if (status==Success) status= XkbDDXListComponent(dev,_XkbListTypes,list,client); if (status==Success) diff --git a/xorg-server/xkb/ddxLoad.c b/xorg-server/xkb/ddxLoad.c index 4d5dfb685..6954dd150 100644 --- a/xorg-server/xkb/ddxLoad.c +++ b/xorg-server/xkb/ddxLoad.c @@ -34,7 +34,6 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include <stdio.h> #include <ctype.h> -#define NEED_EVENTS 1 #include <X11/X.h> #include <X11/Xos.h> #include <X11/Xproto.h> @@ -178,7 +177,7 @@ OutputDirectory( } } -static Bool +static Bool XkbDDXCompileKeymapByNames( XkbDescPtr xkb, XkbComponentNamesPtr names, unsigned want, @@ -205,7 +204,6 @@ XkbDDXCompileKeymapByNames( XkbDescPtr xkb, snprintf(keymap, sizeof(keymap), "server-%s", display); - XkbEnsureSafeMapName(keymap); OutputDirectory(xkm_output_dir, sizeof(xkm_output_dir)); #ifdef WIN32 @@ -405,7 +403,7 @@ XkbRF_RulesPtr rules; return False; } - rules = XkbRF_Create(0, 0); + rules = XkbRF_Create(); if (!rules) { LogMessage(X_ERROR, "XKB: Couldn't create rules struct\n"); fclose(file); @@ -429,3 +427,36 @@ XkbRF_RulesPtr rules; return complete; } + +XkbDescPtr +XkbCompileKeymap(DeviceIntPtr dev, XkbRMLVOSet *rmlvo) +{ + XkbComponentNamesRec kccgst; + XkbRF_VarDefsRec mlvo; + XkbDescPtr xkb; + char name[PATH_MAX]; + + if (!dev || !rmlvo) { + LogMessage(X_ERROR, "XKB: No device or RMLVO specified\n"); + return NULL; + } + + mlvo.model = rmlvo->model; + mlvo.layout = rmlvo->layout; + mlvo.variant = rmlvo->variant; + mlvo.options = rmlvo->options; + + /* XDNFR already logs for us. */ + if (!XkbDDXNamesFromRules(dev, rmlvo->rules, &mlvo, &kccgst)) + return NULL; + + /* XDLKBN too, but it might return 0 as well as allocating. */ + if (!XkbDDXLoadKeymapByNames(dev, &kccgst, XkmAllIndicesMask, 0, &xkb, name, + PATH_MAX)) { + if (xkb) + XkbFreeKeyboard(xkb, 0, TRUE); + return NULL; + } + + return xkb; +} diff --git a/xorg-server/xkb/ddxPrivate.c b/xorg-server/xkb/ddxPrivate.c index f67e20c27..f1c85f6ea 100644 --- a/xorg-server/xkb/ddxPrivate.c +++ b/xorg-server/xkb/ddxPrivate.c @@ -3,7 +3,6 @@ #include <dix-config.h> #endif -#define NEED_EVENTS #include <X11/X.h> #include "windowstr.h" #include <xkbsrv.h> diff --git a/xorg-server/xkb/ddxVT.c b/xorg-server/xkb/ddxVT.c index 55c82a865..cbd453706 100644 --- a/xorg-server/xkb/ddxVT.c +++ b/xorg-server/xkb/ddxVT.c @@ -29,7 +29,6 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #endif #include <stdio.h> -#define NEED_EVENTS #include <X11/X.h> #include <X11/Xproto.h> #include <X11/keysym.h> diff --git a/xorg-server/xkb/maprules.c b/xorg-server/xkb/maprules.c index b25d92901..168c5277f 100644 --- a/xorg-server/xkb/maprules.c +++ b/xorg-server/xkb/maprules.c @@ -36,7 +36,6 @@ #define XOS_USE_NO_LOCKING #include <X11/Xos_r.h> -#define NEED_EVENTS #include <X11/Xproto.h> #include <X11/X.h> #include <X11/Xos.h> @@ -53,6 +52,8 @@ /***====================================================================***/ + + #define DFLT_LINE_SIZE 128 typedef struct { @@ -77,7 +78,7 @@ static void FreeInputLine(InputLine *line) { if (line->line!=line->buf) - _XkbFree(line->line); + xfree(line->line); line->line_num= 1; line->num_line= 0; line->sz_line= DFLT_LINE_SIZE; @@ -90,11 +91,11 @@ InputLineAddChar(InputLine *line,int ch) { if (line->num_line>=line->sz_line) { if (line->line==line->buf) { - line->line= (char *)_XkbAlloc(line->sz_line*2); + line->line= xalloc(line->sz_line*2); memcpy(line->line,line->buf,line->sz_line); } else { - line->line=(char *)_XkbRealloc((char *)line->line,line->sz_line*2); + line->line= xrealloc((char *)line->line,line->sz_line*2); } line->sz_line*= 2; } @@ -194,15 +195,14 @@ Bool endOfFile,spacePending,slashPending,inComment; #define TYPES 6 #define COMPAT 7 #define GEOMETRY 8 -#define KEYMAP 9 -#define MAX_WORDS 10 +#define MAX_WORDS 9 #define PART_MASK 0x000F #define COMPONENT_MASK 0x03F0 static char * cname[MAX_WORDS] = { "model", "layout", "variant", "option", - "keycodes", "symbols", "types", "compat", "geometry", "keymap" + "keycodes", "symbols", "types", "compat", "geometry" }; typedef struct _RemapSpec { @@ -337,13 +337,6 @@ Bool found; remap->num_remap= 0; return; } - if (((present&COMPONENT_MASK)&(1<<KEYMAP))&& - ((present&COMPONENT_MASK)!=(1<<KEYMAP))) { - DebugF("Keymap cannot appear with other components\n"); - DebugF("Illegal mapping ignored\n"); - remap->num_remap= 0; - return; - } remap->number++; return; } @@ -460,7 +453,6 @@ Bool append = False; rule->types= _XkbDupString(tmp.name[TYPES]); rule->compat= _XkbDupString(tmp.name[COMPAT]); rule->geometry= _XkbDupString(tmp.name[GEOMETRY]); - rule->keymap= NULL; rule->layout_num = rule->variant_num = 0; for (i = 0; i < nread; i++) { @@ -561,9 +553,9 @@ MakeMultiDefs(XkbRF_MultiDefsPtr mdefs, XkbRF_VarDefsPtr defs) static void FreeMultiDefs(XkbRF_MultiDefsPtr defs) { - if (defs->options) _XkbFree(defs->options); - if (defs->layout[1]) _XkbFree(defs->layout[1]); - if (defs->variant[1]) _XkbFree(defs->variant[1]); + if (defs->options) xfree(defs->options); + if (defs->layout[1]) xfree(defs->layout[1]); + if (defs->variant[1]) xfree(defs->variant[1]); } static void @@ -777,7 +769,7 @@ int len, ndx; } str= index(&str[0],'%'); } - name= (char *)_XkbAlloc(len+1); + name= xalloc(len+1); str= orig; outstr= name; while (*str!='\0') { @@ -827,7 +819,7 @@ int len, ndx; } *outstr++= '\0'; if (orig!=name) - _XkbFree(orig); + xfree(orig); return name; } @@ -860,15 +852,13 @@ XkbRF_GetComponents( XkbRF_RulesPtr rules, names->compat= XkbRF_SubstituteVars(names->compat, &mdefs); if (names->geometry) names->geometry= XkbRF_SubstituteVars(names->geometry, &mdefs); - if (names->keymap) - names->keymap= XkbRF_SubstituteVars(names->keymap, &mdefs); FreeMultiDefs(&mdefs); return (names->keycodes && names->symbols && names->types && - names->compat && names->geometry ) || names->keymap; + names->compat && names->geometry); } -XkbRF_RulePtr +static XkbRF_RulePtr XkbRF_AddRule(XkbRF_RulesPtr rules) { if (rules->sz_rules<1) { @@ -890,7 +880,7 @@ XkbRF_AddRule(XkbRF_RulesPtr rules) return &rules->rules[rules->num_rules++]; } -XkbRF_GroupPtr +static XkbRF_GroupPtr XkbRF_AddGroup(XkbRF_RulesPtr rules) { if (rules->sz_groups<1) { @@ -979,274 +969,14 @@ Bool ok; /***====================================================================***/ -#define HEAD_NONE 0 -#define HEAD_MODEL 1 -#define HEAD_LAYOUT 2 -#define HEAD_VARIANT 3 -#define HEAD_OPTION 4 -#define HEAD_EXTRA 5 - -XkbRF_VarDescPtr -XkbRF_AddVarDesc(XkbRF_DescribeVarsPtr vars) -{ - if (vars->sz_desc<1) { - vars->sz_desc= 16; - vars->num_desc= 0; - vars->desc= _XkbTypedCalloc(vars->sz_desc,XkbRF_VarDescRec); - } - else if (vars->num_desc>=vars->sz_desc) { - vars->sz_desc*= 2; - vars->desc= _XkbTypedRealloc(vars->desc,vars->sz_desc,XkbRF_VarDescRec); - } - if (!vars->desc) { - vars->sz_desc= vars->num_desc= 0; - DebugF("Allocation failure in XkbRF_AddVarDesc\n"); - return NULL; - } - vars->desc[vars->num_desc].name= NULL; - vars->desc[vars->num_desc].desc= NULL; - return &vars->desc[vars->num_desc++]; -} - -XkbRF_VarDescPtr -XkbRF_AddVarDescCopy(XkbRF_DescribeVarsPtr vars,XkbRF_VarDescPtr from) -{ -XkbRF_VarDescPtr nd; - - if ((nd=XkbRF_AddVarDesc(vars))!=NULL) { - nd->name= _XkbDupString(from->name); - nd->desc= _XkbDupString(from->desc); - } - return nd; -} - -XkbRF_DescribeVarsPtr -XkbRF_AddVarToDescribe(XkbRF_RulesPtr rules,char *name) -{ - if (rules->sz_extra<1) { - rules->num_extra= 0; - rules->sz_extra= 1; - rules->extra_names= _XkbTypedCalloc(rules->sz_extra,char *); - rules->extra= _XkbTypedCalloc(rules->sz_extra, XkbRF_DescribeVarsRec); - } - else if (rules->num_extra>=rules->sz_extra) { - rules->sz_extra*= 2; - rules->extra_names= _XkbTypedRealloc(rules->extra_names,rules->sz_extra, - char *); - rules->extra=_XkbTypedRealloc(rules->extra, rules->sz_extra, - XkbRF_DescribeVarsRec); - } - if ((!rules->extra_names)||(!rules->extra)) { - DebugF("allocation error in extra parts\n"); - rules->sz_extra= rules->num_extra= 0; - rules->extra_names= NULL; - rules->extra= NULL; - return NULL; - } - rules->extra_names[rules->num_extra]= _XkbDupString(name); - bzero(&rules->extra[rules->num_extra],sizeof(XkbRF_DescribeVarsRec)); - return &rules->extra[rules->num_extra++]; -} - -Bool -XkbRF_LoadDescriptions(FILE *file,XkbRF_RulesPtr rules) -{ -InputLine line; -XkbRF_VarDescRec tmp; -char *tok; -int len,headingtype,extra_ndx = 0; - - bzero((char *)&tmp, sizeof(XkbRF_VarDescRec)); - headingtype = HEAD_NONE; - InitInputLine(&line); - for ( ; GetInputLine(file,&line,False); line.num_line= 0) { - if (line.line[0]=='!') { - tok = strtok(&(line.line[1]), " \t"); - if (strcasecmp(tok,"model") == 0) - headingtype = HEAD_MODEL; - else if (strcasecmp(tok,"layout") == 0) - headingtype = HEAD_LAYOUT; - else if (strcasecmp(tok,"variant") == 0) - headingtype = HEAD_VARIANT; - else if (strcasecmp(tok,"option") == 0) - headingtype = HEAD_OPTION; - else { - int i; - headingtype = HEAD_EXTRA; - extra_ndx= -1; - for (i=0;(i<rules->num_extra)&&(extra_ndx<0);i++) { - if (!strcasecmp(tok,rules->extra_names[i])) - extra_ndx= i; - } - if (extra_ndx<0) { - XkbRF_DescribeVarsPtr var; - DebugF("Extra heading \"%s\" encountered\n",tok); - var= XkbRF_AddVarToDescribe(rules,tok); - if (var) - extra_ndx= var-rules->extra; - else headingtype= HEAD_NONE; - } - } - continue; - } - - if (headingtype == HEAD_NONE) { - DebugF("Must have a heading before first line of data\n"); - DebugF("Illegal line of data ignored\n"); - continue; - } - - len = strlen(line.line); - if ((tmp.name= strtok(line.line, " \t")) == NULL) { - DebugF("Huh? No token on line\n"); - DebugF("Illegal line of data ignored\n"); - continue; - } - if (strlen(tmp.name) == len) { - DebugF("No description found\n"); - DebugF("Illegal line of data ignored\n"); - continue; - } - - tok = line.line + strlen(tmp.name) + 1; - while ((*tok!='\n')&&isspace(*tok)) - tok++; - if (*tok == '\0') { - DebugF("No description found\n"); - DebugF("Illegal line of data ignored\n"); - continue; - } - tmp.desc= tok; - switch (headingtype) { - case HEAD_MODEL: - XkbRF_AddVarDescCopy(&rules->models,&tmp); - break; - case HEAD_LAYOUT: - XkbRF_AddVarDescCopy(&rules->layouts,&tmp); - break; - case HEAD_VARIANT: - XkbRF_AddVarDescCopy(&rules->variants,&tmp); - break; - case HEAD_OPTION: - XkbRF_AddVarDescCopy(&rules->options,&tmp); - break; - case HEAD_EXTRA: - XkbRF_AddVarDescCopy(&rules->extra[extra_ndx],&tmp); - break; - } - } - FreeInputLine(&line); - if ((rules->models.num_desc==0) && (rules->layouts.num_desc==0) && - (rules->variants.num_desc==0) && (rules->options.num_desc==0) && - (rules->num_extra==0)) { - return False; - } - return True; -} - -Bool -XkbRF_LoadDescriptionsByName(char *base,char *locale,XkbRF_RulesPtr rules) -{ -FILE * file; -char buf[PATH_MAX]; -Bool ok; - - if ((!base)||(!rules)) - return False; - if (locale) { - if (strlen(base)+strlen(locale)+6 > PATH_MAX) - return False; - sprintf(buf,"%s-%s.lst", base, locale); - } - else { - if (strlen(base)+5 > PATH_MAX) - return False; - sprintf(buf,"%s.lst", base); - } - - file= fopen(buf, "r"); - if ((!file)&&(locale)) { /* fallback if locale was specified */ - sprintf(buf,"%s.lst", base); - - file= fopen(buf, "r"); - } - if (!file) - return False; - ok= XkbRF_LoadDescriptions(file,rules); - fclose(file); - return ok; -} - -/***====================================================================***/ - -XkbRF_RulesPtr -XkbRF_Load(char *base,char *locale,Bool wantDesc,Bool wantRules) -{ -XkbRF_RulesPtr rules; - - if ((!base)||((!wantDesc)&&(!wantRules))) - return NULL; - if ((rules=_XkbTypedCalloc(1,XkbRF_RulesRec))==NULL) - return NULL; - if (wantDesc&&(!XkbRF_LoadDescriptionsByName(base,locale,rules))) { - XkbRF_Free(rules,True); - return NULL; - } - if (wantRules&&(!XkbRF_LoadRulesByName(base,locale,rules))) { - XkbRF_Free(rules,True); - return NULL; - } - return rules; -} - XkbRF_RulesPtr -XkbRF_Create(int szRules,int szExtra) +XkbRF_Create(void) { -XkbRF_RulesPtr rules; - - if ((rules=_XkbTypedCalloc(1,XkbRF_RulesRec))==NULL) - return NULL; - if (szRules>0) { - rules->sz_rules= szRules; - rules->rules= _XkbTypedCalloc(rules->sz_rules,XkbRF_RuleRec); - if (!rules->rules) { - _XkbFree(rules); - return NULL; - } - } - if (szExtra>0) { - rules->sz_extra= szExtra; - rules->extra= _XkbTypedCalloc(rules->sz_extra,XkbRF_DescribeVarsRec); - if (!rules->extra) { - if (rules->rules) - _XkbFree(rules->rules); - _XkbFree(rules); - return NULL; - } - } - return rules; + return _XkbTypedCalloc(1, XkbRF_RulesRec); } /***====================================================================***/ -static void -XkbRF_ClearVarDescriptions(XkbRF_DescribeVarsPtr var) -{ -register int i; - - for (i=0;i<var->num_desc;i++) { - if (var->desc[i].name) - _XkbFree(var->desc[i].name); - if (var->desc[i].desc) - _XkbFree(var->desc[i].desc); - var->desc[i].name= var->desc[i].desc= NULL; - } - if (var->desc) - _XkbFree(var->desc); - var->desc= NULL; - return; -} - void XkbRF_Free(XkbRF_RulesPtr rules,Bool freeRules) { @@ -1256,46 +986,34 @@ XkbRF_GroupPtr group; if (!rules) return; - XkbRF_ClearVarDescriptions(&rules->models); - XkbRF_ClearVarDescriptions(&rules->layouts); - XkbRF_ClearVarDescriptions(&rules->variants); - XkbRF_ClearVarDescriptions(&rules->options); - if (rules->extra) { - for (i = 0; i < rules->num_extra; i++) { - XkbRF_ClearVarDescriptions(&rules->extra[i]); - } - _XkbFree(rules->extra); - rules->num_extra= rules->sz_extra= 0; - rules->extra= NULL; - } if (rules->rules) { for (i=0,rule=rules->rules;i<rules->num_rules;i++,rule++) { - if (rule->model) _XkbFree(rule->model); - if (rule->layout) _XkbFree(rule->layout); - if (rule->variant) _XkbFree(rule->variant); - if (rule->option) _XkbFree(rule->option); - if (rule->keycodes) _XkbFree(rule->keycodes); - if (rule->symbols) _XkbFree(rule->symbols); - if (rule->types) _XkbFree(rule->types); - if (rule->compat) _XkbFree(rule->compat); - if (rule->geometry) _XkbFree(rule->geometry); + if (rule->model) xfree(rule->model); + if (rule->layout) xfree(rule->layout); + if (rule->variant) xfree(rule->variant); + if (rule->option) xfree(rule->option); + if (rule->keycodes) xfree(rule->keycodes); + if (rule->symbols) xfree(rule->symbols); + if (rule->types) xfree(rule->types); + if (rule->compat) xfree(rule->compat); + if (rule->geometry) xfree(rule->geometry); bzero((char *)rule,sizeof(XkbRF_RuleRec)); } - _XkbFree(rules->rules); + xfree(rules->rules); rules->num_rules= rules->sz_rules= 0; rules->rules= NULL; } if (rules->groups) { for (i=0, group=rules->groups;i<rules->num_groups;i++,group++) { - if (group->name) _XkbFree(group->name); - if (group->words) _XkbFree(group->words); + if (group->name) xfree(group->name); + if (group->words) xfree(group->words); } - _XkbFree(rules->groups); + xfree(rules->groups); rules->num_groups= 0; rules->groups= NULL; } if (freeRules) - _XkbFree(rules); + xfree(rules); return; } diff --git a/xorg-server/xkb/xkb.c b/xorg-server/xkb/xkb.c index 4ff2d5fef..0b54a2ec9 100644 --- a/xorg-server/xkb/xkb.c +++ b/xorg-server/xkb/xkb.c @@ -30,8 +30,6 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include <stdio.h> #include <X11/X.h> -#define NEED_EVENTS -#define NEED_REPLIES #include <X11/Xproto.h> #include "misc.h" #include "inputstr.h" @@ -42,12 +40,13 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "xkb.h" #include <X11/extensions/XI.h> +#include <X11/extensions/XKMformat.h> - int XkbEventBase; +int XkbEventBase; static int XkbErrorBase; - int XkbReqCode; - int XkbKeyboardErrorCode; -CARD32 xkbDebugFlags = 0; +int XkbReqCode; +int XkbKeyboardErrorCode; +CARD32 xkbDebugFlags = 0; static CARD32 xkbDebugCtrls = 0; static RESTYPE RT_XKBCLIENT; @@ -181,6 +180,7 @@ ProcXkbUseExtension(ClientPtr client) stuff->wantedMajor,stuff->wantedMinor, XkbMajorVersion,XkbMinorVersion); } + memset(&rep, 0, sizeof(xkbUseExtensionReply)); rep.type = X_Reply; rep.supported = supported; rep.length = 0; @@ -522,7 +522,7 @@ ProcXkbBell(ClientPtr client) DeviceIntPtr other; for (other = inputInfo.devices; other; other = other->next) { - if ((other != dev) && other->key && !other->isMaster && (other->u.master == dev)) + if ((other != dev) && other->key && !IsMaster(other) && (other->u.master == dev)) { rc = XaceHook(XACE_DEVICE_ACCESS, client, other, DixBellAccess); if (rc == Success) @@ -561,7 +561,7 @@ ProcXkbGetState(ClientPtr client) rep.sequenceNumber= client->sequence; rep.length = 0; rep.deviceID = dev->id; - rep.mods = dev->key->state&0xff; + rep.mods = XkbStateFieldFromRec(xkb) & 0xff; rep.baseMods = xkb->base_mods; rep.lockedMods = xkb->locked_mods; rep.latchedMods = xkb->latched_mods; @@ -605,9 +605,8 @@ ProcXkbLatchLockState(ClientPtr client) status = Success; for (tmpd = inputInfo.devices; tmpd; tmpd = tmpd->next) { - if ((dev == inputInfo.keyboard && tmpd->key && tmpd->coreEvents) || - tmpd == dev) { - if (!tmpd->key->xkbInfo) + if ((tmpd == dev) || (!IsMaster(tmpd) && tmpd->u.master == dev)) { + if (!tmpd->key || !tmpd->key->xkbInfo) continue; oldState = tmpd->key->xkbInfo->state; @@ -628,7 +627,6 @@ ProcXkbLatchLockState(ClientPtr client) return status; XkbComputeDerivedState(tmpd->key->xkbInfo); - tmpd->key->state = XkbStateFieldFromRec(newState); changed = XkbStateChangedFlags(&oldState, newState); if (changed) { @@ -670,8 +668,8 @@ ProcXkbGetControls(ClientPtr client) xkb = dev->key->xkbInfo->desc->ctrls; rep.type = X_Reply; - rep.length = (SIZEOF(xkbGetControlsReply)- - SIZEOF(xGenericReply)) >> 2; + rep.length = bytes_to_int32(SIZEOF(xkbGetControlsReply)- + SIZEOF(xGenericReply)); rep.sequenceNumber = client->sequence; rep.deviceID = ((DeviceIntPtr)dev)->id; rep.numGroups = xkb->num_groups; @@ -746,10 +744,10 @@ ProcXkbSetControls(ClientPtr client) CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixManageAccess); CHK_MASK_LEGAL(0x01, stuff->changeCtrls, XkbAllControlsMask); - for (tmpd = inputInfo.keyboard; tmpd; tmpd = tmpd->next) { - if ((dev == inputInfo.keyboard && tmpd->key && tmpd->coreEvents) || - tmpd == dev) { - + for (tmpd = inputInfo.devices; tmpd; tmpd = tmpd->next) { + if (!tmpd->key || !tmpd->key->xkbInfo) + continue; + if ((tmpd == dev) || (!IsMaster(tmpd) && tmpd->u.master == dev)) { xkbi = tmpd->key->xkbInfo; ctrl = xkbi->desc->ctrls; new = *ctrl; @@ -1366,7 +1364,7 @@ unsigned i,len; char *desc,*start; len= (rep->length*4)-(SIZEOF(xkbGetMapReply)-SIZEOF(xGenericReply)); - start= desc= (char *)xalloc(len); + start= desc= xcalloc(1, len); if (!start) return BadAlloc; if ( rep->nTypes>0 ) @@ -2187,8 +2185,8 @@ unsigned first,last; if (maxRG>(int)xkbi->nRadioGroups) { int sz = maxRG*sizeof(XkbRadioGroupRec); if (xkbi->radioGroups) - xkbi->radioGroups=(XkbRadioGroupPtr)_XkbRealloc(xkbi->radioGroups,sz); - else xkbi->radioGroups= (XkbRadioGroupPtr)_XkbCalloc(1, sz); + xkbi->radioGroups= xrealloc(xkbi->radioGroups,sz); + else xkbi->radioGroups= xcalloc(1, sz); if (xkbi->radioGroups) { if (xkbi->nRadioGroups) bzero(&xkbi->radioGroups[xkbi->nRadioGroups], @@ -2522,7 +2520,6 @@ _XkbSetMap(ClientPtr client, DeviceIntPtr dev, xkbSetMapReq *req, char *values) if (!sentNKN) XkbSendNotification(dev,&change,&cause); - XkbUpdateCoreDescription(dev,False); return Success; allocFailure: return BadAlloc; @@ -2560,7 +2557,7 @@ ProcXkbSetMap(ClientPtr client) DeviceIntPtr other; for (other = inputInfo.devices; other; other = other->next) { - if ((other != dev) && other->key && !other->isMaster && (other->u.master == dev)) + if ((other != dev) && other->key && !IsMaster(other) && (other->u.master == dev)) { rc = XaceHook(XACE_DEVICE_ACCESS, client, other, DixManageAccess); if (rc == Success) @@ -2583,7 +2580,7 @@ ProcXkbSetMap(ClientPtr client) DeviceIntPtr other; for (other = inputInfo.devices; other; other = other->next) { - if ((other != dev) && other->key && !other->isMaster && (other->u.master == dev)) + if ((other != dev) && other->key && !IsMaster(other) && (other->u.master == dev)) { rc = XaceHook(XACE_DEVICE_ACCESS, client, other, DixManageAccess); if (rc == Success) @@ -2631,7 +2628,7 @@ int size; size= rep->length*4; if (size>0) { - data = (char *)xalloc(size); + data = xalloc(size); if (data) { register unsigned i,bit; xkbModsWireDesc * grp; @@ -2859,7 +2856,6 @@ _XkbSetCompatMap(ClientPtr client, DeviceIntPtr dev, &cause); if (check) XkbCheckSecondaryEffects(xkbi,check,&change,&cause); - XkbUpdateCoreDescription(dev,False); XkbSendNotification(dev,&change,&cause); } return Success; @@ -2891,7 +2887,7 @@ ProcXkbSetCompatMap(ClientPtr client) DeviceIntPtr other; for (other = inputInfo.devices; other; other = other->next) { - if ((other != dev) && other->key && !other->isMaster && (other->u.master == dev)) + if ((other != dev) && other->key && !IsMaster(other) && (other->u.master == dev)) { rc = XaceHook(XACE_DEVICE_ACCESS, client, other, DixManageAccess); if (rc == Success) @@ -2914,7 +2910,7 @@ ProcXkbSetCompatMap(ClientPtr client) DeviceIntPtr other; for (other = inputInfo.devices; other; other = other->next) { - if ((other != dev) && other->key && !other->isMaster && (other->u.master == dev)) + if ((other != dev) && other->key && !IsMaster(other) && (other->u.master == dev)) { rc = XaceHook(XACE_DEVICE_ACCESS, client, other, DixManageAccess); if (rc == Success) @@ -2999,7 +2995,7 @@ register unsigned bit; length = rep->length*4; if (length>0) { CARD8 *to; - to= map= (CARD8 *)xalloc(length); + to= map= xalloc(length); if (map) { xkbIndicatorMapWireDesc *wire = (xkbIndicatorMapWireDesc *)to; for (i=0,bit=1;i<XkbNumIndicators;i++,bit<<=1) { @@ -3169,7 +3165,7 @@ ProcXkbSetIndicatorMap(ClientPtr client) DeviceIntPtr other; for (other = inputInfo.devices; other; other = other->next) { - if ((other != dev) && other->key && !other->isMaster && (other->u.master == dev)) + if ((other != dev) && other->key && !IsMaster(other) && (other->u.master == dev)) { rc = XaceHook(XACE_DEVICE_ACCESS, client, other, DixSetAttrAccess); if (rc == Success) @@ -3437,7 +3433,7 @@ ProcXkbSetNamedIndicator(ClientPtr client) DeviceIntPtr other; for (other = inputInfo.devices; other; other = other->next) { - if ((other != dev) && !other->isMaster && (other->u.master == dev) && + if ((other != dev) && !IsMaster(other) && (other->u.master == dev) && (other->kbdfeed || other->leds) && (XaceHook(XACE_DEVICE_ACCESS, client, other, DixSetAttrAccess) == Success)) { @@ -3461,7 +3457,7 @@ ProcXkbSetNamedIndicator(ClientPtr client) DeviceIntPtr other; for (other = inputInfo.devices; other; other = other->next) { - if ((other != dev) && !other->isMaster && (other->u.master == dev) && + if ((other != dev) && !IsMaster(other) && (other->u.master == dev) && (other->kbdfeed || other->leds) && (XaceHook(XACE_DEVICE_ACCESS, client, other, DixSetAttrAccess) == Success)) { @@ -3635,7 +3631,7 @@ register int n; swapl(&rep->indicators,n); } - start = desc = (char *)xalloc(length); + start = desc = xalloc(length); if ( !start ) return BadAlloc; if (xkb->names) { @@ -3780,6 +3776,7 @@ ProcXkbGetNames(ClientPtr client) CHK_MASK_LEGAL(0x01,stuff->which,XkbAllNamesMask); xkb = dev->key->xkbInfo->desc; + memset(&rep, 0, sizeof(xkbGetNamesReply)); rep.type= X_Reply; rep.sequenceNumber= client->sequence; rep.length = 0; @@ -3860,7 +3857,7 @@ register int i,bit; static Bool _XkbCheckTypeName(Atom name,int typeNdx) { -char * str; +const char * str; str= NameForAtom(name); if ((strcmp(str,"ONE_LEVEL")==0)||(strcmp(str,"TWO_LEVEL")==0)|| @@ -4120,7 +4117,7 @@ _XkbSetNames(ClientPtr client, DeviceIntPtr dev, xkbSetNamesReq *stuff) tmp+= stuff->nKeyAliases*2; } else if (names->key_aliases!=NULL) { - _XkbFree(names->key_aliases); + xfree(names->key_aliases); names->key_aliases= NULL; names->num_key_aliases= 0; } @@ -4139,7 +4136,7 @@ _XkbSetNames(ClientPtr client, DeviceIntPtr dev, xkbSetNamesReq *stuff) tmp+= stuff->nRadioGroups; } else if (names->radio_groups) { - _XkbFree(names->radio_groups); + xfree(names->radio_groups); names->radio_groups= NULL; names->num_rg= 0; } @@ -4251,7 +4248,7 @@ ProcXkbSetNames(ClientPtr client) DeviceIntPtr other; for (other = inputInfo.devices; other; other = other->next) { - if ((other != dev) && other->key && !other->isMaster && (other->u.master == dev)) + if ((other != dev) && other->key && !IsMaster(other) && (other->u.master == dev)) { rc = XaceHook(XACE_DEVICE_ACCESS, client, other, DixManageAccess); @@ -4276,7 +4273,7 @@ ProcXkbSetNames(ClientPtr client) DeviceIntPtr other; for (other = inputInfo.devices; other; other = other->next) { - if ((other != dev) && other->key && !other->isMaster && (other->u.master == dev)) + if ((other != dev) && other->key && !IsMaster(other) && (other->u.master == dev)) { rc = XaceHook(XACE_DEVICE_ACCESS, client, other, DixManageAccess); @@ -4739,7 +4736,7 @@ XkbSendGeometry( ClientPtr client, if (geom!=NULL) { len= rep->length*4; - start= desc= (char *)xalloc(len); + start= desc= xalloc(len); if (!start) return BadAlloc; desc= XkbWriteCountedString(desc,geom->label_font,client->swapped); @@ -4833,7 +4830,7 @@ CARD16 len,*plen; swaps(plen,n); } len= *plen; - str= (char *)_XkbAlloc(len+1); + str= xalloc(len+1); if (str) { memcpy(str,&wire[2],len); str[len]= '\0'; @@ -5327,7 +5324,7 @@ ProcXkbSetGeometry(ClientPtr client) DeviceIntPtr other; for (other = inputInfo.devices; other; other = other->next) { - if ((other != dev) && other->key && !other->isMaster && (other->u.master == dev)) + if ((other != dev) && other->key && !IsMaster(other) && (other->u.master == dev)) { rc = XaceHook(XACE_DEVICE_ACCESS, client, other, DixManageAccess); if (rc == Success) @@ -5360,6 +5357,7 @@ ProcXkbPerClientFlags(ClientPtr client) CHK_MASK_MATCH(0x02,stuff->change,stuff->value); interest = XkbFindClientResource((DevicePtr)dev,client); + memset(&rep, 0, sizeof(xkbPerClientFlagsReply)); rep.type= X_Reply; rep.length = 0; rep.sequenceNumber = client->sequence; @@ -5447,7 +5445,7 @@ unsigned char *wire,*str,*tmp,*legal; wire= *pWire; len= (*(unsigned char *)wire++); if (len>0) { - str= (unsigned char *)_XkbCalloc(1, len+1); + str= xcalloc(1, len+1); if (str) { tmp= str; for (i=0;i<len;i++) { @@ -5458,7 +5456,7 @@ unsigned char *wire,*str,*tmp,*legal; if (tmp!=str) *tmp++= '\0'; else { - _XkbFree(str); + xfree(str); str= NULL; } } @@ -5497,7 +5495,6 @@ ProcXkbListComponents(ClientPtr client) str= (unsigned char *)&stuff[1]; bzero(&list,sizeof(XkbSrvListInfoRec)); list.maxRtrn= stuff->maxNames; - list.pattern[_XkbListKeymaps]= GetComponentSpec(&str,False,&status); list.pattern[_XkbListKeycodes]= GetComponentSpec(&str,False,&status); list.pattern[_XkbListTypes]= GetComponentSpec(&str,False,&status); list.pattern[_XkbListCompat]= GetComponentSpec(&str,False,&status); @@ -5510,7 +5507,7 @@ ProcXkbListComponents(ClientPtr client) return BadLength; if ((status=XkbDDXList(dev,&list,client))!=Success) { if (list.pool) { - _XkbFree(list.pool); + xfree(list.pool); list.pool= NULL; } return status; @@ -5520,7 +5517,7 @@ ProcXkbListComponents(ClientPtr client) rep.deviceID = dev->id; rep.sequenceNumber = client->sequence; rep.length = XkbPaddedSize(list.nPool)/4; - rep.nKeymaps = list.nFound[_XkbListKeymaps]; + rep.nKeymaps = 0; rep.nKeycodes = list.nFound[_XkbListKeycodes]; rep.nTypes = list.nFound[_XkbListTypes]; rep.nCompatMaps = list.nFound[_XkbListCompat]; @@ -5544,7 +5541,7 @@ ProcXkbListComponents(ClientPtr client) WriteToClient(client,SIZEOF(xkbListComponentsReply),(char *)&rep); if (list.nPool && list.pool) { WriteToClient(client,XkbPaddedSize(list.nPool), (char *)list.pool); - _XkbFree(list.pool); + xfree(list.pool); list.pool= NULL; } return client->noClientException; @@ -5586,7 +5583,8 @@ ProcXkbGetKbdByName(ClientPtr client) xkb = dev->key->xkbInfo->desc; status= Success; str= (unsigned char *)&stuff[1]; - names.keymap= GetComponentSpec(&str,True,&status); + if (GetComponentSpec(&str,True,&status)) /* keymap, unsupported */ + return BadMatch; names.keycodes= GetComponentSpec(&str,True,&status); names.types= GetComponentSpec(&str,True,&status); names.compat= GetComponentSpec(&str,True,&status); @@ -5840,16 +5838,9 @@ ProcXkbGetKbdByName(ClientPtr client) xkb->ctrls->num_groups= nTG; for (tmpd = inputInfo.devices; tmpd; tmpd = tmpd->next) { - if (tmpd == dev || - (dev->id == inputInfo.keyboard->id && tmpd->key && - tmpd->coreEvents)) { - - memcpy(tmpd->key->modifierMap, xkb->map->modmap, - xkb->max_key_code + 1); + if ((tmpd == dev) || (!IsMaster(tmpd) && tmpd->u.master == dev)) { if (tmpd != dev) - XkbCopyKeymap(dev->key->xkbInfo->desc, - tmpd->key->xkbInfo->desc, True); - XkbUpdateCoreDescription(tmpd, True); + XkbCopyDeviceKeymap(tmpd, dev); if (tmpd->kbdfeed && tmpd->kbdfeed->xkb_sli) { old_sli = tmpd->kbdfeed->xkb_sli; @@ -5865,8 +5856,6 @@ ProcXkbGetKbdByName(ClientPtr client) } } - /* this should be either a MN or an NKN, depending on whether or not - * the keycode range changed? */ nkn.deviceID= nkn.oldDeviceID= dev->id; nkn.minKeyCode= new->min_key_code; nkn.maxKeyCode= new->max_key_code; @@ -5878,17 +5867,26 @@ ProcXkbGetKbdByName(ClientPtr client) if (geom_changed) nkn.changed|= XkbNKN_GeometryMask; XkbSendNewKeyboardNotify(dev,&nkn); + + if (!IsMaster(dev) && dev->u.master) + { + DeviceIntPtr master = dev->u.master; + if (master->u.lastSlave == dev) + { + XkbCopyDeviceKeymap(dev->u.master, dev); + XkbSendNewKeyboardNotify(dev,&nkn); + } + } } if ((new!=NULL)&&(new!=xkb)) { XkbFreeKeyboard(new,XkbAllComponentsMask,True); new= 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.symbols) { _XkbFree(names.symbols); names.symbols= NULL; } - if (names.geometry) { _XkbFree(names.geometry); names.geometry= NULL; } + if (names.keycodes) { xfree(names.keycodes); names.keycodes= NULL; } + if (names.types) { xfree(names.types); names.types= NULL; } + if (names.compat) { xfree(names.compat); names.compat= NULL; } + if (names.symbols) { xfree(names.symbols); names.symbols= NULL; } + if (names.geometry) { xfree(names.geometry); names.geometry= NULL; } return client->noClientException; } @@ -5974,10 +5972,8 @@ Bool classOk; } } if (nFBs>0) { - if (rep->supported&XkbXI_IndicatorsMask) { - rep->nDeviceLedFBs= nFBs; - rep->length+= (length/4); - } + rep->nDeviceLedFBs= nFBs; + rep->length+= (length/4); return Success; } if (classOk) client->errorValue= _XkbErrCode2(XkbErr_BadId,id); @@ -6101,7 +6097,7 @@ xkbGetDeviceInfoReply rep; int status,nDeviceLedFBs; unsigned length,nameLen; CARD16 ledClass,ledID; -unsigned wanted,supported; +unsigned wanted; char * str; REQUEST(xkbGetDeviceInfoReq); @@ -6134,7 +6130,7 @@ char * str; if (dev->button) rep.totalBtns= dev->button->numButtons; else rep.totalBtns= 0; - rep.devType= dev->type; + rep.devType= dev->xinput_type; rep.hasOwnState= (dev->key && dev->key->xkbInfo); rep.nDeviceLedFBs = 0; if (dev->kbdfeed) rep.dfltKbdFB= dev->kbdfeed->ctrl.id; @@ -6192,7 +6188,6 @@ char * str; return status; } length= rep.length*4; - supported= rep.supported; nDeviceLedFBs = rep.nDeviceLedFBs; if (client->swapped) { register int n; @@ -6206,7 +6201,7 @@ char * str; } WriteToClient(client,SIZEOF(xkbGetDeviceInfoReply), (char *)&rep); - str= (char*) xalloc(nameLen); + str= xalloc(nameLen); if (!str) return BadAlloc; XkbWriteCountedString(str,dev->name,client->swapped); @@ -6232,19 +6227,6 @@ char * str; ErrorF("[xkb] Wrote %d fewer bytes than expected\n",length); return BadLength; } - if (stuff->wanted&(~supported)) { - xkbExtensionDeviceNotify ed; - bzero((char *)&ed,SIZEOF(xkbExtensionDeviceNotify)); - ed.ledClass= ledClass; - ed.ledID= ledID; - ed.ledsDefined= 0; - ed.ledState= 0; - ed.firstBtn= ed.nBtns= 0; - ed.reason= XkbXI_UnsupportedFeatureMask; - ed.supported= supported; - ed.unsupported= stuff->wanted&(~supported); - XkbSendExtensionDeviceNotify(dev,client,&ed); - } return client->noClientException; } @@ -6530,7 +6512,7 @@ ProcXkbSetDeviceInfo(ClientPtr client) DeviceIntPtr other; for (other = inputInfo.devices; other; other = other->next) { - if (((other != dev) && !other->isMaster && (other->u.master == dev)) && + if (((other != dev) && !IsMaster(other) && (other->u.master == dev)) && ((stuff->deviceSpec == XkbUseCoreKbd && other->key) || (stuff->deviceSpec == XkbUseCorePtr && other->button))) { @@ -6555,7 +6537,7 @@ ProcXkbSetDeviceInfo(ClientPtr client) DeviceIntPtr other; for (other = inputInfo.devices; other; other = other->next) { - if (((other != dev) && !other->isMaster && (other->u.master == dev)) && + if (((other != dev) && !IsMaster(other) && (other->u.master == dev)) && ((stuff->deviceSpec == XkbUseCoreKbd && other->key) || (stuff->deviceSpec == XkbUseCorePtr && other->button))) { @@ -6617,8 +6599,6 @@ int rc; xkbDebugFlags = newFlags; xkbDebugCtrls = newCtrls; - XkbDisableLockActions= (xkbDebugCtrls&XkbDF_DisableLocks); - rep.type= X_Reply; rep.length = 0; rep.sequenceNumber = client->sequence; diff --git a/xorg-server/xkb/xkb.h b/xorg-server/xkb/xkb.h index bc6c6c954..a526356a9 100644 --- a/xorg-server/xkb/xkb.h +++ b/xorg-server/xkb/xkb.h @@ -29,12 +29,4 @@ extern int ProcXkbSetDeviceInfo(ClientPtr client); extern int ProcXkbSetDebuggingFlags(ClientPtr client); extern void XkbExtensionInit(void); - -extern Bool XkbFilterEvents(ClientPtr pClient, int nEvents, xEvent *xE); - -extern Bool XkbCopyKeymap( - XkbDescPtr src, - XkbDescPtr dst, - Bool sendNotifies); - #endif diff --git a/xorg-server/xkb/xkbAccessX.c b/xorg-server/xkb/xkbAccessX.c index 2baa70d7a..47023c048 100644 --- a/xorg-server/xkb/xkbAccessX.c +++ b/xorg-server/xkb/xkbAccessX.c @@ -30,19 +30,20 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include <stdio.h> #include <math.h> -#define NEED_EVENTS 1 #include <X11/X.h> #include <X11/Xproto.h> #include <X11/keysym.h> +#include "exglobals.h" +#include <X11/extensions/XIproto.h> #include "inputstr.h" +#include "eventstr.h" #include <xkbsrv.h> #if !defined(WIN32) #include <sys/time.h> #endif -_X_EXPORT int XkbDfltRepeatDelay= 660; -_X_EXPORT int XkbDfltRepeatInterval= 40; -pointer XkbLastRepeatEvent= NULL; +int XkbDfltRepeatDelay= 660; +int XkbDfltRepeatInterval= 40; #define DFLT_TIMEOUT_CTRLS (XkbAX_KRGMask|XkbStickyKeysMask|XkbMouseKeysMask) #define DFLT_TIMEOUT_OPTS (XkbAX_IndicatorFBMask) @@ -118,27 +119,26 @@ XkbControlsPtr ctrls = xkbi->desc->ctrls; /************************************************************************/ static void AccessXKeyboardEvent(DeviceIntPtr keybd, - BYTE type, + int type, BYTE keyCode, Bool isRepeat) { -xEvent xE; - - xE.u.u.type = type; - xE.u.u.detail = keyCode; - xE.u.keyButtonPointer.time = GetTimeInMillis(); + DeviceEvent event; + memset(&event, 0, sizeof(DeviceEvent)); + event.header = ET_Internal; + event.type = type; + event.detail.key = keyCode; + event.time = GetTimeInMillis(); + event.length = sizeof(DeviceEvent); + event.key_repeat = isRepeat; + if (xkbDebugFlags&0x8) { - DebugF("[xkb] AXKE: Key %d %s\n",keyCode,(xE.u.u.type==KeyPress?"down":"up")); + DebugF("[xkb] AXKE: Key %d %s\n", keyCode, + (event.type == ET_KeyPress ? "down" : "up")); } - if (_XkbIsPressEvent(type)) - XkbDDXKeyClick(keybd,keyCode,TRUE); - else if (isRepeat) - XkbLastRepeatEvent= (pointer)&xE; - XkbProcessKeyboardEvent(&xE,keybd,1L); - XkbLastRepeatEvent= NULL; + XkbProcessKeyboardEvent(&event, keybd); return; - } /* AccessXKeyboardEvent */ /************************************************************************/ @@ -305,14 +305,11 @@ AccessXRepeatKeyExpire(OsTimerPtr timer,CARD32 now,pointer arg) { DeviceIntPtr dev = (DeviceIntPtr) arg; XkbSrvInfoPtr xkbi = dev->key->xkbInfo; -KeyCode key; if (xkbi->repeatKey == 0) return 0; - key = xkbi->repeatKey; - AccessXKeyboardEvent(dev, DeviceKeyRelease, key, True); - AccessXKeyboardEvent(dev, DeviceKeyPress, key, True); + AccessXKeyboardEvent(dev, ET_KeyPress, xkbi->repeatKey, True); return xkbi->desc->ctrls->repeat_interval; } @@ -347,7 +344,7 @@ XkbControlsPtr ctrls; XkbSendAccessXNotify(keybd,&ev); if (XkbAX_NeedFeedback(ctrls,XkbAX_SKAcceptFBMask)) XkbDDXAccessXBeep(keybd,_BEEP_SLOW_ACCEPT,XkbSlowKeysMask); - AccessXKeyboardEvent(keybd,DeviceKeyPress,xkbi->slowKey,False); + AccessXKeyboardEvent(keybd, ET_KeyPress,xkbi->slowKey,False); /* check for magic sequences */ if ((ctrls->enabled_ctrls&XkbAccessXKeysMask) && ((sym[0]==XK_Shift_R)||(sym[0]==XK_Shift_L))) @@ -443,14 +440,13 @@ XkbSrvLedInfoPtr sli; /* */ /************************************************************************/ Bool -AccessXFilterPressEvent( register xEvent * xE, - register DeviceIntPtr keybd, - int count) +AccessXFilterPressEvent( DeviceEvent* event, + DeviceIntPtr keybd) { XkbSrvInfoPtr xkbi = keybd->key->xkbInfo; XkbControlsPtr ctrls = xkbi->desc->ctrls; Bool ignoreKeyEvent = FALSE; -KeyCode key = xE->u.u.detail; +KeyCode key = event->detail.key; KeySym * sym = XkbKeySymsPtr(xkbi->desc,key); if (ctrls->enabled_ctrls&XkbAccessXKeysMask) { @@ -556,7 +552,7 @@ KeySym * sym = XkbKeySymsPtr(xkbi->desc,key); } if (!ignoreKeyEvent) - XkbProcessKeyboardEvent(xE,keybd,count); + XkbProcessKeyboardEvent(event, keybd); return ignoreKeyEvent; } /* AccessXFilterPressEvent */ @@ -573,13 +569,12 @@ KeySym * sym = XkbKeySymsPtr(xkbi->desc,key); /* */ /************************************************************************/ Bool -AccessXFilterReleaseEvent( register xEvent * xE, - register DeviceIntPtr keybd, - int count) +AccessXFilterReleaseEvent( DeviceEvent* event, + DeviceIntPtr keybd) { XkbSrvInfoPtr xkbi = keybd->key->xkbInfo; XkbControlsPtr ctrls = xkbi->desc->ctrls; -KeyCode key = xE->u.u.detail; +KeyCode key = event->detail.key; Bool ignoreKeyEvent = FALSE; /* Don't transmit the KeyRelease if BounceKeys is on and @@ -605,7 +600,7 @@ Bool ignoreKeyEvent = FALSE; ev.keycode= key; ev.slowKeysDelay= ctrls->slow_keys_delay; ev.debounceDelay= ctrls->debounce_delay; - if (BitIsOn(keybd->key->down,key) | (xkbi->mouseKey == key)) { + if (BitIsOn(keybd->key->down,key) || (xkbi->mouseKey == key)) { ev.detail= XkbAXN_SKRelease; beep_type= _BEEP_SLOW_RELEASE; } @@ -665,7 +660,7 @@ Bool ignoreKeyEvent = FALSE; } if (!ignoreKeyEvent) - XkbProcessKeyboardEvent(xE,keybd,count); + XkbProcessKeyboardEvent(event, keybd); return ignoreKeyEvent; } /* AccessXFilterReleaseEvent */ @@ -683,24 +678,31 @@ Bool ignoreKeyEvent = FALSE; extern int xkbDevicePrivateIndex; extern void xkbUnwrapProc(DeviceIntPtr, DeviceHandleProc, pointer); void -ProcessPointerEvent( register xEvent * xE, - register DeviceIntPtr mouse, - int count) +ProcessPointerEvent( InternalEvent *ev, + DeviceIntPtr mouse) { -DeviceIntPtr dev = GetPairedDevice(mouse); -XkbSrvInfoPtr xkbi = dev->key->xkbInfo; +DeviceIntPtr dev; +XkbSrvInfoPtr xkbi = NULL; unsigned changed = 0; ProcessInputProc backupproc; xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(mouse); +DeviceEvent *event = (DeviceEvent*)ev; - xkbi->shiftKeyCount = 0; - xkbi->lastPtrEventTime= xE->u.keyButtonPointer.time; + dev = (IsMaster(mouse) || mouse->u.master) ? GetMaster(mouse, MASTER_KEYBOARD) : mouse; - if (xE->u.u.type==ButtonPress) { + if (dev && dev->key) + { + xkbi = dev->key->xkbInfo; + xkbi->shiftKeyCount = 0; + xkbi->lastPtrEventTime= event->time; + } + + if (event->type == ET_ButtonPress) { changed |= XkbPointerButtonMask; } - else if (xE->u.u.type==ButtonRelease) { - xkbi->lockedPtrButtons&= ~(1<<(xE->u.u.detail&0x7)); + else if (event->type == ET_ButtonRelease) { + if (xkbi) + xkbi->lockedPtrButtons&= ~(1 << (event->detail.key & 0x7)); changed |= XkbPointerButtonMask; } @@ -719,15 +721,19 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(mouse); * * see. it's still steaming. told you. (whot) */ + UNWRAP_PROCESS_INPUT_PROC(mouse, xkbPrivPtr, backupproc); - mouse->public.processInputProc(xE, mouse, count); + mouse->public.processInputProc(ev, mouse); COND_WRAP_PROCESS_INPUT_PROC(mouse, xkbPrivPtr, backupproc, xkbUnwrapProc); - xkbi->state.ptr_buttons = mouse->button->state; + if (!xkbi) + return; + + xkbi->state.ptr_buttons = (mouse->button) ? mouse->button->state : 0; /* clear any latched modifiers */ - if ( xkbi->state.latched_mods && (xE->u.u.type==ButtonRelease) ) { + if ( xkbi->state.latched_mods && (event->type == ET_ButtonRelease) ) { unsigned changed_leds; XkbStateRec oldState; XkbSrvLedInfoPtr sli; @@ -742,17 +748,16 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(mouse); changed_leds= XkbIndicatorsToUpdate(dev,changed,False); if (changed_leds) { XkbEventCauseRec cause; - XkbSetCauseKey(&cause,(xE->u.u.detail&0x7),xE->u.u.type); + XkbSetCauseKey(&cause,(event->detail.key & 0x7), event->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.keycode= event->detail.key; + sn.eventType= event->type; sn.requestMajor = sn.requestMinor = 0; sn.changed= changed; XkbSendStateNotify(dev,&sn); diff --git a/xorg-server/xkb/xkbActions.c b/xorg-server/xkb/xkbActions.c index aea479cd1..9c3184a83 100644 --- a/xorg-server/xkb/xkbActions.c +++ b/xorg-server/xkb/xkbActions.c @@ -30,13 +30,13 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include <stdio.h> #include <math.h> -#define NEED_EVENTS 1 #include <X11/X.h> #include <X11/Xproto.h> #include <X11/keysym.h> #include "misc.h" #include "inputstr.h" #include "exevents.h" +#include "eventstr.h" #include <xkbsrv.h> #include "xkb.h" #include <ctype.h> @@ -75,12 +75,6 @@ XkbSetExtension(DeviceIntPtr device, ProcessInputProc proc) WRAP_PROCESS_INPUT_PROC(device, xkbPrivPtr, proc, xkbUnwrapProc); } -extern void ProcessOtherEvent( - xEvent * /* xE */, - DeviceIntPtr /* dev */, - int /* count */ -); - /***====================================================================***/ static XkbAction @@ -92,41 +86,6 @@ static XkbAction fake; fake.type = XkbSA_NoAction; return fake; } - if (XkbDisableLockActions) { - switch (act->type) { - case XkbSA_LockMods: - fake.mods.type = XkbSA_SetMods; - fake.mods.flags = 0; - fake.mods.mask = act->mods.mask; - return fake; - case XkbSA_LatchMods: - fake.mods.type = XkbSA_SetMods; - fake.mods.flags = 0; - fake.mods.mask = act->mods.mask; - return fake; - case XkbSA_ISOLock: - if (act->iso.flags&XkbSA_ISODfltIsGroup) { - fake.group.type = XkbSA_SetGroup; - fake.group.flags = act->iso.flags&XkbSA_GroupAbsolute; - XkbSASetGroup(&fake.group,XkbSAGroup(&act->iso)); - } - else { - fake.mods.type = XkbSA_SetMods; - fake.mods.flags = 0; - fake.mods.mask = act->iso.mask; - } - return fake; - case XkbSA_LockGroup: - case XkbSA_LatchGroup: - /* We want everything from the latch/lock action except the - * type should be changed to set. - */ - fake = *act; - fake.group.type = XkbSA_SetGroup; - return fake; - } - } - else if (xkb->ctrls->enabled_ctrls&XkbStickyKeysMask) { if (act->any.type==XkbSA_SetMods) { fake.mods.type = XkbSA_LatchMods; @@ -840,11 +799,10 @@ _XkbFilterRedirectKey( XkbSrvInfoPtr xkbi, unsigned keycode, XkbAction * pAction) { -unsigned realMods = 0; -xEvent ev; +DeviceEvent ev; int x,y; XkbStateRec old; -unsigned mods,mask,oldCoreState = 0,oldCorePrevState = 0; +unsigned mods,mask; xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(xkbi->device); ProcessInputProc backupproc; @@ -855,10 +813,12 @@ ProcessInputProc backupproc; if ((filter->keycode!=0)&&(filter->keycode!=keycode)) return 1; - GetSpritePosition(inputInfo.pointer, &x,&y); - ev.u.keyButtonPointer.time = GetTimeInMillis(); - ev.u.keyButtonPointer.rootX = x; - ev.u.keyButtonPointer.rootY = y; + GetSpritePosition(xkbi->device, &x,&y); + ev.header = ET_Internal; + ev.length = sizeof(DeviceEvent); + ev.time = GetTimeInMillis(); + ev.root_x = x; + ev.root_y = y; if (filter->keycode==0) { /* initial press */ if ((pAction->redirect.new_key<xkbi->desc->min_key_code)|| @@ -872,9 +832,8 @@ ProcessInputProc backupproc; filter->filter = _XkbFilterRedirectKey; filter->upAction = *pAction; - /* XXX: what about DeviceKeyPress */ - ev.u.u.type = KeyPress; - ev.u.u.detail = pAction->redirect.new_key; + ev.type = ET_KeyPress; + ev.detail.key = pAction->redirect.new_key; mask= XkbSARedirectVModsMask(&pAction->redirect); mods= XkbSARedirectVMods(&pAction->redirect); @@ -885,8 +844,6 @@ ProcessInputProc backupproc; if ( mask || mods ) { old= xkbi->state; - oldCoreState= xkbi->device->key->state; - oldCorePrevState= xkbi->device->key->prev_state; xkbi->state.base_mods&= ~mask; xkbi->state.base_mods|= (mods&mask); xkbi->state.latched_mods&= ~mask; @@ -894,29 +851,20 @@ ProcessInputProc backupproc; xkbi->state.locked_mods&= ~mask; xkbi->state.locked_mods|= (mods&mask); XkbComputeDerivedState(xkbi); - xkbi->device->key->state= xkbi->device->key->prev_state= - xkbi->state.mods; } - realMods = xkbi->device->key->modifierMap[ev.u.u.detail]; - xkbi->device->key->modifierMap[ev.u.u.detail] = 0; UNWRAP_PROCESS_INPUT_PROC(xkbi->device,xkbPrivPtr, backupproc); - xkbi->device->public.processInputProc(&ev,xkbi->device,1); + xkbi->device->public.processInputProc((InternalEvent*)&ev, xkbi->device); COND_WRAP_PROCESS_INPUT_PROC(xkbi->device, xkbPrivPtr, backupproc,xkbUnwrapProc); - xkbi->device->key->modifierMap[ev.u.u.detail] = realMods; - if ( mask || mods ) { - xkbi->device->key->state= oldCoreState; - xkbi->device->key->prev_state= oldCorePrevState; + if ( mask || mods ) xkbi->state= old; - } } else if (filter->keycode==keycode) { - /* XXX: what about DeviceKeyRelease */ - ev.u.u.type = KeyRelease; - ev.u.u.detail = filter->upAction.redirect.new_key; + ev.type = ET_KeyRelease; + ev.detail.key = filter->upAction.redirect.new_key; mask= XkbSARedirectVModsMask(&filter->upAction.redirect); mods= XkbSARedirectVMods(&filter->upAction.redirect); @@ -927,8 +875,6 @@ ProcessInputProc backupproc; if ( mask || mods ) { old= xkbi->state; - oldCoreState= xkbi->device->key->state; - oldCorePrevState= xkbi->device->key->prev_state; xkbi->state.base_mods&= ~mask; xkbi->state.base_mods|= (mods&mask); xkbi->state.latched_mods&= ~mask; @@ -936,23 +882,15 @@ ProcessInputProc backupproc; xkbi->state.locked_mods&= ~mask; xkbi->state.locked_mods|= (mods&mask); XkbComputeDerivedState(xkbi); - xkbi->device->key->state= xkbi->device->key->prev_state= - xkbi->state.mods; } - realMods = xkbi->device->key->modifierMap[ev.u.u.detail]; - xkbi->device->key->modifierMap[ev.u.u.detail] = 0; UNWRAP_PROCESS_INPUT_PROC(xkbi->device,xkbPrivPtr, backupproc); - xkbi->device->public.processInputProc(&ev,xkbi->device,1); + xkbi->device->public.processInputProc((InternalEvent*)&ev, xkbi->device); COND_WRAP_PROCESS_INPUT_PROC(xkbi->device, xkbPrivPtr, backupproc,xkbUnwrapProc); - xkbi->device->key->modifierMap[ev.u.u.detail] = realMods; - if ( mask || mods ) { - xkbi->device->key->state= oldCoreState; - xkbi->device->key->prev_state= oldCorePrevState; + if ( mask || mods ) xkbi->state= old; - } filter->keycode= 0; filter->active= 0; @@ -1027,7 +965,7 @@ int button; if (filter->keycode==0) { /* initial press */ _XkbLookupButtonDevice(&dev, pAction->devbtn.device, serverClient, DixUnknownAccess, &button); - if (!dev || !dev->public.on || dev == inputInfo.pointer) + if (!dev || !dev->public.on) return 1; button= pAction->devbtn.button; @@ -1068,7 +1006,7 @@ int button; filter->active= 0; _XkbLookupButtonDevice(&dev, filter->upAction.devbtn.device, serverClient, DixUnknownAccess, &button); - if (!dev || !dev->public.on || dev == inputInfo.pointer) + if (!dev || !dev->public.on) return 1; button= filter->upAction.btn.button; @@ -1131,15 +1069,13 @@ register int i,send; } void -XkbHandleActions(DeviceIntPtr dev,DeviceIntPtr kbd,xEvent *xE,int count) +XkbHandleActions(DeviceIntPtr dev, DeviceIntPtr kbd, DeviceEvent* event) { int key,bit,i; -CARD8 realMods = 0; XkbSrvInfoPtr xkbi; KeyClassPtr keyc; int changed,sendEvent; Bool genStateNotify; -XkbStateRec oldState; XkbAction act; XkbFilterPtr filter; Bool keyEvent; @@ -1150,11 +1086,11 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(dev); keyc= kbd->key; xkbi= keyc->xkbInfo; - key= xE->u.u.detail; + key= event->detail.key; /* The state may change, so if we're not in the middle of sending a state * notify, prepare for it */ if ((xkbi->flags&_XkbStateNotifyInProgress)==0) { - oldState= xkbi->state; + xkbi->prev_state = xkbi->state; xkbi->flags|= _XkbStateNotifyInProgress; genStateNotify= True; } @@ -1164,10 +1100,8 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(dev); xkbi->groupChange = 0; sendEvent = 1; - keyEvent= ((xE->u.u.type==KeyPress)||(xE->u.u.type==DeviceKeyPress)|| - (xE->u.u.type==KeyRelease)||(xE->u.u.type==DeviceKeyRelease)); - pressEvent= (xE->u.u.type==KeyPress)||(xE->u.u.type==DeviceKeyPress)|| - (xE->u.u.type==ButtonPress)||(xE->u.u.type==DeviceButtonPress); + keyEvent= ((event->type == ET_KeyPress) || (event->type == ET_KeyRelease)); + pressEvent= ((event->type == ET_KeyPress)|| (event->type == ET_ButtonPress)); if (pressEvent) { if (keyEvent) @@ -1272,34 +1206,27 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(dev); if (sendEvent) { DeviceIntPtr tmpdev; - if (keyEvent) { - realMods = keyc->modifierMap[key]; - keyc->modifierMap[key] = 0; + if (keyEvent) tmpdev = dev; - } else + else tmpdev = GetPairedDevice(dev); UNWRAP_PROCESS_INPUT_PROC(tmpdev,xkbPrivPtr, backupproc); - dev->public.processInputProc(xE,tmpdev,count); + dev->public.processInputProc((InternalEvent*)event, tmpdev); COND_WRAP_PROCESS_INPUT_PROC(tmpdev, xkbPrivPtr, backupproc,xkbUnwrapProc); - if (keyEvent) - keyc->modifierMap[key] = realMods; } else if (keyEvent) { - FixKeyState(xE,dev); + FixKeyState(event, dev); } - xkbi->prev_state= oldState; XkbComputeDerivedState(xkbi); - keyc->prev_state= keyc->state; - keyc->state= XkbStateFieldFromRec(&xkbi->state); - changed = XkbStateChangedFlags(&oldState,&xkbi->state); + changed = XkbStateChangedFlags(&xkbi->prev_state,&xkbi->state); if (genStateNotify) { if (changed) { xkbStateNotify sn; sn.keycode= key; - sn.eventType= xE->u.u.type; + sn.eventType= event->type; sn.requestMajor = sn.requestMinor = 0; sn.changed= changed; XkbSendStateNotify(dev,&sn); @@ -1309,7 +1236,7 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(dev); changed= XkbIndicatorsToUpdate(dev,changed,False); if (changed) { XkbEventCauseRec cause; - XkbSetCauseKey(&cause,key,xE->u.u.type); + XkbSetCauseKey(&cause, key, event->type); XkbUpdateIndicators(dev,changed,False,NULL,&cause); } return; diff --git a/xorg-server/xkb/xkbEvents.c b/xorg-server/xkb/xkbEvents.c index 4d3debba7..8fb49c1d8 100644 --- a/xorg-server/xkb/xkbEvents.c +++ b/xorg-server/xkb/xkbEvents.c @@ -29,13 +29,14 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #endif #include <stdio.h> -#define NEED_EVENTS 1 #include <X11/X.h> #include <X11/Xproto.h> #include <X11/keysym.h> #include <X11/extensions/XI.h> #include <X11/extensions/XIproto.h> #include "inputstr.h" +#include "exevents.h" +#include "exglobals.h" #include "windowstr.h" #include "exevents.h" #include <xkbsrv.h> @@ -43,58 +44,151 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. /***====================================================================***/ +/* + * This function sends out two kinds of notification: + * - Core mapping notify events sent to clients for whom kbd is the + * current core ('picked') keyboard _and_ have not explicitly + * selected for XKB mapping notify events; + * - Xi mapping events, sent unconditionally to all clients who have + * explicitly selected for them (including those who have explicitly + * selected for XKB mapping notify events!). + */ +static void +XkbSendLegacyMapNotify(DeviceIntPtr kbd, CARD16 xkb_event, CARD16 changed, + int first_key, int num_keys) +{ + int i; + int keymap_changed = 0; + int modmap_changed = 0; + xEvent core_mn; + deviceMappingNotify xi_mn; + CARD32 time = GetTimeInMillis(); + + if (xkb_event == XkbNewKeyboardNotify) { + if (changed & XkbNKN_KeycodesMask) { + keymap_changed = 1; + modmap_changed = 1; + } + } + else if (xkb_event == XkbMapNotify) { + if (changed & XkbKeySymsMask) + keymap_changed = 1; + if (changed & XkbModifierMapMask) + modmap_changed = 1; + } + if (!keymap_changed && !modmap_changed) + return; + + core_mn.u.u.type = MappingNotify; + xi_mn.type = DeviceMappingNotify; + xi_mn.deviceid = kbd->id; + xi_mn.time = time; + + /* 0 is serverClient. */ + for (i = 1; i < currentMaxClients; i++) { + if (!clients[i] || clients[i]->clientState != ClientStateRunning) + continue; + + /* Ignore clients which will have already received this. + * Inconsistent with themselves, but consistent with previous + * behaviour.*/ + if (xkb_event == XkbMapNotify && (clients[i]->mapNotifyMask & changed)) + continue; + if (xkb_event == XkbNewKeyboardNotify && + (clients[i]->xkbClientFlags & _XkbClientInitialized)) + continue; + + /* Don't send core events to clients who don't know about us. */ + if (!XIShouldNotify(clients[i], kbd)) + continue; + + core_mn.u.u.sequenceNumber = clients[i]->sequence; + if (keymap_changed) { + core_mn.u.mappingNotify.request = MappingKeyboard; + + /* Clip the keycode range to what the client knows about, so it + * doesn't freak out. */ + if (first_key >= clients[i]->minKC) + core_mn.u.mappingNotify.firstKeyCode = first_key; + else + core_mn.u.mappingNotify.firstKeyCode = clients[i]->minKC; + if (first_key + num_keys - 1 <= clients[i]->maxKC) + core_mn.u.mappingNotify.count = num_keys; + else + core_mn.u.mappingNotify.count = clients[i]->maxKC - + clients[i]->minKC + 1; + + WriteEventsToClient(clients[i], 1, &core_mn); + } + if (modmap_changed) { + core_mn.u.mappingNotify.request = MappingModifier; + core_mn.u.mappingNotify.firstKeyCode = 0; + core_mn.u.mappingNotify.count = 0; + WriteEventsToClient(clients[i], 1, &core_mn); + } + } + + /* Hmm, maybe we can accidentally generate Xi events for core devices + * here? Clients might be upset, but that seems better than the + * alternative of stale keymaps. -ds */ + if (keymap_changed) { + xi_mn.request = MappingKeyboard; + xi_mn.firstKeyCode = first_key; + xi_mn.count = num_keys; + SendEventToAllWindows(kbd, DeviceMappingNotifyMask, (xEvent *) &xi_mn, + 1); + } + if (modmap_changed) { + xi_mn.request = MappingModifier; + xi_mn.firstKeyCode = 0; + xi_mn.count = 0; + SendEventToAllWindows(kbd, DeviceMappingNotifyMask, (xEvent *) &xi_mn, + 1); + } +} + +/***====================================================================***/ + void XkbSendNewKeyboardNotify(DeviceIntPtr kbd,xkbNewKeyboardNotify *pNKN) -{ -register int i; -Time time; -CARD16 changed; +{ + int i; + Time time = GetTimeInMillis(); + CARD16 changed = pNKN->changed; pNKN->type = XkbEventCode + XkbEventBase; pNKN->xkbType = XkbNewKeyboardNotify; - pNKN->time = time = GetTimeInMillis(); - changed = pNKN->changed; for (i=1; i<currentMaxClients; i++) { - if ((!clients[i]) || clients[i]->clientGone || - (clients[i]->requestVector==InitialVector)) { - continue; - } + if (!clients[i] || clients[i]->clientState != ClientStateRunning) + continue; + + if (!(clients[i]->newKeyboardNotifyMask & changed)) + continue; + + if (!XIShouldNotify(clients[i], kbd)) + continue; + + pNKN->sequenceNumber = clients[i]->sequence; + pNKN->time = time; + pNKN->changed = changed; + if (clients[i]->swapped) { + int n; + swaps(&pNKN->sequenceNumber,n); + swapl(&pNKN->time,n); + swaps(&pNKN->changed,n); + } + WriteToClient(clients[i], sizeof(xEvent), pNKN); - if (clients[i]->xkbClientFlags&_XkbClientInitialized) { - if (clients[i]->newKeyboardNotifyMask&changed) { - pNKN->sequenceNumber = clients[i]->sequence; - pNKN->time = time; - pNKN->changed = changed; - if ( clients[i]->swapped ) { - register int n; - swaps(&pNKN->sequenceNumber,n); - swapl(&pNKN->time,n); - swaps(&pNKN->changed,n); - } - WriteToClient(clients[i],sizeof(xEvent),(char *)pNKN); - if (changed&XkbNKN_KeycodesMask) { - clients[i]->minKC= pNKN->minKeyCode; - clients[i]->maxKC= pNKN->maxKeyCode; - } - } - } - else if (changed&XkbNKN_KeycodesMask) { - xEvent event; - event.u.u.type= MappingNotify; - event.u.mappingNotify.request= MappingKeyboard; - event.u.mappingNotify.firstKeyCode= clients[i]->minKC; - event.u.mappingNotify.count= clients[i]->maxKC-clients[i]->minKC+1; - event.u.u.sequenceNumber= clients[i]->sequence; - if (clients[i]->swapped) { - int n; - swaps(&event.u.u.sequenceNumber,n); - } - WriteToClient(clients[i],SIZEOF(xEvent), (char *)&event); - event.u.mappingNotify.request= MappingModifier; - WriteToClient(clients[i],SIZEOF(xEvent), (char *)&event); - } + if (changed & XkbNKN_KeycodesMask) { + clients[i]->minKC = pNKN->minKeyCode; + clients[i]->maxKC = pNKN->maxKeyCode; + } } + + XkbSendLegacyMapNotify(kbd, XkbNewKeyboardNotify, changed, pNKN->minKeyCode, + pNKN->maxKeyCode - pNKN->minKeyCode + 1); + return; } @@ -140,7 +234,8 @@ register CARD16 changed,bState; if ((!interest->client->clientGone) && (interest->client->requestVector != InitialVector) && (interest->client->xkbClientFlags&_XkbClientInitialized) && - (interest->stateNotifyMask&changed)) { + (interest->stateNotifyMask&changed) && + XIShouldNotify(interest->client,kbd)) { pSN->sequenceNumber = interest->client->sequence; pSN->time = time; pSN->changed = changed; @@ -161,49 +256,50 @@ register CARD16 changed,bState; /***====================================================================***/ +/* + * This function sends out XKB mapping notify events to clients which + * have explicitly selected for them. Core and Xi events are handled by + * XkbSendLegacyMapNotify. */ void -XkbSendMapNotify(DeviceIntPtr kbd,xkbMapNotify *pMN) +XkbSendMapNotify(DeviceIntPtr kbd, xkbMapNotify *pMN) { -int i; -XkbSrvInfoPtr xkbi; -unsigned time = 0,initialized; -CARD16 changed; - - if (!kbd->key || !kbd->key->xkbInfo) - return; - - xkbi = kbd->key->xkbInfo; - initialized= 0; - - changed = pMN->changed; - pMN->minKeyCode= xkbi->desc->min_key_code; - pMN->maxKeyCode= xkbi->desc->max_key_code; - for (i=1; i<currentMaxClients; i++) { - if (clients[i] && ! clients[i]->clientGone && - (clients[i]->requestVector != InitialVector) && - (clients[i]->xkbClientFlags&_XkbClientInitialized) && - (clients[i]->mapNotifyMask&changed)) - { - if (!initialized) { - pMN->type = XkbEventCode + XkbEventBase; - pMN->xkbType = XkbMapNotify; - pMN->deviceID = kbd->id; - time = GetTimeInMillis(); - initialized= 1; - } - pMN->time= time; - pMN->sequenceNumber = clients[i]->sequence; - pMN->changed = changed; - if ( clients[i]->swapped ) { - register int n; - swaps(&pMN->sequenceNumber,n); - swapl(&pMN->time,n); - swaps(&pMN->changed,n); - } - WriteToClient(clients[i],sizeof(xEvent),(char *)pMN); - } + int i; + CARD32 time = GetTimeInMillis(); + CARD16 changed = pMN->changed; + XkbSrvInfoPtr xkbi = kbd->key->xkbInfo; + + pMN->minKeyCode = xkbi->desc->min_key_code; + pMN->maxKeyCode = xkbi->desc->max_key_code; + pMN->type = XkbEventCode + XkbEventBase; + pMN->xkbType = XkbMapNotify; + pMN->deviceID = kbd->id; + + /* 0 is serverClient. */ + for (i = 1; i < currentMaxClients; i++) { + if (!clients[i] || clients[i]->clientState != ClientStateRunning) + continue; + + if (!(clients[i]->mapNotifyMask & changed)) + continue; + + if (!XIShouldNotify(clients[i], kbd)) + continue; + + pMN->time = time; + pMN->sequenceNumber = clients[i]->sequence; + pMN->changed = changed; + + if (clients[i]->swapped) { + int n; + swaps(&pMN->sequenceNumber, n); + swapl(&pMN->time, n); + swaps(&pMN->changed, n); + } + WriteToClient(clients[i], sizeof(xEvent), pMN); } - return; + + XkbSendLegacyMapNotify(kbd, XkbMapNotify, changed, pMN->firstKeySym, + pMN->nKeySyms); } int @@ -307,7 +403,8 @@ Time time = 0; if ((!interest->client->clientGone) && (interest->client->requestVector != InitialVector) && (interest->client->xkbClientFlags&_XkbClientInitialized) && - (interest->ctrlsNotifyMask&changedControls)) { + (interest->ctrlsNotifyMask&changedControls) && + XIShouldNotify(interest->client, kbd)) { if (!initialized) { pCN->type = XkbEventCode + XkbEventBase; pCN->xkbType = XkbControlsNotify; @@ -355,6 +452,7 @@ CARD32 state,changed; if ((!interest->client->clientGone) && (interest->client->requestVector != InitialVector) && (interest->client->xkbClientFlags&_XkbClientInitialized) && + XIShouldNotify(interest->client, kbd) && (((xkbType==XkbIndicatorStateNotify)&& (interest->iStateNotifyMask&changed))|| ((xkbType==XkbIndicatorMapNotify)&& @@ -438,7 +536,8 @@ XID winID = 0; if ((!interest->client->clientGone) && (interest->client->requestVector != InitialVector) && (interest->client->xkbClientFlags&_XkbClientInitialized) && - (interest->bellNotifyMask)) { + (interest->bellNotifyMask) && + XIShouldNotify(interest->client,kbd)) { if (!initialized) { time = GetTimeInMillis(); bn.type = XkbEventCode + XkbEventBase; @@ -492,7 +591,8 @@ CARD16 sk_delay,db_delay; if ((!interest->client->clientGone) && (interest->client->requestVector != InitialVector) && (interest->client->xkbClientFlags&_XkbClientInitialized) && - (interest->accessXNotifyMask&(1<<pEv->detail))) { + (interest->accessXNotifyMask&(1<<pEv->detail)) && + XIShouldNotify(interest->client, kbd)) { if (!initialized) { pEv->type = XkbEventCode + XkbEventBase; pEv->xkbType = XkbAccessXNotify; @@ -539,7 +639,8 @@ CARD32 changedIndicators; if ((!interest->client->clientGone) && (interest->client->requestVector != InitialVector) && (interest->client->xkbClientFlags&_XkbClientInitialized) && - (interest->namesNotifyMask&pEv->changed)) { + (interest->namesNotifyMask&pEv->changed) && + XIShouldNotify(interest->client, kbd)) { if (!initialized) { pEv->type = XkbEventCode + XkbEventBase; pEv->xkbType = XkbNamesNotify; @@ -584,7 +685,8 @@ CARD16 firstSI = 0, nSI = 0, nTotalSI = 0; if ((!interest->client->clientGone) && (interest->client->requestVector != InitialVector) && (interest->client->xkbClientFlags&_XkbClientInitialized) && - (interest->compatNotifyMask)) { + (interest->compatNotifyMask) && + XIShouldNotify(interest->client, kbd)) { if (!initialized) { pEv->type = XkbEventCode + XkbEventBase; pEv->xkbType = XkbCompatMapNotify; @@ -636,7 +738,8 @@ Time time = 0; if ((!interest->client->clientGone) && (interest->client->requestVector != InitialVector) && (interest->client->xkbClientFlags&_XkbClientInitialized) && - (interest->actionMessageMask)) { + (interest->actionMessageMask) && + XIShouldNotify(interest->client, kbd)) { if (!initialized) { pEv->type = XkbEventCode + XkbEventBase; pEv->xkbType = XkbActionMessage; @@ -668,7 +771,7 @@ int initialized; XkbInterestPtr interest; Time time = 0; CARD32 defined, state; -CARD16 reason, supported = 0; +CARD16 reason; interest = dev->xkb_interest; if (!interest) @@ -682,14 +785,14 @@ CARD16 reason, supported = 0; if ((!interest->client->clientGone) && (interest->client->requestVector != InitialVector) && (interest->client->xkbClientFlags&_XkbClientInitialized) && - (interest->extDevNotifyMask&reason)) { + (interest->extDevNotifyMask&reason) && + XIShouldNotify(interest->client, dev)) { if (!initialized) { pEv->type = XkbEventCode + XkbEventBase; pEv->xkbType = XkbExtensionDeviceNotify; pEv->deviceID = dev->id; pEv->sequenceNumber = interest->client->sequence; pEv->time = time = GetTimeInMillis(); - supported= pEv->supported; initialized= 1; } else { @@ -698,14 +801,7 @@ CARD16 reason, supported = 0; pEv->ledsDefined= defined; pEv->ledState= state; pEv->reason= reason; - pEv->supported= supported; - } - if (client!=interest->client) { - /* only report UnsupportedFeature to the client that */ - /* issued the failing request */ - pEv->reason&= ~XkbXI_UnsupportedFeatureMask; - if ((interest->extDevNotifyMask&reason)==0) - continue; + pEv->supported= XkbXI_AllFeaturesMask; } if ( interest->client->swapped ) { register int n; @@ -742,6 +838,7 @@ XkbSrvLedInfoPtr sli; } if (pChanges->map.changed) { xkbMapNotify mn; + memset(&mn, 0, sizeof(xkbMapNotify)); mn.changed= pChanges->map.changed; mn.firstType= pChanges->map.first_type; mn.nTypes= pChanges->map.num_types; @@ -763,6 +860,7 @@ XkbSrvLedInfoPtr sli; if ((pChanges->ctrls.changed_ctrls)|| (pChanges->ctrls.enabled_ctrls_changes)) { xkbControlsNotify cn; + memset(&cn, 0, sizeof(xkbControlsNotify)); cn.changedControls= pChanges->ctrls.changed_ctrls; cn.enabledControlChanges= pChanges->ctrls.enabled_ctrls_changes; cn.keycode= cause->kc; @@ -775,6 +873,7 @@ XkbSrvLedInfoPtr sli; xkbIndicatorNotify in; if (sli==NULL) sli= XkbFindSrvLedInfo(kbd,XkbDfltXIClass,XkbDfltXIId,0); + memset(&in, 0, sizeof(xkbIndicatorNotify)); in.state= sli->effectiveState; in.changed= pChanges->indicators.map_changes; XkbSendIndicatorNotify(kbd,XkbIndicatorMapNotify,&in); @@ -783,12 +882,14 @@ XkbSrvLedInfoPtr sli; xkbIndicatorNotify in; if (sli==NULL) sli= XkbFindSrvLedInfo(kbd,XkbDfltXIClass,XkbDfltXIId,0); + memset(&in, 0, sizeof(xkbIndicatorNotify)); in.state= sli->effectiveState; in.changed= pChanges->indicators.state_changes; XkbSendIndicatorNotify(kbd,XkbIndicatorStateNotify,&in); } if (pChanges->names.changed) { xkbNamesNotify nn; + memset(&nn, 0, sizeof(xkbNamesNotify)); nn.changed= pChanges->names.changed; nn.firstType= pChanges->names.first_type; nn.nTypes= pChanges->names.num_types; @@ -801,6 +902,7 @@ XkbSrvLedInfoPtr sli; } if ((pChanges->compat.changed_groups)||(pChanges->compat.num_si>0)) { xkbCompatMapNotify cmn; + memset(&cmn, 0, sizeof(xkbCompatMapNotify)); cmn.changedGroups= pChanges->compat.changed_groups; cmn.firstSI= pChanges->compat.first_si; cmn.nSI= pChanges->compat.num_si; @@ -812,151 +914,104 @@ XkbSrvLedInfoPtr sli; /***====================================================================***/ -Bool -XkbFilterEvents(ClientPtr pClient,int nEvents,xEvent *xE) +void +XkbFilterEvents(ClientPtr client,int nEvents,xEvent *xE) { -int i, button_mask; -DeviceIntPtr pXDev = inputInfo.keyboard; -XkbSrvInfoPtr xkbi; + DeviceIntPtr dev = NULL; + XkbSrvInfoPtr xkbi; + CARD8 type = xE[0].u.u.type; if (xE->u.u.type & EXTENSION_EVENT_BASE) - { - pXDev = XIGetDevice(xE); - if (!pXDev) - pXDev = inputInfo.keyboard; - } + dev = XIGetDevice(xE); - xkbi= (pXDev->key) ? pXDev->key->xkbInfo : NULL; + if (!dev) + dev = PickKeyboard(client); - if ( pClient->xkbClientFlags & _XkbClientInitialized ) { - if ((xkbDebugFlags&0x10)&& - ((xE[0].u.u.type==KeyPress)||(xE[0].u.u.type==KeyRelease)|| - (xE[0].u.u.type==DeviceKeyPress)|| - (xE[0].u.u.type == DeviceKeyRelease))) { - DebugF("[xkb] XKbFilterWriteEvents:\n"); - DebugF("[xkb] Event state= 0x%04x\n",xE[0].u.keyButtonPointer.state); - DebugF("[xkb] XkbLastRepeatEvent!=xE (0x%p!=0x%p) %s\n", - XkbLastRepeatEvent,xE, - ((XkbLastRepeatEvent!=(pointer)xE)?"True":"False")); - DebugF("[xkb] (xkbClientEventsFlags&XWDA)==0 (0x%x) %s\n", - pClient->xkbClientFlags, - (_XkbWantsDetectableAutoRepeat(pClient)?"True":"False")); - DebugF("[xkb] !IsRelease(%d) %s\n",xE[0].u.u.type, - (!_XkbIsReleaseEvent(xE[0].u.u.type))?"True":"False"); - } - if ( (XkbLastRepeatEvent==(pointer)xE) && - (_XkbWantsDetectableAutoRepeat(pClient)) && - (_XkbIsReleaseEvent(xE[0].u.u.type)) ) { - return False; - } - - if (!xkbi) - return True; + if (!dev->key) + return; - if ((pXDev->deviceGrab.grab != NullGrab) - && pXDev->deviceGrab.fromPassiveGrab && - ((xE[0].u.u.type==KeyPress)||(xE[0].u.u.type==KeyRelease)|| - (xE[0].u.u.type==DeviceKeyPress)|| - (xE[0].u.u.type == DeviceKeyRelease))) { - register unsigned state,flags; + xkbi = dev->key->xkbInfo; - flags= pClient->xkbClientFlags; - state= xkbi->state.compat_grab_mods; + if (client->xkbClientFlags & _XkbClientInitialized) { + if ((xkbDebugFlags&0x10)&& + (type == KeyPress || type == KeyRelease || + type == DeviceKeyPress || type == DeviceKeyRelease)) + DebugF("[xkb] XkbFilterWriteEvents (XKB client): state 0x%04x\n", + xE[0].u.keyButtonPointer.state); + + if (dev->deviceGrab.grab != NullGrab && dev->deviceGrab.fromPassiveGrab && + (type == KeyPress || type == KeyRelease || + type == DeviceKeyPress || type == DeviceKeyRelease)) { + unsigned int state, flags; + + flags = client->xkbClientFlags; + state = xkbi->state.compat_grab_mods; if (flags & XkbPCF_GrabsUseXKBStateMask) { int group; - if (flags&XkbPCF_LookupStateWhenGrabbed) { - group= xkbi->state.group; - state= xkbi->state.lookup_mods; + if (flags & XkbPCF_LookupStateWhenGrabbed) { + group = xkbi->state.group; + state = xkbi->state.lookup_mods; } else { - state= xkbi->state.grab_mods; - group= xkbi->state.base_group+xkbi->state.latched_group; - if ((group<0)||(group>=xkbi->desc->ctrls->num_groups)) { - group= XkbAdjustGroup(group,xkbi->desc->ctrls); - } + state = xkbi->state.grab_mods; + group = xkbi->state.base_group + xkbi->state.latched_group; + if (group < 0 || group >= xkbi->desc->ctrls->num_groups) + group = XkbAdjustGroup(group, xkbi->desc->ctrls); } state = XkbBuildCoreState(state, group); } - else if (flags&XkbPCF_LookupStateWhenGrabbed) - state= xkbi->state.compat_lookup_mods; - xE[0].u.keyButtonPointer.state= state; + else if (flags & XkbPCF_LookupStateWhenGrabbed) { + state = xkbi->state.compat_lookup_mods; + } + xE[0].u.keyButtonPointer.state = state; } - button_mask = 1 << xE[0].u.u.detail; - if (xE[0].u.u.type == ButtonPress && - ((xE[0].u.keyButtonPointer.state >> 7) & button_mask) == button_mask && - (xkbi->lockedPtrButtons & button_mask) == button_mask) { - /* If the MouseKeys is pressed, and the "real" mouse is also pressed - * when the mouse is released, the server does not behave properly. - * Faking a release of the button here solves the problem. - */ - DebugF("[xkb] Faking release of button %d\n", xE[0].u.u.detail); - XkbDDXFakeDeviceButton(xkbi->device, 0, xE[0].u.u.detail); - } } else { - register CARD8 type; - - if (!xkbi) - return True; - - for (i=0;i<nEvents;i++) { - type= xE[i].u.u.type; - if ((xkbDebugFlags&0x4)&& - ((xE[i].u.u.type==KeyPress)||(xE[i].u.u.type==KeyRelease)|| - (xE[i].u.u.type==DeviceKeyPress)|| - (xE[i].u.u.type == DeviceKeyRelease))) { - DebugF("[xkb] XKbFilterWriteEvents (non-XKB):\n"); - DebugF("[xkb] event= 0x%04x\n",xE[i].u.keyButtonPointer.state); - DebugF("[xkb] lookup= 0x%02x, grab= 0x%02x\n",xkbi->state.lookup_mods, - xkbi->state.grab_mods); - DebugF("[xkb] compat lookup= 0x%02x, grab= 0x%02x\n", - xkbi->state.compat_lookup_mods, - xkbi->state.compat_grab_mods); - } - if ( (type>=KeyPress)&&(type<=MotionNotify) ) { - CARD16 old,new; + if ((xkbDebugFlags & 0x4) && + (xE[0].u.u.type == KeyPress || xE[0].u.u.type==KeyRelease || + xE[0].u.u.type == DeviceKeyPress || + xE[0].u.u.type == DeviceKeyRelease)) { + DebugF("[xkb] XKbFilterWriteEvents (non-XKB):\n"); + DebugF("[xkb] event= 0x%04x\n",xE[0].u.keyButtonPointer.state); + DebugF("[xkb] lookup= 0x%02x, grab= 0x%02x\n", + xkbi->state.lookup_mods, xkbi->state.grab_mods); + DebugF("[xkb] compat lookup= 0x%02x, grab= 0x%02x\n", + xkbi->state.compat_lookup_mods, xkbi->state.compat_grab_mods); + } + if (type >= KeyPress && type <= MotionNotify) { + CARD16 old, new; - old= xE[i].u.keyButtonPointer.state&(~0x1f00); - new= xE[i].u.keyButtonPointer.state&0x1F00; + old = xE[0].u.keyButtonPointer.state & ~0x1f00; + new = xE[0].u.keyButtonPointer.state & 0x1F00; - if (old==XkbStateFieldFromRec(&xkbi->state)) - new|= xkbi->state.compat_lookup_mods; - else new|= xkbi->state.compat_grab_mods; - xE[i].u.keyButtonPointer.state= new; - } - else if ((type==EnterNotify)||(type==LeaveNotify)) { - xE[i].u.enterLeave.state&= 0x1F00; - xE[i].u.enterLeave.state|= xkbi->state.compat_grab_mods; - } else if ((type>=DeviceKeyPress)&&(type<=DeviceMotionNotify)) { - CARD16 old, new; - deviceKeyButtonPointer *kbp = (deviceKeyButtonPointer*)&xE[i]; - old= kbp->state&(~0x1F00); - new= kbp->state&0x1F00; - if (old==XkbStateFieldFromRec(&xkbi->state)) - new|= xkbi->state.compat_lookup_mods; - else new|= xkbi->state.compat_grab_mods; - kbp->state= new; - } - button_mask = 1 << xE[i].u.u.detail; - if (type == ButtonPress && - ((xE[i].u.keyButtonPointer.state >> 7) & button_mask) == button_mask && - (xkbi->lockedPtrButtons & button_mask) == button_mask) { - DebugF("[xkb] Faking release of button %d\n", xE[i].u.u.detail); - XkbDDXFakeDeviceButton(xkbi->device, 0, xE[i].u.u.detail); - } else if (type == DeviceButtonPress && - ((((deviceKeyButtonPointer*)&xE[i])->state >> 7) & button_mask) == button_mask && - (xkbi->lockedPtrButtons & button_mask) == button_mask) { - DebugF("[xkb] Faking release of button %d\n", ((deviceKeyButtonPointer*)&xE[i])->state); - XkbDDXFakeDeviceButton(xkbi->device, 0, ((deviceKeyButtonPointer*)&xE[i])->state); - } + if (old == XkbStateFieldFromRec(&xkbi->state)) + new |= xkbi->state.compat_lookup_mods; + else + new |= xkbi->state.compat_grab_mods; + xE[0].u.keyButtonPointer.state = new; } + else if (type == EnterNotify || type == LeaveNotify) { + xE[0].u.enterLeave.state &= 0x1F00; + xE[0].u.enterLeave.state |= xkbi->state.compat_grab_mods; + } + else if (type >= DeviceKeyPress && type <= DeviceMotionNotify) { + CARD16 old, new; + deviceKeyButtonPointer *kbp = (deviceKeyButtonPointer*) &xE[0]; + + old = kbp->state & ~0x1F00; + new = kbp->state & 0x1F00; + if (old == XkbStateFieldFromRec(&xkbi->state)) + new |= xkbi->state.compat_lookup_mods; + else + new |= xkbi->state.compat_grab_mods; + kbp->state = new; + } } - return True; } /***====================================================================***/ -XkbInterestPtr +XkbInterestPtr XkbFindClientResource(DevicePtr inDev,ClientPtr client) { DeviceIntPtr dev = (DeviceIntPtr)inDev; @@ -974,7 +1029,7 @@ XkbInterestPtr interest; return NULL; } -XkbInterestPtr +XkbInterestPtr XkbAddClientResource(DevicePtr inDev,ClientPtr client,XID id) { DeviceIntPtr dev = (DeviceIntPtr)inDev; @@ -1031,7 +1086,7 @@ ClientPtr client = NULL; autoCtrls= interest->autoCtrls; autoValues= interest->autoCtrlValues; client= interest->client; - _XkbFree(interest); + xfree(interest); found= True; } while ((!found)&&(interest->next)) { @@ -1041,7 +1096,7 @@ ClientPtr client = NULL; autoCtrls= victim->autoCtrls; autoValues= victim->autoCtrlValues; client= victim->client; - _XkbFree(victim); + xfree(victim); found= True; } interest = interest->next; diff --git a/xorg-server/xkb/xkbInit.c b/xorg-server/xkb/xkbInit.c index 3a0e375e8..747c913f3 100644 --- a/xorg-server/xkb/xkbInit.c +++ b/xorg-server/xkb/xkbInit.c @@ -37,7 +37,6 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include <ctype.h> #include <unistd.h> #include <math.h> -#define NEED_EVENTS 1 #include <X11/X.h> #include <X11/Xproto.h> #include <X11/keysym.h> @@ -86,30 +85,6 @@ typedef struct _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 @@ -118,37 +93,65 @@ char * XkbBaseDirectory= XKB_BASE_DIRECTORY; char * XkbBinDirectory= XKB_BIN_DIRECTORY; static int XkbWantAccessX= 0; -static Bool rulesDefined= False; -static char * XkbRulesFile= NULL; +static char * XkbRulesDflt= NULL; static char * XkbModelDflt= NULL; static char * XkbLayoutDflt= NULL; static char * XkbVariantDflt= NULL; static char * XkbOptionsDflt= NULL; +static char * XkbRulesUsed= NULL; static char * XkbModelUsed= NULL; static char * XkbLayoutUsed= NULL; static char * XkbVariantUsed= NULL; static char * XkbOptionsUsed= NULL; -static XkbDescPtr xkb_cached_map = NULL; +static XkbDescPtr xkb_cached_map = NULL; -_X_EXPORT Bool noXkbExtension= XKB_DFLT_DISABLED; static Bool XkbWantRulesProp= XKB_DFLT_RULES_PROP; /***====================================================================***/ -static char * -XkbGetRulesDflts(XkbRF_VarDefsPtr defs) +/** + * Get the current default XKB rules. + * Caller must free the data in rmlvo. + */ +void +XkbGetRulesDflts(XkbRMLVOSet *rmlvo) { - 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); + if (XkbRulesDflt) rmlvo->rules = XkbRulesDflt; + else rmlvo->rules = XKB_DFLT_RULES; + if (XkbModelDflt) rmlvo->model= XkbModelDflt; + else rmlvo->model= XKB_DFLT_MODEL; + if (XkbLayoutDflt) rmlvo->layout= XkbLayoutDflt; + else rmlvo->layout= XKB_DFLT_LAYOUT; + if (XkbVariantDflt) rmlvo->variant= XkbVariantDflt; + else rmlvo->variant= XKB_DFLT_VARIANT; + if (XkbOptionsDflt) rmlvo->options= XkbOptionsDflt; + else rmlvo->options= XKB_DFLT_OPTIONS; + + rmlvo->rules = strdup(rmlvo->rules); + rmlvo->model = strdup(rmlvo->model); + rmlvo->layout = strdup(rmlvo->layout); + rmlvo->variant = strdup(rmlvo->variant); + rmlvo->options = strdup(rmlvo->options); +} + +void +XkbFreeRMLVOSet(XkbRMLVOSet *rmlvo, Bool freeRMLVO) +{ + if (!rmlvo) + return; + + xfree(rmlvo->rules); + xfree(rmlvo->model); + xfree(rmlvo->layout); + xfree(rmlvo->variant); + xfree(rmlvo->options); + + if (freeRMLVO) + xfree(rmlvo); + else + memset(rmlvo, 0, sizeof(XkbRMLVOSet)); } static Bool @@ -158,9 +161,7 @@ int len,out; Atom name; char * pval; - if (rulesDefined && (!XkbRulesFile)) - return False; - len= (XkbRulesFile?strlen(XkbRulesFile):strlen(XKB_DFLT_RULES_FILE)); + len= (XkbRulesUsed?strlen(XkbRulesUsed):0); len+= (XkbModelUsed?strlen(XkbModelUsed):0); len+= (XkbLayoutUsed?strlen(XkbLayoutUsed):0); len+= (XkbVariantUsed?strlen(XkbVariantUsed):0); @@ -182,12 +183,9 @@ char * pval; 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); + if (XkbRulesUsed) { + strcpy(&pval[out],XkbRulesUsed); + out+= strlen(XkbRulesUsed); } pval[out++]= '\0'; if (XkbModelUsed) { @@ -221,93 +219,93 @@ char * pval; } static void -XkbSetRulesUsed(XkbRF_VarDefsPtr defs) +XkbSetRulesUsed(XkbRMLVOSet *rmlvo) { + if (XkbRulesUsed) + xfree(XkbRulesUsed); + XkbRulesUsed= (rmlvo->rules?_XkbDupString(rmlvo->rules):NULL); if (XkbModelUsed) - _XkbFree(XkbModelUsed); - XkbModelUsed= (defs->model?_XkbDupString(defs->model):NULL); + xfree(XkbModelUsed); + XkbModelUsed= (rmlvo->model?_XkbDupString(rmlvo->model):NULL); if (XkbLayoutUsed) - _XkbFree(XkbLayoutUsed); - XkbLayoutUsed= (defs->layout?_XkbDupString(defs->layout):NULL); + xfree(XkbLayoutUsed); + XkbLayoutUsed= (rmlvo->layout?_XkbDupString(rmlvo->layout):NULL); if (XkbVariantUsed) - _XkbFree(XkbVariantUsed); - XkbVariantUsed= (defs->variant?_XkbDupString(defs->variant):NULL); + xfree(XkbVariantUsed); + XkbVariantUsed= (rmlvo->variant?_XkbDupString(rmlvo->variant):NULL); if (XkbOptionsUsed) - _XkbFree(XkbOptionsUsed); - XkbOptionsUsed= (defs->options?_XkbDupString(defs->options):NULL); + xfree(XkbOptionsUsed); + XkbOptionsUsed= (rmlvo->options?_XkbDupString(rmlvo->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. - */ -_X_EXPORT void -XkbSetRulesDflts(char *rulesFile,char *model,char *layout, - char *variant,char *options) +void +XkbSetRulesDflts(XkbRMLVOSet *rmlvo) { - 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 (rmlvo->rules) { + if (XkbRulesDflt) + xfree(XkbRulesDflt); + XkbRulesDflt= _XkbDupString(rmlvo->rules); } - - if (rulesFile) { - if (XkbRulesFile) - _XkbFree(XkbRulesFile); - XkbRulesFile= _XkbDupString(rulesFile); - rulesDefined= True; - } - - if (model) { + if (rmlvo->model) { if (XkbModelDflt) - _XkbFree(XkbModelDflt); - XkbModelDflt= _XkbDupString(model); + xfree(XkbModelDflt); + XkbModelDflt= _XkbDupString(rmlvo->model); } - if (layout) { + if (rmlvo->layout) { if (XkbLayoutDflt) - _XkbFree(XkbLayoutDflt); - XkbLayoutDflt= _XkbDupString(layout); + xfree(XkbLayoutDflt); + XkbLayoutDflt= _XkbDupString(rmlvo->layout); } - if (variant) { + if (rmlvo->variant) { if (XkbVariantDflt) - _XkbFree(XkbVariantDflt); - XkbVariantDflt= _XkbDupString(variant); + xfree(XkbVariantDflt); + XkbVariantDflt= _XkbDupString(rmlvo->variant); } - if (options) { + if (rmlvo->options) { if (XkbOptionsDflt) - _XkbFree(XkbOptionsDflt); - XkbOptionsDflt= _XkbDupString(options); + xfree(XkbOptionsDflt); + XkbOptionsDflt= _XkbDupString(rmlvo->options); } return; } void -XkbDeleteRulesDflts() +XkbDeleteRulesDflts(void) { - _XkbFree(XkbRulesFile); - XkbRulesFile = NULL; - _XkbFree(XkbModelDflt); + xfree(XkbRulesDflt); + XkbRulesDflt = NULL; + xfree(XkbModelDflt); XkbModelDflt = NULL; - _XkbFree(XkbLayoutDflt); + xfree(XkbLayoutDflt); XkbLayoutDflt = NULL; - _XkbFree(XkbVariantDflt); + xfree(XkbVariantDflt); XkbVariantDflt = NULL; - _XkbFree(XkbOptionsDflt); + xfree(XkbOptionsDflt); XkbOptionsDflt = NULL; XkbFreeKeyboard(xkb_cached_map, XkbAllComponentsMask, True); xkb_cached_map = NULL; } +#define DIFFERS(a, b) (strcmp((a) ? (a) : "", (b) ? (b) : "") != 0) + +static Bool +XkbCompareUsedRMLVO(XkbRMLVOSet *rmlvo) +{ + if (DIFFERS(rmlvo->rules, XkbRulesUsed) || + DIFFERS(rmlvo->model, XkbModelUsed) || + DIFFERS(rmlvo->layout, XkbLayoutUsed) || + DIFFERS(rmlvo->variant, XkbVariantUsed) || + DIFFERS(rmlvo->options, XkbOptionsUsed)) + return FALSE; + return TRUE; +} + +#undef DIFFERS + /***====================================================================***/ #include "xkbDflts.h" @@ -493,292 +491,151 @@ XkbControlsPtr ctrls; return Success; } -void -XkbInitDevice(DeviceIntPtr pXDev) +_X_EXPORT Bool +InitKeyboardDeviceStruct(DeviceIntPtr dev, XkbRMLVOSet *rmlvo, + BellProcPtr bell_func, KbdCtrlProcPtr ctrl_func) { -int i; -XkbSrvInfoPtr xkbi; -XkbChangesRec changes; -unsigned check; -XkbEventCauseRec cause; - - bzero(&changes,sizeof(XkbChangesRec)); - pXDev->key->xkbInfo= xkbi= _XkbTypedCalloc(1,XkbSrvInfoRec); - if ( xkbi ) { - XkbDescPtr xkb; + int i; + unsigned int check; + XkbSrvInfoPtr xkbi; + XkbDescPtr xkb; + XkbSrvLedInfoPtr sli; + XkbChangesRec changes; + XkbEventCauseRec cause; + XkbRMLVOSet rmlvo_dflts = { NULL }; + + if (dev->key || dev->kbdfeed) + return FALSE; + + if (!rmlvo) + { + rmlvo = &rmlvo_dflts; + XkbGetRulesDflts(rmlvo); + } - if (xkb_cached_map) { - xkbi->desc = xkb_cached_map; - xkb_cached_map = 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; + + memset(&changes, 0, sizeof(changes)); + XkbSetCauseUnknown(&cause); + + dev->key = xcalloc(1, sizeof(*dev->key)); + if (!dev->key) { + ErrorF("XKB: Failed to allocate key class\n"); + return False; + } + dev->key->sourceid = dev->id; + + dev->kbdfeed = xcalloc(1, sizeof(*dev->kbdfeed)); + if (!dev->kbdfeed) { + ErrorF("XKB: Failed to allocate key feedback class\n"); + goto unwind_key; + } + + xkbi = xcalloc(1, sizeof(*xkbi)); + if (!xkbi) { + ErrorF("XKB: Failed to allocate XKB info\n"); + goto unwind_kbdfeed; + } + dev->key->xkbInfo = xkbi; + + if (xkb_cached_map && !XkbCompareUsedRMLVO(rmlvo)) { + XkbFreeKeyboard(xkb_cached_map, XkbAllComponentsMask, True); + xkb_cached_map = NULL; + } + + if (xkb_cached_map) + LogMessageVerb(X_INFO, 4, "XKB: Reusing cached keymap\n"); + else { + xkb_cached_map = XkbCompileKeymap(dev, rmlvo); + if (!xkb_cached_map) { + ErrorF("XKB: Failed to compile keymap\n"); + goto unwind_info; } - 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("[xkb] 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; - - XkbInitSemantics(xkb); - XkbInitNames(xkbi); - XkbInitRadioGroups(xkbi); - - /* 12/31/94 (ef) -- XXX! Should check if state loaded from file */ - bzero(&xkbi->state,sizeof(XkbStateRec)); - - XkbInitControls(pXDev,xkbi); - - if (xkb->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); - - XkbDDXInitDevice(pXDev); - - if (xkb->defined & XkmSymbolsMask) - XkbUpdateCoreDescription(pXDev, True); - else - XkbUpdateKeyTypesFromCore(pXDev, xkb->min_key_code, - XkbNumKeys(xkb), &changes); - - 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; } - return; -} -#if MAP_LENGTH > XkbMaxKeyCount -#undef XkbMaxKeyCount -#define XkbMaxKeyCount MAP_LENGTH -#endif + xkb = XkbAllocKeyboard(); + if (!xkb) { + ErrorF("XKB: Failed to allocate keyboard description\n"); + goto unwind_info; + } -_X_EXPORT Bool -XkbInitKeyboardDeviceStruct( - DeviceIntPtr dev, - XkbComponentNamesPtr names, - KeySymsPtr pSymsIn, - CARD8 pModsIn[], - void (*bellProc)( - int /*percent*/, - DeviceIntPtr /*device*/, - pointer /*ctrl*/, - int), - void (*ctrlProc)( - DeviceIntPtr /*device*/, - KeybdCtrl * /*ctrl*/)) -{ -KeySymsRec tmpSyms,*pSyms; -CARD8 tmpMods[XkbMaxLegalKeyCode+1],*pMods; -char name[PATH_MAX],*rules; -Bool ok=False; -XkbRF_VarDefsRec defs; -XkbDescPtr xkb; - - 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. - */ - names->keymap = NULL; - if (names->keycodes) names->keycodes = _XkbDupString(names->keycodes); - if (names->types) names->types = _XkbDupString(names->types); - if (names->compat) names->compat = _XkbDupString(names->compat); - if (names->geometry) names->geometry = _XkbDupString(names->geometry); - if (names->symbols) names->symbols = _XkbDupString(names->symbols); - - if (defs.model && defs.layout && rules) { - XkbComponentNamesRec rNames; - bzero(&rNames,sizeof(XkbComponentNamesRec)); - if (XkbDDXNamesFromRules(dev,rules,&defs,&rNames)) { - 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 (!XkbCopyKeymap(xkb, xkb_cached_map)) { + ErrorF("XKB: Failed to copy keymap\n"); + goto unwind_desc; } + xkb->defined = xkb_cached_map->defined; + xkb->flags = xkb_cached_map->flags; + xkb->device_spec = xkb_cached_map->device_spec; + xkbi->desc = xkb; - ok = (Bool) XkbDDXLoadKeymapByNames(dev,names,XkmAllIndicesMask,0, - &xkb,name,PATH_MAX); + if (xkb->min_key_code == 0) + xkb->min_key_code = 8; + if (xkb->max_key_code == 0) + xkb->max_key_code = 255; - if (ok && (xkb!=NULL)) { - KeyCode minKC,maxKC; + i = XkbNumKeys(xkb) / 3 + 1; + if (XkbAllocClientMap(xkb, XkbAllClientInfoMask, 0) != Success) + goto unwind_desc; + if (XkbAllocServerMap(xkb, XkbAllServerInfoMask, i) != Success) + goto unwind_desc; - 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; + xkbi->dfltPtrDelta = 1; + xkbi->device = dev; - tmpSyms.minKeyCode= minKC; - tmpSyms.maxKeyCode= maxKC; + XkbInitSemantics(xkb); + XkbInitNames(xkbi); + XkbInitRadioGroups(xkbi); - if (minKC<pSymsIn->minKeyCode) - minKC= pSymsIn->minKeyCode; - if (maxKC>pSymsIn->maxKeyCode) - maxKC= pSymsIn->maxKeyCode; + XkbInitControls(dev, xkbi); - 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; - } - } - /* Store the map here so we can pick it back up in XkbInitDevice. - * Sigh. */ - xkb_cached_map = xkb; - } - else { - LogMessage(X_WARNING, "Couldn't load XKB keymap, falling back to pre-XKB keymap\n"); - } - ok= InitKeyboardDeviceStruct((DevicePtr)dev,pSyms,pMods,bellProc,ctrlProc); - xkb_cached_map = NULL; - if ((pSyms==&tmpSyms)&&(pSyms->map!=NULL)) { - _XkbFree(pSyms->map); - pSyms->map= 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; -} + XkbInitIndicatorMap(xkbi); -/***====================================================================***/ + XkbUpdateActions(dev, xkb->min_key_code, XkbNumKeys(xkb), &changes, + &check, &cause); - /* - * 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; + InitFocusClassDeviceStruct(dev); - xkbi = NULL; - if (pXDev && pXDev->key && pXDev->key->xkbInfo && pXDev->kbdfeed) { - xkbi= pXDev->key->xkbInfo; - xkb= xkbi->desc; - /* If we come from DeepCopyDeviceClasses, the CtrlProc was already set - * to XkbDDXKeybdCtrlProc, overwriting it leads to happy recursion. - */ - if (pXDev->kbdfeed && pXDev->kbdfeed->CtrlProc != XkbDDXKeybdCtrlProc) { - 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("[xkb] No indicator feedback in XkbFinishInit (shouldn't happen)!\n"); - return softRepeat; + xkbi->kbdProc = ctrl_func; + dev->kbdfeed->BellProc = bell_func; + dev->kbdfeed->CtrlProc = XkbDDXKeybdCtrlProc; + + dev->kbdfeed->ctrl = defaultKeyboardControl; + if (dev->kbdfeed->ctrl.autoRepeat) + xkb->ctrls->enabled_ctrls |= XkbRepeatKeysMask; + + memcpy(dev->kbdfeed->ctrl.autoRepeats, xkb->ctrls->per_key_repeat, + XkbPerKeyBitArraySize); + + sli = XkbFindSrvLedInfo(dev, XkbDfltXIClass, XkbDfltXIId, 0); + if (sli) + XkbCheckIndicatorMaps(dev, sli, XkbAllIndicatorsMask); + else + DebugF("XKB: No indicator feedback in XkbFinishInit!\n"); + + dev->kbdfeed->CtrlProc(dev,&dev->kbdfeed->ctrl); + + XkbSetRulesDflts(rmlvo); + XkbSetRulesUsed(rmlvo); + XkbFreeRMLVOSet(&rmlvo_dflts, FALSE); + + return TRUE; + +unwind_desc: + XkbFreeKeyboard(xkb, 0, TRUE); +unwind_info: + xfree(xkbi); + dev->key->xkbInfo = NULL; +unwind_kbdfeed: + xfree(dev->kbdfeed); + dev->kbdfeed = NULL; +unwind_key: + xfree(dev->key); + dev->key = NULL; + return FALSE; } + +/***====================================================================***/ + /* * Be very careful about what does and doesn't get freed by this * function. To reduce fragmentation, XkbInitDevice allocates a @@ -790,7 +647,7 @@ void XkbFreeInfo(XkbSrvInfoPtr xkbi) { if (xkbi->radioGroups) { - _XkbFree(xkbi->radioGroups); + xfree(xkbi->radioGroups); xkbi->radioGroups= NULL; } if (xkbi->mouseKeyTimer) { @@ -822,7 +679,7 @@ XkbFreeInfo(XkbSrvInfoPtr xkbi) XkbFreeKeyboard(xkbi->desc,XkbAllComponentsMask,True); xkbi->desc= NULL; } - _XkbFree(xkbi); + xfree(xkbi); return; } @@ -839,15 +696,7 @@ 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 (strncmp(argv[i], "-xkbdir", 7) == 0) { if(++i < argc) { #if !defined(WIN32) && !defined(__CYGWIN__) if (getuid() != geteuid()) { @@ -925,8 +774,6 @@ XkbProcessArguments(int argc,char *argv[],int i) 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"); diff --git a/xorg-server/xkb/xkbLEDs.c b/xorg-server/xkb/xkbLEDs.c index edc389f04..59cdba416 100644 --- a/xorg-server/xkb/xkbLEDs.c +++ b/xorg-server/xkb/xkbLEDs.c @@ -31,7 +31,6 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include <stdio.h> #include <ctype.h> #include <math.h> -#define NEED_EVENTS 1 #include <X11/X.h> #include <X11/Xproto.h> #include "misc.h" @@ -284,7 +283,7 @@ unsigned oldState; ed->ledID= sli->id; ed->ledsDefined= sli->namesPresent|sli->mapsPresent; ed->ledState= sli->effectiveState; - ed->unsupported|= XkbXI_IndicatorStateMask; + ed->unsupported= 0; ed->supported= XkbXI_AllFeaturesMask; if (changes!=&my_changes) changes= NULL; @@ -606,12 +605,12 @@ void XkbFreeSrvLedInfo(XkbSrvLedInfoPtr sli) { if ((sli->flags&XkbSLI_IsDefault)==0) { - if (sli->maps) _XkbFree(sli->maps); - if (sli->names) _XkbFree(sli->names); + if (sli->maps) xfree(sli->maps); + if (sli->names) xfree(sli->names); } sli->maps= NULL; sli->names= NULL; - _XkbFree(sli); + xfree(sli); return; } @@ -644,7 +643,7 @@ XkbCopySrvLedInfo( DeviceIntPtr from, else sli_new->fb.lf = lf; - if (sli_new->flags & XkbSLI_IsDefault) { + if (!(sli_new->flags & XkbSLI_IsDefault)) { sli_new->names= _XkbTypedCalloc(XkbNumIndicators,Atom); sli_new->maps= _XkbTypedCalloc(XkbNumIndicators,XkbIndicatorMapRec); } /* else sli_new->names/maps is pointing to @@ -668,7 +667,7 @@ finish: * */ -XkbSrvLedInfoPtr +XkbSrvLedInfoPtr XkbFindSrvLedInfo( DeviceIntPtr dev, unsigned class, unsigned id, @@ -876,7 +875,7 @@ xkbExtensionDeviceNotify my_ed; ed->ledID= sli->id; ed->ledsDefined= sli->namesPresent|sli->mapsPresent; ed->ledState= sli->effectiveState; - ed->unsupported|= XkbXI_IndicatorMapsMask; + ed->unsupported= 0; ed->supported= XkbXI_AllFeaturesMask; XkbUpdateLedAutoState(dev,sli,changed_maps,ed,changes,cause); @@ -957,7 +956,7 @@ Bool kb_changed; ed->ledID= sli->id; ed->ledsDefined= sli->namesPresent|sli->mapsPresent; ed->ledState= sli->effectiveState; - ed->unsupported|= XkbXI_IndicatorStateMask; + ed->unsupported= 0; ed->supported= XkbXI_AllFeaturesMask; } diff --git a/xorg-server/xkb/xkbPrKeyEv.c b/xorg-server/xkb/xkbPrKeyEv.c index a3f715c7d..8f6705f9f 100644 --- a/xorg-server/xkb/xkbPrKeyEv.c +++ b/xorg-server/xkb/xkbPrKeyEv.c @@ -30,132 +30,85 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include <stdio.h> #include <math.h> -#define NEED_EVENTS 1 #include <X11/X.h> #include <X11/Xproto.h> #include <X11/keysym.h> #include "misc.h" #include "inputstr.h" #include "exevents.h" +#include "eventstr.h" #include <xkbsrv.h> #include <ctype.h> +#include "events.h" /***====================================================================***/ void -XkbProcessKeyboardEvent(xEvent *xE,DeviceIntPtr keybd,int count) +XkbProcessKeyboardEvent(DeviceEvent *event, DeviceIntPtr keybd) { KeyClassPtr keyc = keybd->key; XkbSrvInfoPtr xkbi; int key; XkbBehavior behavior; unsigned ndx; -int xiEvent; - xkbi= keyc->xkbInfo; - key= xE->u.u.detail; - xiEvent= (xE->u.u.type & EXTENSION_EVENT_BASE); - if (xkbDebugFlags&0x8) { - DebugF("[xkb] XkbPKE: Key %d %s\n",key,(xE->u.u.type==KeyPress?"down":"up")); - } + xkbi = keyc->xkbInfo; + key = event->detail.key; + if (xkbDebugFlags & 0x8) + DebugF("[xkb] XkbPKE: Key %d %s\n",key,(event->type == ET_KeyPress?"down":"up")); - if ( (xkbi->repeatKey==key) && (xE->u.u.type==KeyRelease) && - ((xkbi->desc->ctrls->enabled_ctrls&XkbRepeatKeysMask)==0) ) { - AccessXCancelRepeatKey(xkbi,key); - } + if (xkbi->repeatKey == key && event->type== ET_KeyRelease && + !(xkbi->desc->ctrls->enabled_ctrls & XkbRepeatKeysMask)) + AccessXCancelRepeatKey(xkbi, key); - behavior= xkbi->desc->server->behaviors[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) { + if (!(behavior.type & XkbKB_Permanent)) { switch (behavior.type) { case XkbKB_Default: - if (( xE->u.u.type == KeyPress || - xE->u.u.type == DeviceKeyPress) && - (keyc->down[key>>3] & (1<<(key&7)))) { - XkbLastRepeatEvent= (pointer)xE; - - if (xiEvent) - xE->u.u.type = DeviceKeyRelease; - else - xE->u.u.type = KeyRelease; - XkbHandleActions(keybd,keybd,xE,count); - - if (xiEvent) - xE->u.u.type = DeviceKeyPress; - else - xE->u.u.type = KeyPress; - XkbHandleActions(keybd,keybd,xE,count); - XkbLastRepeatEvent= NULL; - return; - } - else if ((xE->u.u.type==KeyRelease || - xE->u.u.type == DeviceKeyRelease) && - (!(keyc->down[key>>3]&(1<<(key&7))))) { - XkbLastRepeatEvent= (pointer)&xE; - if (xiEvent) - xE->u.u.type = DeviceKeyPress; - else - xE->u.u.type = KeyPress; - XkbHandleActions(keybd,keybd,xE,count); - if (xiEvent) - xE->u.u.type = DeviceKeyRelease; - else - xE->u.u.type = KeyRelease; - XkbHandleActions(keybd,keybd,xE,count); - XkbLastRepeatEvent= NULL; - return; - } + /* Neither of these should happen in practice, but ignore them + anyway. */ + if (event->type == ET_KeyPress && !event->key_repeat && + key_is_down(keybd, key, KEY_PROCESSED)) + return; + else if (event->type == ET_KeyRelease && + !key_is_down(keybd, key, KEY_PROCESSED)) + return; break; case XkbKB_Lock: - if ( xE->u.u.type == KeyRelease || - xE->u.u.type == DeviceKeyRelease) { + if (event->type == ET_KeyRelease) return; - } - else { - int bit= 1<<(key&7); - if ( keyc->down[key>>3]&bit ) { - if (xiEvent) - xE->u.u.type = DeviceKeyRelease; - else - xE->u.u.type= KeyRelease; - } - } + else if (key_is_down(keybd, key, KEY_PROCESSED)) + event->type = ET_KeyRelease; break; case XkbKB_RadioGroup: ndx= (behavior.data&(~XkbKB_RGAllowNone)); if ( ndx<xkbi->nRadioGroups ) { XkbRadioGroupPtr rg; - if ( xE->u.u.type == KeyRelease || - xE->u.u.type == DeviceKeyRelease) + if (event->type == ET_KeyRelease) return; rg = &xkbi->radioGroups[ndx]; - if ( rg->currentDown == xE->u.u.detail ) { + if ( rg->currentDown == event->detail.key) { if (behavior.data&XkbKB_RGAllowNone) { - xE->u.u.type = KeyRelease; - XkbHandleActions(keybd,keybd,xE,count); + event->type = ET_KeyRelease; + XkbHandleActions(keybd, keybd, event); rg->currentDown= 0; } return; } if ( rg->currentDown!=0 ) { - int key = xE->u.u.detail; - if (xiEvent) - xE->u.u.type = DeviceKeyRelease; - else - xE->u.u.type= KeyRelease; - xE->u.u.detail= rg->currentDown; - XkbHandleActions(keybd,keybd,xE,count); - if (xiEvent) - xE->u.u.type = DeviceKeyPress; - else - xE->u.u.type= KeyPress; - xE->u.u.detail= key; + int key = event->detail.key; + event->type = ET_KeyRelease; + event->detail.key = rg->currentDown; + XkbHandleActions(keybd, keybd, event); + event->type = ET_KeyPress; + event->detail.key = key; } rg->currentDown= key; } @@ -170,7 +123,7 @@ int xiEvent; break; if ((behavior.data>=xkbi->desc->min_key_code)&& (behavior.data<=xkbi->desc->max_key_code)) { - xE->u.u.detail= behavior.data; + event->detail.key = behavior.data; /* 9/11/94 (ef) -- XXX! need to match release with */ /* press even if the state of the */ /* corresponding overlay control */ @@ -183,34 +136,33 @@ int xiEvent; break; } } - XkbHandleActions(keybd,keybd,xE,count); + XkbHandleActions(keybd, keybd, event); return; } void -ProcessKeyboardEvent(xEvent *xE,DeviceIntPtr keybd,int count) +ProcessKeyboardEvent(InternalEvent *ev, DeviceIntPtr keybd) { KeyClassPtr keyc = keybd->key; XkbSrvInfoPtr xkbi = NULL; ProcessInputProc backup_proc; xkbDeviceInfoPtr xkb_priv = XKBDEVICEINFO(keybd); - int is_press = (xE->u.u.type == KeyPress || xE->u.u.type == DeviceKeyPress); - int is_release = (xE->u.u.type == KeyRelease || - xE->u.u.type == DeviceKeyRelease); - - if (keyc) - xkbi = keyc->xkbInfo; + DeviceEvent *event = (DeviceEvent*)ev; + int is_press = (event->type == ET_KeyPress); + int is_release = (event->type == ET_KeyRelease); /* We're only interested in key events. */ if (!is_press && !is_release) { UNWRAP_PROCESS_INPUT_PROC(keybd, xkb_priv, backup_proc); - keybd->public.processInputProc(xE, keybd, count); + keybd->public.processInputProc(ev, keybd); COND_WRAP_PROCESS_INPUT_PROC(keybd, xkb_priv, backup_proc, xkbUnwrapProc); return; } + xkbi = keyc->xkbInfo; + /* If AccessX filters are active, then pass it through to * AccessXFilter{Press,Release}Event; else, punt to * XkbProcessKeyboardEvent. @@ -219,13 +171,14 @@ ProcessKeyboardEvent(xEvent *xE,DeviceIntPtr keybd,int count) * they'll punt through XPKE anyway. */ if ((xkbi->desc->ctrls->enabled_ctrls & XkbAllFilteredEventsMask)) { if (is_press) - AccessXFilterPressEvent(xE, keybd, count); + AccessXFilterPressEvent(event, keybd); else if (is_release) - AccessXFilterReleaseEvent(xE, keybd, count); - - } else { - XkbProcessKeyboardEvent(xE, keybd, count); + AccessXFilterReleaseEvent(event, keybd); + return; + } + else { + XkbProcessKeyboardEvent(event, keybd); } - + return; } diff --git a/xorg-server/xkb/xkbSwap.c b/xorg-server/xkb/xkbSwap.c index 1a513b35c..ffd66b563 100644 --- a/xorg-server/xkb/xkbSwap.c +++ b/xorg-server/xkb/xkbSwap.c @@ -30,8 +30,6 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "stdio.h" #include <X11/X.h> -#define NEED_EVENTS -#define NEED_REPLIES #include <X11/Xproto.h> #include "misc.h" #include "inputstr.h" diff --git a/xorg-server/xkb/xkbUtils.c b/xorg-server/xkb/xkbUtils.c index 71b0f6661..63b1e31c7 100644 --- a/xorg-server/xkb/xkbUtils.c +++ b/xorg-server/xkb/xkbUtils.c @@ -56,21 +56,19 @@ DEALINGS IN THE SOFTWARE. #include <stdio.h> #include <ctype.h> #include <math.h> -#define NEED_EVENTS 1 #include <X11/X.h> #include <X11/Xproto.h> #define XK_CYRILLIC #include <X11/keysym.h> #include "misc.h" #include "inputstr.h" +#include "eventstr.h" #define XKBSRV_NEED_FILE_FUNCS #include <xkbsrv.h> #include "xkbgeom.h" #include "xkb.h" -int XkbDisableLockActions = 0; - /***====================================================================***/ int @@ -216,13 +214,13 @@ register unsigned mask; void XkbUpdateKeyTypesFromCore( DeviceIntPtr pXDev, + KeySymsPtr pCore, KeyCode first, CARD8 num, XkbChangesPtr changes) { XkbDescPtr xkb; unsigned key,nG,explicit; -KeySymsPtr pCore; int types[XkbNumKbdGroups]; KeySym tsyms[XkbMaxSymsPerKey],*syms; XkbMapChangesPtr mc; @@ -235,8 +233,7 @@ XkbMapChangesPtr mc; mc= (changes?(&changes->map):NULL); - pCore= &pXDev->key->curKeySyms; - syms= &pCore->map[(first-xkb->min_key_code)*pCore->mapWidth]; + syms= &pCore->map[(first - pCore->minKeyCode) * pCore->mapWidth]; for (key=first; key<(first+num); key++,syms+= pCore->mapWidth) { explicit= xkb->server->explicit[key]&XkbExplicitKeyTypesMask; types[XkbGroup1Index]= XkbKeyKeyTypeIndex(xkb,key,XkbGroup1Index); @@ -358,59 +355,24 @@ CARD8 * repeat; return; } -void -XkbUpdateCoreDescription(DeviceIntPtr keybd,Bool resize) +KeySymsPtr +XkbGetCoreMap(DeviceIntPtr keybd) { register int key,tmp; -int maxSymsPerKey,maxKeysPerMod; -int first,last,firstCommon,lastCommon; +int maxSymsPerKey, maxGroup1Width; XkbDescPtr xkb; -KeyClassPtr keyc; -CARD8 keysPerMod[XkbNumModifiers]; +KeySymsPtr syms; +int maxNumberOfGroups; if (!keybd || !keybd->key || !keybd->key->xkbInfo) - return; + return NULL; + 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; - } - } + maxSymsPerKey= maxGroup1Width= 0; + maxNumberOfGroups = 0; /* determine sizes */ - for (key=first;key<=last;key++) { + for (key=xkb->min_key_code;key<=xkb->max_key_code;key++) { if (XkbKeycodeInRange(xkb,key)) { int nGroups; int w; @@ -420,6 +382,9 @@ CARD8 keysPerMod[XkbNumModifiers]; if ((w=XkbKeyGroupWidth(xkb,key,XkbGroup1Index))<=2) tmp+= 2; else tmp+= w + 2; + /* remember highest G1 width */ + if (w > maxGroup1Width) + maxGroup1Width = w; } if (nGroups>1) { if (tmp <= 2) { @@ -437,141 +402,113 @@ CARD8 keysPerMod[XkbNumModifiers]; tmp+= XkbKeyGroupWidth(xkb,key,XkbGroup4Index); if (tmp>maxSymsPerKey) maxSymsPerKey= tmp; + if (nGroups > maxNumberOfGroups) + maxNumberOfGroups = nGroups; } - 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"); + if (maxSymsPerKey <= 0) + return NULL; + + syms = xcalloc(1, sizeof(*syms)); + if (!syms) + return NULL; + + /* See Section 12.4 of the XKB Protocol spec. Because of the + * single-group distribution for multi-group keyboards, we have to + * have enough symbols for the largest group 1 to replicate across the + * number of groups on the keyboard. e.g. a single-group key with 4 + * symbols on a keyboard that has 3 groups -> 12 syms per key */ + if (maxSymsPerKey < maxNumberOfGroups * maxGroup1Width) + maxSymsPerKey = maxNumberOfGroups * maxGroup1Width; + + syms->mapWidth = maxSymsPerKey; + syms->minKeyCode = xkb->min_key_code; + syms->maxKeyCode = xkb->max_key_code; + + tmp = syms->mapWidth * (xkb->max_key_code - xkb->min_key_code + 1); + syms->map = xcalloc(tmp, sizeof(*syms->map)); + if (!syms->map) { + xfree(syms); + return NULL; } - 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; - } + for (key=xkb->min_key_code;key<=xkb->max_key_code;key++) { + KeySym *pCore,*pXKB; + unsigned nGroups,groupWidth,n,nOut; + + nGroups= XkbKeyNumGroups(xkb,key); + n= (key-xkb->min_key_code)*syms->mapWidth; + pCore= &syms->map[n]; + 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; + } - /* See XKB Protocol Sec, Section 12.4. - A 1-group key with ABCDE on a 2 group keyboard must be - duplicated across all groups as ABABCDECDE. - */ - if (nGroups == 1) + /* See XKB Protocol Sec, Section 12.4. + A 1-group key with ABCDE on a 2 group keyboard must be + duplicated across all groups as ABABCDECDE. + */ + if (nGroups == 1) + { + int idx, j; + + groupWidth = XkbKeyGroupWidth(xkb, key, XkbGroup1Index); + + /* AB..CDE... -> ABABCDE... */ + if (groupWidth > 0 && syms->mapWidth >= 3) + pCore[2] = pCore[0]; + if (groupWidth > 1 && syms->mapWidth >= 4) + pCore[3] = pCore[1]; + + /* ABABCDE... -> ABABCDECDE */ + idx = 2 + groupWidth; + while (groupWidth > 2 && idx < syms->mapWidth && + idx < groupWidth * 2) { - int idx; - - groupWidth = XkbKeyGroupWidth(xkb, key, XkbGroup1Index); - - /* AB..CDE... -> ABABCDE... */ - if (groupWidth > 0 && maxSymsPerKey >= 3) - pCore[2] = pCore[0]; - if (groupWidth > 1 && maxSymsPerKey >= 4) - pCore[3] = pCore[1]; - - /* ABABCDE... -> ABABCDECDE */ - idx = 2 + groupWidth; - while (groupWidth > 2 && - idx < maxSymsPerKey && - idx < groupWidth * 2) - { - pCore[idx] = pCore[idx - groupWidth + 2]; - idx++; - } - idx = 2 * groupWidth; - if (idx < 4) - idx = 4; - /* 3 or more groups: ABABCDECDEABCDEABCDE */ + pCore[idx] = pCore[idx - groupWidth + 2]; + idx++; + } + idx = 2 * groupWidth; + if (idx < 4) + idx = 4; + /* 3 or more groups: ABABCDECDEABCDEABCDE */ + for (j = 3; j <= maxNumberOfGroups; j++) for (n = 0; n < groupWidth && idx < maxSymsPerKey; n++) pCore[idx++] = pXKB[n]; - } + } - 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); + 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); } - 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]++; - } + 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); } } - return; + + return syms; } void @@ -598,46 +535,50 @@ XkbSetRepeatKeys(DeviceIntPtr pXDev,int key,int onoff) return; } +/* Applies a change to a single device, does not traverse the device tree. */ void -XkbApplyMappingChange( DeviceIntPtr kbd, - CARD8 request, - KeyCode firstKey, - CARD8 num, - ClientPtr client) +XkbApplyMappingChange(DeviceIntPtr kbd, KeySymsPtr map, KeyCode first_key, + CARD8 num_keys, CARD8 *modmap, 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; + XkbDescPtr xkb = kbd->key->xkbInfo->desc; + XkbEventCauseRec cause; + XkbChangesRec changes; + unsigned int check; + + memset(&changes, 0, sizeof(changes)); + memset(&cause, 0, sizeof(cause)); - XkbSetCauseCoreReq(&cause,X_SetModifierMapping,client); + if (map && first_key && num_keys) { + check = 0; + XkbSetCauseCoreReq(&cause, X_ChangeKeyboardMapping, client); - num = xkb->max_key_code-xkb->min_key_code+1; - memcpy(xkb->map->modmap,kbd->key->modifierMap,xkb->max_key_code+1); + XkbUpdateKeyTypesFromCore(kbd, map, first_key, num_keys, &changes); + XkbUpdateActions(kbd, first_key, num_keys, &changes, &check, &cause); - 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); + if (check) + XkbCheckSecondaryEffects(kbd->key->xkbInfo, 1, &changes, &cause); } - /* 3/26/94 (ef) -- XXX! Doesn't deal with input extension requests */ - XkbSendNotification(kbd,&changes,&cause); - return; + + if (modmap) { + /* A keymap change can imply a modmap change, se we prefer the + * former. */ + if (!cause.mjr) + XkbSetCauseCoreReq(&cause,X_SetModifierMapping,client); + + check = 0; + num_keys = xkb->max_key_code - xkb->min_key_code + 1; + changes.map.changed |= XkbModifierMapMask; + changes.map.first_modmap_key = xkb->min_key_code; + changes.map.num_modmap_keys = num_keys; + memcpy(kbd->key->xkbInfo->desc->map->modmap, modmap, MAP_LENGTH); + XkbUpdateActions(kbd, xkb->min_key_code, num_keys, &changes, &check, + &cause); + + if (check) + XkbCheckSecondaryEffects(kbd->key->xkbInfo, 1, &changes, &cause); + } + + XkbSendNotification(kbd, &changes, &cause); } void @@ -751,8 +692,7 @@ unsigned char grp; if (!state || !ctrls) return; - state->mods= (state->base_mods|state->latched_mods); - state->mods|= state->locked_mods; + state->mods= (state->base_mods|state->latched_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|= @@ -842,7 +782,7 @@ XkbSrvLedInfoPtr sli; #define MAX_TOC 16 -XkbGeometryPtr +XkbGeometryPtr XkbLookupNamedGeometry(DeviceIntPtr dev,Atom name,Bool *shouldFree) { XkbSrvInfoPtr xkbi= dev->key->xkbInfo; @@ -2103,97 +2043,44 @@ _XkbCopyControls(XkbDescPtr src, XkbDescPtr dst) */ Bool -XkbCopyKeymap(XkbDescPtr src, XkbDescPtr dst, Bool sendNotifies) +XkbCopyKeymap(XkbDescPtr dst, XkbDescPtr src) { - DeviceIntPtr pDev = NULL, tmpDev = NULL; - xkbMapNotify mn; - xkbNewKeyboardNotify nkn; - if (!src || !dst || src == dst) + if (!src || !dst) { + DebugF("XkbCopyKeymap: src (%p) or dst (%p) is NULL\n", src, dst); return FALSE; + } - if (!_XkbCopyClientMap(src, dst)) - return FALSE; - if (!_XkbCopyServerMap(src, dst)) - return FALSE; - if (!_XkbCopyIndicators(src, dst)) + if (src == dst) + return TRUE; + + if (!_XkbCopyClientMap(src, dst)) { + DebugF("XkbCopyKeymap: failed to copy client map\n"); return FALSE; - if (!_XkbCopyControls(src, dst)) + } + if (!_XkbCopyServerMap(src, dst)) { + DebugF("XkbCopyKeymap: failed to copy server map\n"); return FALSE; - if (!_XkbCopyNames(src, dst)) + } + if (!_XkbCopyIndicators(src, dst)) { + DebugF("XkbCopyKeymap: failed to copy indicators\n"); return FALSE; - if (!_XkbCopyCompat(src, dst)) + } + if (!_XkbCopyControls(src, dst)) { + DebugF("XkbCopyKeymap: failed to copy controls\n"); return FALSE; - if (!_XkbCopyGeom(src, dst)) + } + if (!_XkbCopyNames(src, dst)) { + DebugF("XkbCopyKeymap: failed to copy names\n"); return FALSE; - - if (inputInfo.keyboard->key->xkbInfo && - inputInfo.keyboard->key->xkbInfo->desc == dst) { - pDev = inputInfo.keyboard; } - else { - for (tmpDev = inputInfo.devices; tmpDev && !pDev; - tmpDev = tmpDev->next) { - if (tmpDev->key && tmpDev->key->xkbInfo && - tmpDev->key->xkbInfo->desc == dst) { - pDev = tmpDev; - break; - } - } - for (tmpDev = inputInfo.off_devices; tmpDev && !pDev; - tmpDev = tmpDev->next) { - if (tmpDev->key && tmpDev->key->xkbInfo && - tmpDev->key->xkbInfo->desc == dst) { - pDev = tmpDev; - break; - } - } + if (!_XkbCopyCompat(src, dst)) { + DebugF("XkbCopyKeymap: failed to copy compat map\n"); + return FALSE; } - - if (sendNotifies) { - if (!pDev) { - ErrorF("[xkb] XkbCopyKeymap: asked for notifies, but can't find device!\n"); - } - else { - /* send NewKeyboardNotify if the keycode range changed, else - * just MapNotify. we also need to send NKN if the geometry - * changed (obviously ...). */ - if ((src->min_key_code != dst->min_key_code || - src->max_key_code != dst->max_key_code)) { - nkn.oldMinKeyCode = dst->min_key_code; - nkn.oldMaxKeyCode = dst->max_key_code; - nkn.deviceID = nkn.oldDeviceID = pDev->id; - nkn.minKeyCode = src->min_key_code; - nkn.maxKeyCode = src->max_key_code; - nkn.requestMajor = XkbReqCode; - nkn.requestMinor = X_kbSetMap; /* XXX bare-faced lie */ - nkn.changed = XkbAllNewKeyboardEventsMask; - XkbSendNewKeyboardNotify(pDev, &nkn); - } else - { - mn.deviceID = pDev->id; - mn.minKeyCode = src->min_key_code; - mn.maxKeyCode = src->max_key_code; - mn.firstType = 0; - mn.nTypes = src->map->num_types; - mn.firstKeySym = src->min_key_code; - mn.nKeySyms = XkbNumKeys(src); - mn.firstKeyAct = src->min_key_code; - mn.nKeyActs = XkbNumKeys(src); - /* Cargo-culted from ProcXkbGetMap. */ - mn.firstKeyBehavior = src->min_key_code; - mn.nKeyBehaviors = XkbNumKeys(src); - mn.firstKeyExplicit = src->min_key_code; - mn.nKeyExplicit = XkbNumKeys(src); - mn.firstModMapKey = src->min_key_code; - mn.nModMapKeys = XkbNumKeys(src); - mn.firstVModMapKey = src->min_key_code; - mn.nVModMapKeys = XkbNumKeys(src); - mn.virtualMods = ~0; /* ??? */ - mn.changed = XkbAllMapComponentsMask; - XkbSendMapNotify(pDev, &mn); - } - } + if (!_XkbCopyGeom(src, dst)) { + DebugF("XkbCopyKeymap: failed to copy geometry\n"); + return FALSE; } dst->min_key_code = src->min_key_code; @@ -2201,3 +2088,33 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr dst, Bool sendNotifies) return TRUE; } + +Bool +XkbCopyDeviceKeymap(DeviceIntPtr dst, DeviceIntPtr src) +{ + xkbNewKeyboardNotify nkn; + Bool ret; + + if (!dst->key || !src->key) + return FALSE; + + memset(&nkn, 0, sizeof(xkbNewKeyboardNotify)); + nkn.oldMinKeyCode = dst->key->xkbInfo->desc->min_key_code; + nkn.oldMaxKeyCode = dst->key->xkbInfo->desc->max_key_code; + nkn.deviceID = dst->id; + nkn.oldDeviceID = dst->id; /* maybe src->id? */ + nkn.minKeyCode = src->key->xkbInfo->desc->min_key_code; + nkn.maxKeyCode = src->key->xkbInfo->desc->max_key_code; + nkn.requestMajor = XkbReqCode; + nkn.requestMinor = X_kbSetMap; /* Near enough's good enough. */ + nkn.changed = XkbNKN_KeycodesMask; + if (src->key->xkbInfo->desc->geom) + nkn.changed |= XkbNKN_GeometryMask; + + ret = XkbCopyKeymap(dst->key->xkbInfo->desc, src->key->xkbInfo->desc); + if (ret) + XkbSendNewKeyboardNotify(dst, &nkn); + + return ret; +} + diff --git a/xorg-server/xkb/xkbfmisc.c b/xorg-server/xkb/xkbfmisc.c index ae752e945..52ef6362c 100644 --- a/xorg-server/xkb/xkbfmisc.c +++ b/xorg-server/xkb/xkbfmisc.c @@ -34,9 +34,9 @@ #include <X11/Xos.h> #include <X11/Xfuncs.h> +#include <X11/extensions/XKMformat.h> #include <X11/X.h> -#define NEED_EVENTS #include <X11/keysym.h> #include <X11/Xproto.h> #include "misc.h" @@ -164,14 +164,13 @@ XkbWriteXKBKeymapForNames( FILE * file, unsigned want, unsigned need) { -char * name,*tmp; +const char * tmp; unsigned complete; XkbNamesPtr old_names; int multi_section; unsigned wantNames,wantConfig,wantDflts; 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; @@ -293,15 +292,15 @@ unsigned wantNames,wantConfig,wantDflts; multi_section= 1; if (((complete&XkmKeymapRequired)==XkmKeymapRequired)&& ((complete&(~XkmKeymapLegal))==0)) { - fprintf(file,"xkb_keymap \"%s\" {\n",name); + fprintf(file,"xkb_keymap \"default\" {\n"); } else if (((complete&XkmSemanticsRequired)==XkmSemanticsRequired)&& ((complete&(~XkmSemanticsLegal))==0)) { - fprintf(file,"xkb_semantics \"%s\" {\n",name); + fprintf(file,"xkb_semantics \"default\" {\n"); } else if (((complete&XkmLayoutRequired)==XkmLayoutRequired)&& ((complete&(~XkmLayoutLegal))==0)) { - fprintf(file,"xkb_layout \"%s\" {\n",name); + fprintf(file,"xkb_layout \"default\" {\n"); } else if (XkmSingleSection(complete&(~XkmVirtualModsMask))) { multi_section= 0; @@ -311,41 +310,36 @@ unsigned wantNames,wantConfig,wantDflts; } wantNames= complete&(~(wantConfig|wantDflts)); - name= names->keycodes; if (wantConfig&XkmKeyNamesMask) - XkbWriteXKBKeycodes(file,xkb,False,False,_AddIncl,name); + XkbWriteXKBKeycodes(file,xkb,False,False,_AddIncl,names->keycodes); else if (wantDflts&XkmKeyNamesMask) fprintf(stderr,"Default symbols not implemented yet!\n"); else if (wantNames&XkmKeyNamesMask) - XkbWriteSectionFromName(file,"keycodes",name); + XkbWriteSectionFromName(file,"keycodes",names->keycodes); - name= names->types; if (wantConfig&XkmTypesMask) - XkbWriteXKBKeyTypes(file,xkb,False,False,_AddIncl,name); + XkbWriteXKBKeyTypes(file,xkb,False,False,_AddIncl,names->types); else if (wantDflts&XkmTypesMask) fprintf(stderr,"Default types not implemented yet!\n"); else if (wantNames&XkmTypesMask) - XkbWriteSectionFromName(file,"types",name); + XkbWriteSectionFromName(file,"types",names->types); - name= names->compat; if (wantConfig&XkmCompatMapMask) - XkbWriteXKBCompatMap(file,xkb,False,False,_AddIncl,name); + XkbWriteXKBCompatMap(file,xkb,False,False,_AddIncl,names->compat); else if (wantDflts&XkmCompatMapMask) fprintf(stderr,"Default interps not implemented yet!\n"); else if (wantNames&XkmCompatMapMask) - XkbWriteSectionFromName(file,"compatibility",name); + XkbWriteSectionFromName(file,"compatibility",names->compat); - name= names->symbols; if (wantConfig&XkmSymbolsMask) - XkbWriteXKBSymbols(file,xkb,False,False,_AddIncl,name); + XkbWriteXKBSymbols(file,xkb,False,False,_AddIncl,names->symbols); else if (wantNames&XkmSymbolsMask) - XkbWriteSectionFromName(file,"symbols",name); + XkbWriteSectionFromName(file,"symbols",names->symbols); - name= names->geometry; if (wantConfig&XkmGeometryMask) - XkbWriteXKBGeometry(file,xkb,False,False,_AddIncl,name); + XkbWriteXKBGeometry(file,xkb,False,False,_AddIncl,names->geometry); else if (wantNames&XkmGeometryMask) - XkbWriteSectionFromName(file,"geometry",name); + XkbWriteSectionFromName(file,"geometry",names->geometry); if (multi_section) fprintf(file,"};\n"); @@ -413,29 +407,6 @@ unsigned rtrn; return rtrn; } -/* 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)=='/')) diff --git a/xorg-server/xkb/xkbgeom.h b/xorg-server/xkb/xkbgeom.h index 173affee9..fe4da3806 100644 --- a/xorg-server/xkb/xkbgeom.h +++ b/xorg-server/xkb/xkbgeom.h @@ -311,8 +311,6 @@ typedef struct _XkbGeometrySizes { unsigned short num_key_aliases; } XkbGeometrySizesRec,*XkbGeometrySizesPtr; -_XFUNCPROTOBEGIN - extern XkbPropertyPtr XkbAddGeomProperty( XkbGeometryPtr /* geom */, @@ -630,6 +628,4 @@ XkbFindOverlayForKey( char * /* under */ ); -_XFUNCPROTOEND - #endif /* _XKBGEOM_H_ */ diff --git a/xorg-server/xkb/xkbout.c b/xorg-server/xkb/xkbout.c index 229cc9258..b1c30d052 100644 --- a/xorg-server/xkb/xkbout.c +++ b/xorg-server/xkb/xkbout.c @@ -34,9 +34,9 @@ #include <X11/Xfuncs.h> #include <X11/X.h> -#define NEED_EVENTS #include <X11/keysym.h> #include <X11/Xproto.h> +#include <X11/extensions/XKMformat.h> #include "misc.h" #include "inputstr.h" #include "dix.h" diff --git a/xorg-server/xkb/xkbtext.c b/xorg-server/xkb/xkbtext.c index d08c91589..95ad01378 100644 --- a/xorg-server/xkb/xkbtext.c +++ b/xorg-server/xkb/xkbtext.c @@ -35,8 +35,8 @@ #include <X11/Xos.h> #include <X11/X.h> -#define NEED_EVENTS #include <X11/Xproto.h> +#include <X11/extensions/XKMformat.h> #include "misc.h" #include "inputstr.h" #include "dix.h" @@ -71,16 +71,17 @@ char *rtrn; char * XkbAtomText(Atom atm,unsigned format) { +const char *atmstr; char *rtrn,*tmp; - tmp= XkbAtomGetString(atm); - if (tmp!=NULL) { + atmstr = XkbAtomGetString(atm); + if (atmstr != NULL) { int len; - len= strlen(tmp)+1; + len= strlen(atmstr)+1; if (len>BUFFER_SIZE) len= BUFFER_SIZE-2; rtrn= tbGetBuffer(len); - strncpy(rtrn,tmp,len); + strncpy(rtrn,atmstr,len); rtrn[len]= '\0'; } else { @@ -105,7 +106,8 @@ XkbVModIndexText(XkbDescPtr xkb,unsigned ndx,unsigned format) { register int len; register Atom *vmodNames; -char *rtrn,*tmp; +char *rtrn; +const char *tmp; char numBuf[20]; if (xkb && xkb->names) @@ -117,8 +119,10 @@ char numBuf[20]; tmp= "illegal"; else if (vmodNames&&(vmodNames[ndx]!=None)) tmp= XkbAtomGetString(vmodNames[ndx]); - if (tmp==NULL) - sprintf(tmp=numBuf,"%d",ndx); + if (tmp==NULL) { + sprintf(numBuf,"%d",ndx); + tmp = numBuf; + } len= strlen(tmp)+1; if (format==XkbCFile) diff --git a/xorg-server/xkb/xkmread.c b/xorg-server/xkb/xkmread.c index b14a5beda..6623d1bf0 100644 --- a/xorg-server/xkb/xkmread.c +++ b/xorg-server/xkb/xkmread.c @@ -34,9 +34,9 @@ #include <X11/Xfuncs.h> #include <X11/X.h> -#define NEED_EVENTS #include <X11/Xproto.h> #include <X11/keysym.h> +#include <X11/extensions/XKMformat.h> #include "misc.h" #include "inputstr.h" #include "xkbstr.h" @@ -52,13 +52,13 @@ XkbInternAtom(char *str,Bool only_if_exists) } char * -_XkbDupString(char *str) +_XkbDupString(const char *str) { char *new; if (str==NULL) return NULL; - new= (char *)_XkbCalloc(strlen(str)+1,sizeof(char)); + new= xcalloc(strlen(str)+1,sizeof(char)); if (new) strcpy(new,str); return new; @@ -74,10 +74,10 @@ int newCount= *newCountRtrn; if (oldPtr==NULL) { if (newCount==0) return NULL; - oldPtr= _XkbCalloc(newCount,elemSize); + oldPtr= xcalloc(newCount,elemSize); } else if (oldCount<newCount) { - oldPtr= _XkbRealloc(oldPtr,newCount*elemSize); + oldPtr= xrealloc(oldPtr,newCount*elemSize); if (oldPtr!=NULL) { char *tmp= (char *)oldPtr; bzero(&tmp[oldCount*elemSize],(newCount-oldCount)*elemSize); @@ -418,6 +418,7 @@ xkmSymInterpretDesc wire; unsigned tmp; int nRead=0; XkbCompatMapPtr compat; +XkbAction *act; if ((tmp= XkmGetCountedString(file,name,100))<1) { _XkbLibError(_XkbErrBadLength,"ReadXkmCompatMap",0); @@ -448,13 +449,96 @@ XkbCompatMapPtr compat; interp->virtual_mod= wire.virtualMod; interp->flags= wire.flags; interp->act.type= wire.actionType; - interp->act.data[0]= wire.actionData[0]; - interp->act.data[1]= wire.actionData[1]; - interp->act.data[2]= wire.actionData[2]; - interp->act.data[3]= wire.actionData[3]; - interp->act.data[4]= wire.actionData[4]; - interp->act.data[5]= wire.actionData[5]; - interp->act.data[6]= wire.actionData[6]; + act = (XkbAction *) &interp->act; + + switch (interp->act.type) { + case XkbSA_SetMods: + case XkbSA_LatchMods: + case XkbSA_LockMods: + act->mods.flags = wire.actionData[0]; + act->mods.mask = wire.actionData[1]; + act->mods.real_mods = wire.actionData[2]; + act->mods.vmods1 = wire.actionData[3]; + act->mods.vmods2 = wire.actionData[4]; + break; + case XkbSA_SetGroup: + case XkbSA_LatchGroup: + case XkbSA_LockGroup: + act->group.flags = wire.actionData[0]; + act->group.group_XXX = wire.actionData[1]; + break; + case XkbSA_MovePtr: + act->ptr.flags = wire.actionData[0]; + act->ptr.high_XXX = wire.actionData[1]; + act->ptr.low_XXX = wire.actionData[2]; + act->ptr.high_YYY = wire.actionData[3]; + act->ptr.low_YYY = wire.actionData[4]; + break; + case XkbSA_PtrBtn: + case XkbSA_LockPtrBtn: + act->btn.flags = wire.actionData[0]; + act->btn.count = wire.actionData[1]; + act->btn.button = wire.actionData[2]; + break; + case XkbSA_DeviceBtn: + case XkbSA_LockDeviceBtn: + act->devbtn.flags = wire.actionData[0]; + act->devbtn.count = wire.actionData[1]; + act->devbtn.button = wire.actionData[2]; + act->devbtn.device = wire.actionData[3]; + break; + case XkbSA_SetPtrDflt: + act->dflt.flags = wire.actionData[0]; + act->dflt.affect = wire.actionData[1]; + act->dflt.valueXXX = wire.actionData[2]; + break; + case XkbSA_ISOLock: + act->iso.flags = wire.actionData[0]; + act->iso.mask = wire.actionData[1]; + act->iso.real_mods = wire.actionData[2]; + act->iso.group_XXX = wire.actionData[3]; + act->iso.affect = wire.actionData[4]; + act->iso.vmods1 = wire.actionData[5]; + act->iso.vmods2 = wire.actionData[6]; + break; + case XkbSA_SwitchScreen: + act->screen.flags = wire.actionData[0]; + act->screen.screenXXX = wire.actionData[1]; + break; + case XkbSA_SetControls: + case XkbSA_LockControls: + act->ctrls.flags = wire.actionData[0]; + act->ctrls.ctrls3 = wire.actionData[1]; + act->ctrls.ctrls2 = wire.actionData[2]; + act->ctrls.ctrls1 = wire.actionData[3]; + act->ctrls.ctrls0 = wire.actionData[4]; + break; + case XkbSA_RedirectKey: + act->redirect.new_key = wire.actionData[0]; + act->redirect.mods_mask = wire.actionData[1]; + act->redirect.mods = wire.actionData[2]; + act->redirect.vmods_mask0 = wire.actionData[3]; + act->redirect.vmods_mask1 = wire.actionData[4]; + act->redirect.vmods0 = wire.actionData[4]; + act->redirect.vmods1 = wire.actionData[5]; + break; + case XkbSA_DeviceValuator: + act->devval.device = wire.actionData[0]; + act->devval.v1_what = wire.actionData[1]; + act->devval.v1_ndx = wire.actionData[2]; + act->devval.v1_value = wire.actionData[3]; + act->devval.v2_what = wire.actionData[4]; + act->devval.v2_ndx = wire.actionData[5]; + act->devval.v2_what = wire.actionData[6]; + break; + case XkbSA_XFree86Private: + case XkbSA_Terminate: + /* no args, kinda (note: untrue for xfree86). */ + break; + case XkbSA_ActionMessage: + /* unsupported. */ + break; + } } if ((num_si>0)&&(changes)) { changes->compat.first_si= 0; |