diff options
| author | Mihai Moldovan <ionic@ionic.de> | 2017-12-15 12:55:17 +0100 |
|---|---|---|
| committer | Mihai Moldovan <ionic@ionic.de> | 2017-12-15 12:55:17 +0100 |
| commit | 1dad092caf01d733990648e6df64cbf964df5143 (patch) | |
| tree | 39de0e643e76754a3e23ca9dd0350b8ba4f76250 /nx-X11/programs/Xserver/dix | |
| parent | 6d70b9e3c47f27a166f4aacb522c5c1e49092dd9 (diff) | |
| parent | 2b9025f797ee322e21077e100c2ee27c2e7fa0e0 (diff) | |
| download | nx-libs-1dad092caf01d733990648e6df64cbf964df5143.tar.gz nx-libs-1dad092caf01d733990648e6df64cbf964df5143.tar.bz2 nx-libs-1dad092caf01d733990648e6df64cbf964df5143.zip | |
Merge branch '3.6.x'
Diffstat (limited to 'nx-X11/programs/Xserver/dix')
34 files changed, 4233 insertions, 7773 deletions
diff --git a/nx-X11/programs/Xserver/dix/BuiltInAtoms b/nx-X11/programs/Xserver/dix/BuiltInAtoms deleted file mode 100644 index 910c62706..000000000 --- a/nx-X11/programs/Xserver/dix/BuiltInAtoms +++ /dev/null @@ -1,329 +0,0 @@ -File: .../x11/server/dix/BuiltInAtoms - -This file is of a fixed format and is used to generate both the file -include/XAtom.h and dix/initatoms.c. Neither of those files should be -edited directly. Changing the atoms in this file, or even the order in -which they occur, is equivalent to forcing a new (minor) version number -on the server. Take care. - -The format of the file is that each built in atom starts in column 1 -with no text, other than spaces and tabs, on that line other than a -mandatory trailing "@" at the end of the line. For each atom (Foo) -below the defines will be of the form - #define XA_Foo <n> -and the string value of the atom will be "Foo". - -The comment lines in this file are not guaranteed to be accurate. To see the -current truth, look at the Xlib documentation as well as the protocol spec. - -Atoms occur in five distinct name spaces within the protocol. Any particular -atom may or may not have some client interpretation within each of the name -spaces. For each of the built in atoms, the intended semantics and the space -within which it is defined is indicated. - -Those name spaces are - Property names - Property types - Selections - Font properties - Type of a ClientMessage event (none built into server) - -For the font properties mentioned here, see the spec for more information. - - -- Selections -- - -PRIMARY @ - Selection. -SECONDARY @ - Selection. - - -- Property types and names -- - -ARC @ - Property type: - x, y: INT16 - width, height: CARD16, - angle1, angle2: INT16 -ATOM @ - Property type: - atom: ATOM -BITMAP @ - Property type: - bitmap: PIXMAP - This is asserted to be of depth 1. -CARDINAL @ - Property type: - card: CARD32 or CARD16 or CARD8 - the datum size is dependent on the property format -COLORMAP @ - Property type: - colormap: COLORMAP -CURSOR @ - Property type: - cursor: CURSOR -CUT_BUFFER0 @ -CUT_BUFFER1 @ -CUT_BUFFER2 @ -CUT_BUFFER3 @ -CUT_BUFFER4 @ -CUT_BUFFER5 @ -CUT_BUFFER6 @ -CUT_BUFFER7 @ - Property name: (type: STRING) - Used to implement cut buffer ring, in particular Andrew uses - this mechanism. Anyone else using this sort of IPC mechanism - should use these properties. - - Data is normally fetched and stored out of CUT_BUFFER0; the - RotateProperties request is used to rotate these buffers. -DRAWABLE @ - Property type: - drawable: DRAWABLE -FONT @ - Property type: - font: FONT -INTEGER @ - Property type: - card: INT32 or INT16 or INT8 - the datum size is dependent on the property format -PIXMAP @ - Property type: - pixmap: PIXMAP -POINT @ - Property type: - x, y: INT16 -RECTANGLE @ - Property type: - x, y: INT16 - width, height: CARD16 -RESOURCE_MANAGER @ - Property name: (type: STRING) - Contents of the user's resource manager data base. -RGB_COLOR_MAP @ - Property type: - colormap: COLORMAP - red-max: CARD32 - red-mult: CARD32 - green-max: CARD32 - green-mult: CARD32 - blue-max: CARD32 - blue-mult: CARD32 - base-pixel: CARD32 - - The fields `red_max', `green_max', and `blue_max' give the maximum - red, green, and blue values, respectively. Each color - coefficient ranges from 0 to its max, inclusive. For example, - a common colormap allocation is 3/3/2: 3 planes for red, 3 - planes for green, and 2 planes for blue. Such a colormap would - have red_max == 7, green_max = 7, and blue_max = 3. An alternate - allocation that uses only 216 colors is red_max = 5, green_max = - 5, and blue_max = 5. - - The fields `red_mult', `green_mult', and `blue_mult' give the - scale factors used to compose a full pixel value. (See next - paragraph.) For a 3/3/2 allocation red_mult might be 32, - green_mult might be 4, and blue_mult might be 1. For a - 6-colors-each allocation, red_mult might be 36, green_mult might - be 6, and blue_mult might be 1. - - The field `base_pixel' gives the base pixel value used to - compose a full pixel value. Normally base_pixel is obtained - from a call to XAllocColorPlanes(). Given integer red, green, - and blue coefficients in their appropriate ranges, one can - compute a corresponding pixel value with the expression: - - r * red_mult + g * green_mult + b * blue_mult + base_pixel - - For gray-scale colormaps, only the colormap, red_max, red_mult, - and base_pixel fields are defined; the other fields are - ignored. To compute a gray-scale pixel value, use: - - gray * red_mult + base_pixel - - This is provided to allow applications to share color maps. - -RGB_BEST_MAP @ -RGB_BLUE_MAP @ -RGB_DEFAULT_MAP @ -RGB_GRAY_MAP @ -RGB_GREEN_MAP @ -RGB_RED_MAP @ - Property name: (type: RGB_COLOR_MAP) - The needs of most applications can be met with five colormaps. - Polite applications may need only a small RGB space, and can - use a portion of the default color map. Applications doing - high-quality RGB rendering will need an entire colormap, - filled with as large an RGB space as possible, e.g. 332. For - color separations, an application may need maximum device - resolution for each of red, green, and blue, even if this - requires three renderings with three colormaps. - - Each of the above five names would be used for sharing color - maps. -STRING @ - Property type: - sequence of Bytes -VISUALID @ - Property type: - visual: VISUALID -WINDOW @ - Property type: - window: WINDOW -WM_COMMAND @ - Property name: (type: STRING) - Command line arguments used to invoke this application. The - arguments are delimited by null characters (ASCII 0). -WM_HINTS @ - Property type: - flags: CARD32 - input: BOOL32 - initial-state: CARD32 - icon-pixmap: PIXMAP - icon-window: WINDOW - icon_mask: BITMAP - icon-x, icon-y: INT32 - flags contains the following bits - 0x00000001 input hint - 0x00000002 state hint - 0x00000004 icon pixmap hint - 0x00000008 icon window hint - 0x00000010 icon position hint - values for initial-state - 0 unspecified -> application does not - care and WM should pick one. - 1 normal - 2 zoomed - 3 iconic - 4 inactive -> application believes - itself to be seldomly used. WM may wish to - place it on an inactive menu. - This type is potentially extensible. The order is critical; - append to the end only. - Property name: (type: WM_HINTS) - Additional hints set by the client for use by the window - manager. -WM_CLIENT_MACHINE @ - Property name: (type: STRING) - used to communicate with the window manager. The host name - of the machine the client is running on may be set here. -WM_ICON_NAME @ - Property name: (type: STRING) - what the application would like the label to be for - the iconic form of the window. -WM_ICON_SIZE @ - Property type: - minWidth, min-height: CARD32 - maxWidth, max-height: CARD32 - widthInc, height-inc: CARD32 - Property name: (type: ICON_SIZE) - The window manager may set this property on the root window - to specify the icon sizes it allows. -WM_NAME @ - Property name: (type: STRING) - used to communicate with the window manager. This is - what the application would like the label for the window. -WM_NORMAL_HINTS @ - Property name: (type: SIZE_HINTS) - used to communicate with the window manager. This is size - hints for a window in its "normal" state. -WM_SIZE_HINTS @ - Property type: - flags: CARD32 - x, y: INT32 - width, height: CARD32 - min-width, min-height: CARD32 - max-width, max-height: CARD32 - width-inc, height-inc: CARD32 - min-aspect-x, min-aspect-y: CARD32 - max-aspect-x, max-aspect-y: CARD32 - flags contains the following bits - 0x00000001 user specified x and y - 0x00000002 user specified width and height - 0x00000004 program specified position - 0x00000008 program specified size - 0x00000010 program specified minimum size - 0x00000020 program specified maximum size - 0x00000040 program specified resize increment - 0x00000080 program specified aspect ratio - This type is potentially extensible. The order is critical; - append to the end only. -WM_ZOOM_HINTS @ - Property name: (type: SIZE_HINTS) - used to communicate with the window manager. This is size - hints for a window in its "zoomed" state. - - -- Font properties -- - -MIN_SPACE @ - Font property: CARD32 -NORM_SPACE @ - Font property: CARD32 -MAX_SPACE @ - Font property: CARD32 -END_SPACE @ - Font property: CARD32 -SUPERSCRIPT_X @ - Font property: INT32 -SUPERSCRIPT_Y @ - Font property: INT32 -SUBSCRIPT_X @ - Font property: INT32 -SUBSCRIPT_Y @ - Font property: INT32 -UNDERLINE_POSITION @ - Font property: INT32 -UNDERLINE_THICKNESS @ - Font property: CARD32 -STRIKEOUT_ASCENT @ - Font property: INT32 -STRIKEOUT_DESCENT @ - Font property: INT32 -ITALIC_ANGLE @ - Font property: INT32 -X_HEIGHT @ - Font property: INT32 -QUAD_WIDTH @ - Font property: INT32 -WEIGHT @ - Font property: CARD32 -POINT_SIZE @ - Font property: CARD32 -RESOLUTION @ - Font property: CARD32 - -The following optional properties on fonts have values that are atoms. The -atom print name is the useful information. - -COPYRIGHT @ - of the font distribution -NOTICE @ - trademark/copyright of the character shapes -FONT_NAME @ - name of this particular instance of a font -FAMILY_NAME @ - name of the 'font family' to which it belongs -FULL_NAME @ - full text name of the font - -The following aren't in order but putting them at the end avoids encoding -changes. - -CAP_HEIGHT @ - Font property: CARD32 - - -WM_CLASS @ - Property name: (type: STRING) - Used (possibly by some window managers; definitely by - session managers) to look up resources in the resource - data base on behalf of the client who set this property. - There are 2 elements: - {char *resource_name; char *resource_class;} - delimited by a null character (ascii 0) - -WM_TRANSIENT_FOR @ - Property name: (type: WINDOW) - Used by transient top-level windows, such as dialog - boxes, to point to their logical "parents". The window - manager can then take down the dialog boxes when the - "parent" gets iconified, for instance. diff --git a/nx-X11/programs/Xserver/dix/CHANGES b/nx-X11/programs/Xserver/dix/CHANGES deleted file mode 100644 index d8fb7c31a..000000000 --- a/nx-X11/programs/Xserver/dix/CHANGES +++ /dev/null @@ -1,17 +0,0 @@ -The following changes have been made to this directory since R3 (for -a full description, see doc/Server/r4.tbl.ms): - - o Windows restructured (memory reduction, devPrivates and speedups) - o GCs restructured (memory reduction, devPrivates and wrappers) - o Screens restructured (window ops merged in, devPrivates) - o Pixmaps restructured (drawable changes mostly) - o Cursors restructured (shares glyph bits now) - o Visuals restructured (screen index removed, fields rearranged) - o Devices restructured (input extension changes) - o Out of memory changes. Many interfaces now return OutOfMemory - status. - o Synchronous grab code rewritten. Should conform to our - understanding of the protocol now. Be careful when time - stamping events (don't allow time to run backwards). - o Resource types redesigned and rewritten. - o Internal fake color allocation routine for software cursors. diff --git a/nx-X11/programs/Xserver/dix/Imakefile b/nx-X11/programs/Xserver/dix/Imakefile index 529e5623e..1024de965 100644 --- a/nx-X11/programs/Xserver/dix/Imakefile +++ b/nx-X11/programs/Xserver/dix/Imakefile @@ -1,33 +1,89 @@ -XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:48:16 cpqbld Exp $ - - - - -XCOMM $XFree86: xc/programs/Xserver/dix/Imakefile,v 3.17 2003/04/15 18:30:43 alanh Exp $ +NULL = #include <Server.tmpl> -#if !BuildXprint || PrintOnlyServer XPSRC = xpstubs.c XPOBJ = xpstubs.o -#endif #if !HasFfs FFS_SRC = ffs.c FFS_OBJ = ffs.o #endif -SRCS = atom.c colormap.c cursor.c devices.c dispatch.c dixutils.c events.c \ - extension.c gc.c globals.c glyphcurs.c grabs.c \ - main.c property.c resource.c swaprep.c swapreq.c \ - tables.c window.c initatoms.c dixfonts.c privates.c pixmap.c $(FFS_SRC) -OBJS = atom.o colormap.o cursor.o devices.o dispatch.o dixutils.o events.o \ - extension.o gc.o globals.o glyphcurs.o grabs.o \ - main.o property.o resource.o swaprep.o swapreq.o \ - tables.o window.o initatoms.o dixfonts.o privates.o pixmap.o $(FFS_OBJ) - - INCLUDES = -I../include -I$(XINCLUDESRC) -I$(FONTINCSRC) -I$(EXTINCSRC) \ - -I$(SERVERSRC)/Xext -I$(SERVERSRC)/lbx -I../Xprint +#if (!(defined(NXAgentServer) && NXAgentServer)) +NXAGENT_SKIP_SRCS = \ + dispatch.c \ + dixfonts.c \ + events.c \ + extension.c \ + glyphcurs.c \ + property.c \ + resource.c \ + window.c \ + $(NULL) +NXAGENT_SKIP_OBJS = \ + dispatch.o \ + dixfonts.o \ + events.o \ + extension.o \ + glyphcurs.o \ + property.o \ + resource.o \ + window.o \ + $(NULL) +#endif + + +SRCS = \ + atom.c \ + colormap.c \ + cursor.c \ + devices.c \ + dixutils.c \ + gc.c \ + globals.c \ + grabs.c \ + main.c \ + region.c \ + swaprep.c \ + swapreq.c \ + tables.c \ + initatoms.c \ + privates.c \ + pixmap.c \ + $(NXAGENT_SKIP_SRCS) \ + $(FFS_SRC) \ + $(NULL) + +OBJS = \ + atom.o \ + colormap.o \ + cursor.o \ + devices.o \ + dixutils.o \ + gc.o \ + globals.o \ + grabs.o \ + main.o \ + region.o \ + swaprep.o \ + swapreq.o \ + tables.o \ + initatoms.o \ + privates.o \ + pixmap.o \ + $(NXAGENT_SKIP_OBJS) \ + $(FFS_OBJ) \ + $(NULL) + + INCLUDES = -I../include \ + -I$(XINCLUDESRC) \ + -I$(EXTINCSRC) \ + -I$(SERVERSRC)/Xext \ + -I$(SERVERSRC)/lbx \ + `pkg-config --cflags-only-I pixman-1` \ + $(NULL) + LINTLIBS = ../os/llib-los.ln /* @@ -35,7 +91,6 @@ OBJS = atom.o colormap.o cursor.o devices.o dispatch.o dixutils.o events.o \ * .macros files or site.def in the directory util/imake.includes/: * * DefaultFontPath COMPILEDDEFAULTFONTPATH - * DefaultRGBDatabase RGB_DB * * The sample util/imake.includes/Imake.tmpl will provide generic defaults. * The values in site.h are simply a last line of defense and should not be @@ -47,11 +102,6 @@ DEFAULTFONTPATH = DefaultFontPath SITE_FONT_PATH = -DCOMPILEDDEFAULTFONTPATH=\"$(DEFAULTFONTPATH)\" #endif -#ifdef DefaultRGBDatabase -DEFAULTRGBDATABASE = DefaultRGBDatabase - SITE_RGB_DB = -DRGB_DB=\"$(DEFAULTRGBDATABASE)\" -#endif - #ifdef DefaultDisplayClass DEFAULTDISPLAYCLASS = DefaultDisplayClass SITE_DISPLAY_CLASS = -DCOMPILEDDISPLAYCLASS=\"$(DEFAULTDISPLAYCLASS)\" @@ -67,17 +117,13 @@ VENDORRELEASE = XVendorRelease VENDOR_RELEASE = -DVENDOR_RELEASE="$(VENDORRELEASE)" #endif -#if HasKrb5 - K5DEFS = Krb5Defines -#endif - #ifdef DarwinArchitecture #if DarwinQuartzSupport QUARTZ_DEFINES = -DDARWIN_WITH_QUARTZ #endif #endif -SITE_DEFINES = $(SITE_FONT_PATH) $(SITE_RGB_DB) $(SITE_DISPLAY_CLASS) +SITE_DEFINES = $(SITE_FONT_PATH) $(SITE_DISPLAY_CLASS) VENDOR_DEFINES = $(VENDOR_STRING) $(VENDOR_RELEASE) $(QUARTZ_DEFINES) @@ -87,15 +133,11 @@ LintLibraryTarget(dix,$(SRCS) $(XPSRC)) NormalLintTarget($(SRCS) $(XPSRC)) SpecialCObjectRule(globals,$(ICONFIGFILES),$(SITE_DEFINES)) -SpecialCObjectRule(tables,$(ICONFIGFILES),$(K5DEFS)) -SpecialCObjectRule(dispatch,$(ICONFIGFILES),$(K5DEFS)) SpecialCObjectRule(main,$(ICONFIGFILES),$(VENDOR_DEFINES)) SpecialCObjectRule(pixmap,$(ICONFIGFILES),$(_NOOP_)) SpecialCObjectRule(privates,$(ICONFIGFILES),$(_NOOP_)) SpecialCObjectRule(window,$(ICONFIGFILES),$(QUARTZ_DEFINES)) -#if !BuildXprint || PrintOnlyServer NormalLibraryTarget(xpstubs,$(XPOBJ)) -#endif DependTarget() diff --git a/nx-X11/programs/Xserver/dix/atom.c b/nx-X11/programs/Xserver/dix/atom.c index 207174280..d569c2314 100644 --- a/nx-X11/programs/Xserver/dix/atom.c +++ b/nx-X11/programs/Xserver/dix/atom.c @@ -1,4 +1,3 @@ -/* $XFree86: xc/programs/Xserver/dix/atom.c,v 3.3 2001/12/14 19:59:29 dawes Exp $ */ /*********************************************************** Copyright 1987, 1998 The Open Group @@ -46,14 +45,13 @@ SOFTWARE. ******************************************************************/ -/* $Xorg: atom.c,v 1.4 2001/02/09 02:04:39 xorgcvs Exp $ */ #ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> #endif -#include <X11/X.h> -#include <X11/Xatom.h> +#include <nx-X11/X.h> +#include <nx-X11/Xatom.h> #include "misc.h" #include "resource.h" #include "dix.h" @@ -64,7 +62,7 @@ typedef struct _Node { struct _Node *left, *right; Atom a; unsigned int fingerPrint; - char *string; + const char *string; } NodeRec, *NodePtr; static Atom lastAtom = None; @@ -75,7 +73,7 @@ static NodePtr *nodeTable; void FreeAtom(NodePtr patom); Atom -MakeAtom(char *string, unsigned len, Bool makeit) +MakeAtom(const char *string, unsigned len, Bool makeit) { register NodePtr * np; unsigned i; @@ -109,7 +107,7 @@ MakeAtom(char *string, unsigned len, Bool makeit) { register NodePtr nd; - nd = (NodePtr) xalloc(sizeof(NodeRec)); + nd = (NodePtr) malloc(sizeof(NodeRec)); if (!nd) return BAD_RESOURCE; if (lastAtom < XA_LAST_PREDEFINED) @@ -118,23 +116,22 @@ MakeAtom(char *string, unsigned len, Bool makeit) } else { - nd->string = (char *) xalloc(len + 1); + nd->string = strndup(string, len); if (!nd->string) { - xfree(nd); + free(nd); return BAD_RESOURCE; } - strncpy(nd->string, string, (int)len); - nd->string[len] = 0; } if ((lastAtom + 1) >= tableLength) { NodePtr *table; - table = (NodePtr *) xrealloc(nodeTable, + table = (NodePtr *) realloc(nodeTable, tableLength * (2 * sizeof(NodePtr))); if (!table) { if (nd->string != string) - xfree(nd->string); - xfree(nd); + /* nd->string has been strdup'ed */ + free((char *)nd->string); + free(nd); return BAD_RESOURCE; } tableLength <<= 1; @@ -157,7 +154,7 @@ ValidAtom(Atom atom) return (atom != None) && (atom <= lastAtom); } -char * +const char * NameForAtom(Atom atom) { NodePtr node; @@ -180,8 +177,8 @@ FreeAtom(NodePtr patom) if(patom->right) FreeAtom(patom->right); if (patom->a > XA_LAST_PREDEFINED) - xfree(patom->string); - xfree(patom); + free((char *)patom->string); + free(patom); } void @@ -191,7 +188,7 @@ FreeAllAtoms() return; FreeAtom(atomRoot); atomRoot = (NodePtr)NULL; - xfree(nodeTable); + free(nodeTable); nodeTable = (NodePtr *)NULL; lastAtom = None; } @@ -201,7 +198,7 @@ InitAtoms() { FreeAllAtoms(); tableLength = InitialTableSize; - nodeTable = (NodePtr *)xalloc(InitialTableSize*sizeof(NodePtr)); + nodeTable = (NodePtr *)malloc(InitialTableSize*sizeof(NodePtr)); if (!nodeTable) AtomError(); nodeTable[None] = (NodePtr)NULL; diff --git a/nx-X11/programs/Xserver/dix/colormap.c b/nx-X11/programs/Xserver/dix/colormap.c index 210bc2731..7fcde71f3 100644 --- a/nx-X11/programs/Xserver/dix/colormap.c +++ b/nx-X11/programs/Xserver/dix/colormap.c @@ -1,5 +1,3 @@ -/* $XdotOrg: xc/programs/Xserver/dix/colormap.c,v 1.11 2005/09/05 07:40:50 daniels Exp $ */ -/* $XFree86: xc/programs/Xserver/dix/colormap.c,v 3.11 2003/11/03 05:10:59 tsi Exp $ */ /*********************************************************** Copyright 1987, 1998 The Open Group @@ -47,15 +45,13 @@ SOFTWARE. ******************************************************************/ -/* $Xorg: colormap.c,v 1.4 2001/02/09 02:04:39 xorgcvs Exp $ */ #ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> #endif -#include <X11/X.h> -#define NEED_EVENTS -#include <X11/Xproto.h> +#include <nx-X11/X.h> +#include <nx-X11/Xproto.h> #include "misc.h" #include "dix.h" #include "colormapst.h" @@ -63,9 +59,6 @@ SOFTWARE. #include "scrnintstr.h" #include "resource.h" #include "windowstr.h" -#ifdef LBX -#include "lbxserve.h" -#endif extern XID clientErrorValue; extern int colormapPrivateCount; @@ -277,7 +270,7 @@ CreateColormap (Colormap mid, ScreenPtr pScreen, VisualPtr pVisual, if ((class | DynamicClass) == DirectColor) sizebytes *= 3; sizebytes += sizeof(ColormapRec); - pmap = (ColormapPtr) xalloc(sizebytes); + pmap = (ColormapPtr) malloc(sizebytes); if (!pmap) return (BadAlloc); pmap->red = (EntryPtr)((char *)pmap + sizeof(ColormapRec)); @@ -306,10 +299,10 @@ CreateColormap (Colormap mid, ScreenPtr pScreen, VisualPtr pVisual, for (pent = &pmap->red[size - 1]; pent >= pmap->red; pent--) pent->refcnt = AllocPrivate; pmap->freeRed = 0; - ppix = (Pixel *)xalloc(size * sizeof(Pixel)); + ppix = (Pixel *)malloc(size * sizeof(Pixel)); if (!ppix) { - xfree(pmap); + free(pmap); return (BadAlloc); } pmap->clientPixelsRed[client] = ppix; @@ -352,11 +345,11 @@ CreateColormap (Colormap mid, ScreenPtr pScreen, VisualPtr pVisual, for(pent = &pmap->green[size-1]; pent >= pmap->green; pent--) pent->refcnt = AllocPrivate; pmap->freeGreen = 0; - ppix = (Pixel *) xalloc(size * sizeof(Pixel)); + ppix = (Pixel *) malloc(size * sizeof(Pixel)); if (!ppix) { - xfree(pmap->clientPixelsRed[client]); - xfree(pmap); + free(pmap->clientPixelsRed[client]); + free(pmap); return(BadAlloc); } pmap->clientPixelsGreen[client] = ppix; @@ -368,12 +361,12 @@ CreateColormap (Colormap mid, ScreenPtr pScreen, VisualPtr pVisual, for(pent = &pmap->blue[size-1]; pent >= pmap->blue; pent--) pent->refcnt = AllocPrivate; pmap->freeBlue = 0; - ppix = (Pixel *) xalloc(size * sizeof(Pixel)); + ppix = (Pixel *) malloc(size * sizeof(Pixel)); if (!ppix) { - xfree(pmap->clientPixelsGreen[client]); - xfree(pmap->clientPixelsRed[client]); - xfree(pmap); + free(pmap->clientPixelsGreen[client]); + free(pmap->clientPixelsRed[client]); + free(pmap); return(BadAlloc); } pmap->clientPixelsBlue[client] = ppix; @@ -382,7 +375,7 @@ CreateColormap (Colormap mid, ScreenPtr pScreen, VisualPtr pVisual, pmap->numPixelsBlue[client] = size; } } - if (!AddResource(mid, RT_COLORMAP, (pointer)pmap)) + if (!AddResource(mid, RT_COLORMAP, (void *)pmap)) return (BadAlloc); /* If the device wants a chance to initialize the colormap in any way, * this is it. In specific, if this is a Static colormap, this is the @@ -398,7 +391,7 @@ CreateColormap (Colormap mid, ScreenPtr pScreen, VisualPtr pVisual, pmap->devPrivates = NULL; else { - pmap->devPrivates = (DevUnion *) xcalloc ( + pmap->devPrivates = (DevUnion *) calloc ( sizeof(DevUnion), colormapPrivateCount); if (!pmap->devPrivates) { @@ -422,7 +415,7 @@ CreateColormap (Colormap mid, ScreenPtr pScreen, VisualPtr pVisual, * \param value must conform to DeleteType */ int -FreeColormap (pointer value, XID mid) +FreeColormap (void * value, XID mid) { int i; register EntryPtr pent; @@ -431,7 +424,7 @@ FreeColormap (pointer value, XID mid) if(CLIENT_ID(mid) != SERVER_ID) { (*pmap->pScreen->UninstallColormap) (pmap); - WalkTree(pmap->pScreen, (VisitWindowProcPtr)TellNoMap, (pointer) &mid); + WalkTree(pmap->pScreen, (VisitWindowProcPtr)TellNoMap, (void *) &mid); } /* This is the device's chance to undo anything it needs to, especially @@ -441,7 +434,7 @@ FreeColormap (pointer value, XID mid) if(pmap->clientPixelsRed) { for(i = 0; i < MAXCLIENTS; i++) - xfree(pmap->clientPixelsRed[i]); + free(pmap->clientPixelsRed[i]); } if ((pmap->class == PseudoColor) || (pmap->class == GrayScale)) @@ -453,11 +446,11 @@ FreeColormap (pointer value, XID mid) if(pent->fShared) { if (--pent->co.shco.red->refcnt == 0) - xfree(pent->co.shco.red); + free(pent->co.shco.red); if (--pent->co.shco.green->refcnt == 0) - xfree(pent->co.shco.green); + free(pent->co.shco.green); if (--pent->co.shco.blue->refcnt == 0) - xfree(pent->co.shco.blue); + free(pent->co.shco.blue); } } } @@ -465,15 +458,15 @@ FreeColormap (pointer value, XID mid) { for(i = 0; i < MAXCLIENTS; i++) { - xfree(pmap->clientPixelsGreen[i]); - xfree(pmap->clientPixelsBlue[i]); + free(pmap->clientPixelsGreen[i]); + free(pmap->clientPixelsBlue[i]); } } if (pmap->devPrivates) - xfree(pmap->devPrivates); + free(pmap->devPrivates); - xfree(pmap); + free(pmap); return(Success); } @@ -506,7 +499,7 @@ TellNoMap (WindowPtr pwin, Colormap *pmid) /* Tell window that pmid got uninstalled */ int -TellLostMap (WindowPtr pwin, pointer value) +TellLostMap (WindowPtr pwin, void * value) { Colormap *pmid = (Colormap *)value; xEvent xE; @@ -531,7 +524,7 @@ TellLostMap (WindowPtr pwin, pointer value) /* Tell window that pmid got installed */ int -TellGainedMap (WindowPtr pwin, pointer value) +TellGainedMap (WindowPtr pwin, void * value) { Colormap *pmid = (Colormap *)value; xEvent xE; @@ -724,11 +717,11 @@ FreeCell (ColormapPtr pmap, Pixel i, int channel) if (pent->fShared) { if(--pent->co.shco.red->refcnt == 0) - xfree(pent->co.shco.red); + free(pent->co.shco.red); if(--pent->co.shco.green->refcnt == 0) - xfree(pent->co.shco.green); + free(pent->co.shco.green); if(--pent->co.shco.blue->refcnt == 0) - xfree(pent->co.shco.blue); + free(pent->co.shco.blue); pent->fShared = FALSE; } pent->refcnt = 0; @@ -747,7 +740,7 @@ UpdateColors (ColormapPtr pmap) pVisual = pmap->pVisual; size = pVisual->ColormapEntries; - defs = (xColorItem *)ALLOCATE_LOCAL(size * sizeof(xColorItem)); + defs = (xColorItem *)malloc(size * sizeof(xColorItem)); if (!defs) return; n = 0; @@ -797,7 +790,7 @@ UpdateColors (ColormapPtr pmap) } if (n) (*pmap->pScreen->StoreColors)(pmap, n, defs); - DEALLOCATE_LOCAL(defs); + free(defs); } /* Get a read-only color from a ColorMap (probably slow for large maps) @@ -844,7 +837,7 @@ AllocColor (ColormapPtr pmap, *pgreen = pmap->red[pixR].co.local.green; *pblue = pmap->red[pixR].co.local.blue; npix = pmap->numPixelsRed[client]; - ppix = (Pixel *) xrealloc(pmap->clientPixelsRed[client], + ppix = (Pixel *) realloc(pmap->clientPixelsRed[client], (npix + 1) * sizeof(Pixel)); if (!ppix) return (BadAlloc); @@ -867,21 +860,21 @@ AllocColor (ColormapPtr pmap, *pgreen = pmap->green[pixG].co.local.green; *pblue = pmap->blue[pixB].co.local.blue; npix = pmap->numPixelsRed[client]; - ppix = (Pixel *) xrealloc(pmap->clientPixelsRed[client], + ppix = (Pixel *) realloc(pmap->clientPixelsRed[client], (npix + 1) * sizeof(Pixel)); if (!ppix) return (BadAlloc); ppix[npix] = pixR; pmap->clientPixelsRed[client] = ppix; npix = pmap->numPixelsGreen[client]; - ppix = (Pixel *) xrealloc(pmap->clientPixelsGreen[client], + ppix = (Pixel *) realloc(pmap->clientPixelsGreen[client], (npix + 1) * sizeof(Pixel)); if (!ppix) return (BadAlloc); ppix[npix] = pixG; pmap->clientPixelsGreen[client] = ppix; npix = pmap->numPixelsBlue[client]; - ppix = (Pixel *) xrealloc(pmap->clientPixelsBlue[client], + ppix = (Pixel *) realloc(pmap->clientPixelsBlue[client], (npix + 1) * sizeof(Pixel)); if (!ppix) return (BadAlloc); @@ -899,7 +892,7 @@ AllocColor (ColormapPtr pmap, { ColormapPtr prootmap = (ColormapPtr) SecurityLookupIDByType (clients[client], pmap->pScreen->defColormap, - RT_COLORMAP, SecurityReadAccess); + RT_COLORMAP, DixReadAccess); if (pmap->class == prootmap->class) FindColorInRootCmap (prootmap, prootmap->red, entries, &rgb, @@ -916,7 +909,7 @@ AllocColor (ColormapPtr pmap, { ColormapPtr prootmap = (ColormapPtr) SecurityLookupIDByType (clients[client], pmap->pScreen->defColormap, - RT_COLORMAP, SecurityReadAccess); + RT_COLORMAP, DixReadAccess); if (pmap->class == prootmap->class) { @@ -966,7 +959,7 @@ AllocColor (ColormapPtr pmap, { colorResource *pcr; - pcr = (colorResource *) xalloc(sizeof(colorResource)); + pcr = (colorResource *) malloc(sizeof(colorResource)); if (!pcr) { (void)FreeColors(pmap, client, 1, pPix, (Pixel)0); @@ -974,7 +967,7 @@ AllocColor (ColormapPtr pmap, } pcr->mid = pmap->mid; pcr->client = client; - if (!AddResource(FakeClientID(client), RT_CMAPENTRY, (pointer)pcr)) + if (!AddResource(FakeClientID(client), RT_CMAPENTRY, (void *)pcr)) return (BadAlloc); } return (Success); @@ -1351,7 +1344,7 @@ gotit: break; } npix = nump[client]; - ppix = (Pixel *) xrealloc (pixp[client], (npix + 1) * sizeof(Pixel)); + ppix = (Pixel *) realloc (pixp[client], (npix + 1) * sizeof(Pixel)); if (!ppix) { pent->refcnt--; @@ -1508,68 +1501,20 @@ FreePixels(register ColormapPtr pmap, register int client) register Pixel *ppix, *ppixStart; register int n; int class; -#ifdef LBX - Bool grabbed; - Bool zeroRefCount; - Bool anyRefCountReachedZero = 0; -#endif class = pmap->class; ppixStart = pmap->clientPixelsRed[client]; if (class & DynamicClass) { n = pmap->numPixelsRed[client]; -#ifdef LBX - grabbed = LbxCheckCmapGrabbed (pmap); - if (grabbed) - { - /* - * If the colormap is grabbed by a proxy, the server must - * notify the proxy of all cells that are freed (the refcount - * has reached zero on these cells). - */ - - LbxBeginFreeCellsEvent (pmap); - LbxSortPixelList (ppixStart, n); - } -#endif for (ppix = ppixStart; --n >= 0; ) { FreeCell(pmap, *ppix, REDMAP); -#ifdef LBX - /* - * Only PSEUDO colormaps are grabbed by LBX proxies. - * Check if the ref count reached zero on this pixel. - */ - - zeroRefCount = pmap->red[*ppix].refcnt == 0; - if (zeroRefCount) - anyRefCountReachedZero = 1; - - if (grabbed && zeroRefCount) - LbxAddFreeCellToEvent (pmap, *ppix); -#endif ppix++; } -#ifdef LBX - if (grabbed) - LbxEndFreeCellsEvent (pmap); - else if (anyRefCountReachedZero) - { - /* - * We only send LbxFreeCell events to a proxy that has the colormap - * grabbed. If the colormap is not grabbed, the proxy that last - * had the colormap grabbed will not be able to do a smart grab - * in the future. A smart grab can only occur if the proxy is kept - * up to date on every alloc/free change in the colormap. - */ - - LbxDisableSmartGrab (pmap); - } -#endif } - xfree(ppixStart); + free(ppixStart); pmap->clientPixelsRed[client] = (Pixel *) NULL; pmap->numPixelsRed[client] = 0; if ((class | DynamicClass) == DirectColor) @@ -1578,7 +1523,7 @@ FreePixels(register ColormapPtr pmap, register int client) if (class & DynamicClass) for (ppix = ppixStart, n = pmap->numPixelsGreen[client]; --n >= 0;) FreeCell(pmap, *ppix++, GREENMAP); - xfree(ppixStart); + free(ppixStart); pmap->clientPixelsGreen[client] = (Pixel *) NULL; pmap->numPixelsGreen[client] = 0; @@ -1586,7 +1531,7 @@ FreePixels(register ColormapPtr pmap, register int client) if (class & DynamicClass) for (ppix = ppixStart, n = pmap->numPixelsBlue[client]; --n >= 0; ) FreeCell(pmap, *ppix++, BLUEMAP); - xfree(ppixStart); + free(ppixStart); pmap->clientPixelsBlue[client] = (Pixel *) NULL; pmap->numPixelsBlue[client] = 0; } @@ -1599,7 +1544,7 @@ FreePixels(register ColormapPtr pmap, register int client) * \unused fakeid */ int -FreeClientPixels (pointer value, XID fakeid) +FreeClientPixels (void * value, XID fakeid) { ColormapPtr pmap; colorResource *pcr = (colorResource *)value; @@ -1607,7 +1552,7 @@ FreeClientPixels (pointer value, XID fakeid) pmap = (ColormapPtr) LookupIDByType(pcr->mid, RT_COLORMAP); if (pmap) FreePixels(pmap, pcr->client); - xfree(pcr); + free(pcr); return Success; } @@ -1629,7 +1574,7 @@ AllocColorCells (int client, ColormapPtr pmap, int colors, int planes, oldcount += pmap->numPixelsGreen[client] + pmap->numPixelsBlue[client]; if (!oldcount && (CLIENT_ID(pmap->mid) != client)) { - pcr = (colorResource *) xalloc(sizeof(colorResource)); + pcr = (colorResource *) malloc(sizeof(colorResource)); if (!pcr) return (BadAlloc); } @@ -1674,10 +1619,10 @@ AllocColorCells (int client, ColormapPtr pmap, int colors, int planes, { pcr->mid = pmap->mid; pcr->client = client; - if (!AddResource(FakeClientID(client), RT_CMAPENTRY, (pointer)pcr)) + if (!AddResource(FakeClientID(client), RT_CMAPENTRY, (void *)pcr)) ok = BadAlloc; } else if (pcr) - xfree(pcr); + free(pcr); return (ok); } @@ -1704,7 +1649,7 @@ AllocColorPlanes (int client, ColormapPtr pmap, int colors, oldcount += pmap->numPixelsGreen[client] + pmap->numPixelsBlue[client]; if (!oldcount && (CLIENT_ID(pmap->mid) != client)) { - pcr = (colorResource *) xalloc(sizeof(colorResource)); + pcr = (colorResource *) malloc(sizeof(colorResource)); if (!pcr) return (BadAlloc); } @@ -1765,10 +1710,10 @@ AllocColorPlanes (int client, ColormapPtr pmap, int colors, { pcr->mid = pmap->mid; pcr->client = client; - if (!AddResource(FakeClientID(client), RT_CMAPENTRY, (pointer)pcr)) + if (!AddResource(FakeClientID(client), RT_CMAPENTRY, (void *)pcr)) ok = BadAlloc; } else if (pcr) - xfree(pcr); + free(pcr); return (ok); } @@ -1796,14 +1741,14 @@ AllocDirect (int client, ColormapPtr pmap, int c, int r, int g, int b, Bool cont for(p = pixels; p < pixels + c; p++) *p = 0; - ppixRed = (Pixel *)ALLOCATE_LOCAL(npixR * sizeof(Pixel)); - ppixGreen = (Pixel *)ALLOCATE_LOCAL(npixG * sizeof(Pixel)); - ppixBlue = (Pixel *)ALLOCATE_LOCAL(npixB * sizeof(Pixel)); + ppixRed = (Pixel *)malloc(npixR * sizeof(Pixel)); + ppixGreen = (Pixel *)malloc(npixG * sizeof(Pixel)); + ppixBlue = (Pixel *)malloc(npixB * sizeof(Pixel)); if (!ppixRed || !ppixGreen || !ppixBlue) { - if (ppixBlue) DEALLOCATE_LOCAL(ppixBlue); - if (ppixGreen) DEALLOCATE_LOCAL(ppixGreen); - if (ppixRed) DEALLOCATE_LOCAL(ppixRed); + if (ppixBlue) free(ppixBlue); + if (ppixGreen) free(ppixGreen); + if (ppixRed) free(ppixRed); return(BadAlloc); } @@ -1813,17 +1758,17 @@ AllocDirect (int client, ColormapPtr pmap, int c, int r, int g, int b, Bool cont if (okR && okG && okB) { - rpix = (Pixel *) xrealloc(pmap->clientPixelsRed[client], + rpix = (Pixel *) realloc(pmap->clientPixelsRed[client], (pmap->numPixelsRed[client] + (c << r)) * sizeof(Pixel)); if (rpix) pmap->clientPixelsRed[client] = rpix; - gpix = (Pixel *) xrealloc(pmap->clientPixelsGreen[client], + gpix = (Pixel *) realloc(pmap->clientPixelsGreen[client], (pmap->numPixelsGreen[client] + (c << g)) * sizeof(Pixel)); if (gpix) pmap->clientPixelsGreen[client] = gpix; - bpix = (Pixel *) xrealloc(pmap->clientPixelsBlue[client], + bpix = (Pixel *) realloc(pmap->clientPixelsBlue[client], (pmap->numPixelsBlue[client] + (c << b)) * sizeof(Pixel)); if (bpix) @@ -1841,9 +1786,9 @@ AllocDirect (int client, ColormapPtr pmap, int c, int r, int g, int b, Bool cont if (okB) for(ppix = ppixBlue, npix = npixB; --npix >= 0; ppix++) pmap->blue[*ppix].refcnt = 0; - DEALLOCATE_LOCAL(ppixBlue); - DEALLOCATE_LOCAL(ppixGreen); - DEALLOCATE_LOCAL(ppixRed); + free(ppixBlue); + free(ppixGreen); + free(ppixRed); return(BadAlloc); } @@ -1885,9 +1830,9 @@ AllocDirect (int client, ColormapPtr pmap, int c, int r, int g, int b, Bool cont for (pDst = pixels; pDst < pixels + c; pDst++) *pDst |= ALPHAMASK(pmap->pVisual); - DEALLOCATE_LOCAL(ppixBlue); - DEALLOCATE_LOCAL(ppixGreen); - DEALLOCATE_LOCAL(ppixRed); + free(ppixBlue); + free(ppixGreen); + free(ppixRed); return (Success); } @@ -1903,7 +1848,7 @@ AllocPseudo (int client, ColormapPtr pmap, int c, int r, Bool contig, npix = c << r; if ((r >= 32) || (npix > pmap->freeRed) || (npix < c)) return(BadAlloc); - if(!(ppixTemp = (Pixel *)ALLOCATE_LOCAL(npix * sizeof(Pixel)))) + if(!(ppixTemp = (Pixel *)malloc(npix * sizeof(Pixel)))) return(BadAlloc); ok = AllocCP(pmap, pmap->red, c, r, contig, ppixTemp, pmask); @@ -1912,7 +1857,7 @@ AllocPseudo (int client, ColormapPtr pmap, int c, int r, Bool contig, /* all the allocated pixels are added to the client pixel list, * but only the unique ones are returned to the client */ - ppix = (Pixel *)xrealloc(pmap->clientPixelsRed[client], + ppix = (Pixel *)realloc(pmap->clientPixelsRed[client], (pmap->numPixelsRed[client] + npix) * sizeof(Pixel)); if (!ppix) { @@ -1933,7 +1878,7 @@ AllocPseudo (int client, ColormapPtr pmap, int c, int r, Bool contig, pmap->numPixelsRed[client] += npix; pmap->freeRed -= npix; } - DEALLOCATE_LOCAL(ppixTemp); + free(ppixTemp); return (ok ? Success : BadAlloc); } @@ -2133,17 +2078,17 @@ AllocShared (ColormapPtr pmap, Pixel *ppix, int c, int r, int g, int b, npixClientNew = c << (r + g + b); npixShared = (c << r) + (c << g) + (c << b); - psharedList = (SHAREDCOLOR **)ALLOCATE_LOCAL(npixShared * + psharedList = (SHAREDCOLOR **)malloc(npixShared * sizeof(SHAREDCOLOR *)); if (!psharedList) return FALSE; ppshared = psharedList; for (z = npixShared; --z >= 0; ) { - if (!(ppshared[z] = (SHAREDCOLOR *)xalloc(sizeof(SHAREDCOLOR)))) + if (!(ppshared[z] = (SHAREDCOLOR *)malloc(sizeof(SHAREDCOLOR)))) { for (z++ ; z < npixShared; z++) - xfree(ppshared[z]); + free(ppshared[z]); return FALSE; } } @@ -2248,7 +2193,7 @@ AllocShared (ColormapPtr pmap, Pixel *ppix, int c, int r, int g, int b, } } } - DEALLOCATE_LOCAL(psharedList); + free(psharedList); return TRUE; } @@ -2316,11 +2261,6 @@ FreeCo (ColormapPtr pmap, int client, int color, int npixIn, Pixel *ppixIn, Pixe int n, zapped; int errVal = Success; int offset, numents; -#ifdef LBX - Bool grabbed; - Bool zeroRefCount; - Bool anyRefCountReachedZero = 0; -#endif if (npixIn == 0) return (errVal); @@ -2365,22 +2305,6 @@ FreeCo (ColormapPtr pmap, int client, int color, int npixIn, Pixel *ppixIn, Pixe break; } -#ifdef LBX - grabbed = LbxCheckCmapGrabbed (pmap); - - if (grabbed) - { - /* - * If the colormap is grabbed by a proxy, the server must - * notify the proxy of all cells that are freed (the refcount - * has reached zero on these cells). - */ - - LbxBeginFreeCellsEvent (pmap); - LbxSortPixelList (ppixIn, npixIn); - } -#endif - /* zap all pixels which match */ while (1) { @@ -2405,19 +2329,6 @@ FreeCo (ColormapPtr pmap, int client, int color, int npixIn, Pixel *ppixIn, Pixe if (pmap->class & DynamicClass) { FreeCell(pmap, pixTest, color); -#ifdef LBX - /* - * Only PSEUDO colormaps are grabbed by LBX proxies. - * Check if the ref count reached zero on this pixel. - */ - - zeroRefCount = pmap->red[pixTest].refcnt == 0; - if (zeroRefCount) - anyRefCountReachedZero = 1; - - if (grabbed && zeroRefCount) - LbxAddFreeCellToEvent (pmap, pixTest); -#endif } *cptr = ~((Pixel)0); zapped++; @@ -2429,23 +2340,6 @@ FreeCo (ColormapPtr pmap, int client, int color, int npixIn, Pixel *ppixIn, Pixe GetNextBitsOrBreak(bits, mask, base); } -#ifdef LBX - if (grabbed) - LbxEndFreeCellsEvent (pmap); - else if (anyRefCountReachedZero) - { - /* - * We only send LbxFreeCell events to a proxy that has the colormap - * grabbed. If the colormap is not grabbed, the proxy that last - * had the colormap grabbed will not be able to do a smart grab - * in the future. A smart grab can only occur if the proxy is kept - * up to date on every alloc/free change in the colormap. - */ - - LbxDisableSmartGrab (pmap); - } -#endif - /* delete freed pixels from client pixel list */ if (zapped) { @@ -2466,7 +2360,7 @@ FreeCo (ColormapPtr pmap, int client, int color, int npixIn, Pixel *ppixIn, Pixe npix++; } } - pptr = (Pixel *)xrealloc(ppixClient, npixNew * sizeof(Pixel)); + pptr = (Pixel *)realloc(ppixClient, npixNew * sizeof(Pixel)); if (pptr) ppixClient = pptr; npixClient = npixNew; @@ -2474,7 +2368,7 @@ FreeCo (ColormapPtr pmap, int client, int color, int npixIn, Pixel *ppixIn, Pixe else { npixClient = 0; - xfree(ppixClient); + free(ppixClient); ppixClient = (Pixel *)NULL; } switch(color) @@ -2773,7 +2667,7 @@ IsMapInstalled(Colormap map, WindowPtr pWin) Colormap *pmaps; int imap, nummaps, found; - pmaps = (Colormap *) ALLOCATE_LOCAL( + pmaps = (Colormap *) malloc( pWin->drawable.pScreen->maxInstalledCmaps * sizeof(Colormap)); if(!pmaps) return(FALSE); @@ -2788,6 +2682,74 @@ IsMapInstalled(Colormap map, WindowPtr pWin) break; } } - DEALLOCATE_LOCAL(pmaps); + free(pmaps); return (found); } + +struct colormap_lookup_data { + ScreenPtr pScreen; + VisualPtr visuals; +}; + +static void +_colormap_find_resource(void *value, XID id, void *cdata) +{ + struct colormap_lookup_data *cmap_data = cdata; + VisualPtr visuals = cmap_data->visuals; + ScreenPtr pScreen = cmap_data->pScreen; + ColormapPtr cmap = value; + int j; + + if (pScreen != cmap->pScreen) + return; + + j = cmap->pVisual - pScreen->visuals; + cmap->pVisual = &visuals[j]; +} + +/* something has realloced the visuals, instead of breaking + ABI fix it up here - glx and compsite did this wrong */ +Bool +ResizeVisualArray(ScreenPtr pScreen, int new_visual_count, DepthPtr depth) +{ + struct colormap_lookup_data cdata; + int numVisuals; + VisualPtr visuals; + XID *vids, vid; + int first_new_vid, first_new_visual, i; + + first_new_vid = depth->numVids; + first_new_visual = pScreen->numVisuals; + + vids = reallocarray(depth->vids, depth->numVids + new_visual_count, + sizeof(XID)); + if (!vids) + return FALSE; + + /* its realloced now no going back if we fail the next one */ + depth->vids = vids; + + numVisuals = pScreen->numVisuals + new_visual_count; + visuals = reallocarray(pScreen->visuals, numVisuals, sizeof(VisualRec)); + if (!visuals) { + return FALSE; + } + + cdata.visuals = visuals; + cdata.pScreen = pScreen; + FindClientResourcesByType(serverClient, RT_COLORMAP, + _colormap_find_resource, &cdata); + + pScreen->visuals = visuals; + + for (i = 0; i < new_visual_count; i++) { + vid = FakeClientID(0); + pScreen->visuals[first_new_visual + i].vid = vid; + vids[first_new_vid + i] = vid; + } + + depth->numVids += new_visual_count; + pScreen->numVisuals += new_visual_count; + + return TRUE; +} diff --git a/nx-X11/programs/Xserver/dix/cursor.c b/nx-X11/programs/Xserver/dix/cursor.c index f4d6c6419..a1bf6a7ed 100644 --- a/nx-X11/programs/Xserver/dix/cursor.c +++ b/nx-X11/programs/Xserver/dix/cursor.c @@ -1,4 +1,3 @@ -/* $XFree86: xc/programs/Xserver/dix/cursor.c,v 3.8 2003/01/12 02:44:26 dawes Exp $ */ /*********************************************************** Copyright 1987, 1998 The Open Group @@ -47,14 +46,13 @@ SOFTWARE. ******************************************************************/ -/* $Xorg: cursor.c,v 1.4 2001/02/09 02:04:39 xorgcvs Exp $ */ #ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> #endif -#include <X11/X.h> -#include <X11/Xmd.h> +#include <nx-X11/X.h> +#include <nx-X11/Xmd.h> #include "servermd.h" #include "scrnintstr.h" #include "dixstruct.h" @@ -81,10 +79,10 @@ FreeCursorBits(CursorBitsPtr bits) { if (--bits->refcnt > 0) return; - xfree(bits->source); - xfree(bits->mask); + free(bits->source); + free(bits->mask); #ifdef ARGB_CURSOR - xfree(bits->argb); + free(bits->argb); #endif if (bits->refcnt == 0) { @@ -98,9 +96,9 @@ FreeCursorBits(CursorBitsPtr bits) { *prev = this->next; CloseFont(this->font, (Font)0); - xfree(this); + free(this); } - xfree(bits); + free(bits); } } @@ -110,7 +108,7 @@ FreeCursorBits(CursorBitsPtr bits) * \param value must conform to DeleteType */ int -FreeCursor(pointer value, XID cid) +FreeCursor(void * value, XID cid) { int nscr; CursorPtr pCurs = (CursorPtr)value; @@ -126,7 +124,7 @@ FreeCursor(pointer value, XID cid) (void)( *pscr->UnrealizeCursor)( pscr, pCurs); } FreeCursorBits(pCurs->bits); - xfree( pCurs); + free( pCurs); return(Success); } @@ -174,11 +172,11 @@ AllocCursorARGB(unsigned char *psrcbits, unsigned char *pmaskbits, CARD32 *argb, int nscr; ScreenPtr pscr; - pCurs = (CursorPtr)xalloc(sizeof(CursorRec) + sizeof(CursorBits)); + pCurs = (CursorPtr)malloc(sizeof(CursorRec) + sizeof(CursorBits)); if (!pCurs) { - xfree(psrcbits); - xfree(pmaskbits); + free(psrcbits); + free(pmaskbits); return (CursorPtr)NULL; } bits = (CursorBitsPtr)((char *)pCurs + sizeof(CursorRec)); @@ -223,7 +221,7 @@ AllocCursorARGB(unsigned char *psrcbits, unsigned char *pmaskbits, CARD32 *argb, ( *pscr->UnrealizeCursor)( pscr, pCurs); } FreeCursorBits(bits); - xfree(pCurs); + free(pCurs); return (CursorPtr)NULL; } } @@ -264,9 +262,9 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar, GlyphSharePtr pShare; sourcefont = (FontPtr) SecurityLookupIDByType(client, source, RT_FONT, - SecurityReadAccess); + DixReadAccess); maskfont = (FontPtr) SecurityLookupIDByType(client, mask, RT_FONT, - SecurityReadAccess); + DixReadAccess); if (!sourcefont) { @@ -292,7 +290,7 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar, } if (pShare) { - pCurs = (CursorPtr)xalloc(sizeof(CursorRec)); + pCurs = (CursorPtr)malloc(sizeof(CursorRec)); if (!pCurs) return BadAlloc; bits = pShare->bits; @@ -311,7 +309,7 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar, register unsigned char *mskptr; n = BitmapBytePad(cm.width)*(long)cm.height; - mskptr = mskbits = (unsigned char *)xalloc(n); + mskptr = mskbits = (unsigned char *)malloc(n); if (!mskptr) return BadAlloc; while (--n >= 0) @@ -329,12 +327,12 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar, } if ((res = ServerBitsFromGlyph(sourcefont, sourceChar, &cm, &srcbits)) != 0) { - xfree(mskbits); + free(mskbits); return res; } if (sourcefont != maskfont) { - pCurs = (CursorPtr)xalloc(sizeof(CursorRec) + sizeof(CursorBits)); + pCurs = (CursorPtr)malloc(sizeof(CursorRec) + sizeof(CursorBits)); if (pCurs) bits = (CursorBitsPtr)((char *)pCurs + sizeof(CursorRec)); else @@ -342,17 +340,17 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar, } else { - pCurs = (CursorPtr)xalloc(sizeof(CursorRec)); + pCurs = (CursorPtr)malloc(sizeof(CursorRec)); if (pCurs) - bits = (CursorBitsPtr)xalloc(sizeof(CursorBits)); + bits = (CursorBitsPtr)malloc(sizeof(CursorBits)); else bits = (CursorBitsPtr)NULL; } if (!bits) { - xfree(pCurs); - xfree(mskbits); - xfree(srcbits); + free(pCurs); + free(mskbits); + free(srcbits); return BadAlloc; } bits->source = srcbits; @@ -369,7 +367,7 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar, else { bits->refcnt = 1; - pShare = (GlyphSharePtr)xalloc(sizeof(GlyphShare)); + pShare = (GlyphSharePtr)malloc(sizeof(GlyphShare)); if (!pShare) { FreeCursorBits(bits); @@ -414,7 +412,7 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar, ( *pscr->UnrealizeCursor)( pscr, pCurs); } FreeCursorBits(pCurs->bits); - xfree(pCurs); + free(pCurs); return BadAlloc; } } @@ -452,7 +450,7 @@ CreateRootCursor(char *pfilename, unsigned glyph) 0, 0, 0, ~0, ~0, ~0, &curs, serverClient) != Success) return NullCursor; - if (!AddResource(FakeClientID(0), RT_CURSOR, (pointer)curs)) + if (!AddResource(FakeClientID(0), RT_CURSOR, (void *)curs)) return NullCursor; return curs; diff --git a/nx-X11/programs/Xserver/dix/devices.c b/nx-X11/programs/Xserver/dix/devices.c index e26879f28..427169222 100644 --- a/nx-X11/programs/Xserver/dix/devices.c +++ b/nx-X11/programs/Xserver/dix/devices.c @@ -1,4 +1,3 @@ -/* $XFree86: xc/programs/Xserver/dix/devices.c,v 3.20 2001/12/14 19:59:30 dawes Exp $ */ /************************************************************ Copyright 1987, 1998 The Open Group @@ -47,35 +46,27 @@ SOFTWARE. ********************************************************/ -/* $Xorg: devices.c,v 1.4 2001/02/09 02:04:39 xorgcvs Exp $ */ -/* $XdotOrg: xc/programs/Xserver/dix/devices.c,v 1.8 2005/07/03 08:53:38 daniels Exp $ */ #ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> #endif -#include <X11/X.h> +#include <nx-X11/X.h> #include "misc.h" #include "resource.h" -#define NEED_EVENTS -#define NEED_REPLIES -#include <X11/Xproto.h> +#include <nx-X11/Xproto.h> #include "windowstr.h" #include "inputstr.h" #include "scrnintstr.h" #include "cursorstr.h" #include "dixstruct.h" #include "site.h" -#define XKB_IN_SERVER #ifdef XKB -#include <X11/extensions/XKBsrv.h> +#include "xkbsrv.h" #endif #ifdef XCSECURITY #define _SECURITY_SERVER -#include <X11/extensions/security.h> -#endif -#ifdef LBX -#include "lbxserve.h" +#include <nx-X11/extensions/security.h> #endif #include "dispatch.h" @@ -89,7 +80,7 @@ _AddInputDevice(DeviceProc deviceProc, Bool autoStart) if (inputInfo.numDevices >= MAX_DEVICES) return (DeviceIntPtr)NULL; - dev = (DeviceIntPtr) xalloc(sizeof(DeviceIntRec)); + dev = (DeviceIntPtr) calloc(1, sizeof(DeviceIntRec)); if (!dev) return (DeviceIntPtr)NULL; dev->name = (char *)NULL; @@ -126,7 +117,8 @@ _AddInputDevice(DeviceProc deviceProc, Bool autoStart) dev->xkb_interest= NULL; #endif dev->nPrivates = 0; - dev->devPrivates = dev->unwrapProc = NULL; + dev->devPrivates = NULL; + dev->unwrapProc = NULL; inputInfo.off_devices = dev; return dev; } @@ -211,29 +203,30 @@ CloseDevice(register DeviceIntPtr dev) if (dev->inited) (void)(*dev->deviceProc)(dev, DEVICE_CLOSE); - xfree(dev->name); + free(dev->name); if (dev->key) { #ifdef XKB if (dev->key->xkbInfo) XkbFreeInfo(dev->key->xkbInfo); #endif - xfree(dev->key->curKeySyms.map); - xfree(dev->key->modifierKeyMap); - xfree(dev->key); + dev->key->xkbInfo = NULL; + free(dev->key->curKeySyms.map); + free(dev->key->modifierKeyMap); + free(dev->key); } - xfree(dev->valuator); + free(dev->valuator); #ifdef XKB if ((dev->button)&&(dev->button->xkb_acts)) - xfree(dev->button->xkb_acts); + free(dev->button->xkb_acts); #endif - xfree(dev->button); + free(dev->button); if (dev->focus) { - xfree(dev->focus->trace); - xfree(dev->focus); + free(dev->focus->trace); + free(dev->focus); } - xfree(dev->proximity); + free(dev->proximity); for (k=dev->kbdfeed; k; k=knext) { knext = k->next; @@ -241,29 +234,29 @@ CloseDevice(register DeviceIntPtr dev) if (k->xkb_sli) XkbFreeSrvLedInfo(k->xkb_sli); #endif - xfree(k); + free(k); } for (p=dev->ptrfeed; p; p=pnext) { pnext = p->next; - xfree(p); + free(p); } for (i=dev->intfeed; i; i=inext) { inext = i->next; - xfree(i); + free(i); } for (s=dev->stringfeed; s; s=snext) { snext = s->next; - xfree(s->ctrl.symbols_supported); - xfree(s->ctrl.symbols_displayed); - xfree(s); + free(s->ctrl.symbols_supported); + free(s->ctrl.symbols_displayed); + free(s); } for (b=dev->bell; b; b=bnext) { bnext = b->next; - xfree(b); + free(b); } for (l=dev->leds; l; l=lnext) { @@ -272,15 +265,15 @@ CloseDevice(register DeviceIntPtr dev) if (l->xkb_sli) XkbFreeSrvLedInfo(l->xkb_sli); #endif - xfree(l); + free(l); } #ifdef XKB while (dev->xkb_interest) { XkbRemoveResourceClient((DevicePtr)dev,dev->xkb_interest->resource); } #endif - xfree(dev->sync.event); - xfree(dev); + free(dev->sync.event); + free(dev); } void @@ -372,7 +365,7 @@ _RegisterPointerDevice(DeviceIntPtr device) if (!device->name) { char *p = "pointer"; - device->name = (char *)xalloc(strlen(p) + 1); + device->name = (char *)malloc(strlen(p) + 1); strcpy(device->name, p); } } @@ -395,7 +388,7 @@ _RegisterKeyboardDevice(DeviceIntPtr device) if (!device->name) { char *k = "keyboard"; - device->name = (char *)xalloc(strlen(k) + 1); + device->name = (char *)malloc(strlen(k) + 1); strcpy(device->name, k); } } @@ -464,7 +457,7 @@ SetKeySymsMap(register KeySymsPtr dst, register KeySymsPtr src) KeySym *map; int bytes = sizeof(KeySym) * src->mapWidth * (dst->maxKeyCode - dst->minKeyCode + 1); - map = (KeySym *)xalloc(bytes); + map = (KeySym *)malloc(bytes); if (!map) return FALSE; bzero((char *)map, bytes); @@ -474,7 +467,7 @@ SetKeySymsMap(register KeySymsPtr dst, register KeySymsPtr src) memmove((char *)&map[i*src->mapWidth], (char *)&dst->map[i*dst->mapWidth], dst->mapWidth * sizeof(KeySym)); - xfree(dst->map); + free(dst->map); } dst->mapWidth = src->mapWidth; dst->map = map; @@ -507,10 +500,9 @@ InitModMap(register KeyClassPtr keyc) } } } - keyc->modifierKeyMap = (KeyCode *)xalloc(8*keyc->maxKeysPerModifier); + keyc->modifierKeyMap = (KeyCode *)calloc(8, keyc->maxKeysPerModifier); if (!keyc->modifierKeyMap && keyc->maxKeysPerModifier) return (FALSE); - bzero((char *)keyc->modifierKeyMap, 8*(int)keyc->maxKeysPerModifier); for (i = 0; i < 8; i++) keysPerModifier[i] = 0; for (i = 8; i < MAP_LENGTH; i++) @@ -534,7 +526,7 @@ InitKeyClassDeviceStruct(DeviceIntPtr dev, KeySymsPtr pKeySyms, CARD8 pModifiers int i; register KeyClassPtr keyc; - keyc = (KeyClassPtr)xalloc(sizeof(KeyClassRec)); + keyc = (KeyClassPtr)calloc(1, sizeof(KeyClassRec)); if (!keyc) return FALSE; keyc->curKeySyms.map = (KeySym *)NULL; @@ -553,9 +545,9 @@ InitKeyClassDeviceStruct(DeviceIntPtr dev, KeySymsPtr pKeySyms, CARD8 pModifiers keyc->modifierKeyCount[i] = 0; if (!SetKeySymsMap(&keyc->curKeySyms, pKeySyms) || !InitModMap(keyc)) { - xfree(keyc->curKeySyms.map); - xfree(keyc->modifierKeyMap); - xfree(keyc); + free(keyc->curKeySyms.map); + free(keyc->modifierKeyMap); + free(keyc); return FALSE; } dev->key = keyc; @@ -573,7 +565,7 @@ InitButtonClassDeviceStruct(register DeviceIntPtr dev, int numButtons, register ButtonClassPtr butc; int i; - butc = (ButtonClassPtr)xalloc(sizeof(ButtonClassRec)); + butc = (ButtonClassPtr)calloc(1, sizeof(ButtonClassRec)); if (!butc) return FALSE; butc->numButtons = numButtons; @@ -598,7 +590,7 @@ InitValuatorClassDeviceStruct(DeviceIntPtr dev, int numAxes, int i; register ValuatorClassPtr valc; - valc = (ValuatorClassPtr)xalloc(sizeof(ValuatorClassRec) + + valc = (ValuatorClassPtr)calloc(1, sizeof(ValuatorClassRec) + numAxes * sizeof(AxisInfo) + numAxes * sizeof(unsigned int)); if (!valc) @@ -621,7 +613,7 @@ InitFocusClassDeviceStruct(DeviceIntPtr dev) { register FocusClassPtr focc; - focc = (FocusClassPtr)xalloc(sizeof(FocusClassRec)); + focc = (FocusClassPtr)calloc(1, sizeof(FocusClassRec)); if (!focc) return FALSE; focc->win = PointerRootWin; @@ -640,7 +632,7 @@ InitKbdFeedbackClassDeviceStruct(DeviceIntPtr dev, BellProcPtr bellProc, { register KbdFeedbackPtr feedc; - feedc = (KbdFeedbackPtr)xalloc(sizeof(KbdFeedbackClassRec)); + feedc = (KbdFeedbackPtr)calloc(1, sizeof(KbdFeedbackClassRec)); if (!feedc) return FALSE; feedc->BellProc = bellProc; @@ -667,17 +659,11 @@ InitPtrFeedbackClassDeviceStruct(DeviceIntPtr dev, PtrCtrlProcPtr controlProc) { register PtrFeedbackPtr feedc; - feedc = (PtrFeedbackPtr)xalloc(sizeof(PtrFeedbackClassRec)); + feedc = (PtrFeedbackPtr)calloc(1, sizeof(PtrFeedbackClassRec)); if (!feedc) return FALSE; feedc->CtrlProc = controlProc; -#ifdef sgi - feedc->ctrl.num = 1; - feedc->ctrl.den = 1; - feedc->ctrl.threshold = 1; -#else feedc->ctrl = defaultPointerControl; -#endif feedc->ctrl.id = 0; if ( (feedc->next = dev->ptrfeed) ) feedc->ctrl.id = dev->ptrfeed->ctrl.id + 1; @@ -711,7 +697,7 @@ InitStringFeedbackClassDeviceStruct ( int i; register StringFeedbackPtr feedc; - feedc = (StringFeedbackPtr)xalloc(sizeof(StringFeedbackClassRec)); + feedc = (StringFeedbackPtr)calloc(1, sizeof(StringFeedbackClassRec)); if (!feedc) return FALSE; feedc->CtrlProc = controlProc; @@ -719,22 +705,22 @@ InitStringFeedbackClassDeviceStruct ( feedc->ctrl.num_symbols_displayed = 0; feedc->ctrl.max_symbols = max_symbols; feedc->ctrl.symbols_supported = (KeySym *) - xalloc (sizeof (KeySym) * num_symbols_supported); + calloc (num_symbols_supported, sizeof (KeySym)); feedc->ctrl.symbols_displayed = (KeySym *) - xalloc (sizeof (KeySym) * max_symbols); + calloc (max_symbols, sizeof (KeySym)); if (!feedc->ctrl.symbols_supported || !feedc->ctrl.symbols_displayed) { if (feedc->ctrl.symbols_supported) - xfree(feedc->ctrl.symbols_supported); + free(feedc->ctrl.symbols_supported); if (feedc->ctrl.symbols_displayed) - xfree(feedc->ctrl.symbols_displayed); - xfree(feedc); + free(feedc->ctrl.symbols_displayed); + free(feedc); return FALSE; } for (i=0; i<num_symbols_supported; i++) *(feedc->ctrl.symbols_supported+i) = *symbols++; for (i=0; i<max_symbols; i++) - *(feedc->ctrl.symbols_displayed+i) = (KeySym) NULL; + *(feedc->ctrl.symbols_displayed+i) = (KeySym) 0; feedc->ctrl.id = 0; if ( (feedc->next = dev->stringfeed) ) feedc->ctrl.id = dev->stringfeed->ctrl.id + 1; @@ -749,7 +735,7 @@ InitBellFeedbackClassDeviceStruct (DeviceIntPtr dev, BellProcPtr bellProc, { register BellFeedbackPtr feedc; - feedc = (BellFeedbackPtr)xalloc(sizeof(BellFeedbackClassRec)); + feedc = (BellFeedbackPtr)calloc(1, sizeof(BellFeedbackClassRec)); if (!feedc) return FALSE; feedc->CtrlProc = controlProc; @@ -768,7 +754,7 @@ InitLedFeedbackClassDeviceStruct (DeviceIntPtr dev, LedCtrlProcPtr controlProc) { register LedFeedbackPtr feedc; - feedc = (LedFeedbackPtr)xalloc(sizeof(LedFeedbackClassRec)); + feedc = (LedFeedbackPtr)calloc(1, sizeof(LedFeedbackClassRec)); if (!feedc) return FALSE; feedc->CtrlProc = controlProc; @@ -789,7 +775,7 @@ InitIntegerFeedbackClassDeviceStruct (DeviceIntPtr dev, IntegerCtrlProcPtr contr { register IntegerFeedbackPtr feedc; - feedc = (IntegerFeedbackPtr)xalloc(sizeof(IntegerFeedbackClassRec)); + feedc = (IntegerFeedbackPtr)calloc(1, sizeof(IntegerFeedbackClassRec)); if (!feedc) return FALSE; feedc->CtrlProc = controlProc; @@ -961,9 +947,6 @@ ProcSetModifierMapping(ClientPtr client) return BadAccess; #endif -#ifdef LBX - LbxFlushModifierMapTag(); -#endif rep.type = X_Reply; rep.length = 0; rep.sequenceNumber = client->sequence; @@ -1003,11 +986,11 @@ ProcSetModifierMapping(ClientPtr client) * Now build the keyboard's modifier bitmap from the * list of keycodes. */ - map = (KeyCode *)xalloc(inputMapLen); + map = (KeyCode *)malloc(inputMapLen); if (!map && inputMapLen) return BadAlloc; if (keyc->modifierKeyMap) - xfree(keyc->modifierKeyMap); + free(keyc->modifierKeyMap); keyc->modifierKeyMap = map; memmove((char *)map, (char *)inputMap, inputMapLen); @@ -1037,6 +1020,7 @@ ProcGetModifierMapping(ClientPtr client) register KeyClassPtr keyc = inputInfo.keyboard->key; REQUEST_SIZE_MATCH(xReq); + memset(&rep, 0, sizeof(xGetModifierMappingReply)); rep.type = X_Reply; rep.numKeyPerModifier = keyc->maxKeysPerModifier; rep.sequenceNumber = client->sequence; @@ -1046,7 +1030,7 @@ ProcGetModifierMapping(ClientPtr client) WriteReplyToClient(client, sizeof(xGetModifierMappingReply), &rep); /* Use the (modified by DDX) map that SetModifierMapping passed in */ - (void)WriteToClient(client, (int)(keyc->maxKeysPerModifier << 3), + WriteToClient(client, (int)(keyc->maxKeysPerModifier << 3), (char *)keyc->modifierKeyMap); return client->noClientException; } @@ -1087,9 +1071,6 @@ ProcChangeKeyboardMapping(ClientPtr client) keysyms.map = (KeySym *)&stuff[1]; if (!SetKeySymsMap(curKeySyms, &keysyms)) return BadAlloc; -#ifdef LBX - LbxFlushKeyboardMapTag(); -#endif SendMappingNotify(MappingKeyboard, stuff->firstKeyCode, stuff->keyCodes, client); return client->noClientException; @@ -1157,6 +1138,7 @@ ProcGetKeyboardMapping(ClientPtr client) return BadValue; } + memset(&rep, 0, sizeof(xGetKeyboardMappingReply)); rep.type = X_Reply; rep.sequenceNumber = client->sequence; rep.keySymsPerKeyCode = curKeySyms->mapWidth; @@ -1185,7 +1167,7 @@ ProcGetPointerMapping(ClientPtr client) rep.nElts = butc->numButtons; rep.length = ((unsigned)rep.nElts + (4-1))/4; WriteReplyToClient(client, sizeof(xGetPointerMappingReply), &rep); - (void)WriteToClient(client, (int)rep.nElts, (char *)&butc->map[1]); + WriteToClient(client, (int)rep.nElts, &butc->map[1]); return Success; } @@ -1447,7 +1429,7 @@ ProcBell(ClientPtr client) else #endif (*keybd->kbdfeed->BellProc)(newpercent, keybd, - (pointer) &keybd->kbdfeed->ctrl, 0); + (void *) &keybd->kbdfeed->ctrl, 0); return Success; } @@ -1567,7 +1549,7 @@ ProcGetMotionEvents(ClientPtr client) { if (CompareTimeStamps(stop, currentTime) == LATER) stop = currentTime; - coords = (xTimecoord *)ALLOCATE_LOCAL(mouse->valuator->numMotionEvents + coords = (xTimecoord *)malloc(mouse->valuator->numMotionEvents * sizeof(xTimecoord)); if (!coords) return BadAlloc; @@ -1601,7 +1583,7 @@ ProcGetMotionEvents(ClientPtr client) (char *)coords); } if (coords) - DEALLOCATE_LOCAL(coords); + free(coords); return Success; } diff --git a/nx-X11/programs/Xserver/dix/dispatch.c b/nx-X11/programs/Xserver/dix/dispatch.c index 6941456de..c9ce8981c 100644 --- a/nx-X11/programs/Xserver/dix/dispatch.c +++ b/nx-X11/programs/Xserver/dix/dispatch.c @@ -1,5 +1,3 @@ -/* $XdotOrg: xc/programs/Xserver/dix/dispatch.c,v 1.13 2005/09/13 01:33:19 daniels Exp $ */ -/* $Xorg: dispatch.c,v 1.5 2001/02/09 02:04:40 xorgcvs Exp $ */ /************************************************************ Copyright 1987, 1989, 1998 The Open Group @@ -76,7 +74,6 @@ Equipment Corporation. ******************************************************************/ -/* $XFree86: xc/programs/Xserver/dix/dispatch.c,v 3.32 2003/11/10 18:21:45 tsi Exp $ */ #ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> @@ -89,6 +86,11 @@ int ProcInitialConnection(); #include "windowstr.h" #include <X11/fonts/fontstruct.h> +#ifdef HAS_XFONT2 +# include <X11/fonts/libxfont2.h> +#else +# include <X11/fonts/fontutil.h> +#endif /* HAS_XFONT2 */ #include "dixfontstr.h" #include "gcstruct.h" #include "selection.h" @@ -104,24 +106,18 @@ int ProcInitialConnection(); #include "swaprep.h" #include "swapreq.h" #ifdef PANORAMIX -#include "panoramiX.h" -#include "panoramiXsrv.h" +#include "../Xext/panoramiX.h" +#include "../Xext/panoramiXsrv.h" #endif #ifdef XCSECURITY #define _SECURITY_SERVER -#include <X11/extensions/security.h> -#endif -#ifdef XAPPGROUP -#include <X11/extensions/Xagsrv.h> +#include <nx-X11/extensions/security.h> #endif #ifdef XKB -#define XKB_IN_SERVER #include "inputstr.h" -#include <X11/extensions/XKBsrv.h> -#endif -#ifdef LBX -#include "lbxserve.h" +#include "xkbsrv.h" #endif +#include "client.h" #define mskcnt ((MAXCLIENTS + 31) / 32) #define BITMASK(i) (1U << ((i) & 31)) @@ -134,6 +130,8 @@ int ProcInitialConnection(); extern xConnSetupPrefix connSetupPrefix; extern char *ConnectionInfo; +extern int screenPrivateCount; + Selection *CurrentSelections; int NumCurrentSelections; CallbackListPtr SelectionCallback = NULL; @@ -215,50 +213,27 @@ UpdateCurrentTimeIf() currentTime = systime; } +#ifndef NXAGENT_SERVER void InitSelections() { if (CurrentSelections) - xfree(CurrentSelections); + free(CurrentSelections); CurrentSelections = (Selection *)NULL; NumCurrentSelections = 0; } - -void -FlushClientCaches(XID id) -{ - int i; - register ClientPtr client; - - client = clients[CLIENT_ID(id)]; - if (client == NullClient) - return ; - for (i=0; i<currentMaxClients; i++) - { - client = clients[i]; - if (client != NullClient) - { - if (client->lastDrawableID == id) - { - client->lastDrawableID = WindowTable[0]->drawable.id; - client->lastDrawable = (DrawablePtr)WindowTable[0]; - } - else if (client->lastGCID == id) - { - client->lastGCID = INVALID; - client->lastGC = (GCPtr)NULL; - } - } - } -} -#ifdef SMART_SCHEDULE +#endif /* NXAGENT_SERVER */ #undef SMART_DEBUG #define SMART_SCHEDULE_DEFAULT_INTERVAL 20 /* ms */ #define SMART_SCHEDULE_MAX_SLICE 200 /* ms */ -Bool SmartScheduleDisable = FALSE; +#ifdef HAVE_SETITIMER +#define SMART_SCHEDULE_DEFAULT_SIGNAL_ENABLE HAVE_SETITIMER +Bool SmartScheduleSignalEnable = SMART_SCHEDULE_DEFAULT_SIGNAL_ENABLE; +#endif + long SmartScheduleSlice = SMART_SCHEDULE_DEFAULT_INTERVAL; long SmartScheduleInterval = SMART_SCHEDULE_DEFAULT_INTERVAL; long SmartScheduleMaxSlice = SMART_SCHEDULE_MAX_SLICE; @@ -277,15 +252,13 @@ void InitProcVectors(void); int SmartScheduleClient (int *clientReady, int nready) { - ClientPtr pClient; int i; int client; - int bestPrio, best = 0; + ClientPtr pClient, best = NULL; int bestRobin, robin; long now = SmartScheduleTime; long idle; - bestPrio = -0x7fffffff; bestRobin = 0; idle = 2 * SmartScheduleSlice; for (i = 0; i < nready; i++) @@ -301,13 +274,19 @@ SmartScheduleClient (int *clientReady, int nready) pClient->smart_check_tick = now; /* check priority to select best client */ - robin = (pClient->index - SmartLastIndex[pClient->smart_priority-SMART_MIN_PRIORITY]) & 0xff; - if (pClient->smart_priority > bestPrio || - (pClient->smart_priority == bestPrio && robin > bestRobin)) + robin = (pClient->index - + SmartLastIndex[pClient->smart_priority - + SMART_MIN_PRIORITY]) & 0xff; + + /* pick the best client */ + if (!best || + pClient->priority > best->priority || + (pClient->priority == best->priority && + (pClient->smart_priority > best->smart_priority || + (pClient->smart_priority == best->smart_priority && robin > bestRobin)))) { - bestPrio = pClient->smart_priority; + best = pClient; bestRobin = robin; - best = client; } #ifdef SMART_DEBUG if ((now - SmartLastPrint) >= 5000) @@ -321,8 +300,7 @@ SmartScheduleClient (int *clientReady, int nready) SmartLastPrint = now; } #endif - pClient = clients[best]; - SmartLastIndex[bestPrio-SMART_MIN_PRIORITY] = pClient->index; + SmartLastIndex[best->smart_priority - SMART_MIN_PRIORITY] = best->index; /* * Set current client pointer */ @@ -351,10 +329,10 @@ SmartScheduleClient (int *clientReady, int nready) { SmartScheduleSlice = SmartScheduleInterval; } - return best; + return best->index; } -#endif +#ifndef NXAGENT_SERVER #define MAJOROP ((xReq *)client->requestBuffer)->reqType void @@ -365,15 +343,13 @@ Dispatch(void) register ClientPtr client; register int nready; register HWEventQueuePtr* icheck = checkForInput; -#ifdef SMART_SCHEDULE long start_tick; -#endif nextFreeClientID = 1; InitSelections(); nClients = 0; - clientReady = (int *) ALLOCATE_LOCAL(sizeof(int) * MaxClients); + clientReady = (int *) malloc(sizeof(int) * MaxClients); if (!clientReady) return; @@ -387,13 +363,11 @@ Dispatch(void) nready = WaitForSomething(clientReady); -#ifdef SMART_SCHEDULE - if (nready && !SmartScheduleDisable) + if (nready) { clientReady[0] = SmartScheduleClient (clientReady, nready); nready = 1; } -#endif /***************** * Handle events in round robin fashion, doing input between * each round @@ -416,9 +390,7 @@ Dispatch(void) isItTimeToYield = FALSE; requestingClient = client; -#ifdef SMART_SCHEDULE start_tick = SmartScheduleTime; -#endif while (!isItTimeToYield) { if (*icheck[0] != *icheck[1]) @@ -426,16 +398,13 @@ Dispatch(void) ProcessInputEvents(); FlushIfCriticalOutputPending(); } -#ifdef SMART_SCHEDULE - if (!SmartScheduleDisable && - (SmartScheduleTime - start_tick) >= SmartScheduleSlice) + if ((SmartScheduleTime - start_tick) >= SmartScheduleSlice) { /* Penalize clients which consume ticks */ if (client->smart_priority > SMART_MIN_PRIORITY) client->smart_priority--; break; } -#endif /* now, finally, deal with client requests */ result = ReadRequestFromClient(client); @@ -457,7 +426,10 @@ Dispatch(void) result = BadLength; else result = (* client->requestVector[MAJOROP])(client); - + + if (!SmartScheduleSignalEnable) + SmartScheduleTime = GetTimeInMillis(); + if (result != Success) { if (client->noClientException != Success) @@ -473,11 +445,9 @@ Dispatch(void) #endif } FlushAllOutput(); -#ifdef SMART_SCHEDULE client = clients[clientReady[nready]]; if (client) client->smart_stop_tick = SmartScheduleTime; -#endif requestingClient = NULL; } dispatchException &= ~DE_PRIORITYCHANGE; @@ -486,11 +456,12 @@ Dispatch(void) ddxBeforeReset (); #endif KillAllClients(); - DEALLOCATE_LOCAL(clientReady); + free(clientReady); dispatchException &= ~DE_RESET; } #undef MAJOROP +#endif /* NXAGENT_SERVER */ int ProcBadRequest(ClientPtr client) @@ -510,7 +481,7 @@ ProcCreateWindow(ClientPtr client) LEGAL_NEW_RESOURCE(stuff->wid, client); if (!(pParent = (WindowPtr)SecurityLookupWindow(stuff->parent, client, - SecurityWriteAccess))) + DixWriteAccess))) return BadWindow; len = client->req_len - (sizeof(xCreateWindowReq) >> 2); if (Ones(stuff->mask) != len) @@ -531,7 +502,7 @@ ProcCreateWindow(ClientPtr client) Mask mask = pWin->eventMask; pWin->eventMask = 0; /* subterfuge in case AddResource fails */ - if (!AddResource(stuff->wid, RT_WINDOW, (pointer)pWin)) + if (!AddResource(stuff->wid, RT_WINDOW, (void *)pWin)) return BadAlloc; pWin->eventMask = mask; } @@ -551,7 +522,7 @@ ProcChangeWindowAttributes(register ClientPtr client) REQUEST_AT_LEAST_SIZE(xChangeWindowAttributesReq); pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - SecurityWriteAccess); + DixWriteAccess); if (!pWin) return(BadWindow); len = client->req_len - (sizeof(xChangeWindowAttributesReq) >> 2); @@ -576,9 +547,10 @@ ProcGetWindowAttributes(register ClientPtr client) REQUEST_SIZE_MATCH(xResourceReq); pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client, - SecurityReadAccess); + DixReadAccess); if (!pWin) return(BadWindow); + memset(&wa, 0, sizeof(xGetWindowAttributesReply)); GetWindowAttributes(pWin, client, &wa); WriteReplyToClient(client, sizeof(xGetWindowAttributesReply), &wa); return(client->noClientException); @@ -592,7 +564,7 @@ ProcDestroyWindow(register ClientPtr client) REQUEST_SIZE_MATCH(xResourceReq); pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client, - SecurityDestroyAccess); + DixDestroyAccess); if (!pWin) return(BadWindow); if (pWin->parent) @@ -608,7 +580,7 @@ ProcDestroySubwindows(register ClientPtr client) REQUEST_SIZE_MATCH(xResourceReq); pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client, - SecurityDestroyAccess); + DixDestroyAccess); if (!pWin) return(BadWindow); DestroySubwindows(pWin, client); @@ -624,7 +596,7 @@ ProcChangeSaveSet(register ClientPtr client) REQUEST_SIZE_MATCH(xChangeSaveSetReq); pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - SecurityReadAccess); + DixReadAccess); if (!pWin) return(BadWindow); if (client->clientAsMask == (CLIENT_BITS(pWin->drawable.id))) @@ -644,6 +616,7 @@ ProcChangeSaveSet(register ClientPtr client) } } +#ifndef NXAGENT_SERVER int ProcReparentWindow(register ClientPtr client) { @@ -653,11 +626,11 @@ ProcReparentWindow(register ClientPtr client) REQUEST_SIZE_MATCH(xReparentWindowReq); pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - SecurityWriteAccess); + DixWriteAccess); if (!pWin) return(BadWindow); pParent = (WindowPtr)SecurityLookupWindow(stuff->parent, client, - SecurityWriteAccess); + DixWriteAccess); if (!pParent) return(BadWindow); if (SAME_SCREENS(pWin->drawable, pParent->drawable)) @@ -678,6 +651,7 @@ ProcReparentWindow(register ClientPtr client) else return (BadMatch); } +#endif /* NXAGENT_SERVER */ int ProcMapWindow(register ClientPtr client) @@ -687,7 +661,7 @@ ProcMapWindow(register ClientPtr client) REQUEST_SIZE_MATCH(xResourceReq); pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client, - SecurityReadAccess); + DixReadAccess); if (!pWin) return(BadWindow); MapWindow(pWin, client); @@ -703,7 +677,7 @@ ProcMapSubwindows(register ClientPtr client) REQUEST_SIZE_MATCH(xResourceReq); pWin = (WindowPtr)SecurityLookupWindow( stuff->id, client, - SecurityReadAccess); + DixReadAccess); if (!pWin) return(BadWindow); MapSubwindows(pWin, client); @@ -719,7 +693,7 @@ ProcUnmapWindow(register ClientPtr client) REQUEST_SIZE_MATCH(xResourceReq); pWin = (WindowPtr)SecurityLookupWindow( stuff->id, client, - SecurityReadAccess); + DixReadAccess); if (!pWin) return(BadWindow); UnmapWindow(pWin, FALSE); @@ -735,7 +709,7 @@ ProcUnmapSubwindows(register ClientPtr client) REQUEST_SIZE_MATCH(xResourceReq); pWin = (WindowPtr)SecurityLookupWindow( stuff->id, client, - SecurityReadAccess); + DixReadAccess); if (!pWin) return(BadWindow); UnmapSubwindows(pWin); @@ -752,7 +726,7 @@ ProcConfigureWindow(register ClientPtr client) REQUEST_AT_LEAST_SIZE(xConfigureWindowReq); pWin = (WindowPtr)SecurityLookupWindow( stuff->window, client, - SecurityWriteAccess); + DixWriteAccess); if (!pWin) return(BadWindow); len = client->req_len - (sizeof(xConfigureWindowReq) >> 2); @@ -780,7 +754,7 @@ ProcCirculateWindow(register ClientPtr client) return BadValue; } pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - SecurityWriteAccess); + DixWriteAccess); if (!pWin) return(BadWindow); CirculateWindow(pWin, (int)stuff->direction, client); @@ -794,11 +768,12 @@ GetGeometry(register ClientPtr client, xGetGeometryReply *rep) REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); - SECURITY_VERIFY_GEOMETRABLE (pDraw, stuff->id, client, SecurityReadAccess); + SECURITY_VERIFY_GEOMETRABLE (pDraw, stuff->id, client, DixReadAccess); + memset(rep, 0, sizeof(xGetGeometryReply)); rep->type = X_Reply; rep->length = 0; rep->sequenceNumber = client->sequence; - rep->root = WindowTable[pDraw->pScreen->myNum]->drawable.id; + rep->root = pDraw->pScreen->root->drawable.id; rep->depth = pDraw->depth; rep->width = pDraw->width; rep->height = pDraw->height; @@ -842,6 +817,7 @@ ProcGetGeometry(register ClientPtr client) } +#ifndef NXAGENT_SERVER int ProcQueryTree(register ClientPtr client) { @@ -853,11 +829,12 @@ ProcQueryTree(register ClientPtr client) REQUEST_SIZE_MATCH(xResourceReq); pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client, - SecurityReadAccess); + DixReadAccess); if (!pWin) return(BadWindow); + memset(&reply, 0, sizeof(xQueryTreeReply)); reply.type = X_Reply; - reply.root = WindowTable[pWin->drawable.pScreen->myNum]->drawable.id; + reply.root = pWin->drawable.pScreen->root->drawable.id; reply.sequenceNumber = client->sequence; if (pWin->parent) reply.parent = pWin->parent->drawable.id; @@ -870,7 +847,7 @@ ProcQueryTree(register ClientPtr client) { int curChild = 0; - childIDs = (Window *) ALLOCATE_LOCAL(numChildren * sizeof(Window)); + childIDs = (Window *) malloc(numChildren * sizeof(Window)); if (!childIDs) return BadAlloc; for (pChild = pWin->lastChild; pChild != pHead; pChild = pChild->prevSib) @@ -885,11 +862,13 @@ ProcQueryTree(register ClientPtr client) { client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write; WriteSwappedDataToClient(client, numChildren * sizeof(Window), childIDs); - DEALLOCATE_LOCAL(childIDs); + free(childIDs); } return(client->noClientException); } +#endif /* NXAGENT_SERVER */ + int ProcInternAtom(register ClientPtr client) @@ -909,6 +888,7 @@ ProcInternAtom(register ClientPtr client) if (atom != BAD_RESOURCE) { xInternAtomReply reply; + memset(&reply, 0, sizeof(xInternAtomReply)); reply.type = X_Reply; reply.length = 0; reply.sequenceNumber = client->sequence; @@ -923,7 +903,7 @@ ProcInternAtom(register ClientPtr client) int ProcGetAtomName(register ClientPtr client) { - char *str; + const char *str; xGetAtomNameReply reply; int len; REQUEST(xResourceReq); @@ -932,12 +912,13 @@ ProcGetAtomName(register ClientPtr client) if ( (str = NameForAtom(stuff->id)) ) { len = strlen(str); + memset(&reply, 0, sizeof(xGetAtomNameReply)); reply.type = X_Reply; reply.length = (len + 3) >> 2; reply.sequenceNumber = client->sequence; reply.nameLength = len; WriteReplyToClient(client, sizeof(xGetAtomNameReply), &reply); - (void)WriteToClient(client, len, str); + WriteToClient(client, len, str); return(client->noClientException); } else @@ -947,10 +928,7 @@ ProcGetAtomName(register ClientPtr client) } } -#ifdef K5AUTH -extern int k5_bad(); -#endif - +#ifndef NXAGENT_SERVER int ProcSetSelectionOwner(register ClientPtr client) { @@ -969,7 +947,7 @@ ProcSetSelectionOwner(register ClientPtr client) if (stuff->window != None) { pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - SecurityReadAccess); + DixReadAccess); if (!pWin) return(BadWindow); } @@ -1016,9 +994,9 @@ ProcSetSelectionOwner(register ClientPtr client) Selection *newsels; if (i == 0) - newsels = (Selection *)xalloc(sizeof(Selection)); + newsels = (Selection *)malloc(sizeof(Selection)); else - newsels = (Selection *)xrealloc(CurrentSelections, + newsels = (Selection *)realloc(CurrentSelections, (NumCurrentSelections + 1) * sizeof(Selection)); if (!newsels) return BadAlloc; @@ -1046,6 +1024,7 @@ ProcSetSelectionOwner(register ClientPtr client) return (BadAtom); } } +#endif /* NXAGENT_SERVER */ int ProcGetSelectionOwner(register ClientPtr client) @@ -1061,6 +1040,7 @@ ProcGetSelectionOwner(register ClientPtr client) i = 0; while ((i < NumCurrentSelections) && CurrentSelections[i].selection != stuff->id) i++; + memset(&reply, 0, sizeof(xGetSelectionOwnerReply)); reply.type = X_Reply; reply.length = 0; reply.sequenceNumber = client->sequence; @@ -1078,6 +1058,7 @@ ProcGetSelectionOwner(register ClientPtr client) } } +#ifndef NXAGENT_SERVER int ProcConvertSelection(register ClientPtr client) { @@ -1088,7 +1069,7 @@ ProcConvertSelection(register ClientPtr client) REQUEST_SIZE_MATCH(xConvertSelectionReq); pWin = (WindowPtr)SecurityLookupWindow(stuff->requestor, client, - SecurityReadAccess); + DixReadAccess); if (!pWin) return(BadWindow); @@ -1107,11 +1088,12 @@ ProcConvertSelection(register ClientPtr client) #ifdef XCSECURITY && (!client->CheckAccess || (* client->CheckAccess)(client, CurrentSelections[i].window, - RT_WINDOW, SecurityReadAccess, + RT_WINDOW, DixReadAccess, CurrentSelections[i].pWin)) #endif ) { + memset(&event, 0, sizeof(xEvent)); event.u.u.type = SelectionRequest; event.u.selectionRequest.time = stuff->time; event.u.selectionRequest.owner = @@ -1125,6 +1107,7 @@ ProcConvertSelection(register ClientPtr client) NoEventMask /* CantBeFiltered */, NullGrab)) return (client->noClientException); } + memset(&event, 0, sizeof(xEvent)); event.u.u.type = SelectionNotify; event.u.selectionNotify.time = stuff->time; event.u.selectionNotify.requestor = stuff->requestor; @@ -1141,6 +1124,7 @@ ProcConvertSelection(register ClientPtr client) return (BadAtom); } } +#endif /* NXAGENT_SERVER */ int ProcGrabServer(register ClientPtr client) @@ -1163,7 +1147,7 @@ ProcGrabServer(register ClientPtr client) ServerGrabInfoRec grabinfo; grabinfo.client = client; grabinfo.grabstate = SERVER_GRABBED; - CallCallbacks(&ServerGrabCallback, (pointer)&grabinfo); + CallCallbacks(&ServerGrabCallback, (void *)&grabinfo); } return(client->noClientException); @@ -1192,7 +1176,7 @@ UngrabServer(ClientPtr client) ServerGrabInfoRec grabinfo; grabinfo.client = client; grabinfo.grabstate = SERVER_UNGRABBED; - CallCallbacks(&ServerGrabCallback, (pointer)&grabinfo); + CallCallbacks(&ServerGrabCallback, (void *)&grabinfo); } } @@ -1214,13 +1198,14 @@ ProcTranslateCoords(register ClientPtr client) REQUEST_SIZE_MATCH(xTranslateCoordsReq); pWin = (WindowPtr)SecurityLookupWindow(stuff->srcWid, client, - SecurityReadAccess); + DixReadAccess); if (!pWin) return(BadWindow); pDst = (WindowPtr)SecurityLookupWindow(stuff->dstWid, client, - SecurityReadAccess); + DixReadAccess); if (!pDst) return(BadWindow); + memset(&rep, 0, sizeof(xTranslateCoordsReply)); rep.type = X_Reply; rep.length = 0; rep.sequenceNumber = client->sequence; @@ -1257,11 +1242,11 @@ ProcTranslateCoords(register ClientPtr client) * borderSize */ && (!wBoundingShape(pWin) || - POINT_IN_REGION(pWin->drawable.pScreen, + RegionContainsPoint( &pWin->borderSize, x, y, &box)) && (!wInputShape(pWin) || - POINT_IN_REGION(pWin->drawable.pScreen, + RegionContainsPoint( wInputShape(pWin), x - pWin->drawable.x, y - pWin->drawable.y, &box)) @@ -1282,6 +1267,7 @@ ProcTranslateCoords(register ClientPtr client) return(client->noClientException); } +#ifndef NXAGENT_SERVER int ProcOpenFont(register ClientPtr client) { @@ -1309,7 +1295,7 @@ ProcCloseFont(register ClientPtr client) REQUEST_SIZE_MATCH(xResourceReq); pFont = (FontPtr)SecurityLookupIDByType(client, stuff->id, RT_FONT, - SecurityDestroyAccess); + DixDestroyAccess); if ( pFont != (FontPtr)NULL) /* id was valid */ { FreeResource(stuff->id, RT_NONE); @@ -1321,6 +1307,7 @@ ProcCloseFont(register ClientPtr client) return (BadFont); } } +#endif /* NXAGENT_SERVER */ int ProcQueryFont(register ClientPtr client) @@ -1332,13 +1319,14 @@ ProcQueryFont(register ClientPtr client) REQUEST_SIZE_MATCH(xResourceReq); client->errorValue = stuff->id; /* EITHER font or gc */ + pFont = (FontPtr)SecurityLookupIDByType(client, stuff->id, RT_FONT, - SecurityReadAccess); + DixReadAccess); if (!pFont) { /* can't use VERIFY_GC because it might return BadGC */ pGC = (GC *) SecurityLookupIDByType(client, stuff->id, RT_GC, - SecurityReadAccess); + DixReadAccess); if (!pGC) { client->errorValue = stuff->id; @@ -1364,19 +1352,21 @@ ProcQueryFont(register ClientPtr client) rlength = sizeof(xQueryFontReply) + FONTINFONPROPS(FONTCHARSET(pFont)) * sizeof(xFontProp) + nprotoxcistructs * sizeof(xCharInfo); - reply = (xQueryFontReply *)ALLOCATE_LOCAL(rlength); + + reply = (xQueryFontReply *)malloc(rlength); if(!reply) { return(BadAlloc); } + memset(reply, 0, rlength); reply->type = X_Reply; reply->length = (rlength - sizeof(xGenericReply)) >> 2; reply->sequenceNumber = client->sequence; QueryFont( pFont, reply, nprotoxcistructs); WriteReplyToClient(client, rlength, reply); - DEALLOCATE_LOCAL(reply); + free(reply); return(client->noClientException); } } @@ -1394,11 +1384,11 @@ ProcQueryTextExtents(register ClientPtr client) REQUEST_AT_LEAST_SIZE(xQueryTextExtentsReq); pFont = (FontPtr)SecurityLookupIDByType(client, stuff->fid, RT_FONT, - SecurityReadAccess); + DixReadAccess); if (!pFont) { pGC = (GC *)SecurityLookupIDByType(client, stuff->fid, RT_GC, - SecurityReadAccess); + DixReadAccess); if (!pGC) { client->errorValue = stuff->fid; @@ -1414,7 +1404,11 @@ ProcQueryTextExtents(register ClientPtr client) return(BadLength); length--; } +#ifdef HAS_XFONT2 + if (!xfont2_query_text_extents(pFont, length, (unsigned char *)&stuff[1], &info)) +#else if (!QueryTextExtents(pFont, length, (unsigned char *)&stuff[1], &info)) +#endif /* HAS_XFONT2 */ return(BadAlloc); reply.type = X_Reply; reply.length = 0; @@ -1431,6 +1425,7 @@ ProcQueryTextExtents(register ClientPtr client) return(client->noClientException); } +#ifndef NXAGENT_SERVER int ProcListFonts(register ClientPtr client) { @@ -1452,13 +1447,14 @@ ProcListFontsWithInfo(register ClientPtr client) return StartListFontsWithInfo(client, stuff->nbytes, (unsigned char *) &stuff[1], stuff->maxNames); } +#endif /* NXAGENT_SERVER */ /** * * \param value must conform to DeleteType */ int -dixDestroyPixmap(pointer value, XID pid) +dixDestroyPixmap(void * value, XID pid) { PixmapPtr pPixmap = (PixmapPtr)value; return (*pPixmap->drawable.pScreen->DestroyPixmap)(pPixmap); @@ -1477,7 +1473,7 @@ ProcCreatePixmap(register ClientPtr client) client->errorValue = stuff->pid; LEGAL_NEW_RESOURCE(stuff->pid, client); SECURITY_VERIFY_GEOMETRABLE (pDraw, stuff->drawable, client, - SecurityReadAccess); + DixReadAccess); if (!stuff->width || !stuff->height) { client->errorValue = 0; @@ -1512,17 +1508,18 @@ ProcCreatePixmap(register ClientPtr client) CreatePmap: pMap = (PixmapPtr)(*pDraw->pScreen->CreatePixmap) (pDraw->pScreen, stuff->width, - stuff->height, stuff->depth); + stuff->height, stuff->depth, 0); if (pMap) { pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER; pMap->drawable.id = stuff->pid; - if (AddResource(stuff->pid, RT_PIXMAP, (pointer)pMap)) + if (AddResource(stuff->pid, RT_PIXMAP, (void *)pMap)) return(client->noClientException); } return (BadAlloc); } +#ifndef NXAGENT_SERVER int ProcFreePixmap(register ClientPtr client) { @@ -1532,7 +1529,7 @@ ProcFreePixmap(register ClientPtr client) REQUEST_SIZE_MATCH(xResourceReq); pMap = (PixmapPtr)SecurityLookupIDByType(client, stuff->id, RT_PIXMAP, - SecurityDestroyAccess); + DixDestroyAccess); if (pMap) { FreeResource(stuff->id, RT_NONE); @@ -1544,6 +1541,7 @@ ProcFreePixmap(register ClientPtr client) return (BadPixmap); } } +#endif /* NXAGENT_SERVER */ int ProcCreateGC(register ClientPtr client) @@ -1558,7 +1556,7 @@ ProcCreateGC(register ClientPtr client) client->errorValue = stuff->gc; LEGAL_NEW_RESOURCE(stuff->gc, client); SECURITY_VERIFY_DRAWABLE (pDraw, stuff->drawable, client, - SecurityReadAccess); + DixReadAccess); len = client->req_len - (sizeof(xCreateGCReq) >> 2); if (len != Ones(stuff->mask)) return BadLength; @@ -1566,7 +1564,7 @@ ProcCreateGC(register ClientPtr client) (XID *) &stuff[1], &error); if (error != Success) return error; - if (!AddResource(stuff->gc, RT_GC, (pointer)pGC)) + if (!AddResource(stuff->gc, RT_GC, (void *)pGC)) return (BadAlloc); return(client->noClientException); } @@ -1580,7 +1578,7 @@ ProcChangeGC(register ClientPtr client) unsigned len; REQUEST_AT_LEAST_SIZE(xChangeGCReq); - SECURITY_VERIFY_GC(pGC, stuff->gc, client, SecurityWriteAccess); + SECURITY_VERIFY_GC(pGC, stuff->gc, client, DixWriteAccess); len = client->req_len - (sizeof(xChangeGCReq) >> 2); if (len != Ones(stuff->mask)) return BadLength; @@ -1604,8 +1602,8 @@ ProcCopyGC(register ClientPtr client) REQUEST(xCopyGCReq); REQUEST_SIZE_MATCH(xCopyGCReq); - SECURITY_VERIFY_GC( pGC, stuff->srcGC, client, SecurityReadAccess); - SECURITY_VERIFY_GC( dstGC, stuff->dstGC, client, SecurityWriteAccess); + SECURITY_VERIFY_GC( pGC, stuff->srcGC, client, DixReadAccess); + SECURITY_VERIFY_GC( dstGC, stuff->dstGC, client, DixWriteAccess); if ((dstGC->pScreen != pGC->pScreen) || (dstGC->depth != pGC->depth)) return (BadMatch); result = CopyGC(pGC, dstGC, stuff->mask); @@ -1632,7 +1630,7 @@ ProcSetDashes(register ClientPtr client) return BadValue; } - SECURITY_VERIFY_GC(pGC,stuff->gc, client, SecurityWriteAccess); + SECURITY_VERIFY_GC(pGC,stuff->gc, client, DixWriteAccess); result = SetDashes(pGC, stuff->dashOffset, stuff->nDashes, (unsigned char *)&stuff[1]); @@ -1660,7 +1658,7 @@ ProcSetClipRectangles(register ClientPtr client) client->errorValue = stuff->ordering; return BadValue; } - SECURITY_VERIFY_GC(pGC,stuff->gc, client, SecurityWriteAccess); + SECURITY_VERIFY_GC(pGC,stuff->gc, client, DixWriteAccess); nr = (client->req_len << 2) - sizeof(xSetClipRectanglesReq); if (nr & 4) @@ -1681,7 +1679,7 @@ ProcFreeGC(register ClientPtr client) REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); - SECURITY_VERIFY_GC(pGC, stuff->id, client, SecurityDestroyAccess); + SECURITY_VERIFY_GC(pGC, stuff->id, client, DixDestroyAccess); FreeResource(stuff->id, RT_NONE); return(client->noClientException); } @@ -1694,7 +1692,7 @@ ProcClearToBackground(register ClientPtr client) REQUEST_SIZE_MATCH(xClearAreaReq); pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - SecurityWriteAccess); + DixWriteAccess); if (!pWin) return(BadWindow); if (pWin->drawable.class == InputOnly) @@ -1728,7 +1726,7 @@ ProcCopyArea(register ClientPtr client) if (stuff->dstDrawable != stuff->srcDrawable) { SECURITY_VERIFY_DRAWABLE(pSrc, stuff->srcDrawable, client, - SecurityReadAccess); + DixReadAccess); if ((pDst->pScreen != pSrc->pScreen) || (pDst->depth != pSrc->depth)) { client->errorValue = stuff->dstDrawable; @@ -1748,7 +1746,7 @@ ProcCopyArea(register ClientPtr client) (*pDst->pScreen->SendGraphicsExpose) (client, pRgn, stuff->dstDrawable, X_CopyArea, 0); if (pRgn) - REGION_DESTROY(pDst->pScreen, pRgn); + RegionDestroy(pRgn); } return(client->noClientException); @@ -1768,7 +1766,7 @@ ProcCopyPlane(register ClientPtr client) if (stuff->dstDrawable != stuff->srcDrawable) { SECURITY_VERIFY_DRAWABLE(psrcDraw, stuff->srcDrawable, client, - SecurityReadAccess); + DixReadAccess); if (pdstDraw->pScreen != psrcDraw->pScreen) { client->errorValue = stuff->dstDrawable; @@ -1796,7 +1794,7 @@ ProcCopyPlane(register ClientPtr client) (*pdstDraw->pScreen->SendGraphicsExpose) (client, pRgn, stuff->dstDrawable, X_CopyPlane, 0); if (pRgn) - REGION_DESTROY(pdstDraw->pScreen, pRgn); + RegionDestroy(pRgn); } return(client->noClientException); } @@ -2071,7 +2069,9 @@ ProcPutImage(register ClientPtr client) tmpImage = (char *)&stuff[1]; lengthProto = length; - + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) + return BadLength; + if (((((lengthProto * stuff->height) + (unsigned)3) >> 2) + (sizeof(xPutImageReq) >> 2)) != client->req_len) return BadLength; @@ -2109,7 +2109,9 @@ DoGetImage(register ClientPtr client, int format, Drawable drawable, client->errorValue = format; return(BadValue); } - SECURITY_VERIFY_DRAWABLE(pDraw, drawable, client, SecurityReadAccess); + SECURITY_VERIFY_DRAWABLE(pDraw, drawable, client, DixReadAccess); + + memset(&xgi, 0, sizeof(xGetImageReply)); if(pDraw->type == DRAWABLE_WINDOW) { if( /* check for being viewable */ @@ -2163,7 +2165,7 @@ DoGetImage(register ClientPtr client, int format, Drawable drawable, xgi.length = length; if (im_return) { - pBuf = (char *)xalloc(sz_xGetImageReply + length); + pBuf = (char *)calloc(1, sz_xGetImageReply + length); if (!pBuf) return (BadAlloc); if (widthBytesLine == 0) @@ -2201,8 +2203,9 @@ DoGetImage(register ClientPtr client, int format, Drawable drawable, length += widthBytesLine; } } - if(!(pBuf = (char *) ALLOCATE_LOCAL(length))) + if(!(pBuf = (char *) malloc(length))) return (BadAlloc); + memset(pBuf, 0, length); WriteReplyToClient(client, sizeof (xGetImageReply), &xgi); } @@ -2213,7 +2216,7 @@ DoGetImage(register ClientPtr client, int format, Drawable drawable, pVisibleRegion = NotClippedByChildren((WindowPtr)pDraw); if (pVisibleRegion) { - REGION_TRANSLATE(pDraw->pScreen, pVisibleRegion, -pDraw->x, -pDraw->y); + RegionTranslate(pVisibleRegion, -pDraw->x, -pDraw->y); } } #endif @@ -2235,7 +2238,7 @@ DoGetImage(register ClientPtr client, int format, Drawable drawable, nlines, format, planemask, - (pointer) pBuf); + (void *) pBuf); #ifdef XCSECURITY if (pVisibleRegion) SecurityCensorImage(client, pVisibleRegion, widthBytesLine, @@ -2252,7 +2255,7 @@ DoGetImage(register ClientPtr client, int format, Drawable drawable, ClientOrder(client)); /* Don't split me, gcc pukes when you do */ - (void)WriteToClient(client, + WriteToClient(client, (int)(nlines * widthBytesLine), pBuf); } @@ -2276,7 +2279,7 @@ DoGetImage(register ClientPtr client, int format, Drawable drawable, nlines, format, plane, - (pointer)pBuf); + (void *)pBuf); #ifdef XCSECURITY if (pVisibleRegion) SecurityCensorImage(client, pVisibleRegion, @@ -2296,7 +2299,7 @@ DoGetImage(register ClientPtr client, int format, Drawable drawable, ClientOrder (client)); /* Don't split me, gcc pukes when you do */ - (void)WriteToClient(client, + WriteToClient(client, (int)(nlines * widthBytesLine), pBuf); } @@ -2307,10 +2310,10 @@ DoGetImage(register ClientPtr client, int format, Drawable drawable, } #ifdef XCSECURITY if (pVisibleRegion) - REGION_DESTROY(pDraw->pScreen, pVisibleRegion); + RegionDestroy(pVisibleRegion); #endif if (!im_return) - DEALLOCATE_LOCAL(pBuf); + free(pBuf); return (client->noClientException); } @@ -2438,7 +2441,7 @@ ProcCreateColormap(register ClientPtr client) mid = stuff->mid; LEGAL_NEW_RESOURCE(mid, client); pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - SecurityReadAccess); + DixReadAccess); if (!pWin) return(BadWindow); @@ -2468,7 +2471,7 @@ ProcFreeColormap(register ClientPtr client) REQUEST_SIZE_MATCH(xResourceReq); pmap = (ColormapPtr )SecurityLookupIDByType(client, stuff->id, RT_COLORMAP, - SecurityDestroyAccess); + DixDestroyAccess); if (pmap) { /* Freeing a default colormap is a no-op */ @@ -2496,7 +2499,7 @@ ProcCopyColormapAndFree(register ClientPtr client) mid = stuff->mid; LEGAL_NEW_RESOURCE(mid, client); if( (pSrcMap = (ColormapPtr )SecurityLookupIDByType(client, stuff->srcCmap, - RT_COLORMAP, SecurityReadAccess|SecurityWriteAccess)) ) + RT_COLORMAP, DixReadAccess|DixWriteAccess)) ) { result = CopyColormapAndFree(mid, pSrcMap, client->index); if (client->noClientException != Success) @@ -2519,7 +2522,7 @@ ProcInstallColormap(register ClientPtr client) REQUEST_SIZE_MATCH(xResourceReq); pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->id, - RT_COLORMAP, SecurityReadAccess); + RT_COLORMAP, DixReadAccess); if (pcmp) { (*(pcmp->pScreen->InstallColormap)) (pcmp); @@ -2540,7 +2543,7 @@ ProcUninstallColormap(register ClientPtr client) REQUEST_SIZE_MATCH(xResourceReq); pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->id, - RT_COLORMAP, SecurityReadAccess); + RT_COLORMAP, DixReadAccess); if (pcmp) { if(pcmp->mid != pcmp->pScreen->defColormap) @@ -2564,13 +2567,13 @@ ProcListInstalledColormaps(register ClientPtr client) REQUEST_SIZE_MATCH(xResourceReq); pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client, - SecurityReadAccess); + DixReadAccess); if (!pWin) return(BadWindow); preply = (xListInstalledColormapsReply *) - ALLOCATE_LOCAL(sizeof(xListInstalledColormapsReply) + + malloc(sizeof(xListInstalledColormapsReply) + pWin->drawable.pScreen->maxInstalledCmaps * sizeof(Colormap)); if(!preply) @@ -2585,7 +2588,7 @@ ProcListInstalledColormaps(register ClientPtr client) WriteReplyToClient(client, sizeof (xListInstalledColormapsReply), preply); client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write; WriteSwappedDataToClient(client, nummaps * sizeof(Colormap), &preply[1]); - DEALLOCATE_LOCAL(preply); + free(preply); return(client->noClientException); } @@ -2599,18 +2602,10 @@ ProcAllocColor (register ClientPtr client) REQUEST_SIZE_MATCH(xAllocColorReq); pmap = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap, - RT_COLORMAP, SecurityWriteAccess); + RT_COLORMAP, DixWriteAccess); if (pmap) { -#ifdef LBX - /* - * If the colormap is grabbed by a proxy, the server will have - * to regain control over the colormap. This AllocColor request - * will be handled after the server gets back the colormap control. - */ - if (LbxCheckColorRequest (client, pmap, (xReq *) stuff)) - return Success; -#endif + memset(&acr, 0, sizeof(xAllocColorReply)); acr.type = X_Reply; acr.length = 0; acr.sequenceNumber = client->sequence; @@ -2648,22 +2643,13 @@ ProcAllocNamedColor (register ClientPtr client) REQUEST_FIXED_SIZE(xAllocNamedColorReq, stuff->nbytes); pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap, - RT_COLORMAP, SecurityWriteAccess); + RT_COLORMAP, DixWriteAccess); if (pcmp) { int retval; xAllocNamedColorReply ancr; -#ifdef LBX - /* - * If the colormap is grabbed by a proxy, the server will have - * to regain control over the colormap. This AllocNamedColor request - * will be handled after the server gets back the colormap control. - */ - if (LbxCheckColorRequest (client, pcmp, (xReq *) stuff)) - return Success; -#endif ancr.type = X_Reply; ancr.length = 0; ancr.sequenceNumber = client->sequence; @@ -2709,7 +2695,7 @@ ProcAllocColorCells (register ClientPtr client) REQUEST_SIZE_MATCH(xAllocColorCellsReq); pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap, - RT_COLORMAP, SecurityWriteAccess); + RT_COLORMAP, DixWriteAccess); if (pcmp) { xAllocColorCellsReply accr; @@ -2717,15 +2703,6 @@ ProcAllocColorCells (register ClientPtr client) long length; Pixel *ppixels, *pmasks; -#ifdef LBX - /* - * If the colormap is grabbed by a proxy, the server will have - * to regain control over the colormap. This AllocColorCells request - * will be handled after the server gets back the colormap control. - */ - if (LbxCheckColorRequest (client, pcmp, (xReq *) stuff)) - return Success; -#endif npixels = stuff->colors; if (!npixels) { @@ -2739,7 +2716,7 @@ ProcAllocColorCells (register ClientPtr client) } nmasks = stuff->planes; length = ((long)npixels + (long)nmasks) * sizeof(Pixel); - ppixels = (Pixel *)ALLOCATE_LOCAL(length); + ppixels = (Pixel *)malloc(length); if(!ppixels) return(BadAlloc); pmasks = ppixels + npixels; @@ -2747,7 +2724,7 @@ ProcAllocColorCells (register ClientPtr client) if( (retval = AllocColorCells(client->index, pcmp, npixels, nmasks, (Bool)stuff->contiguous, ppixels, pmasks)) ) { - DEALLOCATE_LOCAL(ppixels); + free(ppixels); if (client->noClientException != Success) return(client->noClientException); else @@ -2766,7 +2743,7 @@ ProcAllocColorCells (register ClientPtr client) client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write; WriteSwappedDataToClient(client, length, ppixels); } - DEALLOCATE_LOCAL(ppixels); + free(ppixels); return (client->noClientException); } else @@ -2784,7 +2761,7 @@ ProcAllocColorPlanes(register ClientPtr client) REQUEST_SIZE_MATCH(xAllocColorPlanesReq); pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap, - RT_COLORMAP, SecurityWriteAccess); + RT_COLORMAP, DixWriteAccess); if (pcmp) { xAllocColorPlanesReply acpr; @@ -2792,15 +2769,6 @@ ProcAllocColorPlanes(register ClientPtr client) long length; Pixel *ppixels; -#ifdef LBX - /* - * If the colormap is grabbed by a proxy, the server will have - * to regain control over the colormap. This AllocColorPlanes request - * will be handled after the server gets back the colormap control. - */ - if (LbxCheckColorRequest (client, pcmp, (xReq *) stuff)) - return Success; -#endif npixels = stuff->colors; if (!npixels) { @@ -2816,7 +2784,7 @@ ProcAllocColorPlanes(register ClientPtr client) acpr.sequenceNumber = client->sequence; acpr.nPixels = npixels; length = (long)npixels * sizeof(Pixel); - ppixels = (Pixel *)ALLOCATE_LOCAL(length); + ppixels = (Pixel *)malloc(length); if(!ppixels) return(BadAlloc); if( (retval = AllocColorPlanes(client->index, pcmp, npixels, @@ -2824,7 +2792,7 @@ ProcAllocColorPlanes(register ClientPtr client) (Bool)stuff->contiguous, ppixels, &acpr.redMask, &acpr.greenMask, &acpr.blueMask)) ) { - DEALLOCATE_LOCAL(ppixels); + free(ppixels); if (client->noClientException != Success) return(client->noClientException); else @@ -2839,7 +2807,7 @@ ProcAllocColorPlanes(register ClientPtr client) client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write; WriteSwappedDataToClient(client, length, ppixels); } - DEALLOCATE_LOCAL(ppixels); + free(ppixels); return (client->noClientException); } else @@ -2857,7 +2825,7 @@ ProcFreeColors(register ClientPtr client) REQUEST_AT_LEAST_SIZE(xFreeColorsReq); pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap, - RT_COLORMAP, SecurityWriteAccess); + RT_COLORMAP, DixWriteAccess); if (pcmp) { int count; @@ -2892,7 +2860,7 @@ ProcStoreColors (ClientPtr client) REQUEST_AT_LEAST_SIZE(xStoreColorsReq); pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap, - RT_COLORMAP, SecurityWriteAccess); + RT_COLORMAP, DixWriteAccess); if (pcmp) { int count; @@ -2926,7 +2894,7 @@ ProcStoreNamedColor (register ClientPtr client) REQUEST_FIXED_SIZE(xStoreNamedColorReq, stuff->nbytes); pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap, - RT_COLORMAP, SecurityWriteAccess); + RT_COLORMAP, DixWriteAccess); if (pcmp) { xColorItem def; @@ -2960,7 +2928,7 @@ ProcQueryColors(register ClientPtr client) REQUEST_AT_LEAST_SIZE(xQueryColorsReq); pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap, - RT_COLORMAP, SecurityReadAccess); + RT_COLORMAP, DixReadAccess); if (pcmp) { int count, retval; @@ -2968,12 +2936,13 @@ ProcQueryColors(register ClientPtr client) xQueryColorsReply qcr; count = ((client->req_len << 2) - sizeof(xQueryColorsReq)) >> 2; - prgbs = (xrgb *)ALLOCATE_LOCAL(count * sizeof(xrgb)); + prgbs = (xrgb *)malloc(count * sizeof(xrgb)); if(!prgbs && count) return(BadAlloc); + memset(prgbs, 0, count * sizeof(xrgb)); if( (retval = QueryColors(pcmp, count, (Pixel *)&stuff[1], prgbs)) ) { - if (prgbs) DEALLOCATE_LOCAL(prgbs); + if (prgbs) free(prgbs); if (client->noClientException != Success) return(client->noClientException); else @@ -2982,6 +2951,8 @@ ProcQueryColors(register ClientPtr client) return (retval); } } + + memset(&qcr, 0, sizeof(xQueryColorsReply)); qcr.type = X_Reply; qcr.length = (count * sizeof(xrgb)) >> 2; qcr.sequenceNumber = client->sequence; @@ -2992,7 +2963,7 @@ ProcQueryColors(register ClientPtr client) client->pSwapReplyFunc = (ReplySwapPtr) SQColorsExtend; WriteSwappedDataToClient(client, count * sizeof(xrgb), prgbs); } - if (prgbs) DEALLOCATE_LOCAL(prgbs); + if (prgbs) free(prgbs); return(client->noClientException); } @@ -3011,7 +2982,7 @@ ProcLookupColor(register ClientPtr client) REQUEST_FIXED_SIZE(xLookupColorReq, stuff->nbytes); pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap, - RT_COLORMAP, SecurityReadAccess); + RT_COLORMAP, DixReadAccess); if (pcmp) { xLookupColorReply lcr; @@ -3061,9 +3032,9 @@ ProcCreateCursor (register ClientPtr client) LEGAL_NEW_RESOURCE(stuff->cid, client); src = (PixmapPtr)SecurityLookupIDByType(client, stuff->source, - RT_PIXMAP, SecurityReadAccess); + RT_PIXMAP, DixReadAccess); msk = (PixmapPtr)SecurityLookupIDByType(client, stuff->mask, - RT_PIXMAP, SecurityReadAccess); + RT_PIXMAP, DixReadAccess); if ( src == (PixmapPtr)NULL) { client->errorValue = stuff->source; @@ -3091,20 +3062,20 @@ ProcCreateCursor (register ClientPtr client) return (BadMatch); n = BitmapBytePad(width)*height; - srcbits = (unsigned char *)xalloc(n); + srcbits = (unsigned char *)malloc(n); if (!srcbits) return (BadAlloc); - mskbits = (unsigned char *)xalloc(n); + mskbits = (unsigned char *)malloc(n); if (!mskbits) { - xfree(srcbits); + free(srcbits); return (BadAlloc); } /* zeroing the (pad) bits helps some ddx cursor handling */ bzero((char *)srcbits, n); (* src->drawable.pScreen->GetImage)( (DrawablePtr)src, 0, 0, width, height, - XYPixmap, 1, (pointer)srcbits); + XYPixmap, 1, (void *)srcbits); if ( msk == (PixmapPtr)NULL) { register unsigned char *bits = mskbits; @@ -3116,7 +3087,7 @@ ProcCreateCursor (register ClientPtr client) /* zeroing the (pad) bits helps some ddx cursor handling */ bzero((char *)mskbits, n); (* msk->drawable.pScreen->GetImage)( (DrawablePtr)msk, 0, 0, width, - height, XYPixmap, 1, (pointer)mskbits); + height, XYPixmap, 1, (void *)mskbits); } cm.width = width; cm.height = height; @@ -3126,7 +3097,7 @@ ProcCreateCursor (register ClientPtr client) stuff->foreRed, stuff->foreGreen, stuff->foreBlue, stuff->backRed, stuff->backGreen, stuff->backBlue); - if (pCursor && AddResource(stuff->cid, RT_CURSOR, (pointer)pCursor)) + if (pCursor && AddResource(stuff->cid, RT_CURSOR, (void *)pCursor)) return (client->noClientException); return BadAlloc; } @@ -3149,7 +3120,7 @@ ProcCreateGlyphCursor (register ClientPtr client) &pCursor, client); if (res != Success) return res; - if (AddResource(stuff->cid, RT_CURSOR, (pointer)pCursor)) + if (AddResource(stuff->cid, RT_CURSOR, (void *)pCursor)) return client->noClientException; return BadAlloc; } @@ -3163,7 +3134,7 @@ ProcFreeCursor (register ClientPtr client) REQUEST_SIZE_MATCH(xResourceReq); pCursor = (CursorPtr)SecurityLookupIDByType(client, stuff->id, - RT_CURSOR, SecurityDestroyAccess); + RT_CURSOR, DixDestroyAccess); if (pCursor) { FreeResource(stuff->id, RT_NONE); @@ -3193,12 +3164,13 @@ ProcQueryBestSize (register ClientPtr client) return(BadValue); } SECURITY_VERIFY_GEOMETRABLE (pDraw, stuff->drawable, client, - SecurityReadAccess); + DixReadAccess); if (stuff->class != CursorShape && pDraw->type == UNDRAWABLE_WINDOW) return (BadMatch); pScreen = pDraw->pScreen; (* pScreen->QueryBestSize)(stuff->class, &stuff->width, &stuff->height, pScreen); + memset(&reply, 0, sizeof(xQueryBestSizeReply)); reply.type = X_Reply; reply.length = 0; reply.sequenceNumber = client->sequence; @@ -3209,6 +3181,7 @@ ProcQueryBestSize (register ClientPtr client) } +#ifndef NXAGENT_SERVER int ProcSetScreenSaver (register ClientPtr client) { @@ -3264,6 +3237,7 @@ ProcSetScreenSaver (register ClientPtr client) SetScreenSaverTimer(); return (client->noClientException); } +#endif /* NXAGENT_SERVER */ int ProcGetScreenSaver(register ClientPtr client) @@ -3292,10 +3266,10 @@ ProcChangeHosts(register ClientPtr client) if(stuff->mode == HostInsert) result = AddHost(client, (int)stuff->hostFamily, - stuff->hostLength, (pointer)&stuff[1]); + stuff->hostLength, (void *)&stuff[1]); else if (stuff->mode == HostDelete) result = RemoveHost(client, (int)stuff->hostFamily, - stuff->hostLength, (pointer)&stuff[1]); + stuff->hostLength, (void *)&stuff[1]); else { client->errorValue = stuff->mode; @@ -3311,7 +3285,7 @@ ProcListHosts(register ClientPtr client) { xListHostsReply reply; int len, nHosts, result; - pointer pdata; + void * pdata; /* REQUEST(xListHostsReq); */ REQUEST_SIZE_MATCH(xListHostsReq); @@ -3336,7 +3310,7 @@ ProcListHosts(register ClientPtr client) client->pSwapReplyFunc = (ReplySwapPtr) SLHostsExtend; WriteSwappedDataToClient(client, len, pdata); } - xfree(pdata); + free(pdata); return (client->noClientException); } @@ -3399,7 +3373,6 @@ ProcSetFontPath(register ClientPtr client) unsigned long nbytes, total; long nfonts; int n, result; - int error; REQUEST(xSetFontPathReq); REQUEST_AT_LEAST_SIZE(xSetFontPathReq); @@ -3417,13 +3390,9 @@ ProcSetFontPath(register ClientPtr client) } if (total >= 4) return(BadLength); - result = SetFontPath(client, stuff->nFonts, (unsigned char *)&stuff[1], - &error); + result = SetFontPath(client, stuff->nFonts, (unsigned char *)&stuff[1]); if (!result) - { result = client->noClientException; - client->errorValue = error; - } return (result); } @@ -3445,7 +3414,7 @@ ProcGetFontPath(register ClientPtr client) WriteReplyToClient(client, sizeof(xGetFontPathReply), &reply); if (stringLens || numpaths) - (void)WriteToClient(client, stringLens + numpaths, (char *)bufferStart); + WriteToClient(client, stringLens + numpaths, bufferStart); return(client->noClientException); } @@ -3469,6 +3438,7 @@ ProcChangeCloseDownMode(register ClientPtr client) } } +#ifndef NXAGENT_SERVER int ProcForceScreenSaver(register ClientPtr client) { REQUEST(xForceScreenSaverReq); @@ -3484,6 +3454,7 @@ int ProcForceScreenSaver(register ClientPtr client) SaveScreens(SCREEN_SAVER_FORCER, (int)stuff->mode); return client->noClientException; } +#endif /* NXAGENT_SERVER */ int ProcNoOperation(register ClientPtr client) { @@ -3504,12 +3475,6 @@ InitProcVectors(void) ProcVector[i] = SwappedProcVector[i] = ProcBadRequest; ReplySwapVector[i] = ReplyNotSwappd; } -#ifdef K5AUTH - if (!k5_Vector[i]) - { - k5_Vector[i] = k5_bad; - } -#endif } for(i = LASTEvent; i < 128; i++) { @@ -3518,6 +3483,7 @@ InitProcVectors(void) } + /********************** * CloseDownClient * @@ -3525,6 +3491,7 @@ InitProcVectors(void) * then killed again, the client is really destroyed. *********************/ +#ifndef NXAGENT_SERVER char dispatchExceptionAtReset = DE_RESET; void @@ -3563,16 +3530,13 @@ CloseDownClient(register ClientPtr client) clientinfo.client = client; clientinfo.prefix = (xConnSetupPrefix *)NULL; clientinfo.setup = (xConnSetup *) NULL; - CallCallbacks((&ClientStateCallback), (pointer)&clientinfo); + CallCallbacks((&ClientStateCallback), (void *)&clientinfo); } } client->clientGone = TRUE; /* so events aren't sent to client */ if (ClientIsAsleep(client)) ClientSignal (client); ProcessWorkQueueZombies(); -#ifdef LBX - ProcessQTagZombies(); -#endif CloseDownConnection(client); /* If the client made it to the Running stage, nClients has @@ -3600,21 +3564,23 @@ CloseDownClient(register ClientPtr client) clientinfo.client = client; clientinfo.prefix = (xConnSetupPrefix *)NULL; clientinfo.setup = (xConnSetup *) NULL; - CallCallbacks((&ClientStateCallback), (pointer)&clientinfo); + CallCallbacks((&ClientStateCallback), (void *)&clientinfo); } FreeClientResources(client); + /* Disable client ID tracking. This must be done after + * ClientStateCallback. */ + ReleaseClientIds(client); if (client->index < nextFreeClientID) nextFreeClientID = client->index; clients[client->index] = NullClient; -#ifdef SMART_SCHEDULE SmartLastClient = NullClient; -#endif - xfree(client); + free(client); while (!clients[currentMaxClients-1]) currentMaxClients--; } } +#endif /* NXAGENT_SERVER */ static void KillAllClients() @@ -3650,26 +3616,13 @@ CloseDownRetainedResources() } } -void InitClient(ClientPtr client, int i, pointer ospriv) +void InitClient(ClientPtr client, int i, void * ospriv) { client->index = i; client->sequence = 0; client->clientAsMask = ((Mask)i) << CLIENTOFFSET; client->clientGone = FALSE; - if (i) - { - client->closeDownMode = DestroyAll; - client->lastDrawable = (DrawablePtr)WindowTable[0]; - client->lastDrawableID = WindowTable[0]->drawable.id; - } - else - { - client->closeDownMode = RetainPermanent; - client->lastDrawable = (DrawablePtr)NULL; - client->lastDrawableID = INVALID; - } - client->lastGC = (GCPtr) NULL; - client->lastGCID = INVALID; + client->closeDownMode = i ? DestroyAll : RetainPermanent; client->numSaved = 0; client->saveSet = (SaveSetElt *)NULL; client->noClientException = Success; @@ -3690,30 +3643,24 @@ void InitClient(ClientPtr client, int i, pointer ospriv) } #endif client->replyBytesRemaining = 0; -#ifdef LBX - client->readRequest = StandardReadRequestFromClient; -#endif #ifdef XCSECURITY client->trustLevel = XSecurityClientTrusted; client->CheckAccess = NULL; client->authId = 0; #endif -#ifdef XAPPGROUP - client->appgroup = NULL; -#endif client->fontResFunc = NULL; -#ifdef SMART_SCHEDULE client->smart_priority = 0; client->smart_start_tick = SmartScheduleTime; client->smart_stop_tick = SmartScheduleTime; client->smart_check_tick = SmartScheduleTime; -#endif + client->clientIds = NULL; } extern int clientPrivateLen; extern unsigned *clientPrivateSizes; extern unsigned totalClientSize; +#ifndef NXAGENT_SERVER int InitClientPrivates(ClientPtr client) { @@ -3729,7 +3676,7 @@ InitClientPrivates(ClientPtr client) ppriv = (DevUnion *)(client + 1); else { - ppriv = (DevUnion *)xalloc(totalClientSize - sizeof(ClientRec)); + ppriv = (DevUnion *)malloc(totalClientSize - sizeof(ClientRec)); if (!ppriv) return 0; } @@ -3740,14 +3687,15 @@ InitClientPrivates(ClientPtr client) { if ( (size = *sizes) ) { - ppriv->ptr = (pointer)ptr; + ppriv->ptr = (void *)ptr; ptr += size; } else - ppriv->ptr = (pointer)NULL; + ppriv->ptr = (void *)NULL; } return 1; } +#endif /* NXAGENT_SERVER */ /************************ * int NextAvailableClient(ospriv) @@ -3756,7 +3704,7 @@ InitClientPrivates(ClientPtr client) * Returns NULL if there are no free clients. *************************/ -ClientPtr NextAvailableClient(pointer ospriv) +ClientPtr NextAvailableClient(void * ospriv) { register int i; register ClientPtr client; @@ -3765,14 +3713,14 @@ ClientPtr NextAvailableClient(pointer ospriv) i = nextFreeClientID; if (i == MAXCLIENTS) return (ClientPtr)NULL; - clients[i] = client = (ClientPtr)xalloc(totalClientSize); + clients[i] = client = (ClientPtr)malloc(totalClientSize); if (!client) return (ClientPtr)NULL; InitClient(client, i, ospriv); InitClientPrivates(client); if (!InitClientResources(client)) { - xfree(client); + free(client); return (ClientPtr)NULL; } data.reqType = 1; @@ -3780,13 +3728,18 @@ ClientPtr NextAvailableClient(pointer ospriv) if (!InsertFakeRequest(client, (char *)&data, sz_xReq)) { FreeClientResources(client); - xfree(client); + free(client); return (ClientPtr)NULL; } if (i == currentMaxClients) currentMaxClients++; while ((nextFreeClientID < MAXCLIENTS) && clients[nextFreeClientID]) nextFreeClientID++; + + /* Enable client ID tracking. This must be done before + * ClientStateCallback. */ + ReserveClientIds(client); + if (ClientStateCallback) { NewClientInfoRec clientinfo; @@ -3794,7 +3747,7 @@ ClientPtr NextAvailableClient(pointer ospriv) clientinfo.client = client; clientinfo.prefix = (xConnSetupPrefix *)NULL; clientinfo.setup = (xConnSetup *) NULL; - CallCallbacks((&ClientStateCallback), (pointer)&clientinfo); + CallCallbacks((&ClientStateCallback), (void *)&clientinfo); } return(client); } @@ -3805,12 +3758,14 @@ ProcInitialConnection(register ClientPtr client) REQUEST(xReq); register xConnClientPrefix *prefix; int whichbyte = 1; + char order; prefix = (xConnClientPrefix *)((char *)stuff + sz_xReq); - if ((prefix->byteOrder != 'l') && (prefix->byteOrder != 'B')) + order = prefix->byteOrder; + if (order != 'l' && order != 'B' && order != 'r' && order != 'R') return (client->noClientException = -1); - if (((*(char *) &whichbyte) && (prefix->byteOrder == 'B')) || - (!(*(char *) &whichbyte) && (prefix->byteOrder == 'l'))) + if (((*(char *) &whichbyte) && (order == 'B' || order == 'R')) || + (!(*(char *) &whichbyte) && (order == 'l' || order == 'r'))) { client->swapped = TRUE; SwapConnClientPrefix(prefix); @@ -3820,20 +3775,16 @@ ProcInitialConnection(register ClientPtr client) ((prefix->nbytesAuthString + (unsigned)3) >> 2); if (client->swapped) { - swaps(&stuff->length, whichbyte); + swaps(&stuff->length); + } + if (order == 'r' || order == 'R') + { + client->local = FALSE; } ResetCurrentRequest(client); return (client->noClientException); } -#ifdef LBX -void -IncrementClientCount() -{ - nClients++; -} -#endif - int SendConnSetup(register ClientPtr client, char *reason) { @@ -3847,6 +3798,7 @@ SendConnSetup(register ClientPtr client, char *reason) { xConnSetupPrefix csp; + memset(&csp, 0, sizeof(xConnSetupPrefix)); csp.success = xFalse; csp.lengthReason = strlen(reason); csp.length = (csp.lengthReason + (unsigned)3) >> 2; @@ -3855,8 +3807,8 @@ SendConnSetup(register ClientPtr client, char *reason) if (client->swapped) WriteSConnSetupPrefix(client, &csp); else - (void)WriteToClient(client, sz_xConnSetupPrefix, (char *) &csp); - (void)WriteToClient(client, (int)csp.lengthReason, reason); + WriteToClient(client, sz_xConnSetupPrefix, &csp); + WriteToClient(client, (int)csp.lengthReason, reason); return (client->noClientException = -1); } @@ -3873,9 +3825,6 @@ SendConnSetup(register ClientPtr client, char *reason) client->requestVector = client->swapped ? SwappedProcVector : ProcVector; client->sequence = 0; -#ifdef XAPPGROUP - XagConnectionInfo (client, &lconnSetupPrefix, &lConnectionInfo, &numScreens); -#endif ((xConnSetup *)lConnectionInfo)->ridBase = client->clientAsMask; ((xConnSetup *)lConnectionInfo)->ridMask = RESOURCE_ID_MASK; #ifdef MATCH_CLIENT_ENDIAN @@ -3896,8 +3845,8 @@ SendConnSetup(register ClientPtr client, char *reason) register unsigned int j; register xDepth *pDepth; - root->currentInputMask = WindowTable[i]->eventMask | - wOtherEventMasks (WindowTable[i]); + root->currentInputMask = screenInfo.screens[i]->root->eventMask | + wOtherEventMasks (screenInfo.screens[i]->root); pDepth = (xDepth *)(root + 1); for (j = 0; j < root->nDepths; j++) { @@ -3916,9 +3865,9 @@ SendConnSetup(register ClientPtr client, char *reason) } else { - (void)WriteToClient(client, sizeof(xConnSetupPrefix), + WriteToClient(client, sizeof(xConnSetupPrefix), (char *) lconnSetupPrefix); - (void)WriteToClient(client, (int)(lconnSetupPrefix->length << 2), + WriteToClient(client, (int)(lconnSetupPrefix->length << 2), lConnectionInfo); } client->clientState = ClientStateRunning; @@ -3929,7 +3878,7 @@ SendConnSetup(register ClientPtr client, char *reason) clientinfo.client = client; clientinfo.prefix = lconnSetupPrefix; clientinfo.setup = (xConnSetup *)lConnectionInfo; - CallCallbacks((&ClientStateCallback), (pointer)&clientinfo); + CallCallbacks((&ClientStateCallback), (void *)&clientinfo); } return (client->noClientException); } @@ -3974,8 +3923,8 @@ SendErrorToClient(ClientPtr client, unsigned majorCode, unsigned minorCode, { xError rep; + memset(&rep, 0, sizeof(xError)); rep.type = X_Error; - rep.sequenceNumber = client->sequence; rep.errorCode = errorCode; rep.majorCode = majorCode; rep.minorCode = minorCode; @@ -4033,3 +3982,220 @@ MarkClientException(ClientPtr client) { client->noClientException = -1; } + +/* + * This array encodes the answer to the question "what is the log base 2 + * of the number of pixels that fit in a scanline pad unit?" + * Note that ~0 is an invalid entry (mostly for the benefit of the reader). + */ +static int answer[6][4] = { + /* pad pad pad pad*/ + /* 8 16 32 64 */ + + { 3, 4, 5 , 6 }, /* 1 bit per pixel */ + { 1, 2, 3 , 4 }, /* 4 bits per pixel */ + { 0, 1, 2 , 3 }, /* 8 bits per pixel */ + { ~0, 0, 1 , 2 }, /* 16 bits per pixel */ + { ~0, ~0, 0 , 1 }, /* 24 bits per pixel */ + { ~0, ~0, 0 , 1 } /* 32 bits per pixel */ +}; + +/* + * This array gives the bytesperPixel value for cases where the number + * of bits per pixel is a multiple of 8 but not a power of 2. + */ +static int answerBytesPerPixel[ 33 ] = { + ~0, 0, ~0, ~0, /* 1 bit per pixel */ + 0, ~0, ~0, ~0, /* 4 bits per pixel */ + 0, ~0, ~0, ~0, /* 8 bits per pixel */ + ~0,~0, ~0, ~0, + 0, ~0, ~0, ~0, /* 16 bits per pixel */ + ~0,~0, ~0, ~0, + 3, ~0, ~0, ~0, /* 24 bits per pixel */ + ~0,~0, ~0, ~0, + 0 /* 32 bits per pixel */ +}; + +/* + * This array gives the answer to the question "what is the first index for + * the answer array above given the number of bits per pixel?" + * Note that ~0 is an invalid entry (mostly for the benefit of the reader). + */ +static int indexForBitsPerPixel[ 33 ] = { + ~0, 0, ~0, ~0, /* 1 bit per pixel */ + 1, ~0, ~0, ~0, /* 4 bits per pixel */ + 2, ~0, ~0, ~0, /* 8 bits per pixel */ + ~0,~0, ~0, ~0, + 3, ~0, ~0, ~0, /* 16 bits per pixel */ + ~0,~0, ~0, ~0, + 4, ~0, ~0, ~0, /* 24 bits per pixel */ + ~0,~0, ~0, ~0, + 5 /* 32 bits per pixel */ +}; + +/* + * This array gives the answer to the question "what is the second index for + * the answer array above given the number of bits per scanline pad unit?" + * Note that ~0 is an invalid entry (mostly for the benefit of the reader). + */ +static int indexForScanlinePad[ 65 ] = { + ~0, ~0, ~0, ~0, + ~0, ~0, ~0, ~0, + 0, ~0, ~0, ~0, /* 8 bits per scanline pad unit */ + ~0, ~0, ~0, ~0, + 1, ~0, ~0, ~0, /* 16 bits per scanline pad unit */ + ~0, ~0, ~0, ~0, + ~0, ~0, ~0, ~0, + ~0, ~0, ~0, ~0, + 2, ~0, ~0, ~0, /* 32 bits per scanline pad unit */ + ~0, ~0, ~0, ~0, + ~0, ~0, ~0, ~0, + ~0, ~0, ~0, ~0, + ~0, ~0, ~0, ~0, + ~0, ~0, ~0, ~0, + ~0, ~0, ~0, ~0, + ~0, ~0, ~0, ~0, + 3 /* 64 bits per scanline pad unit */ +}; + +#ifndef MIN +#define MIN(a,b) (((a) < (b)) ? (a) : (b)) +#endif + +static int init_screen(ScreenPtr pScreen, int i) +{ + int scanlinepad, format, depth, bitsPerPixel, j, k; +#ifdef DEBUG + void (**jNI) (); +#endif /* DEBUG */ + + pScreen->myNum = i; + pScreen->WindowPrivateLen = 0; + pScreen->WindowPrivateSizes = (unsigned *)NULL; + pScreen->totalWindowSize = + ((sizeof(WindowRec) + sizeof(long) - 1) / sizeof(long)) * sizeof(long); + pScreen->GCPrivateLen = 0; + pScreen->GCPrivateSizes = (unsigned *)NULL; + pScreen->totalGCSize = + ((sizeof(GC) + sizeof(long) - 1) / sizeof(long)) * sizeof(long); +#ifdef PIXPRIV + pScreen->PixmapPrivateLen = 0; + pScreen->PixmapPrivateSizes = (unsigned *)NULL; + pScreen->totalPixmapSize = BitmapBytePad(sizeof(PixmapRec)*8); +#endif + pScreen->ClipNotify = 0; /* for R4 ddx compatibility */ + pScreen->CreateScreenResources = 0; + +#ifdef DEBUG + for (jNI = &pScreen->QueryBestSize; + jNI < (void (**) ()) &pScreen->SendGraphicsExpose; + jNI++) + *jNI = NotImplemented; +#endif /* DEBUG */ + + /* + * This loop gets run once for every Screen that gets added, + * but thats ok. If the ddx layer initializes the formats + * one at a time calling AddScreen() after each, then each + * iteration will make it a little more accurate. Worst case + * we do this loop N * numPixmapFormats where N is # of screens. + * Anyway, this must be called after InitOutput and before the + * screen init routine is called. + */ + for (format=0; format<screenInfo.numPixmapFormats; format++) + { + depth = screenInfo.formats[format].depth; + bitsPerPixel = screenInfo.formats[format].bitsPerPixel; + scanlinepad = screenInfo.formats[format].scanlinePad; + j = indexForBitsPerPixel[ bitsPerPixel ]; + k = indexForScanlinePad[ scanlinepad ]; + PixmapWidthPaddingInfo[ depth ].padPixelsLog2 = answer[j][k]; + PixmapWidthPaddingInfo[ depth ].padRoundUp = + (scanlinepad/bitsPerPixel) - 1; + j = indexForBitsPerPixel[ 8 ]; /* bits per byte */ + PixmapWidthPaddingInfo[ depth ].padBytesLog2 = answer[j][k]; + PixmapWidthPaddingInfo[ depth ].bitsPerPixel = bitsPerPixel; + if (answerBytesPerPixel[bitsPerPixel]) + { + PixmapWidthPaddingInfo[ depth ].notPower2 = 1; + PixmapWidthPaddingInfo[ depth ].bytesPerPixel = + answerBytesPerPixel[bitsPerPixel]; + } + else + { + PixmapWidthPaddingInfo[ depth ].notPower2 = 0; + } + } + return 0; +} + +void FreeScreen(ScreenPtr); + +/* + grow the array of screenRecs if necessary. + call the device-supplied initialization procedure + with its screen number, a pointer to its ScreenRec, argc, and argv. + return the number of successfully installed screens. +*/ + +int +AddScreen(Bool (*pfnInit) (ScreenPtr /*pScreen */ , + int /*argc */ , + char ** /*argv */ + ), int argc, char **argv) +{ + + int i; + ScreenPtr pScreen; + Bool ret; + + i = screenInfo.numScreens; + if (i == MAXSCREENS) + return -1; + + pScreen = (ScreenPtr) calloc(1, sizeof(ScreenRec)); + if (!pScreen) + return -1; + + pScreen->devPrivates = (DevUnion *)calloc(sizeof(DevUnion), + screenPrivateCount); + if (!pScreen->devPrivates && screenPrivateCount) + return -1; + + ret = init_screen(pScreen, i); + if (ret != 0) { + free(pScreen); + return ret; + } + /* This is where screen specific stuff gets initialized. Load the + screen structure, call the hardware, whatever. + This is also where the default colormap should be allocated and + also pixel values for blackPixel, whitePixel, and the cursor + Note that InitScreen is NOT allowed to modify argc, argv, or + any of the strings pointed to by argv. They may be passed to + multiple screens. + */ + pScreen->rgf = ~0L; /* there are no scratch GCs yet*/ + screenInfo.screens[i] = pScreen; + screenInfo.numScreens++; + if (!(*pfnInit)(pScreen, argc, argv)) + { + FreeScreen(pScreen); + screenInfo.numScreens--; + return -1; + } + return i; +} + +void +FreeScreen(ScreenPtr pScreen) +{ + pScreen->root = NullWindow; + free(pScreen->WindowPrivateSizes); + free(pScreen->GCPrivateSizes); +#ifdef PIXPRIV + free(pScreen->PixmapPrivateSizes); +#endif + free(pScreen->devPrivates); + free(pScreen); +} diff --git a/nx-X11/programs/Xserver/dix/dispatch.h b/nx-X11/programs/Xserver/dix/dispatch.h index 89ea2dd7e..dd07096af 100644 --- a/nx-X11/programs/Xserver/dix/dispatch.h +++ b/nx-X11/programs/Xserver/dix/dispatch.h @@ -1,4 +1,3 @@ -/* $XFree86: xc/programs/Xserver/dix/dispatch.h,v 3.2 2001/08/01 00:44:48 tsi Exp $ */ /************************************************************ Copyright 1996 by Thomas E. Dickey <dickey@clark.net> diff --git a/nx-X11/programs/Xserver/dix/dixfonts.c b/nx-X11/programs/Xserver/dix/dixfonts.c index b66fe23bd..98d2a6439 100644 --- a/nx-X11/programs/Xserver/dix/dixfonts.c +++ b/nx-X11/programs/Xserver/dix/dixfonts.c @@ -1,5 +1,3 @@ -/* $XdotOrg: xc/programs/Xserver/dix/dixfonts.c,v 1.8 2005/07/03 08:53:38 daniels Exp $ */ -/* $XFree86: xc/programs/Xserver/dix/dixfonts.c,v 3.28 2003/11/08 02:02:03 dawes Exp $ */ /************************************************************************ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. @@ -49,107 +47,56 @@ dealings in this Software without prior written authorization from Digital Equipment Corporation. ******************************************************************/ -/* $Xorg: dixfonts.c,v 1.4 2000/08/17 19:48:18 cpqbld Exp $ */ -#define NEED_REPLIES #ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> #endif -#include <X11/X.h> -#include <X11/Xmd.h> -#include <X11/Xproto.h> +#include <nx-X11/X.h> +#include <nx-X11/Xmd.h> +#include <nx-X11/Xproto.h> #include "scrnintstr.h" #include "resource.h" #include "dixstruct.h" #include "cursorstr.h" +#include "list.h" #include "misc.h" #include "opaque.h" #include "dixfontstr.h" #include "closestr.h" +#ifdef HAS_XFONT2 +# include <X11/fonts/libxfont2.h> +#endif /* HAS_XFONT2 */ #ifdef DEBUG #include <stdio.h> #endif -#ifdef NX_TRANS_SOCKET - -char _NXFontPath[1024]; - -/* - * Override the default font path and make - * it configurable at run time, based on - * the NX_FONT environment. - */ - -static const char *_NXGetFontPath(const char *path) -{ - const char *fontEnv; - - /* - * Check the environment only once. - */ - - if (*_NXFontPath != '\0') - { - return _NXFontPath; - } - - fontEnv = getenv("NX_FONT"); - - if (fontEnv != NULL && *fontEnv != '\0') - { - if (strlen(fontEnv) + 1 > 1024) - { -#ifdef NX_TRANS_TEST - fprintf(stderr, "_NXGetFontPath: WARNING! Maximum length of font path exceeded.\n"); -#endif - goto _NXGetFontPathError; - } - - strcpy(_NXFontPath, fontEnv); - -#ifdef NX_TRANS_TEST - fprintf(stderr, "_NXGetFontPath: Using NX font path [%s].\n", _NXFontPath); -#endif - - return _NXFontPath; - } - -_NXGetFontPathError: - - strcpy(_NXFontPath, path); - -#ifdef NX_TRANS_TEST - fprintf(stderr, "_NXGetFontPath: Using default font path [%s].\n", _NXFontPath); -#endif - - return _NXFontPath; -} - -#endif - #ifdef PANORAMIX #include "panoramiX.h" #endif -#ifdef LBX -#include "lbxserve.h" -#endif - #ifdef XF86BIGFONT #define _XF86BIGFONT_SERVER_ -#include <X11/extensions/xf86bigfont.h> +#include <nx-X11/extensions/xf86bigfont.h> #endif #define QUERYCHARINFO(pci, pr) *(pr) = (pci)->metrics -extern pointer fosNaturalParams; +#ifndef HAS_XFONT2 +extern void register_fpe_functions(void); +#endif + +extern void * fosNaturalParams; extern FontPtr defaultFont; static FontPathElementPtr *font_path_elements = (FontPathElementPtr *) 0; static int num_fpes = 0; +#ifdef HAS_XFONT2 +xfont2_fpe_funcs_rec const **fpe_functions; +#else FPEFunctions *fpe_functions = (FPEFunctions *) 0; +#endif static int num_fpe_types = 0; static unsigned char *font_path_string; @@ -157,7 +104,11 @@ static unsigned char *font_path_string; static int num_slept_fpes = 0; static int size_slept_fpes = 0; static FontPathElementPtr *slept_fpes = (FontPathElementPtr *) 0; +#ifdef HAS_XFONT2 +xfont2_pattern_cache_ptr patternCache; +#else static FontPatternCachePtr patternCache; +#endif /* HAS_FONT2 */ int FontToXError(err) @@ -229,7 +180,7 @@ QueueFontWakeup(FontPathElementPtr fpe) } if (num_slept_fpes == size_slept_fpes) { new = (FontPathElementPtr *) - xrealloc(slept_fpes, + realloc(slept_fpes, sizeof(FontPathElementPtr) * (size_slept_fpes + 4)); if (!new) return; @@ -258,7 +209,7 @@ RemoveFontWakeup(FontPathElementPtr fpe) } void -FontWakeup(pointer data, int count, pointer LastSelectMask) +FontWakeup(void * data, int count, void * LastSelectMask) { int i; FontPathElementPtr fpe; @@ -268,7 +219,11 @@ FontWakeup(pointer data, int count, pointer LastSelectMask) /* wake up any fpe's that may be waiting for information */ for (i = 0; i < num_slept_fpes; i++) { fpe = slept_fpes[i]; +#ifdef HAS_XFONT2 + (void) (*fpe_functions[fpe->type]->wakeup_fpe) (fpe); +#else (void) (*fpe_functions[fpe->type].wakeup_fpe) (fpe, LastSelectMask); +#endif /* HAS_XFONT2 */ } } @@ -284,12 +239,17 @@ FreeFPE (FontPathElementPtr fpe) { fpe->refcount--; if (fpe->refcount == 0) { +#ifdef HAS_XFONT2 + (*fpe_functions[fpe->type]->free_fpe) (fpe); +#else (*fpe_functions[fpe->type].free_fpe) (fpe); - xfree(fpe->name); - xfree(fpe); +#endif + free(fpe->name); + free(fpe); } } +#ifndef NXAGENT_SERVER static Bool doOpenFont(ClientPtr client, OFclosurePtr c) { @@ -338,15 +298,23 @@ doOpenFont(ClientPtr client, OFclosurePtr c) if (c->current_fpe < c->num_fpes) { fpe = c->fpe_list[c->current_fpe]; - (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); +#ifdef HAS_XFONT2 + (*fpe_functions[fpe->type]->client_died) ((void *) client, fpe); +#else + (*fpe_functions[fpe->type].client_died) ((void *) client, fpe); +#endif /* HAS_XFONT2 */ } err = Successful; goto bail; } while (c->current_fpe < c->num_fpes) { fpe = c->fpe_list[c->current_fpe]; +#ifdef HAS_XFONT2 + err = (*fpe_functions[fpe->type]->open_font) +#else err = (*fpe_functions[fpe->type].open_font) - ((pointer) client, fpe, c->flags, +#endif /* HAS_XFONT2 */ + ((void *) client, fpe, c->flags, c->fontname, c->fnamelen, FontFormat, BitmapFormatMaskByte | BitmapFormatMaskBit | @@ -360,7 +328,7 @@ doOpenFont(ClientPtr client, OFclosurePtr c) if (err == FontNameAlias && alias) { newlen = strlen(alias); - newname = (char *) xrealloc(c->fontname, newlen); + newname = (char *) realloc(c->fontname, newlen); if (!newname) { err = AllocError; break; @@ -380,7 +348,7 @@ doOpenFont(ClientPtr client, OFclosurePtr c) if (err == Suspended) { if (!c->slept) { c->slept = TRUE; - ClientSleep(client, (ClientSleepProcPtr)doOpenFont, (pointer) c); + ClientSleep(client, (ClientSleepProcPtr)doOpenFont, (void *) c); } return TRUE; } @@ -418,12 +386,16 @@ doOpenFont(ClientPtr client, OFclosurePtr c) } } } - if (!AddResource(c->fontid, RT_FONT, (pointer) pfont)) { + if (!AddResource(c->fontid, RT_FONT, (void *) pfont)) { err = AllocError; goto bail; } if (patternCache && pfont != c->non_cachable_font) +#ifdef HAS_XFONT2 + xfont2_cache_font_pattern(patternCache, c->origFontName, c->origFontNameLen, +#else CacheFontPattern(patternCache, c->origFontName, c->origFontNameLen, +#endif /* HAS_XFONT2 */ pfont); bail: if (err != Successful && c->client != serverClient) { @@ -435,11 +407,12 @@ bail: for (i = 0; i < c->num_fpes; i++) { FreeFPE(c->fpe_list[i]); } - xfree(c->fpe_list); - xfree(c->fontname); - xfree(c); + free(c->fpe_list); + free(c->fontname); + free(c); return TRUE; } +#endif /* NXAGENT_SERVER */ int OpenFont(ClientPtr client, XID fid, Mask flags, unsigned lenfname, char *pfontname) @@ -450,11 +423,11 @@ OpenFont(ClientPtr client, XID fid, Mask flags, unsigned lenfname, char *pfontna #ifdef FONTDEBUG char *f; - f = (char *)xalloc(lenfname + 1); + f = (char *)malloc(lenfname + 1); memmove(f, pfontname, lenfname); f[lenfname] = '\0'; ErrorF("OpenFont: fontname is \"%s\"\n", f); - xfree(f); + free(f); #endif if (!lenfname || lenfname > XLFDMAXFONTNAMELEN) return BadName; @@ -478,23 +451,27 @@ OpenFont(ClientPtr client, XID fid, Mask flags, unsigned lenfname, char *pfontna ** having to create another instance of a font that already exists. */ +#ifdef HAS_XFONT2 + cached = xfont2_find_cached_font_pattern(patternCache, pfontname, lenfname); +#else cached = FindCachedFontPattern(patternCache, pfontname, lenfname); +#endif /* HAS_XFONT2 */ if (cached && cached->info.cachable) { - if (!AddResource(fid, RT_FONT, (pointer) cached)) + if (!AddResource(fid, RT_FONT, (void *) cached)) return BadAlloc; cached->refcnt++; return Success; } } - c = (OFclosurePtr) xalloc(sizeof(OFclosureRec)); + c = (OFclosurePtr) malloc(sizeof(OFclosureRec)); if (!c) return BadAlloc; - c->fontname = (char *) xalloc(lenfname); + c->fontname = (char *) malloc(lenfname); c->origFontName = pfontname; c->origFontNameLen = lenfname; if (!c->fontname) { - xfree(c); + free(c); return BadAlloc; } /* @@ -502,10 +479,10 @@ OpenFont(ClientPtr client, XID fid, Mask flags, unsigned lenfname, char *pfontna * while we're blocking, the request still appears atomic */ c->fpe_list = (FontPathElementPtr *) - xalloc(sizeof(FontPathElementPtr) * num_fpes); + malloc(sizeof(FontPathElementPtr) * num_fpes); if (!c->fpe_list) { - xfree(c->fontname); - xfree(c); + free(c->fontname); + free(c); return BadAlloc; } memmove(c->fontname, pfontname, lenfname); @@ -532,7 +509,7 @@ OpenFont(ClientPtr client, XID fid, Mask flags, unsigned lenfname, char *pfontna * \param value must conform to DeleteType */ int -CloseFont(pointer value, XID fid) +CloseFont(void * value, XID fid) { int nscr; ScreenPtr pscr; @@ -543,7 +520,11 @@ CloseFont(pointer value, XID fid) return (Success); if (--pfont->refcnt == 0) { if (patternCache) +#ifdef HAS_XFONT2 + xfont2_remove_cached_font_pattern(patternCache, pfont); +#else RemoveCachedFontPattern (patternCache, pfont); +#endif /* HAS_XFONT2 */ /* * since the last reference is gone, ask each screen to free any * storage it may have allocated locally for it. @@ -555,14 +536,15 @@ CloseFont(pointer value, XID fid) } if (pfont == defaultFont) defaultFont = NULL; -#ifdef LBX - LbxFreeFontTag(pfont); -#endif #ifdef XF86BIGFONT XF86BigfontFreeFontShm(pfont); #endif fpe = pfont->fpe; +#ifdef HAS_XFONT2 + (*fpe_functions[fpe->type]->close_font) (fpe, pfont); +#else (*fpe_functions[fpe->type].close_font) (fpe, pfont); +#endif FreeFPE(fpe); } return (Success); @@ -639,6 +621,7 @@ QueryFont(FontPtr pFont, xQueryFontReply *pReply, int nProtoCCIStructs) return; } +#ifndef NXAGENT_SERVER static Bool doListFontsAndAliases(ClientPtr client, LFclosurePtr c) { @@ -660,7 +643,11 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) if (c->current.current_fpe < c->num_fpes) { fpe = c->fpe_list[c->current.current_fpe]; - (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); +#ifdef HAS_XFONT2 + (*fpe_functions[fpe->type]->client_died) ((void *) client, fpe); +#else + (*fpe_functions[fpe->type].client_died) ((void *) client, fpe); +#endif /* HAS_XFONT2 */ } err = Successful; goto bail; @@ -673,12 +660,20 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) fpe = c->fpe_list[c->current.current_fpe]; err = Successful; +#ifdef HAS_XFONT2 + if (!fpe_functions[fpe->type]->start_list_fonts_and_aliases) +#else if (!fpe_functions[fpe->type].start_list_fonts_and_aliases) +#endif /* HAS_XFONT2 */ { /* This FPE doesn't support/require list_fonts_and_aliases */ +#ifdef HAS_XFONT2 + err = (*fpe_functions[fpe->type]->list_fonts) +#else err = (*fpe_functions[fpe->type].list_fonts) - ((pointer) c->client, fpe, c->current.pattern, +#endif /* HAS_XFONT2 */ + ((void *) c->client, fpe, c->current.pattern, c->current.patlen, c->current.max_names - c->names->nnames, c->names); @@ -687,7 +682,7 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) c->slept = TRUE; ClientSleep(client, (ClientSleepProcPtr)doListFontsAndAliases, - (pointer) c); + (void *) c); } return TRUE; } @@ -706,15 +701,19 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) the FPEs. */ if (!c->current.list_started) { +#ifdef HAS_XFONT2 + err = (*fpe_functions[fpe->type]->start_list_fonts_and_aliases) +#else err = (*fpe_functions[fpe->type].start_list_fonts_and_aliases) - ((pointer) c->client, fpe, c->current.pattern, +#endif /* HAS_XFONT2 */ + ((void *) c->client, fpe, c->current.pattern, c->current.patlen, c->current.max_names - c->names->nnames, &c->current.private); if (err == Suspended) { if (!c->slept) { ClientSleep(client, (ClientSleepProcPtr)doListFontsAndAliases, - (pointer) c); + (void *) c); c->slept = TRUE; } return TRUE; @@ -725,21 +724,25 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) if (err == Successful) { char *tmpname; name = 0; +#ifdef HAS_XFONT2 + err = (*fpe_functions[fpe->type]->list_next_font_or_alias) +#else err = (*fpe_functions[fpe->type].list_next_font_or_alias) - ((pointer) c->client, fpe, &name, &namelen, &tmpname, +#endif /* HAS_XFONT2 */ + ((void *) c->client, fpe, &name, &namelen, &tmpname, &resolvedlen, c->current.private); if (err == Suspended) { if (!c->slept) { ClientSleep(client, (ClientSleepProcPtr)doListFontsAndAliases, - (pointer) c); + (void *) c); c->slept = TRUE; } return TRUE; } if (err == FontNameAlias) { - if (resolved) xfree(resolved); - resolved = (char *) xalloc(resolvedlen + 1); + if (resolved) free(resolved); + resolved = (char *) malloc(resolvedlen + 1); if (resolved) memmove(resolved, tmpname, resolvedlen + 1); } @@ -750,11 +753,19 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) if (c->haveSaved) { if (c->savedName) +#ifdef HAS_XFONT2 + (void)xfont2_add_font_names_name(c->names, c->savedName, +#else (void)AddFontNamesName(c->names, c->savedName, +#endif /* HAS_XFONT2 */ c->savedNameLen); } else +#ifdef HAS_XFONT2 + (void)xfont2_add_font_names_name(c->names, name, namelen); +#else (void)AddFontNamesName(c->names, name, namelen); +#endif /* HAS_XFONT2 */ } /* @@ -779,8 +790,12 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) int tmpnamelen; tmpname = 0; +#ifdef HAS_XFONT2 + (void) (*fpe_functions[fpe->type]->list_next_font_or_alias) +#else (void) (*fpe_functions[fpe->type].list_next_font_or_alias) - ((pointer) c->client, fpe, &tmpname, &tmpnamelen, +#endif /* HAS_XFONT2 */ + ((void *) c->client, fpe, &tmpname, &tmpnamelen, &tmpname, &tmpnamelen, c->current.private); if (--aliascount <= 0) { @@ -793,8 +808,8 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) c->saved = c->current; c->haveSaved = TRUE; if (c->savedName) - xfree(c->savedName); - c->savedName = (char *)xalloc(namelen + 1); + free(c->savedName); + c->savedName = (char *)malloc(namelen + 1); if (c->savedName) memmove(c->savedName, name, namelen + 1); c->savedNameLen = namelen; @@ -850,12 +865,13 @@ finish: for (i = 0; i < nnames; i++) stringLens += (names->length[i] <= 255) ? names->length[i] : 0; + memset(&reply, 0, sizeof(xListFontsReply)); reply.type = X_Reply; reply.length = (stringLens + nnames + 3) >> 2; reply.nFonts = nnames; reply.sequenceNumber = client->sequence; - bufptr = bufferStart = (char *) ALLOCATE_LOCAL(reply.length << 2); + bufptr = bufferStart = (char *) malloc(reply.length << 2); if (!bufptr && reply.length) { SendErrorToClient(client, X_ListFonts, 0, 0, BadAlloc); @@ -879,19 +895,23 @@ finish: reply.length = (stringLens + nnames + 3) >> 2; client->pSwapReplyFunc = ReplySwapVector[X_ListFonts]; WriteSwappedDataToClient(client, sizeof(xListFontsReply), &reply); - (void) WriteToClient(client, stringLens + nnames, bufferStart); - DEALLOCATE_LOCAL(bufferStart); + WriteToClient(client, stringLens + nnames, bufferStart); + free(bufferStart); bail: if (c->slept) ClientWakeup(client); for (i = 0; i < c->num_fpes; i++) FreeFPE(c->fpe_list[i]); - xfree(c->fpe_list); - if (c->savedName) xfree(c->savedName); + free(c->fpe_list); + if (c->savedName) free(c->savedName); +#ifdef HAS_XFONT2 + xfont2_free_font_names(names); +#else FreeFontNames(names); - xfree(c); - if (resolved) xfree(resolved); +#endif /* HAS_XFONT2 */ + free(c); + if (resolved) free(resolved); return TRUE; } @@ -911,19 +931,23 @@ ListFonts(ClientPtr client, unsigned char *pattern, unsigned length, if (length > XLFDMAXFONTNAMELEN) return BadAlloc; - if (!(c = (LFclosurePtr) xalloc(sizeof *c))) + if (!(c = (LFclosurePtr) malloc(sizeof *c))) return BadAlloc; c->fpe_list = (FontPathElementPtr *) - xalloc(sizeof(FontPathElementPtr) * num_fpes); + malloc(sizeof(FontPathElementPtr) * num_fpes); if (!c->fpe_list) { - xfree(c); + free(c); return BadAlloc; } +#ifdef HAS_XFONT2 + c->names = xfont2_make_font_names_record(max_names < 100 ? max_names : 100); +#else c->names = MakeFontNamesRecord(max_names < 100 ? max_names : 100); +#endif /* HAS_XFONT2 */ if (!c->names) { - xfree(c->fpe_list); - xfree(c); + free(c->fpe_list); + free(c); return BadAlloc; } memmove( c->current.pattern, pattern, length); @@ -967,7 +991,11 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c) if (c->current.current_fpe < c->num_fpes) { fpe = c->fpe_list[c->current.current_fpe]; - (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); +#ifdef HAS_XFONT2 + (*fpe_functions[fpe->type]->client_died) ((void *) client, fpe); +#else + (*fpe_functions[fpe->type].client_died) ((void *) client, fpe); +#endif /* HAS_XFONT2 */ } err = Successful; goto bail; @@ -981,7 +1009,11 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c) err = Successful; if (!c->current.list_started) { +#ifdef HAS_XFONT2 + err = (*fpe_functions[fpe->type]->start_list_fonts_with_info) +#else err = (*fpe_functions[fpe->type].start_list_fonts_with_info) +#endif /* HAS_XFONT2 */ (client, fpe, c->current.pattern, c->current.patlen, c->current.max_names, &c->current.private); if (err == Suspended) @@ -1000,7 +1032,11 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c) { name = 0; pFontInfo = &fontInfo; +#ifdef HAS_XFONT2 + err = (*fpe_functions[fpe->type]->list_next_font_with_info) +#else err = (*fpe_functions[fpe->type].list_next_font_with_info) +#endif /* HAS_XFONT2 */ (client, fpe, &name, &namelen, &pFontInfo, &numFonts, c->current.private); if (err == Suspended) @@ -1037,7 +1073,11 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c) tmpname = 0; tmpFontInfo = &fontInfo; - (void) (*fpe_functions[fpe->type].list_next_font_with_info) +#ifdef HAS_XFONT2 + (void) (*fpe_functions[fpe->type]->list_next_font_with_info) +#else + (void) (*fpe_functions[fpe->type].list_next_font_with_info) +#endif /* HAS_XFONT2 */ (client, fpe, &tmpname, &tmpnamelen, &tmpFontInfo, &numFonts, c->current.private); if (--aliascount <= 0) @@ -1052,8 +1092,8 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c) c->haveSaved = TRUE; c->savedNumFonts = numFonts; if (c->savedName) - xfree(c->savedName); - c->savedName = (char *)xalloc(namelen + 1); + free(c->savedName); + c->savedName = (char *)malloc(namelen + 1); if (c->savedName) memmove(c->savedName, name, namelen + 1); aliascount = 20; @@ -1096,12 +1136,13 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c) reply = c->reply; if (c->length < length) { - reply = (xListFontsWithInfoReply *) xrealloc(c->reply, length); + reply = (xListFontsWithInfoReply *) realloc(c->reply, length); if (!reply) { err = AllocError; break; } + memset(reply + c->length, 0, length - c->length); c->reply = reply; c->length = length; } @@ -1138,11 +1179,11 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c) pFP++; } WriteSwappedDataToClient(client, length, reply); - (void) WriteToClient(client, namelen, name); + WriteToClient(client, namelen, name); if (pFontInfo == &fontInfo) { - xfree(fontInfo.props); - xfree(fontInfo.isStringProp); + free(fontInfo.props); + free(fontInfo.isStringProp); } --c->current.max_names; } @@ -1160,12 +1201,13 @@ bail: ClientWakeup(client); for (i = 0; i < c->num_fpes; i++) FreeFPE(c->fpe_list[i]); - xfree(c->reply); - xfree(c->fpe_list); - if (c->savedName) xfree(c->savedName); - xfree(c); + free(c->reply); + free(c->fpe_list); + if (c->savedName) free(c->savedName); + free(c); return TRUE; } +#endif /* NXAGENT_SERVER */ int StartListFontsWithInfo(ClientPtr client, int length, unsigned char *pattern, @@ -1183,13 +1225,13 @@ StartListFontsWithInfo(ClientPtr client, int length, unsigned char *pattern, if (length > XLFDMAXFONTNAMELEN) return BadAlloc; - if (!(c = (LFWIclosurePtr) xalloc(sizeof *c))) + if (!(c = (LFWIclosurePtr) malloc(sizeof *c))) goto badAlloc; c->fpe_list = (FontPathElementPtr *) - xalloc(sizeof(FontPathElementPtr) * num_fpes); + malloc(sizeof(FontPathElementPtr) * num_fpes); if (!c->fpe_list) { - xfree(c); + free(c); goto badAlloc; } memmove(c->current.pattern, pattern, length); @@ -1235,7 +1277,11 @@ doPolyText(ClientPtr client, register PTclosurePtr c) if (client->clientGone) { fpe = c->pGC->font->fpe; - (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); +#ifdef HAS_XFONT2 + (*fpe_functions[fpe->type]->client_died) ((void *) client, fpe); +#else + (*fpe_functions[fpe->type].client_died) ((void *) client, fpe); +#endif /* HAS_XFONT2 */ if (c->slept) { @@ -1257,13 +1303,17 @@ doPolyText(ClientPtr client, register PTclosurePtr c) if (c->slept && c->pDraw && c->pDraw != (DrawablePtr)SecurityLookupIDByClass(client, c->did, - RC_DRAWABLE, SecurityWriteAccess)) + RC_DRAWABLE, DixWriteAccess)) { /* Our drawable has disappeared. Treat like client died... ask the FPE code to clean up after client and avoid further rendering while we clean up after ourself. */ fpe = c->pGC->font->fpe; - (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); +#ifdef HAS_XFONT2 + (*fpe_functions[fpe->type]->client_died) ((void *) client, fpe); +#else + (*fpe_functions[fpe->type].client_died) ((void *) client, fpe); +#endif /* HAS_XFONT2 */ c->pDraw = (DrawablePtr)0; } @@ -1287,7 +1337,7 @@ doPolyText(ClientPtr client, register PTclosurePtr c) | ((Font)*(c->pElt+2)) << 16 | ((Font)*(c->pElt+1)) << 24; pFont = (FontPtr)SecurityLookupIDByType(client, fid, RT_FONT, - SecurityReadAccess); + DixReadAccess); if (!pFont) { client->errorValue = fid; @@ -1373,7 +1423,7 @@ doPolyText(ClientPtr client, register PTclosurePtr c) /* Step 1 */ /* Allocate a malloc'd closure structure to replace the local one we were passed */ - new_closure = (PTclosurePtr) xalloc(sizeof(PTclosureRec)); + new_closure = (PTclosurePtr) malloc(sizeof(PTclosureRec)); if (!new_closure) { err = BadAlloc; @@ -1383,10 +1433,10 @@ doPolyText(ClientPtr client, register PTclosurePtr c) c = new_closure; len = c->endReq - c->pElt; - c->data = (unsigned char *)xalloc(len); + c->data = (unsigned char *)malloc(len); if (!c->data) { - xfree(c); + free(c); err = BadAlloc; goto bail; } @@ -1399,11 +1449,18 @@ doPolyText(ClientPtr client, register PTclosurePtr c) pGC = GetScratchGC(c->pGC->depth, c->pGC->pScreen); if (!pGC) { - xfree(c->data); - xfree(c); + free(c->data); + free(c); err = BadAlloc; goto bail; } + +#ifdef NXAGENT_SERVER + pGC->tileIsPixel = TRUE; + pGC->tile.pixel = 0; + pGC->stipple = NullPixmap; +#endif + if ((err = CopyGC(c->pGC, pGC, GCFunction | GCPlaneMask | GCForeground | GCBackground | GCFillStyle | @@ -1415,8 +1472,8 @@ doPolyText(ClientPtr client, register PTclosurePtr c) Success) { FreeScratchGC(pGC); - xfree(c->data); - xfree(c); + free(c->data); + free(c); err = BadAlloc; goto bail; } @@ -1427,7 +1484,7 @@ doPolyText(ClientPtr client, register PTclosurePtr c) c->slept = TRUE; ClientSleep(client, (ClientSleepProcPtr)doPolyText, - (pointer) c); + (void *) c); /* Set up to perform steps 3 and 4 */ client_state = START_SLEEP; @@ -1483,8 +1540,8 @@ bail: c->pGC->font = NullFont; FreeScratchGC(c->pGC); - xfree(c->data); - xfree(c); + free(c->data); + free(c); } return TRUE; } @@ -1533,7 +1590,11 @@ doImageText(ClientPtr client, register ITclosurePtr c) if (client->clientGone) { fpe = c->pGC->font->fpe; - (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); +#ifdef HAS_XFONT2 + (*fpe_functions[fpe->type]->client_died) ((void *) client, fpe); +#else + (*fpe_functions[fpe->type].client_died) ((void *) client, fpe); +#endif err = Success; goto bail; } @@ -1542,12 +1603,16 @@ doImageText(ClientPtr client, register ITclosurePtr c) if (c->slept && c->pDraw && c->pDraw != (DrawablePtr)SecurityLookupIDByClass(client, c->did, - RC_DRAWABLE, SecurityWriteAccess)) + RC_DRAWABLE, DixWriteAccess)) { /* Our drawable has disappeared. Treat like client died... ask the FPE code to clean up after client. */ fpe = c->pGC->font->fpe; - (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); +#ifdef HAS_XFONT2 + (*fpe_functions[fpe->type]->client_died) ((void *) client, fpe); +#else + (*fpe_functions[fpe->type].client_died) ((void *) client, fpe); +#endif /* HAS_XFONT2 */ err = Success; goto bail; } @@ -1559,25 +1624,28 @@ doImageText(ClientPtr client, register ITclosurePtr c) GC *pGC; unsigned char *data; ITclosurePtr new_closure; + ITclosurePtr old_closure; /* We're putting the client to sleep. We need to save some state. Similar problem to that handled in doPolyText, but much simpler because the request structure is much simpler. */ - new_closure = (ITclosurePtr) xalloc(sizeof(ITclosureRec)); + new_closure = (ITclosurePtr) malloc(sizeof(ITclosureRec)); if (!new_closure) { err = BadAlloc; goto bail; } + old_closure = c; *new_closure = *c; c = new_closure; - data = (unsigned char *)xalloc(c->nChars * c->itemSize); + data = (unsigned char *)malloc(c->nChars * c->itemSize); if (!data) { - xfree(c); + free(c); + c = old_closure; err = BadAlloc; goto bail; } @@ -1587,11 +1655,19 @@ doImageText(ClientPtr client, register ITclosurePtr c) pGC = GetScratchGC(c->pGC->depth, c->pGC->pScreen); if (!pGC) { - xfree(c->data); - xfree(c); + free(c->data); + free(c); + c = old_closure; err = BadAlloc; goto bail; } + +#ifdef NXAGENT_SERVER + pGC->tileIsPixel = TRUE; + pGC->tile.pixel = 0; + pGC->stipple = NullPixmap; +#endif + if ((err = CopyGC(c->pGC, pGC, GCFunction | GCPlaneMask | GCForeground | GCBackground | GCFillStyle | GCTile | GCStipple | GCTileStipXOrigin | @@ -1600,8 +1676,9 @@ doImageText(ClientPtr client, register ITclosurePtr c) GCClipYOrigin | GCClipMask)) != Success) { FreeScratchGC(pGC); - xfree(c->data); - xfree(c); + free(c->data); + free(c); + c = old_closure; err = BadAlloc; goto bail; } @@ -1609,7 +1686,7 @@ doImageText(ClientPtr client, register ITclosurePtr c) ValidateGC(c->pDraw, c->pGC); c->slept = TRUE; - ClientSleep(client, (ClientSleepProcPtr)doImageText, (pointer) c); + ClientSleep(client, (ClientSleepProcPtr)doImageText, (void *) c); } return TRUE; } @@ -1639,8 +1716,8 @@ bail: c->pGC->font = NullFont; FreeScratchGC(c->pGC); - xfree(c->data); - xfree(c); + free(c->data); + free(c); } return TRUE; } @@ -1683,7 +1760,11 @@ DetermineFPEType(char *pathname) int i; for (i = 0; i < num_fpe_types; i++) { +#ifdef HAS_XFONT2 + if ((*fpe_functions[i]->name_check) (pathname)) +#else if ((*fpe_functions[i].name_check) (pathname)) +#endif /* HAS_XFONT2 */ return i; } return -1; @@ -1714,7 +1795,7 @@ FreeFontPath(FontPathElementPtr *list, int n, Bool force) } FreeFPE(list[i]); } - xfree((char *) list); + free((char *) list); } static FontPathElementPtr @@ -1731,7 +1812,6 @@ find_existing_fpe(FontPathElementPtr *list, int num, unsigned char *name, int le return (FontPathElementPtr) 0; } - static int SetFontPathElements(int npaths, unsigned char *paths, int *bad, Bool persist) { @@ -1742,14 +1822,19 @@ SetFontPathElements(int npaths, unsigned char *paths, int *bad, Bool persist) FontPathElementPtr fpe = NULL, *fplist; fplist = (FontPathElementPtr *) - xalloc(sizeof(FontPathElementPtr) * npaths); + malloc(sizeof(FontPathElementPtr) * npaths); if (!fplist) { *bad = 0; return BadAlloc; } for (i = 0; i < num_fpe_types; i++) { +#ifdef HAS_XFONT2 + if (fpe_functions[i]->set_path_hook) + (*fpe_functions[i]->set_path_hook) (); +#else if (fpe_functions[i].set_path_hook) (*fpe_functions[i].set_path_hook) (); +#endif /* HAS_XFONT2 */ } for (i = 0; i < npaths; i++) { @@ -1771,7 +1856,11 @@ SetFontPathElements(int npaths, unsigned char *paths, int *bad, Bool persist) fpe = find_existing_fpe(font_path_elements, num_fpes, cp, len); if (fpe) { +#ifdef HAS_XFONT2 + err = (*fpe_functions[fpe->type]->reset_fpe) (fpe); +#else err = (*fpe_functions[fpe->type].reset_fpe) (fpe); +#endif /* HAS_XFONT2 */ if (err == Successful) { UseFPE(fpe);/* since it'll be decref'd later when freed @@ -1783,16 +1872,16 @@ SetFontPathElements(int npaths, unsigned char *paths, int *bad, Bool persist) /* if error or can't do it, act like it's a new one */ if (!fpe) { - fpe = (FontPathElementPtr) xalloc(sizeof(FontPathElementRec)); + fpe = (FontPathElementPtr) malloc(sizeof(FontPathElementRec)); if (!fpe) { err = BadAlloc; goto bail; } - fpe->name = (char *) xalloc(len + 1); + fpe->name = (char *) malloc(len + 1); if (!fpe->name) { - xfree(fpe); + free(fpe); err = BadAlloc; goto bail; } @@ -1805,16 +1894,22 @@ SetFontPathElements(int npaths, unsigned char *paths, int *bad, Bool persist) if (fpe->type == -1) err = BadValue; else +#ifdef HAS_XFONT2 + err = (*fpe_functions[fpe->type]->init_fpe) (fpe); +#else err = (*fpe_functions[fpe->type].init_fpe) (fpe); +#endif /* HAS_XFONT2 */ if (err != Successful) { +#ifndef NXAGENT_SERVER if (persist) { ErrorF("Could not init font path element %s, removing from list!\n", fpe->name); } - xfree (fpe->name); - xfree (fpe); +#endif /* NXAGENT_SERVER */ + free (fpe->name); + free (fpe); } } } @@ -1833,7 +1928,11 @@ SetFontPathElements(int npaths, unsigned char *paths, int *bad, Bool persist) FreeFontPath(font_path_elements, num_fpes, FALSE); font_path_elements = fplist; if (patternCache) +#ifdef HAS_XFONT2 + xfont2_empty_font_pattern_cache(patternCache); +#else EmptyFontPatternCache(patternCache); +#endif /* HAS_XFONT2 */ num_fpes = valid_paths; return Success; @@ -1841,13 +1940,12 @@ bail: *bad = i; while (--valid_paths >= 0) FreeFPE(fplist[valid_paths]); - xfree(fplist); + free(fplist); return FontToXError(err); } -/* XXX -- do we need to pass error down to each renderer? */ int -SetFontPath(ClientPtr client, int npaths, unsigned char *paths, int *error) +SetFontPath(ClientPtr client, int npaths, unsigned char *paths) { int err = Success; @@ -1855,14 +1953,20 @@ SetFontPath(ClientPtr client, int npaths, unsigned char *paths, int *error) if (SetDefaultFontPath(defaultFontPath) != Success) return BadValue; } else { - err = SetFontPathElements(npaths, paths, error, FALSE); + int bad; + err = SetFontPathElements(npaths, paths, &bad, FALSE); + client->errorValue = bad; } return err; } +#ifndef NXAGENT_SERVER int SetDefaultFontPath(char *path) { + char *temp_path, + *start, + *end; unsigned char *cp, *pp, *nump, @@ -1873,20 +1977,36 @@ SetDefaultFontPath(char *path) size = 0, bad; + /* ensure temp_path contains "built-ins" */ + start = path; + while (1) { + start = strstr(start, "built-ins"); + if (start == NULL) + break; + end = start + strlen("built-ins"); + if ((start == path || start[-1] == ',') && (!*end || *end == ',')) + break; + start = end; + } + if (!start) { + if (asprintf(&temp_path, "%s%sbuilt-ins", path, *path ? "," : "") + == -1) + temp_path = NULL; + } + else { + temp_path = strdup(path); + } + if (!temp_path) + return BadAlloc; + /* get enough for string, plus values -- use up commas */ -#ifdef NX_TRANS_SOCKET - len = strlen(_NXGetFontPath(path)) + 1; -#else - len = strlen(path) + 1; -#endif - nump = cp = newpath = (unsigned char *) ALLOCATE_LOCAL(len); - if (!newpath) + len = strlen(temp_path) + 1; + nump = cp = newpath = (unsigned char *) malloc(len); + if (!newpath) { + free(temp_path); return BadAlloc; -#ifdef NX_TRANS_SOCKET - pp = (unsigned char *) _NXGetFontPath(path); -#else - pp = (unsigned char *) path; -#endif + } + pp = (unsigned char *) temp_path; cp++; while (*pp) { if (*pp == ',') { @@ -1904,10 +2024,12 @@ SetDefaultFontPath(char *path) err = SetFontPathElements(num, newpath, &bad, TRUE); - DEALLOCATE_LOCAL(newpath); + free(newpath); + free(temp_path); return err; } +#endif /* NXAGENT_SERVER */ unsigned char * GetFontPath(int *count, int *length) @@ -1922,11 +2044,14 @@ GetFontPath(int *count, int *length) fpe = font_path_elements[i]; len += fpe->name_length + 1; } - font_path_string = (unsigned char *) xrealloc(font_path_string, len); - if (!font_path_string) + c = realloc(font_path_string, len); + if (c == NULL) { + free(font_path_string); + font_path_string = NULL; return NULL; + } - c = font_path_string; + font_path_string = c; *length = 0; for (i = 0; i < num_fpes; i++) { fpe = font_path_elements[i]; @@ -1942,14 +2067,36 @@ GetFontPath(int *count, int *length) int LoadGlyphs(ClientPtr client, FontPtr pfont, unsigned nchars, int item_size, unsigned char *data) { +#ifdef HAS_XFONT2 + if (fpe_functions[pfont->fpe->type]->load_glyphs) + return (*fpe_functions[pfont->fpe->type]->load_glyphs) +#else if (fpe_functions[pfont->fpe->type].load_glyphs) return (*fpe_functions[pfont->fpe->type].load_glyphs) +#endif (client, pfont, 0, nchars, item_size, data); else return Successful; } void +#ifdef HAS_XFONT2 +GetGlyphs(FontPtr font, unsigned long count, unsigned char *chars, + FontEncoding fontEncoding, + unsigned long *glyphcount, /* RETURN */ + CharInfoPtr *glyphs) /* RETURN */ +#else +dixGetGlyphs(FontPtr font, unsigned long count, unsigned char *chars, + FontEncoding fontEncoding, + unsigned long *glyphcount, /* RETURN */ + CharInfoPtr *glyphs) /* RETURN */ +#endif /* HAS_XFONT2 */ + { + (*font->get_glyphs) (font, count, chars, fontEncoding, glyphcount, glyphs); + } + + +void DeleteClientFontStuff(ClientPtr client) { int i; @@ -1958,43 +2105,74 @@ DeleteClientFontStuff(ClientPtr client) for (i = 0; i < num_fpes; i++) { fpe = font_path_elements[i]; +#ifdef HAS_XFONT2 + if (fpe_functions[fpe->type]->client_died) + (*fpe_functions[fpe->type]->client_died) ((void *) client, fpe); +#else if (fpe_functions[fpe->type].client_died) - (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); + (*fpe_functions[fpe->type].client_died) ((void *) client, fpe); +#endif /* HAS_XFONT2 */ } } +#ifdef HAS_XFONT2 +static int +register_fpe_funcs(const xfont2_fpe_funcs_rec *funcs) +{ + xfont2_fpe_funcs_rec const **new; + + /* grow the list */ + new = reallocarray(fpe_functions, num_fpe_types + 1, sizeof(xfont2_fpe_funcs_ptr)); + if (!new) + return -1; + fpe_functions = new; + + fpe_functions[num_fpe_types] = funcs; + + return num_fpe_types++; +} +#else void InitFonts () { patternCache = MakeFontPatternCache(); -#ifndef KDRIVESERVER - if (screenInfo.numScreens > screenInfo.numVideoScreens) { - PrinterFontRegisterFpeFunctions(); - FontFileCheckRegisterFpeFunctions(); - check_fs_register_fpe_functions(); - } else -#endif - { -#ifdef KDRIVESERVER - BuiltinRegisterFpeFunctions(); -#endif - FontFileRegisterFpeFunctions(); -#ifndef NOFONTSERVERACCESS - fs_register_fpe_functions(); -#endif - } + ResetFontPrivateIndex(); + + register_fpe_functions(); +} +#endif /* HAS_XFONT2 */ + +#ifdef HAS_XFONT2 +static unsigned long +get_server_generation(void) +{ + return serverGeneration; +} + +static void * +get_server_client(void) +{ + return serverClient; } +static int +get_default_point_size(void) +#else int GetDefaultPointSize () +#endif /* HAS_XFONT2 */ { return 120; } - +#ifdef HAS_XFONT2 +static FontResolutionPtr +get_client_resolutions(int *num) +#else FontResolutionPtr GetClientResolutions (int *num) +#endif /* HAS_XFONT2 */ { if (requestingClient && requestingClient->fontResFunc != NULL && !requestingClient->clientGone) @@ -2026,6 +2204,7 @@ GetClientResolutions (int *num) } } +#ifndef HAS_XFONT2 /* * returns the type index of the new fpe * @@ -2052,7 +2231,7 @@ RegisterFPEFunctions(NameCheckFunc name_func, FPEFunctions *new; /* grow the list */ - new = (FPEFunctions *) xrealloc(fpe_functions, + new = (FPEFunctions *) realloc(fpe_functions, (num_fpe_types + 1) * sizeof(FPEFunctions)); if (!new) return -1; @@ -2080,51 +2259,83 @@ RegisterFPEFunctions(NameCheckFunc name_func, return num_fpe_types++; } +#endif /* !HAS_XFONT2 */ void FreeFonts() { if (patternCache) { +#ifdef HAS_XFONT2 + xfont2_free_font_pattern_cache(patternCache); +#else FreeFontPatternCache(patternCache); +#endif /* HAS_XFONT2 */ patternCache = 0; } FreeFontPath(font_path_elements, num_fpes, TRUE); font_path_elements = 0; num_fpes = 0; - xfree(fpe_functions); + free(fpe_functions); num_fpe_types = 0; +#ifdef HAS_XFONT2 + fpe_functions = NULL; +#else fpe_functions = (FPEFunctions *) 0; +#endif /* HAS_XFONT2 */ } /* convenience functions for FS interface */ +#ifdef HAS_XFONT2 +static +#endif /* HAS_XFONT2 */ FontPtr find_old_font(XID id) { return (FontPtr) SecurityLookupIDByType(NullClient, id, RT_NONE, - SecurityUnknownAccess); + DixUnknownAccess); } +#ifdef HAS_XFONT2 +static Font +get_new_font_client_id(void) +#else Font GetNewFontClientID() +#endif /* HAS_XFONT2 */ { return FakeClientID(0); } +#ifdef HAS_XFONT2 +static int +store_font_Client_font(FontPtr pfont, Font id) +#else int StoreFontClientFont(FontPtr pfont, Font id) +#endif /* HAS_XFONT2 */ { - return AddResource(id, RT_NONE, (pointer) pfont); + return AddResource(id, RT_NONE, (void *) pfont); } +#ifdef HAS_XFONT2 +static void +delete_font_client_id(Font id) +#else void DeleteFontClientID(Font id) +#endif /* HAS_XFONT2 */ { FreeResource(id, RT_NONE); } +#ifdef HAS_XFONT2 +static int +_client_auth_generation(ClientPtr client) +#else int client_auth_generation(ClientPtr client) +#endif /* HAS_XFONT2 */ { return 0; } @@ -2132,8 +2343,78 @@ client_auth_generation(ClientPtr client) static int fs_handlers_installed = 0; static unsigned int last_server_gen; +#ifdef HAS_XFONT2 +static void +fs_block_handler(void *blockData, OSTimePtr timeout, void *readmask) +{ + FontBlockHandlerProcPtr block_handler = blockData; + + (*block_handler)(timeout); +} + +struct fs_fd_entry { + struct xorg_list entry; + int fd; + void *data; + FontFdHandlerProcPtr handler; +}; + +static void +fs_fd_handler(int fd, int ready, void *data) +{ + struct fs_fd_entry *entry = data; + + entry->handler(fd, entry->data); +} + +static struct xorg_list fs_fd_list; + +static int +add_fs_fd(int fd, FontFdHandlerProcPtr handler, void *data) +{ + struct fs_fd_entry *entry = calloc(1, sizeof (struct fs_fd_entry)); + + if (!entry) + return FALSE; + + entry->fd = fd; + entry->data = data; + entry->handler = handler; + if (!SetNotifyFd(fd, fs_fd_handler, X_NOTIFY_READ, entry)) { + free(entry); + return FALSE; + } + xorg_list_add(&entry->entry, &fs_fd_list); + return TRUE; +} + +static void +remove_fs_fd(int fd) +{ + struct fs_fd_entry *entry, *temp; + + xorg_list_for_each_entry_safe(entry, temp, &fs_fd_list, entry) { + if (entry->fd == fd) { + xorg_list_del(&entry->entry); + free(entry); + break; + } + } + RemoveNotifyFd(fd); +} + +static void +adjust_fs_wait_for_delay(void *wt, unsigned long newdelay) +{ + AdjustWaitForDelay(wt, newdelay); +} + +static int +_init_fs_handlers(FontPathElementPtr fpe, FontBlockHandlerProcPtr block_handler) +#else int init_fs_handlers(FontPathElementPtr fpe, BlockHandlerProcPtr block_handler) +#endif /* HAS_XFONT2 */ { /* if server has reset, make sure the b&w handlers are reinstalled */ if (last_server_gen < serverGeneration) { @@ -2146,17 +2427,30 @@ init_fs_handlers(FontPathElementPtr fpe, BlockHandlerProcPtr block_handler) fprintf(stderr, "adding FS b & w handlers\n"); #endif +#ifdef HAS_XFONT2 + if (!RegisterBlockAndWakeupHandlers(fs_block_handler, + FontWakeup, (void *) block_handler)) +#else if (!RegisterBlockAndWakeupHandlers(block_handler, - FontWakeup, (pointer) 0)) + FontWakeup, (void *) 0)) +#endif /* HAS_XFONT2 */ return AllocError; +#ifdef HAS_XFONT2 + xorg_list_init(&fs_fd_list); +#endif /* HAS_XFONT2 */ fs_handlers_installed++; } QueueFontWakeup(fpe); return Successful; } +#ifdef HAS_XFONT2 +static void +_remove_fs_handlers(FontPathElementPtr fpe, FontBlockHandlerProcPtr block_handler, Bool all) +#else void remove_fs_handlers(FontPathElementPtr fpe, BlockHandlerProcPtr block_handler, Bool all) +#endif /* HAS_XFONT2 */ { if (all) { /* remove the handlers if no one else is using them */ @@ -2166,13 +2460,57 @@ remove_fs_handlers(FontPathElementPtr fpe, BlockHandlerProcPtr block_handler, Bo fprintf(stderr, "removing FS b & w handlers\n"); #endif +#ifdef HAS_XFONT2 + RemoveBlockAndWakeupHandlers(fs_block_handler, FontWakeup, + (void *) block_handler); +#else RemoveBlockAndWakeupHandlers(block_handler, FontWakeup, - (pointer) 0); + (void *) 0); +#endif /* HAS_XFONT2 */ } } RemoveFontWakeup(fpe); } +#ifdef HAS_XFONT2 +static const xfont2_client_funcs_rec xfont2_client_funcs = { + .version = XFONT2_CLIENT_FUNCS_VERSION, + .client_auth_generation = _client_auth_generation, + .client_signal = ClientSignal, + .delete_font_client_id = delete_font_client_id, + .verrorf = VErrorF, + .find_old_font = find_old_font, + .get_client_resolutions = get_client_resolutions, + .get_default_point_size = get_default_point_size, + .get_new_font_client_id = get_new_font_client_id, + .get_time_in_millis = GetTimeInMillis, + .init_fs_handlers = _init_fs_handlers, + .register_fpe_funcs = register_fpe_funcs, + .remove_fs_handlers = _remove_fs_handlers, + .get_server_client = get_server_client, + .set_font_authorizations = set_font_authorizations, + .store_font_client_font = store_font_Client_font, + .make_atom = MakeAtom, + .valid_atom = ValidAtom, + .name_for_atom = NameForAtom, + .get_server_generation = get_server_generation, + .add_fs_fd = add_fs_fd, + .remove_fs_fd = remove_fs_fd, + .adjust_fs_wait_for_delay = adjust_fs_wait_for_delay, +}; + +xfont2_pattern_cache_ptr fontPatternCache; + +void +InitFonts(void) +{ + if (fontPatternCache) + xfont2_free_font_pattern_cache(fontPatternCache); + fontPatternCache = xfont2_make_font_pattern_cache(); + xfont2_init(&xfont2_client_funcs); +} +#endif /* HAS_XFONT2 */ + #ifdef DEBUG #define GLWIDTHBYTESPADDED(bits,nbytes) \ ((nbytes) == 1 ? (((bits)+7)>>3) /* pad to 1 byte */ \ @@ -2198,12 +2536,12 @@ dump_char_ascii(CharInfoPtr cip) bpr = GLYPH_SIZE(cip, 4); for (r = 0; r < (cip->metrics.ascent + cip->metrics.descent); r++) { - pointer row = (pointer) cip->bits + r * bpr; + void * row = (void *) cip->bits + r * bpr; byte = 0; for (l = 0; l <= (cip->metrics.rightSideBearing - cip->metrics.leftSideBearing); l++) { - if (maskTab[l & 7] & row[l >> 3]) + if (maskTab[l & 7] & (((int*)row)[l >> 3])) putchar('X'); else putchar('.'); diff --git a/nx-X11/programs/Xserver/dix/dixfonts.c.NX.original b/nx-X11/programs/Xserver/dix/dixfonts.c.NX.original deleted file mode 100644 index b66fe23bd..000000000 --- a/nx-X11/programs/Xserver/dix/dixfonts.c.NX.original +++ /dev/null @@ -1,2215 +0,0 @@ -/* $XdotOrg: xc/programs/Xserver/dix/dixfonts.c,v 1.8 2005/07/03 08:53:38 daniels Exp $ */ -/* $XFree86: xc/programs/Xserver/dix/dixfonts.c,v 3.28 2003/11/08 02:02:03 dawes Exp $ */ -/************************************************************************ -Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. - - All Rights Reserved - -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 Digital not be -used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. - -DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING -ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL -DIGITAL 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. - -************************************************************************/ -/* The panoramix components contained the following notice */ -/* -Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts. - -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. - -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 -DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING, -BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL 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 Digital Equipment Corporation -shall not be used in advertising or otherwise to promote the sale, use or other -dealings in this Software without prior written authorization from Digital -Equipment Corporation. - -******************************************************************/ -/* $Xorg: dixfonts.c,v 1.4 2000/08/17 19:48:18 cpqbld Exp $ */ - -#define NEED_REPLIES -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include <X11/X.h> -#include <X11/Xmd.h> -#include <X11/Xproto.h> -#include "scrnintstr.h" -#include "resource.h" -#include "dixstruct.h" -#include "cursorstr.h" -#include "misc.h" -#include "opaque.h" -#include "dixfontstr.h" -#include "closestr.h" - -#ifdef DEBUG -#include <stdio.h> -#endif - -#ifdef NX_TRANS_SOCKET - -char _NXFontPath[1024]; - -/* - * Override the default font path and make - * it configurable at run time, based on - * the NX_FONT environment. - */ - -static const char *_NXGetFontPath(const char *path) -{ - const char *fontEnv; - - /* - * Check the environment only once. - */ - - if (*_NXFontPath != '\0') - { - return _NXFontPath; - } - - fontEnv = getenv("NX_FONT"); - - if (fontEnv != NULL && *fontEnv != '\0') - { - if (strlen(fontEnv) + 1 > 1024) - { -#ifdef NX_TRANS_TEST - fprintf(stderr, "_NXGetFontPath: WARNING! Maximum length of font path exceeded.\n"); -#endif - goto _NXGetFontPathError; - } - - strcpy(_NXFontPath, fontEnv); - -#ifdef NX_TRANS_TEST - fprintf(stderr, "_NXGetFontPath: Using NX font path [%s].\n", _NXFontPath); -#endif - - return _NXFontPath; - } - -_NXGetFontPathError: - - strcpy(_NXFontPath, path); - -#ifdef NX_TRANS_TEST - fprintf(stderr, "_NXGetFontPath: Using default font path [%s].\n", _NXFontPath); -#endif - - return _NXFontPath; -} - -#endif - -#ifdef PANORAMIX -#include "panoramiX.h" -#endif - -#ifdef LBX -#include "lbxserve.h" -#endif - -#ifdef XF86BIGFONT -#define _XF86BIGFONT_SERVER_ -#include <X11/extensions/xf86bigfont.h> -#endif - -#define QUERYCHARINFO(pci, pr) *(pr) = (pci)->metrics - -extern pointer fosNaturalParams; -extern FontPtr defaultFont; - -static FontPathElementPtr *font_path_elements = (FontPathElementPtr *) 0; -static int num_fpes = 0; -FPEFunctions *fpe_functions = (FPEFunctions *) 0; -static int num_fpe_types = 0; - -static unsigned char *font_path_string; - -static int num_slept_fpes = 0; -static int size_slept_fpes = 0; -static FontPathElementPtr *slept_fpes = (FontPathElementPtr *) 0; -static FontPatternCachePtr patternCache; - -int -FontToXError(err) - int err; -{ - switch (err) { - case Successful: - return Success; - case AllocError: - return BadAlloc; - case BadFontName: - return BadName; - case BadFontPath: - case BadFontFormat: /* is there something better? */ - case BadCharRange: - return BadValue; - default: - return err; - } -} - - -/* - * adding RT_FONT prevents conflict with default cursor font - */ -Bool -SetDefaultFont(char *defaultfontname) -{ - int err; - FontPtr pf; - XID fid; - - fid = FakeClientID(0); - err = OpenFont(serverClient, fid, FontLoadAll | FontOpenSync, - (unsigned) strlen(defaultfontname), defaultfontname); - if (err != Success) - return FALSE; - pf = (FontPtr) LookupIDByType(fid, RT_FONT); - if (pf == (FontPtr) NULL) - return FALSE; - defaultFont = pf; - return TRUE; -} - -/* - * note that the font wakeup queue is not refcounted. this is because - * an fpe needs to be added when it's inited, and removed when it's finally - * freed, in order to handle any data that isn't requested, like FS events. - * - * since the only thing that should call these routines is the renderer's - * init_fpe() and free_fpe(), there shouldn't be any problem in using - * freed data. - */ -void -QueueFontWakeup(FontPathElementPtr fpe) -{ - int i; - FontPathElementPtr *new; - - for (i = 0; i < num_slept_fpes; i++) { - if (slept_fpes[i] == fpe) { - -#ifdef DEBUG - fprintf(stderr, "re-queueing fpe wakeup\n"); -#endif - - return; - } - } - if (num_slept_fpes == size_slept_fpes) { - new = (FontPathElementPtr *) - xrealloc(slept_fpes, - sizeof(FontPathElementPtr) * (size_slept_fpes + 4)); - if (!new) - return; - slept_fpes = new; - size_slept_fpes += 4; - } - slept_fpes[num_slept_fpes] = fpe; - num_slept_fpes++; -} - -void -RemoveFontWakeup(FontPathElementPtr fpe) -{ - int i, - j; - - for (i = 0; i < num_slept_fpes; i++) { - if (slept_fpes[i] == fpe) { - for (j = i; j < num_slept_fpes; j++) { - slept_fpes[j] = slept_fpes[j + 1]; - } - num_slept_fpes--; - return; - } - } -} - -void -FontWakeup(pointer data, int count, pointer LastSelectMask) -{ - int i; - FontPathElementPtr fpe; - - if (count < 0) - return; - /* wake up any fpe's that may be waiting for information */ - for (i = 0; i < num_slept_fpes; i++) { - fpe = slept_fpes[i]; - (void) (*fpe_functions[fpe->type].wakeup_fpe) (fpe, LastSelectMask); - } -} - -/* XXX -- these two funcs may want to be broken into macros */ -static void -UseFPE(FontPathElementPtr fpe) -{ - fpe->refcount++; -} - -static void -FreeFPE (FontPathElementPtr fpe) -{ - fpe->refcount--; - if (fpe->refcount == 0) { - (*fpe_functions[fpe->type].free_fpe) (fpe); - xfree(fpe->name); - xfree(fpe); - } -} - -static Bool -doOpenFont(ClientPtr client, OFclosurePtr c) -{ - FontPtr pfont = NullFont; - FontPathElementPtr fpe = NULL; - ScreenPtr pScr; - int err = Successful; - int i; - char *alias, - *newname; - int newlen; - int aliascount = 20; - /* - * Decide at runtime what FontFormat to use. - */ - Mask FontFormat = - - ((screenInfo.imageByteOrder == LSBFirst) ? - BitmapFormatByteOrderLSB : BitmapFormatByteOrderMSB) | - - ((screenInfo.bitmapBitOrder == LSBFirst) ? - BitmapFormatBitOrderLSB : BitmapFormatBitOrderMSB) | - - BitmapFormatImageRectMin | - -#if GLYPHPADBYTES == 1 - BitmapFormatScanlinePad8 | -#endif - -#if GLYPHPADBYTES == 2 - BitmapFormatScanlinePad16 | -#endif - -#if GLYPHPADBYTES == 4 - BitmapFormatScanlinePad32 | -#endif - -#if GLYPHPADBYTES == 8 - BitmapFormatScanlinePad64 | -#endif - - BitmapFormatScanlineUnit8; - - if (client->clientGone) - { - if (c->current_fpe < c->num_fpes) - { - fpe = c->fpe_list[c->current_fpe]; - (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); - } - err = Successful; - goto bail; - } - while (c->current_fpe < c->num_fpes) { - fpe = c->fpe_list[c->current_fpe]; - err = (*fpe_functions[fpe->type].open_font) - ((pointer) client, fpe, c->flags, - c->fontname, c->fnamelen, FontFormat, - BitmapFormatMaskByte | - BitmapFormatMaskBit | - BitmapFormatMaskImageRectangle | - BitmapFormatMaskScanLinePad | - BitmapFormatMaskScanLineUnit, - c->fontid, &pfont, &alias, - c->non_cachable_font && c->non_cachable_font->fpe == fpe ? - c->non_cachable_font : - (FontPtr)0); - - if (err == FontNameAlias && alias) { - newlen = strlen(alias); - newname = (char *) xrealloc(c->fontname, newlen); - if (!newname) { - err = AllocError; - break; - } - memmove(newname, alias, newlen); - c->fontname = newname; - c->fnamelen = newlen; - c->current_fpe = 0; - if (--aliascount <= 0) - break; - continue; - } - if (err == BadFontName) { - c->current_fpe++; - continue; - } - if (err == Suspended) { - if (!c->slept) { - c->slept = TRUE; - ClientSleep(client, (ClientSleepProcPtr)doOpenFont, (pointer) c); - } - return TRUE; - } - break; - } - - if (err != Successful) - goto bail; - if (!pfont) { - err = BadFontName; - goto bail; - } - /* check values for firstCol, lastCol, firstRow, and lastRow */ - if (pfont->info.firstCol > pfont->info.lastCol || - pfont->info.firstRow > pfont->info.lastRow || - pfont->info.lastCol - pfont->info.firstCol > 255) { - err = AllocError; - goto bail; - } - if (!pfont->fpe) - pfont->fpe = fpe; - pfont->refcnt++; - if (pfont->refcnt == 1) { - UseFPE(pfont->fpe); - for (i = 0; i < screenInfo.numScreens; i++) { - pScr = screenInfo.screens[i]; - if (pScr->RealizeFont) - { - if (!(*pScr->RealizeFont) (pScr, pfont)) - { - CloseFont (pfont, (Font) 0); - err = AllocError; - goto bail; - } - } - } - } - if (!AddResource(c->fontid, RT_FONT, (pointer) pfont)) { - err = AllocError; - goto bail; - } - if (patternCache && pfont != c->non_cachable_font) - CacheFontPattern(patternCache, c->origFontName, c->origFontNameLen, - pfont); -bail: - if (err != Successful && c->client != serverClient) { - SendErrorToClient(c->client, X_OpenFont, 0, - c->fontid, FontToXError(err)); - } - if (c->slept) - ClientWakeup(c->client); - for (i = 0; i < c->num_fpes; i++) { - FreeFPE(c->fpe_list[i]); - } - xfree(c->fpe_list); - xfree(c->fontname); - xfree(c); - return TRUE; -} - -int -OpenFont(ClientPtr client, XID fid, Mask flags, unsigned lenfname, char *pfontname) -{ - OFclosurePtr c; - int i; - FontPtr cached = (FontPtr)0; - -#ifdef FONTDEBUG - char *f; - f = (char *)xalloc(lenfname + 1); - memmove(f, pfontname, lenfname); - f[lenfname] = '\0'; - ErrorF("OpenFont: fontname is \"%s\"\n", f); - xfree(f); -#endif - if (!lenfname || lenfname > XLFDMAXFONTNAMELEN) - return BadName; - if (patternCache) - { - - /* - ** Check name cache. If we find a cached version of this font that - ** is cachable, immediately satisfy the request with it. If we find - ** a cached version of this font that is non-cachable, we do not - ** satisfy the request with it. Instead, we pass the FontPtr to the - ** FPE's open_font code (the fontfile FPE in turn passes the - ** information to the rasterizer; the fserve FPE ignores it). - ** - ** Presumably, the font is marked non-cachable because the FPE has - ** put some licensing restrictions on it. If the FPE, using - ** whatever logic it relies on, determines that it is willing to - ** share this existing font with the client, then it has the option - ** to return the FontPtr we passed it as the newly-opened font. - ** This allows the FPE to exercise its licensing logic without - ** having to create another instance of a font that already exists. - */ - - cached = FindCachedFontPattern(patternCache, pfontname, lenfname); - if (cached && cached->info.cachable) - { - if (!AddResource(fid, RT_FONT, (pointer) cached)) - return BadAlloc; - cached->refcnt++; - return Success; - } - } - c = (OFclosurePtr) xalloc(sizeof(OFclosureRec)); - if (!c) - return BadAlloc; - c->fontname = (char *) xalloc(lenfname); - c->origFontName = pfontname; - c->origFontNameLen = lenfname; - if (!c->fontname) { - xfree(c); - return BadAlloc; - } - /* - * copy the current FPE list, so that if it gets changed by another client - * while we're blocking, the request still appears atomic - */ - c->fpe_list = (FontPathElementPtr *) - xalloc(sizeof(FontPathElementPtr) * num_fpes); - if (!c->fpe_list) { - xfree(c->fontname); - xfree(c); - return BadAlloc; - } - memmove(c->fontname, pfontname, lenfname); - for (i = 0; i < num_fpes; i++) { - c->fpe_list[i] = font_path_elements[i]; - UseFPE(c->fpe_list[i]); - } - c->client = client; - c->fontid = fid; - c->current_fpe = 0; - c->num_fpes = num_fpes; - c->fnamelen = lenfname; - c->slept = FALSE; - c->flags = flags; - c->non_cachable_font = cached; - - (void) doOpenFont(client, c); - return Success; -} - -/** - * Decrement font's ref count, and free storage if ref count equals zero - * - * \param value must conform to DeleteType - */ -int -CloseFont(pointer value, XID fid) -{ - int nscr; - ScreenPtr pscr; - FontPathElementPtr fpe; - FontPtr pfont = (FontPtr)value; - - if (pfont == NullFont) - return (Success); - if (--pfont->refcnt == 0) { - if (patternCache) - RemoveCachedFontPattern (patternCache, pfont); - /* - * since the last reference is gone, ask each screen to free any - * storage it may have allocated locally for it. - */ - for (nscr = 0; nscr < screenInfo.numScreens; nscr++) { - pscr = screenInfo.screens[nscr]; - if (pscr->UnrealizeFont) - (*pscr->UnrealizeFont) (pscr, pfont); - } - if (pfont == defaultFont) - defaultFont = NULL; -#ifdef LBX - LbxFreeFontTag(pfont); -#endif -#ifdef XF86BIGFONT - XF86BigfontFreeFontShm(pfont); -#endif - fpe = pfont->fpe; - (*fpe_functions[fpe->type].close_font) (fpe, pfont); - FreeFPE(fpe); - } - return (Success); -} - - -/***====================================================================***/ - -/** - * Sets up pReply as the correct QueryFontReply for pFont with the first - * nProtoCCIStructs char infos. - * - * \param pReply caller must allocate this storage - */ -void -QueryFont(FontPtr pFont, xQueryFontReply *pReply, int nProtoCCIStructs) -{ - FontPropPtr pFP; - int r, - c, - i; - xFontProp *prFP; - xCharInfo *prCI; - xCharInfo *charInfos[256]; - unsigned char chars[512]; - int ninfos; - unsigned long ncols; - unsigned long count; - - /* pr->length set in dispatch */ - pReply->minCharOrByte2 = pFont->info.firstCol; - pReply->defaultChar = pFont->info.defaultCh; - pReply->maxCharOrByte2 = pFont->info.lastCol; - pReply->drawDirection = pFont->info.drawDirection; - pReply->allCharsExist = pFont->info.allExist; - pReply->minByte1 = pFont->info.firstRow; - pReply->maxByte1 = pFont->info.lastRow; - pReply->fontAscent = pFont->info.fontAscent; - pReply->fontDescent = pFont->info.fontDescent; - - pReply->minBounds = pFont->info.ink_minbounds; - pReply->maxBounds = pFont->info.ink_maxbounds; - - pReply->nFontProps = pFont->info.nprops; - pReply->nCharInfos = nProtoCCIStructs; - - for (i = 0, pFP = pFont->info.props, prFP = (xFontProp *) (&pReply[1]); - i < pFont->info.nprops; - i++, pFP++, prFP++) { - prFP->name = pFP->name; - prFP->value = pFP->value; - } - - ninfos = 0; - ncols = (unsigned long) (pFont->info.lastCol - pFont->info.firstCol + 1); - prCI = (xCharInfo *) (prFP); - for (r = pFont->info.firstRow; - ninfos < nProtoCCIStructs && r <= (int)pFont->info.lastRow; - r++) { - i = 0; - for (c = pFont->info.firstCol; c <= (int)pFont->info.lastCol; c++) { - chars[i++] = r; - chars[i++] = c; - } - (*pFont->get_metrics) (pFont, ncols, chars, - TwoD16Bit, &count, charInfos); - i = 0; - for (i = 0; i < (int) count && ninfos < nProtoCCIStructs; i++) { - *prCI = *charInfos[i]; - prCI++; - ninfos++; - } - } - return; -} - -static Bool -doListFontsAndAliases(ClientPtr client, LFclosurePtr c) -{ - FontPathElementPtr fpe; - int err = Successful; - FontNamesPtr names = NULL; - char *name, *resolved=NULL; - int namelen, resolvedlen; - int nnames; - int stringLens; - int i; - xListFontsReply reply; - char *bufptr; - char *bufferStart; - int aliascount = 0; - - if (client->clientGone) - { - if (c->current.current_fpe < c->num_fpes) - { - fpe = c->fpe_list[c->current.current_fpe]; - (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); - } - err = Successful; - goto bail; - } - - if (!c->current.patlen) - goto finish; - - while (c->current.current_fpe < c->num_fpes) { - fpe = c->fpe_list[c->current.current_fpe]; - err = Successful; - - if (!fpe_functions[fpe->type].start_list_fonts_and_aliases) - { - /* This FPE doesn't support/require list_fonts_and_aliases */ - - err = (*fpe_functions[fpe->type].list_fonts) - ((pointer) c->client, fpe, c->current.pattern, - c->current.patlen, c->current.max_names - c->names->nnames, - c->names); - - if (err == Suspended) { - if (!c->slept) { - c->slept = TRUE; - ClientSleep(client, - (ClientSleepProcPtr)doListFontsAndAliases, - (pointer) c); - } - return TRUE; - } - - err = BadFontName; - } - else - { - /* Start of list_fonts_and_aliases functionality. Modeled - after list_fonts_with_info in that it resolves aliases, - except that the information collected from FPEs is just - names, not font info. Each list_next_font_or_alias() - returns either a name into name/namelen or an alias into - name/namelen and its target name into resolved/resolvedlen. - The code at this level then resolves the alias by polling - the FPEs. */ - - if (!c->current.list_started) { - err = (*fpe_functions[fpe->type].start_list_fonts_and_aliases) - ((pointer) c->client, fpe, c->current.pattern, - c->current.patlen, c->current.max_names - c->names->nnames, - &c->current.private); - if (err == Suspended) { - if (!c->slept) { - ClientSleep(client, - (ClientSleepProcPtr)doListFontsAndAliases, - (pointer) c); - c->slept = TRUE; - } - return TRUE; - } - if (err == Successful) - c->current.list_started = TRUE; - } - if (err == Successful) { - char *tmpname; - name = 0; - err = (*fpe_functions[fpe->type].list_next_font_or_alias) - ((pointer) c->client, fpe, &name, &namelen, &tmpname, - &resolvedlen, c->current.private); - if (err == Suspended) { - if (!c->slept) { - ClientSleep(client, - (ClientSleepProcPtr)doListFontsAndAliases, - (pointer) c); - c->slept = TRUE; - } - return TRUE; - } - if (err == FontNameAlias) { - if (resolved) xfree(resolved); - resolved = (char *) xalloc(resolvedlen + 1); - if (resolved) - memmove(resolved, tmpname, resolvedlen + 1); - } - } - - if (err == Successful) - { - if (c->haveSaved) - { - if (c->savedName) - (void)AddFontNamesName(c->names, c->savedName, - c->savedNameLen); - } - else - (void)AddFontNamesName(c->names, name, namelen); - } - - /* - * When we get an alias back, save our state and reset back to - * the start of the FPE looking for the specified name. As - * soon as a real font is found for the alias, pop back to the - * old state - */ - else if (err == FontNameAlias) { - char tmp_pattern[XLFDMAXFONTNAMELEN]; - /* - * when an alias recurses, we need to give - * the last FPE a chance to clean up; so we call - * it again, and assume that the error returned - * is BadFontName, indicating the alias resolution - * is complete. - */ - memmove(tmp_pattern, resolved, resolvedlen); - if (c->haveSaved) - { - char *tmpname; - int tmpnamelen; - - tmpname = 0; - (void) (*fpe_functions[fpe->type].list_next_font_or_alias) - ((pointer) c->client, fpe, &tmpname, &tmpnamelen, - &tmpname, &tmpnamelen, c->current.private); - if (--aliascount <= 0) - { - err = BadFontName; - goto ContBadFontName; - } - } - else - { - c->saved = c->current; - c->haveSaved = TRUE; - if (c->savedName) - xfree(c->savedName); - c->savedName = (char *)xalloc(namelen + 1); - if (c->savedName) - memmove(c->savedName, name, namelen + 1); - c->savedNameLen = namelen; - aliascount = 20; - } - memmove(c->current.pattern, tmp_pattern, resolvedlen); - c->current.patlen = resolvedlen; - c->current.max_names = c->names->nnames + 1; - c->current.current_fpe = -1; - c->current.private = 0; - err = BadFontName; - } - } - /* - * At the end of this FPE, step to the next. If we've finished - * processing an alias, pop state back. If we've collected enough - * font names, quit. - */ - if (err == BadFontName) { - ContBadFontName: ; - c->current.list_started = FALSE; - c->current.current_fpe++; - err = Successful; - if (c->haveSaved) - { - if (c->names->nnames == c->current.max_names || - c->current.current_fpe == c->num_fpes) { - c->haveSaved = FALSE; - c->current = c->saved; - /* Give the saved namelist a chance to clean itself up */ - continue; - } - } - if (c->names->nnames == c->current.max_names) - break; - } - } - - /* - * send the reply - */ - if (err != Successful) { - SendErrorToClient(client, X_ListFonts, 0, 0, FontToXError(err)); - goto bail; - } - -finish: - - names = c->names; - nnames = names->nnames; - client = c->client; - stringLens = 0; - for (i = 0; i < nnames; i++) - stringLens += (names->length[i] <= 255) ? names->length[i] : 0; - - reply.type = X_Reply; - reply.length = (stringLens + nnames + 3) >> 2; - reply.nFonts = nnames; - reply.sequenceNumber = client->sequence; - - bufptr = bufferStart = (char *) ALLOCATE_LOCAL(reply.length << 2); - - if (!bufptr && reply.length) { - SendErrorToClient(client, X_ListFonts, 0, 0, BadAlloc); - goto bail; - } - /* - * since WriteToClient long word aligns things, copy to temp buffer and - * write all at once - */ - for (i = 0; i < nnames; i++) { - if (names->length[i] > 255) - reply.nFonts--; - else - { - *bufptr++ = names->length[i]; - memmove( bufptr, names->names[i], names->length[i]); - bufptr += names->length[i]; - } - } - nnames = reply.nFonts; - reply.length = (stringLens + nnames + 3) >> 2; - client->pSwapReplyFunc = ReplySwapVector[X_ListFonts]; - WriteSwappedDataToClient(client, sizeof(xListFontsReply), &reply); - (void) WriteToClient(client, stringLens + nnames, bufferStart); - DEALLOCATE_LOCAL(bufferStart); - -bail: - if (c->slept) - ClientWakeup(client); - for (i = 0; i < c->num_fpes; i++) - FreeFPE(c->fpe_list[i]); - xfree(c->fpe_list); - if (c->savedName) xfree(c->savedName); - FreeFontNames(names); - xfree(c); - if (resolved) xfree(resolved); - return TRUE; -} - -int -ListFonts(ClientPtr client, unsigned char *pattern, unsigned length, - unsigned max_names) -{ - int i; - LFclosurePtr c; - - /* - * The right error to return here would be BadName, however the - * specification does not allow for a Name error on this request. - * Perhaps a better solution would be to return a nil list, i.e. - * a list containing zero fontnames. - */ - if (length > XLFDMAXFONTNAMELEN) - return BadAlloc; - - if (!(c = (LFclosurePtr) xalloc(sizeof *c))) - return BadAlloc; - c->fpe_list = (FontPathElementPtr *) - xalloc(sizeof(FontPathElementPtr) * num_fpes); - if (!c->fpe_list) { - xfree(c); - return BadAlloc; - } - c->names = MakeFontNamesRecord(max_names < 100 ? max_names : 100); - if (!c->names) - { - xfree(c->fpe_list); - xfree(c); - return BadAlloc; - } - memmove( c->current.pattern, pattern, length); - for (i = 0; i < num_fpes; i++) { - c->fpe_list[i] = font_path_elements[i]; - UseFPE(c->fpe_list[i]); - } - c->client = client; - c->num_fpes = num_fpes; - c->current.patlen = length; - c->current.current_fpe = 0; - c->current.max_names = max_names; - c->current.list_started = FALSE; - c->current.private = 0; - c->haveSaved = FALSE; - c->slept = FALSE; - c->savedName = 0; - doListFontsAndAliases(client, c); - return Success; -} - -int -doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c) -{ - FontPathElementPtr fpe; - int err = Successful; - char *name; - int namelen; - int numFonts; - FontInfoRec fontInfo, - *pFontInfo; - xListFontsWithInfoReply *reply; - int length; - xFontProp *pFP; - int i; - int aliascount = 0; - xListFontsWithInfoReply finalReply; - - if (client->clientGone) - { - if (c->current.current_fpe < c->num_fpes) - { - fpe = c->fpe_list[c->current.current_fpe]; - (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); - } - err = Successful; - goto bail; - } - client->pSwapReplyFunc = ReplySwapVector[X_ListFontsWithInfo]; - if (!c->current.patlen) - goto finish; - while (c->current.current_fpe < c->num_fpes) - { - fpe = c->fpe_list[c->current.current_fpe]; - err = Successful; - if (!c->current.list_started) - { - err = (*fpe_functions[fpe->type].start_list_fonts_with_info) - (client, fpe, c->current.pattern, c->current.patlen, - c->current.max_names, &c->current.private); - if (err == Suspended) - { - if (!c->slept) - { - ClientSleep(client, (ClientSleepProcPtr)doListFontsWithInfo, c); - c->slept = TRUE; - } - return TRUE; - } - if (err == Successful) - c->current.list_started = TRUE; - } - if (err == Successful) - { - name = 0; - pFontInfo = &fontInfo; - err = (*fpe_functions[fpe->type].list_next_font_with_info) - (client, fpe, &name, &namelen, &pFontInfo, - &numFonts, c->current.private); - if (err == Suspended) - { - if (!c->slept) - { - ClientSleep(client, - (ClientSleepProcPtr)doListFontsWithInfo, - c); - c->slept = TRUE; - } - return TRUE; - } - } - /* - * When we get an alias back, save our state and reset back to the - * start of the FPE looking for the specified name. As soon as a real - * font is found for the alias, pop back to the old state - */ - if (err == FontNameAlias) - { - /* - * when an alias recurses, we need to give - * the last FPE a chance to clean up; so we call - * it again, and assume that the error returned - * is BadFontName, indicating the alias resolution - * is complete. - */ - if (c->haveSaved) - { - char *tmpname; - int tmpnamelen; - FontInfoPtr tmpFontInfo; - - tmpname = 0; - tmpFontInfo = &fontInfo; - (void) (*fpe_functions[fpe->type].list_next_font_with_info) - (client, fpe, &tmpname, &tmpnamelen, &tmpFontInfo, - &numFonts, c->current.private); - if (--aliascount <= 0) - { - err = BadFontName; - goto ContBadFontName; - } - } - else - { - c->saved = c->current; - c->haveSaved = TRUE; - c->savedNumFonts = numFonts; - if (c->savedName) - xfree(c->savedName); - c->savedName = (char *)xalloc(namelen + 1); - if (c->savedName) - memmove(c->savedName, name, namelen + 1); - aliascount = 20; - } - memmove(c->current.pattern, name, namelen); - c->current.patlen = namelen; - c->current.max_names = 1; - c->current.current_fpe = 0; - c->current.private = 0; - c->current.list_started = FALSE; - } - /* - * At the end of this FPE, step to the next. If we've finished - * processing an alias, pop state back. If we've sent enough font - * names, quit. Always wait for BadFontName to let the FPE - * have a chance to clean up. - */ - else if (err == BadFontName) - { - ContBadFontName: ; - c->current.list_started = FALSE; - c->current.current_fpe++; - err = Successful; - if (c->haveSaved) - { - if (c->current.max_names == 0 || - c->current.current_fpe == c->num_fpes) - { - c->haveSaved = FALSE; - c->saved.max_names -= (1 - c->current.max_names); - c->current = c->saved; - } - } - else if (c->current.max_names == 0) - break; - } - else if (err == Successful) - { - length = sizeof(*reply) + pFontInfo->nprops * sizeof(xFontProp); - reply = c->reply; - if (c->length < length) - { - reply = (xListFontsWithInfoReply *) xrealloc(c->reply, length); - if (!reply) - { - err = AllocError; - break; - } - c->reply = reply; - c->length = length; - } - if (c->haveSaved) - { - numFonts = c->savedNumFonts; - name = c->savedName; - namelen = strlen(name); - } - reply->type = X_Reply; - reply->length = (sizeof *reply - sizeof(xGenericReply) + - pFontInfo->nprops * sizeof(xFontProp) + - namelen + 3) >> 2; - reply->sequenceNumber = client->sequence; - reply->nameLength = namelen; - reply->minBounds = pFontInfo->ink_minbounds; - reply->maxBounds = pFontInfo->ink_maxbounds; - reply->minCharOrByte2 = pFontInfo->firstCol; - reply->maxCharOrByte2 = pFontInfo->lastCol; - reply->defaultChar = pFontInfo->defaultCh; - reply->nFontProps = pFontInfo->nprops; - reply->drawDirection = pFontInfo->drawDirection; - reply->minByte1 = pFontInfo->firstRow; - reply->maxByte1 = pFontInfo->lastRow; - reply->allCharsExist = pFontInfo->allExist; - reply->fontAscent = pFontInfo->fontAscent; - reply->fontDescent = pFontInfo->fontDescent; - reply->nReplies = numFonts; - pFP = (xFontProp *) (reply + 1); - for (i = 0; i < pFontInfo->nprops; i++) - { - pFP->name = pFontInfo->props[i].name; - pFP->value = pFontInfo->props[i].value; - pFP++; - } - WriteSwappedDataToClient(client, length, reply); - (void) WriteToClient(client, namelen, name); - if (pFontInfo == &fontInfo) - { - xfree(fontInfo.props); - xfree(fontInfo.isStringProp); - } - --c->current.max_names; - } - } -finish: - length = sizeof(xListFontsWithInfoReply); - bzero((char *) &finalReply, sizeof(xListFontsWithInfoReply)); - finalReply.type = X_Reply; - finalReply.sequenceNumber = client->sequence; - finalReply.length = (sizeof(xListFontsWithInfoReply) - - sizeof(xGenericReply)) >> 2; - WriteSwappedDataToClient(client, length, &finalReply); -bail: - if (c->slept) - ClientWakeup(client); - for (i = 0; i < c->num_fpes; i++) - FreeFPE(c->fpe_list[i]); - xfree(c->reply); - xfree(c->fpe_list); - if (c->savedName) xfree(c->savedName); - xfree(c); - return TRUE; -} - -int -StartListFontsWithInfo(ClientPtr client, int length, unsigned char *pattern, - int max_names) -{ - int i; - LFWIclosurePtr c; - - /* - * The right error to return here would be BadName, however the - * specification does not allow for a Name error on this request. - * Perhaps a better solution would be to return a nil list, i.e. - * a list containing zero fontnames. - */ - if (length > XLFDMAXFONTNAMELEN) - return BadAlloc; - - if (!(c = (LFWIclosurePtr) xalloc(sizeof *c))) - goto badAlloc; - c->fpe_list = (FontPathElementPtr *) - xalloc(sizeof(FontPathElementPtr) * num_fpes); - if (!c->fpe_list) - { - xfree(c); - goto badAlloc; - } - memmove(c->current.pattern, pattern, length); - for (i = 0; i < num_fpes; i++) - { - c->fpe_list[i] = font_path_elements[i]; - UseFPE(c->fpe_list[i]); - } - c->client = client; - c->num_fpes = num_fpes; - c->reply = 0; - c->length = 0; - c->current.patlen = length; - c->current.current_fpe = 0; - c->current.max_names = max_names; - c->current.list_started = FALSE; - c->current.private = 0; - c->savedNumFonts = 0; - c->haveSaved = FALSE; - c->slept = FALSE; - c->savedName = 0; - doListFontsWithInfo(client, c); - return Success; -badAlloc: - return BadAlloc; -} - -#define TextEltHeader 2 -#define FontShiftSize 5 -static XID clearGC[] = { CT_NONE }; -#define clearGCmask (GCClipMask) - -int -doPolyText(ClientPtr client, register PTclosurePtr c) -{ - register FontPtr pFont = c->pGC->font, oldpFont; - Font fid, oldfid; - int err = Success, lgerr; /* err is in X error, not font error, space */ - enum { NEVER_SLEPT, START_SLEEP, SLEEPING } client_state = NEVER_SLEPT; - FontPathElementPtr fpe; - GC *origGC = NULL; - - if (client->clientGone) - { - fpe = c->pGC->font->fpe; - (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); - - if (c->slept) - { - /* Client has died, but we cannot bail out right now. We - need to clean up after the work we did when going to - sleep. Setting the drawable pointer to 0 makes this - happen without any attempts to render or perform other - unnecessary activities. */ - c->pDraw = (DrawablePtr)0; - } - else - { - err = Success; - goto bail; - } - } - - /* Make sure our drawable hasn't disappeared while we slept. */ - if (c->slept && - c->pDraw && - c->pDraw != (DrawablePtr)SecurityLookupIDByClass(client, c->did, - RC_DRAWABLE, SecurityWriteAccess)) - { - /* Our drawable has disappeared. Treat like client died... ask - the FPE code to clean up after client and avoid further - rendering while we clean up after ourself. */ - fpe = c->pGC->font->fpe; - (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); - c->pDraw = (DrawablePtr)0; - } - - client_state = c->slept ? SLEEPING : NEVER_SLEPT; - - while (c->endReq - c->pElt > TextEltHeader) - { - if (*c->pElt == FontChange) - { - if (c->endReq - c->pElt < FontShiftSize) - { - err = BadLength; - goto bail; - } - - oldpFont = pFont; - oldfid = fid; - - fid = ((Font)*(c->pElt+4)) /* big-endian */ - | ((Font)*(c->pElt+3)) << 8 - | ((Font)*(c->pElt+2)) << 16 - | ((Font)*(c->pElt+1)) << 24; - pFont = (FontPtr)SecurityLookupIDByType(client, fid, RT_FONT, - SecurityReadAccess); - if (!pFont) - { - client->errorValue = fid; - err = BadFont; - /* restore pFont and fid for step 4 (described below) */ - pFont = oldpFont; - fid = oldfid; - - /* If we're in START_SLEEP mode, the following step - shortens the request... in the unlikely event that - the fid somehow becomes valid before we come through - again to actually execute the polytext, which would - then mess up our refcounting scheme badly. */ - c->err = err; - c->endReq = c->pElt; - - goto bail; - } - - /* Step 3 (described below) on our new font */ - if (client_state == START_SLEEP) - pFont->refcnt++; - else - { - if (pFont != c->pGC->font && c->pDraw) - { - ChangeGC( c->pGC, GCFont, &fid); - ValidateGC(c->pDraw, c->pGC); - if (c->reqType == X_PolyText8) - c->polyText = (PolyTextPtr) c->pGC->ops->PolyText8; - else - c->polyText = (PolyTextPtr) c->pGC->ops->PolyText16; - } - - /* Undo the refcnt++ we performed when going to sleep */ - if (client_state == SLEEPING) - (void)CloseFont(c->pGC->font, (Font)0); - } - c->pElt += FontShiftSize; - } - else /* print a string */ - { - unsigned char *pNextElt; - pNextElt = c->pElt + TextEltHeader + (*c->pElt)*c->itemSize; - if ( pNextElt > c->endReq) - { - err = BadLength; - goto bail; - } - if (client_state == START_SLEEP) - { - c->pElt = pNextElt; - continue; - } - if (c->pDraw) - { - lgerr = LoadGlyphs(client, c->pGC->font, *c->pElt, c->itemSize, - c->pElt + TextEltHeader); - } - else lgerr = Successful; - - if (lgerr == Suspended) - { - if (!c->slept) { - int len; - GC *pGC; - PTclosurePtr new_closure; - - /* We're putting the client to sleep. We need to do a few things - to ensure successful and atomic-appearing execution of the - remainder of the request. First, copy the remainder of the - request into a safe malloc'd area. Second, create a scratch GC - to use for the remainder of the request. Third, mark all fonts - referenced in the remainder of the request to prevent their - deallocation. Fourth, make the original GC look like the - request has completed... set its font to the final font value - from this request. These GC manipulations are for the unlikely - (but possible) event that some other client is using the GC. - Steps 3 and 4 are performed by running this procedure through - the remainder of the request in a special no-render mode - indicated by client_state = START_SLEEP. */ - - /* Step 1 */ - /* Allocate a malloc'd closure structure to replace - the local one we were passed */ - new_closure = (PTclosurePtr) xalloc(sizeof(PTclosureRec)); - if (!new_closure) - { - err = BadAlloc; - goto bail; - } - *new_closure = *c; - c = new_closure; - - len = c->endReq - c->pElt; - c->data = (unsigned char *)xalloc(len); - if (!c->data) - { - xfree(c); - err = BadAlloc; - goto bail; - } - memmove(c->data, c->pElt, len); - c->pElt = c->data; - c->endReq = c->pElt + len; - - /* Step 2 */ - - pGC = GetScratchGC(c->pGC->depth, c->pGC->pScreen); - if (!pGC) - { - xfree(c->data); - xfree(c); - err = BadAlloc; - goto bail; - } - if ((err = CopyGC(c->pGC, pGC, GCFunction | - GCPlaneMask | GCForeground | - GCBackground | GCFillStyle | - GCTile | GCStipple | - GCTileStipXOrigin | - GCTileStipYOrigin | GCFont | - GCSubwindowMode | GCClipXOrigin | - GCClipYOrigin | GCClipMask)) != - Success) - { - FreeScratchGC(pGC); - xfree(c->data); - xfree(c); - err = BadAlloc; - goto bail; - } - origGC = c->pGC; - c->pGC = pGC; - ValidateGC(c->pDraw, c->pGC); - - c->slept = TRUE; - ClientSleep(client, - (ClientSleepProcPtr)doPolyText, - (pointer) c); - - /* Set up to perform steps 3 and 4 */ - client_state = START_SLEEP; - continue; /* on to steps 3 and 4 */ - } - return TRUE; - } - else if (lgerr != Successful) - { - err = FontToXError(lgerr); - goto bail; - } - if (c->pDraw) - { - c->xorg += *((INT8 *)(c->pElt + 1)); /* must be signed */ - c->xorg = (* c->polyText)(c->pDraw, c->pGC, c->xorg, c->yorg, - *c->pElt, c->pElt + TextEltHeader); - } - c->pElt = pNextElt; - } - } - -bail: - - if (client_state == START_SLEEP) - { - /* Step 4 */ - if (pFont != origGC->font) - { - ChangeGC(origGC, GCFont, &fid); - ValidateGC(c->pDraw, origGC); - } - - /* restore pElt pointer for execution of remainder of the request */ - c->pElt = c->data; - return TRUE; - } - - if (c->err != Success) err = c->err; - if (err != Success && c->client != serverClient) { -#ifdef PANORAMIX - if (noPanoramiXExtension || !c->pGC->pScreen->myNum) -#endif - SendErrorToClient(c->client, c->reqType, 0, 0, err); - } - if (c->slept) - { - ClientWakeup(c->client); - ChangeGC(c->pGC, clearGCmask, clearGC); - - /* Unreference the font from the scratch GC */ - CloseFont(c->pGC->font, (Font)0); - c->pGC->font = NullFont; - - FreeScratchGC(c->pGC); - xfree(c->data); - xfree(c); - } - return TRUE; -} - -int -PolyText(ClientPtr client, DrawablePtr pDraw, GC *pGC, unsigned char *pElt, - unsigned char *endReq, int xorg, int yorg, int reqType, XID did) -{ - PTclosureRec local_closure; - - local_closure.pElt = pElt; - local_closure.endReq = endReq; - local_closure.client = client; - local_closure.pDraw = pDraw; - local_closure.xorg = xorg; - local_closure.yorg = yorg; - if ((local_closure.reqType = reqType) == X_PolyText8) - { - local_closure.polyText = (PolyTextPtr) pGC->ops->PolyText8; - local_closure.itemSize = 1; - } - else - { - local_closure.polyText = (PolyTextPtr) pGC->ops->PolyText16; - local_closure.itemSize = 2; - } - local_closure.pGC = pGC; - local_closure.did = did; - local_closure.err = Success; - local_closure.slept = FALSE; - - (void) doPolyText(client, &local_closure); - return Success; -} - - -#undef TextEltHeader -#undef FontShiftSize - -int -doImageText(ClientPtr client, register ITclosurePtr c) -{ - int err = Success, lgerr; /* err is in X error, not font error, space */ - FontPathElementPtr fpe; - - if (client->clientGone) - { - fpe = c->pGC->font->fpe; - (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); - err = Success; - goto bail; - } - - /* Make sure our drawable hasn't disappeared while we slept. */ - if (c->slept && - c->pDraw && - c->pDraw != (DrawablePtr)SecurityLookupIDByClass(client, c->did, - RC_DRAWABLE, SecurityWriteAccess)) - { - /* Our drawable has disappeared. Treat like client died... ask - the FPE code to clean up after client. */ - fpe = c->pGC->font->fpe; - (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); - err = Success; - goto bail; - } - - lgerr = LoadGlyphs(client, c->pGC->font, c->nChars, c->itemSize, c->data); - if (lgerr == Suspended) - { - if (!c->slept) { - GC *pGC; - unsigned char *data; - ITclosurePtr new_closure; - - /* We're putting the client to sleep. We need to - save some state. Similar problem to that handled - in doPolyText, but much simpler because the - request structure is much simpler. */ - - new_closure = (ITclosurePtr) xalloc(sizeof(ITclosureRec)); - if (!new_closure) - { - err = BadAlloc; - goto bail; - } - *new_closure = *c; - c = new_closure; - - data = (unsigned char *)xalloc(c->nChars * c->itemSize); - if (!data) - { - xfree(c); - err = BadAlloc; - goto bail; - } - memmove(data, c->data, c->nChars * c->itemSize); - c->data = data; - - pGC = GetScratchGC(c->pGC->depth, c->pGC->pScreen); - if (!pGC) - { - xfree(c->data); - xfree(c); - err = BadAlloc; - goto bail; - } - if ((err = CopyGC(c->pGC, pGC, GCFunction | GCPlaneMask | - GCForeground | GCBackground | GCFillStyle | - GCTile | GCStipple | GCTileStipXOrigin | - GCTileStipYOrigin | GCFont | - GCSubwindowMode | GCClipXOrigin | - GCClipYOrigin | GCClipMask)) != Success) - { - FreeScratchGC(pGC); - xfree(c->data); - xfree(c); - err = BadAlloc; - goto bail; - } - c->pGC = pGC; - ValidateGC(c->pDraw, c->pGC); - - c->slept = TRUE; - ClientSleep(client, (ClientSleepProcPtr)doImageText, (pointer) c); - } - return TRUE; - } - else if (lgerr != Successful) - { - err = FontToXError(lgerr); - goto bail; - } - if (c->pDraw) - { - (* c->imageText)(c->pDraw, c->pGC, c->xorg, c->yorg, - c->nChars, c->data); - } - -bail: - - if (err != Success && c->client != serverClient) { - SendErrorToClient(c->client, c->reqType, 0, 0, err); - } - if (c->slept) - { - ClientWakeup(c->client); - ChangeGC(c->pGC, clearGCmask, clearGC); - - /* Unreference the font from the scratch GC */ - CloseFont(c->pGC->font, (Font)0); - c->pGC->font = NullFont; - - FreeScratchGC(c->pGC); - xfree(c->data); - xfree(c); - } - return TRUE; -} - -int -ImageText(ClientPtr client, DrawablePtr pDraw, GC *pGC, int nChars, - unsigned char *data, int xorg, int yorg, int reqType, XID did) -{ - ITclosureRec local_closure; - - local_closure.client = client; - local_closure.pDraw = pDraw; - local_closure.pGC = pGC; - local_closure.nChars = nChars; - local_closure.data = data; - local_closure.xorg = xorg; - local_closure.yorg = yorg; - if ((local_closure.reqType = reqType) == X_ImageText8) - { - local_closure.imageText = (ImageTextPtr) pGC->ops->ImageText8; - local_closure.itemSize = 1; - } - else - { - local_closure.imageText = (ImageTextPtr) pGC->ops->ImageText16; - local_closure.itemSize = 2; - } - local_closure.did = did; - local_closure.slept = FALSE; - - (void) doImageText(client, &local_closure); - return Success; -} - - -/* does the necessary magic to figure out the fpe type */ -static int -DetermineFPEType(char *pathname) -{ - int i; - - for (i = 0; i < num_fpe_types; i++) { - if ((*fpe_functions[i].name_check) (pathname)) - return i; - } - return -1; -} - - -static void -FreeFontPath(FontPathElementPtr *list, int n, Bool force) -{ - int i; - - for (i = 0; i < n; i++) { - if (force) { - /* Sanity check that all refcounts will be 0 by the time - we get to the end of the list. */ - int found = 1; /* the first reference is us */ - int j; - for (j = i+1; j < n; j++) { - if (list[j] == list[i]) - found++; - } - if (list[i]->refcount != found) { - ErrorF("FreeFontPath: FPE \"%.*s\" refcount is %d, should be %d; fixing.\n", - list[i]->name_length, list[i]->name, - list[i]->refcount, found); - list[i]->refcount = found; /* ensure it will get freed */ - } - } - FreeFPE(list[i]); - } - xfree((char *) list); -} - -static FontPathElementPtr -find_existing_fpe(FontPathElementPtr *list, int num, unsigned char *name, int len) -{ - FontPathElementPtr fpe; - int i; - - for (i = 0; i < num; i++) { - fpe = list[i]; - if (fpe->name_length == len && memcmp(name, fpe->name, len) == 0) - return fpe; - } - return (FontPathElementPtr) 0; -} - - -static int -SetFontPathElements(int npaths, unsigned char *paths, int *bad, Bool persist) -{ - int i, err = 0; - int valid_paths = 0; - unsigned int len; - unsigned char *cp = paths; - FontPathElementPtr fpe = NULL, *fplist; - - fplist = (FontPathElementPtr *) - xalloc(sizeof(FontPathElementPtr) * npaths); - if (!fplist) { - *bad = 0; - return BadAlloc; - } - for (i = 0; i < num_fpe_types; i++) { - if (fpe_functions[i].set_path_hook) - (*fpe_functions[i].set_path_hook) (); - } - for (i = 0; i < npaths; i++) - { - len = (unsigned int) (*cp++); - - if (len == 0) - { - if (persist) - ErrorF ("Removing empty element from the valid list of fontpaths\n"); - err = BadValue; - } - else - { - /* if it's already in our active list, just reset it */ - /* - * note that this can miss FPE's in limbo -- may be worth catching - * them, though it'd muck up refcounting - */ - fpe = find_existing_fpe(font_path_elements, num_fpes, cp, len); - if (fpe) - { - err = (*fpe_functions[fpe->type].reset_fpe) (fpe); - if (err == Successful) - { - UseFPE(fpe);/* since it'll be decref'd later when freed - * from the old list */ - } - else - fpe = 0; - } - /* if error or can't do it, act like it's a new one */ - if (!fpe) - { - fpe = (FontPathElementPtr) xalloc(sizeof(FontPathElementRec)); - if (!fpe) - { - err = BadAlloc; - goto bail; - } - fpe->name = (char *) xalloc(len + 1); - if (!fpe->name) - { - xfree(fpe); - err = BadAlloc; - goto bail; - } - fpe->refcount = 1; - - strncpy(fpe->name, (char *) cp, (int) len); - fpe->name[len] = '\0'; - fpe->name_length = len; - fpe->type = DetermineFPEType(fpe->name); - if (fpe->type == -1) - err = BadValue; - else - err = (*fpe_functions[fpe->type].init_fpe) (fpe); - if (err != Successful) - { - if (persist) - { - ErrorF("Could not init font path element %s, removing from list!\n", - fpe->name); - } - xfree (fpe->name); - xfree (fpe); - } - } - } - if (err != Successful) - { - if (!persist) - goto bail; - } - else - { - fplist[valid_paths++] = fpe; - } - cp += len; - } - - FreeFontPath(font_path_elements, num_fpes, FALSE); - font_path_elements = fplist; - if (patternCache) - EmptyFontPatternCache(patternCache); - num_fpes = valid_paths; - - return Success; -bail: - *bad = i; - while (--valid_paths >= 0) - FreeFPE(fplist[valid_paths]); - xfree(fplist); - return FontToXError(err); -} - -/* XXX -- do we need to pass error down to each renderer? */ -int -SetFontPath(ClientPtr client, int npaths, unsigned char *paths, int *error) -{ - int err = Success; - - if (npaths == 0) { - if (SetDefaultFontPath(defaultFontPath) != Success) - return BadValue; - } else { - err = SetFontPathElements(npaths, paths, error, FALSE); - } - return err; -} - -int -SetDefaultFontPath(char *path) -{ - unsigned char *cp, - *pp, - *nump, - *newpath; - int num = 1, - len, - err, - size = 0, - bad; - - /* get enough for string, plus values -- use up commas */ -#ifdef NX_TRANS_SOCKET - len = strlen(_NXGetFontPath(path)) + 1; -#else - len = strlen(path) + 1; -#endif - nump = cp = newpath = (unsigned char *) ALLOCATE_LOCAL(len); - if (!newpath) - return BadAlloc; -#ifdef NX_TRANS_SOCKET - pp = (unsigned char *) _NXGetFontPath(path); -#else - pp = (unsigned char *) path; -#endif - cp++; - while (*pp) { - if (*pp == ',') { - *nump = (unsigned char) size; - nump = cp++; - pp++; - num++; - size = 0; - } else { - *cp++ = *pp++; - size++; - } - } - *nump = (unsigned char) size; - - err = SetFontPathElements(num, newpath, &bad, TRUE); - - DEALLOCATE_LOCAL(newpath); - - return err; -} - -unsigned char * -GetFontPath(int *count, int *length) -{ - int i; - unsigned char *c; - int len; - FontPathElementPtr fpe; - - len = 0; - for (i = 0; i < num_fpes; i++) { - fpe = font_path_elements[i]; - len += fpe->name_length + 1; - } - font_path_string = (unsigned char *) xrealloc(font_path_string, len); - if (!font_path_string) - return NULL; - - c = font_path_string; - *length = 0; - for (i = 0; i < num_fpes; i++) { - fpe = font_path_elements[i]; - *c = fpe->name_length; - *length += *c++; - memmove(c, fpe->name, fpe->name_length); - c += fpe->name_length; - } - *count = num_fpes; - return font_path_string; -} - -int -LoadGlyphs(ClientPtr client, FontPtr pfont, unsigned nchars, int item_size, unsigned char *data) -{ - if (fpe_functions[pfont->fpe->type].load_glyphs) - return (*fpe_functions[pfont->fpe->type].load_glyphs) - (client, pfont, 0, nchars, item_size, data); - else - return Successful; -} - -void -DeleteClientFontStuff(ClientPtr client) -{ - int i; - FontPathElementPtr fpe; - - for (i = 0; i < num_fpes; i++) - { - fpe = font_path_elements[i]; - if (fpe_functions[fpe->type].client_died) - (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); - } -} - -void -InitFonts () -{ - patternCache = MakeFontPatternCache(); - -#ifndef KDRIVESERVER - if (screenInfo.numScreens > screenInfo.numVideoScreens) { - PrinterFontRegisterFpeFunctions(); - FontFileCheckRegisterFpeFunctions(); - check_fs_register_fpe_functions(); - } else -#endif - { -#ifdef KDRIVESERVER - BuiltinRegisterFpeFunctions(); -#endif - FontFileRegisterFpeFunctions(); -#ifndef NOFONTSERVERACCESS - fs_register_fpe_functions(); -#endif - } -} - -int -GetDefaultPointSize () -{ - return 120; -} - - -FontResolutionPtr -GetClientResolutions (int *num) -{ - if (requestingClient && requestingClient->fontResFunc != NULL && - !requestingClient->clientGone) - { - return (*requestingClient->fontResFunc)(requestingClient, num); - } - else { - static struct _FontResolution res; - ScreenPtr pScreen; - - pScreen = screenInfo.screens[0]; - res.x_resolution = (pScreen->width * 25.4) / pScreen->mmWidth; - /* - * XXX - we'll want this as long as bitmap instances are prevalent - so that we can match them from scalable fonts - */ - if (res.x_resolution < 88) - res.x_resolution = 75; - else - res.x_resolution = 100; - res.y_resolution = (pScreen->height * 25.4) / pScreen->mmHeight; - if (res.y_resolution < 88) - res.y_resolution = 75; - else - res.y_resolution = 100; - res.point_size = 120; - *num = 1; - return &res; - } -} - -/* - * returns the type index of the new fpe - * - * should be called (only once!) by each type of fpe when initialized - */ - -int -RegisterFPEFunctions(NameCheckFunc name_func, - InitFpeFunc init_func, - FreeFpeFunc free_func, - ResetFpeFunc reset_func, - OpenFontFunc open_func, - CloseFontFunc close_func, - ListFontsFunc list_func, - StartLfwiFunc start_lfwi_func, - NextLfwiFunc next_lfwi_func, - WakeupFpeFunc wakeup_func, - ClientDiedFunc client_died, - LoadGlyphsFunc load_glyphs, - StartLaFunc start_list_alias_func, - NextLaFunc next_list_alias_func, - SetPathFunc set_path_func) -{ - FPEFunctions *new; - - /* grow the list */ - new = (FPEFunctions *) xrealloc(fpe_functions, - (num_fpe_types + 1) * sizeof(FPEFunctions)); - if (!new) - return -1; - fpe_functions = new; - - fpe_functions[num_fpe_types].name_check = name_func; - fpe_functions[num_fpe_types].open_font = open_func; - fpe_functions[num_fpe_types].close_font = close_func; - fpe_functions[num_fpe_types].wakeup_fpe = wakeup_func; - fpe_functions[num_fpe_types].list_fonts = list_func; - fpe_functions[num_fpe_types].start_list_fonts_with_info = - start_lfwi_func; - fpe_functions[num_fpe_types].list_next_font_with_info = - next_lfwi_func; - fpe_functions[num_fpe_types].init_fpe = init_func; - fpe_functions[num_fpe_types].free_fpe = free_func; - fpe_functions[num_fpe_types].reset_fpe = reset_func; - fpe_functions[num_fpe_types].client_died = client_died; - fpe_functions[num_fpe_types].load_glyphs = load_glyphs; - fpe_functions[num_fpe_types].start_list_fonts_and_aliases = - start_list_alias_func; - fpe_functions[num_fpe_types].list_next_font_or_alias = - next_list_alias_func; - fpe_functions[num_fpe_types].set_path_hook = set_path_func; - - return num_fpe_types++; -} - -void -FreeFonts() -{ - if (patternCache) { - FreeFontPatternCache(patternCache); - patternCache = 0; - } - FreeFontPath(font_path_elements, num_fpes, TRUE); - font_path_elements = 0; - num_fpes = 0; - xfree(fpe_functions); - num_fpe_types = 0; - fpe_functions = (FPEFunctions *) 0; -} - -/* convenience functions for FS interface */ - -FontPtr -find_old_font(XID id) -{ - return (FontPtr) SecurityLookupIDByType(NullClient, id, RT_NONE, - SecurityUnknownAccess); -} - -Font -GetNewFontClientID() -{ - return FakeClientID(0); -} - -int -StoreFontClientFont(FontPtr pfont, Font id) -{ - return AddResource(id, RT_NONE, (pointer) pfont); -} - -void -DeleteFontClientID(Font id) -{ - FreeResource(id, RT_NONE); -} - -int -client_auth_generation(ClientPtr client) -{ - return 0; -} - -static int fs_handlers_installed = 0; -static unsigned int last_server_gen; - -int -init_fs_handlers(FontPathElementPtr fpe, BlockHandlerProcPtr block_handler) -{ - /* if server has reset, make sure the b&w handlers are reinstalled */ - if (last_server_gen < serverGeneration) { - last_server_gen = serverGeneration; - fs_handlers_installed = 0; - } - if (fs_handlers_installed == 0) { - -#ifdef DEBUG - fprintf(stderr, "adding FS b & w handlers\n"); -#endif - - if (!RegisterBlockAndWakeupHandlers(block_handler, - FontWakeup, (pointer) 0)) - return AllocError; - fs_handlers_installed++; - } - QueueFontWakeup(fpe); - return Successful; -} - -void -remove_fs_handlers(FontPathElementPtr fpe, BlockHandlerProcPtr block_handler, Bool all) -{ - if (all) { - /* remove the handlers if no one else is using them */ - if (--fs_handlers_installed == 0) { - -#ifdef DEBUG - fprintf(stderr, "removing FS b & w handlers\n"); -#endif - - RemoveBlockAndWakeupHandlers(block_handler, FontWakeup, - (pointer) 0); - } - } - RemoveFontWakeup(fpe); -} - -#ifdef DEBUG -#define GLWIDTHBYTESPADDED(bits,nbytes) \ - ((nbytes) == 1 ? (((bits)+7)>>3) /* pad to 1 byte */ \ - :(nbytes) == 2 ? ((((bits)+15)>>3)&~1) /* pad to 2 bytes */ \ - :(nbytes) == 4 ? ((((bits)+31)>>3)&~3) /* pad to 4 bytes */ \ - :(nbytes) == 8 ? ((((bits)+63)>>3)&~7) /* pad to 8 bytes */ \ - : 0) - -#define GLYPH_SIZE(ch, nbytes) \ - GLWIDTHBYTESPADDED((ch)->metrics.rightSideBearing - \ - (ch)->metrics.leftSideBearing, (nbytes)) -void -dump_char_ascii(CharInfoPtr cip) -{ - int r, - l; - int bpr; - int byte; - static unsigned maskTab[] = { - (1 << 7), (1 << 6), (1 << 5), (1 << 4), - (1 << 3), (1 << 2), (1 << 1), (1 << 0), - }; - - bpr = GLYPH_SIZE(cip, 4); - for (r = 0; r < (cip->metrics.ascent + cip->metrics.descent); r++) { - pointer row = (pointer) cip->bits + r * bpr; - - byte = 0; - for (l = 0; l <= (cip->metrics.rightSideBearing - - cip->metrics.leftSideBearing); l++) { - if (maskTab[l & 7] & row[l >> 3]) - putchar('X'); - else - putchar('.'); - } - putchar('\n'); - } -} - -#endif diff --git a/nx-X11/programs/Xserver/dix/dixfonts.c.X.original b/nx-X11/programs/Xserver/dix/dixfonts.c.X.original deleted file mode 100644 index 2c5874e8d..000000000 --- a/nx-X11/programs/Xserver/dix/dixfonts.c.X.original +++ /dev/null @@ -1,2150 +0,0 @@ -/* $XdotOrg: xc/programs/Xserver/dix/dixfonts.c,v 1.8 2005/07/03 08:53:38 daniels Exp $ */ -/* $XFree86: xc/programs/Xserver/dix/dixfonts.c,v 3.28 2003/11/08 02:02:03 dawes Exp $ */ -/************************************************************************ -Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. - - All Rights Reserved - -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 Digital not be -used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. - -DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING -ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL -DIGITAL 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. - -************************************************************************/ -/* The panoramix components contained the following notice */ -/* -Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts. - -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. - -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 -DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING, -BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL 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 Digital Equipment Corporation -shall not be used in advertising or otherwise to promote the sale, use or other -dealings in this Software without prior written authorization from Digital -Equipment Corporation. - -******************************************************************/ -/* $Xorg: dixfonts.c,v 1.4 2000/08/17 19:48:18 cpqbld Exp $ */ - -#define NEED_REPLIES -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include <X11/X.h> -#include <X11/Xmd.h> -#include <X11/Xproto.h> -#include "scrnintstr.h" -#include "resource.h" -#include "dixstruct.h" -#include "cursorstr.h" -#include "misc.h" -#include "opaque.h" -#include "dixfontstr.h" -#include "closestr.h" - -#ifdef DEBUG -#include <stdio.h> -#endif - -#ifdef PANORAMIX -#include "panoramiX.h" -#endif - -#ifdef LBX -#include "lbxserve.h" -#endif - -#ifdef XF86BIGFONT -#define _XF86BIGFONT_SERVER_ -#include <X11/extensions/xf86bigfont.h> -#endif - -#define QUERYCHARINFO(pci, pr) *(pr) = (pci)->metrics - -extern pointer fosNaturalParams; -extern FontPtr defaultFont; - -static FontPathElementPtr *font_path_elements = (FontPathElementPtr *) 0; -static int num_fpes = 0; -FPEFunctions *fpe_functions = (FPEFunctions *) 0; -static int num_fpe_types = 0; - -static unsigned char *font_path_string; - -static int num_slept_fpes = 0; -static int size_slept_fpes = 0; -static FontPathElementPtr *slept_fpes = (FontPathElementPtr *) 0; -static FontPatternCachePtr patternCache; - -int -FontToXError(err) - int err; -{ - switch (err) { - case Successful: - return Success; - case AllocError: - return BadAlloc; - case BadFontName: - return BadName; - case BadFontPath: - case BadFontFormat: /* is there something better? */ - case BadCharRange: - return BadValue; - default: - return err; - } -} - - -/* - * adding RT_FONT prevents conflict with default cursor font - */ -Bool -SetDefaultFont(char *defaultfontname) -{ - int err; - FontPtr pf; - XID fid; - - fid = FakeClientID(0); - err = OpenFont(serverClient, fid, FontLoadAll | FontOpenSync, - (unsigned) strlen(defaultfontname), defaultfontname); - if (err != Success) - return FALSE; - pf = (FontPtr) LookupIDByType(fid, RT_FONT); - if (pf == (FontPtr) NULL) - return FALSE; - defaultFont = pf; - return TRUE; -} - -/* - * note that the font wakeup queue is not refcounted. this is because - * an fpe needs to be added when it's inited, and removed when it's finally - * freed, in order to handle any data that isn't requested, like FS events. - * - * since the only thing that should call these routines is the renderer's - * init_fpe() and free_fpe(), there shouldn't be any problem in using - * freed data. - */ -void -QueueFontWakeup(FontPathElementPtr fpe) -{ - int i; - FontPathElementPtr *new; - - for (i = 0; i < num_slept_fpes; i++) { - if (slept_fpes[i] == fpe) { - -#ifdef DEBUG - fprintf(stderr, "re-queueing fpe wakeup\n"); -#endif - - return; - } - } - if (num_slept_fpes == size_slept_fpes) { - new = (FontPathElementPtr *) - xrealloc(slept_fpes, - sizeof(FontPathElementPtr) * (size_slept_fpes + 4)); - if (!new) - return; - slept_fpes = new; - size_slept_fpes += 4; - } - slept_fpes[num_slept_fpes] = fpe; - num_slept_fpes++; -} - -void -RemoveFontWakeup(FontPathElementPtr fpe) -{ - int i, - j; - - for (i = 0; i < num_slept_fpes; i++) { - if (slept_fpes[i] == fpe) { - for (j = i; j < num_slept_fpes; j++) { - slept_fpes[j] = slept_fpes[j + 1]; - } - num_slept_fpes--; - return; - } - } -} - -void -FontWakeup(pointer data, int count, pointer LastSelectMask) -{ - int i; - FontPathElementPtr fpe; - - if (count < 0) - return; - /* wake up any fpe's that may be waiting for information */ - for (i = 0; i < num_slept_fpes; i++) { - fpe = slept_fpes[i]; - (void) (*fpe_functions[fpe->type].wakeup_fpe) (fpe, LastSelectMask); - } -} - -/* XXX -- these two funcs may want to be broken into macros */ -static void -UseFPE(FontPathElementPtr fpe) -{ - fpe->refcount++; -} - -static void -FreeFPE (FontPathElementPtr fpe) -{ - fpe->refcount--; - if (fpe->refcount == 0) { - (*fpe_functions[fpe->type].free_fpe) (fpe); - xfree(fpe->name); - xfree(fpe); - } -} - -static Bool -doOpenFont(ClientPtr client, OFclosurePtr c) -{ - FontPtr pfont = NullFont; - FontPathElementPtr fpe = NULL; - ScreenPtr pScr; - int err = Successful; - int i; - char *alias, - *newname; - int newlen; - int aliascount = 20; - /* - * Decide at runtime what FontFormat to use. - */ - Mask FontFormat = - - ((screenInfo.imageByteOrder == LSBFirst) ? - BitmapFormatByteOrderLSB : BitmapFormatByteOrderMSB) | - - ((screenInfo.bitmapBitOrder == LSBFirst) ? - BitmapFormatBitOrderLSB : BitmapFormatBitOrderMSB) | - - BitmapFormatImageRectMin | - -#if GLYPHPADBYTES == 1 - BitmapFormatScanlinePad8 | -#endif - -#if GLYPHPADBYTES == 2 - BitmapFormatScanlinePad16 | -#endif - -#if GLYPHPADBYTES == 4 - BitmapFormatScanlinePad32 | -#endif - -#if GLYPHPADBYTES == 8 - BitmapFormatScanlinePad64 | -#endif - - BitmapFormatScanlineUnit8; - - if (client->clientGone) - { - if (c->current_fpe < c->num_fpes) - { - fpe = c->fpe_list[c->current_fpe]; - (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); - } - err = Successful; - goto bail; - } - while (c->current_fpe < c->num_fpes) { - fpe = c->fpe_list[c->current_fpe]; - err = (*fpe_functions[fpe->type].open_font) - ((pointer) client, fpe, c->flags, - c->fontname, c->fnamelen, FontFormat, - BitmapFormatMaskByte | - BitmapFormatMaskBit | - BitmapFormatMaskImageRectangle | - BitmapFormatMaskScanLinePad | - BitmapFormatMaskScanLineUnit, - c->fontid, &pfont, &alias, - c->non_cachable_font && c->non_cachable_font->fpe == fpe ? - c->non_cachable_font : - (FontPtr)0); - - if (err == FontNameAlias && alias) { - newlen = strlen(alias); - newname = (char *) xrealloc(c->fontname, newlen); - if (!newname) { - err = AllocError; - break; - } - memmove(newname, alias, newlen); - c->fontname = newname; - c->fnamelen = newlen; - c->current_fpe = 0; - if (--aliascount <= 0) - break; - continue; - } - if (err == BadFontName) { - c->current_fpe++; - continue; - } - if (err == Suspended) { - if (!c->slept) { - c->slept = TRUE; - ClientSleep(client, (ClientSleepProcPtr)doOpenFont, (pointer) c); - } - return TRUE; - } - break; - } - - if (err != Successful) - goto bail; - if (!pfont) { - err = BadFontName; - goto bail; - } - /* check values for firstCol, lastCol, firstRow, and lastRow */ - if (pfont->info.firstCol > pfont->info.lastCol || - pfont->info.firstRow > pfont->info.lastRow || - pfont->info.lastCol - pfont->info.firstCol > 255) { - err = AllocError; - goto bail; - } - if (!pfont->fpe) - pfont->fpe = fpe; - pfont->refcnt++; - if (pfont->refcnt == 1) { - UseFPE(pfont->fpe); - for (i = 0; i < screenInfo.numScreens; i++) { - pScr = screenInfo.screens[i]; - if (pScr->RealizeFont) - { - if (!(*pScr->RealizeFont) (pScr, pfont)) - { - CloseFont (pfont, (Font) 0); - err = AllocError; - goto bail; - } - } - } - } - if (!AddResource(c->fontid, RT_FONT, (pointer) pfont)) { - err = AllocError; - goto bail; - } - if (patternCache && pfont != c->non_cachable_font) - CacheFontPattern(patternCache, c->origFontName, c->origFontNameLen, - pfont); -bail: - if (err != Successful && c->client != serverClient) { - SendErrorToClient(c->client, X_OpenFont, 0, - c->fontid, FontToXError(err)); - } - if (c->slept) - ClientWakeup(c->client); - for (i = 0; i < c->num_fpes; i++) { - FreeFPE(c->fpe_list[i]); - } - xfree(c->fpe_list); - xfree(c->fontname); - xfree(c); - return TRUE; -} - -int -OpenFont(ClientPtr client, XID fid, Mask flags, unsigned lenfname, char *pfontname) -{ - OFclosurePtr c; - int i; - FontPtr cached = (FontPtr)0; - -#ifdef FONTDEBUG - char *f; - f = (char *)xalloc(lenfname + 1); - memmove(f, pfontname, lenfname); - f[lenfname] = '\0'; - ErrorF("OpenFont: fontname is \"%s\"\n", f); - xfree(f); -#endif - if (!lenfname || lenfname > XLFDMAXFONTNAMELEN) - return BadName; - if (patternCache) - { - - /* - ** Check name cache. If we find a cached version of this font that - ** is cachable, immediately satisfy the request with it. If we find - ** a cached version of this font that is non-cachable, we do not - ** satisfy the request with it. Instead, we pass the FontPtr to the - ** FPE's open_font code (the fontfile FPE in turn passes the - ** information to the rasterizer; the fserve FPE ignores it). - ** - ** Presumably, the font is marked non-cachable because the FPE has - ** put some licensing restrictions on it. If the FPE, using - ** whatever logic it relies on, determines that it is willing to - ** share this existing font with the client, then it has the option - ** to return the FontPtr we passed it as the newly-opened font. - ** This allows the FPE to exercise its licensing logic without - ** having to create another instance of a font that already exists. - */ - - cached = FindCachedFontPattern(patternCache, pfontname, lenfname); - if (cached && cached->info.cachable) - { - if (!AddResource(fid, RT_FONT, (pointer) cached)) - return BadAlloc; - cached->refcnt++; - return Success; - } - } - c = (OFclosurePtr) xalloc(sizeof(OFclosureRec)); - if (!c) - return BadAlloc; - c->fontname = (char *) xalloc(lenfname); - c->origFontName = pfontname; - c->origFontNameLen = lenfname; - if (!c->fontname) { - xfree(c); - return BadAlloc; - } - /* - * copy the current FPE list, so that if it gets changed by another client - * while we're blocking, the request still appears atomic - */ - c->fpe_list = (FontPathElementPtr *) - xalloc(sizeof(FontPathElementPtr) * num_fpes); - if (!c->fpe_list) { - xfree(c->fontname); - xfree(c); - return BadAlloc; - } - memmove(c->fontname, pfontname, lenfname); - for (i = 0; i < num_fpes; i++) { - c->fpe_list[i] = font_path_elements[i]; - UseFPE(c->fpe_list[i]); - } - c->client = client; - c->fontid = fid; - c->current_fpe = 0; - c->num_fpes = num_fpes; - c->fnamelen = lenfname; - c->slept = FALSE; - c->flags = flags; - c->non_cachable_font = cached; - - (void) doOpenFont(client, c); - return Success; -} - -/** - * Decrement font's ref count, and free storage if ref count equals zero - * - * \param value must conform to DeleteType - */ -int -CloseFont(pointer value, XID fid) -{ - int nscr; - ScreenPtr pscr; - FontPathElementPtr fpe; - FontPtr pfont = (FontPtr)value; - - if (pfont == NullFont) - return (Success); - if (--pfont->refcnt == 0) { - if (patternCache) - RemoveCachedFontPattern (patternCache, pfont); - /* - * since the last reference is gone, ask each screen to free any - * storage it may have allocated locally for it. - */ - for (nscr = 0; nscr < screenInfo.numScreens; nscr++) { - pscr = screenInfo.screens[nscr]; - if (pscr->UnrealizeFont) - (*pscr->UnrealizeFont) (pscr, pfont); - } - if (pfont == defaultFont) - defaultFont = NULL; -#ifdef LBX - LbxFreeFontTag(pfont); -#endif -#ifdef XF86BIGFONT - XF86BigfontFreeFontShm(pfont); -#endif - fpe = pfont->fpe; - (*fpe_functions[fpe->type].close_font) (fpe, pfont); - FreeFPE(fpe); - } - return (Success); -} - - -/***====================================================================***/ - -/** - * Sets up pReply as the correct QueryFontReply for pFont with the first - * nProtoCCIStructs char infos. - * - * \param pReply caller must allocate this storage - */ -void -QueryFont(FontPtr pFont, xQueryFontReply *pReply, int nProtoCCIStructs) -{ - FontPropPtr pFP; - int r, - c, - i; - xFontProp *prFP; - xCharInfo *prCI; - xCharInfo *charInfos[256]; - unsigned char chars[512]; - int ninfos; - unsigned long ncols; - unsigned long count; - - /* pr->length set in dispatch */ - pReply->minCharOrByte2 = pFont->info.firstCol; - pReply->defaultChar = pFont->info.defaultCh; - pReply->maxCharOrByte2 = pFont->info.lastCol; - pReply->drawDirection = pFont->info.drawDirection; - pReply->allCharsExist = pFont->info.allExist; - pReply->minByte1 = pFont->info.firstRow; - pReply->maxByte1 = pFont->info.lastRow; - pReply->fontAscent = pFont->info.fontAscent; - pReply->fontDescent = pFont->info.fontDescent; - - pReply->minBounds = pFont->info.ink_minbounds; - pReply->maxBounds = pFont->info.ink_maxbounds; - - pReply->nFontProps = pFont->info.nprops; - pReply->nCharInfos = nProtoCCIStructs; - - for (i = 0, pFP = pFont->info.props, prFP = (xFontProp *) (&pReply[1]); - i < pFont->info.nprops; - i++, pFP++, prFP++) { - prFP->name = pFP->name; - prFP->value = pFP->value; - } - - ninfos = 0; - ncols = (unsigned long) (pFont->info.lastCol - pFont->info.firstCol + 1); - prCI = (xCharInfo *) (prFP); - for (r = pFont->info.firstRow; - ninfos < nProtoCCIStructs && r <= (int)pFont->info.lastRow; - r++) { - i = 0; - for (c = pFont->info.firstCol; c <= (int)pFont->info.lastCol; c++) { - chars[i++] = r; - chars[i++] = c; - } - (*pFont->get_metrics) (pFont, ncols, chars, - TwoD16Bit, &count, charInfos); - i = 0; - for (i = 0; i < (int) count && ninfos < nProtoCCIStructs; i++) { - *prCI = *charInfos[i]; - prCI++; - ninfos++; - } - } - return; -} - -static Bool -doListFontsAndAliases(ClientPtr client, LFclosurePtr c) -{ - FontPathElementPtr fpe; - int err = Successful; - FontNamesPtr names = NULL; - char *name, *resolved=NULL; - int namelen, resolvedlen; - int nnames; - int stringLens; - int i; - xListFontsReply reply; - char *bufptr; - char *bufferStart; - int aliascount = 0; - - if (client->clientGone) - { - if (c->current.current_fpe < c->num_fpes) - { - fpe = c->fpe_list[c->current.current_fpe]; - (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); - } - err = Successful; - goto bail; - } - - if (!c->current.patlen) - goto finish; - - while (c->current.current_fpe < c->num_fpes) { - fpe = c->fpe_list[c->current.current_fpe]; - err = Successful; - - if (!fpe_functions[fpe->type].start_list_fonts_and_aliases) - { - /* This FPE doesn't support/require list_fonts_and_aliases */ - - err = (*fpe_functions[fpe->type].list_fonts) - ((pointer) c->client, fpe, c->current.pattern, - c->current.patlen, c->current.max_names - c->names->nnames, - c->names); - - if (err == Suspended) { - if (!c->slept) { - c->slept = TRUE; - ClientSleep(client, - (ClientSleepProcPtr)doListFontsAndAliases, - (pointer) c); - } - return TRUE; - } - - err = BadFontName; - } - else - { - /* Start of list_fonts_and_aliases functionality. Modeled - after list_fonts_with_info in that it resolves aliases, - except that the information collected from FPEs is just - names, not font info. Each list_next_font_or_alias() - returns either a name into name/namelen or an alias into - name/namelen and its target name into resolved/resolvedlen. - The code at this level then resolves the alias by polling - the FPEs. */ - - if (!c->current.list_started) { - err = (*fpe_functions[fpe->type].start_list_fonts_and_aliases) - ((pointer) c->client, fpe, c->current.pattern, - c->current.patlen, c->current.max_names - c->names->nnames, - &c->current.private); - if (err == Suspended) { - if (!c->slept) { - ClientSleep(client, - (ClientSleepProcPtr)doListFontsAndAliases, - (pointer) c); - c->slept = TRUE; - } - return TRUE; - } - if (err == Successful) - c->current.list_started = TRUE; - } - if (err == Successful) { - char *tmpname; - name = 0; - err = (*fpe_functions[fpe->type].list_next_font_or_alias) - ((pointer) c->client, fpe, &name, &namelen, &tmpname, - &resolvedlen, c->current.private); - if (err == Suspended) { - if (!c->slept) { - ClientSleep(client, - (ClientSleepProcPtr)doListFontsAndAliases, - (pointer) c); - c->slept = TRUE; - } - return TRUE; - } - if (err == FontNameAlias) { - if (resolved) xfree(resolved); - resolved = (char *) xalloc(resolvedlen + 1); - if (resolved) - memmove(resolved, tmpname, resolvedlen + 1); - } - } - - if (err == Successful) - { - if (c->haveSaved) - { - if (c->savedName) - (void)AddFontNamesName(c->names, c->savedName, - c->savedNameLen); - } - else - (void)AddFontNamesName(c->names, name, namelen); - } - - /* - * When we get an alias back, save our state and reset back to - * the start of the FPE looking for the specified name. As - * soon as a real font is found for the alias, pop back to the - * old state - */ - else if (err == FontNameAlias) { - char tmp_pattern[XLFDMAXFONTNAMELEN]; - /* - * when an alias recurses, we need to give - * the last FPE a chance to clean up; so we call - * it again, and assume that the error returned - * is BadFontName, indicating the alias resolution - * is complete. - */ - memmove(tmp_pattern, resolved, resolvedlen); - if (c->haveSaved) - { - char *tmpname; - int tmpnamelen; - - tmpname = 0; - (void) (*fpe_functions[fpe->type].list_next_font_or_alias) - ((pointer) c->client, fpe, &tmpname, &tmpnamelen, - &tmpname, &tmpnamelen, c->current.private); - if (--aliascount <= 0) - { - err = BadFontName; - goto ContBadFontName; - } - } - else - { - c->saved = c->current; - c->haveSaved = TRUE; - if (c->savedName) - xfree(c->savedName); - c->savedName = (char *)xalloc(namelen + 1); - if (c->savedName) - memmove(c->savedName, name, namelen + 1); - c->savedNameLen = namelen; - aliascount = 20; - } - memmove(c->current.pattern, tmp_pattern, resolvedlen); - c->current.patlen = resolvedlen; - c->current.max_names = c->names->nnames + 1; - c->current.current_fpe = -1; - c->current.private = 0; - err = BadFontName; - } - } - /* - * At the end of this FPE, step to the next. If we've finished - * processing an alias, pop state back. If we've collected enough - * font names, quit. - */ - if (err == BadFontName) { - ContBadFontName: ; - c->current.list_started = FALSE; - c->current.current_fpe++; - err = Successful; - if (c->haveSaved) - { - if (c->names->nnames == c->current.max_names || - c->current.current_fpe == c->num_fpes) { - c->haveSaved = FALSE; - c->current = c->saved; - /* Give the saved namelist a chance to clean itself up */ - continue; - } - } - if (c->names->nnames == c->current.max_names) - break; - } - } - - /* - * send the reply - */ - if (err != Successful) { - SendErrorToClient(client, X_ListFonts, 0, 0, FontToXError(err)); - goto bail; - } - -finish: - - names = c->names; - nnames = names->nnames; - client = c->client; - stringLens = 0; - for (i = 0; i < nnames; i++) - stringLens += (names->length[i] <= 255) ? names->length[i] : 0; - - reply.type = X_Reply; - reply.length = (stringLens + nnames + 3) >> 2; - reply.nFonts = nnames; - reply.sequenceNumber = client->sequence; - - bufptr = bufferStart = (char *) ALLOCATE_LOCAL(reply.length << 2); - - if (!bufptr && reply.length) { - SendErrorToClient(client, X_ListFonts, 0, 0, BadAlloc); - goto bail; - } - /* - * since WriteToClient long word aligns things, copy to temp buffer and - * write all at once - */ - for (i = 0; i < nnames; i++) { - if (names->length[i] > 255) - reply.nFonts--; - else - { - *bufptr++ = names->length[i]; - memmove( bufptr, names->names[i], names->length[i]); - bufptr += names->length[i]; - } - } - nnames = reply.nFonts; - reply.length = (stringLens + nnames + 3) >> 2; - client->pSwapReplyFunc = ReplySwapVector[X_ListFonts]; - WriteSwappedDataToClient(client, sizeof(xListFontsReply), &reply); - (void) WriteToClient(client, stringLens + nnames, bufferStart); - DEALLOCATE_LOCAL(bufferStart); - -bail: - if (c->slept) - ClientWakeup(client); - for (i = 0; i < c->num_fpes; i++) - FreeFPE(c->fpe_list[i]); - xfree(c->fpe_list); - if (c->savedName) xfree(c->savedName); - FreeFontNames(names); - xfree(c); - if (resolved) xfree(resolved); - return TRUE; -} - -int -ListFonts(ClientPtr client, unsigned char *pattern, unsigned length, - unsigned max_names) -{ - int i; - LFclosurePtr c; - - /* - * The right error to return here would be BadName, however the - * specification does not allow for a Name error on this request. - * Perhaps a better solution would be to return a nil list, i.e. - * a list containing zero fontnames. - */ - if (length > XLFDMAXFONTNAMELEN) - return BadAlloc; - - if (!(c = (LFclosurePtr) xalloc(sizeof *c))) - return BadAlloc; - c->fpe_list = (FontPathElementPtr *) - xalloc(sizeof(FontPathElementPtr) * num_fpes); - if (!c->fpe_list) { - xfree(c); - return BadAlloc; - } - c->names = MakeFontNamesRecord(max_names < 100 ? max_names : 100); - if (!c->names) - { - xfree(c->fpe_list); - xfree(c); - return BadAlloc; - } - memmove( c->current.pattern, pattern, length); - for (i = 0; i < num_fpes; i++) { - c->fpe_list[i] = font_path_elements[i]; - UseFPE(c->fpe_list[i]); - } - c->client = client; - c->num_fpes = num_fpes; - c->current.patlen = length; - c->current.current_fpe = 0; - c->current.max_names = max_names; - c->current.list_started = FALSE; - c->current.private = 0; - c->haveSaved = FALSE; - c->slept = FALSE; - c->savedName = 0; - doListFontsAndAliases(client, c); - return Success; -} - -int -doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c) -{ - FontPathElementPtr fpe; - int err = Successful; - char *name; - int namelen; - int numFonts; - FontInfoRec fontInfo, - *pFontInfo; - xListFontsWithInfoReply *reply; - int length; - xFontProp *pFP; - int i; - int aliascount = 0; - xListFontsWithInfoReply finalReply; - - if (client->clientGone) - { - if (c->current.current_fpe < c->num_fpes) - { - fpe = c->fpe_list[c->current.current_fpe]; - (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); - } - err = Successful; - goto bail; - } - client->pSwapReplyFunc = ReplySwapVector[X_ListFontsWithInfo]; - if (!c->current.patlen) - goto finish; - while (c->current.current_fpe < c->num_fpes) - { - fpe = c->fpe_list[c->current.current_fpe]; - err = Successful; - if (!c->current.list_started) - { - err = (*fpe_functions[fpe->type].start_list_fonts_with_info) - (client, fpe, c->current.pattern, c->current.patlen, - c->current.max_names, &c->current.private); - if (err == Suspended) - { - if (!c->slept) - { - ClientSleep(client, (ClientSleepProcPtr)doListFontsWithInfo, c); - c->slept = TRUE; - } - return TRUE; - } - if (err == Successful) - c->current.list_started = TRUE; - } - if (err == Successful) - { - name = 0; - pFontInfo = &fontInfo; - err = (*fpe_functions[fpe->type].list_next_font_with_info) - (client, fpe, &name, &namelen, &pFontInfo, - &numFonts, c->current.private); - if (err == Suspended) - { - if (!c->slept) - { - ClientSleep(client, - (ClientSleepProcPtr)doListFontsWithInfo, - c); - c->slept = TRUE; - } - return TRUE; - } - } - /* - * When we get an alias back, save our state and reset back to the - * start of the FPE looking for the specified name. As soon as a real - * font is found for the alias, pop back to the old state - */ - if (err == FontNameAlias) - { - /* - * when an alias recurses, we need to give - * the last FPE a chance to clean up; so we call - * it again, and assume that the error returned - * is BadFontName, indicating the alias resolution - * is complete. - */ - if (c->haveSaved) - { - char *tmpname; - int tmpnamelen; - FontInfoPtr tmpFontInfo; - - tmpname = 0; - tmpFontInfo = &fontInfo; - (void) (*fpe_functions[fpe->type].list_next_font_with_info) - (client, fpe, &tmpname, &tmpnamelen, &tmpFontInfo, - &numFonts, c->current.private); - if (--aliascount <= 0) - { - err = BadFontName; - goto ContBadFontName; - } - } - else - { - c->saved = c->current; - c->haveSaved = TRUE; - c->savedNumFonts = numFonts; - if (c->savedName) - xfree(c->savedName); - c->savedName = (char *)xalloc(namelen + 1); - if (c->savedName) - memmove(c->savedName, name, namelen + 1); - aliascount = 20; - } - memmove(c->current.pattern, name, namelen); - c->current.patlen = namelen; - c->current.max_names = 1; - c->current.current_fpe = 0; - c->current.private = 0; - c->current.list_started = FALSE; - } - /* - * At the end of this FPE, step to the next. If we've finished - * processing an alias, pop state back. If we've sent enough font - * names, quit. Always wait for BadFontName to let the FPE - * have a chance to clean up. - */ - else if (err == BadFontName) - { - ContBadFontName: ; - c->current.list_started = FALSE; - c->current.current_fpe++; - err = Successful; - if (c->haveSaved) - { - if (c->current.max_names == 0 || - c->current.current_fpe == c->num_fpes) - { - c->haveSaved = FALSE; - c->saved.max_names -= (1 - c->current.max_names); - c->current = c->saved; - } - } - else if (c->current.max_names == 0) - break; - } - else if (err == Successful) - { - length = sizeof(*reply) + pFontInfo->nprops * sizeof(xFontProp); - reply = c->reply; - if (c->length < length) - { - reply = (xListFontsWithInfoReply *) xrealloc(c->reply, length); - if (!reply) - { - err = AllocError; - break; - } - c->reply = reply; - c->length = length; - } - if (c->haveSaved) - { - numFonts = c->savedNumFonts; - name = c->savedName; - namelen = strlen(name); - } - reply->type = X_Reply; - reply->length = (sizeof *reply - sizeof(xGenericReply) + - pFontInfo->nprops * sizeof(xFontProp) + - namelen + 3) >> 2; - reply->sequenceNumber = client->sequence; - reply->nameLength = namelen; - reply->minBounds = pFontInfo->ink_minbounds; - reply->maxBounds = pFontInfo->ink_maxbounds; - reply->minCharOrByte2 = pFontInfo->firstCol; - reply->maxCharOrByte2 = pFontInfo->lastCol; - reply->defaultChar = pFontInfo->defaultCh; - reply->nFontProps = pFontInfo->nprops; - reply->drawDirection = pFontInfo->drawDirection; - reply->minByte1 = pFontInfo->firstRow; - reply->maxByte1 = pFontInfo->lastRow; - reply->allCharsExist = pFontInfo->allExist; - reply->fontAscent = pFontInfo->fontAscent; - reply->fontDescent = pFontInfo->fontDescent; - reply->nReplies = numFonts; - pFP = (xFontProp *) (reply + 1); - for (i = 0; i < pFontInfo->nprops; i++) - { - pFP->name = pFontInfo->props[i].name; - pFP->value = pFontInfo->props[i].value; - pFP++; - } - WriteSwappedDataToClient(client, length, reply); - (void) WriteToClient(client, namelen, name); - if (pFontInfo == &fontInfo) - { - xfree(fontInfo.props); - xfree(fontInfo.isStringProp); - } - --c->current.max_names; - } - } -finish: - length = sizeof(xListFontsWithInfoReply); - bzero((char *) &finalReply, sizeof(xListFontsWithInfoReply)); - finalReply.type = X_Reply; - finalReply.sequenceNumber = client->sequence; - finalReply.length = (sizeof(xListFontsWithInfoReply) - - sizeof(xGenericReply)) >> 2; - WriteSwappedDataToClient(client, length, &finalReply); -bail: - if (c->slept) - ClientWakeup(client); - for (i = 0; i < c->num_fpes; i++) - FreeFPE(c->fpe_list[i]); - xfree(c->reply); - xfree(c->fpe_list); - if (c->savedName) xfree(c->savedName); - xfree(c); - return TRUE; -} - -int -StartListFontsWithInfo(ClientPtr client, int length, unsigned char *pattern, - int max_names) -{ - int i; - LFWIclosurePtr c; - - /* - * The right error to return here would be BadName, however the - * specification does not allow for a Name error on this request. - * Perhaps a better solution would be to return a nil list, i.e. - * a list containing zero fontnames. - */ - if (length > XLFDMAXFONTNAMELEN) - return BadAlloc; - - if (!(c = (LFWIclosurePtr) xalloc(sizeof *c))) - goto badAlloc; - c->fpe_list = (FontPathElementPtr *) - xalloc(sizeof(FontPathElementPtr) * num_fpes); - if (!c->fpe_list) - { - xfree(c); - goto badAlloc; - } - memmove(c->current.pattern, pattern, length); - for (i = 0; i < num_fpes; i++) - { - c->fpe_list[i] = font_path_elements[i]; - UseFPE(c->fpe_list[i]); - } - c->client = client; - c->num_fpes = num_fpes; - c->reply = 0; - c->length = 0; - c->current.patlen = length; - c->current.current_fpe = 0; - c->current.max_names = max_names; - c->current.list_started = FALSE; - c->current.private = 0; - c->savedNumFonts = 0; - c->haveSaved = FALSE; - c->slept = FALSE; - c->savedName = 0; - doListFontsWithInfo(client, c); - return Success; -badAlloc: - return BadAlloc; -} - -#define TextEltHeader 2 -#define FontShiftSize 5 -static XID clearGC[] = { CT_NONE }; -#define clearGCmask (GCClipMask) - -int -doPolyText(ClientPtr client, register PTclosurePtr c) -{ - register FontPtr pFont = c->pGC->font, oldpFont; - Font fid, oldfid; - int err = Success, lgerr; /* err is in X error, not font error, space */ - enum { NEVER_SLEPT, START_SLEEP, SLEEPING } client_state = NEVER_SLEPT; - FontPathElementPtr fpe; - GC *origGC = NULL; - - if (client->clientGone) - { - fpe = c->pGC->font->fpe; - (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); - - if (c->slept) - { - /* Client has died, but we cannot bail out right now. We - need to clean up after the work we did when going to - sleep. Setting the drawable pointer to 0 makes this - happen without any attempts to render or perform other - unnecessary activities. */ - c->pDraw = (DrawablePtr)0; - } - else - { - err = Success; - goto bail; - } - } - - /* Make sure our drawable hasn't disappeared while we slept. */ - if (c->slept && - c->pDraw && - c->pDraw != (DrawablePtr)SecurityLookupIDByClass(client, c->did, - RC_DRAWABLE, SecurityWriteAccess)) - { - /* Our drawable has disappeared. Treat like client died... ask - the FPE code to clean up after client and avoid further - rendering while we clean up after ourself. */ - fpe = c->pGC->font->fpe; - (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); - c->pDraw = (DrawablePtr)0; - } - - client_state = c->slept ? SLEEPING : NEVER_SLEPT; - - while (c->endReq - c->pElt > TextEltHeader) - { - if (*c->pElt == FontChange) - { - if (c->endReq - c->pElt < FontShiftSize) - { - err = BadLength; - goto bail; - } - - oldpFont = pFont; - oldfid = fid; - - fid = ((Font)*(c->pElt+4)) /* big-endian */ - | ((Font)*(c->pElt+3)) << 8 - | ((Font)*(c->pElt+2)) << 16 - | ((Font)*(c->pElt+1)) << 24; - pFont = (FontPtr)SecurityLookupIDByType(client, fid, RT_FONT, - SecurityReadAccess); - if (!pFont) - { - client->errorValue = fid; - err = BadFont; - /* restore pFont and fid for step 4 (described below) */ - pFont = oldpFont; - fid = oldfid; - - /* If we're in START_SLEEP mode, the following step - shortens the request... in the unlikely event that - the fid somehow becomes valid before we come through - again to actually execute the polytext, which would - then mess up our refcounting scheme badly. */ - c->err = err; - c->endReq = c->pElt; - - goto bail; - } - - /* Step 3 (described below) on our new font */ - if (client_state == START_SLEEP) - pFont->refcnt++; - else - { - if (pFont != c->pGC->font && c->pDraw) - { - ChangeGC( c->pGC, GCFont, &fid); - ValidateGC(c->pDraw, c->pGC); - if (c->reqType == X_PolyText8) - c->polyText = (PolyTextPtr) c->pGC->ops->PolyText8; - else - c->polyText = (PolyTextPtr) c->pGC->ops->PolyText16; - } - - /* Undo the refcnt++ we performed when going to sleep */ - if (client_state == SLEEPING) - (void)CloseFont(c->pGC->font, (Font)0); - } - c->pElt += FontShiftSize; - } - else /* print a string */ - { - unsigned char *pNextElt; - pNextElt = c->pElt + TextEltHeader + (*c->pElt)*c->itemSize; - if ( pNextElt > c->endReq) - { - err = BadLength; - goto bail; - } - if (client_state == START_SLEEP) - { - c->pElt = pNextElt; - continue; - } - if (c->pDraw) - { - lgerr = LoadGlyphs(client, c->pGC->font, *c->pElt, c->itemSize, - c->pElt + TextEltHeader); - } - else lgerr = Successful; - - if (lgerr == Suspended) - { - if (!c->slept) { - int len; - GC *pGC; - PTclosurePtr new_closure; - - /* We're putting the client to sleep. We need to do a few things - to ensure successful and atomic-appearing execution of the - remainder of the request. First, copy the remainder of the - request into a safe malloc'd area. Second, create a scratch GC - to use for the remainder of the request. Third, mark all fonts - referenced in the remainder of the request to prevent their - deallocation. Fourth, make the original GC look like the - request has completed... set its font to the final font value - from this request. These GC manipulations are for the unlikely - (but possible) event that some other client is using the GC. - Steps 3 and 4 are performed by running this procedure through - the remainder of the request in a special no-render mode - indicated by client_state = START_SLEEP. */ - - /* Step 1 */ - /* Allocate a malloc'd closure structure to replace - the local one we were passed */ - new_closure = (PTclosurePtr) xalloc(sizeof(PTclosureRec)); - if (!new_closure) - { - err = BadAlloc; - goto bail; - } - *new_closure = *c; - c = new_closure; - - len = c->endReq - c->pElt; - c->data = (unsigned char *)xalloc(len); - if (!c->data) - { - xfree(c); - err = BadAlloc; - goto bail; - } - memmove(c->data, c->pElt, len); - c->pElt = c->data; - c->endReq = c->pElt + len; - - /* Step 2 */ - - pGC = GetScratchGC(c->pGC->depth, c->pGC->pScreen); - if (!pGC) - { - xfree(c->data); - xfree(c); - err = BadAlloc; - goto bail; - } - if ((err = CopyGC(c->pGC, pGC, GCFunction | - GCPlaneMask | GCForeground | - GCBackground | GCFillStyle | - GCTile | GCStipple | - GCTileStipXOrigin | - GCTileStipYOrigin | GCFont | - GCSubwindowMode | GCClipXOrigin | - GCClipYOrigin | GCClipMask)) != - Success) - { - FreeScratchGC(pGC); - xfree(c->data); - xfree(c); - err = BadAlloc; - goto bail; - } - origGC = c->pGC; - c->pGC = pGC; - ValidateGC(c->pDraw, c->pGC); - - c->slept = TRUE; - ClientSleep(client, - (ClientSleepProcPtr)doPolyText, - (pointer) c); - - /* Set up to perform steps 3 and 4 */ - client_state = START_SLEEP; - continue; /* on to steps 3 and 4 */ - } - return TRUE; - } - else if (lgerr != Successful) - { - err = FontToXError(lgerr); - goto bail; - } - if (c->pDraw) - { - c->xorg += *((INT8 *)(c->pElt + 1)); /* must be signed */ - c->xorg = (* c->polyText)(c->pDraw, c->pGC, c->xorg, c->yorg, - *c->pElt, c->pElt + TextEltHeader); - } - c->pElt = pNextElt; - } - } - -bail: - - if (client_state == START_SLEEP) - { - /* Step 4 */ - if (pFont != origGC->font) - { - ChangeGC(origGC, GCFont, &fid); - ValidateGC(c->pDraw, origGC); - } - - /* restore pElt pointer for execution of remainder of the request */ - c->pElt = c->data; - return TRUE; - } - - if (c->err != Success) err = c->err; - if (err != Success && c->client != serverClient) { -#ifdef PANORAMIX - if (noPanoramiXExtension || !c->pGC->pScreen->myNum) -#endif - SendErrorToClient(c->client, c->reqType, 0, 0, err); - } - if (c->slept) - { - ClientWakeup(c->client); - ChangeGC(c->pGC, clearGCmask, clearGC); - - /* Unreference the font from the scratch GC */ - CloseFont(c->pGC->font, (Font)0); - c->pGC->font = NullFont; - - FreeScratchGC(c->pGC); - xfree(c->data); - xfree(c); - } - return TRUE; -} - -int -PolyText(ClientPtr client, DrawablePtr pDraw, GC *pGC, unsigned char *pElt, - unsigned char *endReq, int xorg, int yorg, int reqType, XID did) -{ - PTclosureRec local_closure; - - local_closure.pElt = pElt; - local_closure.endReq = endReq; - local_closure.client = client; - local_closure.pDraw = pDraw; - local_closure.xorg = xorg; - local_closure.yorg = yorg; - if ((local_closure.reqType = reqType) == X_PolyText8) - { - local_closure.polyText = (PolyTextPtr) pGC->ops->PolyText8; - local_closure.itemSize = 1; - } - else - { - local_closure.polyText = (PolyTextPtr) pGC->ops->PolyText16; - local_closure.itemSize = 2; - } - local_closure.pGC = pGC; - local_closure.did = did; - local_closure.err = Success; - local_closure.slept = FALSE; - - (void) doPolyText(client, &local_closure); - return Success; -} - - -#undef TextEltHeader -#undef FontShiftSize - -int -doImageText(ClientPtr client, register ITclosurePtr c) -{ - int err = Success, lgerr; /* err is in X error, not font error, space */ - FontPathElementPtr fpe; - - if (client->clientGone) - { - fpe = c->pGC->font->fpe; - (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); - err = Success; - goto bail; - } - - /* Make sure our drawable hasn't disappeared while we slept. */ - if (c->slept && - c->pDraw && - c->pDraw != (DrawablePtr)SecurityLookupIDByClass(client, c->did, - RC_DRAWABLE, SecurityWriteAccess)) - { - /* Our drawable has disappeared. Treat like client died... ask - the FPE code to clean up after client. */ - fpe = c->pGC->font->fpe; - (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); - err = Success; - goto bail; - } - - lgerr = LoadGlyphs(client, c->pGC->font, c->nChars, c->itemSize, c->data); - if (lgerr == Suspended) - { - if (!c->slept) { - GC *pGC; - unsigned char *data; - ITclosurePtr new_closure; - - /* We're putting the client to sleep. We need to - save some state. Similar problem to that handled - in doPolyText, but much simpler because the - request structure is much simpler. */ - - new_closure = (ITclosurePtr) xalloc(sizeof(ITclosureRec)); - if (!new_closure) - { - err = BadAlloc; - goto bail; - } - *new_closure = *c; - c = new_closure; - - data = (unsigned char *)xalloc(c->nChars * c->itemSize); - if (!data) - { - xfree(c); - err = BadAlloc; - goto bail; - } - memmove(data, c->data, c->nChars * c->itemSize); - c->data = data; - - pGC = GetScratchGC(c->pGC->depth, c->pGC->pScreen); - if (!pGC) - { - xfree(c->data); - xfree(c); - err = BadAlloc; - goto bail; - } - if ((err = CopyGC(c->pGC, pGC, GCFunction | GCPlaneMask | - GCForeground | GCBackground | GCFillStyle | - GCTile | GCStipple | GCTileStipXOrigin | - GCTileStipYOrigin | GCFont | - GCSubwindowMode | GCClipXOrigin | - GCClipYOrigin | GCClipMask)) != Success) - { - FreeScratchGC(pGC); - xfree(c->data); - xfree(c); - err = BadAlloc; - goto bail; - } - c->pGC = pGC; - ValidateGC(c->pDraw, c->pGC); - - c->slept = TRUE; - ClientSleep(client, (ClientSleepProcPtr)doImageText, (pointer) c); - } - return TRUE; - } - else if (lgerr != Successful) - { - err = FontToXError(lgerr); - goto bail; - } - if (c->pDraw) - { - (* c->imageText)(c->pDraw, c->pGC, c->xorg, c->yorg, - c->nChars, c->data); - } - -bail: - - if (err != Success && c->client != serverClient) { - SendErrorToClient(c->client, c->reqType, 0, 0, err); - } - if (c->slept) - { - ClientWakeup(c->client); - ChangeGC(c->pGC, clearGCmask, clearGC); - - /* Unreference the font from the scratch GC */ - CloseFont(c->pGC->font, (Font)0); - c->pGC->font = NullFont; - - FreeScratchGC(c->pGC); - xfree(c->data); - xfree(c); - } - return TRUE; -} - -int -ImageText(ClientPtr client, DrawablePtr pDraw, GC *pGC, int nChars, - unsigned char *data, int xorg, int yorg, int reqType, XID did) -{ - ITclosureRec local_closure; - - local_closure.client = client; - local_closure.pDraw = pDraw; - local_closure.pGC = pGC; - local_closure.nChars = nChars; - local_closure.data = data; - local_closure.xorg = xorg; - local_closure.yorg = yorg; - if ((local_closure.reqType = reqType) == X_ImageText8) - { - local_closure.imageText = (ImageTextPtr) pGC->ops->ImageText8; - local_closure.itemSize = 1; - } - else - { - local_closure.imageText = (ImageTextPtr) pGC->ops->ImageText16; - local_closure.itemSize = 2; - } - local_closure.did = did; - local_closure.slept = FALSE; - - (void) doImageText(client, &local_closure); - return Success; -} - - -/* does the necessary magic to figure out the fpe type */ -static int -DetermineFPEType(char *pathname) -{ - int i; - - for (i = 0; i < num_fpe_types; i++) { - if ((*fpe_functions[i].name_check) (pathname)) - return i; - } - return -1; -} - - -static void -FreeFontPath(FontPathElementPtr *list, int n, Bool force) -{ - int i; - - for (i = 0; i < n; i++) { - if (force) { - /* Sanity check that all refcounts will be 0 by the time - we get to the end of the list. */ - int found = 1; /* the first reference is us */ - int j; - for (j = i+1; j < n; j++) { - if (list[j] == list[i]) - found++; - } - if (list[i]->refcount != found) { - ErrorF("FreeFontPath: FPE \"%.*s\" refcount is %d, should be %d; fixing.\n", - list[i]->name_length, list[i]->name, - list[i]->refcount, found); - list[i]->refcount = found; /* ensure it will get freed */ - } - } - FreeFPE(list[i]); - } - xfree((char *) list); -} - -static FontPathElementPtr -find_existing_fpe(FontPathElementPtr *list, int num, unsigned char *name, int len) -{ - FontPathElementPtr fpe; - int i; - - for (i = 0; i < num; i++) { - fpe = list[i]; - if (fpe->name_length == len && memcmp(name, fpe->name, len) == 0) - return fpe; - } - return (FontPathElementPtr) 0; -} - - -static int -SetFontPathElements(int npaths, unsigned char *paths, int *bad, Bool persist) -{ - int i, err = 0; - int valid_paths = 0; - unsigned int len; - unsigned char *cp = paths; - FontPathElementPtr fpe = NULL, *fplist; - - fplist = (FontPathElementPtr *) - xalloc(sizeof(FontPathElementPtr) * npaths); - if (!fplist) { - *bad = 0; - return BadAlloc; - } - for (i = 0; i < num_fpe_types; i++) { - if (fpe_functions[i].set_path_hook) - (*fpe_functions[i].set_path_hook) (); - } - for (i = 0; i < npaths; i++) - { - len = (unsigned int) (*cp++); - - if (len == 0) - { - if (persist) - ErrorF ("Removing empty element from the valid list of fontpaths\n"); - err = BadValue; - } - else - { - /* if it's already in our active list, just reset it */ - /* - * note that this can miss FPE's in limbo -- may be worth catching - * them, though it'd muck up refcounting - */ - fpe = find_existing_fpe(font_path_elements, num_fpes, cp, len); - if (fpe) - { - err = (*fpe_functions[fpe->type].reset_fpe) (fpe); - if (err == Successful) - { - UseFPE(fpe);/* since it'll be decref'd later when freed - * from the old list */ - } - else - fpe = 0; - } - /* if error or can't do it, act like it's a new one */ - if (!fpe) - { - fpe = (FontPathElementPtr) xalloc(sizeof(FontPathElementRec)); - if (!fpe) - { - err = BadAlloc; - goto bail; - } - fpe->name = (char *) xalloc(len + 1); - if (!fpe->name) - { - xfree(fpe); - err = BadAlloc; - goto bail; - } - fpe->refcount = 1; - - strncpy(fpe->name, (char *) cp, (int) len); - fpe->name[len] = '\0'; - fpe->name_length = len; - fpe->type = DetermineFPEType(fpe->name); - if (fpe->type == -1) - err = BadValue; - else - err = (*fpe_functions[fpe->type].init_fpe) (fpe); - if (err != Successful) - { - if (persist) - { - ErrorF("Could not init font path element %s, removing from list!\n", - fpe->name); - } - xfree (fpe->name); - xfree (fpe); - } - } - } - if (err != Successful) - { - if (!persist) - goto bail; - } - else - { - fplist[valid_paths++] = fpe; - } - cp += len; - } - - FreeFontPath(font_path_elements, num_fpes, FALSE); - font_path_elements = fplist; - if (patternCache) - EmptyFontPatternCache(patternCache); - num_fpes = valid_paths; - - return Success; -bail: - *bad = i; - while (--valid_paths >= 0) - FreeFPE(fplist[valid_paths]); - xfree(fplist); - return FontToXError(err); -} - -/* XXX -- do we need to pass error down to each renderer? */ -int -SetFontPath(ClientPtr client, int npaths, unsigned char *paths, int *error) -{ - int err = Success; - - if (npaths == 0) { - if (SetDefaultFontPath(defaultFontPath) != Success) - return BadValue; - } else { - err = SetFontPathElements(npaths, paths, error, FALSE); - } - return err; -} - -int -SetDefaultFontPath(char *path) -{ - unsigned char *cp, - *pp, - *nump, - *newpath; - int num = 1, - len, - err, - size = 0, - bad; - - /* get enough for string, plus values -- use up commas */ - len = strlen(path) + 1; - nump = cp = newpath = (unsigned char *) ALLOCATE_LOCAL(len); - if (!newpath) - return BadAlloc; - pp = (unsigned char *) path; - cp++; - while (*pp) { - if (*pp == ',') { - *nump = (unsigned char) size; - nump = cp++; - pp++; - num++; - size = 0; - } else { - *cp++ = *pp++; - size++; - } - } - *nump = (unsigned char) size; - - err = SetFontPathElements(num, newpath, &bad, TRUE); - - DEALLOCATE_LOCAL(newpath); - - return err; -} - -unsigned char * -GetFontPath(int *count, int *length) -{ - int i; - unsigned char *c; - int len; - FontPathElementPtr fpe; - - len = 0; - for (i = 0; i < num_fpes; i++) { - fpe = font_path_elements[i]; - len += fpe->name_length + 1; - } - font_path_string = (unsigned char *) xrealloc(font_path_string, len); - if (!font_path_string) - return NULL; - - c = font_path_string; - *length = 0; - for (i = 0; i < num_fpes; i++) { - fpe = font_path_elements[i]; - *c = fpe->name_length; - *length += *c++; - memmove(c, fpe->name, fpe->name_length); - c += fpe->name_length; - } - *count = num_fpes; - return font_path_string; -} - -int -LoadGlyphs(ClientPtr client, FontPtr pfont, unsigned nchars, int item_size, unsigned char *data) -{ - if (fpe_functions[pfont->fpe->type].load_glyphs) - return (*fpe_functions[pfont->fpe->type].load_glyphs) - (client, pfont, 0, nchars, item_size, data); - else - return Successful; -} - -void -DeleteClientFontStuff(ClientPtr client) -{ - int i; - FontPathElementPtr fpe; - - for (i = 0; i < num_fpes; i++) - { - fpe = font_path_elements[i]; - if (fpe_functions[fpe->type].client_died) - (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); - } -} - -void -InitFonts () -{ - patternCache = MakeFontPatternCache(); - -#ifndef KDRIVESERVER - if (screenInfo.numScreens > screenInfo.numVideoScreens) { - PrinterFontRegisterFpeFunctions(); - FontFileCheckRegisterFpeFunctions(); - check_fs_register_fpe_functions(); - } else -#endif - { -#ifdef KDRIVESERVER - BuiltinRegisterFpeFunctions(); -#endif - FontFileRegisterFpeFunctions(); -#ifndef NOFONTSERVERACCESS - fs_register_fpe_functions(); -#endif - } -} - -int -GetDefaultPointSize () -{ - return 120; -} - - -FontResolutionPtr -GetClientResolutions (int *num) -{ - if (requestingClient && requestingClient->fontResFunc != NULL && - !requestingClient->clientGone) - { - return (*requestingClient->fontResFunc)(requestingClient, num); - } - else { - static struct _FontResolution res; - ScreenPtr pScreen; - - pScreen = screenInfo.screens[0]; - res.x_resolution = (pScreen->width * 25.4) / pScreen->mmWidth; - /* - * XXX - we'll want this as long as bitmap instances are prevalent - so that we can match them from scalable fonts - */ - if (res.x_resolution < 88) - res.x_resolution = 75; - else - res.x_resolution = 100; - res.y_resolution = (pScreen->height * 25.4) / pScreen->mmHeight; - if (res.y_resolution < 88) - res.y_resolution = 75; - else - res.y_resolution = 100; - res.point_size = 120; - *num = 1; - return &res; - } -} - -/* - * returns the type index of the new fpe - * - * should be called (only once!) by each type of fpe when initialized - */ - -int -RegisterFPEFunctions(NameCheckFunc name_func, - InitFpeFunc init_func, - FreeFpeFunc free_func, - ResetFpeFunc reset_func, - OpenFontFunc open_func, - CloseFontFunc close_func, - ListFontsFunc list_func, - StartLfwiFunc start_lfwi_func, - NextLfwiFunc next_lfwi_func, - WakeupFpeFunc wakeup_func, - ClientDiedFunc client_died, - LoadGlyphsFunc load_glyphs, - StartLaFunc start_list_alias_func, - NextLaFunc next_list_alias_func, - SetPathFunc set_path_func) -{ - FPEFunctions *new; - - /* grow the list */ - new = (FPEFunctions *) xrealloc(fpe_functions, - (num_fpe_types + 1) * sizeof(FPEFunctions)); - if (!new) - return -1; - fpe_functions = new; - - fpe_functions[num_fpe_types].name_check = name_func; - fpe_functions[num_fpe_types].open_font = open_func; - fpe_functions[num_fpe_types].close_font = close_func; - fpe_functions[num_fpe_types].wakeup_fpe = wakeup_func; - fpe_functions[num_fpe_types].list_fonts = list_func; - fpe_functions[num_fpe_types].start_list_fonts_with_info = - start_lfwi_func; - fpe_functions[num_fpe_types].list_next_font_with_info = - next_lfwi_func; - fpe_functions[num_fpe_types].init_fpe = init_func; - fpe_functions[num_fpe_types].free_fpe = free_func; - fpe_functions[num_fpe_types].reset_fpe = reset_func; - fpe_functions[num_fpe_types].client_died = client_died; - fpe_functions[num_fpe_types].load_glyphs = load_glyphs; - fpe_functions[num_fpe_types].start_list_fonts_and_aliases = - start_list_alias_func; - fpe_functions[num_fpe_types].list_next_font_or_alias = - next_list_alias_func; - fpe_functions[num_fpe_types].set_path_hook = set_path_func; - - return num_fpe_types++; -} - -void -FreeFonts() -{ - if (patternCache) { - FreeFontPatternCache(patternCache); - patternCache = 0; - } - FreeFontPath(font_path_elements, num_fpes, TRUE); - font_path_elements = 0; - num_fpes = 0; - xfree(fpe_functions); - num_fpe_types = 0; - fpe_functions = (FPEFunctions *) 0; -} - -/* convenience functions for FS interface */ - -FontPtr -find_old_font(XID id) -{ - return (FontPtr) SecurityLookupIDByType(NullClient, id, RT_NONE, - SecurityUnknownAccess); -} - -Font -GetNewFontClientID() -{ - return FakeClientID(0); -} - -int -StoreFontClientFont(FontPtr pfont, Font id) -{ - return AddResource(id, RT_NONE, (pointer) pfont); -} - -void -DeleteFontClientID(Font id) -{ - FreeResource(id, RT_NONE); -} - -int -client_auth_generation(ClientPtr client) -{ - return 0; -} - -static int fs_handlers_installed = 0; -static unsigned int last_server_gen; - -int -init_fs_handlers(FontPathElementPtr fpe, BlockHandlerProcPtr block_handler) -{ - /* if server has reset, make sure the b&w handlers are reinstalled */ - if (last_server_gen < serverGeneration) { - last_server_gen = serverGeneration; - fs_handlers_installed = 0; - } - if (fs_handlers_installed == 0) { - -#ifdef DEBUG - fprintf(stderr, "adding FS b & w handlers\n"); -#endif - - if (!RegisterBlockAndWakeupHandlers(block_handler, - FontWakeup, (pointer) 0)) - return AllocError; - fs_handlers_installed++; - } - QueueFontWakeup(fpe); - return Successful; -} - -void -remove_fs_handlers(FontPathElementPtr fpe, BlockHandlerProcPtr block_handler, Bool all) -{ - if (all) { - /* remove the handlers if no one else is using them */ - if (--fs_handlers_installed == 0) { - -#ifdef DEBUG - fprintf(stderr, "removing FS b & w handlers\n"); -#endif - - RemoveBlockAndWakeupHandlers(block_handler, FontWakeup, - (pointer) 0); - } - } - RemoveFontWakeup(fpe); -} - -#ifdef DEBUG -#define GLWIDTHBYTESPADDED(bits,nbytes) \ - ((nbytes) == 1 ? (((bits)+7)>>3) /* pad to 1 byte */ \ - :(nbytes) == 2 ? ((((bits)+15)>>3)&~1) /* pad to 2 bytes */ \ - :(nbytes) == 4 ? ((((bits)+31)>>3)&~3) /* pad to 4 bytes */ \ - :(nbytes) == 8 ? ((((bits)+63)>>3)&~7) /* pad to 8 bytes */ \ - : 0) - -#define GLYPH_SIZE(ch, nbytes) \ - GLWIDTHBYTESPADDED((ch)->metrics.rightSideBearing - \ - (ch)->metrics.leftSideBearing, (nbytes)) -void -dump_char_ascii(CharInfoPtr cip) -{ - int r, - l; - int bpr; - int byte; - static unsigned maskTab[] = { - (1 << 7), (1 << 6), (1 << 5), (1 << 4), - (1 << 3), (1 << 2), (1 << 1), (1 << 0), - }; - - bpr = GLYPH_SIZE(cip, 4); - for (r = 0; r < (cip->metrics.ascent + cip->metrics.descent); r++) { - pointer row = (pointer) cip->bits + r * bpr; - - byte = 0; - for (l = 0; l <= (cip->metrics.rightSideBearing - - cip->metrics.leftSideBearing); l++) { - if (maskTab[l & 7] & row[l >> 3]) - putchar('X'); - else - putchar('.'); - } - putchar('\n'); - } -} - -#endif diff --git a/nx-X11/programs/Xserver/dix/dixutils.c b/nx-X11/programs/Xserver/dix/dixutils.c index e7d4ccd4d..3ccc90d71 100644 --- a/nx-X11/programs/Xserver/dix/dixutils.c +++ b/nx-X11/programs/Xserver/dix/dixutils.c @@ -1,4 +1,3 @@ -/* $XFree86: xc/programs/Xserver/dix/dixutils.c,v 3.13 2003/01/12 02:44:26 dawes Exp $ */ /*********************************************************** Copyright 1987, 1998 The Open Group @@ -82,24 +81,23 @@ Author: Adobe Systems Incorporated */ -/* $Xorg: dixutils.c,v 1.4 2001/02/09 02:04:40 xorgcvs Exp $ */ #ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> #endif -#include <X11/X.h> -#include <X11/Xmd.h> +#include <nx-X11/X.h> +#include <nx-X11/Xmd.h> #include "misc.h" #include "windowstr.h" #include "dixstruct.h" #include "pixmapstr.h" #include "scrnintstr.h" #define XK_LATIN1 -#include <X11/keysymdef.h> +#include <nx-X11/keysymdef.h> #ifdef XCSECURITY #define _SECURITY_SERVER -#include <X11/extensions/security.h> +#include <nx-X11/extensions/security.h> #endif /* @@ -171,7 +169,7 @@ ISOLatin1ToLower (unsigned char source) void -CopyISOLatin1Lowered(unsigned char *dest, unsigned char *source, int length) +CopyISOLatin1Lowered(char *dest, const char *source, int length) { register int i; @@ -212,47 +210,25 @@ CompareISOLatin1Lowered(unsigned char *s1, int s1len, WindowPtr SecurityLookupWindow(XID rid, ClientPtr client, Mask access_mode) { - WindowPtr pWin; - client->errorValue = rid; if(rid == INVALID) return NULL; - if (client->trustLevel != XSecurityClientTrusted) - return (WindowPtr)SecurityLookupIDByType(client, rid, RT_WINDOW, access_mode); - if (client->lastDrawableID == rid) - { - if (client->lastDrawable->type == DRAWABLE_WINDOW) - return ((WindowPtr) client->lastDrawable); - return (WindowPtr) NULL; - } - pWin = (WindowPtr)SecurityLookupIDByType(client, rid, RT_WINDOW, access_mode); - if (pWin && pWin->drawable.type == DRAWABLE_WINDOW) { - client->lastDrawable = (DrawablePtr) pWin; - client->lastDrawableID = rid; - client->lastGCID = INVALID; - client->lastGC = (GCPtr)NULL; - } - return pWin; + return (WindowPtr)SecurityLookupIDByType(client, rid, RT_WINDOW, access_mode); } -pointer +void * SecurityLookupDrawable(XID rid, ClientPtr client, Mask access_mode) { register DrawablePtr pDraw; if(rid == INVALID) - return (pointer) NULL; - if (client->trustLevel != XSecurityClientTrusted) - return (DrawablePtr)SecurityLookupIDByClass(client, rid, RC_DRAWABLE, - access_mode); - if (client->lastDrawableID == rid) - return ((pointer) client->lastDrawable); + return (void *) NULL; pDraw = (DrawablePtr)SecurityLookupIDByClass(client, rid, RC_DRAWABLE, access_mode); - if (pDraw && (pDraw->type != UNDRAWABLE_WINDOW)) - return (pointer)pDraw; - return (pointer)NULL; + if ((client->trustLevel != XSecurityClientTrusted) || (pDraw && (pDraw->type != UNDRAWABLE_WINDOW))) + return (void *)pDraw; + return (void *)NULL; } /* We can't replace the LookupWindow and LookupDrawable functions with @@ -262,13 +238,13 @@ SecurityLookupDrawable(XID rid, ClientPtr client, Mask access_mode) WindowPtr LookupWindow(XID rid, ClientPtr client) { - return SecurityLookupWindow(rid, client, SecurityUnknownAccess); + return SecurityLookupWindow(rid, client, DixUnknownAccess); } -pointer +void * LookupDrawable(XID rid, ClientPtr client) { - return SecurityLookupDrawable(rid, client, SecurityUnknownAccess); + return SecurityLookupDrawable(rid, client, DixUnknownAccess); } #else /* not XCSECURITY */ @@ -281,36 +257,21 @@ LookupWindow(XID rid, ClientPtr client) client->errorValue = rid; if(rid == INVALID) return NULL; - if (client->lastDrawableID == rid) - { - if (client->lastDrawable->type == DRAWABLE_WINDOW) - return ((WindowPtr) client->lastDrawable); - return (WindowPtr) NULL; - } - pWin = (WindowPtr)LookupIDByType(rid, RT_WINDOW); - if (pWin && pWin->drawable.type == DRAWABLE_WINDOW) { - client->lastDrawable = (DrawablePtr) pWin; - client->lastDrawableID = rid; - client->lastGCID = INVALID; - client->lastGC = (GCPtr)NULL; - } - return pWin; + return (WindowPtr)LookupIDByType(rid, RT_WINDOW); } -pointer +void * LookupDrawable(XID rid, ClientPtr client) { register DrawablePtr pDraw; if(rid == INVALID) - return (pointer) NULL; - if (client->lastDrawableID == rid) - return ((pointer) client->lastDrawable); + return (void *) NULL; pDraw = (DrawablePtr)LookupIDByClass(rid, RC_DRAWABLE); if (pDraw && (pDraw->type != UNDRAWABLE_WINDOW)) - return (pointer)pDraw; - return (pointer)NULL; + return (void *)pDraw; + return (void *)NULL; } #endif /* XCSECURITY */ @@ -318,8 +279,8 @@ LookupDrawable(XID rid, ClientPtr client) ClientPtr LookupClient(XID rid, ClientPtr client) { - pointer pRes = (pointer)SecurityLookupIDByClass(client, rid, RC_ANY, - SecurityReadAccess); + void * pRes = (void *)SecurityLookupIDByClass(client, rid, RC_ANY, + DixReadAccess); int clientIndex = CLIENT_ID(rid); if (clientIndex && pRes && clients[clientIndex] && !(rid & SERVER_BIT)) @@ -343,7 +304,7 @@ AlterSaveSetForClient(ClientPtr client, WindowPtr pWin, unsigned mode, if (numnow) { pTmp = client->saveSet; - while ((j < numnow) && (SaveSetWindow(pTmp[j]) != (pointer)pWin)) + while ((j < numnow) && (SaveSetWindow(pTmp[j]) != (void *)pWin)) j++; } if (mode == SetModeInsert) @@ -351,7 +312,7 @@ AlterSaveSetForClient(ClientPtr client, WindowPtr pWin, unsigned mode, if (j < numnow) /* duplicate */ return(Success); numnow++; - pTmp = (SaveSetElt *)xrealloc(client->saveSet, sizeof(*pTmp) * numnow); + pTmp = (SaveSetElt *)realloc(client->saveSet, sizeof(*pTmp) * numnow); if (!pTmp) return(BadAlloc); client->saveSet = pTmp; @@ -371,13 +332,13 @@ AlterSaveSetForClient(ClientPtr client, WindowPtr pWin, unsigned mode, numnow--; if (numnow) { - pTmp = (SaveSetElt *)xrealloc(client->saveSet, sizeof(*pTmp) * numnow); + pTmp = (SaveSetElt *)realloc(client->saveSet, sizeof(*pTmp) * numnow); if (pTmp) client->saveSet = pTmp; } else { - xfree(client->saveSet); + free(client->saveSet); client->saveSet = (SaveSetElt *)NULL; } client->numSaved = numnow; @@ -413,7 +374,7 @@ NoopDDA(void) typedef struct _BlockHandler { BlockHandlerProcPtr BlockHandler; WakeupHandlerProcPtr WakeupHandler; - pointer blockData; + void * blockData; Bool deleted; } BlockHandlerRec, *BlockHandlerPtr; @@ -429,7 +390,7 @@ static Bool handlerDeleted; * \param pReadMask nor how it represents the det of descriptors */ void -BlockHandler(pointer pTimeout, pointer pReadmask) +BlockHandler(void * pTimeout, void * pReadmask) { register int i, j; @@ -463,7 +424,7 @@ BlockHandler(pointer pTimeout, pointer pReadmask) * \param pReadmask the resulting descriptor mask */ void -WakeupHandler(int result, pointer pReadmask) +WakeupHandler(int result, void * pReadmask) { register int i, j; @@ -498,13 +459,13 @@ WakeupHandler(int result, pointer pReadmask) Bool RegisterBlockAndWakeupHandlers (BlockHandlerProcPtr blockHandler, WakeupHandlerProcPtr wakeupHandler, - pointer blockData) + void * blockData) { BlockHandlerPtr new; if (numHandlers >= sizeHandlers) { - new = (BlockHandlerPtr) xrealloc (handlers, (numHandlers + 1) * + new = (BlockHandlerPtr) realloc (handlers, (numHandlers + 1) * sizeof (BlockHandlerRec)); if (!new) return FALSE; @@ -522,7 +483,7 @@ RegisterBlockAndWakeupHandlers (BlockHandlerProcPtr blockHandler, void RemoveBlockAndWakeupHandlers (BlockHandlerProcPtr blockHandler, WakeupHandlerProcPtr wakeupHandler, - pointer blockData) + void * blockData) { int i; @@ -549,7 +510,7 @@ RemoveBlockAndWakeupHandlers (BlockHandlerProcPtr blockHandler, void InitBlockAndWakeupHandlers () { - xfree (handlers); + free (handlers); handlers = (BlockHandlerPtr) 0; numHandlers = 0; sizeHandlers = 0; @@ -581,7 +542,7 @@ ProcessWorkQueue(void) { /* remove q from the list */ *p = q->next; /* don't fetch until after func called */ - xfree (q); + free (q); } else { @@ -604,7 +565,7 @@ ProcessWorkQueueZombies(void) (void) (*q->function) (q->client, q->closure); /* remove q from the list */ *p = q->next; /* don't fetch until after func called */ - xfree (q); + free (q); } else { @@ -616,12 +577,12 @@ ProcessWorkQueueZombies(void) Bool QueueWorkProc ( - Bool (*function)(ClientPtr /* pClient */, pointer /* closure */), - ClientPtr client, pointer closure) + Bool (*function)(ClientPtr /* pClient */, void * /* closure */), + ClientPtr client, void * closure) { WorkQueuePtr q; - q = (WorkQueuePtr) xalloc (sizeof *q); + q = (WorkQueuePtr) malloc (sizeof *q); if (!q) return FALSE; q->function = function; @@ -645,17 +606,17 @@ typedef struct _SleepQueue { struct _SleepQueue *next; ClientPtr client; ClientSleepProcPtr function; - pointer closure; + void * closure; } SleepQueueRec, *SleepQueuePtr; static SleepQueuePtr sleepQueue = NULL; Bool -ClientSleep (ClientPtr client, ClientSleepProcPtr function, pointer closure) +ClientSleep (ClientPtr client, ClientSleepProcPtr function, void * closure) { SleepQueuePtr q; - q = (SleepQueuePtr) xalloc (sizeof *q); + q = (SleepQueuePtr) malloc (sizeof *q); if (!q) return FALSE; @@ -692,7 +653,7 @@ ClientWakeup (ClientPtr client) if (q->client == client) { *prev = q->next; - xfree (q); + free (q); if (client->clientGone) /* Oops -- new zombie cleanup code ensures this only * happens from inside CloseDownClient; don't want to @@ -731,11 +692,11 @@ static Bool _AddCallback( CallbackListPtr *pcbl, CallbackProcPtr callback, - pointer data) + void *data) { CallbackPtr cbr; - cbr = (CallbackPtr) xalloc(sizeof(CallbackRec)); + cbr = (CallbackPtr) malloc(sizeof(CallbackRec)); if (!cbr) return FALSE; cbr->proc = callback; @@ -750,7 +711,7 @@ static Bool _DeleteCallback( CallbackListPtr *pcbl, CallbackProcPtr callback, - pointer data) + void *data) { CallbackListPtr cbl = *pcbl; CallbackPtr cbr, pcbr; @@ -775,7 +736,7 @@ _DeleteCallback( cbl->list = cbr->next; else pcbr->next = cbr->next; - xfree(cbr); + free(cbr); } return TRUE; } @@ -785,7 +746,7 @@ _DeleteCallback( static void _CallCallbacks( CallbackListPtr *pcbl, - pointer call_data) + void *call_data) { CallbackListPtr cbl = *pcbl; CallbackPtr cbr, pcbr; @@ -820,12 +781,12 @@ _CallCallbacks( if (pcbr) { cbr = cbr->next; - xfree(pcbr->next); + free(pcbr->next); pcbr->next = cbr; } else { cbr = cbr->next; - xfree(cbl->list); + free(cbl->list); cbl->list = cbr; } cbl->numDeleted--; @@ -865,9 +826,9 @@ _DeleteCallbackList( for (cbr = cbl->list; cbr != NULL; cbr = nextcbr) { nextcbr = cbr->next; - xfree(cbr); + free(cbr); } - xfree(cbl); + free(cbl); *pcbl = NULL; } @@ -888,7 +849,7 @@ CreateCallbackList(CallbackListPtr *pcbl, CallbackFuncsPtr cbfuncs) int i; if (!pcbl) return FALSE; - cbl = (CallbackListPtr) xalloc(sizeof(CallbackListRec)); + cbl = (CallbackListPtr) malloc(sizeof(CallbackListRec)); if (!cbl) return FALSE; cbl->funcs = cbfuncs ? *cbfuncs : default_cbfuncs; cbl->inCallback = 0; @@ -914,7 +875,7 @@ CreateCallbackList(CallbackListPtr *pcbl, CallbackFuncsPtr cbfuncs) } Bool -AddCallback(CallbackListPtr *pcbl, CallbackProcPtr callback, pointer data) +AddCallback(CallbackListPtr *pcbl, CallbackProcPtr callback, void * data) { if (!pcbl) return FALSE; if (!*pcbl) @@ -926,14 +887,14 @@ AddCallback(CallbackListPtr *pcbl, CallbackProcPtr callback, pointer data) } Bool -DeleteCallback(CallbackListPtr *pcbl, CallbackProcPtr callback, pointer data) +DeleteCallback(CallbackListPtr *pcbl, CallbackProcPtr callback, void * data) { if (!pcbl || !*pcbl) return FALSE; return ((*(*pcbl)->funcs.DeleteCallback) (pcbl, callback, data)); } void -CallCallbacks(CallbackListPtr *pcbl, pointer call_data) +CallCallbacks(CallbackListPtr *pcbl, void * call_data) { if (!pcbl || !*pcbl) return; (*(*pcbl)->funcs.CallCallbacks) (pcbl, call_data); @@ -955,7 +916,7 @@ InitCallbackManager() { DeleteCallbackList(listsToCleanup[i]); } - if (listsToCleanup) xfree(listsToCleanup); + if (listsToCleanup) free(listsToCleanup); numCallbackListsToCleanup = 0; listsToCleanup = NULL; diff --git a/nx-X11/programs/Xserver/dix/events.c b/nx-X11/programs/Xserver/dix/events.c index 4373673f9..73187f712 100644 --- a/nx-X11/programs/Xserver/dix/events.c +++ b/nx-X11/programs/Xserver/dix/events.c @@ -1,5 +1,3 @@ -/* $XdotOrg: xc/programs/Xserver/dix/events.c,v 1.17 2005/08/25 22:11:04 anholt Exp $ */ -/* $XFree86: xc/programs/Xserver/dix/events.c,v 3.51 2004/01/12 17:04:52 tsi Exp $ */ /************************************************************ Copyright 1987, 1998 The Open Group @@ -109,18 +107,15 @@ of the copyright holder. ******************************************************************/ -/* $Xorg: events.c,v 1.4 2001/02/09 02:04:40 xorgcvs Exp $ */ #ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> #endif -#include <X11/X.h> +#include <nx-X11/X.h> #include "misc.h" #include "resource.h" -#define NEED_EVENTS -#define NEED_REPLIES -#include <X11/Xproto.h> +#include <nx-X11/Xproto.h> #include "windowstr.h" #include "inputstr.h" #include "scrnintstr.h" @@ -134,30 +129,16 @@ of the copyright holder. #include "globals.h" #ifdef XKB -#include <X11/extensions/XKBsrv.h> +#include "xkbsrv.h" extern Bool XkbFilterEvents(ClientPtr, int, xEvent *); #endif #ifdef XCSECURITY #define _SECURITY_SERVER -#include <X11/extensions/security.h> +#include <nx-X11/extensions/security.h> #endif -#ifdef XEVIE -extern WindowPtr *WindowTable; -extern int xevieFlag; -extern int xevieClientIndex; -extern DeviceIntPtr xeviemouse; -extern DeviceIntPtr xeviekb; -extern Mask xevieMask; -extern Mask xevieFilters[128]; -extern int xevieEventSent; -extern int xevieKBEventSent; -int xeviegrabState = 0; -xEvent *xeviexE; -#endif - -#include <X11/extensions/XIproto.h> +#include <nx-X11/extensions/XIproto.h> #include "exevents.h" #include "extnsionst.h" @@ -253,11 +234,6 @@ static struct { #endif } sprite; /* info about the cursor sprite */ -#ifdef XEVIE -WindowPtr xeviewin; -HotSpot xeviehot; -#endif - static void DoEnterLeaveEvents( WindowPtr fromWin, WindowPtr toWin, @@ -346,14 +322,14 @@ XineramaSetCursorPosition( x += panoramiXdataPtr[0].x; y += panoramiXdataPtr[0].y; - if(!POINT_IN_REGION(pScreen, &XineramaScreenRegions[pScreen->myNum], + if(!RegionContainsPoint(&XineramaScreenRegions[pScreen->myNum], x, y, &box)) { FOR_NSCREENS(i) { if(i == pScreen->myNum) continue; - if(POINT_IN_REGION(pScreen, &XineramaScreenRegions[i], x, y, &box)) + if(RegionContainsPoint(&XineramaScreenRegions[i], x, y, &box)) { pScreen = screenInfo.screens[i]; break; @@ -432,9 +408,10 @@ XineramaCheckPhysLimits( static Bool XineramaSetWindowPntrs(WindowPtr pWin) { - if(pWin == WindowTable[0]) { - memcpy(sprite.windows, WindowTable, - PanoramiXNumScreens*sizeof(WindowPtr)); + if(pWin == screenInfo.screens[0]->root) { + int i; + for (i = 0; i < PanoramiXNumScreens; i++) + sprite.windows[i] = screenInfo.screens[i]->root; } else { PanoramiXRes *win; int i; @@ -462,13 +439,7 @@ XineramaCheckVirtualMotion( if (qe) { sprite.hot.pScreen = qe->pScreen; /* should always be Screen 0 */ -#ifdef XEVIE - xeviehot.x = -#endif sprite.hot.x = qe->event->u.keyButtonPointer.rootX; -#ifdef XEVIE - xeviehot.y = -#endif sprite.hot.y = qe->event->u.keyButtonPointer.rootY; pWin = inputInfo.pointer->grab ? inputInfo.pointer->grab->confineTo : NullWindow; @@ -483,7 +454,7 @@ XineramaCheckVirtualMotion( i = PanoramiXNumScreens - 1; - REGION_COPY(sprite.screen, &sprite.Reg2, + RegionCopy(&sprite.Reg2, &sprite.windows[i]->borderSize); off_x = panoramiXdataPtr[i].x; off_y = panoramiXdataPtr[i].y; @@ -493,39 +464,27 @@ XineramaCheckVirtualMotion( y = off_y - panoramiXdataPtr[i].y; if(x || y) - REGION_TRANSLATE(sprite.screen, &sprite.Reg2, x, y); + RegionTranslate(&sprite.Reg2, x, y); - REGION_UNION(sprite.screen, &sprite.Reg2, &sprite.Reg2, + RegionUnion(&sprite.Reg2, &sprite.Reg2, &sprite.windows[i]->borderSize); off_x = panoramiXdataPtr[i].x; off_y = panoramiXdataPtr[i].y; } - lims = *REGION_EXTENTS(sprite.screen, &sprite.Reg2); + lims = *RegionExtents(&sprite.Reg2); if (sprite.hot.x < lims.x1) -#ifdef XEVIE - xeviehot.x = -#endif sprite.hot.x = lims.x1; else if (sprite.hot.x >= lims.x2) -#ifdef XEVIE - xeviehot.x = -#endif sprite.hot.x = lims.x2 - 1; if (sprite.hot.y < lims.y1) -#ifdef XEVIE - xeviehot.y = -#endif sprite.hot.y = lims.y1; else if (sprite.hot.y >= lims.y2) -#ifdef XEVIE - xeviehot.y = -#endif sprite.hot.y = lims.y2 - 1; - if (REGION_NUM_RECTS(&sprite.Reg2) > 1) + if (RegionNumRects(&sprite.Reg2) > 1) ConfineToShape(&sprite.Reg2, &sprite.hot.x, &sprite.hot.y); if (qe) @@ -552,33 +511,15 @@ XineramaCheckMotion(xEvent *xE) panoramiXdataPtr[0].x; XE_KBPTR.rootY += panoramiXdataPtr[sprite.screen->myNum].y - panoramiXdataPtr[0].y; -#ifdef XEVIE - xeviehot.x = -#endif sprite.hot.x = XE_KBPTR.rootX; -#ifdef XEVIE - xeviehot.y = -#endif sprite.hot.y = XE_KBPTR.rootY; if (sprite.hot.x < sprite.physLimits.x1) -#ifdef XEVIE - xeviehot.x = -#endif sprite.hot.x = sprite.physLimits.x1; else if (sprite.hot.x >= sprite.physLimits.x2) -#ifdef XEVIE - xeviehot.x = -#endif sprite.hot.x = sprite.physLimits.x2 - 1; if (sprite.hot.y < sprite.physLimits.y1) -#ifdef XEVIE - xeviehot.y = -#endif sprite.hot.y = sprite.physLimits.y1; else if (sprite.hot.y >= sprite.physLimits.y2) -#ifdef XEVIE - xeviehot.y = -#endif sprite.hot.y = sprite.physLimits.y2 - 1; if (sprite.hotShape) @@ -595,9 +536,6 @@ XineramaCheckMotion(xEvent *xE) XE_KBPTR.rootY = sprite.hot.y; } -#ifdef XEVIE - xeviewin = -#endif sprite.win = XYToWindow(sprite.hot.x, sprite.hot.y); if (sprite.win != prevSpriteWin) @@ -632,7 +570,7 @@ XineramaConfineCursorToWindow(WindowPtr pWin, Bool generateEvents) i = PanoramiXNumScreens - 1; - REGION_COPY(sprite.screen, &sprite.Reg1, + RegionCopy(&sprite.Reg1, &sprite.windows[i]->borderSize); off_x = panoramiXdataPtr[i].x; off_y = panoramiXdataPtr[i].y; @@ -642,24 +580,24 @@ XineramaConfineCursorToWindow(WindowPtr pWin, Bool generateEvents) y = off_y - panoramiXdataPtr[i].y; if(x || y) - REGION_TRANSLATE(sprite.screen, &sprite.Reg1, x, y); + RegionTranslate(&sprite.Reg1, x, y); - REGION_UNION(sprite.screen, &sprite.Reg1, &sprite.Reg1, + RegionUnion(&sprite.Reg1, &sprite.Reg1, &sprite.windows[i]->borderSize); off_x = panoramiXdataPtr[i].x; off_y = panoramiXdataPtr[i].y; } - sprite.hotLimits = *REGION_EXTENTS(sprite.screen, &sprite.Reg1); + sprite.hotLimits = *RegionExtents(&sprite.Reg1); - if(REGION_NUM_RECTS(&sprite.Reg1) > 1) + if(RegionNumRects(&sprite.Reg1) > 1) sprite.hotShape = &sprite.Reg1; else sprite.hotShape = NullRegion; sprite.confined = FALSE; - sprite.confineWin = (pWin == WindowTable[0]) ? NullWindow : pWin; + sprite.confineWin = (pWin == screenInfo.screens[0]->root) ? NullWindow : pWin; XineramaCheckPhysLimits(sprite.current, generateEvents); } @@ -714,6 +652,7 @@ SyntheticMotion(int x, int y) y += panoramiXdataPtr[0].y - panoramiXdataPtr[sprite.screen->myNum].y; } #endif + memset(&xE, 0, sizeof(xEvent)); xE.u.keyButtonPointer.rootX = x; xE.u.keyButtonPointer.rootY = y; if (syncEvents.playingEvents) @@ -732,9 +671,9 @@ ConfineToShape(RegionPtr shape, int *px, int *py) int x = *px, y = *py; int incx = 1, incy = 1; - if (POINT_IN_REGION(sprite.hot.pScreen, shape, x, y, &box)) + if (RegionContainsPoint(shape, x, y, &box)) return; - box = *REGION_EXTENTS(sprite.hot.pScreen, shape); + box = *RegionExtents(shape); /* this is rather crude */ do { x += incx; @@ -756,7 +695,7 @@ ConfineToShape(RegionPtr shape, int *px, int *py) else if (y < box.y1) return; /* should never get here! */ } - } while (!POINT_IN_REGION(sprite.hot.pScreen, shape, x, y, &box)); + } while (!RegionContainsPoint(shape, x, y, &box)); *px = x; *py = y; } @@ -821,13 +760,7 @@ CheckVirtualMotion( if (qe) { sprite.hot.pScreen = qe->pScreen; -#ifdef XEVIE - xeviehot.x = -#endif sprite.hot.x = qe->event->u.keyButtonPointer.rootX; -#ifdef XEVIE - xeviehot.y = -#endif sprite.hot.y = qe->event->u.keyButtonPointer.rootY; pWin = inputInfo.pointer->grab ? inputInfo.pointer->grab->confineTo : NullWindow; @@ -839,31 +772,16 @@ CheckVirtualMotion( if (sprite.hot.pScreen != pWin->drawable.pScreen) { sprite.hot.pScreen = pWin->drawable.pScreen; -#ifdef XEVIE - xeviehot.x = xeviehot.y = 0; -#endif sprite.hot.x = sprite.hot.y = 0; } - lims = *REGION_EXTENTS(pWin->drawable.pScreen, &pWin->borderSize); + lims = *RegionExtents(&pWin->borderSize); if (sprite.hot.x < lims.x1) -#ifdef XEVIE - xeviehot.x = -#endif sprite.hot.x = lims.x1; else if (sprite.hot.x >= lims.x2) -#ifdef XEVIE - xeviehot.x = -#endif sprite.hot.x = lims.x2 - 1; if (sprite.hot.y < lims.y1) -#ifdef XEVIE - xeviehot.y = -#endif sprite.hot.y = lims.y1; else if (sprite.hot.y >= lims.y2) -#ifdef XEVIE - xeviehot.y = -#endif sprite.hot.y = lims.y2 - 1; #ifdef SHAPE if (wBoundingShape(pWin)) @@ -876,7 +794,7 @@ CheckVirtualMotion( qe->event->u.keyButtonPointer.rootY = sprite.hot.y; } } - ROOT = WindowTable[sprite.hot.pScreen->myNum]; + ROOT = sprite.hot.pScreen->root; } static void @@ -898,7 +816,7 @@ ConfineCursorToWindow(WindowPtr pWin, Bool generateEvents, Bool confineToScreen) } else { - sprite.hotLimits = *REGION_EXTENTS( pScreen, &pWin->borderSize); + sprite.hotLimits = *RegionExtents(&pWin->borderSize); #ifdef SHAPE sprite.hotShape = wBoundingShape(pWin) ? &pWin->borderSize : NullRegion; @@ -1076,10 +994,10 @@ EnqueueEvent(xEvent *xE, DeviceIntPtr device, int count) */ if (xE->u.u.type == MotionNotify) XE_KBPTR.root = - WindowTable[sprite.hotPhys.pScreen->myNum]->drawable.id; + sprite.hotPhys.pScreen->root->drawable.id; eventinfo.events = xE; eventinfo.count = count; - CallCallbacks(&DeviceEventCallback, (pointer)&eventinfo); + CallCallbacks(&DeviceEventCallback, (void *)&eventinfo); } if (xE->u.u.type == MotionNotify) { @@ -1105,7 +1023,7 @@ EnqueueEvent(xEvent *xE, DeviceIntPtr device, int count) return; } } - qe = (QdEventPtr)xalloc(sizeof(QdEventRec) + (count * sizeof(xEvent))); + qe = (QdEventPtr)calloc(1, sizeof(QdEventRec) + (count * sizeof(xEvent))); if (!qe) return; qe->next = (QdEventPtr)NULL; @@ -1154,7 +1072,7 @@ PlayReleasedEvents(void) #endif (*qe->device->public.processInputProc)(qe->event, qe->device, qe->evcount); - xfree(qe); + free(qe); for (dev = inputInfo.devices; dev && dev->sync.frozen; dev = dev->next) ; if (!dev) @@ -1239,7 +1157,7 @@ playmore: ConfineCursorToWindow(grab->confineTo, TRUE, TRUE); } else - ConfineCursorToWindow(WindowTable[sprite.hotPhys.pScreen->myNum], + ConfineCursorToWindow(sprite.hotPhys.pScreen->root, TRUE, FALSE); PostNewCursor(); } @@ -1257,7 +1175,7 @@ ScreenRestructured (ScreenPtr pScreen) ConfineCursorToWindow(grab->confineTo, TRUE, TRUE); } else - ConfineCursorToWindow(WindowTable[sprite.hotPhys.pScreen->myNum], + ConfineCursorToWindow(sprite.hotPhys.pScreen->root, TRUE, FALSE); } #endif @@ -1296,6 +1214,7 @@ CheckGrabForSyncs(register DeviceIntPtr thisDev, Bool thisMode, Bool otherMode) ComputeFreezes(); } +#ifndef NXAGENT_SERVER void ActivatePointerGrab(register DeviceIntPtr mouse, register GrabPtr grab, TimeStamp time, Bool autoGrab) @@ -1347,6 +1266,7 @@ DeactivatePointerGrab(register DeviceIntPtr mouse) FreeCursor(grab->cursor, (Cursor)0); ComputeFreezes(); } +#endif /* NXAGENT_SERVER */ void ActivateKeyboardGrab(register DeviceIntPtr keybd, GrabPtr grab, TimeStamp time, Bool passive) @@ -1579,7 +1499,6 @@ int TryClientEvents (ClientPtr client, xEvent *pEvents, int count, Mask mask, Mask filter, GrabPtr grab) { - int i; int type; #ifdef DEBUG @@ -1622,20 +1541,10 @@ TryClientEvents (ClientPtr client, xEvent *pEvents, int count, Mask mask, return 1; } #endif - type &= 0177; - if (type != KeymapNotify) - { - /* all extension events must have a sequence number */ - for (i = 0; i < count; i++) - pEvents[i].u.u.sequenceNumber = client->sequence; - } - if (BitIsOn(criticalEvents, type)) { -#ifdef SMART_SCHEDULE if (client->smart_priority < SMART_MAX_PRIORITY) client->smart_priority++; -#endif SetCriticalOutputPending(); } @@ -1972,7 +1881,7 @@ PointInBorderSize(WindowPtr pWin, int x, int y) { BoxRec box; - if(POINT_IN_REGION(pWin->drawable.pScreen, &pWin->borderSize, x, y, &box)) + if(RegionContainsPoint(&pWin->borderSize, x, y, &box)) return TRUE; #ifdef PANORAMIX @@ -1980,7 +1889,7 @@ PointInBorderSize(WindowPtr pWin, int x, int y) int i; for(i = 1; i < PanoramiXNumScreens; i++) { - if(POINT_IN_REGION(sprite.screen, + if(RegionContainsPoint( &sprite.windows[i]->borderSize, x + panoramiXdataPtr[0].x - panoramiXdataPtr[i].x, y + panoramiXdataPtr[0].y - panoramiXdataPtr[i].y, @@ -1992,6 +1901,7 @@ PointInBorderSize(WindowPtr pWin, int x, int y) return FALSE; } +#ifndef NXAGENT_SERVER static WindowPtr XYToWindow(int x, int y) { @@ -2016,7 +1926,7 @@ XYToWindow(int x, int y) */ && (!wBoundingShape(pWin) || PointInBorderSize(pWin, x, y)) && (!wInputShape(pWin) || - POINT_IN_REGION(pWin->drawable.pScreen, + RegionContainsPoint( wInputShape(pWin), x - pWin->drawable.x, y - pWin->drawable.y, &box)) @@ -2027,7 +1937,7 @@ XYToWindow(int x, int y) { spriteTraceSize += 10; Must_have_memory = TRUE; /* XXX */ - spriteTrace = (WindowPtr *)xrealloc( + spriteTrace = (WindowPtr *)realloc( spriteTrace, spriteTraceSize*sizeof(WindowPtr)); Must_have_memory = FALSE; /* XXX */ } @@ -2039,6 +1949,7 @@ XYToWindow(int x, int y) } return spriteTrace[spriteTraceGood-1]; } +#endif /* NXAGENT_SERVER */ static Bool CheckMotion(xEvent *xE) @@ -2055,35 +1966,17 @@ CheckMotion(xEvent *xE) if (sprite.hot.pScreen != sprite.hotPhys.pScreen) { sprite.hot.pScreen = sprite.hotPhys.pScreen; - ROOT = WindowTable[sprite.hot.pScreen->myNum]; + ROOT = sprite.hot.pScreen->root; } -#ifdef XEVIE - xeviehot.x = -#endif sprite.hot.x = XE_KBPTR.rootX; -#ifdef XEVIE - xeviehot.y = -#endif sprite.hot.y = XE_KBPTR.rootY; if (sprite.hot.x < sprite.physLimits.x1) -#ifdef XEVIE - xeviehot.x = -#endif sprite.hot.x = sprite.physLimits.x1; else if (sprite.hot.x >= sprite.physLimits.x2) -#ifdef XEVIE - xeviehot.x = -#endif sprite.hot.x = sprite.physLimits.x2 - 1; if (sprite.hot.y < sprite.physLimits.y1) -#ifdef XEVIE - xeviehot.y = -#endif sprite.hot.y = sprite.physLimits.y1; else if (sprite.hot.y >= sprite.physLimits.y2) -#ifdef XEVIE - xeviehot.y = -#endif sprite.hot.y = sprite.physLimits.y2 - 1; #ifdef SHAPE if (sprite.hotShape) @@ -2101,9 +1994,6 @@ CheckMotion(xEvent *xE) XE_KBPTR.rootY = sprite.hot.y; } -#ifdef XEVIE - xeviewin = -#endif sprite.win = XYToWindow(sprite.hot.x, sprite.hot.y); #ifdef notyet if (!(sprite.win->deliverableEvents & @@ -2134,13 +2024,12 @@ WindowsRestructured() #ifdef PANORAMIX /* This was added to support reconfiguration under Xdmx. The problem is - * that if the 0th screen (i.e., WindowTable[0]) is moved to an origin + * that if the 0th screen (i.e., screenInfo.screens[0]->root) is moved to an origin * other than 0,0, the information in the private sprite structure must * be updated accordingly, or XYToWindow (and other routines) will not * compute correctly. */ void ReinitializeRootWindow(WindowPtr win, int xoff, int yoff) { - ScreenPtr pScreen = win->drawable.pScreen; GrabPtr grab; if (noPanoramiXExtension) return; @@ -2156,10 +2045,10 @@ void ReinitializeRootWindow(WindowPtr win, int xoff, int yoff) sprite.hotLimits.x2 -= xoff; sprite.hotLimits.y2 -= yoff; - if (REGION_NOTEMPTY(sprite.screen, &sprite.Reg1)) - REGION_TRANSLATE(sprite.screen, &sprite.Reg1, xoff, yoff); - if (REGION_NOTEMPTY(sprite.screen, &sprite.Reg2)) - REGION_TRANSLATE(sprite.screen, &sprite.Reg2, xoff, yoff); + if (RegionNotEmpty(&sprite.Reg1)) + RegionTranslate(&sprite.Reg1, xoff, yoff); + if (RegionNotEmpty(&sprite.Reg2)) + RegionTranslate(&sprite.Reg2, xoff, yoff); /* FIXME: if we call ConfineCursorToWindow, must we do anything else? */ if ((grab = inputInfo.pointer->grab) && grab->confineTo) { @@ -2167,11 +2056,12 @@ void ReinitializeRootWindow(WindowPtr win, int xoff, int yoff) sprite.hotPhys.x = sprite.hotPhys.y = 0; ConfineCursorToWindow(grab->confineTo, TRUE, TRUE); } else - ConfineCursorToWindow(WindowTable[sprite.hotPhys.pScreen->myNum], + ConfineCursorToWindow(sprite.hotPhys.pScreen->root, TRUE, FALSE); } #endif +#ifndef NXAGENT_SERVER void DefineInitialRootWindow(register WindowPtr win) { @@ -2183,9 +2073,6 @@ DefineInitialRootWindow(register WindowPtr win) sprite.hot = sprite.hotPhys; sprite.hotLimits.x2 = pScreen->width; sprite.hotLimits.y2 = pScreen->height; -#ifdef XEVIE - xeviewin = -#endif sprite.win = win; sprite.current = wCursor (win); sprite.current->refcnt++; @@ -2211,11 +2098,12 @@ DefineInitialRootWindow(register WindowPtr win) #endif sprite.screen = pScreen; /* gotta UNINIT these someplace */ - REGION_NULL(pScreen, &sprite.Reg1); - REGION_NULL(pScreen, &sprite.Reg2); + RegionNull(&sprite.Reg1); + RegionNull(&sprite.Reg2); } #endif } +#endif /* NXAGENT_SERVER */ /* * This does not take any shortcuts, and even ignores its argument, since @@ -2247,7 +2135,7 @@ NewCurrentScreen(ScreenPtr newScreen, int x, int y) if(sprite.confineWin) XineramaConfineCursorToWindow(sprite.confineWin, TRUE); else - XineramaConfineCursorToWindow(WindowTable[0], TRUE); + XineramaConfineCursorToWindow(screenInfo.screens[0]->root, TRUE); /* if the pointer wasn't confined, the DDX won't get told of the pointer warp so we reposition it here */ if(!syncEvents.playingEvents) @@ -2260,7 +2148,7 @@ NewCurrentScreen(ScreenPtr newScreen, int x, int y) } else #endif if (newScreen != sprite.hotPhys.pScreen) - ConfineCursorToWindow(WindowTable[newScreen->myNum], TRUE, FALSE); + ConfineCursorToWindow(newScreen->root, TRUE, FALSE); } #ifdef PANORAMIX @@ -2272,13 +2160,12 @@ XineramaPointInWindowIsVisible( int y ) { - ScreenPtr pScreen = pWin->drawable.pScreen; BoxRec box; int i, xoff, yoff; if (!pWin->realized) return FALSE; - if (POINT_IN_REGION(pScreen, &pWin->borderClip, x, y, &box)) + if (RegionContainsPoint(&pWin->borderClip, x, y, &box)) return TRUE; if(!XineramaSetWindowPntrs(pWin)) return FALSE; @@ -2288,13 +2175,12 @@ XineramaPointInWindowIsVisible( for(i = 1; i < PanoramiXNumScreens; i++) { pWin = sprite.windows[i]; - pScreen = pWin->drawable.pScreen; x = xoff - panoramiXdataPtr[i].x; y = yoff - panoramiXdataPtr[i].y; - if(POINT_IN_REGION(pScreen, &pWin->borderClip, x, y, &box) + if(RegionContainsPoint(&pWin->borderClip, x, y, &box) && (!wInputShape(pWin) || - POINT_IN_REGION(pWin->drawable.pScreen, + RegionContainsPoint( wInputShape(pWin), x - pWin->drawable.x, y - pWin->drawable.y, &box))) @@ -2316,7 +2202,7 @@ XineramaWarpPointer(ClientPtr client) if (stuff->dstWid != None) { - dest = SecurityLookupWindow(stuff->dstWid, client, SecurityReadAccess); + dest = SecurityLookupWindow(stuff->dstWid, client, DixReadAccess); if (!dest) return BadWindow; } @@ -2329,12 +2215,12 @@ XineramaWarpPointer(ClientPtr client) XID winID = stuff->srcWid; WindowPtr source; - source = SecurityLookupWindow(winID, client, SecurityReadAccess); + source = SecurityLookupWindow(winID, client, DixReadAccess); if (!source) return BadWindow; winX = source->drawable.x; winY = source->drawable.y; - if(source == WindowTable[0]) { + if(source == screenInfo.screens[0]->root) { winX -= panoramiXdataPtr[0].x; winY -= panoramiXdataPtr[0].y; } @@ -2350,7 +2236,7 @@ XineramaWarpPointer(ClientPtr client) if (dest) { x = dest->drawable.x; y = dest->drawable.y; - if(dest == WindowTable[0]) { + if(dest == screenInfo.screens[0]->root) { x -= panoramiXdataPtr[0].x; y -= panoramiXdataPtr[0].y; } @@ -2396,7 +2282,7 @@ ProcWarpPointer(ClientPtr client) if (stuff->dstWid != None) { - dest = SecurityLookupWindow(stuff->dstWid, client, SecurityReadAccess); + dest = SecurityLookupWindow(stuff->dstWid, client, DixReadAccess); if (!dest) return BadWindow; } @@ -2409,7 +2295,7 @@ ProcWarpPointer(ClientPtr client) XID winID = stuff->srcWid; WindowPtr source; - source = SecurityLookupWindow(winID, client, SecurityReadAccess); + source = SecurityLookupWindow(winID, client, DixReadAccess); if (!source) return BadWindow; winX = source->drawable.x; @@ -2470,7 +2356,7 @@ ProcWarpPointer(ClientPtr client) static Bool BorderSizeNotEmpty(WindowPtr pWin) { - if(REGION_NOTEMPTY(sprite.hotPhys.pScreen, &pWin->borderSize)) + if(RegionNotEmpty(&pWin->borderSize)) return TRUE; #ifdef PANORAMIX @@ -2478,7 +2364,7 @@ BorderSizeNotEmpty(WindowPtr pWin) int i; for(i = 1; i < PanoramiXNumScreens; i++) { - if(REGION_NOTEMPTY(sprite.screen, &sprite.windows[i]->borderSize)) + if(RegionNotEmpty(&sprite.windows[i]->borderSize)) return TRUE; } } @@ -2566,7 +2452,7 @@ CheckPassiveGrabsOnWindow( if (device->sync.evcount < count) { Must_have_memory = TRUE; /* XXX */ - device->sync.event = (xEvent *)xrealloc(device->sync.event, + device->sync.event = (xEvent *)realloc(device->sync.event, count* sizeof(xEvent)); Must_have_memory = FALSE; /* XXX */ @@ -2587,7 +2473,7 @@ CheckPassiveGrabsOnWindow( a passive grab to be activated. If the event is a keyboard event, the ancestors of the focus window are traced down and tried to see if they have any passive grabs to be activated. If the focus window itself is reached and -it's descendants contain they pointer, the ancestors of the window that the +its descendants contain the pointer, the ancestors of the window that the pointer is in are then traced down starting at the focus window, otherwise no grabs are activated. If the event is a pointer event, the ancestors of the window that the pointer is in are traced down starting at the root until @@ -2738,7 +2624,7 @@ DeliverGrabbedEvent(register xEvent *xE, register DeviceIntPtr thisDev, if (thisDev->sync.evcount < count) { Must_have_memory = TRUE; /* XXX */ - thisDev->sync.event = (xEvent *)xrealloc(thisDev->sync.event, + thisDev->sync.event = (xEvent *)realloc(thisDev->sync.event, count*sizeof(xEvent)); Must_have_memory = FALSE; /* XXX */ } @@ -2764,45 +2650,6 @@ ProcessKeyboardEvent (register xEvent *xE, register DeviceIntPtr keybd, int coun GrabPtr grab = keybd->grab; Bool deactivateGrab = FALSE; register KeyClassPtr keyc = keybd->key; -#ifdef XEVIE - static Window rootWin = 0; - - if(!xeviegrabState && xevieFlag && clients[xevieClientIndex] && - (xevieMask & xevieFilters[xE->u.u.type])) { - key = xE->u.u.detail; - kptr = &keyc->down[key >> 3]; - bit = 1 << (key & 7); - if((xE->u.u.type == KeyPress && (*kptr & bit)) || - (xE->u.u.type == KeyRelease && !(*kptr & bit))) - {} else { -#ifdef XKB - if(!noXkbExtension) - xevieKBEventSent = 1; -#endif - if(!xevieKBEventSent) - { - xeviekb = keybd; - if(!rootWin) { - rootWin = GetCurrentRootWindow()->drawable.id; - } - xE->u.keyButtonPointer.event = xeviewin->drawable.id; - xE->u.keyButtonPointer.root = rootWin; - 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; - WriteToClient(clients[xevieClientIndex], sizeof(xEvent), (char *)xE); -#ifdef XKB - if(noXkbExtension) -#endif - return; - } else { - xevieKBEventSent = 0; - } - } - } -#endif if (!syncEvents.playingEvents) { @@ -2812,18 +2659,9 @@ drawable.id:0; DeviceEventInfoRec eventinfo; eventinfo.events = xE; eventinfo.count = count; - CallCallbacks(&DeviceEventCallback, (pointer)&eventinfo); + CallCallbacks(&DeviceEventCallback, (void *)&eventinfo); } } -#ifdef XEVIE - /* fix for bug5094030: don't change the state bit if the event is from XEvIE client */ - if(!(!xeviegrabState && xevieFlag && clients[xevieClientIndex] && - (xevieMask & xevieFilters[xE->u.u.type] -#ifdef XKB - && !noXkbExtension -#endif - ))) -#endif XE_KBPTR.state = (keyc->state | inputInfo.pointer->button->state); XE_KBPTR.rootX = sprite.hot.x; XE_KBPTR.rootY = sprite.hot.y; @@ -2831,16 +2669,6 @@ drawable.id:0; kptr = &keyc->down[key >> 3]; bit = 1 << (key & 7); modifiers = keyc->modifierMap[key]; -#if defined(XKB) && defined(XEVIE) - if(!noXkbExtension && !xeviegrabState && - xevieFlag && clients[xevieClientIndex] && - (xevieMask & xevieFilters[xE->u.u.type])) { - switch(xE->u.u.type) { - case KeyPress: *kptr &= ~bit; break; - case KeyRelease: *kptr |= bit; break; - } - } -#endif #ifdef DEBUG if ((xkbDebugFlags&0x4)&& @@ -2963,18 +2791,6 @@ ProcessPointerEvent (register xEvent *xE, register DeviceIntPtr mouse, int count #ifdef XKB XkbSrvInfoPtr xkbi= inputInfo.keyboard->key->xkbInfo; #endif -#ifdef XEVIE - if(xevieFlag && clients[xevieClientIndex] && !xeviegrabState && - (xevieMask & xevieFilters[xE->u.u.type])) { - if(xevieEventSent) - xevieEventSent = 0; - else { - xeviemouse = mouse; - WriteToClient(clients[xevieClientIndex], sizeof(xEvent), (char *)xE); - return; - } - } -#endif if (!syncEvents.playingEvents) NoticeTime(xE) @@ -2995,10 +2811,10 @@ ProcessPointerEvent (register xEvent *xE, register DeviceIntPtr mouse, int count /* see comment in EnqueueEvents regarding the next three lines */ if (xE->u.u.type == MotionNotify) XE_KBPTR.root = - WindowTable[sprite.hotPhys.pScreen->myNum]->drawable.id; + sprite.hotPhys.pScreen->root->drawable.id; eventinfo.events = xE; eventinfo.count = count; - CallCallbacks(&DeviceEventCallback, (pointer)&eventinfo); + CallCallbacks(&DeviceEventCallback, (void *)&eventinfo); } } if (xE->u.u.type != MotionNotify) @@ -3111,7 +2927,7 @@ RecalculateDeliverableEvents(pWin) * \param value must conform to DeleteType */ int -OtherClientGone(pointer value, XID id) +OtherClientGone(void * value, XID id) { register OtherClientsPtr other, prev; register WindowPtr pWin = (WindowPtr)value; @@ -3128,7 +2944,7 @@ OtherClientGone(pointer value, XID id) if (!(pWin->optional->otherClients = other->next)) CheckWindowOptionalNeed (pWin); } - xfree(other); + free(other); RecalculateDeliverableEvents(pWin); return(Success); } @@ -3169,12 +2985,7 @@ EventSelectForWindow(register WindowPtr pWin, register ClientPtr client, Mask ma if (wClient (pWin) == client) { check = pWin->eventMask; -#ifdef SGIMISC - pWin->eventMask = - (mask & ~SGIMiscSpecialDestroyMask) | (pWin->eventMask & SGIMiscSpecialDestroyMask); -#else pWin->eventMask = mask; -#endif } else { @@ -3183,9 +2994,6 @@ EventSelectForWindow(register WindowPtr pWin, register ClientPtr client, Mask ma if (SameClient(others, client)) { check = others->mask; -#ifdef SGIMISC - mask = (mask & ~SGIMiscSpecialDestroyMask) | (others->mask & SGIMiscSpecialDestroyMask); -#endif if (mask == 0) { FreeResource(others->resource, RT_NONE); @@ -3199,14 +3007,14 @@ EventSelectForWindow(register WindowPtr pWin, register ClientPtr client, Mask ma check = 0; if (!pWin->optional && !MakeWindowOptional (pWin)) return BadAlloc; - others = (OtherClients *) xalloc(sizeof(OtherClients)); + others = (OtherClients *) malloc(sizeof(OtherClients)); if (!others) return BadAlloc; others->mask = mask; others->resource = FakeClientID(client->index); others->next = pWin->optional->otherClients; pWin->optional->otherClients = others; - if (!AddResource(others->resource, RT_OTHERCLIENT, (pointer)pWin)) + if (!AddResource(others->resource, RT_OTHERCLIENT, (void *)pWin)) return BadAlloc; } maskSet: @@ -3293,7 +3101,6 @@ EnterLeaveEvent( register WindowPtr pWin, Window child) { - xEvent event; register DeviceIntPtr keybd = inputInfo.keyboard; WindowPtr focus; register DeviceIntPtr mouse = inputInfo.pointer; @@ -3315,6 +3122,8 @@ EnterLeaveEvent( } if (mask & filters[type]) { + xEvent event; + memset(&event, 0, sizeof(xEvent)); event.u.u.type = type; event.u.u.detail = detail; event.u.enterLeave.time = currentTime.milliseconds; @@ -3436,6 +3245,7 @@ FocusEvent(DeviceIntPtr dev, int type, int mode, int detail, register WindowPtr return; } #endif + memset(&event, 0, sizeof(xEvent)); event.u.focus.mode = mode; event.u.u.type = type; event.u.u.detail = detail; @@ -3529,11 +3339,11 @@ DoFocusEvents(DeviceIntPtr dev, WindowPtr fromWin, WindowPtr toWin, int mode) /* Notify all the roots */ #ifdef PANORAMIX if ( !noPanoramiXExtension ) - FocusEvent(dev, FocusOut, mode, out, WindowTable[0]); + FocusEvent(dev, FocusOut, mode, out, screenInfo.screens[0]->root); else #endif for (i=0; i<screenInfo.numScreens; i++) - FocusEvent(dev, FocusOut, mode, out, WindowTable[i]); + FocusEvent(dev, FocusOut, mode, out, screenInfo.screens[i]->root); } else { @@ -3548,11 +3358,11 @@ DoFocusEvents(DeviceIntPtr dev, WindowPtr fromWin, WindowPtr toWin, int mode) /* Notify all the roots */ #ifdef PANORAMIX if ( !noPanoramiXExtension ) - FocusEvent(dev, FocusIn, mode, in, WindowTable[0]); + FocusEvent(dev, FocusIn, mode, in, screenInfo.screens[0]->root); else #endif for (i=0; i<screenInfo.numScreens; i++) - FocusEvent(dev, FocusIn, mode, in, WindowTable[i]); + FocusEvent(dev, FocusIn, mode, in, screenInfo.screens[i]->root); if (toWin == PointerRootWin) (void)FocusInEvents(dev, ROOT, sprite.win, NullWindow, mode, NotifyPointer, TRUE); @@ -3566,11 +3376,11 @@ DoFocusEvents(DeviceIntPtr dev, WindowPtr fromWin, WindowPtr toWin, int mode) TRUE); #ifdef PANORAMIX if ( !noPanoramiXExtension ) - FocusEvent(dev, FocusOut, mode, out, WindowTable[0]); + FocusEvent(dev, FocusOut, mode, out, screenInfo.screens[0]->root); else #endif for (i=0; i<screenInfo.numScreens; i++) - FocusEvent(dev, FocusOut, mode, out, WindowTable[i]); + FocusEvent(dev, FocusOut, mode, out, screenInfo.screens[i]->root); if (toWin->parent != NullWindow) (void)FocusInEvents(dev, ROOT, toWin, toWin, mode, NotifyNonlinearVirtual, TRUE); @@ -3661,7 +3471,7 @@ SetInputFocus( else if ((focusID == FollowKeyboard) && followOK) focusWin = inputInfo.keyboard->focus->win; else if (!(focusWin = SecurityLookupWindow(focusID, client, - SecurityReadAccess))) + DixReadAccess))) return BadWindow; else { @@ -3698,7 +3508,7 @@ SetInputFocus( { focus->traceSize = depth+1; Must_have_memory = TRUE; /* XXX */ - focus->trace = (WindowPtr *)xrealloc(focus->trace, + focus->trace = (WindowPtr *)realloc(focus->trace, focus->traceSize * sizeof(WindowPtr)); Must_have_memory = FALSE; /* XXX */ @@ -3733,6 +3543,7 @@ ProcGetInputFocus(ClientPtr client) FocusClassPtr focus = inputInfo.keyboard->focus; REQUEST_SIZE_MATCH(xReq); + memset(&rep, 0, sizeof(xGetInputFocusReply)); rep.type = X_Reply; rep.length = 0; rep.sequenceNumber = client->sequence; @@ -3781,7 +3592,7 @@ ProcGrabPointer(ClientPtr client) client->errorValue = stuff->eventMask; return BadValue; } - pWin = SecurityLookupWindow(stuff->grabWindow, client, SecurityReadAccess); + pWin = SecurityLookupWindow(stuff->grabWindow, client, DixReadAccess); if (!pWin) return BadWindow; if (stuff->confineTo == None) @@ -3789,7 +3600,7 @@ ProcGrabPointer(ClientPtr client) else { confineTo = SecurityLookupWindow(stuff->confineTo, client, - SecurityReadAccess); + DixReadAccess); if (!confineTo) return BadWindow; } @@ -3798,7 +3609,7 @@ ProcGrabPointer(ClientPtr client) else { cursor = (CursorPtr)SecurityLookupIDByType(client, stuff->cursor, - RT_CURSOR, SecurityReadAccess); + RT_CURSOR, DixReadAccess); if (!cursor) { client->errorValue = stuff->cursor; @@ -3807,6 +3618,7 @@ ProcGrabPointer(ClientPtr client) } /* at this point, some sort of reply is guaranteed. */ time = ClientTimeToServerTime(stuff->time); + memset(&rep, 0, sizeof(xGrabPointerReply)); rep.type = X_Reply; rep.sequenceNumber = client->sequence; rep.length = 0; @@ -3872,7 +3684,7 @@ ProcChangeActivePointerGrab(ClientPtr client) else { newCursor = (CursorPtr)SecurityLookupIDByType(client, stuff->cursor, - RT_CURSOR, SecurityReadAccess); + RT_CURSOR, DixReadAccess); if (!newCursor) { client->errorValue = stuff->cursor; @@ -3942,7 +3754,7 @@ GrabDevice(register ClientPtr client, register DeviceIntPtr dev, client->errorValue = ownerEvents; return BadValue; } - pWin = SecurityLookupWindow(grabWindow, client, SecurityReadAccess); + pWin = SecurityLookupWindow(grabWindow, client, DixReadAccess); if (!pWin) return BadWindow; time = ClientTimeToServerTime(ctime); @@ -3982,6 +3794,7 @@ ProcGrabKeyboard(ClientPtr client) int result; REQUEST_SIZE_MATCH(xGrabKeyboardReq); + memset(&rep, 0, sizeof(xGrabKeyboardReply)); #ifdef XCSECURITY if (!SecurityCheckDeviceAccess(client, inputInfo.keyboard, TRUE)) { @@ -4031,11 +3844,12 @@ ProcQueryPointer(ClientPtr client) DeviceIntPtr mouse = inputInfo.pointer; REQUEST_SIZE_MATCH(xResourceReq); - pWin = SecurityLookupWindow(stuff->id, client, SecurityReadAccess); + pWin = SecurityLookupWindow(stuff->id, client, DixReadAccess); if (!pWin) return BadWindow; if (mouse->valuator->motionHintWindow) MaybeStopHint(mouse, client); + memset(&rep, 0, sizeof(xQueryPointerReply)); rep.type = X_Reply; rep.sequenceNumber = client->sequence; rep.mask = mouse->button->state | inputInfo.keyboard->key->state; @@ -4093,16 +3907,13 @@ InitEvents() if (spriteTraceSize == 0) { spriteTraceSize = 32; - spriteTrace = (WindowPtr *)xalloc(32*sizeof(WindowPtr)); + spriteTrace = (WindowPtr *)malloc(32*sizeof(WindowPtr)); if (!spriteTrace) FatalError("failed to allocate spriteTrace"); } spriteTraceGood = 0; lastEventMask = OwnerGrabButtonMask; filters[MotionNotify] = PointerMotionMask; -#ifdef XEVIE - xeviewin = -#endif sprite.win = NullWindow; sprite.current = NullCursor; sprite.hotLimits.x1 = 0; @@ -4115,7 +3926,7 @@ InitEvents() while (syncEvents.pending) { QdEventPtr next = syncEvents.pending->next; - xfree(syncEvents.pending); + free(syncEvents.pending); syncEvents.pending = next; } syncEvents.pendtail = &syncEvents.pending; @@ -4135,11 +3946,12 @@ InitEvents() void CloseDownEvents(void) { - xfree(spriteTrace); + free(spriteTrace); spriteTrace = NULL; spriteTraceSize = 0; } +#ifndef NXAGENT_SERVER int ProcSendEvent(ClientPtr client) { @@ -4199,7 +4011,7 @@ ProcSendEvent(ClientPtr client) } else pWin = SecurityLookupWindow(stuff->destination, client, - SecurityReadAccess); + DixReadAccess); if (!pWin) return BadWindow; if ((stuff->propagate != xFalse) && (stuff->propagate != xTrue)) @@ -4227,6 +4039,7 @@ ProcSendEvent(ClientPtr client) NullGrab, 0); return Success; } +#endif /* NXAGENT_SERVER */ int ProcUngrabKey(ClientPtr client) @@ -4237,7 +4050,7 @@ ProcUngrabKey(ClientPtr client) DeviceIntPtr keybd = inputInfo.keyboard; REQUEST_SIZE_MATCH(xUngrabKeyReq); - pWin = SecurityLookupWindow(stuff->grabWindow, client, SecurityReadAccess); + pWin = SecurityLookupWindow(stuff->grabWindow, client, DixReadAccess); if (!pWin) return BadWindow; @@ -4308,7 +4121,7 @@ ProcGrabKey(ClientPtr client) client->errorValue = stuff->modifiers; return BadValue; } - pWin = SecurityLookupWindow(stuff->grabWindow, client, SecurityReadAccess); + pWin = SecurityLookupWindow(stuff->grabWindow, client, DixReadAccess); if (!pWin) return BadWindow; @@ -4360,14 +4173,14 @@ ProcGrabButton(ClientPtr client) client->errorValue = stuff->eventMask; return BadValue; } - pWin = SecurityLookupWindow(stuff->grabWindow, client, SecurityReadAccess); + pWin = SecurityLookupWindow(stuff->grabWindow, client, DixReadAccess); if (!pWin) return BadWindow; if (stuff->confineTo == None) confineTo = NullWindow; else { confineTo = SecurityLookupWindow(stuff->confineTo, client, - SecurityReadAccess); + DixReadAccess); if (!confineTo) return BadWindow; } @@ -4376,7 +4189,7 @@ ProcGrabButton(ClientPtr client) else { cursor = (CursorPtr)SecurityLookupIDByType(client, stuff->cursor, - RT_CURSOR, SecurityReadAccess); + RT_CURSOR, DixReadAccess); if (!cursor) { client->errorValue = stuff->cursor; @@ -4411,7 +4224,7 @@ ProcUngrabButton(ClientPtr client) client->errorValue = stuff->modifiers; return BadValue; } - pWin = SecurityLookupWindow(stuff->grabWindow, client, SecurityReadAccess); + pWin = SecurityLookupWindow(stuff->grabWindow, client, DixReadAccess); if (!pWin) return BadWindow; tempGrab.resource = client->clientAsMask; @@ -4565,7 +4378,7 @@ ProcRecolorCursor(ClientPtr client) REQUEST_SIZE_MATCH(xRecolorCursorReq); pCursor = (CursorPtr)SecurityLookupIDByType(client, stuff->cursor, - RT_CURSOR, SecurityWriteAccess); + RT_CURSOR, DixWriteAccess); if ( !pCursor) { client->errorValue = stuff->cursor; @@ -4604,6 +4417,13 @@ WriteEventsToClient(ClientPtr pClient, int count, xEvent *events) xEvent eventTo, *eventFrom; int i; + if (!pClient || pClient == serverClient || pClient->clientGone) + return; + + for (i = 0; i < count; i++) + if ((events[i].u.u.type & 0x7f) != KeymapNotify) + events[i].u.u.sequenceNumber = pClient->sequence; + #ifdef XKB if ((!noXkbExtension)&&(!XkbFilterEvents(pClient, count, events))) return; @@ -4649,7 +4469,7 @@ WriteEventsToClient(ClientPtr pClient, int count, xEvent *events) eventinfo.client = pClient; eventinfo.events = events; eventinfo.count = count; - CallCallbacks(&EventCallback, (pointer)&eventinfo); + CallCallbacks(&EventCallback, (void *)&eventinfo); } if(pClient->swapped) { @@ -4660,11 +4480,11 @@ WriteEventsToClient(ClientPtr pClient, int count, xEvent *events) this event was sent with "SendEvent." */ (*EventSwapVector[eventFrom->u.u.type & 0177]) (eventFrom, &eventTo); - (void)WriteToClient(pClient, sizeof(xEvent), (char *)&eventTo); + WriteToClient(pClient, sizeof(xEvent), &eventTo); } } else { - (void)WriteToClient(pClient, count * sizeof(xEvent), (char *) events); + WriteToClient(pClient, count * sizeof(xEvent), events); } } diff --git a/nx-X11/programs/Xserver/dix/extension.c b/nx-X11/programs/Xserver/dix/extension.c index 270d54f9b..a1701281d 100644 --- a/nx-X11/programs/Xserver/dix/extension.c +++ b/nx-X11/programs/Xserver/dix/extension.c @@ -1,4 +1,3 @@ -/* $XFree86: xc/programs/Xserver/dix/extension.c,v 3.11 2001/12/14 19:59:31 dawes Exp $ */ /*********************************************************** Copyright 1987, 1998 The Open Group @@ -45,16 +44,13 @@ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ******************************************************************/ -/* $Xorg: extension.c,v 1.4 2001/02/09 02:04:40 xorgcvs Exp $ */ #ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> #endif -#include <X11/X.h> -#define NEED_EVENTS -#define NEED_REPLIES -#include <X11/Xproto.h> +#include <nx-X11/X.h> +#include <nx-X11/Xproto.h> #include "misc.h" #include "dixstruct.h" #include "extnsionst.h" @@ -63,10 +59,7 @@ SOFTWARE. #include "dispatch.h" #ifdef XCSECURITY #define _SECURITY_SERVER -#include <X11/extensions/security.h> -#endif -#ifdef LBX -#include "lbxserve.h" +#include <nx-X11/extensions/security.h> #endif #define EXTENSION_BASE 128 @@ -92,31 +85,31 @@ AddExtension(char *name, int NumEvents, int NumErrors, int i; register ExtensionEntry *ext, **newexts; - if (!MainProc || !SwappedMainProc || !CloseDownProc || !MinorOpcodeProc) + if (!MainProc || !SwappedMainProc || !MinorOpcodeProc) return((ExtensionEntry *) NULL); if ((lastEvent + NumEvents > LAST_EVENT) || (unsigned)(lastError + NumErrors > LAST_ERROR)) return((ExtensionEntry *) NULL); - ext = (ExtensionEntry *) xalloc(sizeof(ExtensionEntry)); + ext = (ExtensionEntry *) malloc(sizeof(ExtensionEntry)); if (!ext) return((ExtensionEntry *) NULL); - ext->name = (char *)xalloc(strlen(name) + 1); + ext->name = (char *)malloc(strlen(name) + 1); ext->num_aliases = 0; ext->aliases = (char **)NULL; if (!ext->name) { - xfree(ext); + free(ext); return((ExtensionEntry *) NULL); } strcpy(ext->name, name); i = NumExtensions; - newexts = (ExtensionEntry **) xrealloc(extensions, + newexts = (ExtensionEntry **) realloc(extensions, (i + 1) * sizeof(ExtensionEntry *)); if (!newexts) { - xfree(ext->name); - xfree(ext); + free(ext->name); + free(ext); return((ExtensionEntry *) NULL); } NumExtensions++; @@ -154,9 +147,6 @@ AddExtension(char *name, int NumEvents, int NumErrors, ext->secure = FALSE; #endif -#ifdef LBX - (void) LbxAddExtension(name, ext->base, ext->eventBase, ext->errorBase); -#endif return(ext); } @@ -165,22 +155,18 @@ Bool AddExtensionAlias(char *alias, ExtensionEntry *ext) char *name; char **aliases; - aliases = (char **)xrealloc(ext->aliases, + aliases = (char **)realloc(ext->aliases, (ext->num_aliases + 1) * sizeof(char *)); if (!aliases) return FALSE; ext->aliases = aliases; - name = (char *)xalloc(strlen(alias) + 1); + name = (char *)malloc(strlen(alias) + 1); if (!name) return FALSE; strcpy(name, alias); ext->aliases[ext->num_aliases] = name; ext->num_aliases++; -#ifdef LBX - return LbxAddExtensionAlias(ext->index, alias); -#else return TRUE; -#endif } static int @@ -241,9 +227,6 @@ DeclareExtensionSecurity(char *extname, Bool secure) } } #endif -#ifdef LBX - LbxDeclareExtensionSecurity(extname, secure); -#endif } unsigned short @@ -271,21 +254,18 @@ CloseDownExtensions() { register int i,j; -#ifdef LBX - LbxCloseDownExtensions(); -#endif - for (i = NumExtensions - 1; i >= 0; i--) { - (* extensions[i]->CloseDown)(extensions[i]); + if (extensions[i]->CloseDown) + (* extensions[i]->CloseDown)(extensions[i]); NumExtensions = i; - xfree(extensions[i]->name); + free(extensions[i]->name); for (j = extensions[i]->num_aliases; --j >= 0;) - xfree(extensions[i]->aliases[j]); - xfree(extensions[i]->aliases); - xfree(extensions[i]); + free(extensions[i]->aliases[j]); + free(extensions[i]->aliases); + free(extensions[i]); } - xfree(extensions); + free(extensions); extensions = (ExtensionEntry **)NULL; lastEvent = EXTENSION_EVENT_BASE; lastError = FirstExtensionError; @@ -296,14 +276,14 @@ CloseDownExtensions() while (spentry->num) { spentry->num--; - xfree(spentry->procList[spentry->num].name); + free(spentry->procList[spentry->num].name); } - xfree(spentry->procList); + free(spentry->procList); spentry->procList = (ProcEntryPtr)NULL; } } - +#ifndef NXAGENT_SERVER int ProcQueryExtension(ClientPtr client) { @@ -313,6 +293,7 @@ ProcQueryExtension(ClientPtr client) REQUEST_FIXED_SIZE(xQueryExtensionReq, stuff->nbytes); + memset(&reply, 0, sizeof(xQueryExtensionReply)); reply.type = X_Reply; reply.length = 0; reply.major_opcode = 0; @@ -352,6 +333,7 @@ ProcListExtensions(ClientPtr client) REQUEST_SIZE_MATCH(xReq); + memset(&reply, 0, sizeof(xListExtensionsReply)); reply.type = X_Reply; reply.nExtensions = 0; reply.length = 0; @@ -376,7 +358,7 @@ ProcListExtensions(ClientPtr client) total_length += strlen(extensions[i]->aliases[j]) + 1; } reply.length = (total_length + 3) >> 2; - buffer = bufptr = (char *)ALLOCATE_LOCAL(total_length); + buffer = bufptr = (char *)malloc(total_length); if (!buffer) return(BadAlloc); for (i=0; i<NumExtensions; i++) @@ -402,11 +384,11 @@ ProcListExtensions(ClientPtr client) if (reply.length) { WriteToClient(client, total_length, buffer); - DEALLOCATE_LOCAL(buffer); + free(buffer); } return(client->noClientException); } - +#endif ExtensionLookupProc LookupProc(char *name, GCPtr pGC) @@ -452,15 +434,15 @@ RegisterScreenProc(char *name, ScreenPtr pScreen, ExtensionLookupProc proc) procEntry->proc = proc; else { - newname = (char *)xalloc(strlen(name)+1); + newname = (char *)malloc(strlen(name)+1); if (!newname) return FALSE; procEntry = (ProcEntryPtr) - xrealloc(spentry->procList, + realloc(spentry->procList, sizeof(ProcEntryRec) * (spentry->num+1)); if (!procEntry) { - xfree(newname); + free(newname); return FALSE; } spentry->procList = procEntry; diff --git a/nx-X11/programs/Xserver/dix/ffs.c b/nx-X11/programs/Xserver/dix/ffs.c index 8d0954689..e25d715dd 100644 --- a/nx-X11/programs/Xserver/dix/ffs.c +++ b/nx-X11/programs/Xserver/dix/ffs.c @@ -1,4 +1,3 @@ -/* $Xorg: ffs.c,v 1.4 2001/02/09 02:04:40 xorgcvs Exp $ */ /* Copyright 1996, 1998 The Open Group diff --git a/nx-X11/programs/Xserver/dix/gc.c b/nx-X11/programs/Xserver/dix/gc.c index cb21e09fd..d40334f5f 100644 --- a/nx-X11/programs/Xserver/dix/gc.c +++ b/nx-X11/programs/Xserver/dix/gc.c @@ -1,4 +1,3 @@ -/* $XFree86: xc/programs/Xserver/dix/gc.c,v 3.9 2001/12/14 19:59:32 dawes Exp $ */ /*********************************************************** Copyright 1987, 1998 The Open Group @@ -46,15 +45,14 @@ SOFTWARE. ******************************************************************/ -/* $Xorg: gc.c,v 1.4 2001/02/09 02:04:40 xorgcvs Exp $ */ #ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> #endif -#include <X11/X.h> -#include <X11/Xmd.h> -#include <X11/Xproto.h> +#include <nx-X11/X.h> +#include <nx-X11/Xmd.h> +#include <nx-X11/Xproto.h> #include "misc.h" #include "resource.h" #include "gcstruct.h" @@ -273,7 +271,7 @@ dixChangeGC(ClientPtr client, register GC *pGC, register BITS32 mask, CARD32 *pC { NEXTVAL(XID, newpix); pPixmap = (PixmapPtr)SecurityLookupIDByType(client, - newpix, RT_PIXMAP, SecurityReadAccess); + newpix, RT_PIXMAP, DixReadAccess); } if (pPixmap) { @@ -309,7 +307,7 @@ dixChangeGC(ClientPtr client, register GC *pGC, register BITS32 mask, CARD32 *pC { NEXTVAL(XID, newstipple) pPixmap = (PixmapPtr)SecurityLookupIDByType(client, - newstipple, RT_PIXMAP, SecurityReadAccess); + newstipple, RT_PIXMAP, DixReadAccess); } if (pPixmap) { @@ -351,7 +349,7 @@ dixChangeGC(ClientPtr client, register GC *pGC, register BITS32 mask, CARD32 *pC { NEXTVAL(XID, newfont) pFont = (FontPtr)SecurityLookupIDByType(client, newfont, - RT_FONT, SecurityReadAccess); + RT_FONT, DixReadAccess); } if (pFont) { @@ -418,7 +416,7 @@ dixChangeGC(ClientPtr client, register GC *pGC, register BITS32 mask, CARD32 *pC } else pPixmap = (PixmapPtr)SecurityLookupIDByType(client, - pid, RT_PIXMAP, SecurityReadAccess); + pid, RT_PIXMAP, DixReadAccess); } if (pPixmap) @@ -442,7 +440,7 @@ dixChangeGC(ClientPtr client, register GC *pGC, register BITS32 mask, CARD32 *pC if(error == Success) { (*pGC->funcs->ChangeClip)(pGC, clipType, - (pointer)pPixmap, 0); + (void *)pPixmap, 0); } break; } @@ -457,7 +455,7 @@ dixChangeGC(ClientPtr client, register GC *pGC, register BITS32 mask, CARD32 *pC { if (pGC->dash != DefaultDash) { - xfree(pGC->dash); + free(pGC->dash); pGC->numInDashList = 2; pGC->dash = DefaultDash; } @@ -466,11 +464,11 @@ dixChangeGC(ClientPtr client, register GC *pGC, register BITS32 mask, CARD32 *pC { unsigned char *dash; - dash = (unsigned char *)xalloc(2 * sizeof(unsigned char)); + dash = (unsigned char *)malloc(2 * sizeof(unsigned char)); if (dash) { if (pGC->dash != DefaultDash) - xfree(pGC->dash); + free(pGC->dash); pGC->numInDashList = 2; pGC->dash = dash; dash[0] = newdash; @@ -534,7 +532,7 @@ ChangeGC(register GC *pGC, register BITS32 mask, XID *pval) pval contains an appropriate value for each mask. fPointer is true if the values for tiles, stipples, fonts or clipmasks are pointers instead of IDs. Note: if you are passing pointers you - MUST declare the array of values as type pointer! Other data types + MUST declare the array of values as type void*! Other data types may not be large enough to hold pointers on some machines. Yes, this means you have to cast to (XID *) when you pass the array to DoChangeGC. Similarly, if you are not passing pointers (fPointer = 0) you @@ -580,7 +578,7 @@ AllocateGC(ScreenPtr pScreen) register unsigned size; register int i; - pGC = (GCPtr)xalloc(pScreen->totalGCSize); + pGC = (GCPtr)malloc(pScreen->totalGCSize); if (pGC) { ppriv = (DevUnion *)(pGC + 1); @@ -591,11 +589,11 @@ AllocateGC(ScreenPtr pScreen) { if ( (size = *sizes) ) { - ppriv->ptr = (pointer)ptr; + ppriv->ptr = (void *)ptr; ptr += size; } else - ppriv->ptr = (pointer)NULL; + ppriv->ptr = (void *)NULL; } } return pGC; @@ -651,7 +649,7 @@ CreateGC(DrawablePtr pDrawable, BITS32 mask, XID *pval, int *pStatus) pGC->clipOrg.x = 0; pGC->clipOrg.y = 0; pGC->clientClipType = CT_NONE; - pGC->clientClip = (pointer)NULL; + pGC->clientClip = (void *)NULL; pGC->numInDashList = 2; pGC->dash = DefaultDash; pGC->dashOffset = 0; @@ -696,7 +694,7 @@ CreateDefaultTile (GCPtr pGC) (*pGC->pScreen->QueryBestSize)(TileShape, &w, &h, pGC->pScreen); pTile = (PixmapPtr) (*pGC->pScreen->CreatePixmap)(pGC->pScreen, - w, h, pGC->depth); + w, h, pGC->depth, 0); pgcScratch = GetScratchGC(pGC->depth, pGC->pScreen); if (!pTile || !pgcScratch) { @@ -838,7 +836,7 @@ CopyGC(register GC *pgcSrc, register GC *pgcDst, register BITS32 mask) { if (pgcDst->dash != DefaultDash) { - xfree(pgcDst->dash); + free(pgcDst->dash); pgcDst->numInDashList = pgcSrc->numInDashList; pgcDst->dash = pgcSrc->dash; } @@ -848,12 +846,12 @@ CopyGC(register GC *pgcSrc, register GC *pgcDst, register BITS32 mask) unsigned char *dash; unsigned int i; - dash = (unsigned char *)xalloc(pgcSrc->numInDashList * + dash = (unsigned char *)malloc(pgcSrc->numInDashList * sizeof(unsigned char)); if (dash) { if (pgcDst->dash != DefaultDash) - xfree(pgcDst->dash); + free(pgcDst->dash); pgcDst->numInDashList = pgcSrc->numInDashList; pgcDst->dash = dash; for (i=0; i<pgcSrc->numInDashList; i++) @@ -890,7 +888,7 @@ CopyGC(register GC *pgcSrc, register GC *pgcDst, register BITS32 mask) * \param value must conform to DeleteType */ int -FreeGC(pointer value, XID gid) +FreeGC(void * value, XID gid) { GCPtr pGC = (GCPtr)value; @@ -904,8 +902,8 @@ FreeGC(pointer value, XID gid) (*pGC->funcs->DestroyGC) (pGC); if (pGC->dash != DefaultDash) - xfree(pGC->dash); - xfree(pGC); + free(pGC->dash); + free(pGC); return(Success); } @@ -1049,7 +1047,7 @@ CreateDefaultStipple(int screenNum) h = 16; (* pScreen->QueryBestSize)(StippleShape, &w, &h, pScreen); if (!(pScreen->PixmapPerDepth[0] = - (*pScreen->CreatePixmap)(pScreen, w, h, 1))) + (*pScreen->CreatePixmap)(pScreen, w, h, 1, 0))) return FALSE; /* fill stipple with 1 */ tmpval[0] = GXcopy; tmpval[1] = 1; tmpval[2] = FillSolid; @@ -1098,9 +1096,9 @@ SetDashes(register GCPtr pGC, unsigned offset, unsigned ndash, unsigned char *pd } if (ndash & 1) - p = (unsigned char *)xalloc(2 * ndash * sizeof(unsigned char)); + p = (unsigned char *)malloc(2 * ndash * sizeof(unsigned char)); else - p = (unsigned char *)xalloc(ndash * sizeof(unsigned char)); + p = (unsigned char *)malloc(ndash * sizeof(unsigned char)); if (!p) return BadAlloc; @@ -1113,7 +1111,7 @@ SetDashes(register GCPtr pGC, unsigned offset, unsigned ndash, unsigned char *pd } if (pGC->dash != DefaultDash) - xfree(pGC->dash); + free(pGC->dash); pGC->numInDashList = ndash; pGC->dash = p; if (ndash & 1) @@ -1195,7 +1193,7 @@ SetClipRects(GCPtr pGC, int xOrigin, int yOrigin, int nrects, if (newct < 0) return(BadMatch); size = nrects * sizeof(xRectangle); - prectsNew = (xRectangle *) xalloc(size); + prectsNew = (xRectangle *) malloc(size); if (!prectsNew && size) return BadAlloc; @@ -1208,7 +1206,7 @@ SetClipRects(GCPtr pGC, int xOrigin, int yOrigin, int nrects, if (size) memmove((char *)prectsNew, (char *)prects, size); - (*pGC->funcs->ChangeClip)(pGC, newct, (pointer)prectsNew, nrects); + (*pGC->funcs->ChangeClip)(pGC, newct, (void *)prectsNew, nrects); if (pGC->funcs->ChangeGC) (*pGC->funcs->ChangeGC) (pGC, GCClipXOrigin|GCClipYOrigin|GCClipMask); return Success; diff --git a/nx-X11/programs/Xserver/dix/globals.c b/nx-X11/programs/Xserver/dix/globals.c index 15eedf602..f9fa544ed 100644 --- a/nx-X11/programs/Xserver/dix/globals.c +++ b/nx-X11/programs/Xserver/dix/globals.c @@ -1,5 +1,3 @@ -/* $XdotOrg: xc/programs/Xserver/dix/globals.c,v 1.7 2005/07/03 08:53:38 daniels Exp $ */ -/* $XFree86: xc/programs/Xserver/dix/globals.c,v 1.12tsi Exp $ */ /************************************************************ Copyright 1987, 1998 The Open Group @@ -47,14 +45,13 @@ SOFTWARE. ********************************************************/ -/* $Xorg: globals.c,v 1.4 2001/02/09 02:04:40 xorgcvs Exp $ */ #ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> #endif -#include <X11/X.h> -#include <X11/Xmd.h> +#include <nx-X11/X.h> +#include <nx-X11/Xmd.h> #include "misc.h" #include "windowstr.h" #include "scrnintstr.h" @@ -86,8 +83,6 @@ ClientPtr serverClient; int currentMaxClients; /* current size of clients array */ long maxBigRequestSize = MAX_BIG_REQUEST_SIZE; -WindowPtr *WindowTable; - unsigned long globalSerialNumber = 0; unsigned long serverGeneration = 0; @@ -135,7 +130,6 @@ int logoScreenSaver = DEFAULT_LOGO_SCREEN_SAVER; char *defaultFontPath = COMPILEDDEFAULTFONTPATH; char *defaultTextFont = COMPILEDDEFAULTFONT; char *defaultCursorFont = COMPILEDCURSORFONT; -char *rgbPath = RGB_DB; char *defaultDisplayClass = COMPILEDDISPLAYCLASS; FontPtr defaultFont; /* not declared in dix.h to avoid including font.h in every compilation of dix code */ @@ -155,9 +149,13 @@ int defaultColorVisualClass = -1; int monitorResolution = 0; char *display; +int displayfd = -1; +Bool explicit_display = FALSE; CARD32 TimeOutValue = DEFAULT_TIMEOUT * MILLI_PER_SECOND; int argcGlobal; char **argvGlobal; DDXPointRec dixScreenOrigins[MAXSCREENS]; + +char *ConnectionInfo; diff --git a/nx-X11/programs/Xserver/dix/glyphcurs.c b/nx-X11/programs/Xserver/dix/glyphcurs.c index 8f8adf5ce..5e36f158c 100644 --- a/nx-X11/programs/Xserver/dix/glyphcurs.c +++ b/nx-X11/programs/Xserver/dix/glyphcurs.c @@ -45,7 +45,6 @@ SOFTWARE. ************************************************************************/ -/* $Xorg: glyphcurs.c,v 1.4 2001/02/09 02:04:40 xorgcvs Exp $ */ #ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> @@ -74,6 +73,7 @@ the first one we find. cursor metrics. */ +#ifndef NXAGENT_SERVER int ServerBitsFromGlyph(FontPtr pfont, unsigned ch, register CursorMetricPtr cm, unsigned char **ppbits) { @@ -92,14 +92,15 @@ ServerBitsFromGlyph(FontPtr pfont, unsigned ch, register CursorMetricPtr cm, uns pScreen = screenInfo.screens[0]; nby = BitmapBytePad(cm->width) * (long)cm->height; - pbits = (char *)xalloc(nby); + pbits = (char *)malloc(nby); if (!pbits) return BadAlloc; /* zeroing the (pad) bits seems to help some ddx cursor handling */ bzero(pbits, nby); ppix = (PixmapPtr)(*pScreen->CreatePixmap)(pScreen, cm->width, - cm->height, 1); + cm->height, 1, + CREATE_PIXMAP_USAGE_SCRATCH); pGC = GetScratchGC(1, pScreen); if (!ppix || !pGC) { @@ -107,7 +108,7 @@ ServerBitsFromGlyph(FontPtr pfont, unsigned ch, register CursorMetricPtr cm, uns (*pScreen->DestroyPixmap)(ppix); if (pGC) FreeScratchGC(pGC); - xfree(pbits); + free(pbits); return BadAlloc; } @@ -119,7 +120,7 @@ ServerBitsFromGlyph(FontPtr pfont, unsigned ch, register CursorMetricPtr cm, uns /* fill the pixmap with 0 */ gcval[0].val = GXcopy; gcval[1].val = 0; - gcval[2].ptr = (pointer)pfont; + gcval[2].ptr = (void *)pfont; dixChangeGC(NullClient, pGC, GCFunction | GCForeground | GCFont, NULL, gcval); ValidateGC((DrawablePtr)ppix, pGC); @@ -138,7 +139,7 @@ ServerBitsFromGlyph(FontPtr pfont, unsigned ch, register CursorMetricPtr cm, uns (*pScreen->DestroyPixmap)(ppix); return Success; } - +#endif /* NXAGENT_SERVER */ Bool CursorMetricsFromGlyph(register FontPtr pfont, unsigned ch, register CursorMetricPtr cm) diff --git a/nx-X11/programs/Xserver/dix/grabs.c b/nx-X11/programs/Xserver/dix/grabs.c index 1d76f7f07..0068676c2 100644 --- a/nx-X11/programs/Xserver/dix/grabs.c +++ b/nx-X11/programs/Xserver/dix/grabs.c @@ -1,4 +1,3 @@ -/* $Xorg: grabs.c,v 1.4 2001/02/09 02:04:40 xorgcvs Exp $ */ /* Copyright 1987, 1998 The Open Group @@ -46,16 +45,14 @@ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $XFree86: xc/programs/Xserver/dix/grabs.c,v 3.4 2002/02/19 11:09:22 alanh Exp $ */ #ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> #endif -#include <X11/X.h> +#include <nx-X11/X.h> #include "misc.h" -#define NEED_EVENTS -#include <X11/Xproto.h> +#include <nx-X11/Xproto.h> #include "windowstr.h" #include "inputstr.h" #include "cursorstr.h" @@ -84,7 +81,7 @@ CreateGrab( { GrabPtr grab; - grab = (GrabPtr)xalloc(sizeof(GrabRec)); + grab = (GrabPtr)malloc(sizeof(GrabRec)); if (!grab) return (GrabPtr)NULL; grab->resource = FakeClientID(client); @@ -116,19 +113,19 @@ static void FreeGrab(GrabPtr pGrab) { if (pGrab->modifiersDetail.pMask != NULL) - xfree(pGrab->modifiersDetail.pMask); + free(pGrab->modifiersDetail.pMask); if (pGrab->detail.pMask != NULL) - xfree(pGrab->detail.pMask); + free(pGrab->detail.pMask); if (pGrab->cursor) FreeCursor(pGrab->cursor, (Cursor)0); - xfree(pGrab); + free(pGrab); } int -DeletePassiveGrab(pointer value, XID id) +DeletePassiveGrab(void * value, XID id) { register GrabPtr g, prev; GrabPtr pGrab = (GrabPtr)value; @@ -158,7 +155,7 @@ DeleteDetailFromMask(Mask *pDetailMask, unsigned short detail) register Mask *mask; register int i; - mask = (Mask *)xalloc(sizeof(Mask) * MasksPerDetailMask); + mask = (Mask *)malloc(sizeof(Mask) * MasksPerDetailMask); if (mask) { if (pDetailMask) @@ -295,7 +292,7 @@ AddPassiveGrabToList(GrabPtr pGrab) } pGrab->next = pGrab->window->optional->passiveGrabs; pGrab->window->optional->passiveGrabs = pGrab; - if (AddResource(pGrab->resource, RT_PASSIVEGRAB, (pointer)pGrab)) + if (AddResource(pGrab->resource, RT_PASSIVEGRAB, (void *)pGrab)) return Success; return BadAlloc; } @@ -324,16 +321,16 @@ DeletePassiveGrabFromList(GrabPtr pMinuendGrab) i++; if (!i) return TRUE; - deletes = (GrabPtr *)ALLOCATE_LOCAL(i * sizeof(GrabPtr)); - adds = (GrabPtr *)ALLOCATE_LOCAL(i * sizeof(GrabPtr)); - updates = (Mask ***)ALLOCATE_LOCAL(i * sizeof(Mask **)); - details = (Mask **)ALLOCATE_LOCAL(i * sizeof(Mask *)); + deletes = (GrabPtr *)malloc(i * sizeof(GrabPtr)); + adds = (GrabPtr *)malloc(i * sizeof(GrabPtr)); + updates = (Mask ***)malloc(i * sizeof(Mask **)); + details = (Mask **)malloc(i * sizeof(Mask *)); if (!deletes || !adds || !updates || !details) { - if (details) DEALLOCATE_LOCAL(details); - if (updates) DEALLOCATE_LOCAL(updates); - if (adds) DEALLOCATE_LOCAL(adds); - if (deletes) DEALLOCATE_LOCAL(deletes); + if (details) free(details); + if (updates) free(updates); + if (adds) free(adds); + if (deletes) free(deletes); return FALSE; } ndels = nadds = nups = 0; @@ -389,7 +386,7 @@ DeletePassiveGrabFromList(GrabPtr pMinuendGrab) ok = FALSE; } else if (!AddResource(pNewGrab->resource, RT_PASSIVEGRAB, - (pointer)pNewGrab)) + (void *)pNewGrab)) ok = FALSE; else adds[nadds++] = pNewGrab; @@ -410,7 +407,7 @@ DeletePassiveGrabFromList(GrabPtr pMinuendGrab) for (i = 0; i < nadds; i++) FreeResource(adds[i]->resource, RT_NONE); for (i = 0; i < nups; i++) - xfree(details[i]); + free(details[i]); } else { @@ -424,14 +421,14 @@ DeletePassiveGrabFromList(GrabPtr pMinuendGrab) } for (i = 0; i < nups; i++) { - xfree(*updates[i]); + free(*updates[i]); *updates[i] = details[i]; } } - DEALLOCATE_LOCAL(details); - DEALLOCATE_LOCAL(updates); - DEALLOCATE_LOCAL(adds); - DEALLOCATE_LOCAL(deletes); + free(details); + free(updates); + free(adds); + free(deletes); return ok; #undef UPDATE diff --git a/nx-X11/programs/Xserver/dix/initatoms.c b/nx-X11/programs/Xserver/dix/initatoms.c index a5972afd6..5f6244a76 100644 --- a/nx-X11/programs/Xserver/dix/initatoms.c +++ b/nx-X11/programs/Xserver/dix/initatoms.c @@ -7,8 +7,8 @@ #include <dix-config.h> #endif -#include <X11/X.h> -#include <X11/Xatom.h> +#include <nx-X11/X.h> +#include <nx-X11/Xatom.h> #include "misc.h" #include "dix.h" void MakePredeclaredAtoms() diff --git a/nx-X11/programs/Xserver/dix/main.c b/nx-X11/programs/Xserver/dix/main.c index 6a8f79a96..3f3c079e4 100644 --- a/nx-X11/programs/Xserver/dix/main.c +++ b/nx-X11/programs/Xserver/dix/main.c @@ -1,5 +1,3 @@ -/* $XdotOrg: xc/programs/Xserver/dix/main.c,v 1.14 2005/07/03 08:53:38 daniels Exp $ */ -/* $XFree86: xc/programs/Xserver/dix/main.c,v 3.43 2003/10/30 21:21:02 herrb Exp $ */ /*********************************************************** Copyright 1987, 1998 The Open Group @@ -46,7 +44,6 @@ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ******************************************************************/ -/* $Xorg: main.c,v 1.4 2001/02/09 02:04:40 xorgcvs Exp $ */ /* The panoramix components contained the following notice */ /***************************************************************** @@ -79,14 +76,13 @@ Equipment Corporation. /* $TOG: main.c /main/86 1998/02/09 14:20:03 kaleb $ */ -#define NEED_EVENTS #ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> #endif -#include <X11/X.h> -#include <X11/Xos.h> /* for unistd.h */ -#include <X11/Xproto.h> +#include <nx-X11/X.h> +#include <nx-X11/Xos.h> /* for unistd.h */ +#include <nx-X11/Xproto.h> #include "scrnintstr.h" #include "misc.h" #include "os.h" @@ -99,14 +95,18 @@ Equipment Corporation. #include "colormapst.h" #include "cursorstr.h" #include <X11/fonts/font.h> +#include <X11/fonts/fontstruct.h> +#ifdef HAS_XFONT2 +# include <X11/fonts/libxfont2.h> +#else +# include <X11/fonts/fontutil.h> +#endif /* HAS_XFONT2 */ #include "opaque.h" #include "servermd.h" #include "site.h" #include "dixfont.h" #include "extnsionst.h" -#ifdef XPRINT -#include "DiPrint.h" -#endif +#include "client.h" #ifdef PANORAMIX #include "panoramiXsrv.h" #else @@ -116,7 +116,7 @@ Equipment Corporation. #ifdef DPMSExtension #define DPMS_SERVER -#include <X11/extensions/dpms.h> +#include <nx-X11/extensions/dpms.h> #include "dpmsproc.h" #endif @@ -124,22 +124,20 @@ extern int InitClientPrivates(ClientPtr client); extern void Dispatch(void); -char *ConnectionInfo; xConnSetupPrefix connSetupPrefix; extern FontPtr defaultFont; -extern int screenPrivateCount; extern void InitProcVectors(void); extern Bool CreateGCperDepthArray(void); +extern void FreeScreen(ScreenPtr pScreen); + #ifndef PANORAMIX static #endif Bool CreateConnectionBlock(void); -static void FreeScreen(ScreenPtr); - PaddingInfo PixmapWidthPaddingInfo[33]; int connBlockScreenStart; @@ -166,98 +164,16 @@ ReplyNotSwappd( FatalError("Not implemented"); } -/* - * This array encodes the answer to the question "what is the log base 2 - * of the number of pixels that fit in a scanline pad unit?" - * Note that ~0 is an invalid entry (mostly for the benefit of the reader). - */ -static int answer[6][4] = { - /* pad pad pad pad*/ - /* 8 16 32 64 */ - - { 3, 4, 5 , 6 }, /* 1 bit per pixel */ - { 1, 2, 3 , 4 }, /* 4 bits per pixel */ - { 0, 1, 2 , 3 }, /* 8 bits per pixel */ - { ~0, 0, 1 , 2 }, /* 16 bits per pixel */ - { ~0, ~0, 0 , 1 }, /* 24 bits per pixel */ - { ~0, ~0, 0 , 1 } /* 32 bits per pixel */ -}; - -/* - * This array gives the answer to the question "what is the first index for - * the answer array above given the number of bits per pixel?" - * Note that ~0 is an invalid entry (mostly for the benefit of the reader). - */ -static int indexForBitsPerPixel[ 33 ] = { - ~0, 0, ~0, ~0, /* 1 bit per pixel */ - 1, ~0, ~0, ~0, /* 4 bits per pixel */ - 2, ~0, ~0, ~0, /* 8 bits per pixel */ - ~0,~0, ~0, ~0, - 3, ~0, ~0, ~0, /* 16 bits per pixel */ - ~0,~0, ~0, ~0, - 4, ~0, ~0, ~0, /* 24 bits per pixel */ - ~0,~0, ~0, ~0, - 5 /* 32 bits per pixel */ -}; - -/* - * This array gives the bytesperPixel value for cases where the number - * of bits per pixel is a multiple of 8 but not a power of 2. - */ -static int answerBytesPerPixel[ 33 ] = { - ~0, 0, ~0, ~0, /* 1 bit per pixel */ - 0, ~0, ~0, ~0, /* 4 bits per pixel */ - 0, ~0, ~0, ~0, /* 8 bits per pixel */ - ~0,~0, ~0, ~0, - 0, ~0, ~0, ~0, /* 16 bits per pixel */ - ~0,~0, ~0, ~0, - 3, ~0, ~0, ~0, /* 24 bits per pixel */ - ~0,~0, ~0, ~0, - 0 /* 32 bits per pixel */ -}; - -/* - * This array gives the answer to the question "what is the second index for - * the answer array above given the number of bits per scanline pad unit?" - * Note that ~0 is an invalid entry (mostly for the benefit of the reader). - */ -static int indexForScanlinePad[ 65 ] = { - ~0, ~0, ~0, ~0, - ~0, ~0, ~0, ~0, - 0, ~0, ~0, ~0, /* 8 bits per scanline pad unit */ - ~0, ~0, ~0, ~0, - 1, ~0, ~0, ~0, /* 16 bits per scanline pad unit */ - ~0, ~0, ~0, ~0, - ~0, ~0, ~0, ~0, - ~0, ~0, ~0, ~0, - 2, ~0, ~0, ~0, /* 32 bits per scanline pad unit */ - ~0, ~0, ~0, ~0, - ~0, ~0, ~0, ~0, - ~0, ~0, ~0, ~0, - ~0, ~0, ~0, ~0, - ~0, ~0, ~0, ~0, - ~0, ~0, ~0, ~0, - ~0, ~0, ~0, ~0, - 3 /* 64 bits per scanline pad unit */ -}; - -#ifndef MIN -#define MIN(a,b) (((a) < (b)) ? (a) : (b)) -#endif - int main(int argc, char *argv[], char *envp[]) { - int i, j, k, error; + int i, error; char *xauthfile; HWEventQueueType alwaysCheckForInput[2]; display = "0"; InitGlobals(); -#ifdef XPRINT - PrinterInitGlobals(); -#endif /* Quartz support on Mac OS X requires that the Cocoa event loop be in * the main thread. This allows the X server main to be called again @@ -317,15 +233,15 @@ main(int argc, char *argv[], char *envp[]) { CreateWellKnownSockets(); InitProcVectors(); - clients = (ClientPtr *)xalloc(MAXCLIENTS * sizeof(ClientPtr)); + clients = (ClientPtr *)malloc(MAXCLIENTS * sizeof(ClientPtr)); if (!clients) FatalError("couldn't create client array"); for (i=1; i<MAXCLIENTS; i++) clients[i] = NullClient; - serverClient = (ClientPtr)xalloc(sizeof(ClientRec)); + serverClient = (ClientPtr)malloc(sizeof(ClientRec)); if (!serverClient) FatalError("couldn't create server client"); - InitClient(serverClient, 0, (pointer)NULL); + InitClient(serverClient, 0, (void *)NULL); } else ResetWellKnownSockets (); @@ -339,24 +255,14 @@ main(int argc, char *argv[], char *envp[]) screenInfo.arraySize = MAXSCREENS; screenInfo.numScreens = 0; screenInfo.numVideoScreens = -1; - WindowTable = (WindowPtr *)xalloc(MAXSCREENS * sizeof(WindowPtr)); - if (!WindowTable) - FatalError("couldn't create root window table"); - - /* - * Just in case the ddx doesnt supply a format for depth 1 (like qvss). - */ - j = indexForBitsPerPixel[ 1 ]; - k = indexForScanlinePad[ BITMAP_SCANLINE_PAD ]; - PixmapWidthPaddingInfo[1].padRoundUp = BITMAP_SCANLINE_PAD-1; - PixmapWidthPaddingInfo[1].padPixelsLog2 = answer[j][k]; - j = indexForBitsPerPixel[8]; /* bits per byte */ - PixmapWidthPaddingInfo[1].padBytesLog2 = answer[j][k]; - PixmapWidthPaddingInfo[1].bitsPerPixel = 1; InitAtoms(); InitEvents(); +#ifdef HAS_XFONT2 + xfont2_init_glyph_caching(); +#else InitGlyphCaching(); +#endif /* of HAS_XFONT2 */ ResetClientPrivates(); ResetScreenPrivates(); ResetWindowPrivates(); @@ -365,14 +271,11 @@ main(int argc, char *argv[], char *envp[]) ResetPixmapPrivates(); #endif ResetColormapPrivates(); - ResetFontPrivateIndex(); ResetDevicePrivateIndex(); + InitFonts(); InitCallbackManager(); InitVisualWrap(); InitOutput(&screenInfo, argc, argv); -#ifdef XPRINT - PrinterInitOutput(&screenInfo, argc, argv); -#endif if (screenInfo.numScreens < 1) FatalError("no screens found"); @@ -399,13 +302,13 @@ main(int argc, char *argv[], char *envp[]) InitInput(argc, argv); if (InitAndStartDevices() != Success) FatalError("failed to initialize core devices"); + ReserveClientIds(serverClient); - InitFonts(); if (loadableFonts) { - SetFontPath(0, 0, (unsigned char *)defaultFontPath, &error); + SetFontPath(serverClient, 0, (unsigned char *)defaultFontPath); } else { if (SetDefaultFontPath(defaultFontPath) != Success) - ErrorF("failed to set default font path '%s'", + ErrorF("failed to set default font path '%s'\n", defaultFontPath); } if (!SetDefaultFont(defaultTextFont)) @@ -429,8 +332,8 @@ main(int argc, char *argv[], char *envp[]) #endif for (i = 0; i < screenInfo.numScreens; i++) - InitRootWindow(WindowTable[i]); - DefineInitialRootWindow(WindowTable[0]); + InitRootWindow(screenInfo.screens[i]->root); + DefineInitialRootWindow(screenInfo.screens[0]->root); SaveScreens(SCREEN_SAVER_FORCER, ScreenSaverReset); #ifdef DPMSExtension SetDPMSTimers(); @@ -447,6 +350,8 @@ main(int argc, char *argv[], char *envp[]) FatalError("could not create connection block info"); } + NotifyParentProcess(); + Dispatch(); /* Now free up whatever must be freed */ @@ -466,19 +371,20 @@ main(int argc, char *argv[], char *envp[]) FreeAllResources(); #endif + for (i = 0; i < screenInfo.numScreens; i++) + screenInfo.screens[i]->root = NullWindow; CloseDownDevices(); + CloseDownEvents(); + for (i = screenInfo.numScreens - 1; i >= 0; i--) { FreeScratchPixmapsForScreen(i); FreeGCperDepth(i); FreeDefaultStipple(i); - (* screenInfo.screens[i]->CloseScreen)(i, screenInfo.screens[i]); + (* screenInfo.screens[i]->CloseScreen)(screenInfo.screens[i]); FreeScreen(screenInfo.screens[i]); screenInfo.numScreens = i; } - CloseDownEvents(); - xfree(WindowTable); - WindowTable = NULL; FreeFonts(); #ifdef DPMSExtension @@ -486,7 +392,8 @@ main(int argc, char *argv[], char *envp[]) #endif FreeAuditTimer(); - xfree(serverClient->devPrivates); + ReleaseClientIds(serverClient); + free(serverClient->devPrivates); serverClient->devPrivates = NULL; if (dispatchException & DE_TERMINATE) @@ -502,7 +409,7 @@ main(int argc, char *argv[], char *envp[]) break; } - xfree(ConnectionInfo); + free(ConnectionInfo); ConnectionInfo = NULL; } return(0); @@ -543,6 +450,7 @@ CreateConnectionBlock() char *pBuf; + memset(&setup, 0, sizeof(xConnSetup)); /* Leave off the ridBase and ridMask, these must be sent with connection */ @@ -567,7 +475,7 @@ CreateConnectionBlock() ((setup.nbytesVendor + 3) & ~3) + (setup.numFormats * sizeof(xPixmapFormat)) + (setup.numRoots * sizeof(xWindowRoot)); - ConnectionInfo = (char *) xalloc(lenofblock); + ConnectionInfo = (char *) malloc(lenofblock); if (!ConnectionInfo) return FALSE; @@ -583,6 +491,7 @@ CreateConnectionBlock() while (--i >= 0) *pBuf++ = 0; + memset(&format, 0, sizeof(xPixmapFormat)); for (i=0; i<screenInfo.numPixmapFormats; i++) { format.depth = screenInfo.formats[i].depth; @@ -594,6 +503,8 @@ CreateConnectionBlock() } connBlockScreenStart = sizesofar; + memset(&depth, 0, sizeof(xDepth)); + memset(&visual, 0, sizeof(xVisualType)); for (i=0; i<screenInfo.numScreens; i++) { ScreenPtr pScreen; @@ -601,7 +512,7 @@ CreateConnectionBlock() VisualPtr pVisual; pScreen = screenInfo.screens[i]; - root.windowId = WindowTable[i]->drawable.id; + root.windowId = screenInfo.screens[i]->root->drawable.id; root.defaultColormap = pScreen->defColormap; root.whitePixel = pScreen->whitePixel; root.blackPixel = pScreen->blackPixel; @@ -626,10 +537,10 @@ CreateConnectionBlock() { lenofblock += sizeof(xDepth) + (pDepth->numVids * sizeof(xVisualType)); - pBuf = (char *)xrealloc(ConnectionInfo, lenofblock); + pBuf = (char *)realloc(ConnectionInfo, lenofblock); if (!pBuf) { - xfree(ConnectionInfo); + free(ConnectionInfo); return FALSE; } ConnectionInfo = pBuf; @@ -665,136 +576,3 @@ CreateConnectionBlock() connSetupPrefix.minorVersion = X_PROTOCOL_REVISION; return TRUE; } - -/* - grow the array of screenRecs if necessary. - call the device-supplied initialization procedure -with its screen number, a pointer to its ScreenRec, argc, and argv. - return the number of successfully installed screens. - -*/ - -int -AddScreen( - Bool (* pfnInit)( - int /*index*/, - ScreenPtr /*pScreen*/, - int /*argc*/, - char ** /*argv*/ - ), - int argc, - char **argv) -{ - - int i; - int scanlinepad, format, depth, bitsPerPixel, j, k; - ScreenPtr pScreen; -#ifdef DEBUG - void (**jNI) (); -#endif /* DEBUG */ - - i = screenInfo.numScreens; - if (i == MAXSCREENS) - return -1; - - pScreen = (ScreenPtr) xcalloc(1, sizeof(ScreenRec)); - if (!pScreen) - return -1; - - pScreen->devPrivates = (DevUnion *)xcalloc(sizeof(DevUnion), - screenPrivateCount); - if (!pScreen->devPrivates && screenPrivateCount) - { - xfree(pScreen); - return -1; - } - pScreen->myNum = i; - pScreen->WindowPrivateLen = 0; - pScreen->WindowPrivateSizes = (unsigned *)NULL; - pScreen->totalWindowSize = - ((sizeof(WindowRec) + sizeof(long) - 1) / sizeof(long)) * sizeof(long); - pScreen->GCPrivateLen = 0; - pScreen->GCPrivateSizes = (unsigned *)NULL; - pScreen->totalGCSize = - ((sizeof(GC) + sizeof(long) - 1) / sizeof(long)) * sizeof(long); -#ifdef PIXPRIV - pScreen->PixmapPrivateLen = 0; - pScreen->PixmapPrivateSizes = (unsigned *)NULL; - pScreen->totalPixmapSize = BitmapBytePad(sizeof(PixmapRec)*8); -#endif - pScreen->ClipNotify = 0; /* for R4 ddx compatibility */ - pScreen->CreateScreenResources = 0; - -#ifdef DEBUG - for (jNI = &pScreen->QueryBestSize; - jNI < (void (**) ()) &pScreen->SendGraphicsExpose; - jNI++) - *jNI = NotImplemented; -#endif /* DEBUG */ - - /* - * This loop gets run once for every Screen that gets added, - * but thats ok. If the ddx layer initializes the formats - * one at a time calling AddScreen() after each, then each - * iteration will make it a little more accurate. Worst case - * we do this loop N * numPixmapFormats where N is # of screens. - * Anyway, this must be called after InitOutput and before the - * screen init routine is called. - */ - for (format=0; format<screenInfo.numPixmapFormats; format++) - { - depth = screenInfo.formats[format].depth; - bitsPerPixel = screenInfo.formats[format].bitsPerPixel; - scanlinepad = screenInfo.formats[format].scanlinePad; - j = indexForBitsPerPixel[ bitsPerPixel ]; - k = indexForScanlinePad[ scanlinepad ]; - PixmapWidthPaddingInfo[ depth ].padPixelsLog2 = answer[j][k]; - PixmapWidthPaddingInfo[ depth ].padRoundUp = - (scanlinepad/bitsPerPixel) - 1; - j = indexForBitsPerPixel[ 8 ]; /* bits per byte */ - PixmapWidthPaddingInfo[ depth ].padBytesLog2 = answer[j][k]; - PixmapWidthPaddingInfo[ depth ].bitsPerPixel = bitsPerPixel; - if (answerBytesPerPixel[bitsPerPixel]) - { - PixmapWidthPaddingInfo[ depth ].notPower2 = 1; - PixmapWidthPaddingInfo[ depth ].bytesPerPixel = - answerBytesPerPixel[bitsPerPixel]; - } - else - { - PixmapWidthPaddingInfo[ depth ].notPower2 = 0; - } - } - - /* This is where screen specific stuff gets initialized. Load the - screen structure, call the hardware, whatever. - This is also where the default colormap should be allocated and - also pixel values for blackPixel, whitePixel, and the cursor - Note that InitScreen is NOT allowed to modify argc, argv, or - any of the strings pointed to by argv. They may be passed to - multiple screens. - */ - pScreen->rgf = ~0L; /* there are no scratch GCs yet*/ - WindowTable[i] = NullWindow; - screenInfo.screens[i] = pScreen; - screenInfo.numScreens++; - if (!(*pfnInit)(i, pScreen, argc, argv)) - { - FreeScreen(pScreen); - screenInfo.numScreens--; - return -1; - } - return i; -} - -static void -FreeScreen(ScreenPtr pScreen) -{ - xfree(pScreen->WindowPrivateSizes); - xfree(pScreen->GCPrivateSizes); -#ifdef PIXPRIV - xfree(pScreen->PixmapPrivateSizes); -#endif - xfree(pScreen->devPrivates); - xfree(pScreen); -} diff --git a/nx-X11/programs/Xserver/dix/pixmap.c b/nx-X11/programs/Xserver/dix/pixmap.c index 4be7d03ce..747120b48 100644 --- a/nx-X11/programs/Xserver/dix/pixmap.c +++ b/nx-X11/programs/Xserver/dix/pixmap.c @@ -1,4 +1,3 @@ -/* $Xorg: pixmap.c,v 1.4 2001/02/09 02:04:40 xorgcvs Exp $ */ /* Copyright 1993, 1998 The Open Group @@ -26,13 +25,12 @@ other dealings in this Software without prior written authorization from The Open Group. */ -/* $XFree86: xc/programs/Xserver/dix/pixmap.c,v 3.4 2001/01/17 22:36:44 dawes Exp $ */ #ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> #endif -#include <X11/X.h> +#include <nx-X11/X.h> #include "scrnintstr.h" #include "misc.h" #include "os.h" @@ -53,7 +51,7 @@ from The Open Group. /* callable by ddx */ PixmapPtr GetScratchPixmapHeader(ScreenPtr pScreen, int width, int height, int depth, - int bitsPerPixel, int devKind, pointer pPixData) + int bitsPerPixel, int devKind, void * pPixData) { PixmapPtr pPixmap = pScreen->pScratchPixmap; @@ -61,7 +59,7 @@ GetScratchPixmapHeader(ScreenPtr pScreen, int width, int height, int depth, pScreen->pScratchPixmap = NULL; else /* width and height of 0 means don't allocate any pixmap data */ - pPixmap = (*pScreen->CreatePixmap)(pScreen, 0, 0, depth); + pPixmap = (*pScreen->CreatePixmap)(pScreen, 0, 0, depth, 0); if (pPixmap) { if ((*pScreen->ModifyPixmapHeader)(pPixmap, width, height, depth, @@ -128,7 +126,7 @@ AllocatePixmap(ScreenPtr pScreen, int pixDataSize) * the pixmap buffer. This may be a RENDER bug. */ - pPixmap = (PixmapPtr)xalloc(pScreen->totalPixmapSize + pixDataSize + 4); + pPixmap = (PixmapPtr)malloc(pScreen->totalPixmapSize + pixDataSize + 4); if (!pPixmap) return NullPixmap; ppriv = (DevUnion *)(pPixmap + 1); @@ -139,14 +137,14 @@ AllocatePixmap(ScreenPtr pScreen, int pixDataSize) { if ((size = *sizes) != 0) { - ppriv->ptr = (pointer)ptr; + ppriv->ptr = (void *)ptr; ptr += size; } else - ppriv->ptr = (pointer)NULL; + ppriv->ptr = (void *)NULL; } #else - pPixmap = (PixmapPtr)xalloc(sizeof(PixmapRec) + pixDataSize); + pPixmap = (PixmapPtr)malloc(sizeof(PixmapRec) + pixDataSize); #endif return pPixmap; } diff --git a/nx-X11/programs/Xserver/dix/pixmap.c.NX.original b/nx-X11/programs/Xserver/dix/pixmap.c.NX.original deleted file mode 100644 index 4be7d03ce..000000000 --- a/nx-X11/programs/Xserver/dix/pixmap.c.NX.original +++ /dev/null @@ -1,152 +0,0 @@ -/* $Xorg: pixmap.c,v 1.4 2001/02/09 02:04:40 xorgcvs Exp $ */ -/* - -Copyright 1993, 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. - -*/ -/* $XFree86: xc/programs/Xserver/dix/pixmap.c,v 3.4 2001/01/17 22:36:44 dawes Exp $ */ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include <X11/X.h> -#include "scrnintstr.h" -#include "misc.h" -#include "os.h" -#include "windowstr.h" -#include "resource.h" -#include "dixstruct.h" -#include "gcstruct.h" -#include "servermd.h" -#include "site.h" - - -/* - * Scratch pixmap management and device independent pixmap allocation - * function. - */ - - -/* callable by ddx */ -PixmapPtr -GetScratchPixmapHeader(ScreenPtr pScreen, int width, int height, int depth, - int bitsPerPixel, int devKind, pointer pPixData) -{ - PixmapPtr pPixmap = pScreen->pScratchPixmap; - - if (pPixmap) - pScreen->pScratchPixmap = NULL; - else - /* width and height of 0 means don't allocate any pixmap data */ - pPixmap = (*pScreen->CreatePixmap)(pScreen, 0, 0, depth); - - if (pPixmap) { - if ((*pScreen->ModifyPixmapHeader)(pPixmap, width, height, depth, - bitsPerPixel, devKind, pPixData)) - return pPixmap; - (*pScreen->DestroyPixmap)(pPixmap); - } - return NullPixmap; -} - - -/* callable by ddx */ -void -FreeScratchPixmapHeader(PixmapPtr pPixmap) -{ - if (pPixmap) - { - ScreenPtr pScreen = pPixmap->drawable.pScreen; - - pPixmap->devPrivate.ptr = NULL; /* lest ddx chases bad ptr */ - if (pScreen->pScratchPixmap) - (*pScreen->DestroyPixmap)(pPixmap); - else - pScreen->pScratchPixmap = pPixmap; - } -} - - -Bool -CreateScratchPixmapsForScreen(int scrnum) -{ - /* let it be created on first use */ - screenInfo.screens[scrnum]->pScratchPixmap = NULL; - return TRUE; -} - - -void -FreeScratchPixmapsForScreen(int scrnum) -{ - FreeScratchPixmapHeader(screenInfo.screens[scrnum]->pScratchPixmap); -} - - -/* callable by ddx */ -PixmapPtr -AllocatePixmap(ScreenPtr pScreen, int pixDataSize) -{ - PixmapPtr pPixmap; -#ifdef PIXPRIV - char *ptr; - DevUnion *ppriv; - unsigned *sizes; - unsigned size; - int i; - - if (pScreen->totalPixmapSize > ((size_t)-1) - pixDataSize) - return NullPixmap; - - /* - * FIXME: Allocate 4 bytes at the end of each pixmap. This - * is a quick workaround intended to fix a problem reported - * by Valgrind due to fbBlt() writing just after the end of - * the pixmap buffer. This may be a RENDER bug. - */ - - pPixmap = (PixmapPtr)xalloc(pScreen->totalPixmapSize + pixDataSize + 4); - if (!pPixmap) - return NullPixmap; - ppriv = (DevUnion *)(pPixmap + 1); - pPixmap->devPrivates = ppriv; - sizes = pScreen->PixmapPrivateSizes; - ptr = (char *)(ppriv + pScreen->PixmapPrivateLen); - for (i = pScreen->PixmapPrivateLen; --i >= 0; ppriv++, sizes++) - { - if ((size = *sizes) != 0) - { - ppriv->ptr = (pointer)ptr; - ptr += size; - } - else - ppriv->ptr = (pointer)NULL; - } -#else - pPixmap = (PixmapPtr)xalloc(sizeof(PixmapRec) + pixDataSize); -#endif - return pPixmap; -} diff --git a/nx-X11/programs/Xserver/dix/pixmap.c.X.original b/nx-X11/programs/Xserver/dix/pixmap.c.X.original deleted file mode 100644 index 78ce2a8c6..000000000 --- a/nx-X11/programs/Xserver/dix/pixmap.c.X.original +++ /dev/null @@ -1,145 +0,0 @@ -/* $Xorg: pixmap.c,v 1.4 2001/02/09 02:04:40 xorgcvs Exp $ */ -/* - -Copyright 1993, 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. - -*/ -/* $XFree86: xc/programs/Xserver/dix/pixmap.c,v 3.4 2001/01/17 22:36:44 dawes Exp $ */ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include <X11/X.h> -#include "scrnintstr.h" -#include "misc.h" -#include "os.h" -#include "windowstr.h" -#include "resource.h" -#include "dixstruct.h" -#include "gcstruct.h" -#include "servermd.h" -#include "site.h" - - -/* - * Scratch pixmap management and device independent pixmap allocation - * function. - */ - - -/* callable by ddx */ -PixmapPtr -GetScratchPixmapHeader(ScreenPtr pScreen, int width, int height, int depth, - int bitsPerPixel, int devKind, pointer pPixData) -{ - PixmapPtr pPixmap = pScreen->pScratchPixmap; - - if (pPixmap) - pScreen->pScratchPixmap = NULL; - else - /* width and height of 0 means don't allocate any pixmap data */ - pPixmap = (*pScreen->CreatePixmap)(pScreen, 0, 0, depth); - - if (pPixmap) { - if ((*pScreen->ModifyPixmapHeader)(pPixmap, width, height, depth, - bitsPerPixel, devKind, pPixData)) - return pPixmap; - (*pScreen->DestroyPixmap)(pPixmap); - } - return NullPixmap; -} - - -/* callable by ddx */ -void -FreeScratchPixmapHeader(PixmapPtr pPixmap) -{ - if (pPixmap) - { - ScreenPtr pScreen = pPixmap->drawable.pScreen; - - pPixmap->devPrivate.ptr = NULL; /* lest ddx chases bad ptr */ - if (pScreen->pScratchPixmap) - (*pScreen->DestroyPixmap)(pPixmap); - else - pScreen->pScratchPixmap = pPixmap; - } -} - - -Bool -CreateScratchPixmapsForScreen(int scrnum) -{ - /* let it be created on first use */ - screenInfo.screens[scrnum]->pScratchPixmap = NULL; - return TRUE; -} - - -void -FreeScratchPixmapsForScreen(int scrnum) -{ - FreeScratchPixmapHeader(screenInfo.screens[scrnum]->pScratchPixmap); -} - - -/* callable by ddx */ -PixmapPtr -AllocatePixmap(ScreenPtr pScreen, int pixDataSize) -{ - PixmapPtr pPixmap; -#ifdef PIXPRIV - char *ptr; - DevUnion *ppriv; - unsigned *sizes; - unsigned size; - int i; - - if (pScreen->totalPixmapSize > ((size_t)-1) - pixDataSize) - return NullPixmap; - - pPixmap = (PixmapPtr)xalloc(pScreen->totalPixmapSize + pixDataSize); - if (!pPixmap) - return NullPixmap; - ppriv = (DevUnion *)(pPixmap + 1); - pPixmap->devPrivates = ppriv; - sizes = pScreen->PixmapPrivateSizes; - ptr = (char *)(ppriv + pScreen->PixmapPrivateLen); - for (i = pScreen->PixmapPrivateLen; --i >= 0; ppriv++, sizes++) - { - if ((size = *sizes) != 0) - { - ppriv->ptr = (pointer)ptr; - ptr += size; - } - else - ppriv->ptr = (pointer)NULL; - } -#else - pPixmap = (PixmapPtr)xalloc(sizeof(PixmapRec) + pixDataSize); -#endif - return pPixmap; -} diff --git a/nx-X11/programs/Xserver/dix/privates.c b/nx-X11/programs/Xserver/dix/privates.c index 36bbc65d1..a7009054c 100644 --- a/nx-X11/programs/Xserver/dix/privates.c +++ b/nx-X11/programs/Xserver/dix/privates.c @@ -1,5 +1,3 @@ -/* $Xorg: privates.c,v 1.4 2001/02/09 02:04:40 xorgcvs Exp $ */ -/* $XdotOrg: xc/programs/Xserver/dix/privates.c,v 1.10 2005/09/05 07:40:50 daniels Exp $ */ /* Copyright 1993, 1998 The Open Group @@ -27,13 +25,12 @@ other dealings in this Software without prior written authorization from The Open Group. */ -/* $XFree86: xc/programs/Xserver/dix/privates.c,v 3.7 2001/01/17 22:36:44 dawes Exp $ */ #ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> #endif -#include <X11/X.h> +#include <nx-X11/X.h> #include "scrnintstr.h" #include "misc.h" #include "os.h" @@ -66,7 +63,7 @@ ResetClientPrivates() { clientPrivateCount = 0; clientPrivateLen = 0; - xfree(clientPrivateSizes); + free(clientPrivateSizes); clientPrivateSizes = (unsigned *)NULL; totalClientSize = ((sizeof(ClientRec) + sizeof(long) - 1) / sizeof(long)) * sizeof(long); @@ -89,7 +86,7 @@ AllocateClientPrivate(int index2, unsigned amount) if (index2 >= clientPrivateLen) { unsigned *nsizes; - nsizes = (unsigned *)xrealloc(clientPrivateSizes, + nsizes = (unsigned *)realloc(clientPrivateSizes, (index2 + 1) * sizeof(unsigned)); if (!nsizes) return FALSE; @@ -136,7 +133,7 @@ AllocateScreenPrivateIndex() for (i = 0; i < screenInfo.numScreens; i++) { pScreen = screenInfo.screens[i]; - nprivs = (DevUnion *)xrealloc(pScreen->devPrivates, + nprivs = (DevUnion *)realloc(pScreen->devPrivates, screenPrivateCount * sizeof(DevUnion)); if (!nprivs) { @@ -180,7 +177,7 @@ AllocateWindowPrivate(register ScreenPtr pScreen, int index2, unsigned amount) if (index2 >= pScreen->WindowPrivateLen) { unsigned *nsizes; - nsizes = (unsigned *)xrealloc(pScreen->WindowPrivateSizes, + nsizes = (unsigned *)realloc(pScreen->WindowPrivateSizes, (index2 + 1) * sizeof(unsigned)); if (!nsizes) return FALSE; @@ -230,7 +227,7 @@ AllocateGCPrivate(register ScreenPtr pScreen, int index2, unsigned amount) if (index2 >= pScreen->GCPrivateLen) { unsigned *nsizes; - nsizes = (unsigned *)xrealloc(pScreen->GCPrivateSizes, + nsizes = (unsigned *)realloc(pScreen->GCPrivateSizes, (index2 + 1) * sizeof(unsigned)); if (!nsizes) return FALSE; @@ -280,7 +277,7 @@ AllocatePixmapPrivate(register ScreenPtr pScreen, int index2, unsigned amount) if (index2 >= pScreen->PixmapPrivateLen) { unsigned *nsizes; - nsizes = (unsigned *)xrealloc(pScreen->PixmapPrivateSizes, + nsizes = (unsigned *)realloc(pScreen->PixmapPrivateSizes, (index2 + 1) * sizeof(unsigned)); if (!nsizes) return FALSE; @@ -345,7 +342,7 @@ AllocateColormapPrivateIndex (InitCmapPrivFunc initPrivFunc) if (pColormap) { - privs = (DevUnion *) xrealloc (pColormap->devPrivates, + privs = (DevUnion *) realloc (pColormap->devPrivates, colormapPrivateCount * sizeof(DevUnion)); if (!privs) { colormapPrivateCount--; @@ -380,7 +377,7 @@ Bool AllocateDevicePrivate(DeviceIntPtr device, int index) { if (device->nPrivates < ++index) { - DevUnion *nprivs = (DevUnion *) xrealloc(device->devPrivates, + DevUnion *nprivs = (DevUnion *) realloc(device->devPrivates, index * sizeof(DevUnion)); if (!nprivs) return FALSE; diff --git a/nx-X11/programs/Xserver/dix/property.c b/nx-X11/programs/Xserver/dix/property.c index cabe46ecc..66c38f56c 100644 --- a/nx-X11/programs/Xserver/dix/property.c +++ b/nx-X11/programs/Xserver/dix/property.c @@ -1,4 +1,3 @@ -/* $XFree86: xc/programs/Xserver/dix/property.c,v 3.12 2002/02/19 11:09:22 alanh Exp $ */ /*********************************************************** Copyright 1987, 1998 The Open Group @@ -45,16 +44,13 @@ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ******************************************************************/ -/* $Xorg: property.c,v 1.4 2001/02/09 02:04:40 xorgcvs Exp $ */ #ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> #endif -#include <X11/X.h> -#define NEED_REPLIES -#define NEED_EVENTS -#include <X11/Xproto.h> +#include <nx-X11/X.h> +#include <nx-X11/Xproto.h> #include "windowstr.h" #include "propertyst.h" #include "dixstruct.h" @@ -62,20 +58,7 @@ SOFTWARE. #include "swaprep.h" #ifdef XCSECURITY #define _SECURITY_SERVER -#include <X11/extensions/security.h> -#endif -#ifdef LBX -#include "lbxserve.h" -#include "lbxtags.h" -#endif - -#if defined(LBX) || defined(LBX_COMPAT) -#if 0 /* no header in X11 environment, not used in X11 environment */ -int fWriteToClient(ClientPtr client, int len, char *buf) -{ - return WriteToClient(client, len, buf); -} -#endif +#include <nx-X11/extensions/security.h> #endif /***************************************************************** @@ -118,25 +101,24 @@ ProcRotateProperties(ClientPtr client) register Atom * atoms; PropertyPtr * props; /* array of pointer */ PropertyPtr pProp; - xEvent event; REQUEST_FIXED_SIZE(xRotatePropertiesReq, stuff->nAtoms << 2); UpdateCurrentTime(); pWin = (WindowPtr) SecurityLookupWindow(stuff->window, client, - SecurityWriteAccess); + DixWriteAccess); if (!pWin) return(BadWindow); if (!stuff->nAtoms) return(Success); atoms = (Atom *) & stuff[1]; - props = (PropertyPtr *)ALLOCATE_LOCAL(stuff->nAtoms * sizeof(PropertyPtr)); + props = (PropertyPtr *)malloc(stuff->nAtoms * sizeof(PropertyPtr)); if (!props) return(BadAlloc); for (i = 0; i < stuff->nAtoms; i++) { #ifdef XCSECURITY char action = SecurityCheckPropertyAccess(client, pWin, atoms[i], - SecurityReadAccess|SecurityWriteAccess); + DixReadAccess|DixWriteAccess); #endif if (!ValidAtom(atoms[i]) #ifdef XCSECURITY @@ -144,21 +126,21 @@ ProcRotateProperties(ClientPtr client) #endif ) { - DEALLOCATE_LOCAL(props); + free(props); client->errorValue = atoms[i]; return BadAtom; } #ifdef XCSECURITY if (SecurityIgnoreOperation == action) { - DEALLOCATE_LOCAL(props); + free(props); return Success; } #endif for (j = i + 1; j < stuff->nAtoms; j++) if (atoms[j] == atoms[i]) { - DEALLOCATE_LOCAL(props); + free(props); return BadMatch; } pProp = wUserProps (pWin); @@ -168,7 +150,7 @@ ProcRotateProperties(ClientPtr client) goto found; pProp = pProp->next; } - DEALLOCATE_LOCAL(props); + free(props); return BadMatch; found: props[i] = pProp; @@ -186,7 +168,9 @@ found: { /* Generate a PropertyNotify event for each property whose value is changed in the order in which they appear in the request. */ + xEvent event; + memset(&event, 0, sizeof(xEvent)); event.u.u.type = PropertyNotify; event.u.property.window = pWin->drawable.id; event.u.property.state = PropertyNewValue; @@ -197,10 +181,11 @@ found: props[i]->propertyName = atoms[(i + delta) % stuff->nAtoms]; } } - DEALLOCATE_LOCAL(props); + free(props); return Success; } +#ifndef NXAGENT_SERVER int ProcChangeProperty(ClientPtr client) { @@ -235,7 +220,7 @@ ProcChangeProperty(ClientPtr client) REQUEST_FIXED_SIZE(xChangePropertyReq, totalSize); pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - SecurityWriteAccess); + DixWriteAccess); if (!pWin) return(BadWindow); if (!ValidAtom(stuff->property)) @@ -251,7 +236,7 @@ ProcChangeProperty(ClientPtr client) #ifdef XCSECURITY switch (SecurityCheckPropertyAccess(client, pWin, stuff->property, - SecurityWriteAccess)) + DixWriteAccess)) { case SecurityErrorOperation: client->errorValue = stuff->property; @@ -261,13 +246,8 @@ ProcChangeProperty(ClientPtr client) } #endif -#ifdef LBX - err = LbxChangeWindowProperty(client, pWin, stuff->property, stuff->type, - (int)format, (int)mode, len, TRUE, (pointer)&stuff[1], TRUE, NULL); -#else err = ChangeWindowProperty(pWin, stuff->property, stuff->type, (int)format, - (int)mode, len, (pointer)&stuff[1], TRUE); -#endif + (int)mode, len, (void *)&stuff[1], TRUE); if (err != Success) return err; else @@ -276,19 +256,13 @@ ProcChangeProperty(ClientPtr client) int ChangeWindowProperty(WindowPtr pWin, Atom property, Atom type, int format, - int mode, unsigned long len, pointer value, + int mode, unsigned long len, void * value, Bool sendevent) { -#ifdef LBX - return LbxChangeWindowProperty(NULL, pWin, property, type, - format, mode, len, TRUE, value, - sendevent, NULL); -#else PropertyPtr pProp; - xEvent event; int sizeInBytes; int totalSize; - pointer data; + void * data; sizeInBytes = format>>3; totalSize = len * sizeInBytes; @@ -306,13 +280,13 @@ ChangeWindowProperty(WindowPtr pWin, Atom property, Atom type, int format, { if (!pWin->optional && !MakeWindowOptional (pWin)) return(BadAlloc); - pProp = (PropertyPtr)xalloc(sizeof(PropertyRec)); + pProp = (PropertyPtr)malloc(sizeof(PropertyRec)); if (!pProp) return(BadAlloc); - data = (pointer)xalloc(totalSize); + data = (void *)malloc(totalSize); if (!data && len) { - xfree(pProp); + free(pProp); return(BadAlloc); } pProp->propertyName = property; @@ -340,7 +314,7 @@ ChangeWindowProperty(WindowPtr pWin, Atom property, Atom type, int format, { if (totalSize != pProp->size * (pProp->format >> 3)) { - data = (pointer)xrealloc(pProp->data, totalSize); + data = (void *)realloc(pProp->data, totalSize); if (!data && len) return(BadAlloc); pProp->data = data; @@ -357,7 +331,7 @@ ChangeWindowProperty(WindowPtr pWin, Atom property, Atom type, int format, } else if (mode == PropModeAppend) { - data = (pointer)xrealloc(pProp->data, + data = (void *)realloc(pProp->data, sizeInBytes * (len + pProp->size)); if (!data) return(BadAlloc); @@ -369,19 +343,21 @@ ChangeWindowProperty(WindowPtr pWin, Atom property, Atom type, int format, } else if (mode == PropModePrepend) { - data = (pointer)xalloc(sizeInBytes * (len + pProp->size)); + data = (void *)malloc(sizeInBytes * (len + pProp->size)); if (!data) return(BadAlloc); memmove(&((char *)data)[totalSize], (char *)pProp->data, (int)(pProp->size * sizeInBytes)); memmove((char *)data, (char *)value, totalSize); - xfree(pProp->data); + free(pProp->data); pProp->data = data; pProp->size += len; } } if (sendevent) { + xEvent event; + memset(&event, 0, sizeof(xEvent)); event.u.u.type = PropertyNotify; event.u.property.window = pWin->drawable.id; event.u.property.state = PropertyNewValue; @@ -390,14 +366,13 @@ ChangeWindowProperty(WindowPtr pWin, Atom property, Atom type, int format, DeliverEvents(pWin, &event, 1, (WindowPtr)NULL); } return(Success); -#endif } +#endif /* NXAGENT_SERVER */ int DeleteProperty(WindowPtr pWin, Atom propName) { PropertyPtr pProp, prevProp; - xEvent event; if (!(pProp = wUserProps (pWin))) return(Success); @@ -411,6 +386,7 @@ DeleteProperty(WindowPtr pWin, Atom propName) } if (pProp) { + xEvent event; if (prevProp == (PropertyPtr)NULL) /* takes care of head */ { if (!(pWin->optional->userProps = pProp->next)) @@ -420,18 +396,15 @@ DeleteProperty(WindowPtr pWin, Atom propName) { prevProp->next = pProp->next; } -#ifdef LBX - if (pProp->tag_id) - TagDeleteTag(pProp->tag_id); -#endif + memset(&event, 0, sizeof(xEvent)); event.u.u.type = PropertyNotify; event.u.property.window = pWin->drawable.id; event.u.property.state = PropertyDelete; event.u.property.atom = pProp->propertyName; event.u.property.time = currentTime.milliseconds; DeliverEvents(pWin, &event, 1, (WindowPtr)NULL); - xfree(pProp->data); - xfree(pProp); + free(pProp->data); + free(pProp); } return(Success); } @@ -442,13 +415,10 @@ DeleteAllWindowProperties(WindowPtr pWin) PropertyPtr pProp, pNextProp; xEvent event; + memset(&event, 0, sizeof(xEvent)); pProp = wUserProps (pWin); while (pProp) { -#ifdef LBX - if (pProp->tag_id) - TagDeleteTag(pProp->tag_id); -#endif event.u.u.type = PropertyNotify; event.u.property.window = pWin->drawable.id; event.u.property.state = PropertyDelete; @@ -456,8 +426,8 @@ DeleteAllWindowProperties(WindowPtr pWin) event.u.property.time = currentTime.milliseconds; DeliverEvents(pWin, &event, 1, (WindowPtr)NULL); pNextProp = pProp->next; - xfree(pProp->data); - xfree(pProp); + free(pProp->data); + free(pProp); pProp = pNextProp; } } @@ -478,6 +448,8 @@ NullPropertyReply( return(client->noClientException); } +#ifndef NXAGENT_SERVER + /***************** * GetProperty * If type Any is specified, returns the property from the specified @@ -501,7 +473,7 @@ ProcGetProperty(ClientPtr client) if (stuff->delete) UpdateCurrentTime(); pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - SecurityReadAccess); + DixReadAccess); if (!pWin) return BadWindow; @@ -531,6 +503,7 @@ ProcGetProperty(ClientPtr client) pProp = pProp->next; } + memset(&reply, 0, sizeof(xGetPropertyReply)); reply.type = X_Reply; reply.sequenceNumber = client->sequence; if (!pProp) @@ -538,10 +511,10 @@ ProcGetProperty(ClientPtr client) #ifdef XCSECURITY { - Mask access_mode = SecurityReadAccess; + Mask access_mode = DixReadAccess; if (stuff->delete) - access_mode |= SecurityDestroyAccess; + access_mode |= DixDestroyAccess; switch(SecurityCheckPropertyAccess(client, pWin, stuff->property, access_mode)) { @@ -569,13 +542,6 @@ ProcGetProperty(ClientPtr client) WriteReplyToClient(client, sizeof(xGenericReply), &reply); return(Success); } -#ifdef LBX - /* make sure we have the current value */ - if (pProp->tag_id && pProp->owner_pid) { - LbxStallPropRequest(client, pProp); - return client->noClientException; - } -#endif /* * Return type, format, value to client @@ -604,6 +570,7 @@ ProcGetProperty(ClientPtr client) { /* send the event */ xEvent event; + memset(&event, 0, sizeof(xEvent)); event.u.u.type = PropertyNotify; event.u.property.window = pWin->drawable.id; event.u.property.state = PropertyDelete; @@ -626,10 +593,6 @@ ProcGetProperty(ClientPtr client) if (stuff->delete && (reply.bytesAfter == 0)) { /* delete the Property */ -#ifdef LBX - if (pProp->tag_id) - TagDeleteTag(pProp->tag_id); -#endif if (prevProp == (PropertyPtr)NULL) /* takes care of head */ { if (!(pWin->optional->userProps = pProp->next)) @@ -637,11 +600,12 @@ ProcGetProperty(ClientPtr client) } else prevProp->next = pProp->next; - xfree(pProp->data); - xfree(pProp); + free(pProp->data); + free(pProp); } return(client->noClientException); } +#endif /* NXAGENT_SERVER */ int ProcListProperties(ClientPtr client) @@ -655,7 +619,7 @@ ProcListProperties(ClientPtr client) REQUEST_SIZE_MATCH(xResourceReq); pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client, - SecurityReadAccess); + DixReadAccess); if (!pWin) return(BadWindow); @@ -666,9 +630,10 @@ ProcListProperties(ClientPtr client) numProps++; } if (numProps) - if(!(pAtoms = (Atom *)ALLOCATE_LOCAL(numProps * sizeof(Atom)))) + if(!(pAtoms = (Atom *)malloc(numProps * sizeof(Atom)))) return(BadAlloc); + memset(&xlpr, 0, sizeof(xListPropertiesReply)); xlpr.type = X_Reply; xlpr.nProperties = numProps; xlpr.length = (numProps * sizeof(Atom)) >> 2; @@ -685,7 +650,7 @@ ProcListProperties(ClientPtr client) { client->pSwapReplyFunc = (ReplySwapPtr)Swap32Write; WriteSwappedDataToClient(client, numProps * sizeof(Atom), pAtoms); - DEALLOCATE_LOCAL(pAtoms); + free(pAtoms); } return(client->noClientException); } @@ -700,7 +665,7 @@ ProcDeleteProperty(register ClientPtr client) REQUEST_SIZE_MATCH(xDeletePropertyReq); UpdateCurrentTime(); pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - SecurityWriteAccess); + DixWriteAccess); if (!pWin) return(BadWindow); if (!ValidAtom(stuff->property)) @@ -711,7 +676,7 @@ ProcDeleteProperty(register ClientPtr client) #ifdef XCSECURITY switch(SecurityCheckPropertyAccess(client, pWin, stuff->property, - SecurityDestroyAccess)) + DixDestroyAccess)) { case SecurityErrorOperation: client->errorValue = stuff->property; diff --git a/nx-X11/programs/Xserver/dix/region.c b/nx-X11/programs/Xserver/dix/region.c new file mode 100644 index 000000000..46e8845bf --- /dev/null +++ b/nx-X11/programs/Xserver/dix/region.c @@ -0,0 +1,1742 @@ +/*********************************************************** + +Copyright 1987, 1988, 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. + + +Copyright 1987, 1988, 1989 by +Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +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 Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL 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. + +******************************************************************/ + +/* The panoramix components contained the following notice */ +/***************************************************************** + +Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts. + +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. + +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 +DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING, +BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL 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 Digital Equipment Corporation +shall not be used in advertising or otherwise to promote the sale, use or other +dealings in this Software without prior written authorization from Digital +Equipment Corporation. + +******************************************************************/ + +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#include <pixman.h> + +#include "regionstr.h" +#include <nx-X11/Xprotostr.h> +#include "gc.h" + +#if defined (__GNUC__) && !defined (NO_INLINES) +#define INLINE __inline +#else +#define INLINE +#endif + +#undef assert +#ifdef DEBUG +#define assert(expr) {if (!(expr)) \ + FatalError("Assertion failed file %s, line %d: expr\n", \ + __FILE__, __LINE__); } +#else +#define assert(expr) +#endif + +#define good(reg) assert(RegionIsValid(reg)) + +/* + * The functions in this file implement the Region abstraction used extensively + * throughout the X11 sample server. A Region is simply a set of disjoint + * (non-overlapping) rectangles, plus an "extent" rectangle which is the + * smallest single rectangle that contains all the non-overlapping rectangles. + * + * A Region is implemented as a "y-x-banded" array of rectangles. This array + * imposes two degrees of order. First, all rectangles are sorted by top side + * y coordinate first (y1), and then by left side x coordinate (x1). + * + * Furthermore, the rectangles are grouped into "bands". Each rectangle in a + * band has the same top y coordinate (y1), and each has the same bottom y + * coordinate (y2). Thus all rectangles in a band differ only in their left + * and right side (x1 and x2). Bands are implicit in the array of rectangles: + * there is no separate list of band start pointers. + * + * The y-x band representation does not minimize rectangles. In particular, + * if a rectangle vertically crosses a band (the rectangle has scanlines in + * the y1 to y2 area spanned by the band), then the rectangle may be broken + * down into two or more smaller rectangles stacked one atop the other. + * + * ----------- ----------- + * | | | | band 0 + * | | -------- ----------- -------- + * | | | | in y-x banded | | | | band 1 + * | | | | form is | | | | + * ----------- | | ----------- -------- + * | | | | band 2 + * -------- -------- + * + * An added constraint on the rectangles is that they must cover as much + * horizontal area as possible: no two rectangles within a band are allowed + * to touch. + * + * Whenever possible, bands will be merged together to cover a greater vertical + * distance (and thus reduce the number of rectangles). Two bands can be merged + * only if the bottom of one touches the top of the other and they have + * rectangles in the same places (of the same width, of course). + * + * Adam de Boor wrote most of the original region code. Joel McCormack + * substantially modified or rewrote most of the core arithmetic routines, + * and added RegionValidate in order to support several speed improvements + * to miValidateTree. Bob Scheifler changed the representation to be more + * compact when empty or a single rectangle, and did a bunch of gratuitous + * reformatting. + */ + +/* true iff two Boxes overlap */ +#define EXTENTCHECK(r1,r2) \ + (!( ((r1)->x2 <= (r2)->x1) || \ + ((r1)->x1 >= (r2)->x2) || \ + ((r1)->y2 <= (r2)->y1) || \ + ((r1)->y1 >= (r2)->y2) ) ) + +/* true iff (x,y) is in Box */ +#define INBOX(r,x,y) \ + ( ((r)->x2 > x) && \ + ((r)->x1 <= x) && \ + ((r)->y2 > y) && \ + ((r)->y1 <= y) ) + +/* true iff Box r1 contains Box r2 */ +#define SUBSUMES(r1,r2) \ + ( ((r1)->x1 <= (r2)->x1) && \ + ((r1)->x2 >= (r2)->x2) && \ + ((r1)->y1 <= (r2)->y1) && \ + ((r1)->y2 >= (r2)->y2) ) + +#define xfreeData(reg) if ((reg)->data && (reg)->data->size) free((reg)->data) + +#define RECTALLOC_BAIL(pReg,n,bail) \ +if (!(pReg)->data || (((pReg)->data->numRects + (n)) > (pReg)->data->size)) \ + if (!RegionRectAlloc(pReg, n)) { goto bail; } + +#define RECTALLOC(pReg,n) \ +if (!(pReg)->data || (((pReg)->data->numRects + (n)) > (pReg)->data->size)) \ + if (!RegionRectAlloc(pReg, n)) { return FALSE; } + +#define ADDRECT(pNextRect,nx1,ny1,nx2,ny2) \ +{ \ + pNextRect->x1 = nx1; \ + pNextRect->y1 = ny1; \ + pNextRect->x2 = nx2; \ + pNextRect->y2 = ny2; \ + pNextRect++; \ +} + +#define NEWRECT(pReg,pNextRect,nx1,ny1,nx2,ny2) \ +{ \ + if (!(pReg)->data || ((pReg)->data->numRects == (pReg)->data->size))\ + { \ + if (!RegionRectAlloc(pReg, 1)) \ + return FALSE; \ + pNextRect = RegionTop(pReg); \ + } \ + ADDRECT(pNextRect,nx1,ny1,nx2,ny2); \ + pReg->data->numRects++; \ + assert(pReg->data->numRects<=pReg->data->size); \ +} + + +#define DOWNSIZE(reg,numRects) \ +if (((numRects) < ((reg)->data->size >> 1)) && ((reg)->data->size > 50)) \ +{ \ + size_t NewSize = RegionSizeof(numRects); \ + RegDataPtr NewData = \ + (NewSize > 0) ? (RegDataPtr)realloc((reg)->data, NewSize) : NULL; \ + if (NewData) \ + { \ + NewData->size = (numRects); \ + (reg)->data = NewData; \ + } \ +} + + +pixman_box16_t RegionEmptyBox = {0, 0, 0, 0}; +RegDataRec RegionEmptyData = {0, 0}; + +RegDataRec RegionBrokenData = {0, 0}; +RegionRec RegionBrokenRegion = { { 0, 0, 0, 0 }, &RegionBrokenData }; + +#ifdef DEBUG +int +RegionPrint(rgn) + RegionPtr rgn; +{ + int num, size; + register int i; + BoxPtr rects; + + num = RegionNumRects(rgn); + size = RegionSize(rgn); + rects = RegionRects(rgn); + ErrorF("num: %d size: %d\n", num, size); + ErrorF("extents: %d %d %d %d\n", + rgn->extents.x1, rgn->extents.y1, rgn->extents.x2, rgn->extents.y2); + for (i = 0; i < num; i++) + ErrorF("%d %d %d %d \n", + rects[i].x1, rects[i].y1, rects[i].x2, rects[i].y2); + ErrorF("\n"); + return(num); +} +#endif /* DEBUG */ + +#ifdef DEBUG +Bool +RegionIsValid(reg) + RegionPtr reg; +{ + register int i, numRects; + + if ((reg->extents.x1 > reg->extents.x2) || + (reg->extents.y1 > reg->extents.y2)) + return FALSE; + numRects = RegionNumRects(reg); + if (!numRects) + return ((reg->extents.x1 == reg->extents.x2) && + (reg->extents.y1 == reg->extents.y2) && + (reg->data->size || (reg->data == &RegionEmptyData))); + else if (numRects == 1) + return (!reg->data); + else + { + register BoxPtr pboxP, pboxN; + BoxRec box; + + pboxP = RegionRects(reg); + box = *pboxP; + box.y2 = pboxP[numRects-1].y2; + pboxN = pboxP + 1; + for (i = numRects; --i > 0; pboxP++, pboxN++) + { + if ((pboxN->x1 >= pboxN->x2) || + (pboxN->y1 >= pboxN->y2)) + return FALSE; + if (pboxN->x1 < box.x1) + box.x1 = pboxN->x1; + if (pboxN->x2 > box.x2) + box.x2 = pboxN->x2; + if ((pboxN->y1 < pboxP->y1) || + ((pboxN->y1 == pboxP->y1) && + ((pboxN->x1 < pboxP->x2) || (pboxN->y2 != pboxP->y2)))) + return FALSE; + } + return ((box.x1 == reg->extents.x1) && + (box.x2 == reg->extents.x2) && + (box.y1 == reg->extents.y1) && + (box.y2 == reg->extents.y2)); + } +} + +#endif /* DEBUG */ + + +/***************************************************************** + * RegionCreate(rect, size) + * This routine does a simple malloc to make a structure of + * REGION of "size" number of rectangles. + *****************************************************************/ + +RegionPtr +RegionCreate(rect, size) + BoxPtr rect; + int size; +{ + register RegionPtr pReg; + size_t newSize; + pReg = (RegionPtr)malloc(sizeof(RegionRec)); + if (!pReg) + return &RegionBrokenRegion; + if (rect) + { + pReg->extents = *rect; + pReg->data = (RegDataPtr)NULL; + } + else + { + pReg->extents = RegionEmptyBox; + newSize = RegionSizeof(size); + if ((size > 1) && (newSize > 0) && + (pReg->data = malloc(newSize))) + { + pReg->data->size = size; + pReg->data->numRects = 0; + } + else + pReg->data = &RegionEmptyData; + } + return(pReg); +} + +void +RegionDestroy(pReg) + RegionPtr pReg; +{ + good(pReg); + xfreeData(pReg); + if (pReg != &RegionBrokenRegion) + free(pReg); +} + +Bool +RegionBreak (pReg) + RegionPtr pReg; +{ + xfreeData (pReg); + pReg->extents = RegionEmptyBox; + pReg->data = &RegionBrokenData; + return FALSE; +} + +Bool +RegionRectAlloc( + register RegionPtr pRgn, + int n) +{ + RegDataPtr data; + size_t rgnSize; + + if (!pRgn->data) + { + n++; + rgnSize = RegionSizeof(n); + pRgn->data = (rgnSize > 0) ? malloc(rgnSize) : NULL; + if (!pRgn->data) + return RegionBreak (pRgn); + pRgn->data->numRects = 1; + *RegionBoxptr(pRgn) = pRgn->extents; + } + else if (!pRgn->data->size) + { + rgnSize = RegionSizeof(n); + pRgn->data = (rgnSize > 0) ? malloc(rgnSize) : NULL; + if (!pRgn->data) + return RegionBreak (pRgn); + pRgn->data->numRects = 0; + } + else + { + if (n == 1) + { + n = pRgn->data->numRects; + if (n > 500) /* XXX pick numbers out of a hat */ + n = 250; + } + n += pRgn->data->numRects; + rgnSize = RegionSizeof(n); + data = (rgnSize > 0) ? realloc(pRgn->data, rgnSize) : NULL; + if (!data) + return RegionBreak (pRgn); + pRgn->data = data; + } + pRgn->data->size = n; + return TRUE; +} + + + +/*====================================================================== + * Generic Region Operator + *====================================================================*/ + +/*- + *----------------------------------------------------------------------- + * RegionCoalesce -- + * Attempt to merge the boxes in the current band with those in the + * previous one. We are guaranteed that the current band extends to + * the end of the rects array. Used only by RegionOp. + * + * Results: + * The new index for the previous band. + * + * Side Effects: + * If coalescing takes place: + * - rectangles in the previous band will have their y2 fields + * altered. + * - pReg->data->numRects will be decreased. + * + *----------------------------------------------------------------------- + */ +INLINE static int +RegionCoalesce ( + register RegionPtr pReg, /* Region to coalesce */ + int prevStart, /* Index of start of previous band */ + int curStart) /* Index of start of current band */ +{ + register BoxPtr pPrevBox; /* Current box in previous band */ + register BoxPtr pCurBox; /* Current box in current band */ + register int numRects; /* Number rectangles in both bands */ + register int y2; /* Bottom of current band */ + /* + * Figure out how many rectangles are in the band. + */ + numRects = curStart - prevStart; + assert(numRects == pReg->data->numRects - curStart); + + if (!numRects) return curStart; + + /* + * The bands may only be coalesced if the bottom of the previous + * matches the top scanline of the current. + */ + pPrevBox = RegionBox(pReg, prevStart); + pCurBox = RegionBox(pReg, curStart); + if (pPrevBox->y2 != pCurBox->y1) return curStart; + + /* + * Make sure the bands have boxes in the same places. This + * assumes that boxes have been added in such a way that they + * cover the most area possible. I.e. two boxes in a band must + * have some horizontal space between them. + */ + y2 = pCurBox->y2; + + do { + if ((pPrevBox->x1 != pCurBox->x1) || (pPrevBox->x2 != pCurBox->x2)) { + return (curStart); + } + pPrevBox++; + pCurBox++; + numRects--; + } while (numRects); + + /* + * The bands may be merged, so set the bottom y of each box + * in the previous band to the bottom y of the current band. + */ + numRects = curStart - prevStart; + pReg->data->numRects -= numRects; + do { + pPrevBox--; + pPrevBox->y2 = y2; + numRects--; + } while (numRects); + return prevStart; +} + + +/* Quicky macro to avoid trivial reject procedure calls to RegionCoalesce */ + +#define Coalesce(newReg, prevBand, curBand) \ + if (curBand - prevBand == newReg->data->numRects - curBand) { \ + prevBand = RegionCoalesce(newReg, prevBand, curBand); \ + } else { \ + prevBand = curBand; \ + } + +/*- + *----------------------------------------------------------------------- + * RegionAppendNonO -- + * Handle a non-overlapping band for the union and subtract operations. + * Just adds the (top/bottom-clipped) rectangles into the region. + * Doesn't have to check for subsumption or anything. + * + * Results: + * None. + * + * Side Effects: + * pReg->data->numRects is incremented and the rectangles overwritten + * with the rectangles we're passed. + * + *----------------------------------------------------------------------- + */ + +INLINE static Bool +RegionAppendNonO ( + register RegionPtr pReg, + register BoxPtr r, + BoxPtr rEnd, + register int y1, + register int y2) +{ + register BoxPtr pNextRect; + register int newRects; + + newRects = rEnd - r; + + assert(y1 < y2); + assert(newRects != 0); + + /* Make sure we have enough space for all rectangles to be added */ + RECTALLOC(pReg, newRects); + pNextRect = RegionTop(pReg); + pReg->data->numRects += newRects; + do { + assert(r->x1 < r->x2); + ADDRECT(pNextRect, r->x1, y1, r->x2, y2); + r++; + } while (r != rEnd); + + return TRUE; +} + +#define FindBand(r, rBandEnd, rEnd, ry1) \ +{ \ + ry1 = r->y1; \ + rBandEnd = r+1; \ + while ((rBandEnd != rEnd) && (rBandEnd->y1 == ry1)) { \ + rBandEnd++; \ + } \ +} + +#define AppendRegions(newReg, r, rEnd) \ +{ \ + int newRects; \ + if ((newRects = rEnd - r)) { \ + RECTALLOC(newReg, newRects); \ + memmove((char *)RegionTop(newReg),(char *)r, \ + newRects * sizeof(BoxRec)); \ + newReg->data->numRects += newRects; \ + } \ +} + +/*- + *----------------------------------------------------------------------- + * RegionOp -- + * Apply an operation to two regions. Called by RegionUnion, RegionInverse, + * RegionSubtract, RegionIntersect.... Both regions MUST have at least one + * rectangle, and cannot be the same object. + * + * Results: + * TRUE if successful. + * + * Side Effects: + * The new region is overwritten. + * pOverlap set to TRUE if overlapFunc ever returns TRUE. + * + * Notes: + * The idea behind this function is to view the two regions as sets. + * Together they cover a rectangle of area that this function divides + * into horizontal bands where points are covered only by one region + * or by both. For the first case, the nonOverlapFunc is called with + * each the band and the band's upper and lower extents. For the + * second, the overlapFunc is called to process the entire band. It + * is responsible for clipping the rectangles in the band, though + * this function provides the boundaries. + * At the end of each band, the new region is coalesced, if possible, + * to reduce the number of rectangles in the region. + * + *----------------------------------------------------------------------- + */ + +typedef Bool (*OverlapProcPtr)( + RegionPtr pReg, + BoxPtr r1, + BoxPtr r1End, + BoxPtr r2, + BoxPtr r2End, + short y1, + short y2, + Bool *pOverlap); + +static Bool +RegionOp( + RegionPtr newReg, /* Place to store result */ + RegionPtr reg1, /* First region in operation */ + RegionPtr reg2, /* 2d region in operation */ + OverlapProcPtr overlapFunc, /* Function to call for over- + * lapping bands */ + Bool appendNon1, /* Append non-overlapping bands */ + /* in region 1 ? */ + Bool appendNon2, /* Append non-overlapping bands */ + /* in region 2 ? */ + Bool *pOverlap) +{ + register BoxPtr r1; /* Pointer into first region */ + register BoxPtr r2; /* Pointer into 2d region */ + BoxPtr r1End; /* End of 1st region */ + BoxPtr r2End; /* End of 2d region */ + short ybot; /* Bottom of intersection */ + short ytop; /* Top of intersection */ + RegDataPtr oldData; /* Old data for newReg */ + int prevBand; /* Index of start of + * previous band in newReg */ + int curBand; /* Index of start of current + * band in newReg */ + register BoxPtr r1BandEnd; /* End of current band in r1 */ + register BoxPtr r2BandEnd; /* End of current band in r2 */ + short top; /* Top of non-overlapping band */ + short bot; /* Bottom of non-overlapping band*/ + register int r1y1; /* Temps for r1->y1 and r2->y1 */ + register int r2y1; + int newSize; + int numRects; + + /* + * Break any region computed from a broken region + */ + if (RegionNar (reg1) || RegionNar(reg2)) + return RegionBreak (newReg); + + /* + * Initialization: + * set r1, r2, r1End and r2End appropriately, save the rectangles + * of the destination region until the end in case it's one of + * the two source regions, then mark the "new" region empty, allocating + * another array of rectangles for it to use. + */ + + r1 = RegionRects(reg1); + newSize = RegionNumRects(reg1); + r1End = r1 + newSize; + numRects = RegionNumRects(reg2); + r2 = RegionRects(reg2); + r2End = r2 + numRects; + assert(r1 != r1End); + assert(r2 != r2End); + + oldData = (RegDataPtr)NULL; + if (((newReg == reg1) && (newSize > 1)) || + ((newReg == reg2) && (numRects > 1))) + { + oldData = newReg->data; + newReg->data = &RegionEmptyData; + } + /* guess at new size */ + if (numRects > newSize) + newSize = numRects; + newSize <<= 1; + if (!newReg->data) + newReg->data = &RegionEmptyData; + else if (newReg->data->size) + newReg->data->numRects = 0; + if (newSize > newReg->data->size) + if (!RegionRectAlloc(newReg, newSize)) + return FALSE; + + /* + * Initialize ybot. + * In the upcoming loop, ybot and ytop serve different functions depending + * on whether the band being handled is an overlapping or non-overlapping + * band. + * In the case of a non-overlapping band (only one of the regions + * has points in the band), ybot is the bottom of the most recent + * intersection and thus clips the top of the rectangles in that band. + * ytop is the top of the next intersection between the two regions and + * serves to clip the bottom of the rectangles in the current band. + * For an overlapping band (where the two regions intersect), ytop clips + * the top of the rectangles of both regions and ybot clips the bottoms. + */ + + ybot = min(r1->y1, r2->y1); + + /* + * prevBand serves to mark the start of the previous band so rectangles + * can be coalesced into larger rectangles. qv. RegionCoalesce, above. + * In the beginning, there is no previous band, so prevBand == curBand + * (curBand is set later on, of course, but the first band will always + * start at index 0). prevBand and curBand must be indices because of + * the possible expansion, and resultant moving, of the new region's + * array of rectangles. + */ + prevBand = 0; + + do { + /* + * This algorithm proceeds one source-band (as opposed to a + * destination band, which is determined by where the two regions + * intersect) at a time. r1BandEnd and r2BandEnd serve to mark the + * rectangle after the last one in the current band for their + * respective regions. + */ + assert(r1 != r1End); + assert(r2 != r2End); + + FindBand(r1, r1BandEnd, r1End, r1y1); + FindBand(r2, r2BandEnd, r2End, r2y1); + + /* + * First handle the band that doesn't intersect, if any. + * + * Note that attention is restricted to one band in the + * non-intersecting region at once, so if a region has n + * bands between the current position and the next place it overlaps + * the other, this entire loop will be passed through n times. + */ + if (r1y1 < r2y1) { + if (appendNon1) { + top = max(r1y1, ybot); + bot = min(r1->y2, r2y1); + if (top != bot) { + curBand = newReg->data->numRects; + RegionAppendNonO(newReg, r1, r1BandEnd, top, bot); + Coalesce(newReg, prevBand, curBand); + } + } + ytop = r2y1; + } else if (r2y1 < r1y1) { + if (appendNon2) { + top = max(r2y1, ybot); + bot = min(r2->y2, r1y1); + if (top != bot) { + curBand = newReg->data->numRects; + RegionAppendNonO(newReg, r2, r2BandEnd, top, bot); + Coalesce(newReg, prevBand, curBand); + } + } + ytop = r1y1; + } else { + ytop = r1y1; + } + + /* + * Now see if we've hit an intersecting band. The two bands only + * intersect if ybot > ytop + */ + ybot = min(r1->y2, r2->y2); + if (ybot > ytop) { + curBand = newReg->data->numRects; + (* overlapFunc)(newReg, r1, r1BandEnd, r2, r2BandEnd, ytop, ybot, + pOverlap); + Coalesce(newReg, prevBand, curBand); + } + + /* + * If we've finished with a band (y2 == ybot) we skip forward + * in the region to the next band. + */ + if (r1->y2 == ybot) r1 = r1BandEnd; + if (r2->y2 == ybot) r2 = r2BandEnd; + + } while (r1 != r1End && r2 != r2End); + + /* + * Deal with whichever region (if any) still has rectangles left. + * + * We only need to worry about banding and coalescing for the very first + * band left. After that, we can just group all remaining boxes, + * regardless of how many bands, into one final append to the list. + */ + + if ((r1 != r1End) && appendNon1) { + /* Do first nonOverlap1Func call, which may be able to coalesce */ + FindBand(r1, r1BandEnd, r1End, r1y1); + curBand = newReg->data->numRects; + RegionAppendNonO(newReg, r1, r1BandEnd, max(r1y1, ybot), r1->y2); + Coalesce(newReg, prevBand, curBand); + /* Just append the rest of the boxes */ + AppendRegions(newReg, r1BandEnd, r1End); + + } else if ((r2 != r2End) && appendNon2) { + /* Do first nonOverlap2Func call, which may be able to coalesce */ + FindBand(r2, r2BandEnd, r2End, r2y1); + curBand = newReg->data->numRects; + RegionAppendNonO(newReg, r2, r2BandEnd, max(r2y1, ybot), r2->y2); + Coalesce(newReg, prevBand, curBand); + /* Append rest of boxes */ + AppendRegions(newReg, r2BandEnd, r2End); + } + + if (oldData) + free(oldData); + + if (!(numRects = newReg->data->numRects)) + { + xfreeData(newReg); + newReg->data = &RegionEmptyData; + } + else if (numRects == 1) + { + newReg->extents = *RegionBoxptr(newReg); + xfreeData(newReg); + newReg->data = (RegDataPtr)NULL; + } + else + { + DOWNSIZE(newReg, numRects); + } + + return TRUE; +} + +/*- + *----------------------------------------------------------------------- + * RegionSetExtents -- + * Reset the extents of a region to what they should be. Called by + * RegionSubtract and RegionIntersect as they can't figure it out along the + * way or do so easily, as RegionUnion can. + * + * Results: + * None. + * + * Side Effects: + * The region's 'extents' structure is overwritten. + * + *----------------------------------------------------------------------- + */ +void +RegionSetExtents (pReg) + register RegionPtr pReg; +{ + register BoxPtr pBox, pBoxEnd; + + if (!pReg->data) + return; + if (!pReg->data->size) + { + pReg->extents.x2 = pReg->extents.x1; + pReg->extents.y2 = pReg->extents.y1; + return; + } + + pBox = RegionBoxptr(pReg); + pBoxEnd = RegionEnd(pReg); + + /* + * Since pBox is the first rectangle in the region, it must have the + * smallest y1 and since pBoxEnd is the last rectangle in the region, + * it must have the largest y2, because of banding. Initialize x1 and + * x2 from pBox and pBoxEnd, resp., as good things to initialize them + * to... + */ + pReg->extents.x1 = pBox->x1; + pReg->extents.y1 = pBox->y1; + pReg->extents.x2 = pBoxEnd->x2; + pReg->extents.y2 = pBoxEnd->y2; + + assert(pReg->extents.y1 < pReg->extents.y2); + while (pBox <= pBoxEnd) { + if (pBox->x1 < pReg->extents.x1) + pReg->extents.x1 = pBox->x1; + if (pBox->x2 > pReg->extents.x2) + pReg->extents.x2 = pBox->x2; + pBox++; + }; + + assert(pReg->extents.x1 < pReg->extents.x2); +} + +#define MERGERECT(r) \ +{ \ + if (r->x1 <= x2) { \ + /* Merge with current rectangle */ \ + if (r->x1 < x2) *pOverlap = TRUE; \ + if (x2 < r->x2) x2 = r->x2; \ + } else { \ + /* Add current rectangle, start new one */ \ + NEWRECT(pReg, pNextRect, x1, y1, x2, y2); \ + x1 = r->x1; \ + x2 = r->x2; \ + } \ + r++; \ +} + +/*====================================================================== + * Region Union + *====================================================================*/ + +/*- + *----------------------------------------------------------------------- + * RegionUnionO -- + * Handle an overlapping band for the union operation. Picks the + * left-most rectangle each time and merges it into the region. + * + * Results: + * TRUE if successful. + * + * Side Effects: + * pReg is overwritten. + * pOverlap is set to TRUE if any boxes overlap. + * + *----------------------------------------------------------------------- + */ +static Bool +RegionUnionO ( + register RegionPtr pReg, + register BoxPtr r1, + BoxPtr r1End, + register BoxPtr r2, + BoxPtr r2End, + short y1, + short y2, + Bool *pOverlap) +{ + register BoxPtr pNextRect; + register int x1; /* left and right side of current union */ + register int x2; + + assert (y1 < y2); + assert(r1 != r1End && r2 != r2End); + + pNextRect = RegionTop(pReg); + + /* Start off current rectangle */ + if (r1->x1 < r2->x1) + { + x1 = r1->x1; + x2 = r1->x2; + r1++; + } + else + { + x1 = r2->x1; + x2 = r2->x2; + r2++; + } + while (r1 != r1End && r2 != r2End) + { + if (r1->x1 < r2->x1) MERGERECT(r1) else MERGERECT(r2); + } + + /* Finish off whoever (if any) is left */ + if (r1 != r1End) + { + do + { + MERGERECT(r1); + } while (r1 != r1End); + } + else if (r2 != r2End) + { + do + { + MERGERECT(r2); + } while (r2 != r2End); + } + + /* Add current rectangle */ + NEWRECT(pReg, pNextRect, x1, y1, x2, y2); + + return TRUE; +} + +/*====================================================================== + * Batch Rectangle Union + *====================================================================*/ + +/*- + *----------------------------------------------------------------------- + * RegionAppend -- + * + * "Append" the rgn rectangles onto the end of dstrgn, maintaining + * knowledge of YX-banding when it's easy. Otherwise, dstrgn just + * becomes a non-y-x-banded random collection of rectangles, and not + * yet a true region. After a sequence of appends, the caller must + * call RegionValidate to ensure that a valid region is constructed. + * + * Results: + * TRUE if successful. + * + * Side Effects: + * dstrgn is modified if rgn has rectangles. + * + */ +Bool +RegionAppend(dstrgn, rgn) + register RegionPtr dstrgn; + register RegionPtr rgn; +{ + int numRects, dnumRects, size; + BoxPtr new, old; + Bool prepend; + + if (RegionNar(rgn)) + return RegionBreak (dstrgn); + + if (!rgn->data && (dstrgn->data == &RegionEmptyData)) + { + dstrgn->extents = rgn->extents; + dstrgn->data = (RegDataPtr)NULL; + return TRUE; + } + + numRects = RegionNumRects(rgn); + if (!numRects) + return TRUE; + prepend = FALSE; + size = numRects; + dnumRects = RegionNumRects(dstrgn); + if (!dnumRects && (size < 200)) + size = 200; /* XXX pick numbers out of a hat */ + RECTALLOC(dstrgn, size); + old = RegionRects(rgn); + if (!dnumRects) + dstrgn->extents = rgn->extents; + else if (dstrgn->extents.x2 > dstrgn->extents.x1) + { + register BoxPtr first, last; + + first = old; + last = RegionBoxptr(dstrgn) + (dnumRects - 1); + if ((first->y1 > last->y2) || + ((first->y1 == last->y1) && (first->y2 == last->y2) && + (first->x1 > last->x2))) + { + if (rgn->extents.x1 < dstrgn->extents.x1) + dstrgn->extents.x1 = rgn->extents.x1; + if (rgn->extents.x2 > dstrgn->extents.x2) + dstrgn->extents.x2 = rgn->extents.x2; + dstrgn->extents.y2 = rgn->extents.y2; + } + else + { + first = RegionBoxptr(dstrgn); + last = old + (numRects - 1); + if ((first->y1 > last->y2) || + ((first->y1 == last->y1) && (first->y2 == last->y2) && + (first->x1 > last->x2))) + { + prepend = TRUE; + if (rgn->extents.x1 < dstrgn->extents.x1) + dstrgn->extents.x1 = rgn->extents.x1; + if (rgn->extents.x2 > dstrgn->extents.x2) + dstrgn->extents.x2 = rgn->extents.x2; + dstrgn->extents.y1 = rgn->extents.y1; + } + else + dstrgn->extents.x2 = dstrgn->extents.x1; + } + } + if (prepend) + { + new = RegionBox(dstrgn, numRects); + if (dnumRects == 1) + *new = *RegionBoxptr(dstrgn); + else + memmove((char *)new,(char *)RegionBoxptr(dstrgn), + dnumRects * sizeof(BoxRec)); + new = RegionBoxptr(dstrgn); + } + else + new = RegionBoxptr(dstrgn) + dnumRects; + if (numRects == 1) + *new = *old; + else + memmove((char *)new, (char *)old, numRects * sizeof(BoxRec)); + dstrgn->data->numRects += numRects; + return TRUE; +} + + +#define ExchangeRects(a, b) \ +{ \ + BoxRec t; \ + t = rects[a]; \ + rects[a] = rects[b]; \ + rects[b] = t; \ +} + +static void +QuickSortRects( + register BoxRec rects[], + register int numRects) +{ + register int y1; + register int x1; + register int i, j; + register BoxPtr r; + + /* Always called with numRects > 1 */ + + do + { + if (numRects == 2) + { + if (rects[0].y1 > rects[1].y1 || + (rects[0].y1 == rects[1].y1 && rects[0].x1 > rects[1].x1)) + ExchangeRects(0, 1); + return; + } + + /* Choose partition element, stick in location 0 */ + ExchangeRects(0, numRects >> 1); + y1 = rects[0].y1; + x1 = rects[0].x1; + + /* Partition array */ + i = 0; + j = numRects; + do + { + r = &(rects[i]); + do + { + r++; + i++; + } while (i != numRects && + (r->y1 < y1 || (r->y1 == y1 && r->x1 < x1))); + r = &(rects[j]); + do + { + r--; + j--; + } while (y1 < r->y1 || (y1 == r->y1 && x1 < r->x1)); + if (i < j) + ExchangeRects(i, j); + } while (i < j); + + /* Move partition element back to middle */ + ExchangeRects(0, j); + + /* Recurse */ + if (numRects-j-1 > 1) + QuickSortRects(&rects[j+1], numRects-j-1); + numRects = j; + } while (numRects > 1); +} + +/*- + *----------------------------------------------------------------------- + * RegionValidate -- + * + * Take a ``region'' which is a non-y-x-banded random collection of + * rectangles, and compute a nice region which is the union of all the + * rectangles. + * + * Results: + * TRUE if successful. + * + * Side Effects: + * The passed-in ``region'' may be modified. + * pOverlap set to TRUE if any retangles overlapped, else FALSE; + * + * Strategy: + * Step 1. Sort the rectangles into ascending order with primary key y1 + * and secondary key x1. + * + * Step 2. Split the rectangles into the minimum number of proper y-x + * banded regions. This may require horizontally merging + * rectangles, and vertically coalescing bands. With any luck, + * this step in an identity tranformation (ala the Box widget), + * or a coalescing into 1 box (ala Menus). + * + * Step 3. Merge the separate regions down to a single region by calling + * RegionUnion. Maximize the work each RegionUnion call does by using + * a binary merge. + * + *----------------------------------------------------------------------- + */ + +Bool +RegionValidate(badreg, pOverlap) + RegionPtr badreg; + Bool *pOverlap; +{ + /* Descriptor for regions under construction in Step 2. */ + typedef struct { + RegionRec reg; + int prevBand; + int curBand; + } RegionInfo; + + int numRects; /* Original numRects for badreg */ + RegionInfo *ri; /* Array of current regions */ + int numRI; /* Number of entries used in ri */ + int sizeRI; /* Number of entries available in ri */ + int i; /* Index into rects */ + register int j; /* Index into ri */ + register RegionInfo *rit; /* &ri[j] */ + register RegionPtr reg; /* ri[j].reg */ + register BoxPtr box; /* Current box in rects */ + register BoxPtr riBox; /* Last box in ri[j].reg */ + register RegionPtr hreg; /* ri[j_half].reg */ + Bool ret = TRUE; + + *pOverlap = FALSE; + if (!badreg->data) + { + good(badreg); + return TRUE; + } + numRects = badreg->data->numRects; + if (!numRects) + { + if (RegionNar(badreg)) + return FALSE; + good(badreg); + return TRUE; + } + if (badreg->extents.x1 < badreg->extents.x2) + { + if ((numRects) == 1) + { + xfreeData(badreg); + badreg->data = (RegDataPtr) NULL; + } + else + { + DOWNSIZE(badreg, numRects); + } + good(badreg); + return TRUE; + } + + /* Step 1: Sort the rects array into ascending (y1, x1) order */ + QuickSortRects(RegionBoxptr(badreg), numRects); + + /* Step 2: Scatter the sorted array into the minimum number of regions */ + + /* Set up the first region to be the first rectangle in badreg */ + /* Note that step 2 code will never overflow the ri[0].reg rects array */ + ri = (RegionInfo *) malloc(4 * sizeof(RegionInfo)); + if (!ri) + return RegionBreak (badreg); + sizeRI = 4; + numRI = 1; + ri[0].prevBand = 0; + ri[0].curBand = 0; + ri[0].reg = *badreg; + box = RegionBoxptr(&ri[0].reg); + ri[0].reg.extents = *box; + ri[0].reg.data->numRects = 1; + + /* Now scatter rectangles into the minimum set of valid regions. If the + next rectangle to be added to a region would force an existing rectangle + in the region to be split up in order to maintain y-x banding, just + forget it. Try the next region. If it doesn't fit cleanly into any + region, make a new one. */ + + for (i = numRects; --i > 0;) + { + box++; + /* Look for a region to append box to */ + for (j = numRI, rit = ri; --j >= 0; rit++) + { + reg = &rit->reg; + riBox = RegionEnd(reg); + + if (box->y1 == riBox->y1 && box->y2 == riBox->y2) + { + /* box is in same band as riBox. Merge or append it */ + if (box->x1 <= riBox->x2) + { + /* Merge it with riBox */ + if (box->x1 < riBox->x2) *pOverlap = TRUE; + if (box->x2 > riBox->x2) riBox->x2 = box->x2; + } + else + { + RECTALLOC_BAIL(reg, 1, bail); + *RegionTop(reg) = *box; + reg->data->numRects++; + } + goto NextRect; /* So sue me */ + } + else if (box->y1 >= riBox->y2) + { + /* Put box into new band */ + if (reg->extents.x2 < riBox->x2) reg->extents.x2 = riBox->x2; + if (reg->extents.x1 > box->x1) reg->extents.x1 = box->x1; + Coalesce(reg, rit->prevBand, rit->curBand); + rit->curBand = reg->data->numRects; + RECTALLOC_BAIL(reg, 1, bail); + *RegionTop(reg) = *box; + reg->data->numRects++; + goto NextRect; + } + /* Well, this region was inappropriate. Try the next one. */ + } /* for j */ + + /* Uh-oh. No regions were appropriate. Create a new one. */ + if (sizeRI == numRI) + { + /* Oops, allocate space for new region information */ + sizeRI <<= 1; + rit = (RegionInfo *) realloc(ri, sizeRI * sizeof(RegionInfo)); + if (!rit) + goto bail; + ri = rit; + rit = &ri[numRI]; + } + numRI++; + rit->prevBand = 0; + rit->curBand = 0; + rit->reg.extents = *box; + rit->reg.data = (RegDataPtr)NULL; + if (!RegionRectAlloc(&rit->reg, (i+numRI) / numRI)) /* MUST force allocation */ + goto bail; +NextRect: ; + } /* for i */ + + /* Make a final pass over each region in order to Coalesce and set + extents.x2 and extents.y2 */ + + for (j = numRI, rit = ri; --j >= 0; rit++) + { + reg = &rit->reg; + riBox = RegionEnd(reg); + reg->extents.y2 = riBox->y2; + if (reg->extents.x2 < riBox->x2) reg->extents.x2 = riBox->x2; + Coalesce(reg, rit->prevBand, rit->curBand); + if (reg->data->numRects == 1) /* keep unions happy below */ + { + xfreeData(reg); + reg->data = (RegDataPtr)NULL; + } + } + + /* Step 3: Union all regions into a single region */ + while (numRI > 1) + { + int half = numRI/2; + for (j = numRI & 1; j < (half + (numRI & 1)); j++) + { + reg = &ri[j].reg; + hreg = &ri[j+half].reg; + if (!RegionOp(reg, reg, hreg, RegionUnionO, TRUE, TRUE, pOverlap)) + ret = FALSE; + if (hreg->extents.x1 < reg->extents.x1) + reg->extents.x1 = hreg->extents.x1; + if (hreg->extents.y1 < reg->extents.y1) + reg->extents.y1 = hreg->extents.y1; + if (hreg->extents.x2 > reg->extents.x2) + reg->extents.x2 = hreg->extents.x2; + if (hreg->extents.y2 > reg->extents.y2) + reg->extents.y2 = hreg->extents.y2; + xfreeData(hreg); + } + numRI -= half; + } + *badreg = ri[0].reg; + free(ri); + good(badreg); + return ret; +bail: + for (i = 0; i < numRI; i++) + xfreeData(&ri[i].reg); + free (ri); + return RegionBreak (badreg); +} + +RegionPtr +RegionFromRects(nrects, prect, ctype) + int nrects; + register xRectangle *prect; + int ctype; +{ + register RegionPtr pRgn; + register RegDataPtr pData; + register BoxPtr pBox; + register int i; + int x1, y1, x2, y2; + size_t newSize; + + pRgn = RegionCreate(NullBox, 0); + if (RegionNar (pRgn)) + return pRgn; + if (!nrects) + return pRgn; + if (nrects == 1) + { + x1 = prect->x; + y1 = prect->y; + if ((x2 = x1 + (int) prect->width) > MAXSHORT) + x2 = MAXSHORT; + if ((y2 = y1 + (int) prect->height) > MAXSHORT) + y2 = MAXSHORT; + if (x1 != x2 && y1 != y2) + { + pRgn->extents.x1 = x1; + pRgn->extents.y1 = y1; + pRgn->extents.x2 = x2; + pRgn->extents.y2 = y2; + pRgn->data = (RegDataPtr)NULL; + } + return pRgn; + } + newSize = RegionSizeof(nrects); + pData = newSize > 0 ? malloc(newSize) : NULL; + if (!pData) + { + RegionBreak (pRgn); + return pRgn; + } + pBox = (BoxPtr) (pData + 1); + for (i = nrects; --i >= 0; prect++) + { + x1 = prect->x; + y1 = prect->y; + if ((x2 = x1 + (int) prect->width) > MAXSHORT) + x2 = MAXSHORT; + if ((y2 = y1 + (int) prect->height) > MAXSHORT) + y2 = MAXSHORT; + if (x1 != x2 && y1 != y2) + { + pBox->x1 = x1; + pBox->y1 = y1; + pBox->x2 = x2; + pBox->y2 = y2; + pBox++; + } + } + if (pBox != (BoxPtr) (pData + 1)) + { + pData->size = nrects; + pData->numRects = pBox - (BoxPtr) (pData + 1); + pRgn->data = pData; + if (ctype != CT_YXBANDED) + { + Bool overlap; /* result ignored */ + pRgn->extents.x1 = pRgn->extents.x2 = 0; + RegionValidate(pRgn, &overlap); + } + else + RegionSetExtents(pRgn); + good(pRgn); + } + else + { + free (pData); + } + return pRgn; +} + +Bool +miRegionDataCopy( + register RegionPtr dst, + register RegionPtr src) +{ + good(dst); + good(src); + if (dst->data) + return TRUE; + if (dst == src) + return TRUE; + if (!src->data || !src->data->size) + { + xfreeData(dst); + dst->data = (RegDataPtr)NULL; + return TRUE; + } + if (!dst->data || (dst->data->size < src->data->numRects)) + { + size_t newSize = RegionSizeof(src->data->numRects); + xfreeData(dst); + dst->data = newSize > 0 ? malloc(newSize) : NULL; + if (!dst->data) + return RegionBreak (dst); + } + dst->data->size = src->data->size; + dst->data->numRects = src->data->numRects; + return TRUE; +} + +#define ExchangeSpans(a, b) \ +{ \ + DDXPointRec tpt; \ + register int tw; \ + \ + tpt = spans[a]; spans[a] = spans[b]; spans[b] = tpt; \ + tw = widths[a]; widths[a] = widths[b]; widths[b] = tw; \ +} + +/* ||| I should apply the merge sort code to rectangle sorting above, and see + if mapping time can be improved. But right now I've been at work 12 hours, + so forget it. +*/ + +static void QuickSortSpans( + register DDXPointRec spans[], + register int widths[], + register int numSpans) +{ + register int y; + register int i, j, m; + register DDXPointPtr r; + + /* Always called with numSpans > 1 */ + /* Sorts only by y, doesn't bother to sort by x */ + + do + { + if (numSpans < 9) + { + /* Do insertion sort */ + register int yprev; + + yprev = spans[0].y; + i = 1; + do + { /* while i != numSpans */ + y = spans[i].y; + if (yprev > y) + { + /* spans[i] is out of order. Move into proper location. */ + DDXPointRec tpt; + int tw, k; + + for (j = 0; y >= spans[j].y; j++) {} + tpt = spans[i]; + tw = widths[i]; + for (k = i; k != j; k--) + { + spans[k] = spans[k-1]; + widths[k] = widths[k-1]; + } + spans[j] = tpt; + widths[j] = tw; + y = spans[i].y; + } /* if out of order */ + yprev = y; + i++; + } while (i != numSpans); + return; + } + + /* Choose partition element, stick in location 0 */ + m = numSpans / 2; + if (spans[m].y > spans[0].y) ExchangeSpans(m, 0); + if (spans[m].y > spans[numSpans-1].y) ExchangeSpans(m, numSpans-1); + if (spans[m].y > spans[0].y) ExchangeSpans(m, 0); + y = spans[0].y; + + /* Partition array */ + i = 0; + j = numSpans; + do + { + r = &(spans[i]); + do + { + r++; + i++; + } while (i != numSpans && r->y < y); + r = &(spans[j]); + do + { + r--; + j--; + } while (y < r->y); + if (i < j) + ExchangeSpans(i, j); + } while (i < j); + + /* Move partition element back to middle */ + ExchangeSpans(0, j); + + /* Recurse */ + if (numSpans-j-1 > 1) + QuickSortSpans(&spans[j+1], &widths[j+1], numSpans-j-1); + numSpans = j; + } while (numSpans > 1); +} + +#define NextBand() \ +{ \ + clipy1 = pboxBandStart->y1; \ + clipy2 = pboxBandStart->y2; \ + pboxBandEnd = pboxBandStart + 1; \ + while (pboxBandEnd != pboxLast && pboxBandEnd->y1 == clipy1) { \ + pboxBandEnd++; \ + } \ + for (; ppt != pptLast && ppt->y < clipy1; ppt++, pwidth++) {} \ +} + +/* + Clip a list of scanlines to a region. The caller has allocated the + space. FSorted is non-zero if the scanline origins are in ascending + order. + returns the number of new, clipped scanlines. +*/ + +int +RegionClipSpans( + RegionPtr prgnDst, + register DDXPointPtr ppt, + register int *pwidth, + int nspans, + register DDXPointPtr pptNew, + int *pwidthNew, + int fSorted) +{ + register DDXPointPtr pptLast; + int *pwidthNewStart; /* the vengeance of Xerox! */ + register int y, x1, x2; + register int numRects; + + good(prgnDst); + pptLast = ppt + nspans; + pwidthNewStart = pwidthNew; + + if (!prgnDst->data) + { + /* Do special fast code with clip boundaries in registers(?) */ + /* It doesn't pay much to make use of fSorted in this case, + so we lump everything together. */ + + register int clipx1, clipx2, clipy1, clipy2; + + clipx1 = prgnDst->extents.x1; + clipy1 = prgnDst->extents.y1; + clipx2 = prgnDst->extents.x2; + clipy2 = prgnDst->extents.y2; + + for (; ppt != pptLast; ppt++, pwidth++) + { + y = ppt->y; + x1 = ppt->x; + if (clipy1 <= y && y < clipy2) + { + x2 = x1 + *pwidth; + if (x1 < clipx1) x1 = clipx1; + if (x2 > clipx2) x2 = clipx2; + if (x1 < x2) + { + /* part of span in clip rectangle */ + pptNew->x = x1; + pptNew->y = y; + *pwidthNew = x2 - x1; + pptNew++; + pwidthNew++; + } + } + } /* end for */ + + } + else if ((numRects = prgnDst->data->numRects)) + { + /* Have to clip against many boxes */ + BoxPtr pboxBandStart, pboxBandEnd; + register BoxPtr pbox; + register BoxPtr pboxLast; + register int clipy1, clipy2; + + /* In this case, taking advantage of sorted spans gains more than + the sorting costs. */ + if ((! fSorted) && (nspans > 1)) + QuickSortSpans(ppt, pwidth, nspans); + + pboxBandStart = RegionBoxptr(prgnDst); + pboxLast = pboxBandStart + numRects; + + NextBand(); + + for (; ppt != pptLast; ) + { + y = ppt->y; + if (y < clipy2) + { + /* span is in the current band */ + pbox = pboxBandStart; + x1 = ppt->x; + x2 = x1 + *pwidth; + do + { /* For each box in band */ + register int newx1, newx2; + + newx1 = x1; + newx2 = x2; + if (newx1 < pbox->x1) newx1 = pbox->x1; + if (newx2 > pbox->x2) newx2 = pbox->x2; + if (newx1 < newx2) + { + /* Part of span in clip rectangle */ + pptNew->x = newx1; + pptNew->y = y; + *pwidthNew = newx2 - newx1; + pptNew++; + pwidthNew++; + } + pbox++; + } while (pbox != pboxBandEnd); + ppt++; + pwidth++; + } + else + { + /* Move to next band, adjust ppt as needed */ + pboxBandStart = pboxBandEnd; + if (pboxBandStart == pboxLast) + break; /* We're completely done */ + NextBand(); + } + } + } + return (pwidthNew - pwidthNewStart); +} + +/* find the band in a region with the most rectangles */ +int +miFindMaxBand(prgn) + RegionPtr prgn; +{ + register int nbox; + register BoxPtr pbox; + register int nThisBand; + register int nMaxBand = 0; + short yThisBand; + + good(prgn); + nbox = RegionNumRects(prgn); + pbox = RegionRects(prgn); + + while(nbox > 0) + { + yThisBand = pbox->y1; + nThisBand = 0; + while((nbox > 0) && (pbox->y1 == yThisBand)) + { + nbox--; + pbox++; + nThisBand++; + } + if (nThisBand > nMaxBand) + nMaxBand = nThisBand; + } + return (nMaxBand); +} diff --git a/nx-X11/programs/Xserver/dix/resource.c b/nx-X11/programs/Xserver/dix/resource.c index e12bc7b67..8d2b612d7 100644 --- a/nx-X11/programs/Xserver/dix/resource.c +++ b/nx-X11/programs/Xserver/dix/resource.c @@ -73,8 +73,6 @@ Equipment Corporation. ******************************************************************/ -/* $Xorg: resource.c,v 1.5 2001/02/09 02:04:40 xorgcvs Exp $ */ -/* $XdotOrg: xc/programs/Xserver/dix/resource.c,v 1.8 2005/07/03 08:53:38 daniels Exp $ */ /* $TOG: resource.c /main/41 1998/02/09 14:20:31 kaleb $ */ /* Routines to manage various kinds of resources: @@ -99,14 +97,12 @@ Equipment Corporation. * 1, and an otherwise arbitrary ID in the low 22 bits, we can create a * resource "owned" by the client. */ -/* $XFree86: xc/programs/Xserver/dix/resource.c,v 3.13 2003/09/24 02:43:13 dawes Exp $ */ -#define NEED_EVENTS #ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> #endif -#include <X11/X.h> +#include <nx-X11/X.h> #include "misc.h" #include "os.h" #include "resource.h" @@ -139,7 +135,7 @@ typedef struct _Resource { struct _Resource *next; XID id; RESTYPE type; - pointer value; + void * value; } ResourceRec, *ResourcePtr; #define NullResource ((ResourcePtr)NULL) @@ -178,7 +174,7 @@ CreateNewResourceType(DeleteType deleteFunc) if (next & lastResourceClass) return 0; - funcs = (DeleteType *)xrealloc(DeleteFuncs, + funcs = (DeleteType *)realloc(DeleteFuncs, (next + 1) * sizeof(DeleteType)); if (!funcs) return 0; @@ -186,7 +182,7 @@ CreateNewResourceType(DeleteType deleteFunc) #ifdef XResExtension { Atom *newnames; - newnames = xrealloc(ResourceNames, (next + 1) * sizeof(Atom)); + newnames = realloc(ResourceNames, (next + 1) * sizeof(Atom)); if(!newnames) return 0; ResourceNames = newnames; @@ -231,8 +227,8 @@ InitClientResources(ClientPtr client) lastResourceClass = RC_LASTPREDEF; TypeMask = RC_LASTPREDEF - 1; if (DeleteFuncs) - xfree(DeleteFuncs); - DeleteFuncs = (DeleteType *)xalloc((lastResourceType + 1) * + free(DeleteFuncs); + DeleteFuncs = (DeleteType *)malloc((lastResourceType + 1) * sizeof(DeleteType)); if (!DeleteFuncs) return FALSE; @@ -249,14 +245,14 @@ InitClientResources(ClientPtr client) #ifdef XResExtension if(ResourceNames) - xfree(ResourceNames); - ResourceNames = xalloc((lastResourceType + 1) * sizeof(Atom)); + free(ResourceNames); + ResourceNames = malloc((lastResourceType + 1) * sizeof(Atom)); if(!ResourceNames) return FALSE; #endif } clientTable[i = client->index].resources = - (ResourcePtr *)xalloc(INITBUCKETS*sizeof(ResourcePtr)); + (ResourcePtr *)malloc(INITBUCKETS*sizeof(ResourcePtr)); if (!clientTable[i].resources) return FALSE; clientTable[i].buckets = INITBUCKETS; @@ -422,8 +418,9 @@ FakeClientID(register int client) return id; } +#ifndef NXAGENT_SERVER Bool -AddResource(XID id, RESTYPE type, pointer value) +AddResource(XID id, RESTYPE type, void * value) { int client; register ClientResourceRec *rrec; @@ -441,7 +438,7 @@ AddResource(XID id, RESTYPE type, pointer value) (rrec->hashsize < MAXHASHSIZE)) RebuildTable(client); head = &rrec->resources[Hash(client, id)]; - res = (ResourcePtr)xalloc(sizeof(ResourceRec)); + res = (ResourcePtr)malloc(sizeof(ResourceRec)); if (!res) { (*DeleteFuncs[type & TypeMask])(value, id); @@ -457,6 +454,7 @@ AddResource(XID id, RESTYPE type, pointer value) rrec->expectID = id + 1; return TRUE; } +#endif /* NXAGENT_SERVER */ static void RebuildTable(int client) @@ -472,13 +470,13 @@ RebuildTable(int client) */ j = 2 * clientTable[client].buckets; - tails = (ResourcePtr **)ALLOCATE_LOCAL(j * sizeof(ResourcePtr *)); + tails = (ResourcePtr **)malloc(j * sizeof(ResourcePtr *)); if (!tails) return; - resources = (ResourcePtr *)xalloc(j * sizeof(ResourcePtr)); + resources = (ResourcePtr *)malloc(j * sizeof(ResourcePtr)); if (!resources) { - DEALLOCATE_LOCAL(tails); + free(tails); return; } for (rptr = resources, tptr = tails; --j >= 0; rptr++, tptr++) @@ -501,12 +499,13 @@ RebuildTable(int client) *tptr = &res->next; } } - DEALLOCATE_LOCAL(tails); + free(tails); clientTable[client].buckets *= 2; - xfree(clientTable[client].resources); + free(clientTable[client].resources); clientTable[client].resources = resources; } +#ifndef NXAGENT_SERVER void FreeResource(XID id, RESTYPE skipDeleteFuncType) { @@ -530,11 +529,9 @@ FreeResource(XID id, RESTYPE skipDeleteFuncType) RESTYPE rtype = res->type; *prev = res->next; elements = --*eltptr; - if (rtype & RC_CACHED) - FlushClientCaches(res->id); if (rtype != skipDeleteFuncType) (*DeleteFuncs[rtype & TypeMask])(res->value, res->id); - xfree(res); + free(res); if (*eltptr != elements) prev = head; /* prev may no longer be valid */ gotOne = TRUE; @@ -542,11 +539,6 @@ FreeResource(XID id, RESTYPE skipDeleteFuncType) else prev = &res->next; } - if(clients[cid] && (id == clients[cid]->lastDrawableID)) - { - clients[cid]->lastDrawable = (DrawablePtr)WindowTable[0]; - clients[cid]->lastDrawableID = WindowTable[0]->drawable.id; - } } if (!gotOne) ErrorF("Freeing resource id=%lX which isn't there.\n", @@ -570,23 +562,17 @@ FreeResourceByType(XID id, RESTYPE type, Bool skipFree) if (res->id == id && res->type == type) { *prev = res->next; - if (type & RC_CACHED) - FlushClientCaches(res->id); if (!skipFree) (*DeleteFuncs[type & TypeMask])(res->value, res->id); - xfree(res); + free(res); break; } else prev = &res->next; } - if(clients[cid] && (id == clients[cid]->lastDrawableID)) - { - clients[cid]->lastDrawable = (DrawablePtr)WindowTable[0]; - clients[cid]->lastDrawableID = WindowTable[0]->drawable.id; - } } } +#endif /* NXAGENT_SERVER */ /* * Change the value associated with a resource id. Caller @@ -595,7 +581,7 @@ FreeResourceByType(XID id, RESTYPE type, Bool skipFree) */ Bool -ChangeResourceValue (XID id, RESTYPE rtype, pointer value) +ChangeResourceValue (XID id, RESTYPE rtype, void * value) { int cid; register ResourcePtr res; @@ -607,8 +593,6 @@ ChangeResourceValue (XID id, RESTYPE rtype, pointer value) for (; res; res = res->next) if ((res->id == id) && (res->type == rtype)) { - if (rtype & RC_CACHED) - FlushClientCaches(res->id); res->value = value; return TRUE; } @@ -622,12 +606,13 @@ ChangeResourceValue (XID id, RESTYPE rtype, pointer value) * add and delete an equal number of resources! */ +#ifndef NXAGENT_SERVER void FindClientResourcesByType( ClientPtr client, RESTYPE type, FindResType func, - pointer cdata + void * cdata ){ register ResourcePtr *resources; register ResourcePtr this, next; @@ -658,7 +643,7 @@ void FindAllClientResources( ClientPtr client, FindAllRes func, - pointer cdata + void * cdata ){ register ResourcePtr *resources; register ResourcePtr this, next; @@ -684,12 +669,12 @@ FindAllClientResources( } -pointer +void * LookupClientResourceComplex( ClientPtr client, RESTYPE type, FindComplexResType func, - pointer cdata + void * cdata ){ ResourcePtr *resources; ResourcePtr this; @@ -709,6 +694,7 @@ LookupClientResourceComplex( } return NULL; } +#endif /* NXAGENT_SERVER */ void @@ -732,10 +718,8 @@ FreeClientNeverRetainResources(ClientPtr client) if (rtype & RC_NEVERRETAIN) { *prev = this->next; - if (rtype & RC_CACHED) - FlushClientCaches(this->id); (*DeleteFuncs[rtype & TypeMask])(this->value, this->id); - xfree(this); + free(this); } else prev = &this->next; @@ -778,13 +762,11 @@ FreeClientResources(ClientPtr client) { RESTYPE rtype = this->type; *head = this->next; - if (rtype & RC_CACHED) - FlushClientCaches(this->id); (*DeleteFuncs[rtype & TypeMask])(this->value, this->id); - xfree(this); + free(this); } } - xfree(clientTable[client->index].resources); + free(clientTable[client->index].resources); clientTable[client->index].resources = NULL; clientTable[client->index].buckets = 0; } @@ -831,12 +813,12 @@ LegalNewID(XID id, register ClientPtr client) * else NULL is returned. */ -pointer +void * SecurityLookupIDByType(ClientPtr client, XID id, RESTYPE rtype, Mask mode) { int cid; register ResourcePtr res; - pointer retval = NULL; + void * retval = NULL; assert(client == NullClient || (client->index <= currentMaxClients && clients[client->index] == client)); @@ -860,12 +842,12 @@ SecurityLookupIDByType(ClientPtr client, XID id, RESTYPE rtype, Mask mode) } -pointer +void * SecurityLookupIDByClass(ClientPtr client, XID id, RESTYPE classes, Mask mode) { int cid; register ResourcePtr res = NULL; - pointer retval = NULL; + void * retval = NULL; assert(client == NullClient || (client->index <= currentMaxClients && clients[client->index] == client)); @@ -892,18 +874,18 @@ SecurityLookupIDByClass(ClientPtr client, XID id, RESTYPE classes, Mask mode) * macros because of compatibility with loadable servers. */ -pointer +void * LookupIDByType(XID id, RESTYPE rtype) { return SecurityLookupIDByType(NullClient, id, rtype, - SecurityUnknownAccess); + DixUnknownAccess); } -pointer +void * LookupIDByClass(XID id, RESTYPE classes) { return SecurityLookupIDByClass(NullClient, id, classes, - SecurityUnknownAccess); + DixUnknownAccess); } #else /* not XCSECURITY */ @@ -911,7 +893,7 @@ LookupIDByClass(XID id, RESTYPE classes) /* * LookupIDByType returns the object with the given id and type, else NULL. */ -pointer +void * LookupIDByType(XID id, RESTYPE rtype) { int cid; @@ -926,14 +908,14 @@ LookupIDByType(XID id, RESTYPE rtype) if ((res->id == id) && (res->type == rtype)) return res->value; } - return (pointer)NULL; + return (void *)NULL; } /* * LookupIDByClass returns the object with the given id and any one of the * given classes, else NULL. */ -pointer +void * LookupIDByClass(XID id, RESTYPE classes) { int cid; @@ -948,7 +930,7 @@ LookupIDByClass(XID id, RESTYPE classes) if ((res->id == id) && (res->type & classes)) return res->value; } - return (pointer)NULL; + return (void *)NULL; } #endif /* XCSECURITY */ diff --git a/nx-X11/programs/Xserver/dix/swaprep.c b/nx-X11/programs/Xserver/dix/swaprep.c index 9776cd437..74dae817d 100644 --- a/nx-X11/programs/Xserver/dix/swaprep.c +++ b/nx-X11/programs/Xserver/dix/swaprep.c @@ -1,4 +1,3 @@ -/* $XFree86: xc/programs/Xserver/dix/swaprep.c,v 3.7 2001/12/14 19:59:33 dawes Exp $ */ /************************************************************ Copyright 1987, 1998 The Open Group @@ -46,16 +45,13 @@ SOFTWARE. ********************************************************/ -/* $Xorg: swaprep.c,v 1.4 2001/02/09 02:04:41 xorgcvs Exp $ */ #ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> #endif -#include <X11/X.h> -#define NEED_REPLIES -#define NEED_EVENTS -#include <X11/Xproto.h> +#include <nx-X11/X.h> +#include <nx-X11/Xproto.h> #include "misc.h" #include "dixstruct.h" #include <X11/fonts/fontstruct.h> @@ -65,11 +61,9 @@ SOFTWARE. static void SwapFontInfo(xQueryFontReply *pr); -#ifndef LBX static void SwapCharInfo(xCharInfo *pInfo); static void SwapFont(xQueryFontReply *pr, Bool hasGlyphs); -#endif /** * Thanks to Jack Palevich for testing and subsequently rewriting all this @@ -80,16 +74,15 @@ void Swap32Write(ClientPtr pClient, int size, register CARD32 *pbuf) { register int i; - register char n; size >>= 2; for(i = 0; i < size; i++) /* brackets are mandatory here, because "swapl" macro expands to several statements */ { - swapl(&pbuf[i], n); + swapl(&pbuf[i]); } - (void)WriteToClient(pClient, size << 2, (char *) pbuf); + WriteToClient(pClient, size << 2, pbuf); } /** @@ -105,7 +98,7 @@ CopySwap32Write(ClientPtr pClient, int size, CARD32 *pbuf) CARD32 tmpbuf[1]; /* Allocate as big a buffer as we can... */ - while (!(pbufT = (CARD32 *) ALLOCATE_LOCAL(bufsize))) + while (!(pbufT = (CARD32 *) malloc(bufsize))) { bufsize >>= 1; if (bufsize == 4) @@ -133,11 +126,11 @@ CopySwap32Write(ClientPtr pClient, int size, CARD32 *pbuf) from++; to++; } - (void)WriteToClient (pClient, nbytes, (char *) pbufT); + WriteToClient (pClient, nbytes, pbufT); } if (pbufT != tmpbuf) - DEALLOCATE_LOCAL ((char *) pbufT); + free ((char *) pbufT); } /** @@ -153,7 +146,7 @@ CopySwap16Write(ClientPtr pClient, int size, short *pbuf) short tmpbuf[2]; /* Allocate as big a buffer as we can... */ - while (!(pbufT = (short *) ALLOCATE_LOCAL(bufsize))) + while (!(pbufT = (short *) malloc(bufsize))) { bufsize >>= 1; if (bufsize == 4) @@ -181,11 +174,11 @@ CopySwap16Write(ClientPtr pClient, int size, short *pbuf) from++; to++; } - (void)WriteToClient (pClient, nbytes, (char *) pbufT); + WriteToClient (pClient, nbytes, pbufT); } if (pbufT != tmpbuf) - DEALLOCATE_LOCAL ((char *) pbufT); + free ((char *) pbufT); } @@ -193,10 +186,8 @@ CopySwap16Write(ClientPtr pClient, int size, short *pbuf) void SGenericReply(ClientPtr pClient, int size, xGenericReply *pRep) { - register char n; - - swaps(&pRep->sequenceNumber, n); - (void)WriteToClient(pClient, size, (char *) pRep); + swaps(&pRep->sequenceNumber); + WriteToClient(pClient, size, pRep); } /* Extra-large reply */ @@ -204,131 +195,111 @@ void SGetWindowAttributesReply(ClientPtr pClient, int size, xGetWindowAttributesReply *pRep) { - register char n; - - swaps(&pRep->sequenceNumber, n); - swapl(&pRep->length, n); - swapl(&pRep->visualID, n); - swaps(&pRep->class, n); - swapl(&pRep->backingBitPlanes, n); - swapl(&pRep->backingPixel, n); - swapl(&pRep->colormap, n); - swapl(&pRep->allEventMasks, n); - swapl(&pRep->yourEventMask, n); - swaps(&pRep->doNotPropagateMask, n); - (void)WriteToClient(pClient, size, (char *) pRep); + swaps(&pRep->sequenceNumber); + swapl(&pRep->length); + swapl(&pRep->visualID); + swaps(&pRep->class); + swapl(&pRep->backingBitPlanes); + swapl(&pRep->backingPixel); + swapl(&pRep->colormap); + swapl(&pRep->allEventMasks); + swapl(&pRep->yourEventMask); + swaps(&pRep->doNotPropagateMask); + WriteToClient(pClient, size, pRep); } void SGetGeometryReply(ClientPtr pClient, int size, xGetGeometryReply *pRep) { - register char n; - - swaps(&pRep->sequenceNumber, n); - swapl(&pRep->root, n); - swaps(&pRep->x, n); - swaps(&pRep->y, n); - swaps(&pRep->width, n); - swaps(&pRep->height, n); - swaps(&pRep->borderWidth, n); - (void)WriteToClient(pClient, size, (char *) pRep); + swaps(&pRep->sequenceNumber); + swapl(&pRep->root); + swaps(&pRep->x); + swaps(&pRep->y); + swaps(&pRep->width); + swaps(&pRep->height); + swaps(&pRep->borderWidth); + WriteToClient(pClient, size, pRep); } void SQueryTreeReply(ClientPtr pClient, int size, xQueryTreeReply *pRep) { - register char n; - - swaps(&pRep->sequenceNumber, n); - swapl(&pRep->length, n); - swapl(&pRep->root, n); - swapl(&pRep->parent, n); - swaps(&pRep->nChildren, n); - (void)WriteToClient(pClient, size, (char *) pRep); + swaps(&pRep->sequenceNumber); + swapl(&pRep->length); + swapl(&pRep->root); + swapl(&pRep->parent); + swaps(&pRep->nChildren); + WriteToClient(pClient, size, pRep); } void SInternAtomReply(ClientPtr pClient, int size, xInternAtomReply *pRep) { - register char n; - - swaps(&pRep->sequenceNumber, n); - swapl(&pRep->atom, n); - (void)WriteToClient(pClient, size, (char *) pRep); + swaps(&pRep->sequenceNumber); + swapl(&pRep->atom); + WriteToClient(pClient, size, pRep); } void SGetAtomNameReply(ClientPtr pClient, int size, xGetAtomNameReply *pRep) { - register char n; - - swaps(&pRep->sequenceNumber, n); - swapl(&pRep->length, n); - swaps(&pRep->nameLength, n); - (void)WriteToClient(pClient, size, (char *) pRep); + swaps(&pRep->sequenceNumber); + swapl(&pRep->length); + swaps(&pRep->nameLength); + WriteToClient(pClient, size, pRep); } void SGetPropertyReply(ClientPtr pClient, int size, xGetPropertyReply *pRep) { - register char n; - - swaps(&pRep->sequenceNumber, n); - swapl(&pRep->length, n); - swapl(&pRep->propertyType, n); - swapl(&pRep->bytesAfter, n); - swapl(&pRep->nItems, n); - (void)WriteToClient(pClient, size, (char *) pRep); + swaps(&pRep->sequenceNumber); + swapl(&pRep->length); + swapl(&pRep->propertyType); + swapl(&pRep->bytesAfter); + swapl(&pRep->nItems); + WriteToClient(pClient, size, pRep); } void SListPropertiesReply(ClientPtr pClient, int size, xListPropertiesReply *pRep) { - register char n; - - swaps(&pRep->sequenceNumber, n); - swapl(&pRep->length, n); - swaps(&pRep->nProperties, n); - (void)WriteToClient(pClient, size, (char *) pRep); + swaps(&pRep->sequenceNumber); + swapl(&pRep->length); + swaps(&pRep->nProperties); + WriteToClient(pClient, size, pRep); } void SGetSelectionOwnerReply(ClientPtr pClient, int size, xGetSelectionOwnerReply *pRep) { - register char n; - - swaps(&pRep->sequenceNumber, n); - swapl(&pRep->owner, n); - (void)WriteToClient(pClient, size, (char *) pRep); + swaps(&pRep->sequenceNumber); + swapl(&pRep->owner); + WriteToClient(pClient, size, pRep); } void SQueryPointerReply(ClientPtr pClient, int size, xQueryPointerReply *pRep) { - register char n; - - swaps(&pRep->sequenceNumber, n); - swapl(&pRep->root, n); - swapl(&pRep->child, n); - swaps(&pRep->rootX, n); - swaps(&pRep->rootY, n); - swaps(&pRep->winX, n); - swaps(&pRep->winY, n); - swaps(&pRep->mask, n); - (void)WriteToClient(pClient, size, (char *) pRep); + swaps(&pRep->sequenceNumber); + swapl(&pRep->root); + swapl(&pRep->child); + swaps(&pRep->rootX); + swaps(&pRep->rootY); + swaps(&pRep->winX); + swaps(&pRep->winY); + swaps(&pRep->mask); + WriteToClient(pClient, size, pRep); } void SwapTimecoord(xTimecoord* pCoord) { - register char n; - - swapl(&pCoord->time, n); - swaps(&pCoord->x, n); - swaps(&pCoord->y, n); + swapl(&pCoord->time); + swaps(&pCoord->x); + swaps(&pCoord->y); } void @@ -344,88 +315,72 @@ SwapTimeCoordWrite(ClientPtr pClient, int size, xTimecoord *pRep) SwapTimecoord(pRepT); pRepT++; } - (void)WriteToClient(pClient, size, (char *) pRep); + WriteToClient(pClient, size, pRep); } void SGetMotionEventsReply(ClientPtr pClient, int size, xGetMotionEventsReply *pRep) { - register char n; - - swaps(&pRep->sequenceNumber, n); - swapl(&pRep->length, n); - swapl(&pRep->nEvents, n); - (void)WriteToClient(pClient, size, (char *) pRep); + swaps(&pRep->sequenceNumber); + swapl(&pRep->length); + swapl(&pRep->nEvents); + WriteToClient(pClient, size, pRep); } void STranslateCoordsReply(ClientPtr pClient, int size, xTranslateCoordsReply *pRep) { - register char n; - - swaps(&pRep->sequenceNumber, n); - swapl(&pRep->child, n); - swaps(&pRep->dstX, n); - swaps(&pRep->dstY, n); - (void)WriteToClient(pClient, size, (char *) pRep); + swaps(&pRep->sequenceNumber); + swapl(&pRep->child); + swaps(&pRep->dstX); + swaps(&pRep->dstY); + WriteToClient(pClient, size, pRep); } void SGetInputFocusReply(ClientPtr pClient, int size, xGetInputFocusReply *pRep) { - register char n; - - swaps(&pRep->sequenceNumber, n); - swapl(&pRep->focus, n); - (void)WriteToClient(pClient, size, (char *) pRep); + swaps(&pRep->sequenceNumber); + swapl(&pRep->focus); + WriteToClient(pClient, size, pRep); } /* extra long reply */ void SQueryKeymapReply(ClientPtr pClient, int size, xQueryKeymapReply *pRep) { - register char n; - - swaps(&pRep->sequenceNumber, n); - swapl(&pRep->length, n); - (void)WriteToClient(pClient, size, (char *) pRep); + swaps(&pRep->sequenceNumber); + swapl(&pRep->length); + WriteToClient(pClient, size, pRep); } -#ifndef LBX static -#endif void SwapCharInfo(xCharInfo *pInfo) { - register char n; - - swaps(&pInfo->leftSideBearing, n); - swaps(&pInfo->rightSideBearing, n); - swaps(&pInfo->characterWidth, n); - swaps(&pInfo->ascent, n); - swaps(&pInfo->descent, n); - swaps(&pInfo->attributes, n); + swaps(&pInfo->leftSideBearing); + swaps(&pInfo->rightSideBearing); + swaps(&pInfo->characterWidth); + swaps(&pInfo->ascent); + swaps(&pInfo->descent); + swaps(&pInfo->attributes); } static void SwapFontInfo(xQueryFontReply *pr) { - register char n; - - swaps(&pr->minCharOrByte2, n); - swaps(&pr->maxCharOrByte2, n); - swaps(&pr->defaultChar, n); - swaps(&pr->nFontProps, n); - swaps(&pr->fontAscent, n); - swaps(&pr->fontDescent, n); + swaps(&pr->minCharOrByte2); + swaps(&pr->maxCharOrByte2); + swaps(&pr->defaultChar); + swaps(&pr->nFontProps); + swaps(&pr->fontAscent); + swaps(&pr->fontDescent); SwapCharInfo( &pr->minBounds); SwapCharInfo( &pr->maxBounds); - swapl(&pr->nCharInfos, n); + swapl(&pr->nCharInfos); } -#ifndef LBX static -#endif void SwapFont(xQueryFontReply *pr, Bool hasGlyphs) { @@ -433,10 +388,9 @@ SwapFont(xQueryFontReply *pr, Bool hasGlyphs) xCharInfo * pxci; unsigned nchars, nprops; char *pby; - register char n; - swaps(&pr->sequenceNumber, n); - swapl(&pr->length, n); + swaps(&pr->sequenceNumber); + swapl(&pr->length); nchars = pr->nCharInfos; nprops = pr->nFontProps; SwapFontInfo(pr); @@ -445,9 +399,9 @@ SwapFont(xQueryFontReply *pr, Bool hasGlyphs) * they are always 2 4 byte values */ for(i = 0; i < nprops; i++) { - swapl(pby, n); + swapl((int *)pby); pby += 4; - swapl(pby, n); + swapl((int *)pby); pby += 4; } if (hasGlyphs) @@ -462,34 +416,30 @@ void SQueryFontReply(ClientPtr pClient, int size, xQueryFontReply *pRep) { SwapFont(pRep, TRUE); - (void)WriteToClient(pClient, size, (char *) pRep); + WriteToClient(pClient, size, pRep); } void SQueryTextExtentsReply(ClientPtr pClient, int size, xQueryTextExtentsReply *pRep) { - register char n; - - swaps(&pRep->sequenceNumber, n); - swaps(&pRep->fontAscent, n); - swaps(&pRep->fontDescent, n); - swaps(&pRep->overallAscent, n); - swaps(&pRep->overallDescent, n); - swapl(&pRep->overallWidth, n); - swapl(&pRep->overallLeft, n); - swapl(&pRep->overallRight, n); - (void)WriteToClient(pClient, size, (char *) pRep); + swaps(&pRep->sequenceNumber); + swaps(&pRep->fontAscent); + swaps(&pRep->fontDescent); + swaps(&pRep->overallAscent); + swaps(&pRep->overallDescent); + swapl(&pRep->overallWidth); + swapl(&pRep->overallLeft); + swapl(&pRep->overallRight); + WriteToClient(pClient, size, pRep); } void SListFontsReply(ClientPtr pClient, int size, xListFontsReply *pRep) { - register char n; - - swaps(&pRep->sequenceNumber, n); - swapl(&pRep->length, n); - swaps(&pRep->nFonts, n); - (void)WriteToClient(pClient, size, (char *) pRep); + swaps(&pRep->sequenceNumber); + swapl(&pRep->length); + swaps(&pRep->nFonts); + WriteToClient(pClient, size, pRep); } void @@ -497,29 +447,25 @@ SListFontsWithInfoReply(ClientPtr pClient, int size, xListFontsWithInfoReply *pRep) { SwapFont((xQueryFontReply *)pRep, FALSE); - (void)WriteToClient(pClient, size, (char *) pRep); + WriteToClient(pClient, size, pRep); } void SGetFontPathReply(ClientPtr pClient, int size, xGetFontPathReply *pRep) { - register char n; - - swaps(&pRep->sequenceNumber, n); - swapl(&pRep->length, n); - swaps(&pRep->nPaths, n); - (void)WriteToClient(pClient, size, (char *) pRep); + swaps(&pRep->sequenceNumber); + swapl(&pRep->length); + swaps(&pRep->nPaths); + WriteToClient(pClient, size, pRep); } void SGetImageReply(ClientPtr pClient, int size, xGetImageReply *pRep) { - register char n; - - swaps(&pRep->sequenceNumber, n); - swapl(&pRep->length, n); - swapl(&pRep->visual, n); - (void)WriteToClient(pClient, size, (char *) pRep); + swaps(&pRep->sequenceNumber); + swapl(&pRep->length); + swapl(&pRep->visual); + WriteToClient(pClient, size, pRep); /* Fortunately, image doesn't need swapping */ } @@ -527,12 +473,10 @@ void SListInstalledColormapsReply(ClientPtr pClient, int size, xListInstalledColormapsReply *pRep) { - register char n; - - swaps(&pRep->sequenceNumber, n); - swapl(&pRep->length, n); - swaps(&pRep->nColormaps, n); - (void)WriteToClient(pClient, size, (char *) pRep); + swaps(&pRep->sequenceNumber); + swapl(&pRep->length); + swaps(&pRep->nColormaps); + WriteToClient(pClient, size, pRep); } void @@ -541,67 +485,57 @@ SAllocColorReply(pClient, size, pRep) int size; xAllocColorReply *pRep; { - register char n; - - swaps(&pRep->sequenceNumber, n); - swaps(&pRep->red, n); - swaps(&pRep->green, n); - swaps(&pRep->blue, n); - swapl(&pRep->pixel, n); - (void)WriteToClient(pClient, size, (char *) pRep); + swaps(&pRep->sequenceNumber); + swaps(&pRep->red); + swaps(&pRep->green); + swaps(&pRep->blue); + swapl(&pRep->pixel); + WriteToClient(pClient, size, pRep); } void SAllocNamedColorReply(ClientPtr pClient, int size, xAllocNamedColorReply *pRep) { - register char n; - - swaps(&pRep->sequenceNumber, n); - swapl(&pRep->pixel, n); - swaps(&pRep->exactRed, n); - swaps(&pRep->exactGreen, n); - swaps(&pRep->exactBlue, n); - swaps(&pRep->screenRed, n); - swaps(&pRep->screenGreen, n); - swaps(&pRep->screenBlue, n); - (void)WriteToClient(pClient, size, (char *) pRep); + swaps(&pRep->sequenceNumber); + swapl(&pRep->pixel); + swaps(&pRep->exactRed); + swaps(&pRep->exactGreen); + swaps(&pRep->exactBlue); + swaps(&pRep->screenRed); + swaps(&pRep->screenGreen); + swaps(&pRep->screenBlue); + WriteToClient(pClient, size, pRep); } void SAllocColorCellsReply(ClientPtr pClient, int size, xAllocColorCellsReply *pRep) { - register char n; - - swaps(&pRep->sequenceNumber, n); - swapl(&pRep->length, n); - swaps(&pRep->nPixels, n); - swaps(&pRep->nMasks, n); - (void)WriteToClient(pClient, size, (char *) pRep); + swaps(&pRep->sequenceNumber); + swapl(&pRep->length); + swaps(&pRep->nPixels); + swaps(&pRep->nMasks); + WriteToClient(pClient, size, pRep); } void SAllocColorPlanesReply(ClientPtr pClient, int size, xAllocColorPlanesReply *pRep) { - register char n; - - swaps(&pRep->sequenceNumber, n); - swapl(&pRep->length, n); - swaps(&pRep->nPixels, n); - swapl(&pRep->redMask, n); - swapl(&pRep->greenMask, n); - swapl(&pRep->blueMask, n); - (void)WriteToClient(pClient, size, (char *) pRep); + swaps(&pRep->sequenceNumber); + swapl(&pRep->length); + swaps(&pRep->nPixels); + swapl(&pRep->redMask); + swapl(&pRep->greenMask); + swapl(&pRep->blueMask); + WriteToClient(pClient, size, pRep); } void SwapRGB(xrgb *prgb) { - register char n; - - swaps(&prgb->red, n); - swaps(&prgb->green, n); - swaps(&prgb->blue, n); + swaps(&prgb->red); + swaps(&prgb->green); + swaps(&prgb->blue); } void @@ -617,123 +551,103 @@ SQColorsExtend(ClientPtr pClient, int size, xrgb *prgb) SwapRGB(prgbT); prgbT++; } - (void)WriteToClient(pClient, size, (char *) prgb); + WriteToClient(pClient, size, prgb); } void SQueryColorsReply(ClientPtr pClient, int size, xQueryColorsReply* pRep) { - register char n; - - swaps(&pRep->sequenceNumber, n); - swapl(&pRep->length, n); - swaps(&pRep->nColors, n); - (void)WriteToClient(pClient, size, (char *) pRep); + swaps(&pRep->sequenceNumber); + swapl(&pRep->length); + swaps(&pRep->nColors); + WriteToClient(pClient, size, pRep); } void SLookupColorReply(ClientPtr pClient, int size, xLookupColorReply *pRep) { - register char n; - - swaps(&pRep->sequenceNumber, n); - swaps(&pRep->exactRed, n); - swaps(&pRep->exactGreen, n); - swaps(&pRep->exactBlue, n); - swaps(&pRep->screenRed, n); - swaps(&pRep->screenGreen, n); - swaps(&pRep->screenBlue, n); - (void)WriteToClient(pClient, size, (char *) pRep); + swaps(&pRep->sequenceNumber); + swaps(&pRep->exactRed); + swaps(&pRep->exactGreen); + swaps(&pRep->exactBlue); + swaps(&pRep->screenRed); + swaps(&pRep->screenGreen); + swaps(&pRep->screenBlue); + WriteToClient(pClient, size, pRep); } void SQueryBestSizeReply(ClientPtr pClient, int size, xQueryBestSizeReply *pRep) { - register char n; - - swaps(&pRep->sequenceNumber, n); - swaps(&pRep->width, n); - swaps(&pRep->height, n); - (void)WriteToClient(pClient, size, (char *) pRep); + swaps(&pRep->sequenceNumber); + swaps(&pRep->width); + swaps(&pRep->height); + WriteToClient(pClient, size, pRep); } void SListExtensionsReply(ClientPtr pClient, int size, xListExtensionsReply *pRep) { - register char n; - - swaps(&pRep->sequenceNumber, n); - swapl(&pRep->length, n); - (void)WriteToClient(pClient, size, (char *) pRep); + swaps(&pRep->sequenceNumber); + swapl(&pRep->length); + WriteToClient(pClient, size, pRep); } void SGetKeyboardMappingReply(ClientPtr pClient, int size, xGetKeyboardMappingReply *pRep) { - register char n; - - swaps(&pRep->sequenceNumber, n); - swapl(&pRep->length, n); - (void)WriteToClient(pClient, size, (char *) pRep); + swaps(&pRep->sequenceNumber); + swapl(&pRep->length); + WriteToClient(pClient, size, pRep); } void SGetPointerMappingReply(ClientPtr pClient, int size, xGetPointerMappingReply *pRep) { - register char n; - - swaps(&pRep->sequenceNumber, n); - swapl(&pRep->length, n); - (void)WriteToClient(pClient, size, (char *) pRep); + swaps(&pRep->sequenceNumber); + swapl(&pRep->length); + WriteToClient(pClient, size, pRep); } void SGetModifierMappingReply(ClientPtr pClient, int size, xGetModifierMappingReply *pRep) { - register char n; - - swaps(&pRep->sequenceNumber, n); - swapl(&pRep->length, n); - (void)WriteToClient(pClient, size, (char *) pRep); + swaps(&pRep->sequenceNumber); + swapl(&pRep->length); + WriteToClient(pClient, size, pRep); } void SGetKeyboardControlReply(ClientPtr pClient, int size, xGetKeyboardControlReply *pRep) { - register char n; - - swaps(&pRep->sequenceNumber, n); - swapl(&pRep->length, n); - swapl(&pRep->ledMask, n); - swaps(&pRep->bellPitch, n); - swaps(&pRep->bellDuration, n); - (void)WriteToClient(pClient, size, (char *) pRep); + swaps(&pRep->sequenceNumber); + swapl(&pRep->length); + swapl(&pRep->ledMask); + swaps(&pRep->bellPitch); + swaps(&pRep->bellDuration); + WriteToClient(pClient, size, pRep); } void SGetPointerControlReply(ClientPtr pClient, int size, xGetPointerControlReply *pRep) { - register char n; - - swaps(&pRep->sequenceNumber, n); - swaps(&pRep->accelNumerator, n); - swaps(&pRep->accelDenominator, n); - swaps(&pRep->threshold, n); - (void)WriteToClient(pClient, size, (char *) pRep); + swaps(&pRep->sequenceNumber); + swaps(&pRep->accelNumerator); + swaps(&pRep->accelDenominator); + swaps(&pRep->threshold); + WriteToClient(pClient, size, pRep); } void SGetScreenSaverReply(ClientPtr pClient, int size, xGetScreenSaverReply *pRep) { - register char n; - - swaps(&pRep->sequenceNumber, n); - swaps(&pRep->timeout, n); - swaps(&pRep->interval, n); - (void)WriteToClient(pClient, size, (char *) pRep); + swaps(&pRep->sequenceNumber); + swaps(&pRep->timeout); + swaps(&pRep->interval); + WriteToClient(pClient, size, pRep); } void @@ -744,22 +658,19 @@ SLHostsExtend(ClientPtr pClient, int size, char *buf) while (bufT < endbuf) { xHostEntry *host = (xHostEntry *) bufT; int len = host->length; - register char n; - swaps (&host->length, n); + swaps (&host->length); bufT += sizeof (xHostEntry) + (((len + 3) >> 2) << 2); } - (void)WriteToClient (pClient, size, buf); + WriteToClient (pClient, size, buf); } void SListHostsReply(ClientPtr pClient, int size, xListHostsReply *pRep) { - register char n; - - swaps(&pRep->sequenceNumber, n); - swapl(&pRep->length, n); - swaps(&pRep->nHosts, n); - (void)WriteToClient(pClient, size, (char *) pRep); + swaps(&pRep->sequenceNumber); + swapl(&pRep->length); + swaps(&pRep->nHosts); + WriteToClient(pClient, size, pRep); } @@ -1226,15 +1137,15 @@ WriteSConnectionInfo(ClientPtr pClient, unsigned long size, char *pInfo) { char *pInfoTBase; - pInfoTBase = (char *) ALLOCATE_LOCAL(size); + pInfoTBase = (char *) malloc(size); if (!pInfoTBase) { pClient->noClientException = -1; return; } SwapConnSetupInfo(pInfo, pInfoTBase); - (void)WriteToClient(pClient, (int)size, (char *) pInfoTBase); - DEALLOCATE_LOCAL(pInfoTBase); + WriteToClient(pClient, (int)size, pInfoTBase); + free(pInfoTBase); } void @@ -1305,5 +1216,5 @@ WriteSConnSetupPrefix(ClientPtr pClient, xConnSetupPrefix *pcsp) xConnSetupPrefix cspT; SwapConnSetupPrefix(pcsp, &cspT); - (void)WriteToClient(pClient, sizeof(cspT), (char *) &cspT); + WriteToClient(pClient, sizeof(cspT), &cspT); } diff --git a/nx-X11/programs/Xserver/dix/swapreq.c b/nx-X11/programs/Xserver/dix/swapreq.c index 7d57d551f..7ea841e12 100644 --- a/nx-X11/programs/Xserver/dix/swapreq.c +++ b/nx-X11/programs/Xserver/dix/swapreq.c @@ -1,4 +1,3 @@ -/* $XFree86: xc/programs/Xserver/dix/swapreq.c,v 3.4 2001/12/14 19:59:33 dawes Exp $ */ /************************************************************ Copyright 1987, 1998 The Open Group @@ -46,16 +45,14 @@ SOFTWARE. ********************************************************/ -/* $Xorg: swapreq.c,v 1.4 2001/02/09 02:04:41 xorgcvs Exp $ */ #ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> #endif -#include <X11/X.h> -#define NEED_EVENTS -#include <X11/Xproto.h> -#include <X11/Xprotostr.h> +#include <nx-X11/X.h> +#include <nx-X11/Xproto.h> +#include <nx-X11/Xprotostr.h> #include "misc.h" #include "dixstruct.h" #include "extnsionst.h" /* for SendEvent */ @@ -68,23 +65,21 @@ SOFTWARE. void SwapLongs (register CARD32 *list, register unsigned long count) { - register char n; - while (count >= 8) { - swapl(list+0, n); - swapl(list+1, n); - swapl(list+2, n); - swapl(list+3, n); - swapl(list+4, n); - swapl(list+5, n); - swapl(list+6, n); - swapl(list+7, n); + swapl(list+0); + swapl(list+1); + swapl(list+2); + swapl(list+3); + swapl(list+4); + swapl(list+5); + swapl(list+6); + swapl(list+7); list += 8; count -= 8; } if (count != 0) { do { - swapl(list, n); + swapl(list); list++; } while (--count != 0); } @@ -95,31 +90,29 @@ SwapLongs (register CARD32 *list, register unsigned long count) void SwapShorts (register short *list, register unsigned long count) { - register char n; - while (count >= 16) { - swaps(list+0, n); - swaps(list+1, n); - swaps(list+2, n); - swaps(list+3, n); - swaps(list+4, n); - swaps(list+5, n); - swaps(list+6, n); - swaps(list+7, n); - swaps(list+8, n); - swaps(list+9, n); - swaps(list+10, n); - swaps(list+11, n); - swaps(list+12, n); - swaps(list+13, n); - swaps(list+14, n); - swaps(list+15, n); + swaps(list+0); + swaps(list+1); + swaps(list+2); + swaps(list+3); + swaps(list+4); + swaps(list+5); + swaps(list+6); + swaps(list+7); + swaps(list+8); + swaps(list+9); + swaps(list+10); + swaps(list+11); + swaps(list+12); + swaps(list+13); + swaps(list+14); + swaps(list+15); list += 16; count -= 16; } if (count != 0) { do { - swaps(list, n); + swaps(list); list++; } while (--count != 0); } @@ -130,10 +123,8 @@ SwapShorts (register short *list, register unsigned long count) int SProcSimpleReq(register ClientPtr client) { - register char n; - REQUEST(xReq); - swaps(&stuff->length, n); + swaps(&stuff->length); return(*ProcVector[stuff->reqType])(client); } @@ -143,33 +134,29 @@ SProcSimpleReq(register ClientPtr client) int SProcResourceReq(register ClientPtr client) { - register char n; - REQUEST(xResourceReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xResourceReq); /* not EXACT */ - swapl(&stuff->id, n); + swapl(&stuff->id); return(*ProcVector[stuff->reqType])(client); } int SProcCreateWindow(register ClientPtr client) { - register char n; - REQUEST(xCreateWindowReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xCreateWindowReq); - swapl(&stuff->wid, n); - swapl(&stuff->parent, n); - swaps(&stuff->x, n); - swaps(&stuff->y, n); - swaps(&stuff->width, n); - swaps(&stuff->height, n); - swaps(&stuff->borderWidth, n); - swaps(&stuff->class, n); - swapl(&stuff->visual, n); - swapl(&stuff->mask, n); + swapl(&stuff->wid); + swapl(&stuff->parent); + swaps(&stuff->x); + swaps(&stuff->y); + swaps(&stuff->width); + swaps(&stuff->height); + swaps(&stuff->borderWidth); + swaps(&stuff->class); + swapl(&stuff->visual); + swapl(&stuff->mask); SwapRestL(stuff); return((* ProcVector[X_CreateWindow])(client)); } @@ -177,13 +164,11 @@ SProcCreateWindow(register ClientPtr client) int SProcChangeWindowAttributes(register ClientPtr client) { - register char n; - REQUEST(xChangeWindowAttributesReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xChangeWindowAttributesReq); - swapl(&stuff->window, n); - swapl(&stuff->valueMask, n); + swapl(&stuff->window); + swapl(&stuff->valueMask); SwapRestL(stuff); return((* ProcVector[X_ChangeWindowAttributes])(client)); } @@ -191,26 +176,24 @@ SProcChangeWindowAttributes(register ClientPtr client) int SProcReparentWindow(register ClientPtr client) { - register char n; REQUEST(xReparentWindowReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_SIZE_MATCH(xReparentWindowReq); - swapl(&stuff->window, n); - swapl(&stuff->parent, n); - swaps(&stuff->x, n); - swaps(&stuff->y, n); + swapl(&stuff->window); + swapl(&stuff->parent); + swaps(&stuff->x); + swaps(&stuff->y); return((* ProcVector[X_ReparentWindow])(client)); } int SProcConfigureWindow(register ClientPtr client) { - register char n; REQUEST(xConfigureWindowReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xConfigureWindowReq); - swapl(&stuff->window, n); - swaps(&stuff->mask, n); + swapl(&stuff->window); + swaps(&stuff->mask); SwapRestL(stuff); return((* ProcVector[X_ConfigureWindow])(client)); @@ -220,25 +203,23 @@ SProcConfigureWindow(register ClientPtr client) int SProcInternAtom(register ClientPtr client) { - register char n; REQUEST(xInternAtomReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xInternAtomReq); - swaps(&stuff->nbytes, n); + swaps(&stuff->nbytes); return((* ProcVector[X_InternAtom])(client)); } int SProcChangeProperty(register ClientPtr client) { - register char n; REQUEST(xChangePropertyReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xChangePropertyReq); - swapl(&stuff->window, n); - swapl(&stuff->property, n); - swapl(&stuff->type, n); - swapl(&stuff->nUnits, n); + swapl(&stuff->window); + swapl(&stuff->property); + swapl(&stuff->type); + swapl(&stuff->nUnits); switch ( stuff->format ) { case 8 : break; @@ -255,12 +236,11 @@ SProcChangeProperty(register ClientPtr client) int SProcDeleteProperty(register ClientPtr client) { - register char n; REQUEST(xDeletePropertyReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_SIZE_MATCH(xDeletePropertyReq); - swapl(&stuff->window, n); - swapl(&stuff->property, n); + swapl(&stuff->window); + swapl(&stuff->property); return((* ProcVector[X_DeleteProperty])(client)); } @@ -268,57 +248,53 @@ SProcDeleteProperty(register ClientPtr client) int SProcGetProperty(register ClientPtr client) { - register char n; REQUEST(xGetPropertyReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_SIZE_MATCH(xGetPropertyReq); - swapl(&stuff->window, n); - swapl(&stuff->property, n); - swapl(&stuff->type, n); - swapl(&stuff->longOffset, n); - swapl(&stuff->longLength, n); + swapl(&stuff->window); + swapl(&stuff->property); + swapl(&stuff->type); + swapl(&stuff->longOffset); + swapl(&stuff->longLength); return((* ProcVector[X_GetProperty])(client)); } int SProcSetSelectionOwner(register ClientPtr client) { - register char n; REQUEST(xSetSelectionOwnerReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_SIZE_MATCH(xSetSelectionOwnerReq); - swapl(&stuff->window, n); - swapl(&stuff->selection, n); - swapl(&stuff->time, n); + swapl(&stuff->window); + swapl(&stuff->selection); + swapl(&stuff->time); return((* ProcVector[X_SetSelectionOwner])(client)); } int SProcConvertSelection(register ClientPtr client) { - register char n; REQUEST(xConvertSelectionReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_SIZE_MATCH(xConvertSelectionReq); - swapl(&stuff->requestor, n); - swapl(&stuff->selection, n); - swapl(&stuff->target, n); - swapl(&stuff->property, n); - swapl(&stuff->time, n); + swapl(&stuff->requestor); + swapl(&stuff->selection); + swapl(&stuff->target); + swapl(&stuff->property); + swapl(&stuff->time); return((* ProcVector[X_ConvertSelection])(client)); } int SProcSendEvent(register ClientPtr client) { - register char n; xEvent eventT; EventSwapPtr proc; REQUEST(xSendEventReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_SIZE_MATCH(xSendEventReq); - swapl(&stuff->destination, n); - swapl(&stuff->eventMask, n); + swapl(&stuff->destination); + swapl(&stuff->eventMask); /* Swap event */ proc = EventSwapVector[stuff->event.u.u.type & 0177]; @@ -333,223 +309,206 @@ SProcSendEvent(register ClientPtr client) int SProcGrabPointer(register ClientPtr client) { - register char n; REQUEST(xGrabPointerReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_SIZE_MATCH(xGrabPointerReq); - swapl(&stuff->grabWindow, n); - swaps(&stuff->eventMask, n); - swapl(&stuff->confineTo, n); - swapl(&stuff->cursor, n); - swapl(&stuff->time, n); + swapl(&stuff->grabWindow); + swaps(&stuff->eventMask); + swapl(&stuff->confineTo); + swapl(&stuff->cursor); + swapl(&stuff->time); return((* ProcVector[X_GrabPointer])(client)); } int SProcGrabButton(register ClientPtr client) { - register char n; REQUEST(xGrabButtonReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_SIZE_MATCH(xGrabButtonReq); - swapl(&stuff->grabWindow, n); - swaps(&stuff->eventMask, n); - swapl(&stuff->confineTo, n); - swapl(&stuff->cursor, n); - swaps(&stuff->modifiers, n); + swapl(&stuff->grabWindow); + swaps(&stuff->eventMask); + swapl(&stuff->confineTo); + swapl(&stuff->cursor); + swaps(&stuff->modifiers); return((* ProcVector[X_GrabButton])(client)); } int SProcUngrabButton(register ClientPtr client) { - register char n; REQUEST(xUngrabButtonReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_SIZE_MATCH(xUngrabButtonReq); - swapl(&stuff->grabWindow, n); - swaps(&stuff->modifiers, n); + swapl(&stuff->grabWindow); + swaps(&stuff->modifiers); return((* ProcVector[X_UngrabButton])(client)); } int SProcChangeActivePointerGrab(register ClientPtr client) { - register char n; REQUEST(xChangeActivePointerGrabReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_SIZE_MATCH(xChangeActivePointerGrabReq); - swapl(&stuff->cursor, n); - swapl(&stuff->time, n); - swaps(&stuff->eventMask, n); + swapl(&stuff->cursor); + swapl(&stuff->time); + swaps(&stuff->eventMask); return((* ProcVector[X_ChangeActivePointerGrab])(client)); } int SProcGrabKeyboard(register ClientPtr client) { - register char n; REQUEST(xGrabKeyboardReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_SIZE_MATCH(xGrabKeyboardReq); - swapl(&stuff->grabWindow, n); - swapl(&stuff->time, n); + swapl(&stuff->grabWindow); + swapl(&stuff->time); return((* ProcVector[X_GrabKeyboard])(client)); } int SProcGrabKey(register ClientPtr client) { - register char n; REQUEST(xGrabKeyReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_SIZE_MATCH(xGrabKeyReq); - swapl(&stuff->grabWindow, n); - swaps(&stuff->modifiers, n); + swapl(&stuff->grabWindow); + swaps(&stuff->modifiers); return((* ProcVector[X_GrabKey])(client)); } int SProcUngrabKey(register ClientPtr client) { - register char n; REQUEST(xUngrabKeyReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_SIZE_MATCH(xUngrabKeyReq); - swapl(&stuff->grabWindow, n); - swaps(&stuff->modifiers, n); + swapl(&stuff->grabWindow); + swaps(&stuff->modifiers); return((* ProcVector[X_UngrabKey])(client)); } int SProcGetMotionEvents(register ClientPtr client) { - register char n; REQUEST(xGetMotionEventsReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_SIZE_MATCH(xGetMotionEventsReq); - swapl(&stuff->window, n); - swapl(&stuff->start, n); - swapl(&stuff->stop, n); + swapl(&stuff->window); + swapl(&stuff->start); + swapl(&stuff->stop); return((* ProcVector[X_GetMotionEvents])(client)); } int SProcTranslateCoords(register ClientPtr client) { - register char n; REQUEST(xTranslateCoordsReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_SIZE_MATCH(xTranslateCoordsReq); - swapl(&stuff->srcWid, n); - swapl(&stuff->dstWid, n); - swaps(&stuff->srcX, n); - swaps(&stuff->srcY, n); + swapl(&stuff->srcWid); + swapl(&stuff->dstWid); + swaps(&stuff->srcX); + swaps(&stuff->srcY); return((* ProcVector[X_TranslateCoords])(client)); } int SProcWarpPointer(register ClientPtr client) { - register char n; REQUEST(xWarpPointerReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_SIZE_MATCH(xWarpPointerReq); - swapl(&stuff->srcWid, n); - swapl(&stuff->dstWid, n); - swaps(&stuff->srcX, n); - swaps(&stuff->srcY, n); - swaps(&stuff->srcWidth, n); - swaps(&stuff->srcHeight, n); - swaps(&stuff->dstX, n); - swaps(&stuff->dstY, n); + swapl(&stuff->srcWid); + swapl(&stuff->dstWid); + swaps(&stuff->srcX); + swaps(&stuff->srcY); + swaps(&stuff->srcWidth); + swaps(&stuff->srcHeight); + swaps(&stuff->dstX); + swaps(&stuff->dstY); return((* ProcVector[X_WarpPointer])(client)); } int SProcSetInputFocus(register ClientPtr client) { - register char n; REQUEST(xSetInputFocusReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_SIZE_MATCH(xSetInputFocusReq); - swapl(&stuff->focus, n); - swapl(&stuff->time, n); + swapl(&stuff->focus); + swapl(&stuff->time); return((* ProcVector[X_SetInputFocus])(client)); } int SProcOpenFont(register ClientPtr client) { - register char n; REQUEST(xOpenFontReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xOpenFontReq); - swapl(&stuff->fid, n); - swaps(&stuff->nbytes, n); + swapl(&stuff->fid); + swaps(&stuff->nbytes); return((* ProcVector[X_OpenFont])(client)); } int SProcListFonts(register ClientPtr client) { - register char n; REQUEST(xListFontsReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xListFontsReq); - swaps(&stuff->maxNames, n); - swaps(&stuff->nbytes, n); + swaps(&stuff->maxNames); + swaps(&stuff->nbytes); return((* ProcVector[X_ListFonts])(client)); } int SProcListFontsWithInfo(register ClientPtr client) { - register char n; REQUEST(xListFontsWithInfoReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xListFontsWithInfoReq); - swaps(&stuff->maxNames, n); - swaps(&stuff->nbytes, n); + swaps(&stuff->maxNames); + swaps(&stuff->nbytes); return((* ProcVector[X_ListFontsWithInfo])(client)); } int SProcSetFontPath(register ClientPtr client) { - register char n; REQUEST(xSetFontPathReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xSetFontPathReq); - swaps(&stuff->nFonts, n); + swaps(&stuff->nFonts); return((* ProcVector[X_SetFontPath])(client)); } int SProcCreatePixmap(register ClientPtr client) { - register char n; REQUEST(xCreatePixmapReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_SIZE_MATCH(xCreatePixmapReq); - swapl(&stuff->pid, n); - swapl(&stuff->drawable, n); - swaps(&stuff->width, n); - swaps(&stuff->height, n); + swapl(&stuff->pid); + swapl(&stuff->drawable); + swaps(&stuff->width); + swaps(&stuff->height); return((* ProcVector[X_CreatePixmap])(client)); } int SProcCreateGC(register ClientPtr client) { - register char n; REQUEST(xCreateGCReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xCreateGCReq); - swapl(&stuff->gc, n); - swapl(&stuff->drawable, n); - swapl(&stuff->mask, n); + swapl(&stuff->gc); + swapl(&stuff->drawable); + swapl(&stuff->mask); SwapRestL(stuff); return((* ProcVector[X_CreateGC])(client)); } @@ -557,12 +516,11 @@ SProcCreateGC(register ClientPtr client) int SProcChangeGC(register ClientPtr client) { - register char n; REQUEST(xChangeGCReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xChangeGCReq); - swapl(&stuff->gc, n); - swapl(&stuff->mask, n); + swapl(&stuff->gc); + swapl(&stuff->mask); SwapRestL(stuff); return((* ProcVector[X_ChangeGC])(client)); } @@ -570,26 +528,24 @@ SProcChangeGC(register ClientPtr client) int SProcCopyGC(register ClientPtr client) { - register char n; REQUEST(xCopyGCReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_SIZE_MATCH(xCopyGCReq); - swapl(&stuff->srcGC, n); - swapl(&stuff->dstGC, n); - swapl(&stuff->mask, n); + swapl(&stuff->srcGC); + swapl(&stuff->dstGC); + swapl(&stuff->mask); return((* ProcVector[X_CopyGC])(client)); } int SProcSetDashes(register ClientPtr client) { - register char n; REQUEST(xSetDashesReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xSetDashesReq); - swapl(&stuff->gc, n); - swaps(&stuff->dashOffset, n); - swaps(&stuff->nDashes, n); + swapl(&stuff->gc); + swaps(&stuff->dashOffset); + swaps(&stuff->nDashes); return((* ProcVector[X_SetDashes])(client)); } @@ -597,13 +553,12 @@ SProcSetDashes(register ClientPtr client) int SProcSetClipRectangles(register ClientPtr client) { - register char n; REQUEST(xSetClipRectanglesReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xSetClipRectanglesReq); - swapl(&stuff->gc, n); - swaps(&stuff->xOrigin, n); - swaps(&stuff->yOrigin, n); + swapl(&stuff->gc); + swaps(&stuff->xOrigin); + swaps(&stuff->yOrigin); SwapRestS(stuff); return((* ProcVector[X_SetClipRectangles])(client)); } @@ -611,54 +566,51 @@ SProcSetClipRectangles(register ClientPtr client) int SProcClearToBackground(register ClientPtr client) { - register char n; REQUEST(xClearAreaReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_SIZE_MATCH(xClearAreaReq); - swapl(&stuff->window, n); - swaps(&stuff->x, n); - swaps(&stuff->y, n); - swaps(&stuff->width, n); - swaps(&stuff->height, n); + swapl(&stuff->window); + swaps(&stuff->x); + swaps(&stuff->y); + swaps(&stuff->width); + swaps(&stuff->height); return((* ProcVector[X_ClearArea])(client)); } int SProcCopyArea(register ClientPtr client) { - register char n; REQUEST(xCopyAreaReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_SIZE_MATCH(xCopyAreaReq); - swapl(&stuff->srcDrawable, n); - swapl(&stuff->dstDrawable, n); - swapl(&stuff->gc, n); - swaps(&stuff->srcX, n); - swaps(&stuff->srcY, n); - swaps(&stuff->dstX, n); - swaps(&stuff->dstY, n); - swaps(&stuff->width, n); - swaps(&stuff->height, n); + swapl(&stuff->srcDrawable); + swapl(&stuff->dstDrawable); + swapl(&stuff->gc); + swaps(&stuff->srcX); + swaps(&stuff->srcY); + swaps(&stuff->dstX); + swaps(&stuff->dstY); + swaps(&stuff->width); + swaps(&stuff->height); return((* ProcVector[X_CopyArea])(client)); } int SProcCopyPlane(register ClientPtr client) { - register char n; REQUEST(xCopyPlaneReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_SIZE_MATCH(xCopyPlaneReq); - swapl(&stuff->srcDrawable, n); - swapl(&stuff->dstDrawable, n); - swapl(&stuff->gc, n); - swaps(&stuff->srcX, n); - swaps(&stuff->srcY, n); - swaps(&stuff->dstX, n); - swaps(&stuff->dstY, n); - swaps(&stuff->width, n); - swaps(&stuff->height, n); - swapl(&stuff->bitPlane, n); + swapl(&stuff->srcDrawable); + swapl(&stuff->dstDrawable); + swapl(&stuff->gc); + swaps(&stuff->srcX); + swaps(&stuff->srcY); + swaps(&stuff->dstX); + swaps(&stuff->dstY); + swaps(&stuff->width); + swaps(&stuff->height); + swapl(&stuff->bitPlane); return((* ProcVector[X_CopyPlane])(client)); } @@ -667,13 +619,11 @@ SProcCopyPlane(register ClientPtr client) int SProcPoly(register ClientPtr client) { - register char n; - REQUEST(xPolyPointReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xPolyPointReq); - swapl(&stuff->drawable, n); - swapl(&stuff->gc, n); + swapl(&stuff->drawable); + swapl(&stuff->gc); SwapRestS(stuff); return((* ProcVector[stuff->reqType])(client)); } @@ -684,13 +634,11 @@ SProcPoly(register ClientPtr client) int SProcFillPoly(register ClientPtr client) { - register char n; - REQUEST(xFillPolyReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xFillPolyReq); - swapl(&stuff->drawable, n); - swapl(&stuff->gc, n); + swapl(&stuff->drawable); + swapl(&stuff->gc); SwapRestS(stuff); return((* ProcVector[X_FillPoly])(client)); } @@ -698,16 +646,15 @@ SProcFillPoly(register ClientPtr client) int SProcPutImage(register ClientPtr client) { - register char n; REQUEST(xPutImageReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xPutImageReq); - swapl(&stuff->drawable, n); - swapl(&stuff->gc, n); - swaps(&stuff->width, n); - swaps(&stuff->height, n); - swaps(&stuff->dstX, n); - swaps(&stuff->dstY, n); + swapl(&stuff->drawable); + swapl(&stuff->gc); + swaps(&stuff->width); + swaps(&stuff->height); + swaps(&stuff->dstX); + swaps(&stuff->dstY); /* Image should already be swapped */ return((* ProcVector[X_PutImage])(client)); @@ -716,16 +663,15 @@ SProcPutImage(register ClientPtr client) int SProcGetImage(register ClientPtr client) { - register char n; REQUEST(xGetImageReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_SIZE_MATCH(xGetImageReq); - swapl(&stuff->drawable, n); - swaps(&stuff->x, n); - swaps(&stuff->y, n); - swaps(&stuff->width, n); - swaps(&stuff->height, n); - swapl(&stuff->planeMask, n); + swapl(&stuff->drawable); + swaps(&stuff->x); + swaps(&stuff->y); + swaps(&stuff->width); + swaps(&stuff->height); + swapl(&stuff->planeMask); return((* ProcVector[X_GetImage])(client)); } @@ -734,14 +680,13 @@ SProcGetImage(register ClientPtr client) int SProcPolyText(register ClientPtr client) { - register char n; REQUEST(xPolyTextReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xPolyTextReq); - swapl(&stuff->drawable, n); - swapl(&stuff->gc, n); - swaps(&stuff->x, n); - swaps(&stuff->y, n); + swapl(&stuff->drawable); + swapl(&stuff->gc); + swaps(&stuff->x); + swaps(&stuff->y); return((* ProcVector[stuff->reqType])(client)); } @@ -750,27 +695,25 @@ SProcPolyText(register ClientPtr client) int SProcImageText(register ClientPtr client) { - register char n; REQUEST(xImageTextReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xImageTextReq); - swapl(&stuff->drawable, n); - swapl(&stuff->gc, n); - swaps(&stuff->x, n); - swaps(&stuff->y, n); + swapl(&stuff->drawable); + swapl(&stuff->gc); + swaps(&stuff->x); + swaps(&stuff->y); return((* ProcVector[stuff->reqType])(client)); } int SProcCreateColormap(register ClientPtr client) { - register char n; REQUEST(xCreateColormapReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_SIZE_MATCH(xCreateColormapReq); - swapl(&stuff->mid, n); - swapl(&stuff->window, n); - swapl(&stuff->visual, n); + swapl(&stuff->mid); + swapl(&stuff->window); + swapl(&stuff->visual); return((* ProcVector[X_CreateColormap])(client)); } @@ -778,12 +721,11 @@ SProcCreateColormap(register ClientPtr client) int SProcCopyColormapAndFree(register ClientPtr client) { - register char n; REQUEST(xCopyColormapAndFreeReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_SIZE_MATCH(xCopyColormapAndFreeReq); - swapl(&stuff->mid, n); - swapl(&stuff->srcCmap, n); + swapl(&stuff->mid); + swapl(&stuff->srcCmap); return((* ProcVector[X_CopyColormapAndFree])(client)); } @@ -791,67 +733,61 @@ SProcCopyColormapAndFree(register ClientPtr client) int SProcAllocColor(register ClientPtr client) { - register char n; REQUEST(xAllocColorReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_SIZE_MATCH(xAllocColorReq); - swapl(&stuff->cmap, n); - swaps(&stuff->red, n); - swaps(&stuff->green, n); - swaps(&stuff->blue, n); + swapl(&stuff->cmap); + swaps(&stuff->red); + swaps(&stuff->green); + swaps(&stuff->blue); return((* ProcVector[X_AllocColor])(client)); } int SProcAllocNamedColor(register ClientPtr client) { - register char n; - REQUEST(xAllocNamedColorReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xAllocNamedColorReq); - swapl(&stuff->cmap, n); - swaps(&stuff->nbytes, n); + swapl(&stuff->cmap); + swaps(&stuff->nbytes); return((* ProcVector[X_AllocNamedColor])(client)); } int SProcAllocColorCells(register ClientPtr client) { - register char n; REQUEST(xAllocColorCellsReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_SIZE_MATCH(xAllocColorCellsReq); - swapl(&stuff->cmap, n); - swaps(&stuff->colors, n); - swaps(&stuff->planes, n); + swapl(&stuff->cmap); + swaps(&stuff->colors); + swaps(&stuff->planes); return((* ProcVector[X_AllocColorCells])(client)); } int SProcAllocColorPlanes(register ClientPtr client) { - register char n; REQUEST(xAllocColorPlanesReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_SIZE_MATCH(xAllocColorPlanesReq); - swapl(&stuff->cmap, n); - swaps(&stuff->colors, n); - swaps(&stuff->red, n); - swaps(&stuff->green, n); - swaps(&stuff->blue, n); + swapl(&stuff->cmap); + swaps(&stuff->colors); + swaps(&stuff->red); + swaps(&stuff->green); + swaps(&stuff->blue); return((* ProcVector[X_AllocColorPlanes])(client)); } int SProcFreeColors(register ClientPtr client) { - register char n; REQUEST(xFreeColorsReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xFreeColorsReq); - swapl(&stuff->cmap, n); - swapl(&stuff->planeMask, n); + swapl(&stuff->cmap); + swapl(&stuff->planeMask); SwapRestL(stuff); return((* ProcVector[X_FreeColors])(client)); @@ -860,25 +796,22 @@ SProcFreeColors(register ClientPtr client) void SwapColorItem(xColorItem *pItem) { - register char n; - - swapl(&pItem->pixel, n); - swaps(&pItem->red, n); - swaps(&pItem->green, n); - swaps(&pItem->blue, n); + swapl(&pItem->pixel); + swaps(&pItem->red); + swaps(&pItem->green); + swaps(&pItem->blue); } int SProcStoreColors(register ClientPtr client) { - register char n; long count; xColorItem *pItem; REQUEST(xStoreColorsReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xStoreColorsReq); - swapl(&stuff->cmap, n); + swapl(&stuff->cmap); pItem = (xColorItem *) &stuff[1]; for(count = LengthRestB(stuff)/sizeof(xColorItem); --count >= 0; ) SwapColorItem(pItem++); @@ -888,24 +821,22 @@ SProcStoreColors(register ClientPtr client) int SProcStoreNamedColor (register ClientPtr client) { - register char n; REQUEST(xStoreNamedColorReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xStoreNamedColorReq); - swapl(&stuff->cmap, n); - swapl(&stuff->pixel, n); - swaps(&stuff->nbytes, n); + swapl(&stuff->cmap); + swapl(&stuff->pixel); + swaps(&stuff->nbytes); return((* ProcVector[X_StoreNamedColor])(client)); } int SProcQueryColors (register ClientPtr client) { - register char n; REQUEST(xQueryColorsReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xQueryColorsReq); - swapl(&stuff->cmap, n); + swapl(&stuff->cmap); SwapRestL(stuff); return((* ProcVector[X_QueryColors])(client)); } @@ -913,54 +844,51 @@ SProcQueryColors (register ClientPtr client) int SProcLookupColor (register ClientPtr client) { - register char n; REQUEST(xLookupColorReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xLookupColorReq); - swapl(&stuff->cmap, n); - swaps(&stuff->nbytes, n); + swapl(&stuff->cmap); + swaps(&stuff->nbytes); return((* ProcVector[X_LookupColor])(client)); } int SProcCreateCursor (register ClientPtr client) { - register char n; REQUEST(xCreateCursorReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_SIZE_MATCH(xCreateCursorReq); - swapl(&stuff->cid, n); - swapl(&stuff->source, n); - swapl(&stuff->mask, n); - swaps(&stuff->foreRed, n); - swaps(&stuff->foreGreen, n); - swaps(&stuff->foreBlue, n); - swaps(&stuff->backRed, n); - swaps(&stuff->backGreen, n); - swaps(&stuff->backBlue, n); - swaps(&stuff->x, n); - swaps(&stuff->y, n); + swapl(&stuff->cid); + swapl(&stuff->source); + swapl(&stuff->mask); + swaps(&stuff->foreRed); + swaps(&stuff->foreGreen); + swaps(&stuff->foreBlue); + swaps(&stuff->backRed); + swaps(&stuff->backGreen); + swaps(&stuff->backBlue); + swaps(&stuff->x); + swaps(&stuff->y); return((* ProcVector[X_CreateCursor])(client)); } int SProcCreateGlyphCursor (register ClientPtr client) { - register char n; REQUEST(xCreateGlyphCursorReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_SIZE_MATCH(xCreateGlyphCursorReq); - swapl(&stuff->cid, n); - swapl(&stuff->source, n); - swapl(&stuff->mask, n); - swaps(&stuff->sourceChar, n); - swaps(&stuff->maskChar, n); - swaps(&stuff->foreRed, n); - swaps(&stuff->foreGreen, n); - swaps(&stuff->foreBlue, n); - swaps(&stuff->backRed, n); - swaps(&stuff->backGreen, n); - swaps(&stuff->backBlue, n); + swapl(&stuff->cid); + swapl(&stuff->source); + swapl(&stuff->mask); + swaps(&stuff->sourceChar); + swaps(&stuff->maskChar); + swaps(&stuff->foreRed); + swaps(&stuff->foreGreen); + swaps(&stuff->foreBlue); + swaps(&stuff->backRed); + swaps(&stuff->backGreen); + swaps(&stuff->backBlue); return((* ProcVector[X_CreateGlyphCursor])(client)); } @@ -968,30 +896,28 @@ SProcCreateGlyphCursor (register ClientPtr client) int SProcRecolorCursor (register ClientPtr client) { - register char n; REQUEST(xRecolorCursorReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_SIZE_MATCH(xRecolorCursorReq); - swapl(&stuff->cursor, n); - swaps(&stuff->foreRed, n); - swaps(&stuff->foreGreen, n); - swaps(&stuff->foreBlue, n); - swaps(&stuff->backRed, n); - swaps(&stuff->backGreen, n); - swaps(&stuff->backBlue, n); + swapl(&stuff->cursor); + swaps(&stuff->foreRed); + swaps(&stuff->foreGreen); + swaps(&stuff->foreBlue); + swaps(&stuff->backRed); + swaps(&stuff->backGreen); + swaps(&stuff->backBlue); return((* ProcVector[X_RecolorCursor])(client)); } int SProcQueryBestSize (register ClientPtr client) { - register char n; REQUEST(xQueryBestSizeReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_SIZE_MATCH(xQueryBestSizeReq); - swapl(&stuff->drawable, n); - swaps(&stuff->width, n); - swaps(&stuff->height, n); + swapl(&stuff->drawable); + swaps(&stuff->width); + swaps(&stuff->height); return((* ProcVector[X_QueryBestSize])(client)); } @@ -999,20 +925,18 @@ SProcQueryBestSize (register ClientPtr client) int SProcQueryExtension (register ClientPtr client) { - register char n; REQUEST(xQueryExtensionReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xQueryExtensionReq); - swaps(&stuff->nbytes, n); + swaps(&stuff->nbytes); return((* ProcVector[X_QueryExtension])(client)); } int SProcChangeKeyboardMapping (register ClientPtr client) { - register char n; REQUEST(xChangeKeyboardMappingReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xChangeKeyboardMappingReq); SwapRestL(stuff); return((* ProcVector[X_ChangeKeyboardMapping])(client)); @@ -1022,11 +946,10 @@ SProcChangeKeyboardMapping (register ClientPtr client) int SProcChangeKeyboardControl (register ClientPtr client) { - register char n; REQUEST(xChangeKeyboardControlReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xChangeKeyboardControlReq); - swapl(&stuff->mask, n); + swapl(&stuff->mask); SwapRestL(stuff); return((* ProcVector[X_ChangeKeyboardControl])(client)); } @@ -1034,13 +957,12 @@ SProcChangeKeyboardControl (register ClientPtr client) int SProcChangePointerControl (register ClientPtr client) { - register char n; REQUEST(xChangePointerControlReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_SIZE_MATCH(xChangePointerControlReq); - swaps(&stuff->accelNum, n); - swaps(&stuff->accelDenum, n); - swaps(&stuff->threshold, n); + swaps(&stuff->accelNum); + swaps(&stuff->accelDenum); + swaps(&stuff->threshold); return((* ProcVector[X_ChangePointerControl])(client)); } @@ -1048,37 +970,33 @@ SProcChangePointerControl (register ClientPtr client) int SProcSetScreenSaver (register ClientPtr client) { - register char n; REQUEST(xSetScreenSaverReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_SIZE_MATCH(xSetScreenSaverReq); - swaps(&stuff->timeout, n); - swaps(&stuff->interval, n); + swaps(&stuff->timeout); + swaps(&stuff->interval); return((* ProcVector[X_SetScreenSaver])(client)); } int SProcChangeHosts (register ClientPtr client) { - register char n; - REQUEST(xChangeHostsReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xChangeHostsReq); - swaps(&stuff->hostLength, n); + swaps(&stuff->hostLength); return((* ProcVector[X_ChangeHosts])(client)); } int SProcRotateProperties (register ClientPtr client) { - register char n; REQUEST(xRotatePropertiesReq); - swaps(&stuff->length, n); + swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xRotatePropertiesReq); - swapl(&stuff->window, n); - swaps(&stuff->nAtoms, n); - swaps(&stuff->nPositions, n); + swapl(&stuff->window); + swaps(&stuff->nAtoms); + swaps(&stuff->nPositions); SwapRestL(stuff); return ((* ProcVector[X_RotateProperties])(client)); } @@ -1086,19 +1004,16 @@ int SProcRotateProperties (register ClientPtr client) int SProcNoOperation(register ClientPtr client) { - register char n; REQUEST(xReq); - swaps(&stuff->length, n); + swaps(&stuff->length); return ((* ProcVector[X_NoOperation])(client)); } void SwapConnClientPrefix(xConnClientPrefix *pCCP) { - register char n; - - swaps(&pCCP->majorVersion, n); - swaps(&pCCP->minorVersion, n); - swaps(&pCCP->nbytesAuthProto, n); - swaps(&pCCP->nbytesAuthString, n); + swaps(&pCCP->majorVersion); + swaps(&pCCP->minorVersion); + swaps(&pCCP->nbytesAuthProto); + swaps(&pCCP->nbytesAuthString); } diff --git a/nx-X11/programs/Xserver/dix/tables.c b/nx-X11/programs/Xserver/dix/tables.c index 5196f0e85..624522daf 100644 --- a/nx-X11/programs/Xserver/dix/tables.c +++ b/nx-X11/programs/Xserver/dix/tables.c @@ -1,4 +1,3 @@ -/* $XFree86: xc/programs/Xserver/dix/tables.c,v 3.5 2002/02/19 11:09:22 alanh Exp $ */ /*********************************************************** Copyright 1987, 1998 The Open Group @@ -45,16 +44,13 @@ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ******************************************************************/ -/* $Xorg: tables.c,v 1.4 2001/02/09 02:04:41 xorgcvs Exp $ */ #ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> #endif -#include <X11/X.h> -#define NEED_EVENTS -#define NEED_REPLIES -#include <X11/Xproto.h> +#include <nx-X11/X.h> +#include <nx-X11/Xproto.h> #include "windowstr.h" #include "extnsionst.h" #include "dixstruct.h" @@ -63,11 +59,6 @@ SOFTWARE. #include "swaprep.h" #include "swapreq.h" -#ifdef K5AUTH -extern int - k5_stage1(), k5_stage2(), k5_stage3(), k5_bad(); -#endif - int (* InitialVector[3]) ( ClientPtr /* client */ ) = @@ -517,13 +508,3 @@ ReplySwapPtr ReplySwapVector[256] = ReplyNotSwappd, /* NoOperation */ ReplyNotSwappd }; - -#ifdef K5AUTH -int (*k5_Vector[256])() = -{ - k5_bad, - k5_stage1, - k5_bad, - k5_stage3 -}; -#endif diff --git a/nx-X11/programs/Xserver/dix/window.c b/nx-X11/programs/Xserver/dix/window.c index c060f4a23..ba9cfc2d2 100644 --- a/nx-X11/programs/Xserver/dix/window.c +++ b/nx-X11/programs/Xserver/dix/window.c @@ -1,5 +1,3 @@ -/* $XdotOrg: xc/programs/Xserver/dix/window.c,v 1.12 2005/07/03 08:53:38 daniels Exp $ */ -/* $Xorg: window.c,v 1.4 2001/02/09 02:04:41 xorgcvs Exp $ */ /* Copyright 1987, 1998 The Open Group @@ -78,7 +76,6 @@ Equipment Corporation. ******************************************************************/ -/* $XFree86: xc/programs/Xserver/dix/window.c,v 3.36 2003/11/14 23:52:50 torrey Exp $ */ #ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> @@ -104,12 +101,9 @@ Equipment Corporation. #include "dixevents.h" #include "globals.h" -#ifdef XAPPGROUP -#include <X11/extensions/Xagsrv.h> -#endif #ifdef XCSECURITY #define _SECURITY_SERVER -#include <X11/extensions/security.h> +#include <nx-X11/extensions/security.h> #endif /****** @@ -163,7 +157,7 @@ static Bool TileScreenSaver(int i, int kind); int numSaveUndersViewable = 0; int deltaSaveUndersViewable = 0; -#ifdef DEBUG +#if defined(DEBUG) || (defined(NXAGENT_SERVER) && defined(WINDOW_TREE_DEBUG)) /****** * PrintWindowTree * For debugging only @@ -180,7 +174,7 @@ PrintChildren(WindowPtr p1, int indent) p2 = p1->firstChild; for (i=0; i<indent; i++) ErrorF( " "); ErrorF( "%x\n", p1->drawable.id); - miPrintRegion(&p1->clipList); + RegionPrint(&p1->clipList); PrintChildren(p2, indent+4); p1 = p1->nextSib; } @@ -194,8 +188,8 @@ PrintWindowTree() for (i=0; i<screenInfo.numScreens; i++) { ErrorF( "WINDOW %d\n", i); - pWin = WindowTable[i]; - miPrintRegion(&pWin->clipList); + pWin = screenInfo.screens[i]->root; + RegionPrint(&pWin->clipList); p1 = pWin->firstChild; PrintChildren(p1, 4); } @@ -203,7 +197,7 @@ PrintWindowTree() #endif int -TraverseTree(register WindowPtr pWin, VisitWindowProcPtr func, pointer data) +TraverseTree(register WindowPtr pWin, VisitWindowProcPtr func, void * data) { register int result; register WindowPtr pChild; @@ -238,9 +232,9 @@ TraverseTree(register WindowPtr pWin, VisitWindowProcPtr func, pointer data) *****/ int -WalkTree(ScreenPtr pScreen, VisitWindowProcPtr func, pointer data) +WalkTree(ScreenPtr pScreen, VisitWindowProcPtr func, void * data) { - return(TraverseTree(WindowTable[pScreen->myNum], func, data)); + return(TraverseTree(pScreen->root, func, data)); } /* hack for forcing backing store on all windows */ @@ -264,7 +258,7 @@ SetWindowToDefaults(register WindowPtr pWin) pWin->backingStore = NotUseful; pWin->DIXsaveUnder = FALSE; - pWin->backStorage = (pointer) NULL; + pWin->backStorage = (void *) NULL; pWin->mapped = FALSE; /* off */ pWin->realized = FALSE; /* off */ @@ -289,6 +283,7 @@ SetWindowToDefaults(register WindowPtr pWin) #endif } +#ifndef NXAGENT_SERVER static void MakeRootTile(WindowPtr pWin) { @@ -300,7 +295,7 @@ MakeRootTile(WindowPtr pWin) register int i, j; pWin->background.pixmap = (*pScreen->CreatePixmap)(pScreen, 4, 4, - pScreen->rootDepth); + pScreen->rootDepth, 0); pWin->backgroundState = BackgroundPixmap; pGC = GetScratchGC(pScreen->rootDepth, pScreen); @@ -334,6 +329,7 @@ MakeRootTile(WindowPtr pWin) FreeScratchGC(pGC); } +#endif /* NXAGENT_SERVER */ WindowPtr AllocateWindow(ScreenPtr pScreen) @@ -345,7 +341,7 @@ AllocateWindow(ScreenPtr pScreen) register unsigned size; register int i; - pWin = (WindowPtr)xalloc(pScreen->totalWindowSize); + pWin = (WindowPtr)malloc(pScreen->totalWindowSize); if (pWin) { ppriv = (DevUnion *)(pWin + 1); @@ -356,11 +352,11 @@ AllocateWindow(ScreenPtr pScreen) { if ( (size = *sizes) ) { - ppriv->ptr = (pointer)ptr; + ppriv->ptr = (void *)ptr; ptr += size; } else - ppriv->ptr = (pointer)NULL; + ppriv->ptr = (void *)NULL; } } return pWin; @@ -387,7 +383,7 @@ CreateRootWindow(ScreenPtr pScreen) savedScreenInfo[pScreen->myNum].ExternalScreenSaver = NULL; screenIsSaved = SCREEN_SAVER_OFF; - WindowTable[pScreen->myNum] = pWin; + pScreen->root = pWin; pWin->drawable.pScreen = pScreen; pWin->drawable.type = DRAWABLE_WINDOW; @@ -404,7 +400,7 @@ CreateRootWindow(ScreenPtr pScreen) pWin->parent = NullWindow; SetWindowToDefaults(pWin); - pWin->optional = (WindowOptRec *) xalloc (sizeof (WindowOptRec)); + pWin->optional = (WindowOptRec *) malloc (sizeof (WindowOptRec)); if (!pWin->optional) return FALSE; @@ -439,10 +435,10 @@ CreateRootWindow(ScreenPtr pScreen) box.y1 = 0; box.x2 = pScreen->width; box.y2 = pScreen->height; - REGION_INIT(pScreen, &pWin->clipList, &box, 1); - REGION_INIT(pScreen, &pWin->winSize, &box, 1); - REGION_INIT(pScreen, &pWin->borderSize, &box, 1); - REGION_INIT(pScreen, &pWin->borderClip, &box, 1); + RegionInit(&pWin->clipList, &box, 1); + RegionInit(&pWin->winSize, &box, 1); + RegionInit(&pWin->borderSize, &box, 1); + RegionInit(&pWin->borderClip, &box, 1); pWin->drawable.class = InputOutput; pWin->optional->visual = pScreen->rootVisual; @@ -454,7 +450,7 @@ CreateRootWindow(ScreenPtr pScreen) pWin->border.pixel = pScreen->blackPixel; pWin->borderWidth = 0; - if (!AddResource(pWin->drawable.id, RT_WINDOW, (pointer)pWin)) + if (!AddResource(pWin->drawable.id, RT_WINDOW, (void *)pWin)) return FALSE; if (disableBackingStore) @@ -480,6 +476,7 @@ CreateRootWindow(ScreenPtr pScreen) return TRUE; } +#ifndef NXAGENT_SERVER void InitRootWindow(WindowPtr pWin) { @@ -501,6 +498,7 @@ InitRootWindow(WindowPtr pWin) MapWindow(pWin, serverClient); } +#endif /* NXAGENT_SERVER */ /* Set the region to the intersection of the rectangle and the * window's winSize. The window is typically the parent of the @@ -512,10 +510,9 @@ ClippedRegionFromBox(register WindowPtr pWin, RegionPtr Rgn, register int x, register int y, register int w, register int h) { - ScreenPtr pScreen = pWin->drawable.pScreen; BoxRec box; - box = *(REGION_EXTENTS(pScreen, &pWin->winSize)); + box = *(RegionExtents(&pWin->winSize)); /* we do these calculations to avoid overflows */ if (x > box.x1) box.x1 = x; @@ -531,13 +528,25 @@ ClippedRegionFromBox(register WindowPtr pWin, RegionPtr Rgn, box.x2 = box.x1; if (box.y1 > box.y2) box.y2 = box.y1; - REGION_RESET(pScreen, Rgn, &box); - REGION_INTERSECT(pScreen, Rgn, Rgn, &pWin->winSize); + RegionReset(Rgn, &box); + RegionIntersect(Rgn, Rgn, &pWin->winSize); +} + +static RealChildHeadProc realChildHeadProc = NULL; + +void +RegisterRealChildHeadProc (RealChildHeadProc proc) +{ + realChildHeadProc = proc; } WindowPtr RealChildHead(register WindowPtr pWin) { + if (realChildHeadProc) { + return realChildHeadProc (pWin); + } + if (!pWin->parent && (screenIsSaved == SCREEN_SAVER_ON) && (HasSaverWindow (pWin->drawable.pScreen->myNum))) @@ -595,14 +604,6 @@ CreateWindow(Window wid, register WindowPtr pParent, int x, int y, unsigned w, if (!ancwopt) ancwopt = FindWindowWithOptional(pParent)->optional; if (visual == CopyFromParent) { -#ifdef XAPPGROUP - VisualID ag_visual; - - if (client->appgroup && !pParent->parent && - (ag_visual = XagRootVisual (client))) - visual = ag_visual; - else -#endif visual = ancwopt->visual; } @@ -678,7 +679,7 @@ CreateWindow(Window wid, register WindowPtr pParent, int x, int y, unsigned w, { if (!MakeWindowOptional (pWin)) { - xfree (pWin); + free (pWin); *error = BadAlloc; return NullWindow; } @@ -713,10 +714,10 @@ CreateWindow(Window wid, register WindowPtr pParent, int x, int y, unsigned w, pWin->drawable.y = pParent->drawable.y + y + (int)bw; /* set up clip list correctly for unobscured WindowPtr */ - REGION_NULL(pScreen, &pWin->clipList); - REGION_NULL(pScreen, &pWin->borderClip); - REGION_NULL(pScreen, &pWin->winSize); - REGION_NULL(pScreen, &pWin->borderSize); + RegionNull(&pWin->clipList); + RegionNull(&pWin->borderClip); + RegionNull(&pWin->winSize); + RegionNull(&pWin->borderSize); pHead = RealChildHead(pParent); if (pHead) @@ -774,6 +775,7 @@ CreateWindow(Window wid, register WindowPtr pParent, int x, int y, unsigned w, if (SubSend(pParent)) { + memset(&event, 0, sizeof(xEvent)); event.u.u.type = CreateNotify; event.u.createNotify.window = wid; event.u.createNotify.parent = pParent->drawable.id; @@ -796,17 +798,17 @@ FreeWindowResources(register WindowPtr pWin) DeleteWindowFromAnySaveSet(pWin); DeleteWindowFromAnySelections(pWin); DeleteWindowFromAnyEvents(pWin, TRUE); - REGION_UNINIT(pScreen, &pWin->clipList); - REGION_UNINIT(pScreen, &pWin->winSize); - REGION_UNINIT(pScreen, &pWin->borderClip); - REGION_UNINIT(pScreen, &pWin->borderSize); + RegionUninit(&pWin->clipList); + RegionUninit(&pWin->winSize); + RegionUninit(&pWin->borderClip); + RegionUninit(&pWin->borderSize); #ifdef SHAPE if (wBoundingShape (pWin)) - REGION_DESTROY(pScreen, wBoundingShape (pWin)); + RegionDestroy(wBoundingShape (pWin)); if (wClipShape (pWin)) - REGION_DESTROY(pScreen, wClipShape (pWin)); + RegionDestroy(wClipShape (pWin)); if (wInputShape (pWin)) - REGION_DESTROY(pScreen, wInputShape (pWin)); + RegionDestroy(wInputShape (pWin)); #endif if (pWin->borderIsPixel == FALSE) (*pScreen->DestroyPixmap)(pWin->border.pixmap); @@ -841,6 +843,7 @@ CrushTree(WindowPtr pWin) pParent = pChild->parent; if (SubStrSend(pChild, pParent)) { + memset(&event, 0, sizeof(xEvent)); event.u.u.type = DestroyNotify; event.u.destroyNotify.window = pChild->drawable.id; DeliverEvents(pChild, &event, 1, NullWindow); @@ -858,7 +861,7 @@ CrushTree(WindowPtr pWin) (*UnrealizeWindow)(pChild); } FreeWindowResources(pChild); - xfree(pChild); + free(pChild); if ( (pChild = pSib) ) break; pChild = pParent; @@ -869,15 +872,17 @@ CrushTree(WindowPtr pWin) } } } - + + /***** * DeleteWindow * Deletes child of window then window itself * If wid is None, don't send any events *****/ +#ifndef NXAGENT_SERVER int -DeleteWindow(pointer value, XID wid) +DeleteWindow(void * value, XID wid) { register WindowPtr pParent; register WindowPtr pWin = (WindowPtr)value; @@ -890,6 +895,7 @@ DeleteWindow(pointer value, XID wid) pParent = pWin->parent; if (wid && pParent && SubStrSend(pWin, pParent)) { + memset(&event, 0, sizeof(xEvent)); event.u.u.type = DestroyNotify; event.u.destroyNotify.window = pWin->drawable.id; DeliverEvents(pWin, &event, 1, NullWindow); @@ -907,9 +913,10 @@ DeleteWindow(pointer value, XID wid) if (pWin->prevSib) pWin->prevSib->nextSib = pWin->nextSib; } - xfree(pWin); + free(pWin); return Success; } +#endif /* NXAGENT_SERVER */ void DestroySubwindows(register WindowPtr pWin, ClientPtr client) @@ -1021,7 +1028,7 @@ ChangeWindowAttributes(register WindowPtr pWin, Mask vmask, XID *vlist, ClientPt else { pPixmap = (PixmapPtr)SecurityLookupIDByType(client, pixID, - RT_PIXMAP, SecurityReadAccess); + RT_PIXMAP, DixReadAccess); if (pPixmap != (PixmapPtr) NULL) { if ((pPixmap->drawable.depth != pWin->drawable.depth) || @@ -1082,7 +1089,7 @@ ChangeWindowAttributes(register WindowPtr pWin, Mask vmask, XID *vlist, ClientPt else { pPixmap = (PixmapPtr)SecurityLookupIDByType(client, pixID, - RT_PIXMAP, SecurityReadAccess); + RT_PIXMAP, DixReadAccess); if (pPixmap) { if ((pPixmap->drawable.depth != pWin->drawable.depth) || @@ -1227,6 +1234,25 @@ ChangeWindowAttributes(register WindowPtr pWin, Mask vmask, XID *vlist, ClientPt #endif /* DO_SAVE_UNDERS */ break; case CWEventMask: + + /* + * TODO: Some applications like java bean shell + * don' t work if they cannot monitor the root + * window for Structure Redirect events. However + * this doesn't seem to be the best solution, since + * also an X server with a window manager running, + * doesn't allow to monitor for those events, but + * the java bean shell works flawlessy on this + * server. + * + * #ifdef NXAGENT_SERVER + * if (nxagentCheckIllegalRootMonitoring(pWin, (Mask)*pVlist)) + * { + * return BadAccess; + * } + * #endif + */ + result = EventSelectForWindow(pWin, client, (Mask )*pVlist); if (result) { @@ -1261,22 +1287,6 @@ ChangeWindowAttributes(register WindowPtr pWin, Mask vmask, XID *vlist, ClientPt pVlist++; if (cmap == CopyFromParent) { -#ifdef XAPPGROUP - Colormap ag_colormap; - ClientPtr win_owner; - - /* - * win_owner == client for CreateWindow, other clients - * can ChangeWindowAttributes - */ - win_owner = clients[CLIENT_ID(pWin->drawable.id)]; - - if ( win_owner && win_owner->appgroup && - !pWin->parent->parent && - (ag_colormap = XagDefaultColormap (win_owner))) - cmap = ag_colormap; - else -#endif if (pWin->parent && (!pWin->optional || pWin->optional->visual == wVisual (pWin->parent))) @@ -1292,7 +1302,7 @@ ChangeWindowAttributes(register WindowPtr pWin, Mask vmask, XID *vlist, ClientPt goto PatchUp; } pCmap = (ColormapPtr)SecurityLookupIDByType(client, cmap, - RT_COLORMAP, SecurityReadAccess); + RT_COLORMAP, DixReadAccess); if (!pCmap) { error = BadColor; @@ -1360,7 +1370,7 @@ ChangeWindowAttributes(register WindowPtr pWin, Mask vmask, XID *vlist, ClientPt */ if ( cursorID == None) { - if (pWin == WindowTable[pWin->drawable.pScreen->myNum]) + if (pWin == pWin->drawable.pScreen->root) pCursor = rootCursor; else pCursor = (CursorPtr) None; @@ -1368,7 +1378,7 @@ ChangeWindowAttributes(register WindowPtr pWin, Mask vmask, XID *vlist, ClientPt else { pCursor = (CursorPtr)SecurityLookupIDByType(client, cursorID, - RT_CURSOR, SecurityReadAccess); + RT_CURSOR, DixReadAccess); if (!pCursor) { error = BadCursor; @@ -1464,10 +1474,10 @@ PatchUp: { RegionRec exposed; - REGION_NULL(pScreen, &exposed); - REGION_SUBTRACT(pScreen, &exposed, &pWin->borderClip, &pWin->winSize); + RegionNull(&exposed); + RegionSubtract(&exposed, &pWin->borderClip, &pWin->winSize); (*pWin->drawable.pScreen->PaintWindowBorder)(pWin, &exposed, PW_BORDER); - REGION_UNINIT(pScreen, &exposed); + RegionUninit(&exposed); } return error; } @@ -1608,18 +1618,16 @@ CreateUnclippedWinSize (register WindowPtr pWin) box.y1 = pWin->drawable.y; box.x2 = pWin->drawable.x + (int) pWin->drawable.width; box.y2 = pWin->drawable.y + (int) pWin->drawable.height; - pRgn = REGION_CREATE(pWin->drawable.pScreen, &box, 1); + pRgn = RegionCreate(&box, 1); #ifdef SHAPE if (wBoundingShape (pWin) || wClipShape (pWin)) { - ScreenPtr pScreen = pWin->drawable.pScreen; - - REGION_TRANSLATE(pScreen, pRgn, - pWin->drawable.x, + RegionTranslate(pRgn, - pWin->drawable.x, - pWin->drawable.y); if (wBoundingShape (pWin)) - REGION_INTERSECT(pScreen, pRgn, pRgn, wBoundingShape (pWin)); + RegionIntersect(pRgn, pRgn, wBoundingShape (pWin)); if (wClipShape (pWin)) - REGION_INTERSECT(pScreen, pRgn, pRgn, wClipShape (pWin)); - REGION_TRANSLATE(pScreen, pRgn, pWin->drawable.x, pWin->drawable.y); + RegionIntersect(pRgn, pRgn, wClipShape (pWin)); + RegionTranslate(pRgn, pWin->drawable.x, pWin->drawable.y); } #endif return pRgn; @@ -1637,7 +1645,7 @@ SetWinSize (register WindowPtr pWin) box.y1 = pWin->drawable.y; box.x2 = pWin->drawable.x + pWin->drawable.width; box.y2 = pWin->drawable.y + pWin->drawable.height; - REGION_RESET (pScreen, &pWin->winSize, &box); + RegionReset(&pWin->winSize, &box); } else #endif @@ -1647,17 +1655,15 @@ SetWinSize (register WindowPtr pWin) (int)pWin->drawable.height); #ifdef SHAPE if (wBoundingShape (pWin) || wClipShape (pWin)) { - ScreenPtr pScreen = pWin->drawable.pScreen; - - REGION_TRANSLATE(pScreen, &pWin->winSize, - pWin->drawable.x, + RegionTranslate(&pWin->winSize, - pWin->drawable.x, - pWin->drawable.y); if (wBoundingShape (pWin)) - REGION_INTERSECT(pScreen, &pWin->winSize, &pWin->winSize, + RegionIntersect(&pWin->winSize, &pWin->winSize, wBoundingShape (pWin)); if (wClipShape (pWin)) - REGION_INTERSECT(pScreen, &pWin->winSize, &pWin->winSize, + RegionIntersect(&pWin->winSize, &pWin->winSize, wClipShape (pWin)); - REGION_TRANSLATE(pScreen, &pWin->winSize, pWin->drawable.x, + RegionTranslate(&pWin->winSize, pWin->drawable.x, pWin->drawable.y); } #endif @@ -1679,7 +1685,7 @@ SetBorderSize (register WindowPtr pWin) box.y1 = pWin->drawable.y - bw; box.x2 = pWin->drawable.x + pWin->drawable.width + bw; box.y2 = pWin->drawable.y + pWin->drawable.height + bw; - REGION_RESET (pScreen, &pWin->borderSize, &box); + RegionReset(&pWin->borderSize, &box); } else #endif @@ -1689,20 +1695,18 @@ SetBorderSize (register WindowPtr pWin) (int)(pWin->drawable.height + (bw<<1))); #ifdef SHAPE if (wBoundingShape (pWin)) { - ScreenPtr pScreen = pWin->drawable.pScreen; - - REGION_TRANSLATE(pScreen, &pWin->borderSize, - pWin->drawable.x, + RegionTranslate(&pWin->borderSize, - pWin->drawable.x, - pWin->drawable.y); - REGION_INTERSECT(pScreen, &pWin->borderSize, &pWin->borderSize, + RegionIntersect(&pWin->borderSize, &pWin->borderSize, wBoundingShape (pWin)); - REGION_TRANSLATE(pScreen, &pWin->borderSize, pWin->drawable.x, + RegionTranslate(&pWin->borderSize, pWin->drawable.x, pWin->drawable.y); - REGION_UNION(pScreen, &pWin->borderSize, &pWin->borderSize, + RegionUnion(&pWin->borderSize, &pWin->borderSize, &pWin->winSize); } #endif } else { - REGION_COPY(pWin->drawable.pScreen, &pWin->borderSize, + RegionCopy(&pWin->borderSize, &pWin->winSize); } } @@ -1764,6 +1768,7 @@ GravityTranslate (register int x, register int y, int oldx, int oldy, } /* XXX need to retile border on each window with ParentRelative origin */ +#ifndef NXAGENT_SERVER void ResizeChildrenWinSize(register WindowPtr pWin, int dx, int dy, int dw, int dh) { @@ -1828,6 +1833,7 @@ ResizeChildrenWinSize(register WindowPtr pWin, int dx, int dy, int dw, int dh) } } } +#endif /* NXAGENT_SERVER */ #define GET_INT16(m, f) \ if (m & mask) \ @@ -1900,14 +1906,13 @@ MakeBoundingRegion ( BoxPtr pBox) { RegionPtr pRgn; - ScreenPtr pScreen = pWin->drawable.pScreen; - pRgn = REGION_CREATE(pScreen, pBox, 1); + pRgn = RegionCreate(pBox, 1); if (wBoundingShape (pWin)) { - REGION_TRANSLATE(pScreen, pRgn, -pWin->origin.x, + RegionTranslate(pRgn, -pWin->origin.x, -pWin->origin.y); - REGION_INTERSECT(pScreen, pRgn, pRgn, wBoundingShape (pWin)); - REGION_TRANSLATE(pScreen, pRgn, pWin->origin.x, + RegionIntersect(pRgn, pRgn, wBoundingShape (pWin)); + RegionTranslate(pRgn, pWin->origin.x, pWin->origin.y); } return pRgn; @@ -1921,18 +1926,16 @@ ShapeOverlap ( BoxPtr pSibBox) { RegionPtr pWinRgn, pSibRgn; - register ScreenPtr pScreen; Bool ret; if (!IS_SHAPED(pWin) && !IS_SHAPED(pSib)) return TRUE; - pScreen = pWin->drawable.pScreen; pWinRgn = MakeBoundingRegion (pWin, pWinBox); pSibRgn = MakeBoundingRegion (pSib, pSibBox); - REGION_INTERSECT(pScreen, pWinRgn, pWinRgn, pSibRgn); - ret = REGION_NOTEMPTY(pScreen, pWinRgn); - REGION_DESTROY(pScreen, pWinRgn); - REGION_DESTROY(pScreen, pSibRgn); + RegionIntersect(pWinRgn, pWinRgn, pSibRgn); + ret = RegionNotEmpty(pWinRgn); + RegionDestroy(pWinRgn); + RegionDestroy(pSibRgn); return ret; } #endif @@ -2027,7 +2030,6 @@ WhereDoIGoInTheStack( int smode) { BoxRec box; - register ScreenPtr pScreen; WindowPtr pHead, pFirst; if ((pWin == pWin->parent->firstChild) && @@ -2035,7 +2037,6 @@ WhereDoIGoInTheStack( return((WindowPtr ) NULL); pHead = RealChildHead(pWin->parent); pFirst = pHead ? pHead->nextSib : pWin->parent->firstChild; - pScreen = pWin->drawable.pScreen; box.x1 = x; box.y1 = y; box.x2 = x + (int)w; @@ -2063,7 +2064,7 @@ WhereDoIGoInTheStack( else if (pSib) { if ((IsSiblingAboveMe(pWin, pSib) == Above) && - (RECT_IN_REGION(pScreen, &pSib->borderSize, &box) != rgnOUT)) + (RegionContainsRect(&pSib->borderSize, &box) != rgnOUT)) return(pFirst); else return(pWin->nextSib); @@ -2078,7 +2079,7 @@ WhereDoIGoInTheStack( else if (pSib) { if ((IsSiblingAboveMe(pWin, pSib) == Below) && - (RECT_IN_REGION(pScreen, &pSib->borderSize, &box) != rgnOUT)) + (RegionContainsRect(&pSib->borderSize, &box) != rgnOUT)) return NullWindow; else return(pWin->nextSib); @@ -2092,7 +2093,7 @@ WhereDoIGoInTheStack( return(pWin->nextSib); else if (pSib) { - if (RECT_IN_REGION(pScreen, &pSib->borderSize, &box) != rgnOUT) + if (RegionContainsRect(&pSib->borderSize, &box) != rgnOUT) { if (IsSiblingAboveMe(pWin, pSib) == Above) return(pFirst); @@ -2176,6 +2177,7 @@ ReflectStackChange( * ConfigureWindow *****/ +#ifndef NXAGENT_SERVER int ConfigureWindow(register WindowPtr pWin, register Mask mask, XID *vlist, ClientPtr client) { @@ -2193,10 +2195,6 @@ ConfigureWindow(register WindowPtr pWin, register Mask mask, XID *vlist, ClientP h = pWin->drawable.height, bw = pWin->borderWidth; int action, smode = Above; -#ifdef XAPPGROUP - ClientPtr win_owner; - ClientPtr ag_leader = NULL; -#endif xEvent event; if ((pWin->drawable.class == InputOnly) && (mask & IllegalInputOnlyConfigureMask)) @@ -2254,7 +2252,7 @@ ConfigureWindow(register WindowPtr pWin, register Mask mask, XID *vlist, ClientP sibwid = (Window ) *pVlist; pVlist++; pSib = (WindowPtr )SecurityLookupIDByType(client, sibwid, - RT_WINDOW, SecurityReadAccess); + RT_WINDOW, DixReadAccess); if (!pSib) { client->errorValue = sibwid; @@ -2293,19 +2291,11 @@ ConfigureWindow(register WindowPtr pWin, register Mask mask, XID *vlist, ClientP else pSib = pWin->nextSib; -#ifdef XAPPGROUP - win_owner = clients[CLIENT_ID(pWin->drawable.id)]; - ag_leader = XagLeader (win_owner); -#endif - if ((!pWin->overrideRedirect) && (RedirectSend(pParent) -#ifdef XAPPGROUP - || (win_owner->appgroup && ag_leader && - XagIsControlledRoot (client, pParent)) -#endif )) { + memset(&event, 0, sizeof(xEvent)); event.u.u.type = ConfigureRequest; event.u.configureRequest.window = pWin->drawable.id; if (mask & CWSibling) @@ -2328,16 +2318,6 @@ ConfigureWindow(register WindowPtr pWin, register Mask mask, XID *vlist, ClientP event.u.configureRequest.height = h; event.u.configureRequest.borderWidth = bw; event.u.configureRequest.valueMask = mask; -#ifdef XAPPGROUP - /* make sure if the ag_leader maps the window it goes to the wm */ - if (ag_leader && ag_leader != client && - XagIsControlledRoot (client, pParent)) { - event.u.configureRequest.parent = XagId (win_owner); - (void) TryClientEvents (ag_leader, &event, 1, - NoEventMask, NoEventMask, NullGrab); - return Success; - } -#endif event.u.configureRequest.parent = pParent->drawable.id; if (MaybeDeliverEventsToClient(pParent, &event, 1, SubstructureRedirectMask, client) == 1) @@ -2350,6 +2330,7 @@ ConfigureWindow(register WindowPtr pWin, register Mask mask, XID *vlist, ClientP if (size_change && ((pWin->eventMask|wOtherEventMasks(pWin)) & ResizeRedirectMask)) { xEvent eventT; + memset(&eventT, 0, sizeof(xEvent)); eventT.u.u.type = ResizeRequest; eventT.u.resizeRequest.window = pWin->drawable.id; eventT.u.resizeRequest.width = w; @@ -2396,6 +2377,7 @@ ConfigureWindow(register WindowPtr pWin, register Mask mask, XID *vlist, ClientP ActuallyDoSomething: if (SubStrSend(pWin, pParent)) { + memset(&event, 0, sizeof(xEvent)); event.u.u.type = ConfigureNotify; event.u.configureNotify.window = pWin->drawable.id; if (pSib) @@ -2449,6 +2431,7 @@ ActuallyDoSomething: #undef RESIZE_WIN #undef REBORDER_WIN } +#endif /* NXAGENT_SERVER */ /****** @@ -2468,6 +2451,17 @@ CirculateWindow(WindowPtr pParent, int direction, ClientPtr client) xEvent event; BoxRec box; + /* + * #ifdef NXAGENT_SERVER + * if (nxagentOption(Rootless) && nxagentWMIsRunning && + * nxagentWindowTopLevel(pWin) && pWin -> overrideRedirect == 0) + * { + * nxagentCirculateRootlessWindows(direction); + * return Success; + * } + * #endif + */ + pHead = RealChildHead(pParent); pFirst = pHead ? pHead->nextSib : pParent->firstChild; if (direction == RaiseLowest) @@ -2519,7 +2513,7 @@ CirculateWindow(WindowPtr pParent, int direction, ClientPtr client) static int CompareWIDs( WindowPtr pWin, - pointer value) /* must conform to VisitWindowProcPtr */ + void * value) /* must conform to VisitWindowProcPtr */ { Window *wid = (Window *)value; @@ -2533,6 +2527,7 @@ CompareWIDs( * ReparentWindow *****/ +#ifndef NXAGENT_SERVER int ReparentWindow(register WindowPtr pWin, register WindowPtr pParent, int x, int y, ClientPtr client) @@ -2544,7 +2539,7 @@ ReparentWindow(register WindowPtr pWin, register WindowPtr pParent, register ScreenPtr pScreen; pScreen = pWin->drawable.pScreen; - if (TraverseTree(pWin, CompareWIDs, (pointer)&pParent->drawable.id) == WT_STOPWALKING) + if (TraverseTree(pWin, CompareWIDs, (void *)&pParent->drawable.id) == WT_STOPWALKING) return(BadMatch); if (!MakeWindowOptional(pWin)) return(BadAlloc); @@ -2552,6 +2547,7 @@ ReparentWindow(register WindowPtr pWin, register WindowPtr pParent, if (WasMapped) UnmapWindow(pWin, FALSE); + memset(&event, 0, sizeof(xEvent)); event.u.u.type = ReparentNotify; event.u.reparent.window = pWin->drawable.id; event.u.reparent.parent = pParent->drawable.id; @@ -2624,6 +2620,7 @@ ReparentWindow(register WindowPtr pWin, register WindowPtr pParent, RecalculateDeliverableEvents(pWin); return(Success); } +#endif /* NXAGENT_SERVER */ static void RealizeTree(WindowPtr pWin) @@ -2666,6 +2663,7 @@ RealizeTree(WindowPtr pWin) * MapNotify event is generated. *****/ +#ifndef NXAGENT_SERVER int MapWindow(register WindowPtr pWin, ClientPtr client) { @@ -2695,31 +2693,14 @@ MapWindow(register WindowPtr pWin, ClientPtr client) { xEvent event; Bool anyMarked; -#ifdef XAPPGROUP - ClientPtr win_owner = clients[CLIENT_ID(pWin->drawable.id)]; - ClientPtr ag_leader = XagLeader (win_owner); -#endif if ((!pWin->overrideRedirect) && (RedirectSend(pParent) -#ifdef XAPPGROUP - || (win_owner->appgroup && ag_leader && - XagIsControlledRoot (client, pParent)) -#endif )) { + memset(&event, 0, sizeof(xEvent)); event.u.u.type = MapRequest; event.u.mapRequest.window = pWin->drawable.id; -#ifdef XAPPGROUP - /* make sure if the ag_leader maps the window it goes to the wm */ - if (ag_leader && ag_leader != client && - XagIsControlledRoot (client, pParent)) { - event.u.mapRequest.parent = XagId (win_owner); - (void) TryClientEvents (ag_leader, &event, 1, - NoEventMask, NoEventMask, NullGrab); - return Success; - } -#endif event.u.mapRequest.parent = pParent->drawable.id; if (MaybeDeliverEventsToClient(pParent, &event, 1, @@ -2730,6 +2711,7 @@ MapWindow(register WindowPtr pWin, ClientPtr client) pWin->mapped = TRUE; if (SubStrSend(pWin, pParent)) { + memset(&event, 0, sizeof(xEvent)); event.u.u.type = MapNotify; event.u.mapNotify.window = pWin->drawable.id; event.u.mapNotify.override = pWin->overrideRedirect; @@ -2776,15 +2758,15 @@ MapWindow(register WindowPtr pWin, ClientPtr client) (*pScreen->ClipNotify) (pWin, 0, 0); if (pScreen->PostValidateTree) (*pScreen->PostValidateTree)(NullWindow, pWin, VTMap); - REGION_NULL(pScreen, &temp); - REGION_COPY(pScreen, &temp, &pWin->clipList); + RegionNull(&temp); + RegionCopy(&temp, &pWin->clipList); (*pScreen->WindowExposures) (pWin, &temp, NullRegion); - REGION_UNINIT(pScreen, &temp); + RegionUninit(&temp); } return(Success); } - +#endif /* NXAGENT_SERVER */ /***** * MapSubwindows @@ -2820,6 +2802,7 @@ MapSubwindows(register WindowPtr pParent, ClientPtr client) { if (parentRedirect && !pWin->overrideRedirect) { + memset(&event, 0, sizeof(xEvent)); event.u.u.type = MapRequest; event.u.mapRequest.window = pWin->drawable.id; event.u.mapRequest.parent = pParent->drawable.id; @@ -2832,6 +2815,7 @@ MapSubwindows(register WindowPtr pParent, ClientPtr client) pWin->mapped = TRUE; if (parentNotify || StrSend(pWin)) { + memset(&event, 0, sizeof(xEvent)); event.u.u.type = MapNotify; event.u.mapNotify.window = pWin->drawable.id; event.u.mapNotify.override = pWin->overrideRedirect; @@ -2971,6 +2955,7 @@ UnrealizeTree( * generated. Cannot unmap a root window. *****/ +#ifndef NXAGENT_SERVER int UnmapWindow(register WindowPtr pWin, Bool fromConfigure) { @@ -2985,6 +2970,7 @@ UnmapWindow(register WindowPtr pWin, Bool fromConfigure) return(Success); if (SubStrSend(pWin, pParent)) { + memset(&event, 0, sizeof(xEvent)); event.u.u.type = UnmapNotify; event.u.unmapNotify.window = pWin->drawable.id; event.u.unmapNotify.fromConfigure = fromConfigure; @@ -3023,6 +3009,7 @@ UnmapWindow(register WindowPtr pWin, Bool fromConfigure) WindowsRestructured (); return(Success); } +#endif /* NXAGENT_SERVER */ /***** * UnmapSubwindows @@ -3132,7 +3119,7 @@ HandleSaveSet(register ClientPtr client) pWin = SaveSetWindow(client->saveSet[j]); #ifdef XFIXES if (SaveSetToRoot(client->saveSet[j])) - pParent = WindowTable[pWin->drawable.pScreen->myNum]; + pParent = pWin->drawable.pScreen->root; else #endif { @@ -3157,7 +3144,7 @@ HandleSaveSet(register ClientPtr client) MapWindow(pWin, client); } } - xfree(client->saveSet); + free(client->saveSet); client->numSaved = 0; client->saveSet = (SaveSetElt *)NULL; } @@ -3172,7 +3159,7 @@ VisibleBoundingBoxFromPoint(register WindowPtr pWin, int x, int y, BoxPtr box) { if (!pWin->realized) return (FALSE); - if (POINT_IN_REGION(pWin->drawable.pScreen, &pWin->clipList, x, y, box)) + if (RegionContainsPoint(&pWin->clipList, x, y, box)) return(TRUE); return(FALSE); } @@ -3188,10 +3175,10 @@ PointInWindowIsVisible(register WindowPtr pWin, int x, int y) if (!pWin->realized) return (FALSE); - if (POINT_IN_REGION(pWin->drawable.pScreen, &pWin->borderClip, + if (RegionContainsPoint(&pWin->borderClip, x, y, &box) && (!wInputShape(pWin) || - POINT_IN_REGION(pWin->drawable.pScreen, + RegionContainsPoint( wInputShape(pWin), x - pWin->drawable.x, y - pWin->drawable.y, &box))) @@ -3203,16 +3190,14 @@ PointInWindowIsVisible(register WindowPtr pWin, int x, int y) RegionPtr NotClippedByChildren(register WindowPtr pWin) { - register ScreenPtr pScreen; RegionPtr pReg; - pScreen = pWin->drawable.pScreen; - pReg = REGION_CREATE(pScreen, NullBox, 1); + pReg = RegionCreate(NullBox, 1); if (pWin->parent || screenIsSaved != SCREEN_SAVER_ON || !HasSaverWindow (pWin->drawable.pScreen->myNum)) { - REGION_INTERSECT(pScreen, pReg, &pWin->borderClip, &pWin->winSize); + RegionIntersect(pReg, &pWin->borderClip, &pWin->winSize); } return(pReg); } @@ -3279,6 +3264,7 @@ SendVisibilityNotify(WindowPtr pWin) } #endif + memset(&event, 0, sizeof(xEvent)); event.u.u.type = VisibilityNotify; event.u.visibility.window = pWin->drawable.id; event.u.visibility.state = visibility; @@ -3294,6 +3280,7 @@ static void DrawLogo( ); #endif +#ifndef NXAGENT_SERVER void SaveScreens(int on, int mode) { @@ -3406,6 +3393,7 @@ SaveScreens(int on, int mode) if (mode == ScreenSaverReset) SetScreenSaverTimer(); } +#endif /* NXAGENT_SERVER */ static Bool TileScreenSaver(int i, int kind) @@ -3425,9 +3413,9 @@ TileScreenSaver(int i, int kind) attri = 0; switch (kind) { case SCREEN_IS_TILED: - switch (WindowTable[i]->backgroundState) { + switch (screenInfo.screens[i]->root->backgroundState) { case BackgroundPixel: - attributes[attri++] = WindowTable[i]->background.pixel; + attributes[attri++] = screenInfo.screens[i]->root->background.pixel; mask |= CWBackPixel; break; case BackgroundPixmap: @@ -3439,7 +3427,7 @@ TileScreenSaver(int i, int kind) } break; case SCREEN_IS_BLACK: - attributes[attri++] = WindowTable[i]->drawable.pScreen->blackPixel; + attributes[attri++] = screenInfo.screens[i]->root->drawable.pScreen->blackPixel; mask |= CWBackPixel; break; } @@ -3454,12 +3442,12 @@ TileScreenSaver(int i, int kind) cm.height=16; cm.xhot=8; cm.yhot=8; - srcbits = (unsigned char *)xalloc( BitmapBytePad(32)*16); - mskbits = (unsigned char *)xalloc( BitmapBytePad(32)*16); + srcbits = (unsigned char *)malloc( BitmapBytePad(32)*16); + mskbits = (unsigned char *)malloc( BitmapBytePad(32)*16); if (!srcbits || !mskbits) { - xfree(srcbits); - xfree(mskbits); + free(srcbits); + free(mskbits); cursor = 0; } else @@ -3470,7 +3458,7 @@ TileScreenSaver(int i, int kind) if (cursor) { cursorID = FakeClientID(0); - if (AddResource (cursorID, RT_CURSOR, (pointer) cursor)) + if (AddResource (cursorID, RT_CURSOR, (void *) cursor)) { attributes[attri] = cursorID; mask |= CWCursor; @@ -3480,19 +3468,19 @@ TileScreenSaver(int i, int kind) } else { - xfree (srcbits); - xfree (mskbits); + free (srcbits); + free (mskbits); } } pWin = savedScreenInfo[i].pWindow = CreateWindow(savedScreenInfo[i].wid, - WindowTable[i], + screenInfo.screens[i]->root, -RANDOM_WIDTH, -RANDOM_WIDTH, (unsigned short)screenInfo.screens[i]->width + RANDOM_WIDTH, (unsigned short)screenInfo.screens[i]->height + RANDOM_WIDTH, 0, InputOutput, mask, attributes, 0, serverClient, - wVisual (WindowTable[i]), &result); + wVisual (screenInfo.screens[i]->root), &result); if (cursor) FreeResource (cursorID, RT_NONE); @@ -3501,7 +3489,7 @@ TileScreenSaver(int i, int kind) return FALSE; if (!AddResource(pWin->drawable.id, RT_WINDOW, - (pointer)savedScreenInfo[i].pWindow)) + (void *)savedScreenInfo[i].pWindow)) return FALSE; if (mask & CWBackPixmap) @@ -3604,7 +3592,7 @@ MakeWindowOptional (register WindowPtr pWin) if (pWin->optional) return TRUE; - optional = (WindowOptPtr) xalloc (sizeof (WindowOptRec)); + optional = (WindowOptPtr) malloc (sizeof (WindowOptRec)); if (!optional) return FALSE; optional->dontPropagateMask = DontPropagateMasks[pWin->dontPropagate]; @@ -3669,7 +3657,7 @@ DisposeWindowOptional (register WindowPtr pWin) } else pWin->cursorIsNone = TRUE; - xfree (pWin->optional); + free (pWin->optional); pWin->optional = NULL; } diff --git a/nx-X11/programs/Xserver/dix/xpstubs.c b/nx-X11/programs/Xserver/dix/xpstubs.c index 5135cc398..ade0847d3 100644 --- a/nx-X11/programs/Xserver/dix/xpstubs.c +++ b/nx-X11/programs/Xserver/dix/xpstubs.c @@ -1,4 +1,3 @@ -/* $XFree86$ */ /* Copyright 1996, 1998 The Open Group @@ -25,7 +24,6 @@ other dealings in this Software without prior written authorization from The Open Group. */ -/* $Xorg: xpstubs.c,v 1.5 2001/03/08 17:52:08 pookie Exp $ */ #ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> @@ -33,9 +31,6 @@ from The Open Group. #include "misc.h" #include <X11/fonts/font.h> -#ifdef XPRINT -#include "DiPrint.h" -#endif Bool XpClientIsBitmapClient( @@ -51,27 +46,3 @@ XpClientIsPrintClient( { return FALSE; } -#ifdef XPRINT -int -PrinterOptions( - int argc, - char **argv, - int i) -{ - return i; -} -void -PrinterInitOutput( - ScreenInfo *pScreenInfo, - int argc, - char **argv) -{ -} -void PrinterUseMsg(void) -{ -} -void PrinterInitGlobals(void) -{ -} -#endif /* XPRINT */ - |
