diff options
author | marha <marha@users.sourceforge.net> | 2009-07-25 20:12:58 +0000 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2009-07-25 20:12:58 +0000 |
commit | 2553bdd7c359cd87525d367761c86932cec5adff (patch) | |
tree | ae71245933c98474a699d3e392de5820879b2018 /xorg-server/Xext | |
parent | e2c51f2ee7b0a3ea1a052fc49324057b4a4bbc78 (diff) | |
parent | 4a3dbb926ae3f5410198d7cc4f4ebe4f62eebf05 (diff) | |
download | vcxsrv-2553bdd7c359cd87525d367761c86932cec5adff.tar.gz vcxsrv-2553bdd7c359cd87525d367761c86932cec5adff.tar.bz2 vcxsrv-2553bdd7c359cd87525d367761c86932cec5adff.zip |
svn merge file:///D:/svnrepos/vcxsrv/branches/released .
Diffstat (limited to 'xorg-server/Xext')
38 files changed, 1506 insertions, 6480 deletions
diff --git a/xorg-server/Xext/EVI.c b/xorg-server/Xext/EVI.c deleted file mode 100644 index a637bae5d..000000000 --- a/xorg-server/Xext/EVI.c +++ /dev/null @@ -1,200 +0,0 @@ -/************************************************************ -Copyright (c) 1997 by Silicon Graphics Computer Systems, Inc. -Permission to use, copy, modify, and distribute this -software and its documentation for any purpose and without -fee is hereby granted, provided that the above copyright -notice appear in all copies and that both that copyright -notice and this permission notice appear in supporting -documentation, and that the name of Silicon Graphics not be -used in advertising or publicity pertaining to distribution -of the software without specific prior written permission. -Silicon Graphics makes no representation about the suitability -of this software for any purpose. It is provided "as is" -without any express or implied warranty. -SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS -SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON -GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL -DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, -DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH -THE USE OR PERFORMANCE OF THIS SOFTWARE. -********************************************************/ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include <X11/X.h> -#include <X11/Xproto.h> -#include "dixstruct.h" -#include "extnsionst.h" -#include "dix.h" -#define _XEVI_SERVER_ -#include <X11/extensions/XEVIstr.h> -#include "EVIstruct.h" -#include "modinit.h" -#include "scrnintstr.h" - -static EviPrivPtr eviPriv; - -static int -ProcEVIQueryVersion(ClientPtr client) -{ - /* REQUEST(xEVIQueryVersionReq); */ - xEVIQueryVersionReply rep; - register int n; - REQUEST_SIZE_MATCH (xEVIQueryVersionReq); - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - rep.majorVersion = XEVI_MAJOR_VERSION; - rep.minorVersion = XEVI_MAJOR_VERSION; - if (client->swapped) { - swaps(&rep.sequenceNumber, n); - swapl(&rep.length, n); - swaps(&rep.majorVersion, n); - swaps(&rep.minorVersion, n); - } - WriteToClient(client, sizeof (xEVIQueryVersionReply), (char *)&rep); - return (client->noClientException); -} -#define swapEviInfo(eviInfo, l) \ -{ \ - int l1 = l; \ - xExtendedVisualInfo *eviInfo1 = eviInfo; \ - while (l1-- > 0) { \ - swapl(&eviInfo1->core_visual_id, n); \ - swapl(&eviInfo1->transparency_value, n); \ - swaps(&eviInfo1->num_colormap_conflicts, n); \ - eviInfo1++; \ - } \ -} -#define swapVisual(visual, l) \ -{ \ - int l1 = l; \ - VisualID32 *visual1 = visual; \ - while (l1-- > 0) { \ - swapl(visual1, n); \ - visual1++; \ - } \ -} - -static int -ProcEVIGetVisualInfo(ClientPtr client) -{ - REQUEST(xEVIGetVisualInfoReq); - xEVIGetVisualInfoReply rep; - int i, n, n_conflict, n_info, sz_info, sz_conflict; - VisualID32 *conflict; - unsigned int total_visuals = 0; - xExtendedVisualInfo *eviInfo; - int status; - - /* - * do this first, otherwise REQUEST_FIXED_SIZE can overflow. we assume - * here that you don't have more than 2^32 visuals over all your screens; - * this seems like a safe assumption. - */ - for (i = 0; i < screenInfo.numScreens; i++) - total_visuals += screenInfo.screens[i]->numVisuals; - if (stuff->n_visual > total_visuals) - return BadValue; - - REQUEST_FIXED_SIZE(xEVIGetVisualInfoReq, stuff->n_visual * sz_VisualID32); - status = eviPriv->getVisualInfo((VisualID32 *)&stuff[1], (int)stuff->n_visual, - &eviInfo, &n_info, &conflict, &n_conflict); - if (status != Success) - return status; - sz_info = n_info * sz_xExtendedVisualInfo; - sz_conflict = n_conflict * sz_VisualID32; - rep.type = X_Reply; - rep.n_info = n_info; - rep.n_conflicts = n_conflict; - rep.sequenceNumber = client->sequence; - rep.length = (sz_info + sz_conflict) >> 2; - if (client->swapped) { - swaps(&rep.sequenceNumber, n); - swapl(&rep.length, n); - swapl(&rep.n_info, n); - swapl(&rep.n_conflicts, n); - swapEviInfo(eviInfo, n_info); - swapVisual(conflict, n_conflict); - } - WriteToClient(client, sz_xEVIGetVisualInfoReply, (char *)&rep); - WriteToClient(client, sz_info, (char *)eviInfo); - WriteToClient(client, sz_conflict, (char *)conflict); - eviPriv->freeVisualInfo(eviInfo, conflict); - return (client->noClientException); -} - -static int -ProcEVIDispatch(ClientPtr client) -{ - REQUEST(xReq); - switch (stuff->data) { - case X_EVIQueryVersion: - return ProcEVIQueryVersion (client); - case X_EVIGetVisualInfo: - return ProcEVIGetVisualInfo (client); - default: - return BadRequest; - } -} - -static int -SProcEVIQueryVersion(ClientPtr client) -{ - REQUEST(xEVIQueryVersionReq); - int n; - swaps(&stuff->length, n); - return ProcEVIQueryVersion(client); -} - -static int -SProcEVIGetVisualInfo(ClientPtr client) -{ - register int n; - REQUEST(xEVIGetVisualInfoReq); - swaps(&stuff->length, n); - return ProcEVIGetVisualInfo(client); -} - -static int -SProcEVIDispatch(ClientPtr client) -{ - REQUEST(xReq); - switch (stuff->data) - { - case X_EVIQueryVersion: - return SProcEVIQueryVersion (client); - case X_EVIGetVisualInfo: - return SProcEVIGetVisualInfo (client); - default: - return BadRequest; - } -} - -/*ARGSUSED*/ -static void -EVIResetProc(ExtensionEntry *extEntry) -{ - eviDDXReset(); -} - -/**************** - * XEVIExtensionInit - * - * Called from InitExtensions in main() or from QueryExtension() if the - * extension is dynamically loaded. - * - ****************/ -void -EVIExtensionInit(INITARGS) -{ - if (AddExtension(EVINAME, 0, 0, - ProcEVIDispatch, SProcEVIDispatch, - EVIResetProc, StandardMinorOpcode)) { - eviPriv = eviDDXInit(); - } -} diff --git a/xorg-server/Xext/EVIstruct.h b/xorg-server/Xext/EVIstruct.h deleted file mode 100644 index e6581909f..000000000 --- a/xorg-server/Xext/EVIstruct.h +++ /dev/null @@ -1,58 +0,0 @@ -/************************************************************ -Copyright (c) 1997 by Silicon Graphics Computer Systems, Inc. -Permission to use, copy, modify, and distribute this -software and its documentation for any purpose and without -fee is hereby granted, provided that the above copyright -notice appear in all copies and that both that copyright -notice and this permission notice appear in supporting -documentation, and that the name of Silicon Graphics not be -used in advertising or publicity pertaining to distribution -of the software without specific prior written permission. -Silicon Graphics makes no representation about the suitability -of this software for any purpose. It is provided "as is" -without any express or implied warranty. -SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS -SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON -GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL -DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, -DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH -THE USE OR PERFORMANCE OF THIS SOFTWARE. -********************************************************/ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#ifndef EVI_STRUCT_H -#define EVI_STRUCT_H - -/* - ****************************************************************************** - ** Per-ddx data - ****************************************************************************** - */ - -typedef int (*GetVisualInfoProc)( - VisualID32*, - int, - xExtendedVisualInfo**, - int*, - VisualID32**, - int* -); - -typedef void (*FreeVisualInfoProc)( - xExtendedVisualInfo*, - VisualID32* -); -typedef struct _EviPrivRec { - GetVisualInfoProc getVisualInfo; - FreeVisualInfoProc freeVisualInfo; -} EviPrivRec, *EviPrivPtr; - -extern EviPrivPtr eviDDXInit(void); -extern void eviDDXReset(void); - -#endif /* EVI_STRUCT_H */ diff --git a/xorg-server/Xext/Makefile.am b/xorg-server/Xext/Makefile.am index 648736d95..2f5c98b90 100644 --- a/xorg-server/Xext/Makefile.am +++ b/xorg-server/Xext/Makefile.am @@ -15,23 +15,22 @@ INCLUDES = -I$(top_srcdir)/hw/xfree86/dixmods/extmod AM_CFLAGS = $(DIX_CFLAGS) if XORG -sdk_HEADERS = xvdix.h xvmcext.h +sdk_HEADERS = xvdix.h xvmcext.h geext.h geint.h shmint.h endif # Sources always included in libXextbuiltin.la & libXext.la BUILTIN_SRCS = \ + bigreq.c \ + geext.c \ shape.c \ sleepuntil.c \ sleepuntil.h \ + sync.c \ + xcmisc.c \ xtest.c -# Sources always included in libXextmodule.la & libXext.la -MODULE_SRCS = \ - bigreq.c \ - mitmisc.c \ - shape.c \ - sync.c \ - xcmisc.c +# Sources always included in libXextmodule.la & libXext.la. That's right, zero. +MODULE_SRCS = # Optional sources included if extension enabled by configure.ac rules @@ -91,39 +90,6 @@ BUILTIN_SRCS += $(XCALIBRATE_SRCS) # XCalibrate needs tslib endif -# X EVent Interception Extension: allows accessibility helpers & composite -# managers to intercept events from input devices and transform as needed -# before the clients see them. -XEVIE_SRCS = xevie.c -if XEVIE -BUILTIN_SRCS += $(XEVIE_SRCS) -endif - -# XPrint: Printing via X Protocol -XPRINT_SRCS = xprint.c -if XPRINT -BUILTIN_SRCS += $(XPRINT_SRCS) -endif - -# AppGroup -APPGROUP_SRCS = appgroup.c appgroup.h -if APPGROUP -BUILTIN_SRCS += $(APPGROUP_SRCS) -endif - -# Colormap Utilization Protocol: Less flashing when switching between -# PsuedoColor apps and better sharing of limited colormap slots -CUP_SRCS = cup.c -if CUP -MODULE_SRCS += $(CUP_SRCS) -endif - -# Extended Visual Information -EVI_SRCS = EVI.c sampleEVI.c EVIstruct.h -if EVI -MODULE_SRCS += $(EVI_SRCS) -endif - # Multi-buffering extension MULTIBUFFER_SRCS = mbuf.c EXTRA_MULTIBUFFER_SRCS = mbufbf.c mbufpx.c @@ -131,12 +97,6 @@ if MULTIBUFFER MODULE_SRCS += $(MULTIBUFFER_SRCS) endif -# Font Cache extension -FONTCACHE_SRCS = fontcache.c -if FONTCACHE -MODULE_SRCS += $(FONTCACHE_SRCS) -endif - # XF86 Big Font extension BIGFONT_SRCS = xf86bigfont.c if XF86BIGFONT @@ -168,14 +128,10 @@ EXTRA_DIST = \ $(XCSECURITY_SRCS) \ $(XCALIBRATE_SRCS) \ $(XINERAMA_SRCS) \ - $(XEVIE_SRCS) \ - $(XPRINT_SRCS) \ - $(APPGROUP_SRCS) \ - $(CUP_SRCS) \ - $(EVI_SRCS) \ $(MULTIBUFFER_SRCS) \ $(EXTRA_MULTIBUFFER_SRCS) \ $(FONTCACHE_SRCS) \ $(BIGFONT_SRCS) \ - $(DPMS_SRCS) + $(DPMS_SRCS) \ + $(GE_SRCS) diff --git a/xorg-server/Xext/Makefile.in b/xorg-server/Xext/Makefile.in index 11af6324e..62a07da95 100644 --- a/xorg-server/Xext/Makefile.in +++ b/xorg-server/Xext/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. +# Makefile.in generated by automake 1.10.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -42,15 +42,9 @@ host_triplet = @host@ @XSELINUX_TRUE@am__append_7 = $(XSELINUX_SRCS) @XCSECURITY_TRUE@am__append_8 = $(XCSECURITY_SRCS) @XCALIBRATE_TRUE@am__append_9 = $(XCALIBRATE_SRCS) -@XEVIE_TRUE@am__append_10 = $(XEVIE_SRCS) -@XPRINT_TRUE@am__append_11 = $(XPRINT_SRCS) -@APPGROUP_TRUE@am__append_12 = $(APPGROUP_SRCS) -@CUP_TRUE@am__append_13 = $(CUP_SRCS) -@EVI_TRUE@am__append_14 = $(EVI_SRCS) -@MULTIBUFFER_TRUE@am__append_15 = $(MULTIBUFFER_SRCS) -@FONTCACHE_TRUE@am__append_16 = $(FONTCACHE_SRCS) -@XF86BIGFONT_TRUE@am__append_17 = $(BIGFONT_SRCS) -@DPMSExtension_TRUE@am__append_18 = $(DPMS_SRCS) +@MULTIBUFFER_TRUE@am__append_10 = $(MULTIBUFFER_SRCS) +@XF86BIGFONT_TRUE@am__append_11 = $(BIGFONT_SRCS) +@DPMSExtension_TRUE@am__append_12 = $(DPMS_SRCS) subdir = Xext DIST_COMMON = $(am__sdk_HEADERS_DIST) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in @@ -63,7 +57,6 @@ mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ $(top_builddir)/include/xorg-server.h \ $(top_builddir)/include/dix-config.h \ - $(top_builddir)/include/xgl-config.h \ $(top_builddir)/include/xorg-config.h \ $(top_builddir)/include/xkb-config.h \ $(top_builddir)/include/xwin-config.h \ @@ -71,15 +64,13 @@ CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ CONFIG_CLEAN_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libXext_la_LIBADD = -am__libXext_la_SOURCES_DIST = shape.c sleepuntil.c sleepuntil.h \ - xtest.c shm.c shmint.h panoramiX.c panoramiX.h panoramiXh.h \ - panoramiXsrv.h panoramiXprocs.c panoramiXSwap.c xace.c xace.h \ - xacestr.h security.c securitysrv.h xcalibrate.c xevie.c \ - xprint.c appgroup.c appgroup.h xf86bigfont.c bigreq.c \ - mitmisc.c sync.c xcmisc.c xvmain.c xvdisp.c xvmc.c xvdix.h \ - xvmcext.h xvdisp.h xres.c saver.c xselinux.c xselinux.h cup.c \ - EVI.c sampleEVI.c EVIstruct.h mbuf.c fontcache.c dpms.c \ - dpmsproc.h +am__libXext_la_SOURCES_DIST = bigreq.c geext.c shape.c sleepuntil.c \ + sleepuntil.h sync.c xcmisc.c xtest.c shm.c shmint.h \ + panoramiX.c panoramiX.h panoramiXh.h panoramiXsrv.h \ + panoramiXprocs.c panoramiXSwap.c xace.c xace.h xacestr.h \ + security.c securitysrv.h xcalibrate.c xf86bigfont.c xvmain.c \ + xvdisp.c xvmc.c xvdix.h xvmcext.h xvdisp.h xres.c saver.c \ + xselinux.c xselinux.h mbuf.c dpms.c dpmsproc.h am__objects_1 = shm.lo @MITSHM_TRUE@am__objects_2 = $(am__objects_1) am__objects_3 = panoramiX.lo panoramiXprocs.lo panoramiXSwap.lo @@ -90,59 +81,44 @@ am__objects_7 = security.lo @XCSECURITY_TRUE@am__objects_8 = $(am__objects_7) am__objects_9 = xcalibrate.lo @XCALIBRATE_TRUE@am__objects_10 = $(am__objects_9) -am__objects_11 = xevie.lo -@XEVIE_TRUE@am__objects_12 = $(am__objects_11) -am__objects_13 = xprint.lo -@XPRINT_TRUE@am__objects_14 = $(am__objects_13) -am__objects_15 = appgroup.lo -@APPGROUP_TRUE@am__objects_16 = $(am__objects_15) -am__objects_17 = xf86bigfont.lo -@XF86BIGFONT_TRUE@am__objects_18 = $(am__objects_17) -am__objects_19 = shape.lo sleepuntil.lo xtest.lo $(am__objects_2) \ - $(am__objects_4) $(am__objects_6) $(am__objects_8) \ - $(am__objects_10) $(am__objects_12) $(am__objects_14) \ - $(am__objects_16) $(am__objects_18) -am__objects_20 = xvmain.lo xvdisp.lo xvmc.lo -@XV_TRUE@am__objects_21 = $(am__objects_20) -am__objects_22 = xres.lo -@RES_TRUE@am__objects_23 = $(am__objects_22) -am__objects_24 = saver.lo -@SCREENSAVER_TRUE@am__objects_25 = $(am__objects_24) -am__objects_26 = xselinux.lo -@XSELINUX_TRUE@am__objects_27 = $(am__objects_26) -am__objects_28 = cup.lo -@CUP_TRUE@am__objects_29 = $(am__objects_28) -am__objects_30 = EVI.lo sampleEVI.lo -@EVI_TRUE@am__objects_31 = $(am__objects_30) -am__objects_32 = mbuf.lo -@MULTIBUFFER_TRUE@am__objects_33 = $(am__objects_32) -am__objects_34 = fontcache.lo -@FONTCACHE_TRUE@am__objects_35 = $(am__objects_34) -am__objects_36 = dpms.lo -@DPMSExtension_TRUE@am__objects_37 = $(am__objects_36) -am__objects_38 = bigreq.lo mitmisc.lo shape.lo sync.lo xcmisc.lo \ - $(am__objects_21) $(am__objects_23) $(am__objects_25) \ - $(am__objects_27) $(am__objects_29) $(am__objects_31) \ - $(am__objects_33) $(am__objects_35) $(am__objects_37) -am_libXext_la_OBJECTS = $(am__objects_19) $(am__objects_38) +am__objects_11 = xf86bigfont.lo +@XF86BIGFONT_TRUE@am__objects_12 = $(am__objects_11) +am__objects_13 = bigreq.lo geext.lo shape.lo sleepuntil.lo sync.lo \ + xcmisc.lo xtest.lo $(am__objects_2) $(am__objects_4) \ + $(am__objects_6) $(am__objects_8) $(am__objects_10) \ + $(am__objects_12) +am__objects_14 = xvmain.lo xvdisp.lo xvmc.lo +@XV_TRUE@am__objects_15 = $(am__objects_14) +am__objects_16 = xres.lo +@RES_TRUE@am__objects_17 = $(am__objects_16) +am__objects_18 = saver.lo +@SCREENSAVER_TRUE@am__objects_19 = $(am__objects_18) +am__objects_20 = xselinux.lo +@XSELINUX_TRUE@am__objects_21 = $(am__objects_20) +am__objects_22 = mbuf.lo +@MULTIBUFFER_TRUE@am__objects_23 = $(am__objects_22) +am__objects_24 = dpms.lo +@DPMSExtension_TRUE@am__objects_25 = $(am__objects_24) +am__objects_26 = $(am__objects_15) $(am__objects_17) $(am__objects_19) \ + $(am__objects_21) $(am__objects_23) $(am__objects_25) +am_libXext_la_OBJECTS = $(am__objects_13) $(am__objects_26) libXext_la_OBJECTS = $(am_libXext_la_OBJECTS) @XORG_FALSE@am_libXext_la_rpath = @XORG_TRUE@am_libXext_la_rpath = libXextbuiltin_la_LIBADD = -am__libXextbuiltin_la_SOURCES_DIST = shape.c sleepuntil.c sleepuntil.h \ - xtest.c shm.c shmint.h panoramiX.c panoramiX.h panoramiXh.h \ - panoramiXsrv.h panoramiXprocs.c panoramiXSwap.c xace.c xace.h \ - xacestr.h security.c securitysrv.h xcalibrate.c xevie.c \ - xprint.c appgroup.c appgroup.h xf86bigfont.c -@XORG_TRUE@am_libXextbuiltin_la_OBJECTS = $(am__objects_19) +am__libXextbuiltin_la_SOURCES_DIST = bigreq.c geext.c shape.c \ + sleepuntil.c sleepuntil.h sync.c xcmisc.c xtest.c shm.c \ + shmint.h panoramiX.c panoramiX.h panoramiXh.h panoramiXsrv.h \ + panoramiXprocs.c panoramiXSwap.c xace.c xace.h xacestr.h \ + security.c securitysrv.h xcalibrate.c xf86bigfont.c +@XORG_TRUE@am_libXextbuiltin_la_OBJECTS = $(am__objects_13) libXextbuiltin_la_OBJECTS = $(am_libXextbuiltin_la_OBJECTS) @XORG_TRUE@am_libXextbuiltin_la_rpath = libXextmodule_la_LIBADD = -am__libXextmodule_la_SOURCES_DIST = bigreq.c mitmisc.c shape.c sync.c \ - xcmisc.c xvmain.c xvdisp.c xvmc.c xvdix.h xvmcext.h xvdisp.h \ - xres.c saver.c xselinux.c xselinux.h cup.c EVI.c sampleEVI.c \ - EVIstruct.h mbuf.c fontcache.c dpms.c dpmsproc.h -@XORG_TRUE@am_libXextmodule_la_OBJECTS = $(am__objects_38) +am__libXextmodule_la_SOURCES_DIST = xvmain.c xvdisp.c xvmc.c xvdix.h \ + xvmcext.h xvdisp.h xres.c saver.c xselinux.c xselinux.h mbuf.c \ + dpms.c dpmsproc.h +@XORG_TRUE@am_libXextmodule_la_OBJECTS = $(am__objects_26) libXextmodule_la_OBJECTS = $(am_libXextmodule_la_OBJECTS) @XORG_TRUE@am_libXextmodule_la_rpath = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include @@ -150,9 +126,6 @@ depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ - --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ - $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ @@ -162,7 +135,7 @@ SOURCES = $(libXext_la_SOURCES) $(libXextbuiltin_la_SOURCES) \ DIST_SOURCES = $(am__libXext_la_SOURCES_DIST) \ $(am__libXextbuiltin_la_SOURCES_DIST) \ $(am__libXextmodule_la_SOURCES_DIST) -am__sdk_HEADERS_DIST = xvdix.h xvmcext.h +am__sdk_HEADERS_DIST = xvdix.h xvmcext.h geext.h geint.h shmint.h am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ @@ -180,8 +153,9 @@ ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ ALLOCA = @ALLOCA@ AMTAR = @AMTAR@ -APPDEFAULTDIR = @APPDEFAULTDIR@ APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ +APPLE_APPLICATION_ID = @APPLE_APPLICATION_ID@ +APPLE_APPLICATION_NAME = @APPLE_APPLICATION_NAME@ APP_MAN_DIR = @APP_MAN_DIR@ APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ AR = @AR@ @@ -202,10 +176,6 @@ CFLAGS = @CFLAGS@ COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DARWIN_LIBS = @DARWIN_LIBS@ DBUS_CFLAGS = @DBUS_CFLAGS@ @@ -227,6 +197,7 @@ DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@ DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@ DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@ DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@ +DOLT_BASH = @DOLT_BASH@ DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ @@ -236,18 +207,15 @@ DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ DSYMUTIL = @DSYMUTIL@ DTRACE = @DTRACE@ -ECHO = @ECHO@ +DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ -F77 = @F77@ -FFLAGS = @FFLAGS@ +FGREP = @FGREP@ FILE_MAN_DIR = @FILE_MAN_DIR@ FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ -FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ -FREETYPE_LIBS = @FREETYPE_LIBS@ GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ GLX_DEFINES = @GLX_DEFINES@ GL_CFLAGS = @GL_CFLAGS@ @@ -266,7 +234,7 @@ KDRIVE_LIBS = @KDRIVE_LIBS@ KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@ KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@ KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@ -LAUNCHD = @LAUNCHD@ +LD = @LD@ LDFLAGS = @LDFLAGS@ LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@ LEX = @LEX@ @@ -280,7 +248,10 @@ LIBTOOL = @LIBTOOL@ LIB_MAN_DIR = @LIB_MAN_DIR@ LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ LINUXDOC = @LINUXDOC@ +LIPO = @LIPO@ LN_S = @LN_S@ +LTCOMPILE = @LTCOMPILE@ +LTCXXCOMPILE = @LTCXXCOMPILE@ LTLIBOBJS = @LTLIBOBJS@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ @@ -292,8 +263,7 @@ MESA_SOURCE = @MESA_SOURCE@ MISC_MAN_DIR = @MISC_MAN_DIR@ MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ MKDIR_P = @MKDIR_P@ -MKFONTDIR = @MKFONTDIR@ -MKFONTSCALE = @MKFONTSCALE@ +NM = @NM@ NMEDIT = @NMEDIT@ OBJC = @OBJC@ OBJCCLD = @OBJCCLD@ @@ -302,8 +272,8 @@ OBJCFLAGS = @OBJCFLAGS@ OBJCLINK = @OBJCLINK@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ -OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ -OPENSSL_LIBS = @OPENSSL_LIBS@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ @@ -336,7 +306,6 @@ VENDOR_NAME = @VENDOR_NAME@ VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ VENDOR_RELEASE = @VENDOR_RELEASE@ VERSION = @VERSION@ -X11APP_ARCHS = @X11APP_ARCHS@ X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ XDMCP_CFLAGS = @XDMCP_CFLAGS@ @@ -346,27 +315,12 @@ XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@ XDMX_CFLAGS = @XDMX_CFLAGS@ XDMX_LIBS = @XDMX_LIBS@ XDMX_SYS_LIBS = @XDMX_SYS_LIBS@ -XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@ -XEGL_LIBS = @XEGL_LIBS@ -XEGL_SYS_LIBS = @XEGL_SYS_LIBS@ XEPHYR_CFLAGS = @XEPHYR_CFLAGS@ -XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@ XEPHYR_INCS = @XEPHYR_INCS@ XEPHYR_LIBS = @XEPHYR_LIBS@ XF86CONFIGFILE = @XF86CONFIGFILE@ -XF86MISC_CFLAGS = @XF86MISC_CFLAGS@ -XF86MISC_LIBS = @XF86MISC_LIBS@ XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ -XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@ -XGLMODULES_LIBS = @XGLMODULES_LIBS@ -XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@ -XGLXMODULES_LIBS = @XGLXMODULES_LIBS@ -XGLX_LIBS = @XGLX_LIBS@ -XGLX_SYS_LIBS = @XGLX_SYS_LIBS@ -XGL_LIBS = @XGL_LIBS@ -XGL_MODULE_PATH = @XGL_MODULE_PATH@ -XGL_SYS_LIBS = @XGL_SYS_LIBS@ XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@ XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@ XKB_COMPILED_DIR = @XKB_COMPILED_DIR@ @@ -377,10 +331,6 @@ XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@ XNESTMODULES_LIBS = @XNESTMODULES_LIBS@ XNEST_LIBS = @XNEST_LIBS@ XNEST_SYS_LIBS = @XNEST_SYS_LIBS@ -XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@ -XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@ -XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@ -XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@ XORG_CFLAGS = @XORG_CFLAGS@ XORG_INCS = @XORG_INCS@ XORG_LIBS = @XORG_LIBS@ @@ -389,13 +339,8 @@ XORG_MODULES_LIBS = @XORG_MODULES_LIBS@ XORG_OS = @XORG_OS@ XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ XORG_SYS_LIBS = @XORG_SYS_LIBS@ -XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@ -XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@ -XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@ -XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@ -XPRINT_CFLAGS = @XPRINT_CFLAGS@ -XPRINT_LIBS = @XPRINT_LIBS@ -XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@ +XPBPROXY_CFLAGS = @XPBPROXY_CFLAGS@ +XPBPROXY_LIBS = @XPBPROXY_LIBS@ XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ XSDL_INCS = @XSDL_INCS@ @@ -428,8 +373,7 @@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_F77 = @ac_ct_F77@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ @@ -449,7 +393,6 @@ driverdir = @driverdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ extdir = @extdir@ -ft_config = @ft_config@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ @@ -459,12 +402,12 @@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ -launchagentsdir = @launchagentsdir@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ logdir = @logdir@ +lt_ECHO = @lt_ECHO@ mandir = @mandir@ mkdir_p = @mkdir_p@ moduledir = @moduledir@ @@ -482,8 +425,6 @@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -xglmoduledir = @xglmoduledir@ -xpconfigdir = @xpconfigdir@ @XORG_FALSE@noinst_LTLIBRARIES = libXext.la # libXext.la: includes all extensions and should be linked into Xvfb, @@ -495,19 +436,17 @@ xpconfigdir = @xpconfigdir@ @XORG_TRUE@noinst_LTLIBRARIES = libXext.la libXextbuiltin.la libXextmodule.la INCLUDES = -I$(top_srcdir)/hw/xfree86/dixmods/extmod AM_CFLAGS = $(DIX_CFLAGS) -@XORG_TRUE@sdk_HEADERS = xvdix.h xvmcext.h +@XORG_TRUE@sdk_HEADERS = xvdix.h xvmcext.h geext.h geint.h shmint.h # Sources always included in libXextbuiltin.la & libXext.la -BUILTIN_SRCS = shape.c sleepuntil.c sleepuntil.h xtest.c \ - $(am__append_1) $(am__append_5) $(am__append_6) \ - $(am__append_8) $(am__append_9) $(am__append_10) \ - $(am__append_11) $(am__append_12) $(am__append_17) +BUILTIN_SRCS = bigreq.c geext.c shape.c sleepuntil.c sleepuntil.h \ + sync.c xcmisc.c xtest.c $(am__append_1) $(am__append_5) \ + $(am__append_6) $(am__append_8) $(am__append_9) \ + $(am__append_11) -# Sources always included in libXextmodule.la & libXext.la -MODULE_SRCS = bigreq.c mitmisc.c shape.c sync.c xcmisc.c \ - $(am__append_2) $(am__append_3) $(am__append_4) \ - $(am__append_7) $(am__append_13) $(am__append_14) \ - $(am__append_15) $(am__append_16) $(am__append_18) +# Sources always included in libXextmodule.la & libXext.la. That's right, zero. +MODULE_SRCS = $(am__append_2) $(am__append_3) $(am__append_4) \ + $(am__append_7) $(am__append_10) $(am__append_12) # Optional sources included if extension enabled by configure.ac rules @@ -539,31 +478,10 @@ XCSECURITY_SRCS = security.c securitysrv.h XCALIBRATE_SRCS = xcalibrate.c # XCalibrate needs tslib -# X EVent Interception Extension: allows accessibility helpers & composite -# managers to intercept events from input devices and transform as needed -# before the clients see them. -XEVIE_SRCS = xevie.c - -# XPrint: Printing via X Protocol -XPRINT_SRCS = xprint.c - -# AppGroup -APPGROUP_SRCS = appgroup.c appgroup.h - -# Colormap Utilization Protocol: Less flashing when switching between -# PsuedoColor apps and better sharing of limited colormap slots -CUP_SRCS = cup.c - -# Extended Visual Information -EVI_SRCS = EVI.c sampleEVI.c EVIstruct.h - # Multi-buffering extension MULTIBUFFER_SRCS = mbuf.c EXTRA_MULTIBUFFER_SRCS = mbufbf.c mbufpx.c -# Font Cache extension -FONTCACHE_SRCS = fontcache.c - # XF86 Big Font extension BIGFONT_SRCS = xf86bigfont.c @@ -583,16 +501,12 @@ EXTRA_DIST = \ $(XCSECURITY_SRCS) \ $(XCALIBRATE_SRCS) \ $(XINERAMA_SRCS) \ - $(XEVIE_SRCS) \ - $(XPRINT_SRCS) \ - $(APPGROUP_SRCS) \ - $(CUP_SRCS) \ - $(EVI_SRCS) \ $(MULTIBUFFER_SRCS) \ $(EXTRA_MULTIBUFFER_SRCS) \ $(FONTCACHE_SRCS) \ $(BIGFONT_SRCS) \ - $(DPMS_SRCS) + $(DPMS_SRCS) \ + $(GE_SRCS) all: all-am @@ -602,8 +516,8 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ @@ -649,18 +563,13 @@ mostlyclean-compile: distclean-compile: -rm -f *.tab.c -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/EVI.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/appgroup.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bigreq.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cup.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dpms.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fontcache.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/geext.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mbuf.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mitmisc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/panoramiX.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/panoramiXSwap.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/panoramiXprocs.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sampleEVI.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/saver.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/security.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shape.Plo@am__quote@ @@ -670,9 +579,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xace.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xcalibrate.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xcmisc.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xevie.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86bigfont.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xprint.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xres.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xselinux.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xtest.Plo@am__quote@ @@ -729,7 +636,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ - $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS diff --git a/xorg-server/Xext/appgroup.c b/xorg-server/Xext/appgroup.c deleted file mode 100644 index c40782df5..000000000 --- a/xorg-server/Xext/appgroup.c +++ /dev/null @@ -1,775 +0,0 @@ -/* -Copyright 1996, 1998, 2001 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall -not be used in advertising or otherwise to promote the sale, use or -other dealings in this Software without prior written authorization -from The Open Group. -*/ - -#define NEED_REPLIES -#define NEED_EVENTS -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include <X11/X.h> -#include <X11/Xproto.h> -#include "misc.h" -#include "dixstruct.h" -#include "extnsionst.h" -#include "scrnintstr.h" -#include "windowstr.h" -#include "colormapst.h" -#include "servermd.h" -#define _XAG_SERVER_ -#include <X11/extensions/Xagstr.h> -#include "xacestr.h" -#include "securitysrv.h" -#include <X11/Xfuncproto.h> - -#define XSERV_t -#include <X11/Xtrans/Xtrans.h> -#include "../os/osdep.h" - -#include <stdio.h> - -#include "modinit.h" -#include "appgroup.h" - -typedef struct _AppGroupRec { - struct _AppGroupRec* next; - XID appgroupId; - ClientPtr* clients; - int nclients; - ClientPtr leader; - Bool single_screen; - Window default_root; - VisualID root_visual; - Colormap default_colormap; - Pixel black_pixel; - Pixel white_pixel; - xConnSetupPrefix connSetupPrefix; - char* ConnectionInfo; -} AppGroupRec, *AppGroupPtr; - -static int ProcXagDispatch(ClientPtr client); -static int SProcXagDispatch(ClientPtr client); -static void XagResetProc(ExtensionEntry* extEntry); - -static int XagCallbackRefCount = 0; - -static RESTYPE RT_APPGROUP; -static AppGroupPtr appGrpList = NULL; - -extern xConnSetupPrefix connSetupPrefix; -extern char* ConnectionInfo; -extern int connBlockScreenStart; - -static -int XagAppGroupFree( - pointer what, - XID id) /* unused */ -{ - int i; - AppGroupPtr pAppGrp = (AppGroupPtr) what; - - if (pAppGrp->leader) - for (i = 0; i < pAppGrp->nclients; i++) { - if (pAppGrp->clients[i] == NULL) continue; - CloseDownClient (pAppGrp->clients[i]); - } - - if (pAppGrp == appGrpList) - appGrpList = appGrpList->next; - else { - AppGroupPtr tpAppGrp; - for (tpAppGrp = appGrpList; - tpAppGrp->next != NULL; - tpAppGrp = tpAppGrp->next) { - if (tpAppGrp->next == pAppGrp) { - tpAppGrp->next = tpAppGrp->next->next; - break; - } - } - } - (void) xfree (pAppGrp->clients); - (void) xfree (pAppGrp->ConnectionInfo); - (void) xfree (what); - return Success; -} - -static void XagClientStateChange( - CallbackListPtr* pcbl, - pointer nulldata, - pointer calldata) -{ - NewClientInfoRec* pci = (NewClientInfoRec*) calldata; - ClientPtr pClient = pci->client; - AppGroupPtr pAppGrp = pClient->appgroup; - int slot; - - if (!pAppGrp) - return; - - switch (pClient->clientState) { - case ClientStateAuthenticating: - case ClientStateRunning: - case ClientStateCheckingSecurity: - break; - - case ClientStateInitial: - case ClientStateCheckedSecurity: - slot = -1; - /* see the comment above about Initial vs. CheckedSecurity */ - if (pAppGrp->nclients != 0) { - /* if this client already in AppGroup, don't add it again */ - int i; - for (i = 0; i < pAppGrp->nclients; i++) - if (pClient == pAppGrp->clients[i]) return; - if (slot == -1 && pAppGrp->clients[i] == NULL) - slot = i; - } - if (slot == -1) { - slot = pAppGrp->nclients++; - pAppGrp->clients = (ClientPtr*) xrealloc (pAppGrp->clients, - pAppGrp->nclients * sizeof (ClientPtr)); - } - pAppGrp->clients[slot] = pClient; - pClient->appgroup = pAppGrp; - break; - - case ClientStateGone: - case ClientStateRetained: /* client disconnected, dump it */ - { - int i; - for (i = 0; i < pAppGrp->nclients; i++) - if (pAppGrp->clients[i] == pClient) { - pAppGrp->clients[i] = NULL; - break; - } - } - pClient->appgroup = NULL; /* redundant, pClient will be freed */ - break; - } -} - -/*ARGSUSED*/ -static -void XagResetProc( - ExtensionEntry* extEntry) -{ - DeleteCallback (&ClientStateCallback, XagClientStateChange, NULL); - XagCallbackRefCount = 0; - while (appGrpList) XagAppGroupFree ((pointer) appGrpList, 0); -} - -static -int ProcXagQueryVersion( - register ClientPtr client) -{ - /* REQUEST (xXagQueryVersionReq); */ - xXagQueryVersionReply rep; - register int n; - - REQUEST_SIZE_MATCH (xXagQueryVersionReq); - rep.type = X_Reply; - rep.length = 0; - rep.sequence_number = client->sequence; - rep.server_major_version = XAG_MAJOR_VERSION; - rep.server_minor_version = XAG_MINOR_VERSION; - if (client->swapped) { - swaps (&rep.sequence_number, n); - swapl (&rep.length, n); - swaps (&rep.server_major_version, n); - swaps (&rep.server_minor_version, n); - } - WriteToClient (client, sizeof (xXagQueryVersionReply), (char *)&rep); - return client->noClientException; -} - -static -void ProcessAttr( - AppGroupPtr pAppGrp, - ClientPtr client, - unsigned int attrib_mask, - CARD32* attribs) -{ - int i; - - for (i = 0; i <= XagNappGroupLeader; i++) { - switch (attrib_mask & (1 << i)) { - case XagSingleScreenMask: - pAppGrp->single_screen = *attribs; - break; - case XagDefaultRootMask: - pAppGrp->default_root = *attribs; - break; - case XagRootVisualMask: - pAppGrp->root_visual = *attribs; - break; - case XagDefaultColormapMask: - pAppGrp->default_colormap = *attribs; - break; - case XagBlackPixelMask: - pAppGrp->black_pixel = *attribs; - break; - case XagWhitePixelMask: - pAppGrp->white_pixel = *attribs; - break; - case XagAppGroupLeaderMask: - pAppGrp->leader = client; - break; - default: continue; - } - attribs++; - } -} - -static -void CreateConnectionInfo( - AppGroupPtr pAppGrp) -{ - xWindowRoot* rootp; - xWindowRoot* roots[MAXSCREENS]; - unsigned int rootlens[MAXSCREENS]; - xDepth* depth; - int olen; - int snum, i; - - rootp = (xWindowRoot*) (ConnectionInfo + connBlockScreenStart); - for (snum = 0; snum < screenInfo.numScreens; snum++) { - - rootlens[snum] = sizeof (xWindowRoot); - roots[snum] = rootp; - - depth = (xDepth*) (rootp + 1); - for (i = 0; i < rootp->nDepths; i++) { - rootlens[snum] += sizeof (xDepth) + - depth->nVisuals * sizeof (xVisualType); - depth = (xDepth *)(((char*)(depth + 1)) + - depth->nVisuals * sizeof (xVisualType)); - } - rootp = (xWindowRoot*) depth; - } - snum = 0; - if (pAppGrp->default_root) { - for (; snum < screenInfo.numVideoScreens; snum++) { - if (roots[snum]->windowId == pAppGrp->default_root) - break; - } - } - olen = connBlockScreenStart + rootlens[snum]; - for (i = screenInfo.numVideoScreens; i < screenInfo.numScreens; i++) - olen += rootlens[i]; - pAppGrp->ConnectionInfo = (char*) xalloc (olen); - if (!pAppGrp->ConnectionInfo) - return; - memmove (pAppGrp->ConnectionInfo, ConnectionInfo, connBlockScreenStart); - ((xConnSetup*) (pAppGrp->ConnectionInfo))->numRoots = - 1 + screenInfo.numScreens - screenInfo.numVideoScreens; - memmove (pAppGrp->ConnectionInfo + connBlockScreenStart, - (void*) roots[snum], rootlens[snum]); - rootp = (xWindowRoot*) (pAppGrp->ConnectionInfo + connBlockScreenStart); - if (pAppGrp->default_colormap) { - rootp->defaultColormap = pAppGrp->default_colormap; - rootp->whitePixel = pAppGrp->white_pixel; - rootp->blackPixel = pAppGrp->black_pixel; - } - if (pAppGrp->root_visual) - rootp->rootVisualID = pAppGrp->root_visual; - rootp = (xWindowRoot*) (((char*)rootp) + rootlens[snum]); - for (i = screenInfo.numVideoScreens; i < screenInfo.numScreens; i++) { - memmove ((void*) rootp, (void*) roots[i], rootlens[i]); - rootp = (xWindowRoot*) (((char*) rootp) + rootlens[i]); - } - pAppGrp->connSetupPrefix = connSetupPrefix; - pAppGrp->connSetupPrefix.length = olen >> 2; -} - -static -AppGroupPtr CreateAppGroup( - ClientPtr client, - XID appgroupId, - unsigned int attrib_mask, - CARD32* attribs) -{ - AppGroupPtr pAppGrp; - - pAppGrp = (AppGroupPtr) xalloc (sizeof(AppGroupRec)); - if (pAppGrp) { - pAppGrp->next = appGrpList; - appGrpList = pAppGrp; - pAppGrp->appgroupId = appgroupId; - pAppGrp->clients = (ClientPtr*) xalloc (0); - pAppGrp->nclients = 0; - pAppGrp->leader = NULL; - pAppGrp->default_root = 0; - pAppGrp->root_visual = 0; - pAppGrp->default_colormap = 0; - pAppGrp->black_pixel = -1; - pAppGrp->white_pixel = -1; - pAppGrp->ConnectionInfo = NULL; - ProcessAttr (pAppGrp, client, attrib_mask, attribs); - } - return pAppGrp; -} - -static -int AttrValidate( - ClientPtr client, - int attrib_mask, - AppGroupPtr pAppGrp) -{ - WindowPtr pWin; - int idepth, ivids, found, rc; - ScreenPtr pScreen; - DepthPtr pDepth; - ColormapPtr pColormap; - - rc = dixLookupWindow(&pWin, pAppGrp->default_root, client, - DixGetAttrAccess); - if (rc != Success) - return rc; - pScreen = pWin->drawable.pScreen; - if (WindowTable[pScreen->myNum]->drawable.id != pAppGrp->default_root) - return BadWindow; - pDepth = pScreen->allowedDepths; - if (pAppGrp->root_visual) { - found = FALSE; - for (idepth = 0; idepth < pScreen->numDepths; idepth++, pDepth++) { - for (ivids = 0; ivids < pDepth->numVids; ivids++) { - if (pAppGrp->root_visual == pDepth->vids[ivids]) { - found = TRUE; - break; - } - } - } - if (!found) - return BadMatch; - } - if (pAppGrp->default_colormap) { - - rc = dixLookupResource((pointer *)&pColormap, pAppGrp->default_colormap, - RT_COLORMAP, client, DixUseAccess); - if (rc != Success) - return rc; - if (pColormap->pScreen != pScreen) - return BadColor; - if (pColormap->pVisual->vid != (pAppGrp->root_visual ? pAppGrp->root_visual : pScreen->rootVisual)) - return BadMatch; - } - return client->noClientException; -} - -static int ProcXagCreate ( - register ClientPtr client) -{ - REQUEST (xXagCreateReq); - AppGroupPtr pAppGrp; - int ret; - - REQUEST_AT_LEAST_SIZE (xXagCreateReq); - - LEGAL_NEW_RESOURCE (stuff->app_group, client); - pAppGrp = CreateAppGroup (client, stuff->app_group, - stuff->attrib_mask, (CARD32*) &stuff[1]); - if (!pAppGrp) - return BadAlloc; - ret = AttrValidate (client, stuff->attrib_mask, pAppGrp); - if (ret != Success) { - XagAppGroupFree ((pointer)pAppGrp, (XID)0); - return ret; - } - if (pAppGrp->single_screen) { - CreateConnectionInfo (pAppGrp); - if (!pAppGrp->ConnectionInfo) - return BadAlloc; - } - if (!AddResource (stuff->app_group, RT_APPGROUP, (pointer)pAppGrp)) - return BadAlloc; - if (XagCallbackRefCount++ == 0) - (void) AddCallback (&ClientStateCallback, XagClientStateChange, NULL); - return client->noClientException; -} - -static int ProcXagDestroy( - register ClientPtr client) -{ - AppGroupPtr pAppGrp; - REQUEST (xXagDestroyReq); - - REQUEST_SIZE_MATCH (xXagDestroyReq); - pAppGrp = (AppGroupPtr)SecurityLookupIDByType (client, - (XID)stuff->app_group, RT_APPGROUP, DixReadAccess); - if (!pAppGrp) return XagBadAppGroup; - FreeResource ((XID)stuff->app_group, RT_NONE); - if (--XagCallbackRefCount == 0) - (void) DeleteCallback (&ClientStateCallback, XagClientStateChange, NULL); - return client->noClientException; -} - -static -int ProcXagGetAttr( - register ClientPtr client) -{ - AppGroupPtr pAppGrp; - REQUEST (xXagGetAttrReq); - xXagGetAttrReply rep; - int n; - - REQUEST_SIZE_MATCH (xXagGetAttrReq); - pAppGrp = (AppGroupPtr)SecurityLookupIDByType (client, - (XID)stuff->app_group, RT_APPGROUP, DixReadAccess); - if (!pAppGrp) return XagBadAppGroup; - rep.type = X_Reply; - rep.length = 0; - rep.sequence_number = client->sequence; - rep.default_root = pAppGrp->default_root; - rep.root_visual = pAppGrp->root_visual; - rep.default_colormap = pAppGrp->default_colormap; - rep.black_pixel = pAppGrp->black_pixel; - rep.white_pixel = pAppGrp->white_pixel; - rep.single_screen = pAppGrp->single_screen; - rep.app_group_leader = (pAppGrp->leader) ? 1 : 0; - if (client->swapped) { - swaps (&rep.sequence_number, n); - swapl (&rep.length, n); - swapl (&rep.default_root, n); - swapl (&rep.root_visual, n); - swapl (&rep.default_colormap, n); - swapl (&rep.black_pixel, n); - swapl (&rep.white_pixel, n); - } - WriteToClient (client, sizeof (xXagGetAttrReply), (char *)&rep); - return client->noClientException; -} - -static -int ProcXagQuery( - register ClientPtr client) -{ - ClientPtr pClient; - AppGroupPtr pAppGrp; - REQUEST (xXagQueryReq); - int n, rc; - - REQUEST_SIZE_MATCH (xXagQueryReq); - rc = dixLookupClient(&pClient, stuff->resource, client, DixGetAttrAccess); - if (rc != Success) - return rc; - - for (pAppGrp = appGrpList; pAppGrp != NULL; pAppGrp = pAppGrp->next) - for (n = 0; n < pAppGrp->nclients; n++) - if (pAppGrp->clients[n] == pClient) { - xXagQueryReply rep; - - rep.type = X_Reply; - rep.length = 0; - rep.sequence_number = client->sequence; - rep.app_group = pAppGrp->appgroupId; - if (client->swapped) { - swaps (&rep.sequence_number, n); - swapl (&rep.length, n); - swapl (&rep.app_group, n); - } - WriteToClient (client, sizeof (xXagQueryReply), (char *)&rep); - return client->noClientException; - } - - return BadMatch; -} - -static -int ProcXagCreateAssoc( - register ClientPtr client) -{ - REQUEST (xXagCreateAssocReq); - - REQUEST_SIZE_MATCH (xXagCreateAssocReq); -#ifdef WIN32 - if (stuff->window_type != XagWindowTypeWin32) -#else - if (stuff->window_type != XagWindowTypeX11) -#endif - return BadMatch; -#if defined(WIN32) || defined(__CYGWIN__) /* and Mac, etc */ - if (!LocalClient (client)) - return BadAccess; -#endif - -/* Macintosh, OS/2, and MS-Windows servers have some work to do here */ - - return client->noClientException; -} - -static -int ProcXagDestroyAssoc( - register ClientPtr client) -{ - /* REQUEST (xXagDestroyAssocReq); */ - - REQUEST_SIZE_MATCH (xXagDestroyAssocReq); -/* Macintosh, OS/2, and MS-Windows servers have some work to do here */ - return client->noClientException; -} - -static -int ProcXagDispatch ( - register ClientPtr client) -{ - REQUEST (xReq); - switch (stuff->data) - { - case X_XagQueryVersion: - return ProcXagQueryVersion (client); - case X_XagCreate: - return ProcXagCreate (client); - case X_XagDestroy: - return ProcXagDestroy (client); - case X_XagGetAttr: - return ProcXagGetAttr (client); - case X_XagQuery: - return ProcXagQuery (client); - case X_XagCreateAssoc: - return ProcXagCreateAssoc (client); - case X_XagDestroyAssoc: - return ProcXagDestroyAssoc (client); - default: - return BadRequest; - } -} - -static -int SProcXagQueryVersion( - register ClientPtr client) -{ - register int n; - REQUEST(xXagQueryVersionReq); - swaps(&stuff->length, n); - return ProcXagQueryVersion(client); -} - -static -int SProcXagCreate( - ClientPtr client) -{ - register int n; - REQUEST (xXagCreateReq); - swaps (&stuff->length, n); - REQUEST_AT_LEAST_SIZE (xXagCreateReq); - swapl (&stuff->app_group, n); - swapl (&stuff->attrib_mask, n); - SwapRestL (stuff); - return ProcXagCreate (client); -} - -static -int SProcXagDestroy( - ClientPtr client) -{ - register int n; - REQUEST (xXagDestroyReq); - swaps (&stuff->length, n); - REQUEST_SIZE_MATCH (xXagDestroyReq); - swapl (&stuff->app_group, n); - return ProcXagDestroy (client); -} - -static -int SProcXagGetAttr( - ClientPtr client) -{ - register int n; - REQUEST (xXagGetAttrReq); - swaps (&stuff->length, n); - REQUEST_SIZE_MATCH (xXagGetAttrReq); - swapl (&stuff->app_group, n); - return ProcXagGetAttr (client); -} - -static -int SProcXagQuery( - ClientPtr client) -{ - register int n; - REQUEST (xXagQueryReq); - swaps (&stuff->length, n); - REQUEST_SIZE_MATCH (xXagQueryReq); - swapl (&stuff->resource, n); - return ProcXagQuery (client); -} - -static -int SProcXagCreateAssoc( - ClientPtr client) -{ - register int n; - REQUEST (xXagCreateAssocReq); - swaps (&stuff->length, n); - REQUEST_SIZE_MATCH (xXagCreateAssocReq); - swapl (&stuff->window, n); - swapl (&stuff->window_type, n); - swaps (&stuff->system_window_len, n); - return ProcXagCreateAssoc (client); -} - -static -int SProcXagDestroyAssoc( - ClientPtr client) -{ - register int n; - REQUEST (xXagDestroyAssocReq); - swaps (&stuff->length, n); - REQUEST_SIZE_MATCH (xXagDestroyAssocReq); - swapl (&stuff->window, n); - return ProcXagDestroyAssoc (client); -} - -static -int SProcXagDispatch( - register ClientPtr client) -{ - REQUEST(xReq); - switch (stuff->data) - { - case X_XagQueryVersion: - return SProcXagQueryVersion (client); - case X_XagCreate: - return SProcXagCreate (client); - case X_XagDestroy: - return SProcXagDestroy (client); - case X_XagGetAttr: - return SProcXagGetAttr (client); - case X_XagQuery: - return SProcXagQuery (client); - case X_XagCreateAssoc: - return SProcXagCreateAssoc (client); - case X_XagDestroyAssoc: - return SProcXagDestroyAssoc (client); - default: - return BadRequest; - } -} - -Colormap XagDefaultColormap( - ClientPtr client) -{ - return (client->appgroup ? client->appgroup->default_colormap : None); -} - -VisualID XagRootVisual( - ClientPtr client) -{ - return (client->appgroup ? client->appgroup->root_visual : 0); -} - -ClientPtr XagLeader( - ClientPtr client) -{ - return (client->appgroup ? client->appgroup->leader : NULL); -} - -/* - * Return whether the Map request event should be sent to the appgroup leader. - * We don't want to send it to the leader when the window is on a different - * screen, e.g. a print screen. - */ -Bool XagIsControlledRoot( - ClientPtr client, - WindowPtr pParent) -{ - if (client->appgroup) { - if (client->appgroup->single_screen && - pParent->drawable.id == client->appgroup->default_root) - return TRUE; - else if (!pParent->parent) - return TRUE; - else - return FALSE; - } - return FALSE; -} - -void XagConnectionInfo( - ClientPtr client, - xConnSetupPrefix** conn_prefix, - char** conn_info, - int* num_screen) -{ - if (client->appgroup && client->appgroup->ConnectionInfo) { - *conn_prefix = &client->appgroup->connSetupPrefix; - *conn_info = client->appgroup->ConnectionInfo; - *num_screen = ((xConnSetup*)(client->appgroup->ConnectionInfo))->numRoots; - } -} - -XID XagId( - ClientPtr client) -{ - return (client->appgroup ? client->appgroup->appgroupId : 0); -} - -static void XagCallClientStateChange( - CallbackListPtr *pcbl, - pointer nulldata, - pointer calldata) -{ - XaceAuthAvailRec* rec = (XaceAuthAvailRec*) calldata; - ClientPtr pClient = rec->client; - - if (!pClient->appgroup) { - SecurityAuthorizationPtr pAuth; - XID authId = rec->authId; - - /* can't use SecurityLookupIDByType here -- client - * security state hasn't been setup yet. - */ - pAuth = (SecurityAuthorizationPtr)LookupIDByType(authId, - SecurityAuthorizationResType); - if (!pAuth) - return; - - pClient->appgroup = (AppGroupPtr)LookupIDByType(pAuth->group, - RT_APPGROUP); - } - - if (pClient->appgroup) { - NewClientInfoRec clientinfo; - - clientinfo.client = pClient; - XagClientStateChange (NULL, NULL, (pointer)&clientinfo); - } -} - -void -XagExtensionInit(INITARGS) -{ - if (AddExtension (XAGNAME, - 0, - XagNumberErrors, - ProcXagDispatch, - SProcXagDispatch, - XagResetProc, - StandardMinorOpcode)) { - RT_APPGROUP = CreateNewResourceType (XagAppGroupFree); - XaceRegisterCallback(XACE_AUTH_AVAIL, XagCallClientStateChange, NULL); - } -} diff --git a/xorg-server/Xext/appgroup.h b/xorg-server/Xext/appgroup.h deleted file mode 100644 index 778da5de6..000000000 --- a/xorg-server/Xext/appgroup.h +++ /dev/null @@ -1,67 +0,0 @@ -/* -Copyright 1996, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall -not be used in advertising or otherwise to promote the sale, use or -other dealings in this Software without prior written authorization -from The Open Group. -*/ - -#ifndef _APPGROUP_SRV_H_ -#define _APPGROUP_SRV_H_ - -#include <X11/Xfuncproto.h> - -_XFUNCPROTOBEGIN - -extern void XagConnectionInfo( - ClientPtr /* client */, - xConnSetupPrefix** /* conn_prefix */, - char** /* conn_info */, - int* /* num_screens */ -); - -extern VisualID XagRootVisual( - ClientPtr /* client */ -); - -extern Colormap XagDefaultColormap( - ClientPtr /* client */ -); - -extern ClientPtr XagLeader( - ClientPtr /* client */ -); - -extern Bool XagIsControlledRoot ( - ClientPtr /* client */, - WindowPtr /* pParent */ -); - -extern XID XagId ( - ClientPtr /* client */ -); - -_XFUNCPROTOEND - -#endif /* _APPGROUP_SRV_H_ */ - - - diff --git a/xorg-server/Xext/bigreq.c b/xorg-server/Xext/bigreq.c index 4f0724bc1..1e807d820 100644 --- a/xorg-server/Xext/bigreq.c +++ b/xorg-server/Xext/bigreq.c @@ -41,10 +41,6 @@ from The Open Group. #include "opaque.h" #include "modinit.h" -static void BigReqResetProc( - ExtensionEntry * /* extEntry */ -); - static DISPATCH_PROC(ProcBigReqDispatch); void @@ -52,23 +48,16 @@ BigReqExtensionInit(INITARGS) { AddExtension(XBigReqExtensionName, 0, 0, ProcBigReqDispatch, ProcBigReqDispatch, - BigReqResetProc, StandardMinorOpcode); -} - -/*ARGSUSED*/ -static void -BigReqResetProc (extEntry) - ExtensionEntry *extEntry; -{ + NULL, StandardMinorOpcode); } static int ProcBigReqDispatch (client) - register ClientPtr client; + ClientPtr client; { REQUEST(xBigReqEnableReq); xBigReqEnableReply rep; - register int n; + int n; if (client->swapped) { swaps(&stuff->length, n); diff --git a/xorg-server/Xext/cup.c b/xorg-server/Xext/cup.c deleted file mode 100644 index fd1409e33..000000000 --- a/xorg-server/Xext/cup.c +++ /dev/null @@ -1,342 +0,0 @@ -/* - -Copyright 1997, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -#define NEED_REPLIES -#define NEED_EVENTS -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include <X11/X.h> -#include <X11/Xproto.h> -#include "misc.h" -#include "dixstruct.h" -#include "extnsionst.h" -#include "colormapst.h" -#include "scrnintstr.h" -#include "servermd.h" -#include "swapreq.h" -#define _XCUP_SERVER_ -#include <X11/extensions/Xcupstr.h> -#include <X11/Xfuncproto.h> - -#include "../os/osdep.h" - -#include "modinit.h" - -static int ProcDispatch(ClientPtr client); -static int SProcDispatch(ClientPtr client); -static void ResetProc(ExtensionEntry* extEntry); - -#if defined(WIN32) || defined(TESTWIN32) -#define HAVE_SPECIAL_DESKTOP_COLORS -#endif - -static xColorItem citems[] = { -#ifndef HAVE_SPECIAL_DESKTOP_COLORS -#define CUP_BLACK_PIXEL 0 -#define CUP_WHITE_PIXEL 1 - /* pix red green blue */ - { 0, 0, 0, 0, 0, 0 }, - { 1, 0xffff, 0xffff, 0xffff, 0, 0 } -#else -#ifndef WIN32 - /* - This approximates the MS-Windows desktop colormap for testing - purposes but has black and white pixels in the typical Unix - locations, which should be switched if necessary if your system - has blackPixel and whitePixel swapped. No entries are provided - for colormap entries 254 and 255 because AllocColor/FindColor - will reuse entries zero and one. - */ - { 0, 0, 0, 0, 0, 0 }, - { 1, 0xffff, 0xffff, 0xffff, 0, 0 }, - { 2, 0x8000, 0, 0, 0, 0 }, - { 3, 0, 0x8000, 0, 0, 0 }, - { 4, 0x8000, 0x8000, 0, 0, 0 }, - { 5, 0, 0, 0x8000, 0, 0 }, - { 6, 0x8000, 0, 0x8000, 0, 0 }, - { 7, 0, 0x8000, 0x8000, 0, 0 }, - { 8, 0xc000, 0xc000, 0xc000, 0, 0 }, - { 9, 0xc000, 0xdc00, 0xc000, 0, 0 }, - { 246, 0xa000, 0xa000, 0xa000, 0, 0 }, - { 247, 0x8000, 0x8000, 0x8000, 0, 0 }, - { 248, 0xffff, 0, 0, 0, 0 }, - { 249, 0, 0xffff, 0, 0, 0 }, - { 250, 0xffff, 0xffff, 0, 0, 0 }, - { 251, 0, 0, 0xffff, 0, 0 }, - { 252, 0xffff, 0, 0xffff, 0, 0 }, - { 253, 0, 0xffff, 0xffff, 0, 0 } -#else - /* - this is the MS-Windows desktop, adjusted for X's 16-bit color - specifications. - */ - { 0, 0, 0, 0, 0, 0 }, - { 1, 0x8000, 0, 0, 0, 0 }, - { 2, 0, 0x8000, 0, 0, 0 }, - { 3, 0x8000, 0x8000, 0, 0, 0 }, - { 4, 0, 0, 0x8000, 0, 0 }, - { 5, 0x8000, 0, 0x8000, 0, 0 }, - { 6, 0, 0x8000, 0x8000, 0, 0 }, - { 7, 0xc000, 0xc000, 0xc000, 0, 0 }, - { 8, 0xc000, 0xdc00, 0xc000, 0, 0 }, - { 9, 0xa600, 0xca00, 0xf000, 0, 0 }, - { 246, 0xff00, 0xfb00, 0xf000, 0, 0 }, - { 247, 0xa000, 0xa000, 0xa400, 0, 0 }, - { 248, 0x8000, 0x8000, 0x8000, 0, 0 }, - { 249, 0xff00, 0, 0, 0, 0 }, - { 250, 0, 0xff00, 0, 0, 0 }, - { 251, 0xff00, 0xff00, 0, 0, 0 }, - { 252, 0, 0, 0xff00, 0, 0 }, - { 253, 0xff00, 0, 0xff00, 0, 0 }, - { 254, 0, 0xff00, 0xff00, 0, 0 }, - { 255, 0xff00, 0xff00, 0xff00, 0, 0 } -#endif -#endif -}; -#define NUM_DESKTOP_COLORS (sizeof citems / sizeof citems[0]) - -void -XcupExtensionInit (INITARGS) -{ - (void) AddExtension (XCUPNAME, - 0, - XcupNumberErrors, - ProcDispatch, - SProcDispatch, - ResetProc, - StandardMinorOpcode); - - /* PC servers initialize the desktop colors (citems) here! */ -} - -/*ARGSUSED*/ -static -void ResetProc( - ExtensionEntry* extEntry) -{ -} - -static -int ProcQueryVersion( - register ClientPtr client) -{ - /* REQUEST (xXcupQueryVersionReq); */ - xXcupQueryVersionReply rep; - register int n; - - REQUEST_SIZE_MATCH (xXcupQueryVersionReq); - rep.type = X_Reply; - rep.length = 0; - rep.sequence_number = client->sequence; - rep.server_major_version = XCUP_MAJOR_VERSION; - rep.server_minor_version = XCUP_MINOR_VERSION; - if (client->swapped) { - swaps (&rep.sequence_number, n); - swapl (&rep.length, n); - swaps (&rep.server_major_version, n); - swaps (&rep.server_minor_version, n); - } - WriteToClient (client, sizeof (xXcupQueryVersionReply), (char *)&rep); - return client->noClientException; -} - -static -int ProcGetReservedColormapEntries( - register ClientPtr client) -{ - REQUEST (xXcupGetReservedColormapEntriesReq); - xXcupGetReservedColormapEntriesReply rep; - xColorItem* cptr; - register int n; - - REQUEST_SIZE_MATCH (xXcupGetReservedColormapEntriesReq); - - if (stuff->screen >= screenInfo.numScreens) - return BadValue; - -#ifndef HAVE_SPECIAL_DESKTOP_COLORS - citems[CUP_BLACK_PIXEL].pixel = - screenInfo.screens[stuff->screen]->blackPixel; - citems[CUP_WHITE_PIXEL].pixel = - screenInfo.screens[stuff->screen]->whitePixel; -#endif - - rep.type = X_Reply; - rep.sequence_number = client->sequence; - rep.length = NUM_DESKTOP_COLORS * 3; - if (client->swapped) { - swaps (&rep.sequence_number, n); - swapl (&rep.length, n); - } - WriteToClient (client, sizeof (xXcupGetReservedColormapEntriesReply), (char *)&rep); - for (n = 0, cptr = citems; n < NUM_DESKTOP_COLORS; n++, cptr++) { - if (client->swapped) SwapColorItem (cptr); - WriteToClient (client, SIZEOF(xColorItem), (char *)cptr); - } - return client->noClientException; -} - -static -int ProcStoreColors( - register ClientPtr client) -{ - REQUEST (xXcupStoreColorsReq); - ColormapPtr pcmp; - int rc; - - REQUEST_AT_LEAST_SIZE (xXcupStoreColorsReq); - rc = dixLookupResource((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, - client, DixAddAccess); - - if (rc == Success) { - int ncolors, n; - xXcupStoreColorsReply rep; - xColorItem* cptr; - - if (!(pcmp->class & DynamicClass)) - return BadMatch; - - ncolors = (client->req_len << 2) - SIZEOF (xXcupStoreColorsReq); - if (ncolors % SIZEOF(xColorItem)) - return BadLength; - - ncolors /= SIZEOF (xColorItem); - - - for (n = 0, cptr = (xColorItem*) &stuff[1]; n < ncolors; n++) { - Pixel pixel = cptr->pixel; - - if (AllocColor (pcmp, - &cptr->red, &cptr->green, &cptr->blue, - &pixel, client->index) == Success) { - cptr->pixel = pixel; - cptr->flags = 0x08; - } else - cptr->flags = 0; - cptr = (xColorItem*) (((char*)cptr) + SIZEOF(xColorItem)); - } - - rep.type = X_Reply; - rep.sequence_number = client->sequence; - rep.length = ncolors * 3; - if (client->swapped) { - swaps (&rep.sequence_number, n); - swapl (&rep.length, n); - } - WriteToClient (client, sizeof (xXcupGetReservedColormapEntriesReply), (char *)&rep); - for (n = 0, cptr = (xColorItem*) &stuff[1]; n < ncolors; n++) { - if (client->swapped) SwapColorItem (cptr); - WriteToClient (client, SIZEOF(xColorItem), (char *)cptr); - cptr = (xColorItem*) (((char*)cptr) + SIZEOF(xColorItem)); - } - return client->noClientException; - } else { - client->errorValue = stuff->cmap; - return (rc == BadValue) ? BadColor : rc; - } -} - -static -int ProcDispatch( - register ClientPtr client) -{ - REQUEST (xReq); - switch (stuff->data) - { - case X_XcupQueryVersion: - return ProcQueryVersion (client); - case X_XcupGetReservedColormapEntries: - return ProcGetReservedColormapEntries (client); - case X_XcupStoreColors: - return ProcStoreColors (client); - default: - return BadRequest; - } -} - -static -int SProcQueryVersion( - register ClientPtr client) -{ - register int n; - - REQUEST(xXcupQueryVersionReq); - swaps(&stuff->length, n); - return ProcQueryVersion(client); -} - -static -int SProcGetReservedColormapEntries( - ClientPtr client) -{ - register int n; - - REQUEST (xXcupGetReservedColormapEntriesReq); - swaps (&stuff->length, n); - swapl (&stuff->screen, n); - REQUEST_AT_LEAST_SIZE (xXcupGetReservedColormapEntriesReq); - return ProcGetReservedColormapEntries (client); -} - -static -int SProcXcupStoreColors( - ClientPtr client) -{ - register int n; - int count; - xColorItem* pItem; - - REQUEST (xXcupStoreColorsReq); - swaps (&stuff->length, n); - REQUEST_AT_LEAST_SIZE (xXcupStoreColorsReq); - swapl(&stuff->cmap, n); - pItem = (xColorItem*) &stuff[1]; - for(count = LengthRestB(stuff)/sizeof(xColorItem); --count >= 0; ) - SwapColorItem(pItem++); - return ProcStoreColors (client); -} - -static -int SProcDispatch( - register ClientPtr client) -{ - REQUEST(xReq); - switch (stuff->data) - { - case X_XcupQueryVersion: - return SProcQueryVersion (client); - case X_XcupGetReservedColormapEntries: - return SProcGetReservedColormapEntries (client); - case X_XcupStoreColors: - return SProcXcupStoreColors (client); - default: - return BadRequest; - } -} - - diff --git a/xorg-server/Xext/dpms.c b/xorg-server/Xext/dpms.c index be11fd76a..06425993b 100644 --- a/xorg-server/Xext/dpms.c +++ b/xorg-server/Xext/dpms.c @@ -70,30 +70,22 @@ static DISPATCH_PROC(ProcDPMSInfo); static DISPATCH_PROC(SProcDPMSInfo); static DISPATCH_PROC(ProcDPMSCapable); static DISPATCH_PROC(SProcDPMSCapable); -static void DPMSResetProc(ExtensionEntry* extEntry); void DPMSExtensionInit(INITARGS) { AddExtension(DPMSExtensionName, 0, 0, ProcDPMSDispatch, SProcDPMSDispatch, - DPMSResetProc, StandardMinorOpcode); -} - -/*ARGSUSED*/ -static void -DPMSResetProc (extEntry) - ExtensionEntry *extEntry; -{ + NULL, StandardMinorOpcode); } static int ProcDPMSGetVersion(client) - register ClientPtr client; + ClientPtr client; { /* REQUEST(xDPMSGetVersionReq); */ xDPMSGetVersionReply rep; - register int n; + int n; REQUEST_SIZE_MATCH(xDPMSGetVersionReq); @@ -112,11 +104,11 @@ ProcDPMSGetVersion(client) } static int -ProcDPMSCapable(register ClientPtr client) +ProcDPMSCapable(ClientPtr client) { /* REQUEST(xDPMSCapableReq); */ xDPMSCapableReply rep; - register int n; + int n; REQUEST_SIZE_MATCH(xDPMSCapableReq); @@ -134,11 +126,11 @@ ProcDPMSCapable(register ClientPtr client) static int ProcDPMSGetTimeouts(client) - register ClientPtr client; + ClientPtr client; { /* REQUEST(xDPMSGetTimeoutsReq); */ xDPMSGetTimeoutsReply rep; - register int n; + int n; REQUEST_SIZE_MATCH(xDPMSGetTimeoutsReq); @@ -161,7 +153,7 @@ ProcDPMSGetTimeouts(client) static int ProcDPMSSetTimeouts(client) - register ClientPtr client; + ClientPtr client; { REQUEST(xDPMSSetTimeoutsReq); @@ -188,7 +180,7 @@ ProcDPMSSetTimeouts(client) static int ProcDPMSEnable(client) - register ClientPtr client; + ClientPtr client; { Bool was_enabled = DPMSEnabled; @@ -205,7 +197,7 @@ ProcDPMSEnable(client) static int ProcDPMSDisable(client) - register ClientPtr client; + ClientPtr client; { /* REQUEST(xDPMSDisableReq); */ @@ -220,7 +212,7 @@ ProcDPMSDisable(client) static int ProcDPMSForceLevel(client) - register ClientPtr client; + ClientPtr client; { REQUEST(xDPMSForceLevelReq); @@ -252,11 +244,11 @@ ProcDPMSForceLevel(client) } static int -ProcDPMSInfo(register ClientPtr client) +ProcDPMSInfo(ClientPtr client) { /* REQUEST(xDPMSInfoReq); */ xDPMSInfoReply rep; - register int n; + int n; REQUEST_SIZE_MATCH(xDPMSInfoReq); @@ -276,7 +268,7 @@ ProcDPMSInfo(register ClientPtr client) static int ProcDPMSDispatch (client) - register ClientPtr client; + ClientPtr client; { REQUEST(xReq); @@ -305,9 +297,9 @@ ProcDPMSDispatch (client) static int SProcDPMSGetVersion(client) - register ClientPtr client; + ClientPtr client; { - register int n; + int n; REQUEST(xDPMSGetVersionReq); swaps(&stuff->length, n); @@ -318,10 +310,10 @@ SProcDPMSGetVersion(client) } static int -SProcDPMSCapable(register ClientPtr client) +SProcDPMSCapable(ClientPtr client) { REQUEST(xDPMSCapableReq); - register int n; + int n; swaps(&stuff->length, n); REQUEST_SIZE_MATCH(xDPMSCapableReq); @@ -331,10 +323,10 @@ SProcDPMSCapable(register ClientPtr client) static int SProcDPMSGetTimeouts(client) - register ClientPtr client; + ClientPtr client; { REQUEST(xDPMSGetTimeoutsReq); - register int n; + int n; swaps(&stuff->length, n); REQUEST_SIZE_MATCH(xDPMSGetTimeoutsReq); @@ -344,10 +336,10 @@ SProcDPMSGetTimeouts(client) static int SProcDPMSSetTimeouts(client) - register ClientPtr client; + ClientPtr client; { REQUEST(xDPMSSetTimeoutsReq); - register int n; + int n; swaps(&stuff->length, n); REQUEST_SIZE_MATCH(xDPMSSetTimeoutsReq); @@ -360,10 +352,10 @@ SProcDPMSSetTimeouts(client) static int SProcDPMSEnable(client) - register ClientPtr client; + ClientPtr client; { REQUEST(xDPMSEnableReq); - register int n; + int n; swaps(&stuff->length, n); REQUEST_SIZE_MATCH(xDPMSEnableReq); @@ -373,10 +365,10 @@ SProcDPMSEnable(client) static int SProcDPMSDisable(client) - register ClientPtr client; + ClientPtr client; { REQUEST(xDPMSDisableReq); - register int n; + int n; swaps(&stuff->length, n); REQUEST_SIZE_MATCH(xDPMSDisableReq); @@ -386,10 +378,10 @@ SProcDPMSDisable(client) static int SProcDPMSForceLevel(client) - register ClientPtr client; + ClientPtr client; { REQUEST(xDPMSForceLevelReq); - register int n; + int n; swaps(&stuff->length, n); REQUEST_SIZE_MATCH(xDPMSForceLevelReq); @@ -401,10 +393,10 @@ SProcDPMSForceLevel(client) static int SProcDPMSInfo(client) - register ClientPtr client; + ClientPtr client; { REQUEST(xDPMSInfoReq); - register int n; + int n; swaps(&stuff->length, n); REQUEST_SIZE_MATCH(xDPMSInfoReq); @@ -414,7 +406,7 @@ SProcDPMSInfo(client) static int SProcDPMSDispatch (client) - register ClientPtr client; + ClientPtr client; { REQUEST(xReq); switch (stuff->data) diff --git a/xorg-server/Xext/fontcache.c b/xorg-server/Xext/fontcache.c deleted file mode 100644 index 0338d4a0f..000000000 --- a/xorg-server/Xext/fontcache.c +++ /dev/null @@ -1,323 +0,0 @@ -/*- - * Copyright (c) 1998-1999 Shunsuke Akiyama <akiyama@jp.FreeBSD.org>. - * All rights reserved. - * Copyright (c) 1998-1999 X-TrueType Server Project, All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* THIS IS NOT AN X CONSORTIUM STANDARD */ - -#define NEED_REPLIES -#define NEED_EVENTS -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include <X11/X.h> -#include <X11/Xproto.h> -#include "misc.h" -#include "dixstruct.h" -#include "extnsionst.h" -#include "scrnintstr.h" -#include "inputstr.h" -#include "servermd.h" -#define _FONTCACHE_SERVER_ -#include <X11/extensions/fontcacheP.h> -#include <X11/extensions/fontcachstr.h> -#include <X11/Xfuncproto.h> - -#include "swaprep.h" -#include "modinit.h" - -static int miscErrorBase; - -static void FontCacheResetProc( - ExtensionEntry* /* extEntry */ -); - -static DISPATCH_PROC(ProcFontCacheDispatch); -static DISPATCH_PROC(ProcFontCacheGetCacheSettings); -static DISPATCH_PROC(ProcFontCacheGetCacheStatistics); -static DISPATCH_PROC(ProcFontCacheQueryVersion); -static DISPATCH_PROC(ProcFontCacheChangeCacheSettings); -static DISPATCH_PROC(SProcFontCacheDispatch); -static DISPATCH_PROC(SProcFontCacheGetCacheSettings); -static DISPATCH_PROC(SProcFontCacheGetCacheStatistics); -static DISPATCH_PROC(SProcFontCacheQueryVersion); -static DISPATCH_PROC(SProcFontCacheChangeCacheSettings); - -void -FontCacheExtensionInit(INITARGS) -{ - ExtensionEntry* extEntry; - - if ( - (extEntry = AddExtension(FONTCACHENAME, - FontCacheNumberEvents, - FontCacheNumberErrors, - ProcFontCacheDispatch, - SProcFontCacheDispatch, - FontCacheResetProc, - StandardMinorOpcode))) { - miscErrorBase = extEntry->errorBase; - } -} - -/*ARGSUSED*/ -static void -FontCacheResetProc (extEntry) - ExtensionEntry* extEntry; -{ -} - -static int -ProcFontCacheQueryVersion(client) - register ClientPtr client; -{ - xFontCacheQueryVersionReply rep; - register int n; - - REQUEST_SIZE_MATCH(xFontCacheQueryVersionReq); - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - rep.majorVersion = FONTCACHE_MAJOR_VERSION; - rep.minorVersion = FONTCACHE_MINOR_VERSION; - if (client->swapped) { - swaps(&rep.sequenceNumber, n); - swapl(&rep.length, n); - swaps(&rep.majorVersion, n); - swaps(&rep.minorVersion, n); - } - WriteToClient(client, SIZEOF(xFontCacheQueryVersionReply), (char *)&rep); - return (client->noClientException); -} - -static int -ProcFontCacheGetCacheSettings(client) - register ClientPtr client; -{ - xFontCacheGetCacheSettingsReply rep; - FontCacheSettings cinfo; - register int n; - - REQUEST_SIZE_MATCH(xFontCacheGetCacheSettingsReq); - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.length = 0; - - /* XXX */ - FontCacheGetSettings(&cinfo); - rep.himark = cinfo.himark; - rep.lowmark = cinfo.lowmark; - rep.balance = cinfo.balance; - rep.reserve0 = 0; - rep.reserve1 = 0; - rep.reserve2 = 0; - - if (client->swapped) { - swaps(&rep.sequenceNumber, n); - swapl(&rep.himark, n); - swapl(&rep.lowmark, n); - swapl(&rep.balance, n); - swapl(&rep.reserve0, n); - swapl(&rep.reserve1, n); - swapl(&rep.reserve2, n); - } - /* XXX */ - - WriteToClient(client, SIZEOF(xFontCacheGetCacheSettingsReply), - (char *)&rep); - return (client->noClientException); -} - -static int -ProcFontCacheGetCacheStatistics(client) - register ClientPtr client; -{ - xFontCacheGetCacheStatisticsReply rep; - FontCacheStatistics cstats; - register int n; - - REQUEST_SIZE_MATCH(xFontCacheGetCacheStatisticsReq); - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.length = (sz_xFontCacheGetCacheStatisticsReply - 32) >> 2; - - /* XXX */ - FontCacheGetStatistics(&cstats); - rep.purge_runs = cstats.purge_runs; - rep.purge_stat = cstats.purge_stat; - rep.balance = cstats.balance; - rep.reserve0 = 0; - rep.f_hits = cstats.f.hits; - rep.f_misshits = cstats.f.misshits; - rep.f_purged = cstats.f.purged; - rep.f_usage = cstats.f.usage; - rep.f_reserve0 = 0; - rep.v_hits = cstats.v.hits; - rep.v_misshits = cstats.v.misshits; - rep.v_purged = cstats.v.purged; - rep.v_usage = cstats.v.usage; - rep.v_reserve0 = 0; - if (client->swapped) { - swaps(&rep.sequenceNumber, n); - swapl(&rep.length, n); - swapl(&rep.purge_runs, n); - swapl(&rep.purge_stat, n); - swapl(&rep.balance, n); - swapl(&rep.reserve0, n); - swapl(&rep.f_hits, n); - swapl(&rep.f_misshits, n); - swapl(&rep.f_purged, n); - swapl(&rep.f_usage, n); - swapl(&rep.f_reserve0, n); - swapl(&rep.v_hits, n); - swapl(&rep.v_misshits, n); - swapl(&rep.v_purged, n); - swapl(&rep.v_usage, n); - swapl(&rep.v_reserve0, n); - } - /* XXX */ - WriteToClient(client, SIZEOF(xFontCacheGetCacheStatisticsReply), - (char *)&rep); - return (client->noClientException); -} - -static int -ProcFontCacheChangeCacheSettings(client) - register ClientPtr client; -{ - FontCacheSettings cs; - - REQUEST(xFontCacheChangeCacheSettingsReq); - - REQUEST_SIZE_MATCH(xFontCacheChangeCacheSettingsReq); - - /* XXX */ - cs.himark = stuff->himark; - cs.lowmark = stuff->lowmark; - cs.balance = stuff->balance; - - if (cs.himark < 0 || cs.lowmark < 0) - return BadValue; - if (cs.himark <= cs.lowmark) - return BadValue; - if (!(10 <= cs.balance && cs.balance <= 90)) - return BadValue; - - if (FontCacheChangeSettings(&cs) == 0) - return miscErrorBase + FontCacheCannotAllocMemory; - /* XXX */ - - return (client->noClientException); -} - -static int -ProcFontCacheDispatch (client) - register ClientPtr client; -{ - REQUEST(xReq); - switch (stuff->data) - { - case X_FontCacheQueryVersion: - return ProcFontCacheQueryVersion(client); - case X_FontCacheGetCacheSettings: - return ProcFontCacheGetCacheSettings(client); - case X_FontCacheGetCacheStatistics: - return ProcFontCacheGetCacheStatistics(client); - case X_FontCacheChangeCacheSettings: - return ProcFontCacheChangeCacheSettings(client); - default: - return miscErrorBase + FontCacheBadProtocol; - } -} - -static int -SProcFontCacheQueryVersion(client) - register ClientPtr client; -{ - register int n; - REQUEST(xFontCacheQueryVersionReq); - swaps(&stuff->length, n); - return ProcFontCacheQueryVersion(client); -} - -static int -SProcFontCacheGetCacheSettings(client) - ClientPtr client; -{ - register int n; - REQUEST(xFontCacheGetCacheSettingsReq); - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xFontCacheGetCacheSettingsReq); - return ProcFontCacheGetCacheSettings(client); -} - -static int -SProcFontCacheGetCacheStatistics(client) - ClientPtr client; -{ - register int n; - REQUEST(xFontCacheGetCacheStatisticsReq); - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xFontCacheGetCacheStatisticsReq); - return ProcFontCacheGetCacheStatistics(client); -} - -static int -SProcFontCacheChangeCacheSettings(client) - ClientPtr client; -{ - register int n; - REQUEST(xFontCacheChangeCacheSettingsReq); - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xFontCacheChangeCacheSettingsReq); - /* XXX */ - swapl(&stuff->himark, n); - swapl(&stuff->lowmark, n); - swapl(&stuff->balance, n); - /* XXX */ - return ProcFontCacheChangeCacheSettings(client); -} - -static int -SProcFontCacheDispatch (client) - register ClientPtr client; -{ - REQUEST(xReq); - switch (stuff->data) - { - case X_FontCacheQueryVersion: - return SProcFontCacheQueryVersion(client); - case X_FontCacheGetCacheSettings: - return SProcFontCacheGetCacheSettings(client); - case X_FontCacheGetCacheStatistics: - return SProcFontCacheGetCacheStatistics(client); - case X_FontCacheChangeCacheSettings: - return SProcFontCacheChangeCacheSettings(client); - default: - return miscErrorBase + FontCacheBadProtocol; - } -} diff --git a/xorg-server/Xext/geext.c b/xorg-server/Xext/geext.c new file mode 100644 index 000000000..7ab99517d --- /dev/null +++ b/xorg-server/Xext/geext.c @@ -0,0 +1,474 @@ +/* + * Copyright 2007-2008 Peter Hutterer + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Author: Peter Hutterer, University of South Australia, NICTA + */ + +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif +#include "windowstr.h" +#include <X11/extensions/ge.h> +#include "registry.h" + +#include "geint.h" +#include "geext.h" + +/* Currently supported XGE version */ +#define SERVER_GE_MAJOR 1 +#define SERVER_GE_MINOR 0 + +#define rClient(obj) (clients[CLIENT_ID((obj)->resource)]) + +int GEEventBase; +int GEErrorBase; +static int GEClientPrivateKeyIndex; +DevPrivateKey GEClientPrivateKey = &GEClientPrivateKeyIndex; +int GEEventType; /* The opcode for all GenericEvents will have. */ + +int RT_GECLIENT = 0; + + +GEExtension GEExtensions[MAXEXTENSIONS]; + +/* Major available requests */ +static const int version_requests[] = { + X_GEQueryVersion, /* before client sends QueryVersion */ + X_GEQueryVersion, /* must be set to last request in version 1 */ +}; + +/* Forward declarations */ +static void SGEGenericEvent(xEvent* from, xEvent* to); +static void GERecalculateWinMask(WindowPtr pWin); + +#define NUM_VERSION_REQUESTS (sizeof (version_requests) / sizeof (version_requests[0])) + +/************************************************************/ +/* request handlers */ +/************************************************************/ + +static int +ProcGEQueryVersion(ClientPtr client) +{ + int n; + GEClientInfoPtr pGEClient = GEGetClient(client); + xGEQueryVersionReply rep; + REQUEST(xGEQueryVersionReq); + + REQUEST_SIZE_MATCH(xGEQueryVersionReq); + + rep.repType = X_Reply; + rep.RepType = X_GEQueryVersion; + rep.length = 0; + rep.sequenceNumber = client->sequence; + + /* return the supported version by the server */ + rep.majorVersion = SERVER_GE_MAJOR; + rep.minorVersion = SERVER_GE_MINOR; + + /* Remember version the client requested */ + pGEClient->major_version = stuff->majorVersion; + pGEClient->minor_version = stuff->minorVersion; + + if (client->swapped) + { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swaps(&rep.majorVersion, n); + swaps(&rep.minorVersion, n); + } + + WriteToClient(client, sizeof(xGEQueryVersionReply), (char*)&rep); + return(client->noClientException); +} + +int (*ProcGEVector[GENumberRequests])(ClientPtr) = { + /* Version 1.0 */ + ProcGEQueryVersion +}; + +/************************************************************/ +/* swapped request handlers */ +/************************************************************/ +static int +SProcGEQueryVersion(ClientPtr client) +{ + int n; + REQUEST(xGEQueryVersionReq); + + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xGEQueryVersionReq); + swaps(&stuff->majorVersion, n); + swaps(&stuff->minorVersion, n); + return(*ProcGEVector[stuff->ReqType])(client); +} + +int (*SProcGEVector[GENumberRequests])(ClientPtr) = { + /* Version 1.0 */ + SProcGEQueryVersion +}; + + +/************************************************************/ +/* callbacks */ +/************************************************************/ + +/* dispatch requests */ +static int +ProcGEDispatch(ClientPtr client) +{ + GEClientInfoPtr pGEClient = GEGetClient(client); + REQUEST(xGEReq); + + if (pGEClient->major_version >= NUM_VERSION_REQUESTS) + return BadRequest; + if (stuff->ReqType > version_requests[pGEClient->major_version]) + return BadRequest; + + return (ProcGEVector[stuff->ReqType])(client); +} + +/* dispatch swapped requests */ +static int +SProcGEDispatch(ClientPtr client) +{ + REQUEST(xGEReq); + if (stuff->ReqType >= GENumberRequests) + return BadRequest; + return (*SProcGEVector[stuff->ReqType])(client); +} + +/** + * Called when a new client inits a connection to the X server. + * + * We alloc a simple struct to store the client's major/minor version. Can be + * used in the furture for versioning support. + */ +static void +GEClientCallback(CallbackListPtr *list, + pointer closure, + pointer data) +{ + NewClientInfoRec *clientinfo = (NewClientInfoRec *) data; + ClientPtr pClient = clientinfo->client; + GEClientInfoPtr pGEClient = GEGetClient(pClient); + + if (pGEClient == NULL) + { + pGEClient = xcalloc(1, sizeof(GEClientInfoRec)); + dixSetPrivate(&pClient->devPrivates, GEClientPrivateKey, pGEClient); + } + + pGEClient->major_version = 0; + pGEClient->minor_version = 0; +} + +/* Reset extension. Called on server shutdown. */ +static void +GEResetProc(ExtensionEntry *extEntry) +{ + DeleteCallback(&ClientStateCallback, GEClientCallback, 0); + EventSwapVector[GenericEvent] = NotImplemented; + + GEEventBase = 0; + GEErrorBase = 0; + GEEventType = 0; +} + +/* Calls the registered event swap function for the extension. + * + * Each extension can register a swap function to handle GenericEvents being + * swapped properly. The server calls SGEGenericEvent() before the event is + * written on the wire, this one calls the registered swap function to do the + * work. + */ +static void +SGEGenericEvent(xEvent* from, xEvent* to) +{ + xGenericEvent* gefrom = (xGenericEvent*)from; + xGenericEvent* geto = (xGenericEvent*)to; + + if (gefrom->extension > MAXEXTENSIONS) + { + ErrorF("GE: Invalid extension offset for event.\n"); + return; + } + + if (GEExtensions[gefrom->extension & 0x7F].evswap) + GEExtensions[gefrom->extension & 0x7F].evswap(gefrom, geto); +} + +/** + * Resource callback, invoked when the client disconnects and the associated + * GE masks must be destroyed. + */ +static int +GEClientGone(WindowPtr pWin, XID id) +{ + GenericClientMasksPtr gclmask; + GenericMaskPtr gmask, prev = NULL; + + if (!pWin || !pWin->optional) + return Success; + + gclmask = pWin->optional->geMasks; + for (gmask = gclmask->geClients; gmask; gmask = gmask->next) + { + if (gmask->resource == id) + { + if (prev) + { + prev->next = gmask->next; + xfree(gmask); + } else { + gclmask->geClients = NULL; + CheckWindowOptionalNeed(pWin); + GERecalculateWinMask(pWin); + xfree(gmask); + } + return Success; + } + prev = gmask; + } + + FatalError("Client not a GE client"); + return BadImplementation; +} + +/* Init extension, register at server. + * Since other extensions may rely on XGE (XInput does already), it is a good + * idea to init XGE first, before any other extension. + */ +void +GEExtensionInit(void) +{ + ExtensionEntry *extEntry; + + if(!AddCallback(&ClientStateCallback, GEClientCallback, 0)) + { + FatalError("GEExtensionInit: register client callback failed.\n"); + } + + if((extEntry = AddExtension(GE_NAME, + GENumberEvents, GENumberErrors, + ProcGEDispatch, SProcGEDispatch, + GEResetProc, StandardMinorOpcode)) != 0) + { + GEEventBase = extEntry->eventBase; + GEErrorBase = extEntry->errorBase; + GEEventType = GEEventBase; + + RT_GECLIENT = CreateNewResourceType((DeleteType)GEClientGone); + RegisterResourceName(RT_GECLIENT, "GECLIENT"); + + memset(GEExtensions, 0, sizeof(GEExtensions)); + + EventSwapVector[GenericEvent] = (EventSwapPtr) SGEGenericEvent; + } else { + FatalError("GEInit: AddExtensions failed.\n"); + } + +} + +/************************************************************/ +/* interface for extensions */ +/************************************************************/ + +/* Register an extension with GE. The given swap function will be called each + * time an event is sent to a client with different byte order. + * @param extension The extensions major opcode + * @param ev_swap The event swap function. + * @param ev_fill Called for an event before delivery. The extension now has + * the chance to fill in necessary fields for the event. + */ +void +GERegisterExtension(int extension, + void (*ev_swap)(xGenericEvent* from, xGenericEvent* to), + void (*ev_fill)(xGenericEvent* ev, DeviceIntPtr pDev, + WindowPtr pWin, GrabPtr pGrab)) +{ + if ((extension & 0x7F) >= MAXEXTENSIONS) + FatalError("GE: extension > MAXEXTENSIONS. This should not happen.\n"); + + /* extension opcodes are > 128, might as well save some space here */ + GEExtensions[extension & 0x7f].evswap = ev_swap; + GEExtensions[extension & 0x7f].evfill = ev_fill; +} + + +/* Sets type and extension field for a generic event. This is just an + * auxiliary function, extensions could do it manually too. + */ +void +GEInitEvent(xGenericEvent* ev, int extension) +{ + ev->type = GenericEvent; + ev->extension = extension; + ev->length = 0; +} + +/* Recalculates the summary mask for the window. */ +static void +GERecalculateWinMask(WindowPtr pWin) +{ + int i; + GenericMaskPtr it; + GenericClientMasksPtr evmasks; + + if (!pWin->optional) + return; + + evmasks = pWin->optional->geMasks; + + for (i = 0; i < MAXEXTENSIONS; i++) + { + evmasks->eventMasks[i] = 0; + } + + it = pWin->optional->geMasks->geClients; + while(it) + { + for (i = 0; i < MAXEXTENSIONS; i++) + { + evmasks->eventMasks[i] |= it->eventMask[i]; + } + it = it->next; + } +} + +/* Set generic event mask for given window. */ +void +GEWindowSetMask(ClientPtr pClient, DeviceIntPtr pDev, + WindowPtr pWin, int extension, Mask mask) +{ + GenericMaskPtr cli; + + extension = (extension & 0x7F); + + if (extension >= MAXEXTENSIONS) + { + ErrorF("Invalid extension number.\n"); + return; + } + + if (!pWin->optional && !MakeWindowOptional(pWin)) + { + ErrorF("GE: Could not make window optional.\n"); + return; + } + + if (mask) + { + GenericClientMasksPtr evmasks = pWin->optional->geMasks; + + /* check for existing client */ + cli = evmasks->geClients; + while(cli) + { + if (rClient(cli) == pClient && cli->dev == pDev) + break; + cli = cli->next; + } + if (!cli) + { + /* new client and/or new device */ + cli = (GenericMaskPtr)xcalloc(1, sizeof(GenericMaskRec)); + if (!cli) + { + ErrorF("GE: Insufficient memory to alloc client.\n"); + return; + } + cli->next = evmasks->geClients; + cli->resource = FakeClientID(pClient->index); + cli->dev = pDev; + evmasks->geClients = cli; + AddResource(cli->resource, RT_GECLIENT, (pointer)pWin); + } + cli->eventMask[extension] = mask; + } else + { + /* remove client. */ + cli = pWin->optional->geMasks->geClients; + if (rClient(cli) == pClient && cli->dev == pDev) + { + pWin->optional->geMasks->geClients = cli->next; + xfree(cli); + } else + { + GenericMaskPtr prev = cli; + cli = cli->next; + + while(cli) + { + if (rClient(cli) == pClient && cli->dev == pDev) + { + prev->next = cli->next; + xfree(cli); + break; + } + prev = cli; + cli = cli->next; + } + } + if (!cli) + return; + } + + GERecalculateWinMask(pWin); +} + +/** + * Return TRUE if the mask for the given device is set. + * @param pWin Window the event may be delivered to. + * @param pDev Device the device originating the event. May be NULL. + * @param extension Extension ID + * @param mask Event mask + */ +BOOL +GEDeviceMaskIsSet(WindowPtr pWin, DeviceIntPtr pDev, + int extension, Mask mask) +{ + GenericMaskPtr gemask; + + if (!pWin->optional || !pWin->optional->geMasks) + return FALSE; + + extension &= 0x7F; + + if (!pWin->optional->geMasks->eventMasks[extension] & mask) + return FALSE; + + + gemask = pWin->optional->geMasks->geClients; + + while(gemask) + { + if ((!gemask->dev || gemask->dev == pDev) && + (gemask->eventMask[extension] & mask)) + return TRUE; + + gemask = gemask->next; + } + + return FALSE; +} + diff --git a/xorg-server/Xext/geext.h b/xorg-server/Xext/geext.h new file mode 100644 index 000000000..3d1665373 --- /dev/null +++ b/xorg-server/Xext/geext.h @@ -0,0 +1,114 @@ +/* + +Copyright 2007 Peter Hutterer <peter@cs.unisa.edu.au> + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the author shall +not be used in advertising or otherwise to promote the sale, use or +other dealings in this Software without prior written authorization +from the author. + +*/ + +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#ifndef _GEEXT_H_ +#define _GEEXT_H_ +#include <X11/extensions/geproto.h> + + +/** + * This struct is used both in the window and by grabs to determine the event + * mask for a client. + * A window will have a linked list of these structs, with one entry per + * client per device, null-terminated. + * A grab has only one instance of this struct. + */ +typedef struct _GenericMaskRec { + struct _GenericMaskRec* next; + XID resource; /* id for the resource manager */ + DeviceIntPtr dev; + Mask eventMask[MAXEXTENSIONS]; /* one mask per extension */ +} GenericMaskRec, *GenericMaskPtr; + + +/* Struct to keep information about registered extensions + * + * evswap ... use to swap event fields for different byte ordered clients. + * evfill ... use to fill various event fields from the given parameters. + */ +typedef struct _GEExtension { + void (*evswap)(xGenericEvent* from, xGenericEvent* to); + void (*evfill)(xGenericEvent* ev, + DeviceIntPtr pDev, /* device */ + WindowPtr pWin, /* event window */ + GrabPtr pGrab /* current grab, may be NULL */ + ); +} GEExtension, *GEExtensionPtr; + + +/* All registered extensions and their handling functions. */ +extern GEExtension GEExtensions[MAXEXTENSIONS]; + +/* Returns the extension offset from the event */ +#define GEEXT(ev) (((xGenericEvent*)(ev))->extension) + +#define GEEXTIDX(ev) (GEEXT(ev) & 0x7F) +/* Typecast to generic event */ +#define GEV(ev) ((xGenericEvent*)(ev)) +/* True if mask is set for extension on window */ +#define GEMaskIsSet(pWin, extension, mask) \ + ((pWin)->optional && \ + (pWin)->optional->geMasks && \ + ((pWin)->optional->geMasks->eventMasks[(extension) & 0x7F] & (mask))) + +/* Returns first client */ +#define GECLIENT(pWin) \ + (((pWin)->optional) ? (pWin)->optional->geMasks->geClients : NULL) + +/* Returns the event_fill for the given event */ +#define GEEventFill(ev) \ + GEExtensions[GEEXTIDX(xE)].evfill + +#define GEIsType(ev, ext, ev_type) \ + ((ev->u.u.type == GenericEvent) && \ + ((xGenericEvent*)(ev))->extension == ext && \ + ((xGenericEvent*)(ev))->evtype == ev_type) + + +/* Interface for other extensions */ +void GEWindowSetMask(ClientPtr pClient, DeviceIntPtr pDev, + WindowPtr pWin, int extension, Mask mask); + +void GERegisterExtension( + int extension, + void (*ev_dispatch)(xGenericEvent* from, xGenericEvent* to), + void (*ev_fill)(xGenericEvent* ev, DeviceIntPtr pDev, + WindowPtr pWin, GrabPtr pGrab) + ); + +void GEInitEvent(xGenericEvent* ev, int extension); +BOOL GEDeviceMaskIsSet(WindowPtr pWin, DeviceIntPtr pDev, + int extension, Mask mask); + +void GEExtensionInit(void); + +#endif /* _GEEXT_H_ */ diff --git a/xorg-server/Xext/geint.h b/xorg-server/Xext/geint.h new file mode 100644 index 000000000..60cba7d72 --- /dev/null +++ b/xorg-server/Xext/geint.h @@ -0,0 +1,56 @@ +/* + * Copyright 2007-2008 Peter Hutterer + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Author: Peter Hutterer, University of South Australia, NICTA + */ +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#ifndef _GEINT_H_ +#define _GEINT_H_ + +#define NEED_EVENTS +#include <X11/X.h> +#include <X11/Xproto.h> +#include "misc.h" +#include "os.h" +#include "dixstruct.h" +#include "extnsionst.h" +#include <X11/extensions/geproto.h> + +extern int GEEventType; +extern int GEEventBase; +extern int GEErrorBase; +extern DevPrivateKey GEClientPrivateKey; + +typedef struct _GEClientInfo { + CARD32 major_version; + CARD32 minor_version; +} GEClientInfoRec, *GEClientInfoPtr; + +#define GEGetClient(pClient) ((GEClientInfoPtr)(dixLookupPrivate(&((pClient)->devPrivates), GEClientPrivateKey))) + +extern int (*ProcGEVector[/*GENumRequests*/])(ClientPtr); +extern int (*SProcGEVector[/*GENumRequests*/])(ClientPtr); + +#endif /* _GEINT_H_ */ diff --git a/xorg-server/Xext/mbuf.c b/xorg-server/Xext/mbuf.c index 0b5b91ea9..39b8ba11e 100644 --- a/xorg-server/Xext/mbuf.c +++ b/xorg-server/Xext/mbuf.c @@ -47,7 +47,7 @@ in this Software without prior written authorization from The Open Group. #include <X11/extensions/multibufst.h> #include <stdio.h> -#if !defined(WIN32) && !defined(Lynx) +#if !defined(WIN32) #include <sys/time.h> #endif @@ -61,8 +61,10 @@ in this Software without prior written authorization from The Open Group. static int MultibufferEventBase; static int MultibufferErrorBase; -static DevPrivateKey MultibufferScreenPrivKey = &MultibufferScreenPrivKey; -static DevPrivateKey MultibufferWindowPrivKey = &MultibufferWindowPrivKey; +static int MultibufferScreenPrivKeyIndex; +static DevPrivateKey MultibufferScreenPrivKey = &MultibufferScreenPrivKeyIndex; +static int MultibufferWindowPrivKeyIndex; +static DevPrivateKey MultibufferWindowPrivKey = &MultibufferWindowPrivKeyIndex; static void PerformDisplayRequest ( MultibuffersPtr * /* ppMultibuffers */, @@ -262,10 +264,10 @@ ExtensionEntry *extEntry; static int ProcGetBufferVersion (client) - register ClientPtr client; + ClientPtr client; { xMbufGetBufferVersionReply rep; - register int n; + int n; REQUEST_SIZE_MATCH (xMbufGetBufferVersionReq); rep.type = X_Reply; @@ -421,11 +423,11 @@ CreateImageBuffers (pWin, nbuf, ids, action, hint) static int ProcCreateImageBuffers (client) - register ClientPtr client; + ClientPtr client; { REQUEST(xMbufCreateImageBuffersReq); xMbufCreateImageBuffersReply rep; - register int n; + int n; WindowPtr pWin; XID *ids; int len, nbuf, i, err, rc; @@ -486,7 +488,7 @@ ProcCreateImageBuffers (client) static int ProcDisplayImageBuffers (client) - register ClientPtr client; + ClientPtr client; { REQUEST(xMbufDisplayImageBuffersReq); MultibufferPtr *pMultibuffer; @@ -559,7 +561,7 @@ MultibufferResType); static int ProcDestroyImageBuffers (client) - register ClientPtr client; + ClientPtr client; { REQUEST (xMbufDestroyImageBuffersReq); WindowPtr pWin; @@ -575,7 +577,7 @@ ProcDestroyImageBuffers (client) static int ProcSetMBufferAttributes (client) - register ClientPtr client; + ClientPtr client; { REQUEST (xMbufSetMBufferAttributesReq); WindowPtr pWin; @@ -674,7 +676,7 @@ ProcGetMBufferAttributes (client) static int ProcSetBufferAttributes (client) - register ClientPtr client; + ClientPtr client; { REQUEST(xMbufSetBufferAttributesReq); MultibufferPtr pMultibuffer; @@ -716,7 +718,7 @@ ProcSetBufferAttributes (client) int ProcGetBufferAttributes (client) - register ClientPtr client; + ClientPtr client; { REQUEST(xMbufGetBufferAttributesReq); MultibufferPtr pMultibuffer; @@ -760,7 +762,7 @@ ProcGetBufferAttributes (client) static int ProcGetBufferInfo (client) - register ClientPtr client; + ClientPtr client; { REQUEST (xMbufGetBufferInfoReq); DrawablePtr pDrawable; @@ -825,7 +827,7 @@ ProcGetBufferInfo (client) static int ProcClearImageBufferArea (client) - register ClientPtr client; + ClientPtr client; { REQUEST (xMbufClearImageBufferAreaReq); MultibufferPtr pMultibuffer; @@ -887,7 +889,7 @@ ProcClearImageBufferArea (client) static int ProcMultibufferDispatch (client) - register ClientPtr client; + ClientPtr client; { REQUEST(xReq); switch (stuff->data) { @@ -918,9 +920,9 @@ ProcMultibufferDispatch (client) static int SProcGetBufferVersion (client) - register ClientPtr client; + ClientPtr client; { - register int n; + int n; REQUEST (xMbufGetBufferVersionReq); swaps (&stuff->length, n); @@ -929,9 +931,9 @@ SProcGetBufferVersion (client) static int SProcCreateImageBuffers (client) - register ClientPtr client; + ClientPtr client; { - register int n; + int n; REQUEST (xMbufCreateImageBuffersReq); swaps (&stuff->length, n); @@ -943,9 +945,9 @@ SProcCreateImageBuffers (client) static int SProcDisplayImageBuffers (client) - register ClientPtr client; + ClientPtr client; { - register int n; + int n; REQUEST (xMbufDisplayImageBuffersReq); swaps (&stuff->length, n); @@ -958,9 +960,9 @@ SProcDisplayImageBuffers (client) static int SProcDestroyImageBuffers (client) - register ClientPtr client; + ClientPtr client; { - register int n; + int n; REQUEST (xMbufDestroyImageBuffersReq); swaps (&stuff->length, n); @@ -971,9 +973,9 @@ SProcDestroyImageBuffers (client) static int SProcSetMBufferAttributes (client) - register ClientPtr client; + ClientPtr client; { - register int n; + int n; REQUEST (xMbufSetMBufferAttributesReq); swaps (&stuff->length, n); @@ -986,9 +988,9 @@ SProcSetMBufferAttributes (client) static int SProcGetMBufferAttributes (client) - register ClientPtr client; + ClientPtr client; { - register int n; + int n; REQUEST (xMbufGetMBufferAttributesReq); swaps (&stuff->length, n); @@ -999,9 +1001,9 @@ SProcGetMBufferAttributes (client) static int SProcSetBufferAttributes (client) - register ClientPtr client; + ClientPtr client; { - register int n; + int n; REQUEST (xMbufSetBufferAttributesReq); swaps (&stuff->length, n); @@ -1014,9 +1016,9 @@ SProcSetBufferAttributes (client) static int SProcGetBufferAttributes (client) - register ClientPtr client; + ClientPtr client; { - register int n; + int n; REQUEST (xMbufGetBufferAttributesReq); swaps (&stuff->length, n); @@ -1027,9 +1029,9 @@ SProcGetBufferAttributes (client) static int SProcGetBufferInfo (client) - register ClientPtr client; + ClientPtr client; { - register int n; + int n; REQUEST (xMbufGetBufferInfoReq); swaps (&stuff->length, n); @@ -1040,9 +1042,9 @@ SProcGetBufferInfo (client) static int SProcClearImageBufferArea(client) - register ClientPtr client; + ClientPtr client; { - register char n; + char n; REQUEST(xMbufClearImageBufferAreaReq); swaps(&stuff->length, n); @@ -1057,7 +1059,7 @@ SProcClearImageBufferArea(client) static int SProcMultibufferDispatch (client) - register ClientPtr client; + ClientPtr client; { REQUEST(xReq); switch (stuff->data) { @@ -1277,7 +1279,7 @@ QueueDisplayRequest (client, activateTime) /* swap the request back so we can simply re-execute it */ if (client->swapped) { - register int n; + int n; REQUEST (xMbufDisplayImageBuffersReq); SwapRestL(stuff); @@ -1312,7 +1314,7 @@ DeliverEventsToMultibuffer (pMultibuffer, pEvents, count, filter) /* maybe send event to owner */ if ((attempt = TryClientEvents( - bClient(pMultibuffer), pEvents, count, pMultibuffer->eventMask, filter, (GrabPtr) 0)) != 0) + bClient(pMultibuffer), NULL, pEvents, count, pMultibuffer->eventMask, filter, (GrabPtr) 0)) != 0) { if (attempt > 0) deliveries++; @@ -1324,7 +1326,7 @@ DeliverEventsToMultibuffer (pMultibuffer, pEvents, count, filter) for (other = pMultibuffer->otherClients; other; other=other->next) { if ((attempt = TryClientEvents( - rClient(other), pEvents, count, other->mask, filter, (GrabPtr) 0)) != 0) + rClient(other), NULL, pEvents, count, other->mask, filter, (GrabPtr) 0)) != 0) { if (attempt > 0) deliveries++; @@ -1350,9 +1352,9 @@ MultibufferExpose (pMultibuffer, pRegion) { xEvent *pEvent; PixmapPtr pPixmap; - register xEvent *pe; - register BoxPtr pBox; - register int i; + xEvent *pe; + BoxPtr pBox; + int i; int numRects; pPixmap = pMultibuffer->pPixmap; @@ -1662,7 +1664,7 @@ OtherClientDelete (value, id) XID id; { MultibufferPtr pMultibuffer = (MultibufferPtr)value; - register OtherClientsPtr other, prev; + OtherClientsPtr other, prev; prev = 0; for (other = pMultibuffer->otherClients; other; other = other->next) diff --git a/xorg-server/Xext/mbufbf.c b/xorg-server/Xext/mbufbf.c index a3b3de79d..e929ab5fd 100644 --- a/xorg-server/Xext/mbufbf.c +++ b/xorg-server/Xext/mbufbf.c @@ -47,6 +47,7 @@ in this Software without prior written authorization from The Open Group. #include "gcstruct.h" #include "inputstr.h" #include "validate.h" +#include "globals.h" #include <sys/time.h> #define _MULTIBUF_SERVER_ /* don't want Xlib structures */ @@ -199,8 +200,6 @@ static Bool bufChangeWindowAttributes(); static void bufClearToBackground(); static void bufCopyWindow(); -extern WindowPtr *WindowTable; - static Bool bufMultibufferInit(pScreen, pMBScreen) ScreenPtr pScreen; @@ -600,9 +599,9 @@ bufDrawSelectPlane(pScreen, selectPlane, prgn, bufferNum) { DrawablePtr pDrawable; GCPtr pGC; - register int i; - register BoxPtr pbox; - register xRectangle *prect; + int i; + BoxPtr pbox; + xRectangle *prect; int numRects; XID value; @@ -882,7 +881,7 @@ bufChangeWindowAttributes(pWin, mask) static void bufWindowExposures(pWin, prgn, other_exposed) WindowPtr pWin; - register RegionPtr prgn, other_exposed; + RegionPtr prgn, other_exposed; { ScreenPtr pScreen = pWin->drawable.pScreen; mbufWindowPtr pMBWindow = MB_WINDOW_PRIV(pWin); diff --git a/xorg-server/Xext/mitmisc.c b/xorg-server/Xext/mitmisc.c deleted file mode 100644 index e793d4dc1..000000000 --- a/xorg-server/Xext/mitmisc.c +++ /dev/null @@ -1,155 +0,0 @@ -/************************************************************ - -Copyright 1989, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -********************************************************/ - -/* RANDOM CRUFT! THIS HAS NO OFFICIAL X CONSORTIUM OR X PROJECT TEAM BLESSING */ - - -#define NEED_EVENTS -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include <X11/X.h> -#include <X11/Xproto.h> -#include "misc.h" -#include "os.h" -#include "dixstruct.h" -#include "extnsionst.h" -#define _MITMISC_SERVER_ -#include <X11/extensions/mitmiscstr.h> -#include "modinit.h" - -static void MITResetProc( - ExtensionEntry * /* extEntry */ -); - -static DISPATCH_PROC(ProcMITDispatch); -static DISPATCH_PROC(ProcMITGetBugMode); -static DISPATCH_PROC(ProcMITSetBugMode); -static DISPATCH_PROC(SProcMITDispatch); -static DISPATCH_PROC(SProcMITGetBugMode); -static DISPATCH_PROC(SProcMITSetBugMode); - -void -MITMiscExtensionInit(INITARGS) -{ - AddExtension(MITMISCNAME, 0, 0, - ProcMITDispatch, SProcMITDispatch, - MITResetProc, StandardMinorOpcode); -} - -/*ARGSUSED*/ -static void -MITResetProc (extEntry) -ExtensionEntry *extEntry; -{ -} - -static int -ProcMITSetBugMode(client) - register ClientPtr client; -{ - REQUEST(xMITSetBugModeReq); - - REQUEST_SIZE_MATCH(xMITSetBugModeReq); - if (stuff->onOff != xFalse) - return BadRequest; - return(client->noClientException); -} - -static int -ProcMITGetBugMode(client) - register ClientPtr client; -{ - xMITGetBugModeReply rep; - register int n; - - REQUEST_SIZE_MATCH(xMITGetBugModeReq); - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - rep.onOff = FALSE; - if (client->swapped) { - swaps(&rep.sequenceNumber, n); - swapl(&rep.length, n); - } - WriteToClient(client, sizeof(xMITGetBugModeReply), (char *)&rep); - return(client->noClientException); -} - -static int -ProcMITDispatch (client) - register ClientPtr client; -{ - REQUEST(xReq); - switch (stuff->data) - { - case X_MITSetBugMode: - return ProcMITSetBugMode(client); - case X_MITGetBugMode: - return ProcMITGetBugMode(client); - default: - return BadRequest; - } -} - -static int -SProcMITSetBugMode(client) - register ClientPtr client; -{ - register int n; - REQUEST(xMITSetBugModeReq); - - swaps(&stuff->length, n); - return ProcMITSetBugMode(client); -} - -static int -SProcMITGetBugMode(client) - register ClientPtr client; -{ - register int n; - REQUEST(xMITGetBugModeReq); - - swaps(&stuff->length, n); - return ProcMITGetBugMode(client); -} - -static int -SProcMITDispatch (client) - register ClientPtr client; -{ - REQUEST(xReq); - switch (stuff->data) - { - case X_MITSetBugMode: - return SProcMITSetBugMode(client); - case X_MITGetBugMode: - return SProcMITGetBugMode(client); - default: - return BadRequest; - } -} diff --git a/xorg-server/Xext/panoramiX.c b/xorg-server/Xext/panoramiX.c index 8bc5c42c2..a1f4ce01e 100644 --- a/xorg-server/Xext/panoramiX.c +++ b/xorg-server/Xext/panoramiX.c @@ -58,6 +58,8 @@ Equipment Corporation. #endif #include "modinit.h" +#define SERVER_PANORAMIX_MAJOR_VERSION 1 +#define SERVER_PANORAMIX_MINOR_VERSION 1 #ifdef GLXPROXY extern VisualPtr glxMatchVisual(ScreenPtr pScreen, @@ -107,8 +109,10 @@ static void PanoramiXResetProc(ExtensionEntry*); int (* SavedProcVector[256]) (ClientPtr client) = { NULL, }; -static DevPrivateKey PanoramiXGCKey = &PanoramiXGCKey; -static DevPrivateKey PanoramiXScreenKey = &PanoramiXScreenKey; +static int PanoramiXGCKeyIndex; +static DevPrivateKey PanoramiXGCKey = &PanoramiXGCKeyIndex; +static int PanoramiXScreenKeyIndex; +static DevPrivateKey PanoramiXScreenKey = &PanoramiXScreenKeyIndex; typedef struct { DDXPointRec clipOrg; @@ -548,8 +552,8 @@ void PanoramiXExtensionInit(int argc, char *argv[]) ProcVector[X_SetClipRectangles] = PanoramiXSetClipRectangles; ProcVector[X_FreeGC] = PanoramiXFreeGC; ProcVector[X_ClearArea] = PanoramiXClearToBackground; - ProcVector[X_CopyArea] = PanoramiXCopyArea;; - ProcVector[X_CopyPlane] = PanoramiXCopyPlane;; + ProcVector[X_CopyArea] = PanoramiXCopyArea; + ProcVector[X_CopyPlane] = PanoramiXCopyPlane; ProcVector[X_PolyPoint] = PanoramiXPolyPoint; ProcVector[X_PolyLine] = PanoramiXPolyLine; ProcVector[X_PolySegment] = PanoramiXPolySegment; @@ -572,10 +576,10 @@ void PanoramiXExtensionInit(int argc, char *argv[]) ProcVector[X_AllocColor] = PanoramiXAllocColor; ProcVector[X_AllocNamedColor] = PanoramiXAllocNamedColor; ProcVector[X_AllocColorCells] = PanoramiXAllocColorCells; - ProcVector[X_AllocColorPlanes] = PanoramiXAllocColorPlanes; + ProcVector[X_AllocColorPlanes] = PanoramiXAllocColorPlanes; ProcVector[X_FreeColors] = PanoramiXFreeColors; - ProcVector[X_StoreColors] = PanoramiXStoreColors; - ProcVector[X_StoreNamedColor] = PanoramiXStoreNamedColor; + ProcVector[X_StoreColors] = PanoramiXStoreColors; + ProcVector[X_StoreNamedColor] = PanoramiXStoreNamedColor; #ifdef RENDER PanoramiXRenderInit (); @@ -588,7 +592,6 @@ Bool PanoramiXCreateConnectionBlock(void) { int i, j, length; Bool disableBackingStore = FALSE; - Bool disableSaveUnders = FALSE; int old_width, old_height; float width_mult, height_mult; xWindowRoot *root; @@ -614,17 +617,12 @@ Bool PanoramiXCreateConnectionBlock(void) } if(pScreen->backingStoreSupport != screenInfo.screens[0]->backingStoreSupport) disableBackingStore = TRUE; - if(pScreen->saveUnderSupport != screenInfo.screens[0]->saveUnderSupport) - disableSaveUnders = TRUE; } - if(disableBackingStore || disableSaveUnders) { - for(i = 0; i < screenInfo.numScreens; i++) { + if (disableBackingStore) { + for (i = 0; i < screenInfo.numScreens; i++) { pScreen = screenInfo.screens[i]; - if(disableBackingStore) - pScreen->backingStoreSupport = NotUseful; - if(disableSaveUnders) - pScreen->saveUnderSupport = NotUseful; + pScreen->backingStoreSupport = NotUseful; } } @@ -907,8 +905,8 @@ ProcPanoramiXQueryVersion (ClientPtr client) rep.type = X_Reply; rep.length = 0; rep.sequenceNumber = client->sequence; - rep.majorVersion = PANORAMIX_MAJOR_VERSION; - rep.minorVersion = PANORAMIX_MINOR_VERSION; + rep.majorVersion = SERVER_PANORAMIX_MAJOR_VERSION; + rep.minorVersion = SERVER_PANORAMIX_MINOR_VERSION; if (client->swapped) { swaps(&rep.sequenceNumber, n); swapl(&rep.length, n); @@ -925,7 +923,7 @@ ProcPanoramiXGetState(ClientPtr client) REQUEST(xPanoramiXGetStateReq); WindowPtr pWin; xPanoramiXGetStateReply rep; - register int n, rc; + int n, rc; REQUEST_SIZE_MATCH(xPanoramiXGetStateReq); rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); @@ -953,7 +951,7 @@ ProcPanoramiXGetScreenCount(ClientPtr client) REQUEST(xPanoramiXGetScreenCountReq); WindowPtr pWin; xPanoramiXGetScreenCountReply rep; - register int n, rc; + int n, rc; REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq); rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); @@ -980,7 +978,7 @@ ProcPanoramiXGetScreenSize(ClientPtr client) REQUEST(xPanoramiXGetScreenSizeReq); WindowPtr pWin; xPanoramiXGetScreenSizeReply rep; - register int n, rc; + int n, rc; if (stuff->screen >= PanoramiXNumScreens) return BadMatch; @@ -1032,7 +1030,7 @@ ProcXineramaIsActive(ClientPtr client) rep.state = !noPanoramiXExtension; #endif if (client->swapped) { - register int n; + int n; swaps (&rep.sequenceNumber, n); swapl (&rep.length, n); swapl (&rep.state, n); @@ -1055,7 +1053,7 @@ ProcXineramaQueryScreens(ClientPtr client) rep.number = (noPanoramiXExtension) ? 0 : PanoramiXNumScreens; rep.length = rep.number * sz_XineramaScreenInfo >> 2; if (client->swapped) { - register int n; + int n; swaps (&rep.sequenceNumber, n); swapl (&rep.length, n); swapl (&rep.number, n); @@ -1073,7 +1071,7 @@ ProcXineramaQueryScreens(ClientPtr client) scratch.height = panoramiXdataPtr[i].height; if(client->swapped) { - register int n; + int n; swaps (&scratch.x_org, n); swaps (&scratch.y_org, n); swaps (&scratch.width, n); diff --git a/xorg-server/Xext/panoramiX.h b/xorg-server/Xext/panoramiX.h index 89c754732..700c5a4f9 100644 --- a/xorg-server/Xext/panoramiX.h +++ b/xorg-server/Xext/panoramiX.h @@ -40,7 +40,10 @@ Equipment Corporation. #ifndef _PANORAMIX_H_ #define _PANORAMIX_H_ +#define _PANORAMIX_SERVER #include <X11/extensions/panoramiXext.h> +#undef _PANORAMIX_SERVER + #include "gcstruct.h" diff --git a/xorg-server/Xext/panoramiXSwap.c b/xorg-server/Xext/panoramiXSwap.c index b13c286dd..e1720c9ab 100644 --- a/xorg-server/Xext/panoramiXSwap.c +++ b/xorg-server/Xext/panoramiXSwap.c @@ -51,7 +51,7 @@ static int SProcPanoramiXQueryVersion (ClientPtr client) { REQUEST(xPanoramiXQueryVersionReq); - register int n; + int n; swaps(&stuff->length,n); REQUEST_SIZE_MATCH (xPanoramiXQueryVersionReq); @@ -62,7 +62,7 @@ static int SProcPanoramiXGetState(ClientPtr client) { REQUEST(xPanoramiXGetStateReq); - register int n; + int n; swaps (&stuff->length, n); REQUEST_SIZE_MATCH(xPanoramiXGetStateReq); @@ -74,7 +74,7 @@ static int SProcPanoramiXGetScreenCount(ClientPtr client) { REQUEST(xPanoramiXGetScreenCountReq); - register int n; + int n; swaps (&stuff->length, n); REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq); @@ -86,7 +86,7 @@ static int SProcPanoramiXGetScreenSize(ClientPtr client) { REQUEST(xPanoramiXGetScreenSizeReq); - register int n; + int n; swaps (&stuff->length, n); REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq); @@ -100,7 +100,7 @@ static int SProcXineramaIsActive(ClientPtr client) { REQUEST(xXineramaIsActiveReq); - register int n; + int n; swaps (&stuff->length, n); REQUEST_SIZE_MATCH(xXineramaIsActiveReq); @@ -112,7 +112,7 @@ static int SProcXineramaQueryScreens(ClientPtr client) { REQUEST(xXineramaQueryScreensReq); - register int n; + int n; swaps (&stuff->length, n); REQUEST_SIZE_MATCH(xXineramaQueryScreensReq); diff --git a/xorg-server/Xext/panoramiXh.h b/xorg-server/Xext/panoramiXh.h index 1a76a45cd..31b8f90b6 100644 --- a/xorg-server/Xext/panoramiXh.h +++ b/xorg-server/Xext/panoramiXh.h @@ -67,7 +67,6 @@ PROC_EXTERN(ProcXineramaIsActive); extern int SProcPanoramiXDispatch(ClientPtr client); -extern char *ConnectionInfo; extern int connBlockScreenStart; extern xConnSetupPrefix connSetupPrefix; diff --git a/xorg-server/Xext/panoramiXprocs.c b/xorg-server/Xext/panoramiXprocs.c index 30aff7460..38199a5df 100644 --- a/xorg-server/Xext/panoramiXprocs.c +++ b/xorg-server/Xext/panoramiXprocs.c @@ -595,9 +595,7 @@ int PanoramiXTranslateCoords(ClientPtr client) } pWin = pDst->firstChild; while (pWin) { -#ifdef SHAPE BoxRec box; -#endif if ((pWin->mapped) && (x >= pWin->drawable.x - wBorderWidth (pWin)) && (x < pWin->drawable.x + (int)pWin->drawable.width + @@ -605,7 +603,6 @@ int PanoramiXTranslateCoords(ClientPtr client) (y >= pWin->drawable.y - wBorderWidth (pWin)) && (y < pWin->drawable.y + (int)pWin->drawable.height + wBorderWidth (pWin)) -#ifdef SHAPE /* When a window is shaped, a further check * is made to see if the point is inside * borderSize @@ -615,7 +612,6 @@ int PanoramiXTranslateCoords(ClientPtr client) wBoundingShape(pWin), x - pWin->drawable.x, y - pWin->drawable.y, &box)) -#endif ) { rep.child = pWin->drawable.id; diff --git a/xorg-server/Xext/sampleEVI.c b/xorg-server/Xext/sampleEVI.c deleted file mode 100644 index b871bfd74..000000000 --- a/xorg-server/Xext/sampleEVI.c +++ /dev/null @@ -1,123 +0,0 @@ -/************************************************************ -Copyright (c) 1997 by Silicon Graphics Computer Systems, Inc. -Permission to use, copy, modify, and distribute this -software and its documentation for any purpose and without -fee is hereby granted, provided that the above copyright -notice appear in all copies and that both that copyright -notice and this permission notice appear in supporting -documentation, and that the name of Silicon Graphics not be -used in advertising or publicity pertaining to distribution -of the software without specific prior written permission. -Silicon Graphics makes no representation about the suitability -of this software for any purpose. It is provided "as is" -without any express or implied warranty. -SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS -SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON -GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL -DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, -DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH -THE USE OR PERFORMANCE OF THIS SOFTWARE. -********************************************************/ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include <X11/X.h> -#include <X11/Xproto.h> -#include "dixstruct.h" -#include "extnsionst.h" -#include "dix.h" -#define _XEVI_SERVER_ -#include <X11/extensions/XEVIstr.h> -#include "EVIstruct.h" -#include "scrnintstr.h" - -#if HAVE_STDINT_H -#include <stdint.h> -#elif !defined(UINT32_MAX) -#define UINT32_MAX 0xffffffffU -#endif - -static int sampleGetVisualInfo( - VisualID32 *visual, - int n_visual, - xExtendedVisualInfo **evi_rn, - int *n_info_rn, - VisualID32 **conflict_rn, - int *n_conflict_rn) -{ - unsigned int max_sz_evi; - VisualID32 *temp_conflict; - xExtendedVisualInfo *evi; - unsigned int max_visuals = 0, max_sz_conflict, sz_conflict = 0; - register int visualI, scrI, sz_evi = 0, conflictI, n_conflict; - - if (n_visual > UINT32_MAX/(sz_xExtendedVisualInfo * screenInfo.numScreens)) - return BadAlloc; - max_sz_evi = n_visual * sz_xExtendedVisualInfo * screenInfo.numScreens; - - for (scrI = 0; scrI < screenInfo.numScreens; scrI++) { - if (screenInfo.screens[scrI]->numVisuals > max_visuals) - max_visuals = screenInfo.screens[scrI]->numVisuals; - } - - if (n_visual > UINT32_MAX/(sz_VisualID32 * screenInfo.numScreens - * max_visuals)) - return BadAlloc; - max_sz_conflict = n_visual * sz_VisualID32 * screenInfo.numScreens * max_visuals; - - *evi_rn = evi = (xExtendedVisualInfo *)xalloc(max_sz_evi); - if (!*evi_rn) - return BadAlloc; - - temp_conflict = (VisualID32 *)xalloc(max_sz_conflict); - if (!temp_conflict) { - xfree(*evi_rn); - return BadAlloc; - } - - for (scrI = 0; scrI < screenInfo.numScreens; scrI++) { - for (visualI = 0; visualI < n_visual; visualI++) { - evi[sz_evi].core_visual_id = visual[visualI]; - evi[sz_evi].screen = scrI; - evi[sz_evi].level = 0; - evi[sz_evi].transparency_type = XEVI_TRANSPARENCY_NONE; - evi[sz_evi].transparency_value = 0; - evi[sz_evi].min_hw_colormaps = 1; - evi[sz_evi].max_hw_colormaps = 1; - evi[sz_evi].num_colormap_conflicts = n_conflict = 0; - for (conflictI = 0; conflictI < n_conflict; conflictI++) - temp_conflict[sz_conflict++] = visual[visualI]; - sz_evi++; - } - } - *conflict_rn = temp_conflict; - *n_conflict_rn = sz_conflict; - *n_info_rn = sz_evi; - return Success; -} - -static void sampleFreeVisualInfo( - xExtendedVisualInfo *evi, - VisualID32 *conflict) -{ - if (evi) - xfree(evi); - if (conflict) - xfree(conflict); -} - -EviPrivPtr eviDDXInit(void) -{ - static EviPrivRec eviPriv; - eviPriv.getVisualInfo = sampleGetVisualInfo; - eviPriv.freeVisualInfo = sampleFreeVisualInfo; - return &eviPriv; -} - -void eviDDXReset(void) -{ -} diff --git a/xorg-server/Xext/saver.c b/xorg-server/Xext/saver.c index 3a70afe6d..ba565027f 100644 --- a/xorg-server/Xext/saver.c +++ b/xorg-server/Xext/saver.c @@ -112,10 +112,6 @@ static void SScreenSaverNotifyEvent ( xScreenSaverNotifyEvent * /* to */ ); -static void ScreenSaverResetProc ( - ExtensionEntry * /* extEntry */ - ); - static RESTYPE SuspendType; /* resource type for suspension records */ typedef struct _ScreenSaverSuspension *ScreenSaverSuspensionPtr; @@ -234,7 +230,8 @@ MakeScreenPrivate ( ScreenPtr /* pScreen */ ); -static DevPrivateKey ScreenPrivateKey = &ScreenPrivateKey; +static int ScreenPrivateKeyIndex; +static DevPrivateKey ScreenPrivateKey = &ScreenPrivateKeyIndex; #define GetScreenPrivate(s) ((ScreenSaverScreenPrivatePtr) \ dixLookupPrivate(&(s)->devPrivates, ScreenPrivateKey)) @@ -271,20 +268,13 @@ ScreenSaverExtensionInit(INITARGS) if (AttrType && EventType && SuspendType && (extEntry = AddExtension(ScreenSaverName, ScreenSaverNumberEvents, 0, ProcScreenSaverDispatch, SProcScreenSaverDispatch, - ScreenSaverResetProc, StandardMinorOpcode))) + NULL, StandardMinorOpcode))) { ScreenSaverEventBase = extEntry->eventBase; EventSwapVector[ScreenSaverEventBase] = (EventSwapPtr) SScreenSaverNotifyEvent; } } -/*ARGSUSED*/ -static void -ScreenSaverResetProc (extEntry) -ExtensionEntry *extEntry; -{ -} - static void CheckScreenPrivate (pScreen) ScreenPtr pScreen; @@ -753,10 +743,10 @@ ScreenSaverHandle (pScreen, xstate, force) static int ProcScreenSaverQueryVersion (client) - register ClientPtr client; + ClientPtr client; { xScreenSaverQueryVersionReply rep; - register int n; + int n; REQUEST_SIZE_MATCH (xScreenSaverQueryVersionReq); rep.type = X_Reply; @@ -774,11 +764,11 @@ ProcScreenSaverQueryVersion (client) static int ProcScreenSaverQueryInfo (client) - register ClientPtr client; + ClientPtr client; { REQUEST(xScreenSaverQueryInfoReq); xScreenSaverQueryInfoReply rep; - register int n, rc; + int n, rc; ScreenSaverStuffPtr pSaver; DrawablePtr pDraw; CARD32 lastInput; @@ -851,7 +841,7 @@ ProcScreenSaverQueryInfo (client) static int ProcScreenSaverSelectInput (client) - register ClientPtr client; + ClientPtr client; { REQUEST(xScreenSaverSelectInputReq); DrawablePtr pDraw; diff --git a/xorg-server/Xext/security.c b/xorg-server/Xext/security.c index ff6c1edfa..318ef6068 100644 --- a/xorg-server/Xext/security.c +++ b/xorg-server/Xext/security.c @@ -40,9 +40,6 @@ in this Software without prior written authorization from The Open Group. #include "xacestr.h" #include "securitysrv.h" #include <X11/extensions/securstr.h> -#ifdef XAPPGROUP -#include "appgroup.h" -#endif #include "modinit.h" /* Extension stuff */ @@ -55,7 +52,8 @@ static RESTYPE RTEventClient; static CallbackListPtr SecurityValidateGroupCallback = NULL; /* Private state record */ -static DevPrivateKey stateKey = &stateKey; +static int stateKeyIndex; +static DevPrivateKey stateKey = &stateKeyIndex; /* This is what we store as client security state */ typedef struct { @@ -65,10 +63,10 @@ typedef struct { } SecurityStateRec; /* Extensions that untrusted clients shouldn't have access to */ -static char *SecurityUntrustedExtensions[] = { - "RandR", - "SECURITY", - "XFree86-DGA", +static char *SecurityTrustedExtensions[] = { + "XC-MISC", + "BIG-REQUESTS", + "XpExtension", NULL }; @@ -78,6 +76,7 @@ static char *SecurityUntrustedExtensions[] = { static const Mask SecurityResourceMask = DixGetAttrAccess | DixReceiveAccess | DixListPropAccess | DixGetPropAccess | DixListAccess; +static const Mask SecurityWindowExtraMask = DixRemoveAccess; static const Mask SecurityRootWindowExtraMask = DixReceiveAccess | DixSendAccess | DixAddAccess | DixRemoveAccess; static const Mask SecurityDeviceMask = @@ -378,7 +377,7 @@ ProcSecurityQueryVersion( rep.minorVersion = SECURITY_MINOR_VERSION; if(client->swapped) { - register char n; + char n; swaps(&rep.sequenceNumber, n); swaps(&rep.majorVersion, n); swaps(&rep.minorVersion, n); @@ -590,7 +589,7 @@ ProcSecurityGenerateAuthorization( if (client->swapped) { - register char n; + char n; swapl(&rep.length, n); swaps(&rep.sequenceNumber, n); swapl(&rep.authId, n); @@ -663,7 +662,7 @@ SProcSecurityQueryVersion( ClientPtr client) { REQUEST(xSecurityQueryVersionReq); - register char n; + char n; swaps(&stuff->length, n); REQUEST_SIZE_MATCH(xSecurityQueryVersionReq); @@ -678,7 +677,7 @@ SProcSecurityGenerateAuthorization( ClientPtr client) { REQUEST(xSecurityGenerateAuthorizationReq); - register char n; + char n; CARD32 *values; unsigned long nvalues; int values_offset; @@ -705,7 +704,7 @@ SProcSecurityRevokeAuthorization( ClientPtr client) { REQUEST(xSecurityRevokeAuthorizationReq); - register char n; + char n; swaps(&stuff->length, n); REQUEST_SIZE_MATCH(xSecurityRevokeAuthorizationReq); @@ -821,6 +820,10 @@ SecurityResource(CallbackListPtr *pcbl, pointer unused, pointer calldata) if (subj->haveState && subj->trustLevel != XSecurityClientTrusted) ((WindowPtr)rec->res)->forcedBG = TRUE; + /* additional permissions for specific resource types */ + if (rec->rtype == RT_WINDOW) + allowed |= SecurityWindowExtraMask; + /* special checks for server-owned resources */ if (cid == 0) { if (rec->rtype & RC_DRAWABLE) @@ -839,11 +842,6 @@ SecurityResource(CallbackListPtr *pcbl, pointer unused, pointer calldata) if (SecurityDoCheck(subj, obj, requested, allowed) == Success) return; -#ifdef XAPPGROUP - if (rec->id == XagDefaultColormap(rec->client)) - return; -#endif - SecurityAudit("Security: denied client %d access %x to resource 0x%x " "of client %d on request %s\n", rec->client->index, requested, rec->id, cid, @@ -861,16 +859,18 @@ SecurityExtension(CallbackListPtr *pcbl, pointer unused, pointer calldata) subj = dixLookupPrivate(&rec->client->devPrivates, stateKey); - if (subj->haveState && subj->trustLevel != XSecurityClientTrusted) - while (SecurityUntrustedExtensions[i]) - if (!strcmp(SecurityUntrustedExtensions[i++], rec->ext->name)) { - SecurityAudit("Security: denied client %d access to extension " - "%s on request %s\n", - rec->client->index, rec->ext->name, - SecurityLookupRequestName(rec->client)); - rec->status = BadAccess; - return; - } + if (subj->haveState && subj->trustLevel == XSecurityClientTrusted) + return; + + while (SecurityTrustedExtensions[i]) + if (!strcmp(SecurityTrustedExtensions[i++], rec->ext->name)) + return; + + SecurityAudit("Security: denied client %d access to extension " + "%s on request %s\n", + rec->client->index, rec->ext->name, + SecurityLookupRequestName(rec->client)); + rec->status = BadAccess; } static void @@ -955,9 +955,10 @@ SecuritySend(CallbackListPtr *pcbl, pointer unused, pointer calldata) SecurityAudit("Security: denied client %d from sending event " "of type %s to window 0x%x of client %d\n", - rec->client->index, rec->pWin->drawable.id, - wClient(rec->pWin)->index, - LookupEventName(rec->events[i].u.u.type)); + rec->client->index, + LookupEventName(rec->events[i].u.u.type), + rec->pWin->drawable.id, + wClient(rec->pWin)->index); rec->status = BadAccess; return; } @@ -1051,7 +1052,7 @@ SecurityClientState(CallbackListPtr *pcbl, pointer unused, pointer calldata) break; default: - break; + break; } } diff --git a/xorg-server/Xext/shape.c b/xorg-server/Xext/shape.c index 53c7de8b8..791e7fa07 100644 --- a/xorg-server/Xext/shape.c +++ b/xorg-server/Xext/shape.c @@ -63,9 +63,6 @@ static int ShapeFreeEvents( pointer /* data */, XID /* id */ ); -static void ShapeResetProc( - ExtensionEntry * /* extEntry */ - ); static void SShapeNotifyEvent( xShapeNotifyEvent * /* from */, xShapeNotifyEvent * /* to */ @@ -151,20 +148,13 @@ ShapeExtensionInit(void) if (ClientType && EventType && (extEntry = AddExtension(SHAPENAME, ShapeNumberEvents, 0, ProcShapeDispatch, SProcShapeDispatch, - ShapeResetProc, StandardMinorOpcode))) + NULL, StandardMinorOpcode))) { ShapeEventBase = extEntry->eventBase; EventSwapVector[ShapeEventBase] = (EventSwapPtr) SShapeNotifyEvent; } } -/*ARGSUSED*/ -static void -ShapeResetProc (extEntry) -ExtensionEntry *extEntry; -{ -} - static int RegionOperate (client, pWin, kind, destRgnp, srcRgn, op, xoff, yoff, create) ClientPtr client; @@ -278,10 +268,10 @@ CreateClipShape (pWin) static int ProcShapeQueryVersion (client) - register ClientPtr client; + ClientPtr client; { xShapeQueryVersionReply rep; - register int n; + int n; REQUEST_SIZE_MATCH (xShapeQueryVersionReq); rep.type = X_Reply; @@ -306,7 +296,7 @@ ProcShapeQueryVersion (client) static int ProcShapeRectangles (client) - register ClientPtr client; + ClientPtr client; { WindowPtr pWin; ScreenPtr pScreen; @@ -377,7 +367,7 @@ ProcShapeRectangles (client) #ifdef PANORAMIX static int ProcPanoramiXShapeRectangles( - register ClientPtr client) + ClientPtr client) { REQUEST(xShapeRectanglesReq); PanoramiXRes *win; @@ -406,7 +396,7 @@ ProcPanoramiXShapeRectangles( static int ProcShapeMask (client) - register ClientPtr client; + ClientPtr client; { WindowPtr pWin; ScreenPtr pScreen; @@ -476,7 +466,7 @@ ProcShapeMask (client) #ifdef PANORAMIX static int ProcPanoramiXShapeMask( - register ClientPtr client) + ClientPtr client) { REQUEST(xShapeMaskReq); PanoramiXRes *win, *pmap; @@ -513,7 +503,7 @@ ProcPanoramiXShapeMask( static int ProcShapeCombine (client) - register ClientPtr client; + ClientPtr client; { WindowPtr pSrcWin, pDestWin; ScreenPtr pScreen; @@ -605,7 +595,7 @@ ProcShapeCombine (client) #ifdef PANORAMIX static int ProcPanoramiXShapeCombine( - register ClientPtr client) + ClientPtr client) { REQUEST(xShapeCombineReq); PanoramiXRes *win, *win2; @@ -637,7 +627,7 @@ ProcPanoramiXShapeCombine( static int ProcShapeOffset (client) - register ClientPtr client; + ClientPtr client; { WindowPtr pWin; ScreenPtr pScreen; @@ -678,7 +668,7 @@ ProcShapeOffset (client) #ifdef PANORAMIX static int ProcPanoramiXShapeOffset( - register ClientPtr client) + ClientPtr client) { REQUEST(xShapeOffsetReq); PanoramiXRes *win; @@ -702,13 +692,13 @@ ProcPanoramiXShapeOffset( static int ProcShapeQueryExtents (client) - register ClientPtr client; + ClientPtr client; { REQUEST(xShapeQueryExtentsReq); WindowPtr pWin; xShapeQueryExtentsReply rep; BoxRec extents, *pExtents; - register int n, rc; + int n, rc; RegionPtr region; REQUEST_SIZE_MATCH (xShapeQueryExtentsReq); @@ -813,7 +803,7 @@ ShapeFreeEvents (data, id) static int ProcShapeSelectInput (client) - register ClientPtr client; + ClientPtr client; { REQUEST(xShapeSelectInputReq); WindowPtr pWin; @@ -985,14 +975,14 @@ SendShapeNotify (pWin, which) static int ProcShapeInputSelected (client) - register ClientPtr client; + ClientPtr client; { REQUEST(xShapeInputSelectedReq); WindowPtr pWin; ShapeEventPtr pShapeEvent, *pHead; int enabled, rc; xShapeInputSelectedReply rep; - register int n; + int n; REQUEST_SIZE_MATCH (xShapeInputSelectedReq); rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); @@ -1026,7 +1016,7 @@ ProcShapeInputSelected (client) static int ProcShapeGetRectangles (client) - register ClientPtr client; + ClientPtr client; { REQUEST(xShapeGetRectanglesReq); WindowPtr pWin; @@ -1034,7 +1024,7 @@ ProcShapeGetRectangles (client) xRectangle *rects; int nrects, i, rc; RegionPtr region; - register int n; + int n; REQUEST_SIZE_MATCH(xShapeGetRectanglesReq); rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); @@ -1112,7 +1102,7 @@ ProcShapeGetRectangles (client) static int ProcShapeDispatch (client) - register ClientPtr client; + ClientPtr client; { REQUEST(xReq); switch (stuff->data) { @@ -1177,9 +1167,9 @@ SShapeNotifyEvent(from, to) static int SProcShapeQueryVersion (client) - register ClientPtr client; + ClientPtr client; { - register int n; + int n; REQUEST (xShapeQueryVersionReq); swaps (&stuff->length, n); @@ -1188,9 +1178,9 @@ SProcShapeQueryVersion (client) static int SProcShapeRectangles (client) - register ClientPtr client; + ClientPtr client; { - register char n; + char n; REQUEST (xShapeRectanglesReq); swaps (&stuff->length, n); @@ -1204,9 +1194,9 @@ SProcShapeRectangles (client) static int SProcShapeMask (client) - register ClientPtr client; + ClientPtr client; { - register char n; + char n; REQUEST (xShapeMaskReq); swaps (&stuff->length, n); @@ -1220,9 +1210,9 @@ SProcShapeMask (client) static int SProcShapeCombine (client) - register ClientPtr client; + ClientPtr client; { - register char n; + char n; REQUEST (xShapeCombineReq); swaps (&stuff->length, n); @@ -1236,9 +1226,9 @@ SProcShapeCombine (client) static int SProcShapeOffset (client) - register ClientPtr client; + ClientPtr client; { - register char n; + char n; REQUEST (xShapeOffsetReq); swaps (&stuff->length, n); @@ -1251,9 +1241,9 @@ SProcShapeOffset (client) static int SProcShapeQueryExtents (client) - register ClientPtr client; + ClientPtr client; { - register char n; + char n; REQUEST (xShapeQueryExtentsReq); swaps (&stuff->length, n); @@ -1264,9 +1254,9 @@ SProcShapeQueryExtents (client) static int SProcShapeSelectInput (client) - register ClientPtr client; + ClientPtr client; { - register char n; + char n; REQUEST (xShapeSelectInputReq); swaps (&stuff->length, n); @@ -1277,9 +1267,9 @@ SProcShapeSelectInput (client) static int SProcShapeInputSelected (client) - register ClientPtr client; + ClientPtr client; { - register int n; + int n; REQUEST (xShapeInputSelectedReq); swaps (&stuff->length, n); @@ -1290,10 +1280,10 @@ SProcShapeInputSelected (client) static int SProcShapeGetRectangles (client) - register ClientPtr client; + ClientPtr client; { REQUEST(xShapeGetRectanglesReq); - register char n; + char n; swaps (&stuff->length, n); REQUEST_SIZE_MATCH(xShapeGetRectanglesReq); @@ -1303,7 +1293,7 @@ SProcShapeGetRectangles (client) static int SProcShapeDispatch (client) - register ClientPtr client; + ClientPtr client; { REQUEST(xReq); switch (stuff->data) { diff --git a/xorg-server/Xext/shm.c b/xorg-server/Xext/shm.c index bbcbd05af..0b549a487 100644 --- a/xorg-server/Xext/shm.c +++ b/xorg-server/Xext/shm.c @@ -35,15 +35,10 @@ in this Software without prior written authorization from The Open Group. #include <sys/types.h> #if !defined(_MSC_VER) -#if !defined(Lynx) #include <sys/ipc.h> #include <sys/shm.h> -#else -#include <ipc.h> -#include <shm.h> #endif #include <unistd.h> -#endif #include <sys/stat.h> #define NEED_REPLIES #define NEED_EVENTS @@ -144,11 +139,10 @@ _X_EXPORT int BadShmSegCode; _X_EXPORT RESTYPE ShmSegType; static ShmDescPtr Shmsegs; static Bool sharedPixmaps; -static int pixmapFormat; -static int shmPixFormat[MAXSCREENS]; static ShmFuncsPtr shmFuncs[MAXSCREENS]; static DestroyPixmapProcPtr destroyPixmap[MAXSCREENS]; -static DevPrivateKey shmPixmapPrivate = &shmPixmapPrivate; +static int shmPixmapPrivateIndex; +static DevPrivateKey shmPixmapPrivate = &shmPixmapPrivateIndex; static ShmFuncs miFuncs = {NULL, NULL}; static ShmFuncs fbFuncs = {fbShmCreatePixmap, NULL}; @@ -189,13 +183,12 @@ static ShmFuncs fbFuncs = {fbShmCreatePixmap, NULL}; static Bool badSysCall = FALSE; static void -SigSysHandler(signo) -int signo; +SigSysHandler(int signo) { badSysCall = TRUE; } -static Bool CheckForShmSyscall() +static Bool CheckForShmSyscall(void) { void (*oldHandler)(); int shmid = -1; @@ -239,24 +232,15 @@ ShmExtensionInit(INITARGS) #endif sharedPixmaps = xFalse; - pixmapFormat = 0; { sharedPixmaps = xTrue; - pixmapFormat = shmPixFormat[0]; for (i = 0; i < screenInfo.numScreens; i++) { if (!shmFuncs[i]) shmFuncs[i] = &miFuncs; if (!shmFuncs[i]->CreatePixmap) sharedPixmaps = xFalse; - if (shmPixFormat[i] && (shmPixFormat[i] != pixmapFormat)) - { - sharedPixmaps = xFalse; - pixmapFormat = 0; - } } - if (!pixmapFormat) - pixmapFormat = ZPixmap; if (sharedPixmaps) for (i = 0; i < screenInfo.numScreens; i++) { @@ -279,34 +263,22 @@ ShmExtensionInit(INITARGS) /*ARGSUSED*/ static void -ShmResetProc (extEntry) -ExtensionEntry *extEntry; +ShmResetProc(ExtensionEntry *extEntry) { int i; for (i = 0; i < MAXSCREENS; i++) { shmFuncs[i] = (ShmFuncsPtr)NULL; - shmPixFormat[i] = 0; } } -void -ShmRegisterFuncs( - ScreenPtr pScreen, - ShmFuncsPtr funcs) +_X_EXPORT void +ShmRegisterFuncs(ScreenPtr pScreen, ShmFuncsPtr funcs) { shmFuncs[pScreen->myNum] = funcs; } -void -ShmSetPixmapFormat( - ScreenPtr pScreen, - int format) -{ - shmPixFormat[pScreen->myNum] = format; -} - static Bool ShmDestroyPixmap (PixmapPtr pPixmap) { @@ -328,26 +300,24 @@ ShmDestroyPixmap (PixmapPtr pPixmap) return ret; } -void -ShmRegisterFbFuncs(pScreen) - ScreenPtr pScreen; +_X_EXPORT void +ShmRegisterFbFuncs(ScreenPtr pScreen) { shmFuncs[pScreen->myNum] = &fbFuncs; } static int -ProcShmQueryVersion(client) - register ClientPtr client; +ProcShmQueryVersion(ClientPtr client) { xShmQueryVersionReply rep; - register int n; + int n; REQUEST_SIZE_MATCH(xShmQueryVersionReq); rep.type = X_Reply; rep.length = 0; rep.sequenceNumber = client->sequence; rep.sharedPixmaps = sharedPixmaps; - rep.pixmapFormat = pixmapFormat; + rep.pixmapFormat = sharedPixmaps ? ZPixmap : 0; rep.majorVersion = SHM_MAJOR_VERSION; rep.minorVersion = SHM_MINOR_VERSION; #ifndef _MSC_VER @@ -446,8 +416,7 @@ shm_access(ClientPtr client, SHMPERM_TYPE *perm, int readonly) } static int -ProcShmAttach(client) - register ClientPtr client; +ProcShmAttach(ClientPtr client) { SHMSTAT_TYPE buf; ShmDescPtr shmdesc; @@ -508,9 +477,8 @@ ProcShmAttach(client) /*ARGSUSED*/ static int -ShmDetachSegment(value, shmseg) - pointer value; /* must conform to DeleteType */ - XID shmseg; +ShmDetachSegment(pointer value, /* must conform to DeleteType */ + XID shmseg) { ShmDescPtr shmdesc = (ShmDescPtr)value; ShmDescPtr *prev; @@ -528,8 +496,7 @@ ShmDetachSegment(value, shmseg) } static int -ProcShmDetach(client) - register ClientPtr client; +ProcShmDetach(ClientPtr client) { ShmDescPtr shmdesc; REQUEST(xShmDetachReq); @@ -564,7 +531,7 @@ doShmPutImage(DrawablePtr dst, GCPtr pGC, #ifdef PANORAMIX static int -ProcPanoramiXShmPutImage(register ClientPtr client) +ProcPanoramiXShmPutImage(ClientPtr client) { int j, result = 0, orig_x, orig_y; PanoramiXRes *draw, *gc; @@ -711,7 +678,7 @@ ProcPanoramiXShmGetImage(ClientPtr client) } if (client->swapped) { - register int n; + int n; swaps(&xgi.sequenceNumber, n); swapl(&xgi.length, n); swapl(&xgi.visual, n); @@ -723,8 +690,7 @@ ProcPanoramiXShmGetImage(ClientPtr client) } static int -ProcPanoramiXShmCreatePixmap( - register ClientPtr client) +ProcPanoramiXShmCreatePixmap(ClientPtr client) { ScreenPtr pScreen = NULL; PixmapPtr pMap = NULL; @@ -831,8 +797,7 @@ CreatePmap: #endif static int -ProcShmPutImage(client) - register ClientPtr client; +ProcShmPutImage(ClientPtr client) { GCPtr pGC; DrawablePtr pDraw; @@ -943,8 +908,7 @@ ProcShmPutImage(client) static int -ProcShmGetImage(client) - register ClientPtr client; +ProcShmGetImage(ClientPtr client) { DrawablePtr pDraw; long lenPer = 0, length; @@ -1056,14 +1020,10 @@ ProcShmGetImage(client) } static PixmapPtr -fbShmCreatePixmap (pScreen, width, height, depth, addr) - ScreenPtr pScreen; - int width; - int height; - int depth; - char *addr; +fbShmCreatePixmap (ScreenPtr pScreen, + int width, int height, int depth, char *addr) { - register PixmapPtr pPixmap; + PixmapPtr pPixmap; pPixmap = (*pScreen->CreatePixmap)(pScreen, 0, 0, pScreen->rootDepth, 0); if (!pPixmap) @@ -1078,13 +1038,12 @@ fbShmCreatePixmap (pScreen, width, height, depth, addr) } static int -ProcShmCreatePixmap(client) - register ClientPtr client; +ProcShmCreatePixmap(ClientPtr client) { PixmapPtr pMap; DrawablePtr pDraw; DepthPtr pDepth; - register int i, rc; + int i, rc; ShmDescPtr shmdesc; REQUEST(xShmCreatePixmapReq); unsigned int width, height, depth; @@ -1160,8 +1119,7 @@ CreatePmap: } static int -ProcShmDispatch (client) - register ClientPtr client; +ProcShmDispatch (ClientPtr client) { REQUEST(xReq); switch (stuff->data) @@ -1196,8 +1154,7 @@ ProcShmDispatch (client) } static void -SShmCompletionEvent(from, to) - xShmCompletionEvent *from, *to; +SShmCompletionEvent(xShmCompletionEvent *from, xShmCompletionEvent *to) { to->type = from->type; cpswaps(from->sequenceNumber, to->sequenceNumber); @@ -1209,10 +1166,9 @@ SShmCompletionEvent(from, to) } static int -SProcShmQueryVersion(client) - register ClientPtr client; +SProcShmQueryVersion(ClientPtr client) { - register int n; + int n; REQUEST(xShmQueryVersionReq); swaps(&stuff->length, n); @@ -1220,10 +1176,9 @@ SProcShmQueryVersion(client) } static int -SProcShmAttach(client) - ClientPtr client; +SProcShmAttach(ClientPtr client) { - register int n; + int n; REQUEST(xShmAttachReq); swaps(&stuff->length, n); REQUEST_SIZE_MATCH(xShmAttachReq); @@ -1233,10 +1188,9 @@ SProcShmAttach(client) } static int -SProcShmDetach(client) - ClientPtr client; +SProcShmDetach(ClientPtr client) { - register int n; + int n; REQUEST(xShmDetachReq); swaps(&stuff->length, n); REQUEST_SIZE_MATCH(xShmDetachReq); @@ -1245,10 +1199,9 @@ SProcShmDetach(client) } static int -SProcShmPutImage(client) - ClientPtr client; +SProcShmPutImage(ClientPtr client) { - register int n; + int n; REQUEST(xShmPutImageReq); swaps(&stuff->length, n); REQUEST_SIZE_MATCH(xShmPutImageReq); @@ -1268,10 +1221,9 @@ SProcShmPutImage(client) } static int -SProcShmGetImage(client) - ClientPtr client; +SProcShmGetImage(ClientPtr client) { - register int n; + int n; REQUEST(xShmGetImageReq); swaps(&stuff->length, n); REQUEST_SIZE_MATCH(xShmGetImageReq); @@ -1287,10 +1239,9 @@ SProcShmGetImage(client) } static int -SProcShmCreatePixmap(client) - ClientPtr client; +SProcShmCreatePixmap(ClientPtr client) { - register int n; + int n; REQUEST(xShmCreatePixmapReq); swaps(&stuff->length, n); REQUEST_SIZE_MATCH(xShmCreatePixmapReq); @@ -1304,8 +1255,7 @@ SProcShmCreatePixmap(client) } static int -SProcShmDispatch (client) - register ClientPtr client; +SProcShmDispatch (ClientPtr client) { REQUEST(xReq); switch (stuff->data) diff --git a/xorg-server/Xext/shmint.h b/xorg-server/Xext/shmint.h index fc056bc72..f659fd23a 100644 --- a/xorg-server/Xext/shmint.h +++ b/xorg-server/Xext/shmint.h @@ -34,9 +34,6 @@ void ShmRegisterFuncs(ScreenPtr pScreen, ShmFuncsPtr funcs); void -ShmSetPixmapFormat(ScreenPtr pScreen, int format); - -void ShmRegisterFbFuncs(ScreenPtr pScreen); #endif /* _SHMINT_H_ */ diff --git a/xorg-server/Xext/sync.c b/xorg-server/Xext/sync.c index 10d448106..1b3736644 100644 --- a/xorg-server/Xext/sync.c +++ b/xorg-server/Xext/sync.c @@ -72,7 +72,7 @@ PERFORMANCE OF THIS SOFTWARE. #include <X11/extensions/syncstr.h> #include <stdio.h> -#if !defined(WIN32) && !defined(Lynx) +#if !defined(WIN32) #include <sys/time.h> #endif @@ -1405,7 +1405,7 @@ ProcSyncListSystemCounters(client) if (client->swapped) { - register char n; + char n; swaps(&rep.sequenceNumber, n); swapl(&rep.length, n); swapl(&rep.nCounters, n); @@ -1425,7 +1425,7 @@ ProcSyncListSystemCounters(client) if (client->swapped) { - register char n; + char n; swapl(&walklist->counter, n); swapl(&walklist->resolution_hi, n); swapl(&walklist->resolution_lo, n); @@ -1514,7 +1514,7 @@ ProcSyncGetPriority(client) if (client->swapped) { - register char n; + char n; swaps(&rep.sequenceNumber, n); swapl(&rep.priority, n); } @@ -1799,7 +1799,7 @@ ProcSyncQueryCounter(client) rep.value_lo = XSyncValueLow32(pCounter->value); if (client->swapped) { - register char n; + char n; swaps(&rep.sequenceNumber, n); swapl(&rep.length, n); swapl(&rep.value_hi, n); @@ -1981,7 +1981,7 @@ ProcSyncQueryAlarm(client) if (client->swapped) { - register char n; + char n; swaps(&rep.sequenceNumber, n); swapl(&rep.length, n); swapl(&rep.counter, n); @@ -2070,7 +2070,7 @@ SProcSyncInitialize(client) ClientPtr client; { REQUEST(xSyncInitializeReq); - register char n; + char n; swaps(&stuff->length, n); REQUEST_SIZE_MATCH (xSyncInitializeReq); @@ -2083,7 +2083,7 @@ SProcSyncListSystemCounters(client) ClientPtr client; { REQUEST(xSyncListSystemCountersReq); - register char n; + char n; swaps(&stuff->length, n); REQUEST_SIZE_MATCH (xSyncListSystemCountersReq); @@ -2096,7 +2096,7 @@ SProcSyncCreateCounter(client) ClientPtr client; { REQUEST(xSyncCreateCounterReq); - register char n; + char n; swaps(&stuff->length, n); REQUEST_SIZE_MATCH (xSyncCreateCounterReq); @@ -2112,7 +2112,7 @@ SProcSyncSetCounter(client) ClientPtr client; { REQUEST(xSyncSetCounterReq); - register char n; + char n; swaps(&stuff->length, n); REQUEST_SIZE_MATCH (xSyncSetCounterReq); @@ -2128,7 +2128,7 @@ SProcSyncChangeCounter(client) ClientPtr client; { REQUEST(xSyncChangeCounterReq); - register char n; + char n; swaps(&stuff->length, n); REQUEST_SIZE_MATCH (xSyncChangeCounterReq); @@ -2144,7 +2144,7 @@ SProcSyncQueryCounter(client) ClientPtr client; { REQUEST(xSyncQueryCounterReq); - register char n; + char n; swaps(&stuff->length, n); REQUEST_SIZE_MATCH (xSyncQueryCounterReq); @@ -2158,7 +2158,7 @@ SProcSyncDestroyCounter(client) ClientPtr client; { REQUEST(xSyncDestroyCounterReq); - register char n; + char n; swaps(&stuff->length, n); REQUEST_SIZE_MATCH (xSyncDestroyCounterReq); @@ -2172,7 +2172,7 @@ SProcSyncAwait(client) ClientPtr client; { REQUEST(xSyncAwaitReq); - register char n; + char n; swaps(&stuff->length, n); REQUEST_AT_LEAST_SIZE(xSyncAwaitReq); @@ -2187,7 +2187,7 @@ SProcSyncCreateAlarm(client) ClientPtr client; { REQUEST(xSyncCreateAlarmReq); - register char n; + char n; swaps(&stuff->length, n); REQUEST_AT_LEAST_SIZE(xSyncCreateAlarmReq); @@ -2203,7 +2203,7 @@ SProcSyncChangeAlarm(client) ClientPtr client; { REQUEST(xSyncChangeAlarmReq); - register char n; + char n; swaps(&stuff->length, n); REQUEST_AT_LEAST_SIZE(xSyncChangeAlarmReq); @@ -2218,7 +2218,7 @@ SProcSyncQueryAlarm(client) ClientPtr client; { REQUEST(xSyncQueryAlarmReq); - register char n; + char n; swaps(&stuff->length, n); REQUEST_SIZE_MATCH (xSyncQueryAlarmReq); @@ -2232,7 +2232,7 @@ SProcSyncDestroyAlarm(client) ClientPtr client; { REQUEST(xSyncDestroyAlarmReq); - register char n; + char n; swaps(&stuff->length, n); REQUEST_SIZE_MATCH (xSyncDestroyAlarmReq); @@ -2246,7 +2246,7 @@ SProcSyncSetPriority(client) ClientPtr client; { REQUEST(xSyncSetPriorityReq); - register char n; + char n; swaps(&stuff->length, n); REQUEST_SIZE_MATCH (xSyncSetPriorityReq); @@ -2261,7 +2261,7 @@ SProcSyncGetPriority(client) ClientPtr client; { REQUEST(xSyncGetPriorityReq); - register char n; + char n; swaps(&stuff->length, n); REQUEST_SIZE_MATCH (xSyncGetPriorityReq); @@ -2533,7 +2533,7 @@ SyncInitServerTime(void) * IDLETIME implementation */ -static pointer IdleTimeCounter; +static SyncCounter *IdleTimeCounter; static XSyncValue *pIdleTimeValueLess; static XSyncValue *pIdleTimeValueGreater; @@ -2545,38 +2545,69 @@ IdleTimeQueryValue (pointer pCounter, CARD64 *pValue_return) } static void -IdleTimeBlockHandler (pointer env, - struct timeval **wt, - pointer LastSelectMask) +IdleTimeBlockHandler(pointer env, struct timeval **wt, pointer LastSelectMask) { - XSyncValue idle; + XSyncValue idle, old_idle; + SyncTriggerList *list = IdleTimeCounter->pTriglist; + SyncTrigger *trig; if (!pIdleTimeValueLess && !pIdleTimeValueGreater) return; + old_idle = IdleTimeCounter->value; IdleTimeQueryValue (NULL, &idle); + IdleTimeCounter->value = idle; /* push, so CheckTrigger works */ if (pIdleTimeValueLess && XSyncValueLessOrEqual (idle, *pIdleTimeValueLess)) { - AdjustWaitForDelay (wt, 0); + /* + * We've been idle for less than the threshold value, and someone + * wants to know about that, but now we need to know whether they + * want level or edge trigger. Check the trigger list against the + * current idle time, and if any succeed, bomb out of select() + * immediately so we can reschedule. + */ + + for (list = IdleTimeCounter->pTriglist; list; list = list->next) { + trig = list->pTrigger; + if (trig->CheckTrigger(trig, old_idle)) { + AdjustWaitForDelay(wt, 0); + break; + } + } } else if (pIdleTimeValueGreater) { - unsigned long timeout = 0; + /* + * There's a threshold in the positive direction. If we've been + * idle less than it, schedule a wakeup for sometime in the future. + * If we've been idle more than it, and someone wants to know about + * that level-triggered, schedule an immediate wakeup. + */ + unsigned long timeout = -1; - if (XSyncValueLessThan (idle, *pIdleTimeValueGreater)) - { + if (XSyncValueLessThan (idle, *pIdleTimeValueGreater)) { XSyncValue value; Bool overflow; XSyncValueSubtract (&value, *pIdleTimeValueGreater, idle, &overflow); - timeout = XSyncValueLow32 (value); + timeout = min(timeout, XSyncValueLow32 (value)); + } else { + for (list = IdleTimeCounter->pTriglist; list; list = list->next) { + trig = list->pTrigger; + if (trig->CheckTrigger(trig, old_idle)) { + timeout = min(timeout, 0); + break; + } + } } AdjustWaitForDelay (wt, timeout); } + + IdleTimeCounter->value = old_idle; /* pop */ } static void diff --git a/xorg-server/Xext/xcalibrate.c b/xorg-server/Xext/xcalibrate.c index 3fe2bdc5c..3e05e6ca2 100644 --- a/xorg-server/Xext/xcalibrate.c +++ b/xorg-server/Xext/xcalibrate.c @@ -218,11 +218,6 @@ SProcXCalibrateScreenToCoord (ClientPtr client) return ProcXCalibrateScreenToCoord(client); } -static void -XCalibrateResetProc (ExtensionEntry *extEntry) -{ -} - static int ProcXCalibrateDispatch (ClientPtr client) { @@ -292,7 +287,7 @@ XCalibrateExtensionInit(void) extEntry = AddExtension(XCALIBRATE_NAME, XCalibrateNumberEvents, XCalibrateNumberErrors, ProcXCalibrateDispatch, SProcXCalibrateDispatch, - XCalibrateResetProc, StandardMinorOpcode); + NULL, StandardMinorOpcode); if (!extEntry) return; diff --git a/xorg-server/Xext/xcmisc.c b/xorg-server/Xext/xcmisc.c index a42d2e210..1ee173bd6 100644 --- a/xorg-server/Xext/xcmisc.c +++ b/xorg-server/Xext/xcmisc.c @@ -48,10 +48,6 @@ from The Open Group. #define UINT32_MAX 0xffffffffU #endif -static void XCMiscResetProc( - ExtensionEntry * /* extEntry */ -); - static DISPATCH_PROC(ProcXCMiscDispatch); static DISPATCH_PROC(ProcXCMiscGetVersion); static DISPATCH_PROC(ProcXCMiscGetXIDList); @@ -66,22 +62,15 @@ XCMiscExtensionInit(INITARGS) { AddExtension(XCMiscExtensionName, 0, 0, ProcXCMiscDispatch, SProcXCMiscDispatch, - XCMiscResetProc, StandardMinorOpcode); -} - -/*ARGSUSED*/ -static void -XCMiscResetProc (extEntry) - ExtensionEntry *extEntry; -{ + NULL, StandardMinorOpcode); } static int ProcXCMiscGetVersion(client) - register ClientPtr client; + ClientPtr client; { xXCMiscGetVersionReply rep; - register int n; + int n; REQUEST_SIZE_MATCH(xXCMiscGetVersionReq); rep.type = X_Reply; @@ -100,10 +89,10 @@ ProcXCMiscGetVersion(client) static int ProcXCMiscGetXIDRange(client) - register ClientPtr client; + ClientPtr client; { xXCMiscGetXIDRangeReply rep; - register int n; + int n; XID min_id, max_id; REQUEST_SIZE_MATCH(xXCMiscGetXIDRangeReq); @@ -124,11 +113,11 @@ ProcXCMiscGetXIDRange(client) static int ProcXCMiscGetXIDList(client) - register ClientPtr client; + ClientPtr client; { REQUEST(xXCMiscGetXIDListReq); xXCMiscGetXIDListReply rep; - register int n; + int n; XID *pids; unsigned int count; @@ -164,7 +153,7 @@ ProcXCMiscGetXIDList(client) static int ProcXCMiscDispatch (client) - register ClientPtr client; + ClientPtr client; { REQUEST(xReq); switch (stuff->data) @@ -182,9 +171,9 @@ ProcXCMiscDispatch (client) static int SProcXCMiscGetVersion(client) - register ClientPtr client; + ClientPtr client; { - register int n; + int n; REQUEST(xXCMiscGetVersionReq); swaps(&stuff->length, n); @@ -196,9 +185,9 @@ SProcXCMiscGetVersion(client) static int SProcXCMiscGetXIDRange(client) - register ClientPtr client; + ClientPtr client; { - register int n; + int n; REQUEST(xReq); swaps(&stuff->length, n); @@ -207,9 +196,9 @@ SProcXCMiscGetXIDRange(client) static int SProcXCMiscGetXIDList(client) - register ClientPtr client; + ClientPtr client; { - register int n; + int n; REQUEST(xXCMiscGetXIDListReq); swaps(&stuff->length, n); @@ -219,7 +208,7 @@ SProcXCMiscGetXIDList(client) static int SProcXCMiscDispatch (client) - register ClientPtr client; + ClientPtr client; { REQUEST(xReq); switch (stuff->data) diff --git a/xorg-server/Xext/xevie.c b/xorg-server/Xext/xevie.c deleted file mode 100644 index ad1ea52b8..000000000 --- a/xorg-server/Xext/xevie.c +++ /dev/null @@ -1,746 +0,0 @@ -/************************************************************ - -Copyright 2003-2005 Sun Microsystems, Inc. - -All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, and/or sell copies of the Software, and to permit persons -to whom the Software is furnished to do so, provided that the above -copyright notice(s) and this permission notice appear in all copies of -the Software and that both the above copyright notice(s) and this -permission notice appear in supporting documentation. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT -OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL -INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING -FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, -NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION -WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -Except as contained in this notice, the name of a copyright holder -shall not be used in advertising or otherwise to promote the sale, use -or other dealings in this Software without prior written authorization -of the copyright holder. - -************************************************************/ - -#define NEED_REPLIES -#define NEED_EVENTS -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#else -#define XEVIE -#endif - -#include <X11/X.h> -#include <X11/Xproto.h> -#include "misc.h" -#include "dixstruct.h" -#include "extnsionst.h" -#include "colormapst.h" -#include "scrnintstr.h" -#include "servermd.h" -#define _XEVIE_SERVER_ -#include <X11/extensions/Xeviestr.h> -#include <X11/Xfuncproto.h> -#include "input.h" -#include "inputstr.h" -#include "windowstr.h" -#include "cursorstr.h" -#include <xkbsrv.h> - -#include "../os/osdep.h" - -#define NoSuchEvent 0x80000000 - -#ifdef XKB -extern Bool noXkbExtension; -#endif -extern int xeviegrabState; - -static DISPATCH_PROC(ProcXevieDispatch); -static DISPATCH_PROC(SProcXevieDispatch); - -static void XevieResetProc (ExtensionEntry *extEntry); - -static unsigned char XevieReqCode = 0; -static int XevieErrorBase; - -int xevieFlag = 0; -int xevieClientIndex = 0; -DeviceIntPtr xeviekb = NULL; -DeviceIntPtr xeviemouse = NULL; -Mask xevieMask = 0; -int xevieEventSent = 0; -int xevieKBEventSent = 0; -static DevPrivateKey xevieDevicePrivateKey = &xevieDevicePrivateKey; -static Bool xevieModifiersOn = FALSE; - -#define XEVIEINFO(dev) ((xevieDeviceInfoPtr) \ - dixLookupPrivate(&(dev)->devPrivates, xevieDevicePrivateKey)) - -Mask xevieFilters[128] = -{ - NoSuchEvent, /* 0 */ - NoSuchEvent, /* 1 */ - KeyPressMask, /* KeyPress */ - KeyReleaseMask, /* KeyRelease */ - ButtonPressMask, /* ButtonPress */ - ButtonReleaseMask, /* ButtonRelease */ - PointerMotionMask /* MotionNotify (initial state) */ -}; - -typedef struct { - ProcessInputProc processInputProc; - ProcessInputProc realInputProc; - DeviceUnwrapProc unwrapProc; -} xevieDeviceInfoRec, *xevieDeviceInfoPtr; - -typedef struct { - CARD32 time; - KeyClassPtr keyc; -} xevieKeycQueueRec, *xevieKeycQueuePtr; - -#define KEYC_QUEUE_SIZE 100 -static xevieKeycQueueRec keycq[KEYC_QUEUE_SIZE] = {{0, NULL}}; -static int keycqHead = 0, keycqTail = 0; - -static Bool XevieStart(void); -static void XevieEnd(int clientIndex); -static void XevieClientStateCallback(CallbackListPtr *pcbl, pointer nulldata, - pointer calldata); -static void XevieServerGrabStateCallback(CallbackListPtr *pcbl, - pointer nulldata, - pointer calldata); - -static Bool XevieAdd(DeviceIntPtr device, pointer data); -static void XevieWrap(DeviceIntPtr device, ProcessInputProc proc); -static Bool XevieRemove(DeviceIntPtr device, pointer data); -static void doSendEvent(xEvent *xE, DeviceIntPtr device); -static void XeviePointerProcessInputProc(xEvent *xE, DeviceIntPtr dev, - int count); -static void XevieKbdProcessInputProc(xEvent *xE, DeviceIntPtr dev, int count); - -void -XevieExtensionInit (void) -{ - ExtensionEntry* extEntry; - - if (!AddCallback(&ServerGrabCallback,XevieServerGrabStateCallback,NULL)) - return; - - if ((extEntry = AddExtension (XEVIENAME, - 0, - XevieNumberErrors, - ProcXevieDispatch, - SProcXevieDispatch, - XevieResetProc, - StandardMinorOpcode))) { - XevieReqCode = (unsigned char)extEntry->base; - XevieErrorBase = extEntry->errorBase; - } -} - -/*ARGSUSED*/ -static -void XevieResetProc (ExtensionEntry *extEntry) -{ -} - -static -int ProcXevieQueryVersion (register ClientPtr client) -{ - xXevieQueryVersionReply rep; - int n; - - REQUEST_SIZE_MATCH (xXevieQueryVersionReq); - rep.type = X_Reply; - rep.length = 0; - rep.sequence_number = client->sequence; - rep.server_major_version = XEVIE_MAJOR_VERSION; - rep.server_minor_version = XEVIE_MINOR_VERSION; - if (client->swapped) { - swaps(&rep.sequence_number, n); - swapl(&rep.length, n); - swaps(&rep.server_major_version, n); - swaps(&rep.server_minor_version, n); - } - WriteToClient (client, sizeof (xXevieQueryVersionReply), (char *)&rep); - return client->noClientException; -} - -static -int ProcXevieStart (register ClientPtr client) -{ - xXevieStartReply rep; - int n; - - REQUEST_SIZE_MATCH (xXevieStartReq); - rep.pad1 = 0; - - if(!xevieFlag){ - if (AddCallback(&ClientStateCallback,XevieClientStateCallback,NULL)) { - xevieFlag = 1; - rep.pad1 = 1; - xevieClientIndex = client->index; - if(!keycq[0].time ) { - int i; - for(i=0; i<KEYC_QUEUE_SIZE; i++) { - keycq[i].keyc = xalloc(sizeof(KeyClassRec)); - keycq[i].keyc->xkbInfo = xalloc(sizeof(XkbSrvInfoRec)); - } - } - } else - return BadAlloc; - } else - return BadAccess; -#ifdef XKB - if (!noXkbExtension) { - if (!XevieStart()) { - DeleteCallback(&ClientStateCallback,XevieClientStateCallback,NULL); - return BadAlloc; - } - } -#endif - - xevieModifiersOn = FALSE; - - rep.length = 0; - rep.type = X_Reply; - rep.sequence_number = client->sequence; - if (client->swapped) { - swaps(&rep.sequence_number, n); - swapl(&rep.length, n); - } - WriteToClient (client, sizeof (xXevieStartReply), (char *)&rep); - return client->noClientException; -} - -static -int ProcXevieEnd (register ClientPtr client) -{ - xXevieEndReply rep; - int n; - - REQUEST_SIZE_MATCH (xXevieEndReq); - - if (xevieFlag) { - if (client->index != xevieClientIndex) - return BadAccess; - - DeleteCallback(&ClientStateCallback,XevieClientStateCallback,NULL); - XevieEnd(xevieClientIndex); - } - - rep.length = 0; - rep.type = X_Reply; - rep.sequence_number = client->sequence; - if (client->swapped) { - swaps(&rep.sequence_number, n); - swapl(&rep.length, n); - } - WriteToClient (client, sizeof (xXevieEndReply), (char *)&rep); - return client->noClientException; -} - -static -int ProcXevieSend (register ClientPtr client) -{ - REQUEST (xXevieSendReq); - xXevieSendReply rep; - xEvent *xE; - static unsigned char lastDetail = 0, lastType = 0; - int n; - - REQUEST_SIZE_MATCH (xXevieSendReq); - - if (client->index != xevieClientIndex) - return BadAccess; - - xE = (xEvent *)&stuff->event; - rep.length = 0; - rep.type = X_Reply; - rep.sequence_number = client->sequence; - if (client->swapped) { - swaps(&rep.sequence_number, n); - swapl(&rep.length, n); - } - WriteToClient (client, sizeof (xXevieSendReply), (char *)&rep); - - switch(xE->u.u.type) { - case KeyPress: - case KeyRelease: - xevieKBEventSent = 1; -#ifdef XKB - if(!noXkbExtension) - doSendEvent(xE, inputInfo.keyboard); - else -#endif - CoreProcessKeyboardEvent (xE, xeviekb, 1); - break; - case ButtonPress: - case ButtonRelease: - case MotionNotify: - xevieEventSent = 1; -#ifdef XKB - if(!noXkbExtension) - doSendEvent(xE, inputInfo.pointer); - else -#endif - CoreProcessPointerEvent(xE, xeviemouse, 1); - break; - default: - break; - } - lastType = xE->u.u.type; - lastDetail = xE->u.u.detail; - return client->noClientException; -} - -static -int ProcXevieSelectInput (register ClientPtr client) -{ - REQUEST (xXevieSelectInputReq); - xXevieSelectInputReply rep; - int n; - - REQUEST_SIZE_MATCH (xXevieSelectInputReq); - - if (client->index != xevieClientIndex) - return BadAccess; - - xevieMask = stuff->event_mask; - rep.length = 0; - rep.type = X_Reply; - rep.sequence_number = client->sequence; - if (client->swapped) { - swaps(&rep.sequence_number, n); - swapl(&rep.length, n); - } - WriteToClient (client, sizeof (xXevieSelectInputReply), (char *)&rep); - return client->noClientException; -} - -static -int ProcXevieDispatch (register ClientPtr client) -{ - REQUEST (xReq); - switch (stuff->data) - { - case X_XevieQueryVersion: - return ProcXevieQueryVersion (client); - case X_XevieStart: - return ProcXevieStart (client); - case X_XevieEnd: - return ProcXevieEnd (client); - case X_XevieSend: - return ProcXevieSend (client); - case X_XevieSelectInput: - return ProcXevieSelectInput(client); - default: - return BadRequest; - } -} - -static -int SProcXevieQueryVersion (register ClientPtr client) -{ - register int n; - - REQUEST(xXevieQueryVersionReq); - swaps (&stuff->length, n); - REQUEST_SIZE_MATCH (xXevieQueryVersionReq); - swaps (&stuff->client_major_version, n); - swaps (&stuff->client_minor_version, n); - return ProcXevieQueryVersion(client); -} - -static -int SProcXevieStart (ClientPtr client) -{ - register int n; - - REQUEST (xXevieStartReq); - swaps (&stuff->length, n); - REQUEST_SIZE_MATCH (xXevieStartReq); - swapl (&stuff->screen, n); - return ProcXevieStart (client); -} - -static -int SProcXevieEnd (ClientPtr client) -{ - register int n; - - REQUEST (xXevieEndReq); - swaps (&stuff->length, n); - REQUEST_SIZE_MATCH (xXevieEndReq); - swapl (&stuff->cmap, n); - return ProcXevieEnd (client); -} - -static -int SProcXevieSend (ClientPtr client) -{ - register int n; - xEvent eventT; - EventSwapPtr proc; - - REQUEST (xXevieSendReq); - swaps (&stuff->length, n); - REQUEST_SIZE_MATCH (xXevieSendReq); - swapl (&stuff->dataType, n); - - /* Swap event */ - proc = EventSwapVector[stuff->event.u.u.type & 0177]; - if (!proc || proc == NotImplemented) /* no swapping proc; invalid event type? */ - return (BadValue); - (*proc)(&stuff->event, &eventT); - stuff->event = eventT; - - return ProcXevieSend (client); -} - -static -int SProcXevieSelectInput (ClientPtr client) -{ - register int n; - - REQUEST (xXevieSelectInputReq); - swaps (&stuff->length, n); - REQUEST_SIZE_MATCH (xXevieSelectInputReq); - swapl (&stuff->event_mask, n); - return ProcXevieSelectInput (client); -} - - -static -int SProcXevieDispatch (register ClientPtr client) -{ - REQUEST(xReq); - switch (stuff->data) - { - case X_XevieQueryVersion: - return SProcXevieQueryVersion (client); - case X_XevieStart: - return SProcXevieStart (client); - case X_XevieEnd: - return SProcXevieEnd (client); - case X_XevieSend: - return SProcXevieSend (client); - case X_XevieSelectInput: - return SProcXevieSelectInput(client); - default: - return BadRequest; - } -} -/*======================================================*/ - -#define WRAP_INPUTPROC(dev,store,inputProc) \ - store->processInputProc = dev->public.processInputProc; \ - dev->public.processInputProc = inputProc; \ - store->realInputProc = dev->public.realInputProc; \ - dev->public.realInputProc = inputProc; - -#define COND_WRAP_INPUTPROC(dev,store,inputProc) \ - if (dev->public.processInputProc == dev->public.realInputProc) \ - dev->public.processInputProc = inputProc; \ - store->processInputProc = \ - store->realInputProc = dev->public.realInputProc; \ - dev->public.realInputProc = inputProc; - -#define UNWRAP_INPUTPROC(dev,restore) \ - dev->public.processInputProc = restore->processInputProc; \ - dev->public.realInputProc = restore->realInputProc; - -#define UNWRAP_INPUTPROC(dev,restore) \ - dev->public.processInputProc = restore->processInputProc; \ - dev->public.realInputProc = restore->realInputProc; - -#define XEVIE_EVENT(xE) \ - (xevieFlag \ - && !xeviegrabState \ - && clients[xevieClientIndex] \ - && (xevieMask & xevieFilters[xE->u.u.type])) - - -static void -sendEvent(ClientPtr pClient, xEvent *xE) -{ - if(pClient->swapped) { - xEvent eventTo; - - /* Remember to strip off the leading bit of type in case - this event was sent with "SendEvent." */ - (*EventSwapVector[xE->u.u.type & 0177]) (xE, &eventTo); - (void)WriteToClient(pClient, sizeof(xEvent), (char *)&eventTo); - } else { - (void)WriteToClient(pClient, sizeof(xEvent), (char *) xE); - } -} - -static void -XevieKbdProcessInputProc(xEvent *xE, DeviceIntPtr dev, int count) -{ - int key, bit; - BYTE *kptr; - ProcessInputProc tmp; - KeyClassPtr keyc = dev->key; - xevieDeviceInfoPtr xeviep = XEVIEINFO(dev); - - if(XEVIE_EVENT(xE)) { - key = xE->u.u.detail; - kptr = &keyc->down[key >> 3]; - bit = 1 << (key & 7); - - if (dev->key->modifierMap[xE->u.u.detail]) - xevieModifiersOn = TRUE; - - xE->u.keyButtonPointer.event = xeviewin->drawable.id; - xE->u.keyButtonPointer.root = GetCurrentRootWindow()->drawable.id; - xE->u.keyButtonPointer.child = (xeviewin->firstChild) - ? xeviewin->firstChild->drawable.id:0; - xE->u.keyButtonPointer.rootX = xeviehot.x; - xE->u.keyButtonPointer.rootY = xeviehot.y; - xE->u.keyButtonPointer.state = keyc->state | inputInfo.pointer->button->state; - /* fix bug: sequence lost in Xlib */ - xE->u.u.sequenceNumber = clients[xevieClientIndex]->sequence; -#ifdef XKB - /* fix for bug5092586 */ - if(!noXkbExtension) { - switch(xE->u.u.type) { - case KeyPress: *kptr |= bit; break; - case KeyRelease: *kptr &= ~bit; break; - } - } -#endif - keycq[keycqHead].time = xE->u.keyButtonPointer.time; - memcpy(keycq[keycqHead].keyc, keyc, sizeof(KeyClassRec) - sizeof(KeyClassPtr)); - memcpy(keycq[keycqHead].keyc->xkbInfo, keyc->xkbInfo, sizeof(XkbSrvInfoRec)); - if(++keycqHead >=KEYC_QUEUE_SIZE) - keycqHead = 0; - sendEvent(clients[xevieClientIndex], xE); - return; - } - - tmp = dev->public.realInputProc; - UNWRAP_INPUTPROC(dev,xeviep); - dev->public.processInputProc(xE,dev,count); - COND_WRAP_INPUTPROC(dev,xeviep,tmp); -} - -static void -XeviePointerProcessInputProc(xEvent *xE, DeviceIntPtr dev, int count) -{ - xevieDeviceInfoPtr xeviep = XEVIEINFO(dev); - ProcessInputProc tmp; - - if (XEVIE_EVENT(xE)) { - /* fix bug: sequence lost in Xlib */ - xE->u.u.sequenceNumber = clients[xevieClientIndex]->sequence; - sendEvent(clients[xevieClientIndex], xE); - return; - } - - tmp = dev->public.realInputProc; - UNWRAP_INPUTPROC(dev,xeviep); - dev->public.processInputProc(xE,dev,count); - COND_WRAP_INPUTPROC(dev,xeviep,tmp); -} - -static Bool -XevieStart(void) -{ - ProcessInputProc prp; - prp = XevieKbdProcessInputProc; - if (!XevieAdd(inputInfo.keyboard,&prp)) - return FALSE; - prp = XeviePointerProcessInputProc; - if (!XevieAdd(inputInfo.pointer,&prp)) - return FALSE; - - return TRUE; -} - - -static void -XevieEnd(int clientIndex) -{ - if (!clientIndex || clientIndex == xevieClientIndex) { - -#ifdef XKB - if(!noXkbExtension) { - - XevieRemove(inputInfo.keyboard,NULL); - - inputInfo.keyboard->public.processInputProc = CoreProcessKeyboardEvent; - inputInfo.keyboard->public.realInputProc = CoreProcessKeyboardEvent; - XkbSetExtension(inputInfo.keyboard,ProcessKeyboardEvent); - - - XevieRemove(inputInfo.pointer,NULL); - - inputInfo.pointer->public.processInputProc = CoreProcessPointerEvent; - inputInfo.pointer->public.realInputProc = CoreProcessPointerEvent; - XkbSetExtension(inputInfo.pointer,ProcessPointerEvent); - } -#endif - - xevieFlag = 0; - xevieClientIndex = 0; - DeleteCallback (&ClientStateCallback, XevieClientStateCallback, NULL); - } -} - -static void -XevieClientStateCallback(CallbackListPtr *pcbl, pointer nulldata, - pointer calldata) -{ - NewClientInfoRec *pci = (NewClientInfoRec *)calldata; - ClientPtr client = pci->client; - if (client->clientState == ClientStateGone - || client->clientState == ClientStateRetained) - XevieEnd(client->index); -} - -static void -XevieServerGrabStateCallback(CallbackListPtr *pcbl, pointer nulldata, - pointer calldata) -{ - ServerGrabInfoRec *grbinfo = (ServerGrabInfoRec *)calldata; - if (grbinfo->grabstate == SERVER_GRABBED) - xeviegrabState = TRUE; - else - xeviegrabState = FALSE; -} - -#define UNWRAP_UNWRAPPROC(device,proc_store) \ - device->unwrapProc = proc_store; - -#define WRAP_UNWRAPPROC(device,proc_store,proc) \ - proc_store = device->unwrapProc; \ - device->unwrapProc = proc; - -static void -xevieUnwrapProc(DeviceIntPtr device, DeviceHandleProc proc, pointer data) -{ - xevieDeviceInfoPtr xeviep = XEVIEINFO(device); - ProcessInputProc tmp = device->public.processInputProc; - - UNWRAP_INPUTPROC(device,xeviep); - UNWRAP_UNWRAPPROC(device,xeviep->unwrapProc); - proc(device,data); - WRAP_INPUTPROC(device,xeviep,tmp); - WRAP_UNWRAPPROC(device,xeviep->unwrapProc,xevieUnwrapProc); -} - -static Bool -XevieUnwrapAdd(DeviceIntPtr device, void* data) -{ - if (device->unwrapProc) - device->unwrapProc(device,XevieUnwrapAdd,data); - else { - ProcessInputProc *ptr = data; - XevieWrap(device,*ptr); - } - - return TRUE; -} - -static Bool -XevieAdd(DeviceIntPtr device, void* data) -{ - xevieDeviceInfoPtr xeviep; - - xeviep = xalloc (sizeof (xevieDeviceInfoRec)); - if (!xeviep) - return FALSE; - - dixSetPrivate(&device->devPrivates, xevieDevicePrivateKey, xeviep); - XevieUnwrapAdd(device, data); - - return TRUE; -} - -static Bool -XevieRemove(DeviceIntPtr device,pointer data) -{ - xevieDeviceInfoPtr xeviep = XEVIEINFO(device); - - if (!xeviep) return TRUE; - - UNWRAP_INPUTPROC(device,xeviep); - UNWRAP_UNWRAPPROC(device,xeviep->unwrapProc); - - xfree(xeviep); - dixSetPrivate(&device->devPrivates, xevieDevicePrivateKey, NULL); - return TRUE; -} - -static void -XevieWrap(DeviceIntPtr device, ProcessInputProc proc) -{ - xevieDeviceInfoPtr xeviep = XEVIEINFO(device); - - WRAP_INPUTPROC(device,xeviep,proc); - WRAP_UNWRAPPROC(device,xeviep->unwrapProc,xevieUnwrapProc); -} - -static void -doSendEvent(xEvent *xE, DeviceIntPtr dev) -{ - xevieDeviceInfoPtr xeviep = XEVIEINFO(dev); - ProcessInputProc tmp = dev->public.realInputProc; - if (((xE->u.u.type==KeyPress)||(xE->u.u.type==KeyRelease)) - && !xevieModifiersOn) { - KeyClassPtr keyc = dev->key; - CARD8 realModes = dev->key->modifierMap[xE->u.u.detail]; - int notFound = 0; - /* if some events are consumed by client, move the queue tail pointer to the current - event which just comes back from Xevie client . - */ - if(keycq[keycqTail].time != xE->u.keyButtonPointer.time) { - while(keycq[keycqTail].time != xE->u.keyButtonPointer.time) { - if(++keycqTail >= KEYC_QUEUE_SIZE) - keycqTail = 0; - if(keycqTail == keycqHead) { - notFound = 1; - break; - } - } - } - if(!notFound) { - dev->key = keycq[keycqTail].keyc; - if(++keycqTail >= KEYC_QUEUE_SIZE) - keycqTail = 0; - } - dev->key->modifierMap[xE->u.u.detail] = 0; - - if(dev->key->xkbInfo->repeatKey != 0 && xE->u.u.type != KeyPress) - XkbLastRepeatEvent= (pointer)xE; - UNWRAP_INPUTPROC(dev,xeviep); - dev->public.processInputProc(xE,dev,1); - COND_WRAP_INPUTPROC(dev,xeviep,tmp); - XkbLastRepeatEvent= NULL; - - dev->key->modifierMap[xE->u.u.detail] = realModes; - dev->key = keyc; - if(notFound) { - DeleteCallback(&ClientStateCallback,XevieClientStateCallback,NULL); - XevieEnd(xevieClientIndex); - ErrorF("Error: Xevie keyc queue size is not enough, disable Xevie\n"); - } - } else { - UNWRAP_INPUTPROC(dev,xeviep); - dev->public.processInputProc(xE,dev,1); - COND_WRAP_INPUTPROC(dev,xeviep,tmp); - } -} - diff --git a/xorg-server/Xext/xf86bigfont.c b/xorg-server/Xext/xf86bigfont.c index d5c5704de..dabbdd6e0 100644 --- a/xorg-server/Xext/xf86bigfont.c +++ b/xorg-server/Xext/xf86bigfont.c @@ -50,7 +50,7 @@ #ifdef SVR4 #include <sys/sysmacros.h> #endif -#if defined(ISC) || defined(__CYGWIN__) || defined(__SCO__) +#if defined(__CYGWIN__) || defined(__SCO__) #include <sys/param.h> #include <sys/sysmacros.h> #endif diff --git a/xorg-server/Xext/xprint.c b/xorg-server/Xext/xprint.c deleted file mode 100644 index a5d8fcc33..000000000 --- a/xorg-server/Xext/xprint.c +++ /dev/null @@ -1,2617 +0,0 @@ -/* -(c) Copyright 1996 Hewlett-Packard Company -(c) Copyright 1996 International Business Machines Corp. -(c) Copyright 1996 Sun Microsystems, Inc. -(c) Copyright 1996 Novell, Inc. -(c) Copyright 1996 Digital Equipment Corp. -(c) Copyright 1996 Fujitsu Limited -(c) Copyright 1996 Hitachi, Ltd. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the names of the copyright holders shall -not be used in advertising or otherwise to promote the sale, use or other -dealings in this Software without prior written authorization from said -copyright holders. -*/ -/******************************************************************* -** -** ********************************************************* -** * -** * File: xprint.c -** * -** * Copyright: Copyright 1993, 1995 Hewlett-Packard Company -** * -** * Copyright 1989 by The Massachusetts Institute of Technology -** * -** * Permission to use, copy, modify, and distribute this -** * software and its documentation for any purpose and without -** * fee is hereby granted, provided that the above copyright -** * notice appear in all copies and that both that copyright -** * notice and this permission notice appear in supporting -** * documentation, and that the name of MIT not be used in -** * advertising or publicity pertaining to distribution of the -** * software without specific prior written permission. -** * M.I.T. makes no representation about the suitability of -** * this software for any purpose. It is provided "as is" -** * without any express or implied warranty. -** * -** * MIT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -** * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT- -** * NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MIT BE LI- -** * ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR -** * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR -** * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -** * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH -** * THE USE OR PERFORMANCE OF THIS SOFTWARE. -** * -** ********************************************************* -** -********************************************************************/ - -#define _XP_PRINT_SERVER_ -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include <X11/X.h> -#include <X11/Xos.h> -#define NEED_EVENTS -#include <X11/Xproto.h> -#undef NEED_EVENTS -#include "misc.h" -#include "windowstr.h" -#include "scrnintstr.h" -#include "pixmapstr.h" -#include "extnsionst.h" -#include "dixstruct.h" -#include <X11/Xatom.h> -#include <X11/extensions/Print.h> -#include <X11/extensions/Printstr.h> -#include "../hw/xprint/DiPrint.h" -#include "../hw/xprint/attributes.h" -#include "modinit.h" - -static void XpResetProc(ExtensionEntry *); - -static int ProcXpDispatch(ClientPtr); -static int ProcXpSwappedDispatch(ClientPtr); - -static int ProcXpQueryVersion(ClientPtr); -static int ProcXpGetPrinterList(ClientPtr); -static int ProcXpCreateContext(ClientPtr); -static int ProcXpSetContext(ClientPtr); -static int ProcXpGetContext(ClientPtr); -static int ProcXpDestroyContext(ClientPtr); -static int ProcXpGetContextScreen(ClientPtr); -static int ProcXpStartJob(ClientPtr); -static int ProcXpEndJob(ClientPtr); -static int ProcXpStartDoc(ClientPtr); -static int ProcXpEndDoc(ClientPtr); -static int ProcXpStartPage(ClientPtr); -static int ProcXpEndPage(ClientPtr); -static int ProcXpSelectInput(ClientPtr); -static int ProcXpInputSelected(ClientPtr); -static int ProcXpPutDocumentData(ClientPtr); -static int ProcXpGetDocumentData(ClientPtr); -static int ProcXpGetAttributes(ClientPtr); -static int ProcXpGetOneAttribute(ClientPtr); -static int ProcXpSetAttributes(ClientPtr); -static int ProcXpRehashPrinterList(ClientPtr); -static int ProcXpQueryScreens(ClientPtr); -static int ProcXpGetPageDimensions(ClientPtr); -static int ProcXpSetImageResolution(ClientPtr); -static int ProcXpGetImageResolution(ClientPtr); - -static void SwapXpNotifyEvent(xPrintPrintEvent *, xPrintPrintEvent *); -static void SwapXpAttributeEvent(xPrintAttributeEvent *, xPrintAttributeEvent *); - -static int SProcXpGetPrinterList(ClientPtr); -static int SProcXpCreateContext(ClientPtr); -static int SProcXpSetContext(ClientPtr); -static int SProcXpGetContext(ClientPtr); -static int SProcXpDestroyContext(ClientPtr); -static int SProcXpGetContextScreen(ClientPtr); -static int SProcXpStartJob(ClientPtr); -static int SProcXpEndJob(ClientPtr); -static int SProcXpStartDoc(ClientPtr); -static int SProcXpEndDoc(ClientPtr); -static int SProcXpStartPage(ClientPtr); -static int SProcXpEndPage(ClientPtr); -static int SProcXpSelectInput(ClientPtr); -static int SProcXpInputSelected(ClientPtr); -static int SProcXpPutDocumentData(ClientPtr); -static int SProcXpGetDocumentData(ClientPtr); -static int SProcXpGetAttributes(ClientPtr); -static int SProcXpGetOneAttribute(ClientPtr); -static int SProcXpSetAttributes(ClientPtr); -static int SProcXpRehashPrinterList(ClientPtr); -static int SProcXpGetPageDimensions(ClientPtr); -static int SProcXpSetImageResolution(ClientPtr); -static int SProcXpGetImageResolution(ClientPtr); - -static void SendXpNotify(XpContextPtr, int, int); -static void SendAttributeNotify(XpContextPtr, int); -static int XpFreeClient(pointer, XID); -static int XpFreeContext(pointer, XID); -static int XpFreePage(pointer, XID); -static Bool XpCloseScreen(int, ScreenPtr); -static CARD32 GetAllEventMasks(XpContextPtr); -static struct _XpClient *CreateXpClient(ClientPtr); -static struct _XpClient *FindClient(XpContextPtr, ClientPtr); -static struct _XpClient *AcquireClient(XpContextPtr, ClientPtr); - -typedef struct _driver { - struct _driver *next; - char *name; - int (* CreateContext)(XpContextPtr); -} XpDriverRec, *XpDriverPtr; - -typedef struct _xpScreen { - Bool (* CloseScreen)(int, ScreenPtr); - struct _driver *drivers; -} XpScreenRec, *XpScreenPtr; - -/* - * Each context has a list of XpClients indicating which clients have - * associated this context with their connection. - * Each such client has a RTclient resource allocated for it, - * and this per-client - * resource is used to delete the XpClientRec if/when the client closes - * its connection. - * The list of XpClients is also walked if/when the context is destroyed - * so that the ContextPtr can be removed from the client's devPrivates. - */ -typedef struct _XpClient { - struct _XpClient *pNext; - ClientPtr client; - XpContextPtr context; - CARD32 eventMask; - XID contextClientID; /* unneeded sanity check? */ -} XpClientRec, *XpClientPtr; - -static void FreeXpClient(XpClientPtr, Bool); - -/* - * Each StartPage request specifies a window which forms the top level - * window of the page. One of the following structs is created as a - * RTpage resource with the same ID as the window itself. This enables - * us to clean up when/if the window is destroyed, and to prevent the - * same window from being simultaneously referenced in multiple contexts. - * The page resource is created at the first StartPage on a given window, - * and is only destroyed when/if the window is destroyed. When the - * EndPage is recieved (or an EndDoc or EndJob) the context field is - * set to NULL, but the resource remains alive. - */ -typedef struct _XpPage { - XpContextPtr context; -} XpPageRec, *XpPagePtr; - -typedef struct _XpStPageRec { - XpContextPtr pContext; - Bool slept; - XpPagePtr pPage; - WindowPtr pWin; -} XpStPageRec, *XpStPagePtr; - -typedef struct _XpStDocRec { - XpContextPtr pContext; - Bool slept; - CARD8 type; -} XpStDocRec, *XpStDocPtr; - -#define QUADPAD(x) ((((x)+3)>>2)<<2) - -/* - * Possible bit-mask values in the "state" field of a XpContextRec. - */ -#define JOB_STARTED (1 << 0) -#define DOC_RAW_STARTED (1 << 1) -#define DOC_COOKED_STARTED (1 << 2) -#define PAGE_STARTED (1 << 3) -#define GET_DOC_DATA_STARTED (1 << 4) -#define JOB_GET_DATA (1 << 5) - -static XpScreenPtr XpScreens[MAXSCREENS]; -static unsigned char XpReqCode; -static int XpEventBase; -static int XpErrorBase; -static DevPrivateKey XpClientPrivateKey = &XpClientPrivateKey; - -#define XP_GETPRIV(pClient) ((XpContextPtr) \ - dixLookupPrivate(&(pClient)->devPrivates, XpClientPrivateKey)) -#define XP_SETPRIV(pClient, p) \ - dixSetPrivate(&(pClient)->devPrivates, XpClientPrivateKey, p) - -/* - * There are three types of resources involved. One is the resource associated - * with the context itself, with an ID specified by a printing client. The - * next is a resource created by us on the client's behalf (and unknown to - * the client) when a client inits or sets a context which allows us to - * track each client's interest in events - * on a particular context, and also allows us to clean up this interest - * record when/if the client's connection is closed. Finally, there is - * a resource created for each window that's specified in a StartPage. This - * resource carries the same ID as the window itself, and enables us to - * easily prevent the same window being referenced in multiple contexts - * simultaneously, and enables us to clean up if the window is destroyed - * before the EndPage. - */ -static RESTYPE RTclient, RTcontext, RTpage; - -/* - * allEvents is the OR of all the legal event mask bits. - */ -static CARD32 allEvents = XPPrintMask | XPAttributeMask; - - -/******************************************************************************* - * - * ExtensionInit, Driver Init functions, QueryVersion, and Dispatch procs - * - ******************************************************************************/ - -/* - * XpExtensionInit - * - * Called from InitExtensions in main() usually through miinitextension - * - */ - -void -XpExtensionInit(INITARGS) -{ - ExtensionEntry *extEntry; - int i; - - RTclient = CreateNewResourceType(XpFreeClient); - RTcontext = CreateNewResourceType(XpFreeContext); - RTpage = CreateNewResourceType(XpFreePage); - if (RTclient && RTcontext && RTpage && - (extEntry = AddExtension(XP_PRINTNAME, XP_EVENTS, XP_ERRORS, - ProcXpDispatch, ProcXpSwappedDispatch, - XpResetProc, StandardMinorOpcode))) - { - XpReqCode = (unsigned char)extEntry->base; - XpEventBase = extEntry->eventBase; - XpErrorBase = extEntry->errorBase; - EventSwapVector[XpEventBase] = (EventSwapPtr) SwapXpNotifyEvent; - EventSwapVector[XpEventBase+1] = (EventSwapPtr) SwapXpAttributeEvent; - } - - for(i = 0; i < MAXSCREENS; i++) - { - /* - * If a screen has registered with our extension, then we - * wrap the screen's CloseScreen function to allow us to - * reset our ContextPrivate stuff. Note that this - * requires a printing DDX to call XpRegisterInitFunc - * _before_ this extension is initialized - i.e. at screen init - * time, _not_ at root window creation time. - */ - if(XpScreens[i] != (XpScreenPtr)NULL) - { - XpScreens[i]->CloseScreen = screenInfo.screens[i]->CloseScreen; - screenInfo.screens[i]->CloseScreen = XpCloseScreen; - } - } -} - -static void -XpResetProc(ExtensionEntry *extEntry) -{ - /* - * We can't free up the XpScreens recs here, because extensions are - * closed before screens, and our CloseScreen function uses the XpScreens - * recs. - - int i; - - for(i = 0; i < MAXSCREENS; i++) - { - if(XpScreens[i] != (XpScreenPtr)NULL) - Xfree(XpScreens[i]); - XpScreens[i] = (XpScreenPtr)NULL; - } - */ -} - -static Bool -XpCloseScreen(int index, ScreenPtr pScreen) -{ - Bool (* CloseScreen)(int, ScreenPtr); - - CloseScreen = XpScreens[index]->CloseScreen; - if(XpScreens[index] != (XpScreenPtr)NULL) - { - XpDriverPtr pDriv, nextDriv; - - pDriv = XpScreens[index]->drivers; - while(pDriv != (XpDriverPtr)NULL) - { - nextDriv = pDriv->next; - Xfree(pDriv); - pDriv = nextDriv; - } - Xfree(XpScreens[index]); - } - XpScreens[index] = (XpScreenPtr)NULL; - - return (*CloseScreen)(index, pScreen); -} - -/* - * XpRegisterInitFunc tells the print extension which screens - * are printers as opposed to displays, and what drivers are - * supported on each screen. This eliminates the need of - * allocating print-related private structures on windows on _all_ screens. - * It also hands the extension a pointer to the routine to be called - * whenever a context gets created for a particular driver on this screen. - */ -void -XpRegisterInitFunc(ScreenPtr pScreen, char *driverName, int (*initContext)(struct _XpContext *)) -{ - XpDriverPtr pDriver; - - if(XpScreens[pScreen->myNum] == 0) - { - if((XpScreens[pScreen->myNum] = - (XpScreenPtr) Xalloc(sizeof(XpScreenRec))) == 0) - return; - XpScreens[pScreen->myNum]->CloseScreen = 0; - XpScreens[pScreen->myNum]->drivers = 0; - } - - if((pDriver = (XpDriverPtr)Xalloc(sizeof(XpDriverRec))) == 0) - return; - pDriver->next = XpScreens[pScreen->myNum]->drivers; - pDriver->name = driverName; - pDriver->CreateContext = initContext; - XpScreens[pScreen->myNum]->drivers = pDriver; -} - -static int -ProcXpDispatch(ClientPtr client) -{ - REQUEST(xReq); - - switch(stuff->data) - { - case X_PrintQueryVersion: - return ProcXpQueryVersion(client); - case X_PrintGetPrinterList: - return ProcXpGetPrinterList(client); - case X_PrintCreateContext: - return ProcXpCreateContext(client); - case X_PrintSetContext: - return ProcXpSetContext(client); - case X_PrintGetContext: - return ProcXpGetContext(client); - case X_PrintDestroyContext: - return ProcXpDestroyContext(client); - case X_PrintGetContextScreen: - return ProcXpGetContextScreen(client); - case X_PrintStartJob: - return ProcXpStartJob(client); - case X_PrintEndJob: - return ProcXpEndJob(client); - case X_PrintStartDoc: - return ProcXpStartDoc(client); - case X_PrintEndDoc: - return ProcXpEndDoc(client); - case X_PrintStartPage: - return ProcXpStartPage(client); - case X_PrintEndPage: - return ProcXpEndPage(client); - case X_PrintSelectInput: - return ProcXpSelectInput(client); - case X_PrintInputSelected: - return ProcXpInputSelected(client); - case X_PrintPutDocumentData: - return ProcXpPutDocumentData(client); - case X_PrintGetDocumentData: - return ProcXpGetDocumentData(client); - case X_PrintSetAttributes: - return ProcXpSetAttributes(client); - case X_PrintGetAttributes: - return ProcXpGetAttributes(client); - case X_PrintGetOneAttribute: - return ProcXpGetOneAttribute(client); - case X_PrintRehashPrinterList: - return ProcXpRehashPrinterList(client); - case X_PrintQueryScreens: - return ProcXpQueryScreens(client); - case X_PrintGetPageDimensions: - return ProcXpGetPageDimensions(client); - case X_PrintSetImageResolution: - return ProcXpSetImageResolution(client); - case X_PrintGetImageResolution: - return ProcXpGetImageResolution(client); - default: - return BadRequest; - } -} - -static int -ProcXpSwappedDispatch(ClientPtr client) -{ - int temp; - REQUEST(xReq); - - switch(stuff->data) - { - case X_PrintQueryVersion: - swaps(&stuff->length, temp); - return ProcXpQueryVersion(client); - case X_PrintGetPrinterList: - return SProcXpGetPrinterList(client); - case X_PrintCreateContext: - return SProcXpCreateContext(client); - case X_PrintSetContext: - return SProcXpSetContext(client); - case X_PrintGetContext: - return SProcXpGetContext(client); - case X_PrintDestroyContext: - return SProcXpDestroyContext(client); - case X_PrintGetContextScreen: - return SProcXpGetContextScreen(client); - case X_PrintStartJob: - return SProcXpStartJob(client); - case X_PrintEndJob: - return SProcXpEndJob(client); - case X_PrintStartDoc: - return SProcXpStartDoc(client); - case X_PrintEndDoc: - return SProcXpEndDoc(client); - case X_PrintStartPage: - return SProcXpStartPage(client); - case X_PrintEndPage: - return SProcXpEndPage(client); - case X_PrintSelectInput: - return SProcXpSelectInput(client); - case X_PrintInputSelected: - return SProcXpInputSelected(client); - case X_PrintPutDocumentData: - return SProcXpPutDocumentData(client); - case X_PrintGetDocumentData: - return SProcXpGetDocumentData(client); - case X_PrintSetAttributes: - return SProcXpSetAttributes(client); - case X_PrintGetAttributes: - return SProcXpGetAttributes(client); - case X_PrintGetOneAttribute: - return SProcXpGetOneAttribute(client); - case X_PrintRehashPrinterList: - return SProcXpRehashPrinterList(client); - case X_PrintQueryScreens: - swaps(&stuff->length, temp); - return ProcXpQueryScreens(client); - case X_PrintGetPageDimensions: - return SProcXpGetPageDimensions(client); - case X_PrintSetImageResolution: - return SProcXpSetImageResolution(client); - case X_PrintGetImageResolution: - return SProcXpGetImageResolution(client); - default: - return BadRequest; - } -} - -static int -ProcXpQueryVersion(ClientPtr client) -{ - /* REQUEST(xPrintQueryVersionReq); */ - xPrintQueryVersionReply rep; - register int n; - long l; - - REQUEST_SIZE_MATCH(xPrintQueryVersionReq); - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - rep.majorVersion = XP_MAJOR_VERSION; - rep.minorVersion = XP_MINOR_VERSION; - if (client->swapped) { - swaps(&rep.sequenceNumber, n); - swapl(&rep.length, l); - swaps(&rep.majorVersion, n); - swaps(&rep.minorVersion, n); - } - WriteToClient(client, sz_xPrintQueryVersionReply, (char *)&rep); - return client->noClientException; -} - -/******************************************************************************* - * - * GetPrinterList : Return a list of all printers associated with this - * server. Calls XpDiGetPrinterList, which is defined in - * the device-independent code in Xserver/Xprint. - * - ******************************************************************************/ - -static int -ProcXpGetPrinterList(ClientPtr client) -{ - REQUEST(xPrintGetPrinterListReq); - int totalSize; - int numEntries; - XpDiListEntry **pList; - xPrintGetPrinterListReply *rep; - int n, i, totalBytes; - long l; - char *curByte; - - REQUEST_AT_LEAST_SIZE(xPrintGetPrinterListReq); - - totalSize = ((sz_xPrintGetPrinterListReq) >> 2) + - ((stuff->printerNameLen + 3) >> 2) + - ((stuff->localeLen + 3) >> 2); - if(totalSize != client->req_len) - return BadLength; - - pList = XpDiGetPrinterList(stuff->printerNameLen, (char *)(stuff + 1), - stuff->localeLen, (char *)((stuff + 1) + - QUADPAD(stuff->printerNameLen))); - - for(numEntries = 0, totalBytes = sz_xPrintGetPrinterListReply; - pList[numEntries] != (XpDiListEntry *)NULL; - numEntries++) - { - totalBytes += 2 * sizeof(CARD32); - totalBytes += QUADPAD(strlen(pList[numEntries]->name)); - totalBytes += QUADPAD(strlen(pList[numEntries]->description)); - } - - if((rep = (xPrintGetPrinterListReply *)xalloc(totalBytes)) == - (xPrintGetPrinterListReply *)NULL) - return BadAlloc; - - rep->type = X_Reply; - rep->length = (totalBytes - sz_xPrintGetPrinterListReply) >> 2; - rep->sequenceNumber = client->sequence; - rep->listCount = numEntries; - if (client->swapped) { - swaps(&rep->sequenceNumber, n); - swapl(&rep->length, l); - swapl(&rep->listCount, l); - } - - for(i = 0, curByte = (char *)(rep + 1); i < numEntries; i++) - { - CARD32 *pCrd; - int len; - - pCrd = (CARD32 *)curByte; - len = strlen(pList[i]->name); - *pCrd = len; - if (client->swapped) - swapl((long *)curByte, l); - curByte += sizeof(CARD32); - strncpy(curByte, pList[i]->name, len); - curByte += QUADPAD(len); - - pCrd = (CARD32 *)curByte; - len = strlen(pList[i]->description); - *pCrd = len; - if (client->swapped) - swapl((long *)curByte, l); - curByte += sizeof(CARD32); - strncpy(curByte, pList[i]->description, len); - curByte += QUADPAD(len); - } - - XpDiFreePrinterList(pList); - - WriteToClient(client, totalBytes, (char *)rep); - xfree(rep); - return client->noClientException; -} - -/******************************************************************************* - * - * QueryScreens: Returns the list of screens which are associated with - * print drivers. - * - ******************************************************************************/ - -static int -ProcXpQueryScreens(ClientPtr client) -{ - /* REQUEST(xPrintQueryScreensReq); */ - int i, numPrintScreens, totalSize; - WINDOW *pWinId; - xPrintQueryScreensReply *rep; - long l; - - REQUEST_SIZE_MATCH(xPrintQueryScreensReq); - - rep = (xPrintQueryScreensReply *)xalloc(sz_xPrintQueryScreensReply); - pWinId = (WINDOW *)(rep + 1); - - for(i = 0, numPrintScreens = 0, totalSize = sz_xPrintQueryScreensReply; - i < MAXSCREENS; i++) - { - /* - * If a screen has registered with our extension, then it's - * a printer screen. - */ - if(XpScreens[i] != (XpScreenPtr)NULL) - { - numPrintScreens++; - totalSize += sizeof(WINDOW); - rep = (xPrintQueryScreensReply *)xrealloc(rep, totalSize); - /* fix of bug: pWinId should be set again after reallocate rep */ - pWinId = (WINDOW *)(rep + 1); - *pWinId = WindowTable[i]->drawable.id; - if (client->swapped) - swapl((long *)pWinId, l); - } - } - - rep->type = X_Reply; - rep->sequenceNumber = client->sequence; - rep->length = (totalSize - sz_xPrintQueryScreensReply) >> 2; - rep->listCount = numPrintScreens; - if (client->swapped) - { - int n; - - swaps(&rep->sequenceNumber, n); - swapl(&rep->length, l); - swapl(&rep->listCount, l); - } - - WriteToClient(client, totalSize, (char *)rep); - xfree(rep); - return client->noClientException; -} - -static int -ProcXpGetPageDimensions(ClientPtr client) -{ - REQUEST(xPrintGetPageDimensionsReq); - CARD16 width, height; - xRectangle rect; - xPrintGetPageDimensionsReply rep; - XpContextPtr pContext; - int result; - - REQUEST_SIZE_MATCH(xPrintGetPageDimensionsReq); - - if((pContext =(XpContextPtr)SecurityLookupIDByType(client, - stuff->printContext, - RTcontext, - DixReadAccess)) - == (XpContextPtr)NULL) - { - client->errorValue = stuff->printContext; - return XpErrorBase+XPBadContext; - } - - if((pContext->funcs.GetMediumDimensions == 0) || - (pContext->funcs.GetReproducibleArea == 0)) - return BadImplementation; - - result = pContext->funcs.GetMediumDimensions(pContext, &width, &height); - if(result != Success) - return result; - - result = pContext->funcs.GetReproducibleArea(pContext, &rect); - if(result != Success) - return result; - - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.length = 0; - rep.width = width; - rep.height = height; - rep.rx = rect.x; - rep.ry = rect.y; - rep.rwidth = rect.width; - rep.rheight = rect.height; - - if(client->swapped) - { - int n; - long l; - - swaps(&rep.sequenceNumber, n); - swapl(&rep.length, l); - swaps(&rep.width, n); - swaps(&rep.height, n); - swaps(&rep.rx, n); - swaps(&rep.ry, n); - swaps(&rep.rwidth, n); - swaps(&rep.rheight, n); - } - - WriteToClient(client, sz_xPrintGetPageDimensionsReply, (char *)&rep); - return client->noClientException; -} - -static int -ProcXpSetImageResolution(ClientPtr client) -{ - REQUEST(xPrintSetImageResolutionReq); - xPrintSetImageResolutionReply rep; - XpContextPtr pContext; - Bool status; - int result; - - REQUEST_SIZE_MATCH(xPrintSetImageResolutionReq); - - if((pContext =(XpContextPtr)SecurityLookupIDByType(client, - stuff->printContext, - RTcontext, - DixWriteAccess)) - == (XpContextPtr)NULL) - { - client->errorValue = stuff->printContext; - return XpErrorBase+XPBadContext; - } - - rep.prevRes = pContext->imageRes; - if(pContext->funcs.SetImageResolution != 0) { - result = pContext->funcs.SetImageResolution(pContext, - (int)stuff->imageRes, - &status); - if(result != Success) - status = FALSE; - } else - status = FALSE; - - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.length = 0; - rep.status = status; - - if(client->swapped) - { - int n; - long l; - - swaps(&rep.sequenceNumber, n); - swapl(&rep.length, l); - swaps(&rep.prevRes, n); - } - - WriteToClient(client, sz_xPrintSetImageResolutionReply, (char *)&rep); - return client->noClientException; -} - -static int -ProcXpGetImageResolution(ClientPtr client) -{ - REQUEST(xPrintGetImageResolutionReq); - xPrintGetImageResolutionReply rep; - XpContextPtr pContext; - - REQUEST_SIZE_MATCH(xPrintGetImageResolutionReq); - - if((pContext =(XpContextPtr)SecurityLookupIDByType(client, - stuff->printContext, - RTcontext, - DixReadAccess)) - == (XpContextPtr)NULL) - { - client->errorValue = stuff->printContext; - return XpErrorBase+XPBadContext; - } - - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.length = 0; - rep.imageRes = pContext->imageRes; - - if(client->swapped) - { - int n; - long l; - - swaps(&rep.sequenceNumber, n); - swapl(&rep.length, l); - swaps(&rep.imageRes, n); - } - - WriteToClient(client, sz_xPrintGetImageResolutionReply, (char *)&rep); - return client->noClientException; -} - -/******************************************************************************* - * - * RehashPrinterList : Cause the server's list of printers to be rebuilt. - * This allows new printers to be added, or old ones - * deleted without needing to restart the server. - * - ******************************************************************************/ - -static int -ProcXpRehashPrinterList(ClientPtr client) -{ - /* REQUEST(xPrintRehashPrinterListReq); */ - - REQUEST_SIZE_MATCH(xPrintRehashPrinterListReq); - - return XpRehashPrinterList(); -} - -/****************************************************************************** - * - * Context functions: Init, Set, Destroy, FreeContext - * AllocateContextPrivateIndex, AllocateContextPrivate - * and supporting functions. - * - * Init creates a context, creates a XpClientRec for the calling - * client, and stores the contextPtr in the client's devPrivates. - * - * Set creates a XpClientRec for the calling client, and stores the - * contextPtr in the client's devPrivates unless the context is None. - * If the context is None, then the client's connection association - * with any context is removed. - * - * Destroy frees any and all XpClientRecs associated with the context, - * frees the context itself, and removes the contextPtr from any - * relevant client devPrivates. - * - * FreeContext is called by FreeResource to free up a context. - * - ******************************************************************************/ - -/* - * CreateContext creates and initializes the memory for the context itself. - * The driver's CreateContext function - * is then called. - */ -static int -ProcXpCreateContext(ClientPtr client) -{ - REQUEST(xPrintCreateContextReq); - XpScreenPtr pPrintScreen; - WindowPtr pRoot; - char *driverName; - XpContextPtr pContext; - int result = Success; - XpDriverPtr pDriver; - - REQUEST_AT_LEAST_SIZE(xPrintCreateContextReq); - - LEGAL_NEW_RESOURCE(stuff->contextID, client); - - /* - * Check to see if the printer name is valid. - */ - if((pRoot = XpDiValidatePrinter((char *)(stuff + 1), stuff->printerNameLen)) == - (WindowPtr)NULL) - return BadMatch; - - pPrintScreen = XpScreens[pRoot->drawable.pScreen->myNum]; - - /* - * Allocate and add the context resource. - */ - if((pContext = (XpContextPtr) xalloc(sizeof(XpContextRec))) == - (XpContextPtr) NULL) - return BadAlloc; - - if(AddResource(stuff->contextID, RTcontext, (pointer) pContext) - != TRUE) - { - xfree(pContext); - return BadAlloc; - } - - pContext->contextID = stuff->contextID; - pContext->clientHead = (XpClientPtr)NULL; - pContext->screenNum = pRoot->drawable.pScreen->myNum; - pContext->state = 0; - pContext->clientSlept = (ClientPtr)NULL; - pContext->imageRes = 0; - pContext->devPrivates = NULL; - - pContext->funcs.DestroyContext = 0; - pContext->funcs.StartJob = 0; - pContext->funcs.EndJob = 0; - pContext->funcs.StartDoc = 0; - pContext->funcs.EndDoc = 0; - pContext->funcs.StartPage = 0; - pContext->funcs.EndPage = 0; - pContext->funcs.PutDocumentData = 0; - pContext->funcs.GetDocumentData = 0; - pContext->funcs.GetAttributes = 0; - pContext->funcs.GetOneAttribute = 0; - pContext->funcs.SetAttributes = 0; - pContext->funcs.AugmentAttributes = 0; - pContext->funcs.GetMediumDimensions = 0; - pContext->funcs.GetReproducibleArea = 0; - pContext->funcs.SetImageResolution = 0; - - if((pContext->printerName = (char *)xalloc(stuff->printerNameLen + 1)) == - (char *)NULL) - { - /* Freeing the context also causes the XpClients to be freed. */ - FreeResource(stuff->contextID, RT_NONE); - return BadAlloc; - } - strncpy(pContext->printerName, (char *)(stuff + 1), stuff->printerNameLen); - pContext->printerName[stuff->printerNameLen] = (char)'\0'; - - driverName = XpDiGetDriverName(pRoot->drawable.pScreen->myNum, - pContext->printerName); - - for(pDriver = pPrintScreen->drivers; - pDriver != (XpDriverPtr)NULL; - pDriver = pDriver->next) - { - if(!strcmp(driverName, pDriver->name)) - { - if(pDriver->CreateContext != 0) - pDriver->CreateContext(pContext); - else - return BadImplementation; - break; - } - } - - if (client->noClientException != Success) - return client->noClientException; - else - return result; -} - -/* - * SetContext creates the calling client's contextClient resource, - * and stashes the contextID in the client's devPrivate. - */ -static int -ProcXpSetContext(ClientPtr client) -{ - REQUEST(xPrintSetContextReq); - - XpContextPtr pContext; - XpClientPtr pPrintClient; - int result = Success; - - REQUEST_AT_LEAST_SIZE(xPrintSetContextReq); - - if((pContext = XP_GETPRIV(client)) != (pointer)NULL) - { - /* - * Erase this client's knowledge of its old context, if any. - */ - if((pPrintClient = FindClient(pContext, client)) != (XpClientPtr)NULL) - { - XpUnsetFontResFunc(client); - - if(pPrintClient->eventMask == 0) - FreeXpClient(pPrintClient, TRUE); - } - - XP_SETPRIV(client, NULL); - } - if(stuff->printContext == None) - return Success; - - /* - * Check to see that the supplied XID is really a valid print context - * in this server. - */ - if((pContext =(XpContextPtr)SecurityLookupIDByType(client, - stuff->printContext, - RTcontext, - DixWriteAccess)) - == (XpContextPtr)NULL) - { - client->errorValue = stuff->printContext; - return XpErrorBase+XPBadContext; - } - - if((pPrintClient = AcquireClient(pContext, client)) == (XpClientPtr)NULL) - return BadAlloc; - - XP_SETPRIV(client, pContext); - - XpSetFontResFunc(client); - - if (client->noClientException != Success) - return client->noClientException; - else - return result; -} - -XpContextPtr -XpGetPrintContext(ClientPtr client) -{ - return XP_GETPRIV(client); -} - -static int -ProcXpGetContext(ClientPtr client) -{ - /* REQUEST(xPrintGetContextReq); */ - xPrintGetContextReply rep; - - XpContextPtr pContext; - register int n; - register long l; - - REQUEST_SIZE_MATCH(xPrintGetContextReq); - - if((pContext = XP_GETPRIV(client)) == (pointer)NULL) - rep.printContext = None; - else - rep.printContext = pContext->contextID; - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - if (client->swapped) { - swaps(&rep.sequenceNumber, n); - swapl(&rep.length, l); - swapl(&rep.printContext, l); - } - WriteToClient(client, sz_xPrintGetContextReply, (char *)&rep); - return client->noClientException; -} - - -/* - * DestroyContext frees the context associated with the calling client. - * It operates by freeing the context resource ID, thus causing XpFreeContext - * to be called. - */ -static int -ProcXpDestroyContext(ClientPtr client) -{ - REQUEST(xPrintDestroyContextReq); - - XpContextPtr pContext; - - REQUEST_SIZE_MATCH(xPrintDestroyContextReq); - - if((pContext =(XpContextPtr)SecurityLookupIDByType(client, - stuff->printContext, - RTcontext, - DixDestroyAccess)) - == (XpContextPtr)NULL) - { - client->errorValue = stuff->printContext; - return XpErrorBase+XPBadContext; - } - - XpUnsetFontResFunc(client); - - FreeResource(pContext->contextID, RT_NONE); - - return Success; -} - -static int -ProcXpGetContextScreen(ClientPtr client) -{ - REQUEST(xPrintGetContextScreenReq); - xPrintGetContextScreenReply rep; - XpContextPtr pContext; - int n; - long l; - - if((pContext =(XpContextPtr)SecurityLookupIDByType(client, - stuff->printContext, - RTcontext, - DixReadAccess)) - == (XpContextPtr)NULL) - return XpErrorBase+XPBadContext; - - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.length = 0; - rep.rootWindow = WindowTable[pContext->screenNum]->drawable.id; - - if (client->swapped) { - swaps(&rep.sequenceNumber, n); - swapl(&rep.length, l); - swapl(&rep.rootWindow, l); - } - - WriteToClient(client, sz_xPrintGetContextScreenReply, (char *)&rep); - return client->noClientException; -} - -/* - * XpFreeContext is the routine called by dix:FreeResource when a context - * resource ID is freed. - * It checks to see if there's a partial job pending on the context, and - * if so it calls the appropriate End procs with the cancel flag set. - * It calls the driver's DestroyContext routine to allow the driver to clean - * up any context-related memory or state. - * It calls FreeXpClient to free all the - * associated XpClientRecs and to set all the client->devPrivates to NULL. - * It frees the printer name string, and frees the context - * itself. - */ -static int -XpFreeContext(pointer data, XID id) -{ - XpContextPtr pContext = (XpContextPtr)data; - - /* Clean up any pending job on this context */ - if(pContext->state != 0) - { - if(pContext->state & PAGE_STARTED) - { - WindowPtr pWin = (WindowPtr )LookupIDByType( - pContext->pageWin, RT_WINDOW); - XpPagePtr pPage = (XpPagePtr)LookupIDByType( - pContext->pageWin, RTpage); - - pContext->funcs.EndPage(pContext, pWin); - SendXpNotify(pContext, XPEndPageNotify, TRUE); - pContext->state &= ~PAGE_STARTED; - if(pPage) - pPage->context = (XpContextPtr)NULL; - } - if((pContext->state & DOC_RAW_STARTED) || - (pContext->state & DOC_COOKED_STARTED)) - { - pContext->funcs.EndDoc(pContext, TRUE); - SendXpNotify(pContext, XPEndDocNotify, TRUE); - pContext->state &= ~DOC_RAW_STARTED; - pContext->state &= ~DOC_COOKED_STARTED; - } - if(pContext->funcs.EndJob != 0) - { - pContext->funcs.EndJob(pContext, TRUE); - SendXpNotify(pContext, XPEndJobNotify, TRUE); - pContext->state &= ~JOB_STARTED; - pContext->state &= ~GET_DOC_DATA_STARTED; - } - } - - /* - * Tell the driver we're destroying the context - * This allows the driver to free and ContextPrivate data - */ - if(pContext->funcs.DestroyContext != 0) - pContext->funcs.DestroyContext(pContext); - - /* Free up all the XpClientRecs */ - while(pContext->clientHead != (XpClientPtr)NULL) - { - FreeXpClient(pContext->clientHead, TRUE); - } - - xfree(pContext->printerName); - dixFreePrivates(pContext->devPrivates); - xfree(pContext); - return Success; /* ??? */ -} - -/* - * XpFreeClient is the routine called by dix:FreeResource when a RTclient - * is freed. It simply calls the FreeXpClient routine to do the work. - */ -static int -XpFreeClient(pointer data, XID id) -{ - FreeXpClient((XpClientPtr)data, TRUE); - return Success; -} - -/* - * FreeXpClient - * frees the ClientRec passed in, and sets the client->devPrivates to NULL - * if the client->devPrivates points to the same context as the XpClient. - * Called from XpFreeContext(from FreeResource), and - * XpFreeClient. The boolean freeResource specifies whether or not to call - * FreeResource for the XpClientRec's XID. We should free it except if we're - * called from XpFreeClient (which is itself called from FreeResource for the - * XpClientRec's XID). - */ -static void -FreeXpClient(XpClientPtr pXpClient, Bool freeResource) -{ - XpClientPtr pCurrent, pPrev; - XpContextPtr pContext = pXpClient->context; - - /* - * If we're freeing the clientRec associated with the context tied - * to the client's devPrivates, then we need to clear the devPrivates. - */ - if(XP_GETPRIV(pXpClient->client) == pXpClient->context) - { - XP_SETPRIV(pXpClient->client, NULL); - } - - for(pPrev = (XpClientPtr)NULL, pCurrent = pContext->clientHead; - pCurrent != (XpClientPtr)NULL; - pCurrent = pCurrent->pNext) - { - if(pCurrent == pXpClient) - { - if(freeResource == TRUE) - FreeResource (pCurrent->contextClientID, RTclient); - - if (pPrev != (XpClientPtr)NULL) - pPrev->pNext = pCurrent->pNext; - else - pContext->clientHead = pCurrent->pNext; - - xfree (pCurrent); - break; - } - pPrev = pCurrent; - } -} - -/* - * CreateXpClient takes a ClientPtr and returns a pointer to a - * XpClientRec which it allocates. It also initializes the Rec, - * including adding a resource on behalf of the client to enable the - * freeing of the Rec when the client's connection is closed. - */ -static XpClientPtr -CreateXpClient(ClientPtr client) -{ - XpClientPtr pNewPrintClient; - XID clientResource; - - if((pNewPrintClient = (XpClientPtr)xalloc(sizeof(XpClientRec))) == - (XpClientPtr)NULL) - return (XpClientPtr)NULL; - - clientResource = FakeClientID(client->index); - if(!AddResource(clientResource, RTclient, (pointer)pNewPrintClient)) - { - xfree (pNewPrintClient); - return (XpClientPtr)NULL; - } - - pNewPrintClient->pNext = (XpClientPtr)NULL; - pNewPrintClient->client = client; - pNewPrintClient->context = (XpContextPtr)NULL; - pNewPrintClient->eventMask = 0; - pNewPrintClient->contextClientID = clientResource; - - return pNewPrintClient; -} - -/* - * XpFreePage is the routine called by dix:FreeResource to free the page - * resource built with the same ID as a page window. It checks to see - * if we're in the middle of a page, and if so calls the driver's EndPage - * function with 'cancel' set TRUE. It frees the memory associated with - * the page resource. - */ -static int -XpFreePage(pointer data, XID id) -{ - XpPagePtr page = (XpPagePtr)data; - int result = Success; - WindowPtr pWin = (WindowPtr )LookupIDByType(id, RT_WINDOW); - - /* Check to see if the window's being deleted in the middle of a page */ - if(page->context != (XpContextPtr)NULL && - page->context->state & PAGE_STARTED) - { - if(page->context->funcs.EndPage != 0) - result = page->context->funcs.EndPage(page->context, pWin); - SendXpNotify(page->context, XPEndPageNotify, (int)TRUE); - page->context->pageWin = 0; /* None, NULL??? XXX */ - } - - xfree(page); - return result; -} - -static XpClientPtr -AcquireClient(XpContextPtr pContext, ClientPtr client) -{ - XpClientPtr pXpClient; - - if((pXpClient = FindClient(pContext, client)) != (XpClientPtr)NULL) - return pXpClient; - - if((pXpClient = CreateXpClient(client)) == (XpClientPtr)NULL) - return (XpClientPtr)NULL; - - pXpClient->context = pContext; - pXpClient->pNext = pContext->clientHead; - pContext->clientHead = pXpClient; - - return pXpClient; -} - -static XpClientPtr -FindClient(XpContextPtr pContext, ClientPtr client) -{ - XpClientPtr pXpClient; - - for(pXpClient = pContext->clientHead; pXpClient != (XpClientPtr)NULL; - pXpClient = pXpClient->pNext) - { - if(pXpClient->client == client) return pXpClient; - } - return (XpClientPtr)NULL; -} - - -/****************************************************************************** - * - * Start/End Functions: StartJob, EndJob, StartDoc, EndDoc, StartPage, EndPage - * - ******************************************************************************/ - -static int -ProcXpStartJob(ClientPtr client) -{ - REQUEST(xPrintStartJobReq); - XpContextPtr pContext; - int result = Success; - - REQUEST_SIZE_MATCH(xPrintStartJobReq); - - /* Check to see that a context has been established by this client. */ - if((pContext = XP_GETPRIV(client)) == (XpContextPtr)NULL) - return XpErrorBase+XPBadContext; - - if(pContext->state != 0) - return XpErrorBase+XPBadSequence; - - if(stuff->saveData != XPSpool && stuff->saveData != XPGetData) - { - client->errorValue = stuff->saveData; - return BadValue; - } - - if(pContext->funcs.StartJob != 0) - result = pContext->funcs.StartJob(pContext, - (stuff->saveData == XPGetData)? TRUE:FALSE, - client); - else - return BadImplementation; - - pContext->state = JOB_STARTED; - if(stuff->saveData == XPGetData) - pContext->state |= JOB_GET_DATA; - - SendXpNotify(pContext, XPStartJobNotify, FALSE); - - if (client->noClientException != Success) - return client->noClientException; - else - return result; -} - -static int -ProcXpEndJob(ClientPtr client) -{ - REQUEST(xPrintEndJobReq); - int result = Success; - XpContextPtr pContext; - - REQUEST_SIZE_MATCH(xPrintEndJobReq); - - if((pContext = XP_GETPRIV(client)) == (XpContextPtr)NULL) - return XpErrorBase+XPBadSequence; - - if(!(pContext->state & JOB_STARTED)) - return XpErrorBase+XPBadSequence; - - /* Check for missing EndDoc */ - if((pContext->state & DOC_RAW_STARTED) || - (pContext->state & DOC_COOKED_STARTED)) - { - if(pContext->state & PAGE_STARTED) - { - WindowPtr pWin = (WindowPtr )LookupIDByType( - pContext->pageWin, RT_WINDOW); - XpPagePtr pPage = (XpPagePtr)LookupIDByType( - pContext->pageWin, RTpage); - - if(stuff->cancel != TRUE) - return XpErrorBase+XPBadSequence; - - if(pContext->funcs.EndPage != 0) - result = pContext->funcs.EndPage(pContext, pWin); - else - return BadImplementation; - - SendXpNotify(pContext, XPEndPageNotify, TRUE); - - pContext->state &= ~PAGE_STARTED; - - if(pPage) - pPage->context = (XpContextPtr)NULL; - - if(result != Success) return result; - } - - if(pContext->funcs.EndDoc != 0) - result = pContext->funcs.EndDoc(pContext, stuff->cancel); - else - return BadImplementation; - - SendXpNotify(pContext, XPEndDocNotify, stuff->cancel); - } - - if(pContext->funcs.EndJob != 0) - result = pContext->funcs.EndJob(pContext, stuff->cancel); - else - return BadImplementation; - - pContext->state = 0; - - SendXpNotify(pContext, XPEndJobNotify, stuff->cancel); - - if (client->noClientException != Success) - return client->noClientException; - else - return result; -} - -static Bool -DoStartDoc(ClientPtr client, XpStDocPtr c) -{ - XpContextPtr pContext = c->pContext; - - if(c->pContext->state & JOB_GET_DATA && - !(c->pContext->state & GET_DOC_DATA_STARTED)) - { - if(!c->slept) - { - c->slept = TRUE; - ClientSleep(client, (ClientSleepProcPtr)DoStartDoc, (pointer) c); - c->pContext->clientSlept = client; - } - return TRUE; - } - - if(pContext->funcs.StartDoc != 0) - (void) pContext->funcs.StartDoc(pContext, c->type); - else - { - SendErrorToClient(client, XpReqCode, X_PrintStartPage, 0, - BadImplementation); - return TRUE; - } - - if(c->type == XPDocNormal) - pContext->state |= DOC_COOKED_STARTED; - else - pContext->state |= DOC_RAW_STARTED; - - SendXpNotify(pContext, XPStartDocNotify, (int)FALSE); - - xfree(c); - return TRUE; -} - -static int -ProcXpStartDoc(ClientPtr client) -{ - REQUEST(xPrintStartDocReq); - int result = Success; - XpContextPtr pContext; - XpStDocPtr c; - - REQUEST_SIZE_MATCH(xPrintStartDocReq); - - if((pContext = XP_GETPRIV(client)) == (XpContextPtr)NULL) - return XpErrorBase+XPBadSequence; - - if(!(pContext->state & JOB_STARTED) || - pContext->state & DOC_RAW_STARTED || - pContext->state & DOC_COOKED_STARTED) - return XpErrorBase+XPBadSequence; - - if(stuff->type != XPDocNormal && stuff->type != XPDocRaw) - { - client->errorValue = stuff->type; - return BadValue; - } - - c = (XpStDocPtr)xalloc(sizeof(XpStDocRec)); - c->pContext = pContext; - c->type = stuff->type; - c->slept = FALSE; - (void)DoStartDoc(client, c); - - if (client->noClientException != Success) - return client->noClientException; - else - return result; -} - -static int -ProcXpEndDoc(ClientPtr client) -{ - REQUEST(xPrintEndDocReq); - XpContextPtr pContext; - int result = Success; - - REQUEST_SIZE_MATCH(xPrintEndDocReq); - - if((pContext = XP_GETPRIV(client)) == (XpContextPtr)NULL) - return XpErrorBase+XPBadSequence; - - if(!(pContext->state & DOC_RAW_STARTED) && - !(pContext->state & DOC_COOKED_STARTED)) - return XpErrorBase+XPBadSequence; - - if(pContext->state & PAGE_STARTED) - { - if(stuff->cancel == TRUE) - { - WindowPtr pWin = (WindowPtr )LookupIDByType( - pContext->pageWin, RT_WINDOW); - XpPagePtr pPage = (XpPagePtr)LookupIDByType( - pContext->pageWin, RTpage); - - if(pContext->funcs.EndPage != 0) - result = pContext->funcs.EndPage(pContext, pWin); - else - return BadImplementation; - - SendXpNotify(pContext, XPEndPageNotify, TRUE); - - if(pPage) - pPage->context = (XpContextPtr)NULL; - } - else - return XpErrorBase+XPBadSequence; - if(result != Success) - return result; - } - - if(pContext->funcs.EndDoc != 0) - result = pContext->funcs.EndDoc(pContext, stuff->cancel); - else - return BadImplementation; - - pContext->state &= ~DOC_RAW_STARTED; - pContext->state &= ~DOC_COOKED_STARTED; - - SendXpNotify(pContext, XPEndDocNotify, stuff->cancel); - - if (client->noClientException != Success) - return client->noClientException; - else - return result; -} - -static Bool -DoStartPage( - ClientPtr client, - XpStPagePtr c) -{ - WindowPtr pWin = c->pWin; - int result = Success; - XpContextPtr pContext = c->pContext; - XpPagePtr pPage; - - if(c->pContext->state & JOB_GET_DATA && - !(c->pContext->state & GET_DOC_DATA_STARTED)) - { - if(!c->slept) - { - c->slept = TRUE; - ClientSleep(client, (ClientSleepProcPtr)DoStartPage, (pointer) c); - c->pContext->clientSlept = client; - } - return TRUE; - } - - if(!(pContext->state & DOC_COOKED_STARTED)) - { - /* Implied StartDoc if it was omitted */ - if(pContext->funcs.StartDoc != 0) - result = pContext->funcs.StartDoc(pContext, XPDocNormal); - else - { - SendErrorToClient(client, XpReqCode, X_PrintStartPage, 0, - BadImplementation); - return TRUE; - } - - if(result != Success) - { - SendErrorToClient(client, XpReqCode, X_PrintStartPage, 0, result); - return TRUE; - } - - pContext->state |= DOC_COOKED_STARTED; - SendXpNotify(pContext, XPStartDocNotify, (int)FALSE); - } - - /* ensure the window's not already being used as a page */ - if((pPage = (XpPagePtr)LookupIDByType(c->pWin->drawable.id, RTpage)) != - (XpPagePtr)NULL) - { - if(pPage->context != (XpContextPtr)NULL) - { - SendErrorToClient(client, XpReqCode, X_PrintStartPage, 0, - BadWindow); - return TRUE; - } - } - else - { - if((pPage = (XpPagePtr)xalloc(sizeof(XpPageRec))) == (XpPagePtr)NULL) - { - SendErrorToClient(client, XpReqCode, X_PrintStartPage, 0, - BadAlloc); - return TRUE; - } - if(AddResource(c->pWin->drawable.id, RTpage, pPage) == FALSE) - { - xfree(pPage); - SendErrorToClient(client, XpReqCode, X_PrintStartPage, 0, - BadAlloc); - return TRUE; - } - } - - pPage->context = pContext; - pContext->pageWin = c->pWin->drawable.id; - - if(pContext->funcs.StartPage != 0) - result = pContext->funcs.StartPage(pContext, pWin); - else - { - SendErrorToClient(client, XpReqCode, X_PrintStartPage, 0, - BadImplementation); - return TRUE; - } - - pContext->state |= PAGE_STARTED; - - (void)MapWindow(pWin, client); - - SendXpNotify(pContext, XPStartPageNotify, (int)FALSE); - - return TRUE; -} - -static int -ProcXpStartPage(ClientPtr client) -{ - REQUEST(xPrintStartPageReq); - WindowPtr pWin; - int result = Success; - XpContextPtr pContext; - XpStPagePtr c; - - REQUEST_SIZE_MATCH(xPrintStartPageReq); - - if((pContext = XP_GETPRIV(client)) == (XpContextPtr)NULL) - return XpErrorBase+XPBadSequence; - - if(!(pContext->state & JOB_STARTED)) - return XpErrorBase+XPBadSequence; - - /* can't have pages in a raw documented */ - if(pContext->state & DOC_RAW_STARTED) - return XpErrorBase+XPBadSequence; - - if(pContext->state & PAGE_STARTED) - return XpErrorBase+XPBadSequence; - - result = dixLookupWindow(&pWin, stuff->window, client, DixWriteAccess); - if (result != Success) - return result; - if (pWin->drawable.pScreen->myNum != pContext->screenNum) - return BadWindow; - - if((c = (XpStPagePtr)xalloc(sizeof(XpStPageRec))) == (XpStPagePtr)NULL) - return BadAlloc; - c->pContext = pContext; - c->slept = FALSE; - c->pWin = pWin; - - (void)DoStartPage(client, c); - - if (client->noClientException != Success) - return client->noClientException; - else - return result; -} - -static int -ProcXpEndPage(ClientPtr client) -{ - REQUEST(xPrintEndPageReq); - int result = Success; - XpContextPtr pContext; - XpPagePtr page; - WindowPtr pWin; - - REQUEST_SIZE_MATCH(xPrintEndPageReq); - - if((pContext = XP_GETPRIV(client)) == (XpContextPtr)NULL) - return XpErrorBase+XPBadSequence; - - if(!(pContext->state & PAGE_STARTED)) - return XpErrorBase+XPBadSequence; - - pWin = (WindowPtr )LookupIDByType(pContext->pageWin, RT_WINDOW); - - /* Call the ddx's EndPage proc. */ - if(pContext->funcs.EndPage != 0) - result = pContext->funcs.EndPage(pContext, pWin); - else - return BadImplementation; - - if((page = (XpPagePtr)LookupIDByType(pContext->pageWin, RTpage)) != - (XpPagePtr)NULL) - page->context = (XpContextPtr)NULL; - - pContext->state &= ~PAGE_STARTED; - pContext->pageWin = 0; /* None, NULL??? XXX */ - - (void)UnmapWindow(pWin, FALSE); - - SendXpNotify(pContext, XPEndPageNotify, stuff->cancel); - - if (client->noClientException != Success) - return client->noClientException; - else - return result; -} - -/******************************************************************************* - * - * Document Data Functions: PutDocumentData, GetDocumentData - * - ******************************************************************************/ - -static int -ProcXpPutDocumentData(ClientPtr client) -{ - REQUEST(xPrintPutDocumentDataReq); - XpContextPtr pContext; - DrawablePtr pDraw; - int result = Success; - unsigned totalSize; - char *pData, *pDoc_fmt, *pOptions; - - REQUEST_AT_LEAST_SIZE(xPrintPutDocumentDataReq); - - if((pContext = XP_GETPRIV(client)) == (XpContextPtr)NULL) - return XpErrorBase+XPBadSequence; - - if(!(pContext->state & DOC_RAW_STARTED) && - !(pContext->state & DOC_COOKED_STARTED)) - return XpErrorBase+XPBadSequence; - - if (stuff->drawable) { - if (pContext->state & DOC_RAW_STARTED) - return BadDrawable; - result = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, - DixWriteAccess); - if (result != Success) - return result; - if (pDraw->pScreen->myNum != pContext->screenNum) - return BadDrawable; - } else { - if (pContext->state & DOC_COOKED_STARTED) - return BadDrawable; - pDraw = NULL; - } - - pData = (char *)(&stuff[1]); - - totalSize = (stuff->len_data + 3) >> 2; - pDoc_fmt = pData + (totalSize << 2); - - totalSize += (stuff->len_fmt + 3) >> 2; - pOptions = pData + (totalSize << 2); - - totalSize += (stuff->len_options + 3) >> 2; - if((totalSize + (sz_xPrintPutDocumentDataReq >> 2)) != client->req_len) - return BadLength; - - if(pContext->funcs.PutDocumentData != 0) - { - result = (*pContext->funcs.PutDocumentData)(pContext, pDraw, - pData, stuff->len_data, - pDoc_fmt, stuff->len_fmt, - pOptions, stuff->len_options, - client); - } - else - return BadImplementation; - - if (client->noClientException != Success) - return client->noClientException; - else - return result; -} - -static int -ProcXpGetDocumentData(ClientPtr client) -{ - REQUEST(xPrintGetDocumentDataReq); - xPrintGetDocumentDataReply rep; - XpContextPtr pContext; - int result = Success; - - REQUEST_SIZE_MATCH(xPrintGetDocumentDataReq); - - if((pContext = (XpContextPtr)SecurityLookupIDByType(client, - stuff->printContext, - RTcontext, - DixWriteAccess)) - == (XpContextPtr)NULL) - { - client->errorValue = stuff->printContext; - return XpErrorBase+XPBadContext; - } - - if(pContext->funcs.GetDocumentData == 0) - return BadImplementation; - - if(!(pContext->state & JOB_GET_DATA) || - pContext->state & GET_DOC_DATA_STARTED) - return XpErrorBase+XPBadSequence; - - if(stuff->maxBufferSize <= 0) - { - client->errorValue = stuff->maxBufferSize; - return BadValue; /* gotta have a positive buffer size */ - } - - result = (*pContext->funcs.GetDocumentData)(pContext, client, - stuff->maxBufferSize); - if(result != Success) - { - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.length = 0; - rep.dataLen = 0; - rep.statusCode = 1; - rep.finishedFlag = TRUE; - if (client->swapped) { - int n; - long l; - - swaps(&rep.sequenceNumber, n); - swapl(&rep.statusCode, l); /* XXX Why are these longs??? */ - swapl(&rep.finishedFlag, l); /* XXX Why are these longs??? */ - } - (void)WriteToClient(client,sz_xPrintGetDocumentDataReply,(char *)&rep); - } - else - pContext->state |= GET_DOC_DATA_STARTED; - - if(pContext->clientSlept != (ClientPtr)NULL) - { - ClientSignal(pContext->clientSlept); - ClientWakeup(pContext->clientSlept); - pContext->clientSlept = (ClientPtr)NULL; - } - - return result; -} - -/******************************************************************************* - * - * Attribute requests: GetAttributes, SetAttributes, GetOneAttribute - * - ******************************************************************************/ - -static int -ProcXpGetAttributes(ClientPtr client) -{ - REQUEST(xPrintGetAttributesReq); - XpContextPtr pContext; - char *attrs; - xPrintGetAttributesReply *pRep; - int totalSize, n; - unsigned long l; - - REQUEST_SIZE_MATCH(xPrintGetAttributesReq); - - if(stuff->type < XPJobAttr || stuff->type > XPServerAttr) - { - client->errorValue = stuff->type; - return BadValue; - } - - if(stuff->type != XPServerAttr) - { - if((pContext = (XpContextPtr)SecurityLookupIDByType( - client, - stuff->printContext, - RTcontext, - DixReadAccess)) - == (XpContextPtr)NULL) - { - client->errorValue = stuff->printContext; - return XpErrorBase+XPBadContext; - } - - if(pContext->funcs.GetAttributes == 0) - return BadImplementation; - if((attrs = (*pContext->funcs.GetAttributes)(pContext, stuff->type)) == - (char *)NULL) - return BadAlloc; - } - else - { - if((attrs = XpGetAttributes((XpContextPtr)NULL, XPServerAttr)) == - (char *)NULL) - return BadAlloc; - } - - totalSize = sz_xPrintGetAttributesReply + QUADPAD(strlen(attrs)); - if((pRep = (xPrintGetAttributesReply *)malloc(totalSize)) == - (xPrintGetAttributesReply *)NULL) - return BadAlloc; - - pRep->type = X_Reply; - pRep->length = (totalSize - sz_xPrintGetAttributesReply) >> 2; - pRep->sequenceNumber = client->sequence; - pRep->stringLen = strlen(attrs); - - if (client->swapped) { - swaps(&pRep->sequenceNumber, n); - swapl(&pRep->length, l); - swapl(&pRep->stringLen, l); - } - - strncpy((char*)(pRep + 1), attrs, strlen(attrs)); - xfree(attrs); - - WriteToClient(client, totalSize, (char *)pRep); - - xfree(pRep); - - return client->noClientException; -} - -static int -ProcXpSetAttributes(ClientPtr client) -{ - REQUEST(xPrintSetAttributesReq); - int result = Success; - XpContextPtr pContext; - char *attr; - - REQUEST_AT_LEAST_SIZE(xPrintSetAttributesReq); - - if(stuff->type < XPJobAttr || stuff->type > XPServerAttr) - { - client->errorValue = stuff->type; - return BadValue; - } - - /* - * Disallow changing of read-only attribute pools - */ - if(stuff->type == XPPrinterAttr || stuff->type == XPServerAttr) - return BadMatch; - - if((pContext = (XpContextPtr)SecurityLookupIDByType( - client, - stuff->printContext, - RTcontext, - DixWriteAccess)) - == (XpContextPtr)NULL) - { - client->errorValue = stuff->printContext; - return XpErrorBase+XPBadContext; - } - - if(pContext->funcs.SetAttributes == 0) - return BadImplementation; - - /* - * Check for attributes being set after their relevant phase - * has already begun (e.g. Job attributes set after StartJob). - */ - if((pContext->state & JOB_STARTED) && stuff->type == XPJobAttr) - return XpErrorBase+XPBadSequence; - if(((pContext->state & DOC_RAW_STARTED) || - (pContext->state & DOC_COOKED_STARTED)) && stuff->type == XPDocAttr) - return XpErrorBase+XPBadSequence; - if((pContext->state & PAGE_STARTED) && stuff->type == XPPageAttr) - return XpErrorBase+XPBadSequence; - - if((attr = (char *)malloc(stuff->stringLen + 1)) == (char *)NULL) - return BadAlloc; - - strncpy(attr, (char *)(stuff + 1), stuff->stringLen); - attr[stuff->stringLen] = (char)'\0'; - - if(stuff->rule == XPAttrReplace) - (*pContext->funcs.SetAttributes)(pContext, stuff->type, attr); - else if(stuff->rule == XPAttrMerge) - (*pContext->funcs.AugmentAttributes)(pContext, stuff->type, attr); - else - { - client->errorValue = stuff->rule; - result = BadValue; - } - - xfree(attr); - - SendAttributeNotify(pContext, stuff->type); - - return result; -} - -static int -ProcXpGetOneAttribute(ClientPtr client) -{ - REQUEST(xPrintGetOneAttributeReq); - XpContextPtr pContext; - char *value, *attrName; - xPrintGetOneAttributeReply *pRep; - int totalSize; - int n; - unsigned long l; - - REQUEST_AT_LEAST_SIZE(xPrintGetOneAttributeReq); - - totalSize = ((sz_xPrintGetOneAttributeReq) >> 2) + - ((stuff->nameLen + 3) >> 2); - if(totalSize != client->req_len) - return BadLength; - - if(stuff->type < XPJobAttr || stuff->type > XPServerAttr) - { - client->errorValue = stuff->type; - return BadValue; - } - - if((attrName = (char *)malloc(stuff->nameLen + 1)) == (char *)NULL) - return BadAlloc; - strncpy(attrName, (char *)(stuff+1), stuff->nameLen); - attrName[stuff->nameLen] = (char)'\0'; - - if(stuff->type != XPServerAttr) - { - if((pContext = (XpContextPtr)SecurityLookupIDByType( - client, - stuff->printContext, - RTcontext, - DixReadAccess)) - == (XpContextPtr)NULL) - { - client->errorValue = stuff->printContext; - return XpErrorBase+XPBadContext; - } - - if(pContext->funcs.GetOneAttribute == 0) - return BadImplementation; - if((value = (*pContext->funcs.GetOneAttribute)(pContext, stuff->type, - attrName)) == (char *)NULL) - return BadAlloc; - } - else - { - if((value = XpGetOneAttribute((XpContextPtr)NULL, XPServerAttr, - attrName)) == (char *)NULL) - return BadAlloc; - } - - free(attrName); - - totalSize = sz_xPrintGetOneAttributeReply + QUADPAD(strlen(value)); - if((pRep = (xPrintGetOneAttributeReply *)malloc(totalSize)) == - (xPrintGetOneAttributeReply *)NULL) - return BadAlloc; - - pRep->type = X_Reply; - pRep->length = (totalSize - sz_xPrintGetOneAttributeReply) >> 2; - pRep->sequenceNumber = client->sequence; - pRep->valueLen = strlen(value); - - if (client->swapped) { - swaps(&pRep->sequenceNumber, n); - swapl(&pRep->length, l); - swapl(&pRep->valueLen, l); - } - - strncpy((char*)(pRep + 1), value, strlen(value)); - - WriteToClient(client, totalSize, (char *)pRep); - - xfree(pRep); - - return client->noClientException; -} - -/******************************************************************************* - * - * Print Event requests: SelectInput InputSelected, SendXpNotify - * - ******************************************************************************/ - - -static int -ProcXpSelectInput(ClientPtr client) -{ - REQUEST(xPrintSelectInputReq); - int result = Success; - XpContextPtr pContext; - XpClientPtr pPrintClient; - - REQUEST_SIZE_MATCH(xPrintSelectInputReq); - - /* - * Check to see that the supplied XID is really a valid print context - * in this server. - */ - if((pContext=(XpContextPtr)SecurityLookupIDByType(client, - stuff->printContext, - RTcontext, - DixWriteAccess)) - == (XpContextPtr)NULL) - { - client->errorValue = stuff->printContext; - return XpErrorBase+XPBadContext; - } - - if(stuff->eventMask & ~allEvents) - { - client->errorValue = stuff->eventMask; - return BadValue; /* bogus event mask bits */ - } - - if((pPrintClient = AcquireClient(pContext, client)) == (XpClientPtr)NULL) - return BadAlloc; - - pPrintClient->eventMask = stuff->eventMask; - - return result; -} - -static int -ProcXpInputSelected(ClientPtr client) -{ - REQUEST(xPrintInputSelectedReq); - xPrintInputSelectedReply rep; - register int n; - long l; - XpClientPtr pXpClient; - XpContextPtr pContext; - - REQUEST_SIZE_MATCH(xPrintInputSelectedReq); - - if((pContext=(XpContextPtr)SecurityLookupIDByType(client, - stuff->printContext, - RTcontext, - DixReadAccess)) - == (XpContextPtr)NULL) - { - client->errorValue = stuff->printContext; - return XpErrorBase+XPBadContext; - } - - pXpClient = FindClient(pContext, client); - - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - rep.eventMask = (pXpClient != (XpClientPtr)NULL)? pXpClient->eventMask : 0; - rep.allEventsMask = GetAllEventMasks(pContext); - - if (client->swapped) { - swaps(&rep.sequenceNumber, n); - swapl(&rep.length, l); - swapl(&rep.eventMask, l); - swapl(&rep.allEventsMask, l); - } - - WriteToClient(client, sz_xPrintInputSelectedReply, (char *)&rep); - return client->noClientException; -} - -static void -SendAttributeNotify(XpContextPtr pContext, int which) -{ - XpClientPtr pXpClient; - xPrintAttributeEvent ae; - ClientPtr client; - - pXpClient = pContext->clientHead; - if(pXpClient == (XpClientPtr)NULL) - return; /* Nobody's interested in the events (or this context). */ - - for (pXpClient = pContext->clientHead; - pXpClient != (XpClientPtr)NULL; - pXpClient = pXpClient->pNext) - { - client = pXpClient->client; - if (client == serverClient || client->clientGone || - !(pXpClient->eventMask & XPAttributeMask)) - continue; - ae.type = XPAttributeNotify + XpEventBase; - ae.detail = which; - ae.printContext = pContext->contextID; - ae.sequenceNumber = client->sequence; - WriteEventsToClient (client, 1, (xEvent *) &ae); - } -} - -static void -SendXpNotify(XpContextPtr pContext, int which, int val) -{ - XpClientPtr pXpClient; - xPrintPrintEvent pe; - ClientPtr client; - - pXpClient = pContext->clientHead; - if(pXpClient == (XpClientPtr)NULL) - return; /* Nobody's interested in the events (or this context). */ - - for (pXpClient = pContext->clientHead; - pXpClient != (XpClientPtr)NULL; - pXpClient = pXpClient->pNext) - { - client = pXpClient->client; - if (client == serverClient || client->clientGone || - !(pXpClient->eventMask & XPPrintMask)) - continue; - pe.type = XPPrintNotify + XpEventBase; - pe.detail = which; - pe.printContext = pContext->contextID; - pe.cancel = (Bool)val; - pe.sequenceNumber = client->sequence; - WriteEventsToClient (client, 1, (xEvent *) &pe); - } -} - -static CARD32 -GetAllEventMasks(XpContextPtr pContext) -{ - XpClientPtr pPrintClient; - CARD32 totalMask = (CARD32)0; - - for (pPrintClient = pContext->clientHead; - pPrintClient != (XpClientPtr)NULL; - pPrintClient = pPrintClient->pNext) - { - totalMask |= pPrintClient->eventMask; - } - return totalMask; -} - -/* - * XpContextOfClient - returns the XpContextPtr to the context - * associated with the specified client, or NULL if the client - * does not currently have a context set. - */ -XpContextPtr -XpContextOfClient(ClientPtr client) -{ - return XP_GETPRIV(client); -} - - -/******************************************************************************* - * - * Swap-request functions - * - ******************************************************************************/ - -static int -SProcXpCreateContext(ClientPtr client) -{ - int i; - long n; - - REQUEST(xPrintCreateContextReq); - - swaps(&stuff->length, i); - swapl(&stuff->contextID, n); - swapl(&stuff->printerNameLen, n); - swapl(&stuff->localeLen, n); - return ProcXpCreateContext(client); -} - -static int -SProcXpGetPrinterList(ClientPtr client) -{ - int i; - long n; - - REQUEST(xPrintGetPrinterListReq); - - swaps(&stuff->length, i); - swapl(&stuff->printerNameLen, n); - swapl(&stuff->localeLen, n); - return ProcXpGetPrinterList(client); -} - -static int -SProcXpRehashPrinterList(ClientPtr client) -{ - int i; - - REQUEST(xPrintRehashPrinterListReq); - swaps(&stuff->length, i); - return ProcXpRehashPrinterList(client); -} - -static int -SProcXpSetContext(ClientPtr client) -{ - int i; - - REQUEST(xPrintSetContextReq); - swaps(&stuff->length, i); - swapl(&stuff->printContext, i); - return ProcXpSetContext(client); -} - -static int -SProcXpGetContext(ClientPtr client) -{ - int i; - - REQUEST(xPrintGetContextReq); - swaps(&stuff->length, i); - return ProcXpGetContext(client); -} - -static int -SProcXpDestroyContext(ClientPtr client) -{ - int i; - long n; - - REQUEST(xPrintDestroyContextReq); - swaps(&stuff->length, i); - swapl(&stuff->printContext, n); - return ProcXpDestroyContext(client); -} - -static int -SProcXpGetContextScreen(ClientPtr client) -{ - int i; - long n; - - REQUEST(xPrintGetContextScreenReq); - swaps(&stuff->length, i); - swapl(&stuff->printContext, n); - return ProcXpGetContextScreen(client); -} - -static int -SProcXpInputSelected(ClientPtr client) -{ - int i; - long n; - - REQUEST(xPrintInputSelectedReq); - swaps(&stuff->length, i); - swapl(&stuff->printContext, n); - return ProcXpInputSelected(client); -} - -static int -SProcXpStartJob(ClientPtr client) -{ - int i; - - REQUEST(xPrintStartJobReq); - swaps(&stuff->length, i); - return ProcXpStartJob(client); -} - -static int -SProcXpEndJob(ClientPtr client) -{ - int i; - - REQUEST(xPrintEndJobReq); - swaps(&stuff->length, i); - return ProcXpEndJob(client); -} - -static int -SProcXpStartDoc(ClientPtr client) -{ - int i; - - REQUEST(xPrintStartDocReq); - swaps(&stuff->length, i); - return ProcXpStartDoc(client); -} - -static int -SProcXpEndDoc(ClientPtr client) -{ - int i; - - REQUEST(xPrintEndDocReq); - swaps(&stuff->length, i); - return ProcXpEndDoc(client); -} - -static int -SProcXpStartPage(ClientPtr client) -{ - int i; - long n; - - REQUEST(xPrintStartPageReq); - swaps(&stuff->length, i); - swapl(&stuff->window, n); - return ProcXpStartPage(client); -} - -static int -SProcXpEndPage(ClientPtr client) -{ - int i; - - REQUEST(xPrintEndPageReq); - swaps(&stuff->length, i); - return ProcXpEndPage(client); -} - -static int -SProcXpPutDocumentData(ClientPtr client) -{ - long n; - int i; - - REQUEST(xPrintPutDocumentDataReq); - swaps(&stuff->length, i); - swapl(&stuff->drawable, n); - swapl(&stuff->len_data, n); - swaps(&stuff->len_fmt, i); - swaps(&stuff->len_options, i); - return ProcXpPutDocumentData(client); -} - -static int -SProcXpGetDocumentData(ClientPtr client) -{ - long n; - int i; - - REQUEST(xPrintGetDocumentDataReq); - swaps(&stuff->length, i); - swapl(&stuff->printContext, n); - swapl(&stuff->maxBufferSize, n); - return ProcXpGetDocumentData(client); -} - -static int -SProcXpGetAttributes(ClientPtr client) -{ - long n; - int i; - - REQUEST(xPrintGetAttributesReq); - swaps(&stuff->length, i); - swapl(&stuff->printContext, n); - return ProcXpGetAttributes(client); -} - -static int -SProcXpSetAttributes(ClientPtr client) -{ - long n; - int i; - - REQUEST(xPrintSetAttributesReq); - swaps(&stuff->length, i); - swapl(&stuff->printContext, n); - swapl(&stuff->stringLen, n); - return ProcXpSetAttributes(client); -} - -static int -SProcXpGetOneAttribute(ClientPtr client) -{ - long n; - int i; - - REQUEST(xPrintGetOneAttributeReq); - swaps(&stuff->length, i); - swapl(&stuff->printContext, n); - swapl(&stuff->nameLen, n); - return ProcXpGetOneAttribute(client); -} - -static int -SProcXpSelectInput(ClientPtr client) -{ - long n; - int i; - - REQUEST(xPrintSelectInputReq); - swaps(&stuff->length, i); - swapl(&stuff->eventMask, n); - swapl(&stuff->printContext, n); - return ProcXpSelectInput(client); -} - -static int -SProcXpGetPageDimensions(ClientPtr client) -{ - long n; - int i; - - REQUEST(xPrintGetPageDimensionsReq); - swaps(&stuff->length, i); - swapl(&stuff->printContext, n); - return ProcXpGetPageDimensions(client); -} - -static int -SProcXpSetImageResolution(ClientPtr client) -{ - long n; - int i; - - REQUEST(xPrintSetImageResolutionReq); - swaps(&stuff->length, i); - swapl(&stuff->printContext, n); - swaps(&stuff->imageRes, i); - return ProcXpSetImageResolution(client); -} - -static int -SProcXpGetImageResolution(ClientPtr client) -{ - long n; - int i; - - REQUEST(xPrintGetImageResolutionReq); - swaps(&stuff->length, i); - swapl(&stuff->printContext, n); - return ProcXpGetImageResolution(client); -} - -static void -SwapXpNotifyEvent(xPrintPrintEvent *src, xPrintPrintEvent *dst) -{ - /* - * Swap the sequence number and context fields. - */ - cpswaps(src->sequenceNumber, dst->sequenceNumber); - cpswapl(src->printContext, dst->printContext); - - /* - * Copy the byte-long fields. - */ - dst->type = src->type; - dst->detail = src->detail; - dst->cancel = src->cancel; -} - -static void -SwapXpAttributeEvent(xPrintAttributeEvent *src, xPrintAttributeEvent *dst) -{ - /* - * Swap the sequence number and context fields. - */ - cpswaps(src->sequenceNumber, dst->sequenceNumber); - cpswapl(src->printContext, dst->printContext); - - /* - * Copy the byte-long fields. - */ - dst->type = src->type; - dst->detail = src->detail; -} diff --git a/xorg-server/Xext/xres.c b/xorg-server/Xext/xres.c index f444c4e69..bdc534c91 100644 --- a/xorg-server/Xext/xres.c +++ b/xorg-server/Xext/xres.c @@ -94,7 +94,7 @@ ProcXResQueryClients (ClientPtr client) scratch.resource_mask = RESOURCE_ID_MASK; if(client->swapped) { - register int n; + int n; swapl (&scratch.resource_base, n); swapl (&scratch.resource_mask, n); } @@ -133,9 +133,7 @@ ProcXResQueryClientResources (ClientPtr client) return BadValue; } - counts = xalloc((lastResourceType + 1) * sizeof(int)); - - memset(counts, 0, (lastResourceType + 1) * sizeof(int)); + counts = xcalloc(lastResourceType + 1, sizeof(int)); FindAllClientResources(clients[clientID], ResFindAllRes, counts); @@ -177,7 +175,7 @@ ProcXResQueryClientResources (ClientPtr client) scratch.count = counts[i]; if(client->swapped) { - register int n; + int n; swapl (&scratch.resource_type, n); swapl (&scratch.count, n); } @@ -301,10 +299,6 @@ ProcXResQueryClientPixmapBytes (ClientPtr client) return (client->noClientException); } - -static void -ResResetProc (ExtensionEntry *extEntry) { } - static int ProcResDispatch (ClientPtr client) { @@ -386,5 +380,5 @@ ResExtensionInit(INITARGS) { (void) AddExtension(XRES_NAME, 0, 0, ProcResDispatch, SProcResDispatch, - ResResetProc, StandardMinorOpcode); + NULL, StandardMinorOpcode); } diff --git a/xorg-server/Xext/xselinux.c b/xorg-server/Xext/xselinux.c index 1d3449b9a..6c99c2944 100644 --- a/xorg-server/Xext/xselinux.c +++ b/xorg-server/Xext/xselinux.c @@ -62,9 +62,12 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* private state keys */ -static DevPrivateKey subjectKey = &subjectKey; -static DevPrivateKey objectKey = &objectKey; -static DevPrivateKey dataKey = &dataKey; +static int subjectKeyIndex; +static DevPrivateKey subjectKey = &subjectKeyIndex; +static int objectKeyIndex; +static DevPrivateKey objectKey = &objectKeyIndex; +static int dataKeyIndex; +static DevPrivateKey dataKey = &dataKeyIndex; /* subject state (clients and devices only) */ typedef struct { @@ -183,19 +186,19 @@ SELinuxAtomToSIDLookup(Atom atom, SELinuxObjectRec *obj, int map, int polymap) obj->poly = 1; /* Look in the mappings of names to contexts */ - if (selabel_lookup(label_hnd, &ctx, name, map) == 0) { + if (selabel_lookup_raw(label_hnd, &ctx, name, map) == 0) { obj->poly = 0; } else if (errno != ENOENT) { ErrorF("SELinux: a property label lookup failed!\n"); return BadValue; - } else if (selabel_lookup(label_hnd, &ctx, name, polymap) < 0) { + } else if (selabel_lookup_raw(label_hnd, &ctx, name, polymap) < 0) { ErrorF("SELinux: a property label lookup failed!\n"); return BadValue; } /* Get a SID for context */ - if (avc_context_to_sid(ctx, &obj->sid) < 0) { - ErrorF("SELinux: a context_to_SID call failed!\n"); + if (avc_context_to_sid_raw(ctx, &obj->sid) < 0) { + ErrorF("SELinux: a context_to_SID_raw call failed!\n"); rc = BadAlloc; } @@ -340,7 +343,7 @@ SELinuxEventToSID(unsigned type, security_id_t sid_of_window, SELinuxObjectRec *sid_return) { const char *name = LookupEventName(type); - security_context_t con; + security_context_t ctx; type &= 127; if (type >= numKnownEvents) { @@ -356,16 +359,16 @@ SELinuxEventToSID(unsigned type, security_id_t sid_of_window, if (!knownEvents[type]) { /* Look in the mappings of event names to contexts */ - if (selabel_lookup(label_hnd, &con, name, SELABEL_X_EVENT) < 0) { + if (selabel_lookup_raw(label_hnd, &ctx, name, SELABEL_X_EVENT) < 0) { ErrorF("SELinux: an event label lookup failed!\n"); return BadValue; } /* Get a SID for context */ - if (avc_context_to_sid(con, knownEvents + type) < 0) { - ErrorF("SELinux: a context_to_SID call failed!\n"); + if (avc_context_to_sid_raw(ctx, knownEvents + type) < 0) { + ErrorF("SELinux: a context_to_SID_raw call failed!\n"); return BadAlloc; } - freecon(con); + freecon(ctx); } /* Perform a transition to obtain the final SID */ @@ -469,9 +472,9 @@ SELinuxLabelClient(ClientPtr client) sidput(obj->sid); /* Try to get a context from the socket */ - if (fd < 0 || getpeercon(fd, &ctx) < 0) { + if (fd < 0 || getpeercon_raw(fd, &ctx) < 0) { /* Otherwise, fall back to a default context */ - if (selabel_lookup(label_hnd, &ctx, NULL, SELABEL_X_CLIENT) < 0) + if (selabel_lookup_raw(label_hnd, &ctx, "remote", SELABEL_X_CLIENT) < 0) FatalError("SELinux: failed to look up remote-client context\n"); } @@ -506,8 +509,8 @@ SELinuxLabelClient(ClientPtr client) finish: /* Get a SID from the context */ - if (avc_context_to_sid(ctx, &subj->sid) < 0) - FatalError("SELinux: client %d: context_to_sid(%s) failed\n", + if (avc_context_to_sid_raw(ctx, &subj->sid) < 0) + FatalError("SELinux: client %d: context_to_sid_raw(%s) failed\n", client->index, ctx); sidget(obj->sid = subj->sid); @@ -534,11 +537,11 @@ SELinuxLabelInitial(void) sidput(subj->sid); /* Use the context of the X server process for the serverClient */ - if (getcon(&ctx) < 0) + if (getcon_raw(&ctx) < 0) FatalError("SELinux: couldn't get context of X server process\n"); /* Get a SID from the context */ - if (avc_context_to_sid(ctx, &subj->sid) < 0) + if (avc_context_to_sid_raw(ctx, &subj->sid) < 0) FatalError("SELinux: serverClient: context_to_sid(%s) failed\n", ctx); sidget(obj->sid = subj->sid); @@ -654,7 +657,19 @@ SELinuxLog(int type, const char *fmt, ...) { va_list ap; char buf[MAX_AUDIT_MESSAGE_LENGTH]; - int rc, aut = AUDIT_USER_AVC; + int rc, aut; + + switch (type) { + case SELINUX_INFO: + aut = AUDIT_USER_MAC_POLICY_LOAD; + break; + case SELINUX_AVC: + aut = AUDIT_USER_AVC; + break; + default: + aut = AUDIT_USER_SELINUX_ERR; + break; + } va_start(ap, fmt); vsnprintf(buf, MAX_AUDIT_MESSAGE_LENGTH, fmt, ap); @@ -812,20 +827,20 @@ SELinuxExtension(CallbackListPtr *pcbl, pointer unused, pointer calldata) /* XXX there should be a separate callback for this */ if (obj->sid == unlabeled_sid) { const char *name = rec->ext->name; - security_context_t con; + security_context_t ctx; security_id_t sid; serv = dixLookupPrivate(&serverClient->devPrivates, subjectKey); /* Look in the mappings of extension names to contexts */ - if (selabel_lookup(label_hnd, &con, name, SELABEL_X_EXT) < 0) { + if (selabel_lookup_raw(label_hnd, &ctx, name, SELABEL_X_EXT) < 0) { ErrorF("SELinux: a property label lookup failed!\n"); rec->status = BadValue; return; } /* Get a SID for context */ - if (avc_context_to_sid(con, &sid) < 0) { - ErrorF("SELinux: a context_to_SID call failed!\n"); + if (avc_context_to_sid_raw(ctx, &sid) < 0) { + ErrorF("SELinux: a context_to_SID_raw call failed!\n"); rec->status = BadAlloc; return; } @@ -836,11 +851,11 @@ SELinuxExtension(CallbackListPtr *pcbl, pointer unused, pointer calldata) if (avc_compute_create(serv->sid, sid, SECCLASS_X_EXTENSION, &obj->sid) < 0) { ErrorF("SELinux: a SID transition call failed!\n"); - freecon(con); + freecon(ctx); rec->status = BadValue; return; } - freecon(con); + freecon(ctx); } /* Perform the security check */ @@ -1135,13 +1150,15 @@ SELinuxResourceState(CallbackListPtr *pcbl, pointer unused, pointer calldata) if (rec->type != RT_WINDOW) return; + if (rec->state != ResourceStateAdding) + return; pWin = (WindowPtr)rec->value; subj = dixLookupPrivate(&wClient(pWin)->devPrivates, subjectKey); if (subj->sid) { security_context_t ctx; - int rc = avc_sid_to_context(subj->sid, &ctx); + int rc = avc_sid_to_context_raw(subj->sid, &ctx); if (rc < 0) FatalError("SELinux: Failed to get security context!\n"); rc = dixChangeWindowProperty(serverClient, @@ -1157,7 +1174,7 @@ SELinuxResourceState(CallbackListPtr *pcbl, pointer unused, pointer calldata) if (obj->sid) { security_context_t ctx; - int rc = avc_sid_to_context(obj->sid, &ctx); + int rc = avc_sid_to_context_raw(obj->sid, &ctx); if (rc < 0) FatalError("SELinux: Failed to get security context!\n"); rc = dixChangeWindowProperty(serverClient, @@ -1244,6 +1261,17 @@ typedef struct { CARD32 id; } SELinuxListItemRec; +static security_context_t +SELinuxCopyContext(char *ptr, unsigned len) +{ + security_context_t copy = xalloc(len + 1); + if (!copy) + return NULL; + strncpy(copy, ptr, len); + copy[len] = '\0'; + return copy; +} + static int ProcSELinuxQueryVersion(ClientPtr client) { @@ -1273,7 +1301,7 @@ SELinuxSendContextReply(ClientPtr client, security_id_t sid) int len = 0; if (sid) { - if (avc_sid_to_context(sid, &ctx) < 0) + if (avc_sid_to_context_raw(sid, &ctx) < 0) return BadValue; len = strlen(ctx) + 1; } @@ -1301,43 +1329,41 @@ ProcSELinuxSetCreateContext(ClientPtr client, unsigned offset) { PrivateRec **privPtr = &client->devPrivates; security_id_t *pSid; - security_context_t ctx; + security_context_t ctx = NULL; char *ptr; + int rc; REQUEST(SELinuxSetCreateContextReq); REQUEST_FIXED_SIZE(SELinuxSetCreateContextReq, stuff->context_len); - ctx = (char *)(stuff + 1); - if (stuff->context_len > 0 && ctx[stuff->context_len - 1]) - return BadLength; + if (stuff->context_len > 0) { + ctx = SELinuxCopyContext((char *)(stuff + 1), stuff->context_len); + if (!ctx) + return BadAlloc; + } if (offset == CTX_DEV) { /* Device create context currently requires manage permission */ - int rc = XaceHook(XACE_SERVER_ACCESS, client, DixManageAccess); + rc = XaceHook(XACE_SERVER_ACCESS, client, DixManageAccess); if (rc != Success) - return rc; + goto out; privPtr = &serverClient->devPrivates; } - else if (offset == USE_SEL) { - /* Selection use context currently requires no selections owned */ - Selection *pSel; - for (pSel = CurrentSelections; pSel; pSel = pSel->next) - if (pSel->client == client) - return BadMatch; - } ptr = dixLookupPrivate(privPtr, subjectKey); pSid = (security_id_t *)(ptr + offset); sidput(*pSid); *pSid = NULL; + rc = Success; if (stuff->context_len > 0) { - if (security_check_context(ctx) < 0) - return BadValue; - if (avc_context_to_sid(ctx, pSid) < 0) - return BadValue; + if (security_check_context_raw(ctx) < 0 || + avc_context_to_sid_raw(ctx, pSid) < 0) + rc = BadValue; } - return Success; +out: + xfree(ctx); + return rc; } static int @@ -1370,18 +1396,21 @@ ProcSELinuxSetDeviceContext(ClientPtr client) REQUEST(SELinuxSetContextReq); REQUEST_FIXED_SIZE(SELinuxSetContextReq, stuff->context_len); - ctx = (char *)(stuff + 1); - if (stuff->context_len < 1 || ctx[stuff->context_len - 1]) + if (stuff->context_len < 1) return BadLength; + ctx = SELinuxCopyContext((char *)(stuff + 1), stuff->context_len); + if (!ctx) + return BadAlloc; rc = dixLookupDevice(&dev, stuff->id, client, DixManageAccess); if (rc != Success) - return rc; + goto out; - if (security_check_context(ctx) < 0) - return BadValue; - if (avc_context_to_sid(ctx, &sid) < 0) - return BadValue; + if (security_check_context_raw(ctx) < 0 || + avc_context_to_sid_raw(ctx, &sid) < 0) { + rc = BadValue; + goto out; + } subj = dixLookupPrivate(&dev->devPrivates, subjectKey); sidput(subj->sid); @@ -1390,7 +1419,10 @@ ProcSELinuxSetDeviceContext(ClientPtr client) sidput(obj->sid); sidget(obj->sid = sid); - return Success; + rc = Success; +out: + xfree(ctx); + return rc; } static int @@ -1496,9 +1528,9 @@ SELinuxPopulateItem(SELinuxListItemRec *i, PrivateRec **privPtr, CARD32 id, SELinuxObjectRec *obj = dixLookupPrivate(privPtr, objectKey); SELinuxObjectRec *data = dixLookupPrivate(privPtr, dataKey); - if (avc_sid_to_context(obj->sid, &i->octx) < 0) + if (avc_sid_to_context_raw(obj->sid, &i->octx) < 0) return BadValue; - if (avc_sid_to_context(data->sid, &i->dctx) < 0) + if (avc_sid_to_context_raw(data->sid, &i->dctx) < 0) return BadValue; i->id = id; @@ -1529,7 +1561,7 @@ SELinuxSendItemsToClient(ClientPtr client, SELinuxListItemRec *items, CARD32 *buf; buf = xcalloc(size, sizeof(CARD32)); - if (!buf) { + if (size && !buf) { rc = BadAlloc; goto out; } @@ -1601,7 +1633,7 @@ ProcSELinuxListProperties(ClientPtr client) for (pProp = wUserProps(pWin); pProp; pProp = pProp->next) count++; items = xcalloc(count, sizeof(SELinuxListItemRec)); - if (!items) + if (count && !items) return BadAlloc; /* Fill in the items and calculate size */ @@ -1635,7 +1667,7 @@ ProcSELinuxListSelections(ClientPtr client) for (pSel = CurrentSelections; pSel; pSel = pSel->next) count++; items = xcalloc(count, sizeof(SELinuxListItemRec)); - if (!items) + if (count && !items) return BadAlloc; /* Fill in the items and calculate size */ @@ -1872,6 +1904,22 @@ SProcSELinuxDispatch(ClientPtr client) } } +#ifdef HAVE_AVC_NETLINK_ACQUIRE_FD +static int netlink_fd; + +static void +SELinuxBlockHandler(void *data, struct timeval **tv, void *read_mask) +{ +} + +static void +SELinuxWakeupHandler(void *data, int err, void *read_mask) +{ + if (FD_ISSET(netlink_fd, (fd_set *)read_mask)) + avc_netlink_check_nb(); +} +#endif + /* * Extension Setup / Teardown @@ -1902,6 +1950,12 @@ SELinuxResetProc(ExtensionEntry *extEntry) label_hnd = NULL; audit_close(audit_fd); +#ifdef HAVE_AVC_NETLINK_ACQUIRE_FD + avc_netlink_release_fd(); + RemoveBlockAndWakeupHandlers(SELinuxBlockHandler, SELinuxWakeupHandler, + NULL); + RemoveGeneralSocket(netlink_fd); +#endif avc_destroy(); avc_active = 0; @@ -1926,7 +1980,7 @@ SELinuxExtensionInit(INITARGS) ExtensionEntry *extEntry; struct selinux_opt selabel_option = { SELABEL_OPT_VALIDATE, (char *)1 }; struct selinux_opt avc_option = { AVC_OPT_SETENFORCE, (char *)0 }; - security_context_t con; + security_context_t ctx; int ret = TRUE; /* Check SELinux mode on system */ @@ -1973,11 +2027,11 @@ SELinuxExtensionInit(INITARGS) if (!label_hnd) FatalError("SELinux: Failed to open x_contexts mapping in policy\n"); - if (security_get_initial_context("unlabeled", &con) < 0) + if (security_get_initial_context_raw("unlabeled", &ctx) < 0) FatalError("SELinux: Failed to look up unlabeled context\n"); - if (avc_context_to_sid(con, &unlabeled_sid) < 0) + if (avc_context_to_sid_raw(ctx, &unlabeled_sid) < 0) FatalError("SELinux: a context_to_SID call failed!\n"); - freecon(con); + freecon(ctx); /* Prepare for auditing */ audit_fd = audit_open(); @@ -1998,6 +2052,13 @@ SELinuxExtensionInit(INITARGS) if (atom_client_ctx == BAD_RESOURCE) FatalError("SELinux: Failed to create atom\n"); +#ifdef HAVE_AVC_NETLINK_ACQUIRE_FD + netlink_fd = avc_netlink_acquire_fd(); + AddGeneralSocket(netlink_fd); + RegisterBlockAndWakeupHandlers(SELinuxBlockHandler, SELinuxWakeupHandler, + NULL); +#endif + /* Register callbacks */ ret &= dixRegisterPrivateInitFunc(subjectKey, SELinuxSubjectInit, NULL); ret &= dixRegisterPrivateDeleteFunc(subjectKey, SELinuxSubjectFree, NULL); diff --git a/xorg-server/Xext/xtest.c b/xorg-server/Xext/xtest.c index db6d54543..3ff02ed91 100644 --- a/xorg-server/Xext/xtest.c +++ b/xorg-server/Xext/xtest.c @@ -1,30 +1,30 @@ /* -Copyright 1992, 1998 The Open Group + Copyright 1992, 1998 The Open Group -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. + Permission to use, copy, modify, distribute, and sell this software and its + documentation for any purpose is hereby granted without fee, provided that + the above copyright notice appear in all copies and that both that + copyright notice and this permission notice appear in supporting + documentation. -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR + OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + OTHER DEALINGS IN THE SOFTWARE. -Except as contained in this notice, the name of The Open Group shall -not be used in advertising or otherwise to promote the sale, use or -other dealings in this Software without prior written authorization -from The Open Group. + Except as contained in this notice, the name of The Open Group shall + not be used in advertising or otherwise to promote the sale, use or + other dealings in this Software without prior written authorization + from The Open Group. -*/ + */ #ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> @@ -42,33 +42,27 @@ from The Open Group. #include "scrnintstr.h" #include "dixevents.h" #include "sleepuntil.h" +#include "mi.h" #define _XTEST_SERVER_ #include <X11/extensions/XTest.h> #include <X11/extensions/xteststr.h> -#ifdef XINPUT #include <X11/extensions/XI.h> #include <X11/extensions/XIproto.h> -#define EXTENSION_EVENT_BASE 64 -#endif /* XINPUT */ #include "modinit.h" -#ifdef XINPUT extern int DeviceValuator; -#endif /* XINPUT */ +extern int DeviceMotionNotify; #ifdef PANORAMIX #include "panoramiX.h" #include "panoramiXsrv.h" #endif -static void XTestResetProc( - ExtensionEntry * /* extEntry */ -); static int XTestSwapFakeInput( - ClientPtr /* client */, - xReq * /* req */ -); + ClientPtr /* client */, + xReq * /* req */ + ); static DISPATCH_PROC(ProcXTestCompareCursor); static DISPATCH_PROC(ProcXTestDispatch); @@ -85,23 +79,16 @@ void XTestExtensionInit(INITARGS) { AddExtension(XTestExtensionName, 0, 0, - ProcXTestDispatch, SProcXTestDispatch, - XTestResetProc, StandardMinorOpcode); -} - -/*ARGSUSED*/ -static void -XTestResetProc (extEntry) -ExtensionEntry *extEntry; -{ + ProcXTestDispatch, SProcXTestDispatch, + NULL, StandardMinorOpcode); } static int ProcXTestGetVersion(client) - register ClientPtr client; + ClientPtr client; { xXTestGetVersionReply rep; - register int n; + int n; REQUEST_SIZE_MATCH(xXTestGetVersionReq); rep.type = X_Reply; @@ -110,8 +97,8 @@ ProcXTestGetVersion(client) rep.majorVersion = XTestMajorVersion; rep.minorVersion = XTestMinorVersion; if (client->swapped) { - swaps(&rep.sequenceNumber, n); - swaps(&rep.minorVersion, n); + swaps(&rep.sequenceNumber, n); + swaps(&rep.minorVersion, n); } WriteToClient(client, sizeof(xXTestGetVersionReply), (char *)&rep); return(client->noClientException); @@ -119,37 +106,38 @@ ProcXTestGetVersion(client) static int ProcXTestCompareCursor(client) - register ClientPtr client; + ClientPtr client; { REQUEST(xXTestCompareCursorReq); xXTestCompareCursorReply rep; WindowPtr pWin; CursorPtr pCursor; - register int n, rc; + int n, rc; + DeviceIntPtr ptr = PickPointer(client); REQUEST_SIZE_MATCH(xXTestCompareCursorReq); rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); if (rc != Success) return rc; if (stuff->cursor == None) - pCursor = NullCursor; + pCursor = NullCursor; else if (stuff->cursor == XTestCurrentCursor) - pCursor = GetSpriteCursor(); + pCursor = GetSpriteCursor(ptr); else { - rc = dixLookupResource((pointer *)&pCursor, stuff->cursor, RT_CURSOR, - client, DixReadAccess); - if (rc != Success) - { - client->errorValue = stuff->cursor; - return (rc == BadValue) ? BadCursor : rc; - } + rc = dixLookupResource((pointer *)&pCursor, stuff->cursor, RT_CURSOR, + client, DixReadAccess); + if (rc != Success) + { + client->errorValue = stuff->cursor; + return (rc == BadValue) ? BadCursor : rc; + } } rep.type = X_Reply; rep.length = 0; rep.sequenceNumber = client->sequence; rep.same = (wCursor(pWin) == pCursor); if (client->swapped) { - swaps(&rep.sequenceNumber, n); + swaps(&rep.sequenceNumber, n); } WriteToClient(client, sizeof(xXTestCompareCursorReply), (char *)&rep); return(client->noClientException); @@ -157,345 +145,315 @@ ProcXTestCompareCursor(client) static int ProcXTestFakeInput(client) - register ClientPtr client; + ClientPtr client; { REQUEST(xXTestFakeInputReq); int nev, n, type, rc; xEvent *ev; DeviceIntPtr dev = NULL; WindowPtr root; -#ifdef XINPUT Bool extension = FALSE; deviceValuator *dv = NULL; - int base; - int *values; -#endif /* XINPUT */ + int valuators[MAX_VALUATORS] = {0}; + int numValuators = 0; + int firstValuator = 0; + EventListPtr events; + int nevents; + int i; + int base = 0; + int flags = 0; nev = (stuff->length << 2) - sizeof(xReq); if ((nev % sizeof(xEvent)) || !nev) - return BadLength; + return BadLength; nev /= sizeof(xEvent); UpdateCurrentTime(); ev = (xEvent *)&((xReq *)stuff)[1]; type = ev->u.u.type & 0177; -#ifdef XINPUT + if (type >= EXTENSION_EVENT_BASE) { - type -= DeviceValuator; - switch (type) { - case XI_DeviceKeyPress: - case XI_DeviceKeyRelease: - case XI_DeviceButtonPress: - case XI_DeviceButtonRelease: - case XI_DeviceMotionNotify: - case XI_ProximityIn: - case XI_ProximityOut: - break; - default: - client->errorValue = ev->u.u.type; - return BadValue; - } - if (nev == 1 && type == XI_DeviceMotionNotify) - return BadLength; - if (type == XI_DeviceMotionNotify) - base = ((deviceValuator *)(ev+1))->first_valuator; - else - base = 0; - for (n = 1; n < nev; n++) - { - dv = (deviceValuator *)(ev + n); - if (dv->type != DeviceValuator) - { - client->errorValue = dv->type; - return BadValue; - } - if (dv->first_valuator != base) - { - client->errorValue = dv->first_valuator; - return BadValue; - } - if (!dv->num_valuators || dv->num_valuators > 6) - { - client->errorValue = dv->num_valuators; - return BadValue; - } - base += dv->num_valuators; - } - type = type - XI_DeviceKeyPress + KeyPress; - extension = TRUE; - } - else -#endif /* XINPUT */ + extension = TRUE; + + /* check device */ + rc = dixLookupDevice(&dev, stuff->deviceid & 0177, client, + DixWriteAccess); + if (rc != Success) + { + client->errorValue = stuff->deviceid & 0177; + return rc; + } + + /* check type */ + type -= DeviceValuator; + switch (type) { + case XI_DeviceKeyPress: + case XI_DeviceKeyRelease: + case XI_DeviceButtonPress: + case XI_DeviceButtonRelease: + case XI_DeviceMotionNotify: + case XI_ProximityIn: + case XI_ProximityOut: + break; + default: + client->errorValue = ev->u.u.type; + return BadValue; + } + + /* check validity */ + if (nev == 1 && type == XI_DeviceMotionNotify) + return BadLength; /* DevMotion must be followed by DevValuator */ + + if (type == XI_DeviceMotionNotify) + { + firstValuator = ((deviceValuator *)(ev+1))->first_valuator; + if (firstValuator > dev->valuator->numAxes) + { + client->errorValue = ev->u.u.type; + return BadValue; + } + + if (ev->u.u.detail == xFalse) + flags |= POINTER_ABSOLUTE; + } else + { + firstValuator = 0; + flags |= POINTER_ABSOLUTE; + } + + if (nev == 1 && type == XI_DeviceMotionNotify && !dev->valuator) + { + client->errorValue = dv->first_valuator; + return BadValue; + } + + + /* check validity of valuator events */ + base = firstValuator; + for (n = 1; n < nev; n++) + { + dv = (deviceValuator *)(ev + n); + if (dv->type != DeviceValuator) + { + client->errorValue = dv->type; + return BadValue; + } + if (dv->first_valuator != base) + { + client->errorValue = dv->first_valuator; + return BadValue; + } + switch(dv->num_valuators) + { + case 6: valuators[base + 5] = dv->valuator5; + case 5: valuators[base + 4] = dv->valuator4; + case 4: valuators[base + 3] = dv->valuator3; + case 3: valuators[base + 2] = dv->valuator2; + case 2: valuators[base + 1] = dv->valuator1; + case 1: valuators[base] = dv->valuator0; + break; + default: + client->errorValue = dv->num_valuators; + return BadValue; + } + + base += dv->num_valuators; + numValuators += dv->num_valuators; + + if (firstValuator + numValuators > dev->valuator->numAxes) + { + client->errorValue = dv->num_valuators; + return BadValue; + } + } + type = type - XI_DeviceKeyPress + KeyPress; + + } else { - if (nev != 1) - return BadLength; - switch (type) - { - case KeyPress: - case KeyRelease: - case MotionNotify: - case ButtonPress: - case ButtonRelease: - break; - default: - client->errorValue = ev->u.u.type; - return BadValue; - } + if (nev != 1) + return BadLength; + switch (type) + { + case KeyPress: + case KeyRelease: + dev = PickKeyboard(client); + break; + case ButtonPress: + case ButtonRelease: + dev = PickPointer(client); + break; + case MotionNotify: + dev = PickPointer(client); + valuators[0] = ev->u.keyButtonPointer.rootX; + valuators[1] = ev->u.keyButtonPointer.rootY; + numValuators = 2; + firstValuator = 0; + if (ev->u.u.detail == xFalse) + flags = POINTER_ABSOLUTE | POINTER_SCREEN; + break; + default: + client->errorValue = ev->u.u.type; + return BadValue; + } + + if (dev->u.lastSlave) + dev = dev->u.lastSlave; } + + /* If the event has a time set, wait for it to pass */ if (ev->u.keyButtonPointer.time) { - TimeStamp activateTime; - CARD32 ms; - - activateTime = currentTime; - ms = activateTime.milliseconds + ev->u.keyButtonPointer.time; - if (ms < activateTime.milliseconds) - activateTime.months++; - activateTime.milliseconds = ms; - ev->u.keyButtonPointer.time = 0; - - /* see mbuf.c:QueueDisplayRequest for code similar to this */ - - if (!ClientSleepUntil(client, &activateTime, NULL, NULL)) - { - return BadAlloc; - } - /* swap the request back so we can simply re-execute it */ - if (client->swapped) - { - (void) XTestSwapFakeInput(client, (xReq *)stuff); - swaps(&stuff->length, n); - } - ResetCurrentRequest (client); - client->sequence--; - return Success; - } -#ifdef XINPUT - if (extension) - { - rc = dixLookupDevice(&dev, stuff->deviceid & 0177, client, - DixWriteAccess); - if (rc != Success) - { - client->errorValue = stuff->deviceid & 0177; - return rc; - } - if (nev > 1) - { - dv = (deviceValuator *)(ev + 1); - if (!dev->valuator || dv->first_valuator >= dev->valuator->numAxes) - { - client->errorValue = dv->first_valuator; - return BadValue; - } - if (dv->first_valuator + dv->num_valuators > - dev->valuator->numAxes) - { - client->errorValue = dv->num_valuators; - return BadValue; - } - } + TimeStamp activateTime; + CARD32 ms; + + activateTime = currentTime; + ms = activateTime.milliseconds + ev->u.keyButtonPointer.time; + if (ms < activateTime.milliseconds) + activateTime.months++; + activateTime.milliseconds = ms; + ev->u.keyButtonPointer.time = 0; + + /* see mbuf.c:QueueDisplayRequest for code similar to this */ + + if (!ClientSleepUntil(client, &activateTime, NULL, NULL)) + { + return BadAlloc; + } + /* swap the request back so we can simply re-execute it */ + if (client->swapped) + { + (void) XTestSwapFakeInput(client, (xReq *)stuff); + swaps(&stuff->length, n); + } + ResetCurrentRequest (client); + client->sequence--; + return Success; } -#endif /* XINPUT */ + switch (type) { - case KeyPress: - case KeyRelease: -#ifdef XINPUT - if (!extension) -#endif /* XINPUT */ - dev = inputInfo.keyboard; - if (ev->u.u.detail < dev->key->curKeySyms.minKeyCode || - ev->u.u.detail > dev->key->curKeySyms.maxKeyCode) - { - client->errorValue = ev->u.u.detail; - return BadValue; - } - break; - case MotionNotify: -#ifdef XINPUT - if (extension) - { - if (ev->u.u.detail != xFalse && ev->u.u.detail != xTrue) - { - client->errorValue = ev->u.u.detail; - return BadValue; - } - if (ev->u.u.detail == xTrue && dev->valuator->mode == Absolute) - { - values = dev->valuator->axisVal + dv->first_valuator; - for (n = 1; n < nev; n++) - { - dv = (deviceValuator *)(ev + n); - switch (dv->num_valuators) - { - case 6: - dv->valuator5 += values[5]; - case 5: - dv->valuator4 += values[4]; - case 4: - dv->valuator3 += values[3]; - case 3: - dv->valuator2 += values[2]; - case 2: - dv->valuator1 += values[1]; - case 1: - dv->valuator0 += values[0]; - } - values += 6; - } - } - break; - } -#endif /* XINPUT */ - dev = inputInfo.pointer; - if (ev->u.keyButtonPointer.root == None) - root = GetCurrentRootWindow(); - else - { - rc = dixLookupWindow(&root, ev->u.keyButtonPointer.root, client, - DixGetAttrAccess); - if (rc != Success) - return rc; - if (root->parent) - { - client->errorValue = ev->u.keyButtonPointer.root; - return BadValue; - } - } - if (ev->u.u.detail == xTrue) - { - int x, y; - GetSpritePosition(&x, &y); - ev->u.keyButtonPointer.rootX += x; - ev->u.keyButtonPointer.rootY += y; - } - else if (ev->u.u.detail != xFalse) - { - client->errorValue = ev->u.u.detail; - return BadValue; - } - -#ifdef PANORAMIX - if (!noPanoramiXExtension) { - ScreenPtr pScreen = root->drawable.pScreen; - BoxRec box; - int i; - int x = ev->u.keyButtonPointer.rootX + panoramiXdataPtr[0].x; - int y = ev->u.keyButtonPointer.rootY + panoramiXdataPtr[0].y; - if (!POINT_IN_REGION(pScreen, &XineramaScreenRegions[pScreen->myNum], - x, y, &box)) { - FOR_NSCREENS(i) { - if (i == pScreen->myNum) continue; - if (POINT_IN_REGION(pScreen, - &XineramaScreenRegions[i], - x, y, &box)) { - root = WindowTable[i]; - x -= panoramiXdataPtr[i].x; - y -= panoramiXdataPtr[i].y; - ev->u.keyButtonPointer.rootX = x; - ev->u.keyButtonPointer.rootY = y; - break; - } - } - } - } -#endif - - if (ev->u.keyButtonPointer.rootX < 0) - ev->u.keyButtonPointer.rootX = 0; - else if (ev->u.keyButtonPointer.rootX >= root->drawable.width) - ev->u.keyButtonPointer.rootX = root->drawable.width - 1; - if (ev->u.keyButtonPointer.rootY < 0) - ev->u.keyButtonPointer.rootY = 0; - else if (ev->u.keyButtonPointer.rootY >= root->drawable.height) - ev->u.keyButtonPointer.rootY = root->drawable.height - 1; - -#ifdef PANORAMIX - if ((!noPanoramiXExtension - && root->drawable.pScreen->myNum != XineramaGetCursorScreen()) - || (noPanoramiXExtension && root != GetCurrentRootWindow())) - -#else - if (root != GetCurrentRootWindow()) -#endif - { - NewCurrentScreen(root->drawable.pScreen, - ev->u.keyButtonPointer.rootX, - ev->u.keyButtonPointer.rootY); - return client->noClientException; - } - (*root->drawable.pScreen->SetCursorPosition) - (root->drawable.pScreen, - ev->u.keyButtonPointer.rootX, - ev->u.keyButtonPointer.rootY, FALSE); - dev->valuator->lastx = ev->u.keyButtonPointer.rootX; - dev->valuator->lasty = ev->u.keyButtonPointer.rootY; - break; - case ButtonPress: - case ButtonRelease: -#ifdef XINPUT - if (!extension) -#endif /* XINPUT */ - dev = inputInfo.pointer; - if (!ev->u.u.detail || ev->u.u.detail > dev->button->numButtons) - { - client->errorValue = ev->u.u.detail; - return BadValue; - } - break; + case KeyPress: + case KeyRelease: + if (ev->u.u.detail < dev->key->curKeySyms.minKeyCode || + ev->u.u.detail > dev->key->curKeySyms.maxKeyCode) + { + client->errorValue = ev->u.u.detail; + return BadValue; + } + break; + case MotionNotify: + /* broken lib, XI events have root uninitialized */ + if (extension || ev->u.keyButtonPointer.root == None) + root = GetCurrentRootWindow(dev); + else + { + rc = dixLookupWindow(&root, ev->u.keyButtonPointer.root, + client, DixGetAttrAccess); + if (rc != Success) + return rc; + if (root->parent) + { + client->errorValue = ev->u.keyButtonPointer.root; + return BadValue; + } + } + if (ev->u.u.detail != xTrue && ev->u.u.detail != xFalse) + { + client->errorValue = ev->u.u.detail; + return BadValue; + } + + /* FIXME: Xinerama! */ + + break; + case ButtonPress: + case ButtonRelease: + if (!extension) + { + dev = PickPointer(client); + if (dev->u.lastSlave) + dev = dev->u.lastSlave; + } + if (!ev->u.u.detail || ev->u.u.detail > dev->button->numButtons) + { + client->errorValue = ev->u.u.detail; + return BadValue; + } + break; } if (screenIsSaved == SCREEN_SAVER_ON) - dixSaveScreens(serverClient, SCREEN_SAVER_OFF, ScreenSaverReset); - ev->u.keyButtonPointer.time = currentTime.milliseconds; - (*dev->public.processInputProc)(ev, dev, nev); + dixSaveScreens(serverClient, SCREEN_SAVER_OFF, ScreenSaverReset); + + GetEventList(&events); + switch(type) { + case MotionNotify: + nevents = GetPointerEvents(events, dev, type, 0, flags, + firstValuator, numValuators, valuators); + break; + case ButtonPress: + case ButtonRelease: + nevents = GetPointerEvents(events, dev, type, ev->u.u.detail, + flags, firstValuator, + numValuators, valuators); + break; + case KeyPress: + case KeyRelease: + nevents = GetKeyboardEvents(events, dev, type, ev->u.u.detail); + break; + } + + OsBlockSignals(); + for (i = 0; i < nevents; i++) + mieqEnqueue(dev, (events+i)->event); + OsReleaseSignals(); + return client->noClientException; } static int ProcXTestGrabControl(client) - register ClientPtr client; + ClientPtr client; { REQUEST(xXTestGrabControlReq); REQUEST_SIZE_MATCH(xXTestGrabControlReq); if ((stuff->impervious != xTrue) && (stuff->impervious != xFalse)) { - client->errorValue = stuff->impervious; + client->errorValue = stuff->impervious; return(BadValue); } if (stuff->impervious) - MakeClientGrabImpervious(client); + MakeClientGrabImpervious(client); else - MakeClientGrabPervious(client); + MakeClientGrabPervious(client); return(client->noClientException); } static int ProcXTestDispatch (client) - register ClientPtr client; + ClientPtr client; { REQUEST(xReq); switch (stuff->data) { - case X_XTestGetVersion: - return ProcXTestGetVersion(client); - case X_XTestCompareCursor: - return ProcXTestCompareCursor(client); - case X_XTestFakeInput: - return ProcXTestFakeInput(client); - case X_XTestGrabControl: - return ProcXTestGrabControl(client); - default: - return BadRequest; + case X_XTestGetVersion: + return ProcXTestGetVersion(client); + case X_XTestCompareCursor: + return ProcXTestCompareCursor(client); + case X_XTestFakeInput: + return ProcXTestFakeInput(client); + case X_XTestGrabControl: + return ProcXTestGrabControl(client); + default: + return BadRequest; } } static int SProcXTestGetVersion(client) - register ClientPtr client; + ClientPtr client; { - register int n; + int n; REQUEST(xXTestGetVersionReq); swaps(&stuff->length, n); @@ -506,9 +464,9 @@ SProcXTestGetVersion(client) static int SProcXTestCompareCursor(client) - register ClientPtr client; + ClientPtr client; { - register int n; + int n; REQUEST(xXTestCompareCursorReq); swaps(&stuff->length, n); @@ -520,49 +478,49 @@ SProcXTestCompareCursor(client) static int XTestSwapFakeInput(client, req) - register ClientPtr client; + ClientPtr client; xReq *req; { - register int nev; - register xEvent *ev; + int nev; + xEvent *ev; xEvent sev; EventSwapPtr proc; nev = ((req->length << 2) - sizeof(xReq)) / sizeof(xEvent); for (ev = (xEvent *)&req[1]; --nev >= 0; ev++) { - /* Swap event */ - proc = EventSwapVector[ev->u.u.type & 0177]; - /* no swapping proc; invalid event type? */ - if (!proc || proc == NotImplemented) { - client->errorValue = ev->u.u.type; - return BadValue; - } - (*proc)(ev, &sev); - *ev = sev; + /* Swap event */ + proc = EventSwapVector[ev->u.u.type & 0177]; + /* no swapping proc; invalid event type? */ + if (!proc || proc == NotImplemented) { + client->errorValue = ev->u.u.type; + return BadValue; + } + (*proc)(ev, &sev); + *ev = sev; } return Success; } static int SProcXTestFakeInput(client) - register ClientPtr client; + ClientPtr client; { - register int n; + int n; REQUEST(xReq); swaps(&stuff->length, n); n = XTestSwapFakeInput(client, stuff); if (n != Success) - return n; + return n; return ProcXTestFakeInput(client); } static int SProcXTestGrabControl(client) - register ClientPtr client; + ClientPtr client; { - register int n; + int n; REQUEST(xXTestGrabControlReq); swaps(&stuff->length, n); @@ -572,20 +530,20 @@ SProcXTestGrabControl(client) static int SProcXTestDispatch (client) - register ClientPtr client; + ClientPtr client; { REQUEST(xReq); switch (stuff->data) { - case X_XTestGetVersion: - return SProcXTestGetVersion(client); - case X_XTestCompareCursor: - return SProcXTestCompareCursor(client); - case X_XTestFakeInput: - return SProcXTestFakeInput(client); - case X_XTestGrabControl: - return SProcXTestGrabControl(client); - default: - return BadRequest; + case X_XTestGetVersion: + return SProcXTestGetVersion(client); + case X_XTestCompareCursor: + return SProcXTestCompareCursor(client); + case X_XTestFakeInput: + return SProcXTestFakeInput(client); + case X_XTestGrabControl: + return SProcXTestGrabControl(client); + default: + return BadRequest; } } diff --git a/xorg-server/Xext/xvmain.c b/xorg-server/Xext/xvmain.c index 9834fcfa0..fcca724b0 100644 --- a/xorg-server/Xext/xvmain.c +++ b/xorg-server/Xext/xvmain.c @@ -105,7 +105,8 @@ SOFTWARE. #endif #include "xvdisp.h" -static DevPrivateKey XvScreenKey = &XvScreenKey; +static int XvScreenKeyIndex; +static DevPrivateKey XvScreenKey = &XvScreenKeyIndex; unsigned long XvExtensionGeneration = 0; unsigned long XvScreenGeneration = 0; unsigned long XvResourceGeneration = 0; @@ -541,8 +542,8 @@ int reason; event.u.videoNotify.drawable = pDraw->id; event.u.videoNotify.port = pPort->id; event.u.videoNotify.reason = reason; - (void) TryClientEvents(pn->client, (xEventPtr)&event, 1, NoEventMask, - NoEventMask, NullGrab); + TryClientEvents(pn->client, NULL, (xEventPtr)&event, 1, + NoEventMask, NoEventMask, NullGrab); } pn = pn->next; } @@ -573,8 +574,8 @@ XvdiSendPortNotify( event.u.portNotify.port = pPort->id; event.u.portNotify.attribute = attribute; event.u.portNotify.value = value; - (void) TryClientEvents(pn->client, (xEventPtr)&event, 1, NoEventMask, - NoEventMask, NullGrab); + TryClientEvents(pn->client, NULL, (xEventPtr)&event, 1, + NoEventMask, NoEventMask, NullGrab); } pn = pn->next; } diff --git a/xorg-server/Xext/xvmc.c b/xorg-server/Xext/xvmc.c index 7ae8cc0da..ad1b8abc0 100644 --- a/xorg-server/Xext/xvmc.c +++ b/xorg-server/Xext/xvmc.c @@ -24,14 +24,9 @@ #include "xvmcext.h" #ifdef HAS_XVMCSHM -#ifndef Lynx #include <sys/ipc.h> #include <sys/types.h> #include <sys/shm.h> -#else -#include <ipc.h> -#include <shm.h> -#endif /* Lynx */ #endif /* HAS_XVMCSHM */ @@ -39,7 +34,8 @@ #define DR_CLIENT_DRIVER_NAME_SIZE 48 #define DR_BUSID_SIZE 48 -static DevPrivateKey XvMCScreenKey = NULL; +static int XvMCScreenKeyIndex; +static DevPrivateKey XvMCScreenKey; unsigned long XvMCGeneration = 0; @@ -113,12 +109,6 @@ XvMCDestroySubpictureRes(pointer data, XID id) return Success; } -static void -XvMCResetProc (ExtensionEntry *extEntry) -{ -} - - static int ProcXvMCQueryVersion(ClientPtr client) { @@ -613,8 +603,8 @@ ProcXvMCGetDRInfo(ClientPtr client) #ifdef HAS_XVMCSHM patternP = (CARD32 *)shmat( stuff->shmKey, NULL, SHM_RDONLY ); if ( -1 != (long) patternP) { - register volatile CARD32 *patternC = patternP; - register int i; + volatile CARD32 *patternC = patternP; + int i; CARD32 magic = stuff->magic; rep.isLocal = 1; @@ -693,7 +683,7 @@ XvMCExtensionInit(void) extEntry = AddExtension(XvMCName, XvMCNumEvents, XvMCNumErrors, ProcXvMCDispatch, SProcXvMCDispatch, - XvMCResetProc, StandardMinorOpcode); + NULL, StandardMinorOpcode); if(!extEntry) return; @@ -720,7 +710,7 @@ XvMCScreenInit(ScreenPtr pScreen, int num, XvMCAdaptorPtr pAdapt) { XvMCScreenPtr pScreenPriv; - XvMCScreenKey = &XvMCScreenKey; + XvMCScreenKey = &XvMCScreenKeyIndex; if(!(pScreenPriv = (XvMCScreenPtr)xalloc(sizeof(XvMCScreenRec)))) return BadAlloc; |