New upstream version 3.5.99.27
This commit is contained in:
138
nx-X11/programs/Xserver/dix/Imakefile
Normal file
138
nx-X11/programs/Xserver/dix/Imakefile
Normal file
@@ -0,0 +1,138 @@
|
||||
NULL =
|
||||
|
||||
#include <Server.tmpl>
|
||||
|
||||
#if !HasFfs
|
||||
FFS_SRC = ffs.c
|
||||
FFS_OBJ = ffs.o
|
||||
#endif
|
||||
|
||||
#if (!(defined(NXAgentServer) && NXAgentServer))
|
||||
NXAGENT_SKIP_SRCS = \
|
||||
dispatch.c \
|
||||
dixfonts.c \
|
||||
events.c \
|
||||
glyphcurs.c \
|
||||
property.c \
|
||||
resource.c \
|
||||
window.c \
|
||||
$(NULL)
|
||||
NXAGENT_SKIP_OBJS = \
|
||||
dispatch.o \
|
||||
dixfonts.o \
|
||||
events.o \
|
||||
glyphcurs.o \
|
||||
property.o \
|
||||
resource.o \
|
||||
window.o \
|
||||
$(NULL)
|
||||
#endif
|
||||
|
||||
|
||||
SRCS = \
|
||||
atom.c \
|
||||
colormap.c \
|
||||
cursor.c \
|
||||
devices.c \
|
||||
dixutils.c \
|
||||
extension.c \
|
||||
ffs.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 \
|
||||
extension.o \
|
||||
ffs.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
|
||||
|
||||
/*
|
||||
* The following configuration parameters may be set in the appropriate
|
||||
* .macros files or site.def in the directory util/imake.includes/:
|
||||
*
|
||||
* DefaultFontPath COMPILEDDEFAULTFONTPATH
|
||||
*
|
||||
* 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
|
||||
* changed.
|
||||
*/
|
||||
|
||||
#ifdef DefaultFontPath
|
||||
DEFAULTFONTPATH = DefaultFontPath
|
||||
SITE_FONT_PATH = -DCOMPILEDDEFAULTFONTPATH=\"$(DEFAULTFONTPATH)\"
|
||||
#endif
|
||||
|
||||
#ifdef DefaultDisplayClass
|
||||
DEFAULTDISPLAYCLASS = DefaultDisplayClass
|
||||
SITE_DISPLAY_CLASS = -DCOMPILEDDISPLAYCLASS=\"$(DEFAULTDISPLAYCLASS)\"
|
||||
#endif
|
||||
|
||||
#ifdef XVendorString
|
||||
VENDORSTRING = XVendorString
|
||||
VENDOR_STRING = -DVENDOR_STRING=\"$(VENDORSTRING)\"
|
||||
#endif
|
||||
|
||||
#ifdef XVendorRelease
|
||||
VENDORRELEASE = XVendorRelease
|
||||
VENDOR_RELEASE = -DVENDOR_RELEASE="$(VENDORRELEASE)"
|
||||
#endif
|
||||
|
||||
#ifdef DarwinArchitecture
|
||||
#if DarwinQuartzSupport
|
||||
QUARTZ_DEFINES = -DDARWIN_WITH_QUARTZ
|
||||
#endif
|
||||
#endif
|
||||
|
||||
SITE_DEFINES = $(SITE_FONT_PATH) $(SITE_DISPLAY_CLASS)
|
||||
|
||||
VENDOR_DEFINES = $(VENDOR_STRING) $(VENDOR_RELEASE) $(QUARTZ_DEFINES)
|
||||
|
||||
NormalLibraryObjectRule()
|
||||
NormalLibraryTarget(dix,$(OBJS))
|
||||
|
||||
SpecialCObjectRule(globals,$(ICONFIGFILES),$(SITE_DEFINES) $(EXT_DEFINES))
|
||||
SpecialCObjectRule(main,$(ICONFIGFILES),$(VENDOR_DEFINES))
|
||||
SpecialCObjectRule(pixmap,$(ICONFIGFILES),$(_NOOP_))
|
||||
SpecialCObjectRule(privates,$(ICONFIGFILES),$(_NOOP_))
|
||||
SpecialCObjectRule(window,$(ICONFIGFILES),$(QUARTZ_DEFINES))
|
||||
|
||||
DependTarget()
|
||||
212
nx-X11/programs/Xserver/dix/atom.c
Normal file
212
nx-X11/programs/Xserver/dix/atom.c
Normal file
@@ -0,0 +1,212 @@
|
||||
/***********************************************************
|
||||
|
||||
Copyright 1987, 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 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.
|
||||
|
||||
******************************************************************/
|
||||
|
||||
|
||||
#ifdef HAVE_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#include <nx-X11/X.h>
|
||||
#include <nx-X11/Xatom.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "misc.h"
|
||||
#include "resource.h"
|
||||
#include "dix.h"
|
||||
|
||||
#define InitialTableSize 100
|
||||
|
||||
typedef struct _Node {
|
||||
struct _Node *left, *right;
|
||||
Atom a;
|
||||
unsigned int fingerPrint;
|
||||
const char *string;
|
||||
} NodeRec, *NodePtr;
|
||||
|
||||
static Atom lastAtom = None;
|
||||
static NodePtr atomRoot = (NodePtr)NULL;
|
||||
static unsigned long tableLength;
|
||||
static NodePtr *nodeTable;
|
||||
|
||||
void FreeAtom(NodePtr patom);
|
||||
|
||||
Atom
|
||||
MakeAtom(const char *string, unsigned len, Bool makeit)
|
||||
{
|
||||
register NodePtr * np;
|
||||
unsigned i;
|
||||
int comp;
|
||||
register unsigned int fp = 0;
|
||||
|
||||
np = &atomRoot;
|
||||
for (i = 0; i < (len+1)/2; i++)
|
||||
{
|
||||
fp = fp * 27 + string[i];
|
||||
fp = fp * 27 + string[len - 1 - i];
|
||||
}
|
||||
while (*np != (NodePtr) NULL)
|
||||
{
|
||||
if (fp < (*np)->fingerPrint)
|
||||
np = &((*np)->left);
|
||||
else if (fp > (*np)->fingerPrint)
|
||||
np = &((*np)->right);
|
||||
else
|
||||
{ /* now start testing the strings */
|
||||
comp = strncmp(string, (*np)->string, (int)len);
|
||||
if ((comp < 0) || ((comp == 0) && (len < strlen((*np)->string))))
|
||||
np = &((*np)->left);
|
||||
else if (comp > 0)
|
||||
np = &((*np)->right);
|
||||
else
|
||||
return(*np)->a;
|
||||
}
|
||||
}
|
||||
if (makeit)
|
||||
{
|
||||
register NodePtr nd;
|
||||
|
||||
nd = (NodePtr) malloc(sizeof(NodeRec));
|
||||
if (!nd)
|
||||
return BAD_RESOURCE;
|
||||
if (lastAtom < XA_LAST_PREDEFINED)
|
||||
{
|
||||
nd->string = string;
|
||||
}
|
||||
else
|
||||
{
|
||||
nd->string = strndup(string, len);
|
||||
if (!nd->string) {
|
||||
free(nd);
|
||||
return BAD_RESOURCE;
|
||||
}
|
||||
}
|
||||
if ((lastAtom + 1) >= tableLength) {
|
||||
NodePtr *table;
|
||||
|
||||
table = (NodePtr *) realloc(nodeTable,
|
||||
tableLength * (2 * sizeof(NodePtr)));
|
||||
if (!table) {
|
||||
if (nd->string != string)
|
||||
/* nd->string has been strdup'ed */
|
||||
free((char *)nd->string);
|
||||
free(nd);
|
||||
return BAD_RESOURCE;
|
||||
}
|
||||
tableLength <<= 1;
|
||||
nodeTable = table;
|
||||
}
|
||||
*np = nd;
|
||||
nd->left = nd->right = (NodePtr) NULL;
|
||||
nd->fingerPrint = fp;
|
||||
nd->a = (++lastAtom);
|
||||
*(nodeTable+lastAtom) = nd;
|
||||
return nd->a;
|
||||
}
|
||||
else
|
||||
return None;
|
||||
}
|
||||
|
||||
Bool
|
||||
ValidAtom(Atom atom)
|
||||
{
|
||||
return (atom != None) && (atom <= lastAtom);
|
||||
}
|
||||
|
||||
const char *
|
||||
NameForAtom(Atom atom)
|
||||
{
|
||||
NodePtr node;
|
||||
if (atom > lastAtom) return 0;
|
||||
if ((node = nodeTable[atom]) == (NodePtr)NULL) return 0;
|
||||
return node->string;
|
||||
}
|
||||
|
||||
void
|
||||
AtomError()
|
||||
{
|
||||
FatalError("initializing atoms");
|
||||
}
|
||||
|
||||
void
|
||||
FreeAtom(NodePtr patom)
|
||||
{
|
||||
if(patom->left)
|
||||
FreeAtom(patom->left);
|
||||
if(patom->right)
|
||||
FreeAtom(patom->right);
|
||||
if (patom->a > XA_LAST_PREDEFINED)
|
||||
free((char *)patom->string);
|
||||
free(patom);
|
||||
}
|
||||
|
||||
void
|
||||
FreeAllAtoms()
|
||||
{
|
||||
if(atomRoot == (NodePtr)NULL)
|
||||
return;
|
||||
FreeAtom(atomRoot);
|
||||
atomRoot = (NodePtr)NULL;
|
||||
free(nodeTable);
|
||||
nodeTable = (NodePtr *)NULL;
|
||||
lastAtom = None;
|
||||
}
|
||||
|
||||
void
|
||||
InitAtoms()
|
||||
{
|
||||
FreeAllAtoms();
|
||||
tableLength = InitialTableSize;
|
||||
nodeTable = (NodePtr *)malloc(InitialTableSize*sizeof(NodePtr));
|
||||
if (!nodeTable)
|
||||
AtomError();
|
||||
nodeTable[None] = (NodePtr)NULL;
|
||||
MakePredeclaredAtoms();
|
||||
if (lastAtom != XA_LAST_PREDEFINED)
|
||||
AtomError ();
|
||||
}
|
||||
|
||||
|
||||
43
nx-X11/programs/Xserver/dix/buildatoms
Normal file
43
nx-X11/programs/Xserver/dix/buildatoms
Normal file
@@ -0,0 +1,43 @@
|
||||
#!/bin/sh
|
||||
hfile=../../../include/Xatom.h
|
||||
cfile=initatoms.c
|
||||
rm -f $hfile $cfile
|
||||
umask 222
|
||||
awk '
|
||||
BEGIN {
|
||||
hfile = "'$hfile'";
|
||||
cfile = "'$cfile'";
|
||||
hformat = "#define XA_%s ((Atom) %d)\n";
|
||||
printf("#ifndef XATOM_H\n") > hfile;
|
||||
printf("#define XATOM_H 1\n\n") > hfile;
|
||||
printf("/* THIS IS A GENERATED FILE\n") > hfile;
|
||||
printf(" *\n") > hfile;
|
||||
printf(" * Do not change! Changing this file implies a protocol change!\n") > hfile;
|
||||
printf(" */\n\n") > hfile;
|
||||
|
||||
printf("/* THIS IS A GENERATED FILE\n") > cfile;
|
||||
printf(" *\n") > cfile;
|
||||
printf(" * Do not change! Changing this file implies a protocol change!\n") > cfile;
|
||||
printf(" */\n\n") > cfile;
|
||||
printf("#include \"X.h\"\n") > cfile;
|
||||
printf("#include \"Xatom.h\"\n") > cfile;
|
||||
printf("#include \"misc.h\"\n") > cfile;
|
||||
printf("#include \"dix.h\"\n") > cfile;
|
||||
printf("void MakePredeclaredAtoms()\n") > cfile;
|
||||
printf("{\n") > cfile;
|
||||
|
||||
}
|
||||
|
||||
NF == 2 && $2 == "@" {
|
||||
printf(hformat, $1, ++atomno) > hfile ;
|
||||
printf(" if (MakeAtom(\"%s\", %d, 1) != XA_%s) AtomError();\n", $1, length($1), $1) > cfile ;
|
||||
}
|
||||
|
||||
END {
|
||||
printf("\n") > hfile;
|
||||
printf(hformat, "LAST_PREDEFINED", atomno) > hfile ;
|
||||
printf("#endif /* XATOM_H */\n") > hfile;
|
||||
printf("}\n") > cfile ;
|
||||
}
|
||||
' BuiltInAtoms
|
||||
exit 0
|
||||
2765
nx-X11/programs/Xserver/dix/colormap.c
Normal file
2765
nx-X11/programs/Xserver/dix/colormap.c
Normal file
File diff suppressed because it is too large
Load Diff
458
nx-X11/programs/Xserver/dix/cursor.c
Normal file
458
nx-X11/programs/Xserver/dix/cursor.c
Normal file
@@ -0,0 +1,458 @@
|
||||
/***********************************************************
|
||||
|
||||
Copyright 1987, 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 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.
|
||||
|
||||
******************************************************************/
|
||||
|
||||
|
||||
|
||||
#ifdef HAVE_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#include <nx-X11/X.h>
|
||||
#include <nx-X11/Xmd.h>
|
||||
#include "servermd.h"
|
||||
#include "scrnintstr.h"
|
||||
#include "dixstruct.h"
|
||||
#include "cursorstr.h"
|
||||
#include "dixfontstr.h"
|
||||
#include "opaque.h"
|
||||
|
||||
typedef struct _GlyphShare {
|
||||
FontPtr font;
|
||||
unsigned short sourceChar;
|
||||
unsigned short maskChar;
|
||||
CursorBitsPtr bits;
|
||||
struct _GlyphShare *next;
|
||||
} GlyphShare, *GlyphSharePtr;
|
||||
|
||||
static GlyphSharePtr sharedGlyphs = (GlyphSharePtr)NULL;
|
||||
|
||||
#ifdef XFIXES
|
||||
static CARD32 cursorSerial;
|
||||
#endif
|
||||
|
||||
static void
|
||||
FreeCursorBits(CursorBitsPtr bits)
|
||||
{
|
||||
if (--bits->refcnt > 0)
|
||||
return;
|
||||
free(bits->source);
|
||||
free(bits->mask);
|
||||
#ifdef ARGB_CURSOR
|
||||
free(bits->argb);
|
||||
#endif
|
||||
if (bits->refcnt == 0)
|
||||
{
|
||||
register GlyphSharePtr *prev, this;
|
||||
|
||||
for (prev = &sharedGlyphs;
|
||||
(this = *prev) && (this->bits != bits);
|
||||
prev = &this->next)
|
||||
;
|
||||
if (this)
|
||||
{
|
||||
*prev = this->next;
|
||||
CloseFont(this->font, (Font)0);
|
||||
free(this);
|
||||
}
|
||||
free(bits);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* To be called indirectly by DeleteResource; must use exactly two args.
|
||||
*
|
||||
* \param value must conform to DeleteType
|
||||
*/
|
||||
int
|
||||
FreeCursor(void * value, XID cid)
|
||||
{
|
||||
int nscr;
|
||||
CursorPtr pCurs = (CursorPtr)value;
|
||||
|
||||
ScreenPtr pscr;
|
||||
|
||||
if ( --pCurs->refcnt > 0)
|
||||
return(Success);
|
||||
|
||||
for (nscr = 0; nscr < screenInfo.numScreens; nscr++)
|
||||
{
|
||||
pscr = screenInfo.screens[nscr];
|
||||
(void)( *pscr->UnrealizeCursor)( pscr, pCurs);
|
||||
}
|
||||
FreeCursorBits(pCurs->bits);
|
||||
free( pCurs);
|
||||
return(Success);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* We check for empty cursors so that we won't have to display them
|
||||
*/
|
||||
static void
|
||||
CheckForEmptyMask(CursorBitsPtr bits)
|
||||
{
|
||||
register unsigned char *msk = bits->mask;
|
||||
int n = BitmapBytePad(bits->width) * bits->height;
|
||||
|
||||
bits->emptyMask = FALSE;
|
||||
while(n--)
|
||||
if(*(msk++) != 0) return;
|
||||
#ifdef ARGB_CURSOR
|
||||
if (bits->argb)
|
||||
{
|
||||
CARD32 *argb = bits->argb;
|
||||
n = bits->width * bits->height;
|
||||
while (n--)
|
||||
if (*argb++ & 0xff000000) return;
|
||||
}
|
||||
#endif
|
||||
bits->emptyMask = TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* does nothing about the resource table, just creates the data structure.
|
||||
* does not copy the src and mask bits
|
||||
*
|
||||
* \param psrcbits server-defined padding
|
||||
* \param pmaskbits server-defined padding
|
||||
* \param argb no padding
|
||||
*/
|
||||
CursorPtr
|
||||
AllocCursorARGB(unsigned char *psrcbits, unsigned char *pmaskbits, CARD32 *argb,
|
||||
CursorMetricPtr cm,
|
||||
unsigned foreRed, unsigned foreGreen, unsigned foreBlue,
|
||||
unsigned backRed, unsigned backGreen, unsigned backBlue)
|
||||
{
|
||||
CursorBitsPtr bits;
|
||||
CursorPtr pCurs;
|
||||
int nscr;
|
||||
ScreenPtr pscr;
|
||||
|
||||
pCurs = (CursorPtr)malloc(sizeof(CursorRec) + sizeof(CursorBits));
|
||||
if (!pCurs)
|
||||
{
|
||||
free(psrcbits);
|
||||
free(pmaskbits);
|
||||
return (CursorPtr)NULL;
|
||||
}
|
||||
bits = (CursorBitsPtr)((char *)pCurs + sizeof(CursorRec));
|
||||
bits->source = psrcbits;
|
||||
bits->mask = pmaskbits;
|
||||
#ifdef ARGB_CURSOR
|
||||
bits->argb = argb;
|
||||
#endif
|
||||
bits->width = cm->width;
|
||||
bits->height = cm->height;
|
||||
bits->xhot = cm->xhot;
|
||||
bits->yhot = cm->yhot;
|
||||
bits->refcnt = -1;
|
||||
CheckForEmptyMask(bits);
|
||||
|
||||
pCurs->bits = bits;
|
||||
pCurs->refcnt = 1;
|
||||
#ifdef XFIXES
|
||||
pCurs->serialNumber = ++cursorSerial;
|
||||
pCurs->name = None;
|
||||
#endif
|
||||
|
||||
pCurs->foreRed = foreRed;
|
||||
pCurs->foreGreen = foreGreen;
|
||||
pCurs->foreBlue = foreBlue;
|
||||
|
||||
pCurs->backRed = backRed;
|
||||
pCurs->backGreen = backGreen;
|
||||
pCurs->backBlue = backBlue;
|
||||
|
||||
/*
|
||||
* realize the cursor for every screen
|
||||
*/
|
||||
for (nscr = 0; nscr < screenInfo.numScreens; nscr++)
|
||||
{
|
||||
pscr = screenInfo.screens[nscr];
|
||||
if (!( *pscr->RealizeCursor)( pscr, pCurs))
|
||||
{
|
||||
while (--nscr >= 0)
|
||||
{
|
||||
pscr = screenInfo.screens[nscr];
|
||||
( *pscr->UnrealizeCursor)( pscr, pCurs);
|
||||
}
|
||||
FreeCursorBits(bits);
|
||||
free(pCurs);
|
||||
return (CursorPtr)NULL;
|
||||
}
|
||||
}
|
||||
return pCurs;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* \param psrcbits server-defined padding
|
||||
* \param pmaskbits server-defined padding
|
||||
*/
|
||||
CursorPtr
|
||||
AllocCursor(unsigned char *psrcbits, unsigned char *pmaskbits,
|
||||
CursorMetricPtr cm,
|
||||
unsigned foreRed, unsigned foreGreen, unsigned foreBlue,
|
||||
unsigned backRed, unsigned backGreen, unsigned backBlue)
|
||||
{
|
||||
return AllocCursorARGB (psrcbits, pmaskbits, (CARD32 *) 0, cm,
|
||||
foreRed, foreGreen, foreBlue,
|
||||
backRed, backGreen, backBlue);
|
||||
}
|
||||
|
||||
int
|
||||
AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar,
|
||||
unsigned foreRed, unsigned foreGreen, unsigned foreBlue,
|
||||
unsigned backRed, unsigned backGreen, unsigned backBlue,
|
||||
CursorPtr *ppCurs, ClientPtr client)
|
||||
{
|
||||
FontPtr sourcefont, maskfont;
|
||||
unsigned char *srcbits;
|
||||
unsigned char *mskbits;
|
||||
CursorMetricRec cm;
|
||||
int res;
|
||||
CursorBitsPtr bits;
|
||||
CursorPtr pCurs;
|
||||
int nscr;
|
||||
ScreenPtr pscr;
|
||||
GlyphSharePtr pShare;
|
||||
|
||||
sourcefont = (FontPtr) SecurityLookupIDByType(client, source, RT_FONT,
|
||||
DixReadAccess);
|
||||
maskfont = (FontPtr) SecurityLookupIDByType(client, mask, RT_FONT,
|
||||
DixReadAccess);
|
||||
|
||||
if (!sourcefont)
|
||||
{
|
||||
client->errorValue = source;
|
||||
return(BadFont);
|
||||
}
|
||||
if (!maskfont && (mask != None))
|
||||
{
|
||||
client->errorValue = mask;
|
||||
return(BadFont);
|
||||
}
|
||||
if (sourcefont != maskfont)
|
||||
pShare = (GlyphSharePtr)NULL;
|
||||
else
|
||||
{
|
||||
for (pShare = sharedGlyphs;
|
||||
pShare &&
|
||||
((pShare->font != sourcefont) ||
|
||||
(pShare->sourceChar != sourceChar) ||
|
||||
(pShare->maskChar != maskChar));
|
||||
pShare = pShare->next)
|
||||
;
|
||||
}
|
||||
if (pShare)
|
||||
{
|
||||
pCurs = (CursorPtr)malloc(sizeof(CursorRec));
|
||||
if (!pCurs)
|
||||
return BadAlloc;
|
||||
bits = pShare->bits;
|
||||
bits->refcnt++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!CursorMetricsFromGlyph(sourcefont, sourceChar, &cm))
|
||||
{
|
||||
client->errorValue = sourceChar;
|
||||
return BadValue;
|
||||
}
|
||||
if (!maskfont)
|
||||
{
|
||||
register long n;
|
||||
register unsigned char *mskptr;
|
||||
|
||||
n = BitmapBytePad(cm.width)*(long)cm.height;
|
||||
mskptr = mskbits = (unsigned char *)malloc(n);
|
||||
if (!mskptr)
|
||||
return BadAlloc;
|
||||
while (--n >= 0)
|
||||
*mskptr++ = ~0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!CursorMetricsFromGlyph(maskfont, maskChar, &cm))
|
||||
{
|
||||
client->errorValue = maskChar;
|
||||
return BadValue;
|
||||
}
|
||||
if ((res = ServerBitsFromGlyph(maskfont, maskChar, &cm, &mskbits)) != 0)
|
||||
return res;
|
||||
}
|
||||
if ((res = ServerBitsFromGlyph(sourcefont, sourceChar, &cm, &srcbits)) != 0)
|
||||
{
|
||||
free(mskbits);
|
||||
return res;
|
||||
}
|
||||
if (sourcefont != maskfont)
|
||||
{
|
||||
pCurs = (CursorPtr)malloc(sizeof(CursorRec) + sizeof(CursorBits));
|
||||
if (pCurs)
|
||||
bits = (CursorBitsPtr)((char *)pCurs + sizeof(CursorRec));
|
||||
else
|
||||
bits = (CursorBitsPtr)NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
pCurs = (CursorPtr)malloc(sizeof(CursorRec));
|
||||
if (pCurs)
|
||||
bits = (CursorBitsPtr)malloc(sizeof(CursorBits));
|
||||
else
|
||||
bits = (CursorBitsPtr)NULL;
|
||||
}
|
||||
if (!bits)
|
||||
{
|
||||
free(pCurs);
|
||||
free(mskbits);
|
||||
free(srcbits);
|
||||
return BadAlloc;
|
||||
}
|
||||
bits->source = srcbits;
|
||||
bits->mask = mskbits;
|
||||
#ifdef ARGB_CURSOR
|
||||
bits->argb = 0;
|
||||
#endif
|
||||
bits->width = cm.width;
|
||||
bits->height = cm.height;
|
||||
bits->xhot = cm.xhot;
|
||||
bits->yhot = cm.yhot;
|
||||
if (sourcefont != maskfont)
|
||||
bits->refcnt = -1;
|
||||
else
|
||||
{
|
||||
bits->refcnt = 1;
|
||||
pShare = (GlyphSharePtr)malloc(sizeof(GlyphShare));
|
||||
if (!pShare)
|
||||
{
|
||||
FreeCursorBits(bits);
|
||||
free(pCurs);
|
||||
return BadAlloc;
|
||||
}
|
||||
pShare->font = sourcefont;
|
||||
sourcefont->refcnt++;
|
||||
pShare->sourceChar = sourceChar;
|
||||
pShare->maskChar = maskChar;
|
||||
pShare->bits = bits;
|
||||
pShare->next = sharedGlyphs;
|
||||
sharedGlyphs = pShare;
|
||||
}
|
||||
}
|
||||
CheckForEmptyMask(bits);
|
||||
pCurs->bits = bits;
|
||||
pCurs->refcnt = 1;
|
||||
#ifdef XFIXES
|
||||
pCurs->serialNumber = ++cursorSerial;
|
||||
pCurs->name = None;
|
||||
#endif
|
||||
|
||||
pCurs->foreRed = foreRed;
|
||||
pCurs->foreGreen = foreGreen;
|
||||
pCurs->foreBlue = foreBlue;
|
||||
|
||||
pCurs->backRed = backRed;
|
||||
pCurs->backGreen = backGreen;
|
||||
pCurs->backBlue = backBlue;
|
||||
|
||||
/*
|
||||
* realize the cursor for every screen
|
||||
*/
|
||||
for (nscr = 0; nscr < screenInfo.numScreens; nscr++)
|
||||
{
|
||||
pscr = screenInfo.screens[nscr];
|
||||
if (!( *pscr->RealizeCursor)( pscr, pCurs))
|
||||
{
|
||||
while (--nscr >= 0)
|
||||
{
|
||||
pscr = screenInfo.screens[nscr];
|
||||
( *pscr->UnrealizeCursor)( pscr, pCurs);
|
||||
}
|
||||
FreeCursorBits(pCurs->bits);
|
||||
free(pCurs);
|
||||
return BadAlloc;
|
||||
}
|
||||
}
|
||||
*ppCurs = pCurs;
|
||||
return Success;
|
||||
}
|
||||
|
||||
/** CreateRootCursor
|
||||
*
|
||||
* look up the name of a font
|
||||
* open the font
|
||||
* add the font to the resource table
|
||||
* make a cursor from the glyphs
|
||||
* add the cursor to the resource table
|
||||
*************************************************************/
|
||||
|
||||
CursorPtr
|
||||
CreateRootCursor(char *pfilename, unsigned glyph)
|
||||
{
|
||||
CursorPtr curs;
|
||||
FontPtr cursorfont;
|
||||
int err;
|
||||
XID fontID;
|
||||
|
||||
fontID = FakeClientID(0);
|
||||
err = OpenFont(serverClient, fontID, FontLoadAll | FontOpenSync,
|
||||
(unsigned)strlen( pfilename), pfilename);
|
||||
if (err != Success)
|
||||
return NullCursor;
|
||||
|
||||
cursorfont = (FontPtr)LookupIDByType(fontID, RT_FONT);
|
||||
if (!cursorfont)
|
||||
return NullCursor;
|
||||
if (AllocGlyphCursor(fontID, glyph, fontID, glyph + 1,
|
||||
0, 0, 0, ~0, ~0, ~0, &curs, serverClient) != Success)
|
||||
return NullCursor;
|
||||
|
||||
if (!AddResource(FakeClientID(0), RT_CURSOR, (void *)curs))
|
||||
return NullCursor;
|
||||
|
||||
return curs;
|
||||
}
|
||||
1624
nx-X11/programs/Xserver/dix/devices.c
Normal file
1624
nx-X11/programs/Xserver/dix/devices.c
Normal file
File diff suppressed because it is too large
Load Diff
4197
nx-X11/programs/Xserver/dix/dispatch.c
Normal file
4197
nx-X11/programs/Xserver/dix/dispatch.c
Normal file
File diff suppressed because it is too large
Load Diff
146
nx-X11/programs/Xserver/dix/dispatch.h
Normal file
146
nx-X11/programs/Xserver/dix/dispatch.h
Normal file
@@ -0,0 +1,146 @@
|
||||
/************************************************************
|
||||
|
||||
Copyright 1996 by Thomas E. Dickey <dickey@clark.net>
|
||||
|
||||
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 the above listed
|
||||
copyright holder(s) not be used in advertising or publicity pertaining
|
||||
to distribution of the software without specific, written prior
|
||||
permission.
|
||||
|
||||
THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
|
||||
TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) 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.
|
||||
|
||||
********************************************************/
|
||||
|
||||
/*
|
||||
* This prototypes the dispatch.c module (except for functions declared in
|
||||
* global headers), plus related dispatch procedures from devices.c, events.c,
|
||||
* extension.c, property.c.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#ifndef DISPATCH_H
|
||||
#define DISPATCH_H 1
|
||||
|
||||
DISPATCH_PROC(InitClientPrivates);
|
||||
DISPATCH_PROC(ProcAllocColor);
|
||||
DISPATCH_PROC(ProcAllocColorCells);
|
||||
DISPATCH_PROC(ProcAllocColorPlanes);
|
||||
DISPATCH_PROC(ProcAllocNamedColor);
|
||||
DISPATCH_PROC(ProcBell);
|
||||
DISPATCH_PROC(ProcChangeAccessControl);
|
||||
DISPATCH_PROC(ProcChangeCloseDownMode);
|
||||
DISPATCH_PROC(ProcChangeGC);
|
||||
DISPATCH_PROC(ProcChangeHosts);
|
||||
DISPATCH_PROC(ProcChangeKeyboardControl);
|
||||
DISPATCH_PROC(ProcChangeKeyboardMapping);
|
||||
DISPATCH_PROC(ProcChangePointerControl);
|
||||
DISPATCH_PROC(ProcChangeProperty);
|
||||
DISPATCH_PROC(ProcChangeSaveSet);
|
||||
DISPATCH_PROC(ProcChangeWindowAttributes);
|
||||
DISPATCH_PROC(ProcCirculateWindow);
|
||||
DISPATCH_PROC(ProcClearToBackground);
|
||||
DISPATCH_PROC(ProcCloseFont);
|
||||
DISPATCH_PROC(ProcConfigureWindow);
|
||||
DISPATCH_PROC(ProcConvertSelection);
|
||||
DISPATCH_PROC(ProcCopyArea);
|
||||
DISPATCH_PROC(ProcCopyColormapAndFree);
|
||||
DISPATCH_PROC(ProcCopyGC);
|
||||
DISPATCH_PROC(ProcCopyPlane);
|
||||
DISPATCH_PROC(ProcCreateColormap);
|
||||
DISPATCH_PROC(ProcCreateCursor);
|
||||
DISPATCH_PROC(ProcCreateGC);
|
||||
DISPATCH_PROC(ProcCreateGlyphCursor);
|
||||
DISPATCH_PROC(ProcCreatePixmap);
|
||||
DISPATCH_PROC(ProcCreateWindow);
|
||||
DISPATCH_PROC(ProcDeleteProperty);
|
||||
DISPATCH_PROC(ProcDestroySubwindows);
|
||||
DISPATCH_PROC(ProcDestroyWindow);
|
||||
DISPATCH_PROC(ProcEstablishConnection);
|
||||
DISPATCH_PROC(ProcFillPoly);
|
||||
DISPATCH_PROC(ProcForceScreenSaver);
|
||||
DISPATCH_PROC(ProcFreeColormap);
|
||||
DISPATCH_PROC(ProcFreeColors);
|
||||
DISPATCH_PROC(ProcFreeCursor);
|
||||
DISPATCH_PROC(ProcFreeGC);
|
||||
DISPATCH_PROC(ProcFreePixmap);
|
||||
DISPATCH_PROC(ProcGetAtomName);
|
||||
DISPATCH_PROC(ProcGetFontPath);
|
||||
DISPATCH_PROC(ProcGetGeometry);
|
||||
DISPATCH_PROC(ProcGetImage);
|
||||
DISPATCH_PROC(ProcGetKeyboardControl);
|
||||
DISPATCH_PROC(ProcGetKeyboardMapping);
|
||||
DISPATCH_PROC(ProcGetModifierMapping);
|
||||
DISPATCH_PROC(ProcGetMotionEvents);
|
||||
DISPATCH_PROC(ProcGetPointerControl);
|
||||
DISPATCH_PROC(ProcGetPointerMapping);
|
||||
DISPATCH_PROC(ProcGetProperty);
|
||||
DISPATCH_PROC(ProcGetScreenSaver);
|
||||
DISPATCH_PROC(ProcGetSelectionOwner);
|
||||
DISPATCH_PROC(ProcGetWindowAttributes);
|
||||
DISPATCH_PROC(ProcGrabServer);
|
||||
DISPATCH_PROC(ProcImageText16);
|
||||
DISPATCH_PROC(ProcImageText8);
|
||||
DISPATCH_PROC(ProcInitialConnection);
|
||||
DISPATCH_PROC(ProcInstallColormap);
|
||||
DISPATCH_PROC(ProcInternAtom);
|
||||
DISPATCH_PROC(ProcKillClient);
|
||||
DISPATCH_PROC(ProcListExtensions);
|
||||
DISPATCH_PROC(ProcListFonts);
|
||||
DISPATCH_PROC(ProcListFontsWithInfo);
|
||||
DISPATCH_PROC(ProcListHosts);
|
||||
DISPATCH_PROC(ProcListInstalledColormaps);
|
||||
DISPATCH_PROC(ProcListProperties);
|
||||
DISPATCH_PROC(ProcLookupColor);
|
||||
DISPATCH_PROC(ProcMapSubwindows);
|
||||
DISPATCH_PROC(ProcMapWindow);
|
||||
DISPATCH_PROC(ProcNoOperation);
|
||||
DISPATCH_PROC(ProcOpenFont);
|
||||
DISPATCH_PROC(ProcPolyArc);
|
||||
DISPATCH_PROC(ProcPolyFillArc);
|
||||
DISPATCH_PROC(ProcPolyFillRectangle);
|
||||
DISPATCH_PROC(ProcPolyLine);
|
||||
DISPATCH_PROC(ProcPolyPoint);
|
||||
DISPATCH_PROC(ProcPolyRectangle);
|
||||
DISPATCH_PROC(ProcPolySegment);
|
||||
DISPATCH_PROC(ProcPolyText);
|
||||
DISPATCH_PROC(ProcPutImage);
|
||||
DISPATCH_PROC(ProcQueryBestSize);
|
||||
DISPATCH_PROC(ProcQueryColors);
|
||||
DISPATCH_PROC(ProcQueryExtension);
|
||||
DISPATCH_PROC(ProcQueryFont);
|
||||
DISPATCH_PROC(ProcQueryKeymap);
|
||||
DISPATCH_PROC(ProcQueryTextExtents);
|
||||
DISPATCH_PROC(ProcQueryTree);
|
||||
DISPATCH_PROC(ProcReparentWindow);
|
||||
DISPATCH_PROC(ProcRotateProperties);
|
||||
DISPATCH_PROC(ProcSetClipRectangles);
|
||||
DISPATCH_PROC(ProcSetDashes);
|
||||
DISPATCH_PROC(ProcSetFontPath);
|
||||
DISPATCH_PROC(ProcSetModifierMapping);
|
||||
DISPATCH_PROC(ProcSetPointerMapping);
|
||||
DISPATCH_PROC(ProcSetScreenSaver);
|
||||
DISPATCH_PROC(ProcSetSelectionOwner);
|
||||
DISPATCH_PROC(ProcStoreColors);
|
||||
DISPATCH_PROC(ProcStoreNamedColor);
|
||||
DISPATCH_PROC(ProcTranslateCoords);
|
||||
DISPATCH_PROC(ProcUngrabServer);
|
||||
DISPATCH_PROC(ProcUninstallColormap);
|
||||
DISPATCH_PROC(ProcUnmapSubwindows);
|
||||
DISPATCH_PROC(ProcUnmapWindow);
|
||||
|
||||
#endif /* DISPATCH_H */
|
||||
2552
nx-X11/programs/Xserver/dix/dixfonts.c
Normal file
2552
nx-X11/programs/Xserver/dix/dixfonts.c
Normal file
File diff suppressed because it is too large
Load Diff
923
nx-X11/programs/Xserver/dix/dixutils.c
Normal file
923
nx-X11/programs/Xserver/dix/dixutils.c
Normal file
@@ -0,0 +1,923 @@
|
||||
/***********************************************************
|
||||
|
||||
Copyright 1987, 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 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.
|
||||
|
||||
******************************************************************/
|
||||
|
||||
/*
|
||||
|
||||
(c)Copyright 1988,1991 Adobe Systems Incorporated. All rights reserved.
|
||||
|
||||
Permission to use, copy, modify, distribute, and sublicense this software and its
|
||||
documentation for any purpose and without fee is hereby granted, provided that
|
||||
the above copyright notices appear in all copies and that both those copyright
|
||||
notices and this permission notice appear in supporting documentation and that
|
||||
the name of Adobe Systems Incorporated not be used in advertising or publicity
|
||||
pertaining to distribution of the software without specific, written prior
|
||||
permission. No trademark license to use the Adobe trademarks is hereby
|
||||
granted. If the Adobe trademark "Display PostScript"(tm) is used to describe
|
||||
this software, its functionality or for any other purpose, such use shall be
|
||||
limited to a statement that this software works in conjunction with the Display
|
||||
PostScript system. Proper trademark attribution to reflect Adobe's ownership
|
||||
of the trademark shall be given whenever any such reference to the Display
|
||||
PostScript system is made.
|
||||
|
||||
ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR ANY
|
||||
PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY. ADOBE
|
||||
DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-
|
||||
INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE TO YOU
|
||||
OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
|
||||
DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,NEGLIGENCE, STRICT
|
||||
LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT PROVIDE ANY TRAINING OR OTHER
|
||||
SUPPORT FOR THE SOFTWARE.
|
||||
|
||||
Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
|
||||
Incorporated which may be registered in certain jurisdictions.
|
||||
|
||||
Author: Adobe Systems Incorporated
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#ifdef HAVE_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#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 <nx-X11/keysymdef.h>
|
||||
#ifdef XCSECURITY
|
||||
#define _SECURITY_SERVER
|
||||
#include <nx-X11/extensions/security.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* CompareTimeStamps returns -1, 0, or +1 depending on if the first
|
||||
* argument is less than, equal to or greater than the second argument.
|
||||
*/
|
||||
|
||||
int
|
||||
CompareTimeStamps(TimeStamp a, TimeStamp b)
|
||||
{
|
||||
if (a.months < b.months)
|
||||
return EARLIER;
|
||||
if (a.months > b.months)
|
||||
return LATER;
|
||||
if (a.milliseconds < b.milliseconds)
|
||||
return EARLIER;
|
||||
if (a.milliseconds > b.milliseconds)
|
||||
return LATER;
|
||||
return SAMETIME;
|
||||
}
|
||||
|
||||
/*
|
||||
* convert client times to server TimeStamps
|
||||
*/
|
||||
|
||||
#define HALFMONTH ((unsigned long) 1<<31)
|
||||
TimeStamp
|
||||
ClientTimeToServerTime(CARD32 c)
|
||||
{
|
||||
TimeStamp ts;
|
||||
if (c == CurrentTime)
|
||||
return currentTime;
|
||||
ts.months = currentTime.months;
|
||||
ts.milliseconds = c;
|
||||
if (c > currentTime.milliseconds)
|
||||
{
|
||||
if (((unsigned long) c - currentTime.milliseconds) > HALFMONTH)
|
||||
ts.months -= 1;
|
||||
}
|
||||
else if (c < currentTime.milliseconds)
|
||||
{
|
||||
if (((unsigned long)currentTime.milliseconds - c) > HALFMONTH)
|
||||
ts.months += 1;
|
||||
}
|
||||
return ts;
|
||||
}
|
||||
|
||||
/*
|
||||
* ISO Latin-1 case conversion routine
|
||||
*
|
||||
* this routine always null-terminates the result, so
|
||||
* beware of too-small buffers
|
||||
*/
|
||||
|
||||
static unsigned char
|
||||
ISOLatin1ToLower (unsigned char source)
|
||||
{
|
||||
unsigned char dest;
|
||||
if ((source >= XK_A) && (source <= XK_Z))
|
||||
dest = source + (XK_a - XK_A);
|
||||
else if ((source >= XK_Agrave) && (source <= XK_Odiaeresis))
|
||||
dest = source + (XK_agrave - XK_Agrave);
|
||||
else if ((source >= XK_Ooblique) && (source <= XK_Thorn))
|
||||
dest = source + (XK_oslash - XK_Ooblique);
|
||||
else
|
||||
dest = source;
|
||||
return dest;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CopyISOLatin1Lowered(char *dest, const char *source, int length)
|
||||
{
|
||||
register int i;
|
||||
|
||||
for (i = 0; i < length; i++, source++, dest++)
|
||||
*dest = ISOLatin1ToLower (*source);
|
||||
*dest = '\0';
|
||||
}
|
||||
|
||||
int
|
||||
CompareISOLatin1Lowered(unsigned char *s1, int s1len,
|
||||
unsigned char *s2, int s2len)
|
||||
{
|
||||
unsigned char c1, c2;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
/* note -- compare against zero so that -1 ignores len */
|
||||
c1 = s1len-- ? *s1++ : '\0';
|
||||
c2 = s2len-- ? *s2++ : '\0';
|
||||
if (!c1 ||
|
||||
(c1 != c2 &&
|
||||
(c1 = ISOLatin1ToLower (c1)) != (c2 = ISOLatin1ToLower (c2))))
|
||||
break;
|
||||
}
|
||||
return (int) c1 - (int) c2;
|
||||
}
|
||||
|
||||
#ifdef XCSECURITY
|
||||
|
||||
/* SecurityLookupWindow and SecurityLookupDrawable:
|
||||
* Look up the window/drawable taking into account the client doing
|
||||
* the lookup and the type of access desired. Return the window/drawable
|
||||
* if it exists and the client is allowed access, else return NULL.
|
||||
* Most Proc* functions should be calling these instead of
|
||||
* LookupWindow and LookupDrawable, which do no access checks.
|
||||
*/
|
||||
|
||||
WindowPtr
|
||||
SecurityLookupWindow(XID rid, ClientPtr client, Mask access_mode)
|
||||
{
|
||||
client->errorValue = rid;
|
||||
if(rid == INVALID)
|
||||
return NULL;
|
||||
return (WindowPtr)SecurityLookupIDByType(client, rid, RT_WINDOW, access_mode);
|
||||
}
|
||||
|
||||
|
||||
void *
|
||||
SecurityLookupDrawable(XID rid, ClientPtr client, Mask access_mode)
|
||||
{
|
||||
register DrawablePtr pDraw;
|
||||
|
||||
if(rid == INVALID)
|
||||
return (void *) NULL;
|
||||
pDraw = (DrawablePtr)SecurityLookupIDByClass(client, rid, RC_DRAWABLE,
|
||||
access_mode);
|
||||
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
|
||||
* macros because of compatibility with loadable servers.
|
||||
*/
|
||||
|
||||
WindowPtr
|
||||
LookupWindow(XID rid, ClientPtr client)
|
||||
{
|
||||
return SecurityLookupWindow(rid, client, DixUnknownAccess);
|
||||
}
|
||||
|
||||
void *
|
||||
LookupDrawable(XID rid, ClientPtr client)
|
||||
{
|
||||
return SecurityLookupDrawable(rid, client, DixUnknownAccess);
|
||||
}
|
||||
|
||||
#else /* not XCSECURITY */
|
||||
|
||||
WindowPtr
|
||||
LookupWindow(XID rid, ClientPtr client)
|
||||
{
|
||||
WindowPtr pWin;
|
||||
|
||||
client->errorValue = rid;
|
||||
if(rid == INVALID)
|
||||
return NULL;
|
||||
return (WindowPtr)LookupIDByType(rid, RT_WINDOW);
|
||||
}
|
||||
|
||||
|
||||
void *
|
||||
LookupDrawable(XID rid, ClientPtr client)
|
||||
{
|
||||
register DrawablePtr pDraw;
|
||||
|
||||
if(rid == INVALID)
|
||||
return (void *) NULL;
|
||||
pDraw = (DrawablePtr)LookupIDByClass(rid, RC_DRAWABLE);
|
||||
if (pDraw && (pDraw->type != UNDRAWABLE_WINDOW))
|
||||
return (void *)pDraw;
|
||||
return (void *)NULL;
|
||||
}
|
||||
|
||||
#endif /* XCSECURITY */
|
||||
|
||||
ClientPtr
|
||||
LookupClient(XID rid, ClientPtr client)
|
||||
{
|
||||
void * pRes = (void *)SecurityLookupIDByClass(client, rid, RC_ANY,
|
||||
DixReadAccess);
|
||||
int clientIndex = CLIENT_ID(rid);
|
||||
|
||||
if (clientIndex && pRes && clients[clientIndex] && !(rid & SERVER_BIT))
|
||||
{
|
||||
return clients[clientIndex];
|
||||
}
|
||||
return (ClientPtr)NULL;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
AlterSaveSetForClient(ClientPtr client, WindowPtr pWin, unsigned mode,
|
||||
Bool toRoot, Bool remap)
|
||||
{
|
||||
int numnow;
|
||||
SaveSetElt *pTmp = NULL;
|
||||
int j;
|
||||
|
||||
numnow = client->numSaved;
|
||||
j = 0;
|
||||
if (numnow)
|
||||
{
|
||||
pTmp = client->saveSet;
|
||||
while ((j < numnow) && (SaveSetWindow(pTmp[j]) != (void *)pWin))
|
||||
j++;
|
||||
}
|
||||
if (mode == SetModeInsert)
|
||||
{
|
||||
if (j < numnow) /* duplicate */
|
||||
return(Success);
|
||||
numnow++;
|
||||
pTmp = (SaveSetElt *)realloc(client->saveSet, sizeof(*pTmp) * numnow);
|
||||
if (!pTmp)
|
||||
return(BadAlloc);
|
||||
client->saveSet = pTmp;
|
||||
client->numSaved = numnow;
|
||||
SaveSetAssignWindow(client->saveSet[numnow - 1], pWin);
|
||||
SaveSetAssignToRoot(client->saveSet[numnow - 1], toRoot);
|
||||
SaveSetAssignRemap(client->saveSet[numnow - 1], remap);
|
||||
return(Success);
|
||||
}
|
||||
else if ((mode == SetModeDelete) && (j < numnow))
|
||||
{
|
||||
while (j < numnow-1)
|
||||
{
|
||||
pTmp[j] = pTmp[j+1];
|
||||
j++;
|
||||
}
|
||||
numnow--;
|
||||
if (numnow)
|
||||
{
|
||||
pTmp = (SaveSetElt *)realloc(client->saveSet, sizeof(*pTmp) * numnow);
|
||||
if (pTmp)
|
||||
client->saveSet = pTmp;
|
||||
}
|
||||
else
|
||||
{
|
||||
free(client->saveSet);
|
||||
client->saveSet = (SaveSetElt *)NULL;
|
||||
}
|
||||
client->numSaved = numnow;
|
||||
return(Success);
|
||||
}
|
||||
return(Success);
|
||||
}
|
||||
|
||||
void
|
||||
DeleteWindowFromAnySaveSet(WindowPtr pWin)
|
||||
{
|
||||
register int i;
|
||||
register ClientPtr client;
|
||||
|
||||
for (i = 0; i< currentMaxClients; i++)
|
||||
{
|
||||
client = clients[i];
|
||||
if (client && client->numSaved)
|
||||
(void)AlterSaveSetForClient(client, pWin, SetModeDelete, FALSE, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
/* No-op Don't Do Anything : sometimes we need to be able to call a procedure
|
||||
* that doesn't do anything. For example, on screen with only static
|
||||
* colormaps, if someone calls install colormap, it's easier to have a dummy
|
||||
* procedure to call than to check if there's a procedure
|
||||
*/
|
||||
void
|
||||
NoopDDA(void)
|
||||
{
|
||||
}
|
||||
|
||||
typedef struct _BlockHandler {
|
||||
BlockHandlerProcPtr BlockHandler;
|
||||
WakeupHandlerProcPtr WakeupHandler;
|
||||
void * blockData;
|
||||
Bool deleted;
|
||||
} BlockHandlerRec, *BlockHandlerPtr;
|
||||
|
||||
static BlockHandlerPtr handlers;
|
||||
static int numHandlers;
|
||||
static int sizeHandlers;
|
||||
static Bool inHandler;
|
||||
static Bool handlerDeleted;
|
||||
|
||||
/**
|
||||
*
|
||||
* \param pTimeout DIX doesn't want to know how OS represents time
|
||||
* \param pReadMask nor how it represents the det of descriptors
|
||||
*/
|
||||
void
|
||||
BlockHandler(void * pTimeout, void * pReadmask)
|
||||
{
|
||||
register int i, j;
|
||||
|
||||
++inHandler;
|
||||
for (i = 0; i < screenInfo.numScreens; i++)
|
||||
(* screenInfo.screens[i]->BlockHandler)(i,
|
||||
screenInfo.screens[i]->blockData,
|
||||
pTimeout, pReadmask);
|
||||
for (i = 0; i < numHandlers; i++)
|
||||
(*handlers[i].BlockHandler) (handlers[i].blockData,
|
||||
pTimeout, pReadmask);
|
||||
if (handlerDeleted)
|
||||
{
|
||||
for (i = 0; i < numHandlers;)
|
||||
if (handlers[i].deleted)
|
||||
{
|
||||
for (j = i; j < numHandlers - 1; j++)
|
||||
handlers[j] = handlers[j+1];
|
||||
numHandlers--;
|
||||
}
|
||||
else
|
||||
i++;
|
||||
handlerDeleted = FALSE;
|
||||
}
|
||||
--inHandler;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* \param result 32 bits of undefined result from the wait
|
||||
* \param pReadmask the resulting descriptor mask
|
||||
*/
|
||||
void
|
||||
WakeupHandler(int result, void * pReadmask)
|
||||
{
|
||||
register int i, j;
|
||||
|
||||
++inHandler;
|
||||
for (i = numHandlers - 1; i >= 0; i--)
|
||||
(*handlers[i].WakeupHandler) (handlers[i].blockData,
|
||||
result, pReadmask);
|
||||
for (i = 0; i < screenInfo.numScreens; i++)
|
||||
(* screenInfo.screens[i]->WakeupHandler)(i,
|
||||
screenInfo.screens[i]->wakeupData,
|
||||
result, pReadmask);
|
||||
if (handlerDeleted)
|
||||
{
|
||||
for (i = 0; i < numHandlers;)
|
||||
if (handlers[i].deleted)
|
||||
{
|
||||
for (j = i; j < numHandlers - 1; j++)
|
||||
handlers[j] = handlers[j+1];
|
||||
numHandlers--;
|
||||
}
|
||||
else
|
||||
i++;
|
||||
handlerDeleted = FALSE;
|
||||
}
|
||||
--inHandler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reentrant with BlockHandler and WakeupHandler, except wakeup won't
|
||||
* get called until next time
|
||||
*/
|
||||
Bool
|
||||
RegisterBlockAndWakeupHandlers (BlockHandlerProcPtr blockHandler,
|
||||
WakeupHandlerProcPtr wakeupHandler,
|
||||
void * blockData)
|
||||
{
|
||||
BlockHandlerPtr new;
|
||||
|
||||
if (numHandlers >= sizeHandlers)
|
||||
{
|
||||
new = (BlockHandlerPtr) realloc (handlers, (numHandlers + 1) *
|
||||
sizeof (BlockHandlerRec));
|
||||
if (!new)
|
||||
return FALSE;
|
||||
handlers = new;
|
||||
sizeHandlers = numHandlers + 1;
|
||||
}
|
||||
handlers[numHandlers].BlockHandler = blockHandler;
|
||||
handlers[numHandlers].WakeupHandler = wakeupHandler;
|
||||
handlers[numHandlers].blockData = blockData;
|
||||
handlers[numHandlers].deleted = FALSE;
|
||||
numHandlers = numHandlers + 1;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
RemoveBlockAndWakeupHandlers (BlockHandlerProcPtr blockHandler,
|
||||
WakeupHandlerProcPtr wakeupHandler,
|
||||
void * blockData)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < numHandlers; i++)
|
||||
if (handlers[i].BlockHandler == blockHandler &&
|
||||
handlers[i].WakeupHandler == wakeupHandler &&
|
||||
handlers[i].blockData == blockData)
|
||||
{
|
||||
if (inHandler)
|
||||
{
|
||||
handlerDeleted = TRUE;
|
||||
handlers[i].deleted = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (; i < numHandlers - 1; i++)
|
||||
handlers[i] = handlers[i+1];
|
||||
numHandlers--;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
InitBlockAndWakeupHandlers ()
|
||||
{
|
||||
free (handlers);
|
||||
handlers = (BlockHandlerPtr) 0;
|
||||
numHandlers = 0;
|
||||
sizeHandlers = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* A general work queue. Perform some task before the server
|
||||
* sleeps for input.
|
||||
*/
|
||||
|
||||
WorkQueuePtr workQueue;
|
||||
static WorkQueuePtr *workQueueLast = &workQueue;
|
||||
|
||||
void
|
||||
ProcessWorkQueue(void)
|
||||
{
|
||||
WorkQueuePtr q, *p;
|
||||
|
||||
p = &workQueue;
|
||||
/*
|
||||
* Scan the work queue once, calling each function. Those
|
||||
* which return TRUE are removed from the queue, otherwise
|
||||
* they will be called again. This must be reentrant with
|
||||
* QueueWorkProc.
|
||||
*/
|
||||
while ((q = *p))
|
||||
{
|
||||
if ((*q->function) (q->client, q->closure))
|
||||
{
|
||||
/* remove q from the list */
|
||||
*p = q->next; /* don't fetch until after func called */
|
||||
free (q);
|
||||
}
|
||||
else
|
||||
{
|
||||
p = &q->next; /* don't fetch until after func called */
|
||||
}
|
||||
}
|
||||
workQueueLast = p;
|
||||
}
|
||||
|
||||
void
|
||||
ProcessWorkQueueZombies(void)
|
||||
{
|
||||
WorkQueuePtr q, *p;
|
||||
|
||||
p = &workQueue;
|
||||
while ((q = *p))
|
||||
{
|
||||
if (q->client && q->client->clientGone)
|
||||
{
|
||||
(void) (*q->function) (q->client, q->closure);
|
||||
/* remove q from the list */
|
||||
*p = q->next; /* don't fetch until after func called */
|
||||
free (q);
|
||||
}
|
||||
else
|
||||
{
|
||||
p = &q->next; /* don't fetch until after func called */
|
||||
}
|
||||
}
|
||||
workQueueLast = p;
|
||||
}
|
||||
|
||||
Bool
|
||||
QueueWorkProc (
|
||||
Bool (*function)(ClientPtr /* pClient */, void * /* closure */),
|
||||
ClientPtr client, void * closure)
|
||||
{
|
||||
WorkQueuePtr q;
|
||||
|
||||
q = (WorkQueuePtr) malloc (sizeof *q);
|
||||
if (!q)
|
||||
return FALSE;
|
||||
q->function = function;
|
||||
q->client = client;
|
||||
q->closure = closure;
|
||||
q->next = NULL;
|
||||
*workQueueLast = q;
|
||||
workQueueLast = &q->next;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Manage a queue of sleeping clients, awakening them
|
||||
* when requested, by using the OS functions IgnoreClient
|
||||
* and AttendClient. Note that this *ignores* the troubles
|
||||
* with request data interleaving itself with events, but
|
||||
* we'll leave that until a later time.
|
||||
*/
|
||||
|
||||
typedef struct _SleepQueue {
|
||||
struct _SleepQueue *next;
|
||||
ClientPtr client;
|
||||
ClientSleepProcPtr function;
|
||||
void * closure;
|
||||
} SleepQueueRec, *SleepQueuePtr;
|
||||
|
||||
static SleepQueuePtr sleepQueue = NULL;
|
||||
|
||||
Bool
|
||||
ClientSleep (ClientPtr client, ClientSleepProcPtr function, void * closure)
|
||||
{
|
||||
SleepQueuePtr q;
|
||||
|
||||
q = (SleepQueuePtr) malloc (sizeof *q);
|
||||
if (!q)
|
||||
return FALSE;
|
||||
|
||||
IgnoreClient (client);
|
||||
q->next = sleepQueue;
|
||||
q->client = client;
|
||||
q->function = function;
|
||||
q->closure = closure;
|
||||
sleepQueue = q;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Bool
|
||||
ClientSignal (ClientPtr client)
|
||||
{
|
||||
SleepQueuePtr q;
|
||||
|
||||
for (q = sleepQueue; q; q = q->next)
|
||||
if (q->client == client)
|
||||
{
|
||||
return QueueWorkProc (q->function, q->client, q->closure);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
ClientWakeup (ClientPtr client)
|
||||
{
|
||||
SleepQueuePtr q, *prev;
|
||||
|
||||
prev = &sleepQueue;
|
||||
while ( (q = *prev) )
|
||||
{
|
||||
if (q->client == client)
|
||||
{
|
||||
*prev = q->next;
|
||||
free (q);
|
||||
if (client->clientGone)
|
||||
/* Oops -- new zombie cleanup code ensures this only
|
||||
* happens from inside CloseDownClient; don't want to
|
||||
* recurse here...
|
||||
*/
|
||||
/* CloseDownClient(client) */;
|
||||
else
|
||||
AttendClient (client);
|
||||
break;
|
||||
}
|
||||
prev = &q->next;
|
||||
}
|
||||
}
|
||||
|
||||
Bool
|
||||
ClientIsAsleep (ClientPtr client)
|
||||
{
|
||||
SleepQueuePtr q;
|
||||
|
||||
for (q = sleepQueue; q; q = q->next)
|
||||
if (q->client == client)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Generic Callback Manager
|
||||
*/
|
||||
|
||||
/* ===== Private Procedures ===== */
|
||||
|
||||
static int numCallbackListsToCleanup = 0;
|
||||
static CallbackListPtr **listsToCleanup = NULL;
|
||||
|
||||
static Bool
|
||||
_AddCallback(
|
||||
CallbackListPtr *pcbl,
|
||||
CallbackProcPtr callback,
|
||||
void *data)
|
||||
{
|
||||
CallbackPtr cbr;
|
||||
|
||||
cbr = (CallbackPtr) malloc(sizeof(CallbackRec));
|
||||
if (!cbr)
|
||||
return FALSE;
|
||||
cbr->proc = callback;
|
||||
cbr->data = data;
|
||||
cbr->next = (*pcbl)->list;
|
||||
cbr->deleted = FALSE;
|
||||
(*pcbl)->list = cbr;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static Bool
|
||||
_DeleteCallback(
|
||||
CallbackListPtr *pcbl,
|
||||
CallbackProcPtr callback,
|
||||
void *data)
|
||||
{
|
||||
CallbackListPtr cbl = *pcbl;
|
||||
CallbackPtr cbr, pcbr;
|
||||
|
||||
for (pcbr = NULL, cbr = cbl->list;
|
||||
cbr != NULL;
|
||||
pcbr = cbr, cbr = cbr->next)
|
||||
{
|
||||
if ((cbr->proc == callback) && (cbr->data == data))
|
||||
break;
|
||||
}
|
||||
if (cbr != NULL)
|
||||
{
|
||||
if (cbl->inCallback)
|
||||
{
|
||||
++(cbl->numDeleted);
|
||||
cbr->deleted = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pcbr == NULL)
|
||||
cbl->list = cbr->next;
|
||||
else
|
||||
pcbr->next = cbr->next;
|
||||
free(cbr);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
_CallCallbacks(
|
||||
CallbackListPtr *pcbl,
|
||||
void *call_data)
|
||||
{
|
||||
CallbackListPtr cbl = *pcbl;
|
||||
CallbackPtr cbr, pcbr;
|
||||
|
||||
++(cbl->inCallback);
|
||||
for (cbr = cbl->list; cbr != NULL; cbr = cbr->next)
|
||||
{
|
||||
(*(cbr->proc)) (pcbl, cbr->data, call_data);
|
||||
}
|
||||
--(cbl->inCallback);
|
||||
|
||||
if (cbl->inCallback) return;
|
||||
|
||||
/* Was the entire list marked for deletion? */
|
||||
|
||||
if (cbl->deleted)
|
||||
{
|
||||
DeleteCallbackList(pcbl);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Were some individual callbacks on the list marked for deletion?
|
||||
* If so, do the deletions.
|
||||
*/
|
||||
|
||||
if (cbl->numDeleted)
|
||||
{
|
||||
for (pcbr = NULL, cbr = cbl->list; (cbr != NULL) && cbl->numDeleted; )
|
||||
{
|
||||
if (cbr->deleted)
|
||||
{
|
||||
if (pcbr)
|
||||
{
|
||||
cbr = cbr->next;
|
||||
free(pcbr->next);
|
||||
pcbr->next = cbr;
|
||||
} else
|
||||
{
|
||||
cbr = cbr->next;
|
||||
free(cbl->list);
|
||||
cbl->list = cbr;
|
||||
}
|
||||
cbl->numDeleted--;
|
||||
}
|
||||
else /* this one wasn't deleted */
|
||||
{
|
||||
pcbr = cbr;
|
||||
cbr = cbr->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_DeleteCallbackList(
|
||||
CallbackListPtr *pcbl)
|
||||
{
|
||||
CallbackListPtr cbl = *pcbl;
|
||||
CallbackPtr cbr, nextcbr;
|
||||
int i;
|
||||
|
||||
if (cbl->inCallback)
|
||||
{
|
||||
cbl->deleted = TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < numCallbackListsToCleanup; i++)
|
||||
{
|
||||
if ((listsToCleanup[i] = pcbl) != 0)
|
||||
{
|
||||
listsToCleanup[i] = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (cbr = cbl->list; cbr != NULL; cbr = nextcbr)
|
||||
{
|
||||
nextcbr = cbr->next;
|
||||
free(cbr);
|
||||
}
|
||||
free(cbl);
|
||||
*pcbl = NULL;
|
||||
}
|
||||
|
||||
static CallbackFuncsRec default_cbfuncs =
|
||||
{
|
||||
_AddCallback,
|
||||
_DeleteCallback,
|
||||
_CallCallbacks,
|
||||
_DeleteCallbackList
|
||||
};
|
||||
|
||||
/* ===== Public Procedures ===== */
|
||||
|
||||
Bool
|
||||
CreateCallbackList(CallbackListPtr *pcbl, CallbackFuncsPtr cbfuncs)
|
||||
{
|
||||
CallbackListPtr cbl;
|
||||
int i;
|
||||
|
||||
if (!pcbl) return FALSE;
|
||||
cbl = (CallbackListPtr) malloc(sizeof(CallbackListRec));
|
||||
if (!cbl) return FALSE;
|
||||
cbl->funcs = cbfuncs ? *cbfuncs : default_cbfuncs;
|
||||
cbl->inCallback = 0;
|
||||
cbl->deleted = FALSE;
|
||||
cbl->numDeleted = 0;
|
||||
cbl->list = NULL;
|
||||
*pcbl = cbl;
|
||||
|
||||
for (i = 0; i < numCallbackListsToCleanup; i++)
|
||||
{
|
||||
if (!listsToCleanup[i])
|
||||
{
|
||||
listsToCleanup[i] = pcbl;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
listsToCleanup = (CallbackListPtr **)xnfrealloc(listsToCleanup,
|
||||
sizeof(CallbackListPtr *) * (numCallbackListsToCleanup+1));
|
||||
listsToCleanup[numCallbackListsToCleanup] = pcbl;
|
||||
numCallbackListsToCleanup++;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Bool
|
||||
AddCallback(CallbackListPtr *pcbl, CallbackProcPtr callback, void * data)
|
||||
{
|
||||
if (!pcbl) return FALSE;
|
||||
if (!*pcbl)
|
||||
{ /* list hasn't been created yet; go create it */
|
||||
if (!CreateCallbackList(pcbl, (CallbackFuncsPtr)NULL))
|
||||
return FALSE;
|
||||
}
|
||||
return ((*(*pcbl)->funcs.AddCallback) (pcbl, callback, data));
|
||||
}
|
||||
|
||||
Bool
|
||||
DeleteCallback(CallbackListPtr *pcbl, CallbackProcPtr callback, void * data)
|
||||
{
|
||||
if (!pcbl || !*pcbl) return FALSE;
|
||||
return ((*(*pcbl)->funcs.DeleteCallback) (pcbl, callback, data));
|
||||
}
|
||||
|
||||
void
|
||||
CallCallbacks(CallbackListPtr *pcbl, void * call_data)
|
||||
{
|
||||
if (!pcbl || !*pcbl) return;
|
||||
(*(*pcbl)->funcs.CallCallbacks) (pcbl, call_data);
|
||||
}
|
||||
|
||||
void
|
||||
DeleteCallbackList(CallbackListPtr *pcbl)
|
||||
{
|
||||
if (!pcbl || !*pcbl) return;
|
||||
(*(*pcbl)->funcs.DeleteCallbackList) (pcbl);
|
||||
}
|
||||
|
||||
void
|
||||
InitCallbackManager()
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < numCallbackListsToCleanup; i++)
|
||||
{
|
||||
DeleteCallbackList(listsToCleanup[i]);
|
||||
}
|
||||
if (listsToCleanup) free(listsToCleanup);
|
||||
|
||||
numCallbackListsToCleanup = 0;
|
||||
listsToCleanup = NULL;
|
||||
}
|
||||
4500
nx-X11/programs/Xserver/dix/events.c
Normal file
4500
nx-X11/programs/Xserver/dix/events.c
Normal file
File diff suppressed because it is too large
Load Diff
503
nx-X11/programs/Xserver/dix/extension.c
Normal file
503
nx-X11/programs/Xserver/dix/extension.c
Normal file
@@ -0,0 +1,503 @@
|
||||
/***********************************************************
|
||||
|
||||
Copyright 1987, 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 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.
|
||||
|
||||
******************************************************************/
|
||||
|
||||
#ifdef HAVE_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#include <nx-X11/X.h>
|
||||
#include <nx-X11/Xproto.h>
|
||||
#include "misc.h"
|
||||
#include "dixstruct.h"
|
||||
#include "extnsionst.h"
|
||||
#include "gcstruct.h"
|
||||
#include "scrnintstr.h"
|
||||
#include "dispatch.h"
|
||||
#ifdef XCSECURITY
|
||||
#define _SECURITY_SERVER
|
||||
#include <nx-X11/extensions/security.h>
|
||||
#endif
|
||||
|
||||
#define EXTENSION_BASE 128
|
||||
#define EXTENSION_EVENT_BASE 64
|
||||
#define LAST_EVENT 128
|
||||
#define LAST_ERROR 255
|
||||
|
||||
ScreenProcEntry AuxillaryScreenProcs[MAXSCREENS];
|
||||
|
||||
static ExtensionEntry **extensions = (ExtensionEntry **)NULL;
|
||||
|
||||
int lastEvent = EXTENSION_EVENT_BASE;
|
||||
static int lastError = FirstExtensionError;
|
||||
static unsigned int NumExtensions = 0;
|
||||
|
||||
extern int extensionPrivateLen;
|
||||
extern unsigned *extensionPrivateSizes;
|
||||
extern unsigned totalExtensionSize;
|
||||
|
||||
static void
|
||||
InitExtensionPrivates(ExtensionEntry *ext)
|
||||
{
|
||||
register char *ptr;
|
||||
DevUnion *ppriv;
|
||||
register unsigned *sizes;
|
||||
register unsigned size;
|
||||
register int i;
|
||||
|
||||
if (totalExtensionSize == sizeof(ExtensionEntry))
|
||||
ppriv = (DevUnion *)NULL;
|
||||
else
|
||||
ppriv = (DevUnion *)(ext + 1);
|
||||
|
||||
ext->devPrivates = ppriv;
|
||||
sizes = extensionPrivateSizes;
|
||||
ptr = (char *)(ppriv + extensionPrivateLen);
|
||||
for (i = extensionPrivateLen; --i >= 0; ppriv++, sizes++)
|
||||
{
|
||||
if ( (size = *sizes) )
|
||||
{
|
||||
ppriv->ptr = (void *)ptr;
|
||||
ptr += size;
|
||||
}
|
||||
else
|
||||
ppriv->ptr = (void *)NULL;
|
||||
}
|
||||
}
|
||||
|
||||
ExtensionEntry *
|
||||
AddExtension(char *name, int NumEvents, int NumErrors,
|
||||
int (*MainProc)(ClientPtr c1),
|
||||
int (*SwappedMainProc)(ClientPtr c2),
|
||||
void (*CloseDownProc)(ExtensionEntry *e),
|
||||
unsigned short (*MinorOpcodeProc)(ClientPtr c3))
|
||||
{
|
||||
int i;
|
||||
register ExtensionEntry *ext, **newexts;
|
||||
|
||||
if (!MainProc || !SwappedMainProc || !MinorOpcodeProc)
|
||||
return((ExtensionEntry *) NULL);
|
||||
if ((lastEvent + NumEvents > LAST_EVENT) ||
|
||||
(unsigned)(lastError + NumErrors > LAST_ERROR))
|
||||
return((ExtensionEntry *) NULL);
|
||||
|
||||
ext = (ExtensionEntry *) malloc(totalExtensionSize);
|
||||
if (!ext)
|
||||
return((ExtensionEntry *) NULL);
|
||||
bzero(ext, totalExtensionSize);
|
||||
InitExtensionPrivates(ext);
|
||||
ext->name = (char *)malloc(strlen(name) + 1);
|
||||
ext->num_aliases = 0;
|
||||
ext->aliases = (char **)NULL;
|
||||
if (!ext->name)
|
||||
{
|
||||
free(ext);
|
||||
return((ExtensionEntry *) NULL);
|
||||
}
|
||||
strcpy(ext->name, name);
|
||||
i = NumExtensions;
|
||||
newexts = (ExtensionEntry **) realloc(extensions,
|
||||
(i + 1) * sizeof(ExtensionEntry *));
|
||||
if (!newexts)
|
||||
{
|
||||
free(ext->name);
|
||||
free(ext);
|
||||
return((ExtensionEntry *) NULL);
|
||||
}
|
||||
NumExtensions++;
|
||||
extensions = newexts;
|
||||
extensions[i] = ext;
|
||||
ext->index = i;
|
||||
ext->base = i + EXTENSION_BASE;
|
||||
ext->CloseDown = CloseDownProc;
|
||||
ext->MinorOpcode = MinorOpcodeProc;
|
||||
ProcVector[i + EXTENSION_BASE] = MainProc;
|
||||
SwappedProcVector[i + EXTENSION_BASE] = SwappedMainProc;
|
||||
if (NumEvents)
|
||||
{
|
||||
ext->eventBase = lastEvent;
|
||||
ext->eventLast = lastEvent + NumEvents;
|
||||
lastEvent += NumEvents;
|
||||
}
|
||||
else
|
||||
{
|
||||
ext->eventBase = 0;
|
||||
ext->eventLast = 0;
|
||||
}
|
||||
if (NumErrors)
|
||||
{
|
||||
ext->errorBase = lastError;
|
||||
ext->errorLast = lastError + NumErrors;
|
||||
lastError += NumErrors;
|
||||
}
|
||||
else
|
||||
{
|
||||
ext->errorBase = 0;
|
||||
ext->errorLast = 0;
|
||||
}
|
||||
#ifdef XCSECURITY
|
||||
ext->secure = FALSE;
|
||||
#endif
|
||||
|
||||
return(ext);
|
||||
}
|
||||
|
||||
Bool AddExtensionAlias(char *alias, ExtensionEntry *ext)
|
||||
{
|
||||
char *name;
|
||||
char **aliases;
|
||||
|
||||
aliases = (char **)realloc(ext->aliases,
|
||||
(ext->num_aliases + 1) * sizeof(char *));
|
||||
if (!aliases)
|
||||
return FALSE;
|
||||
ext->aliases = aliases;
|
||||
name = (char *)malloc(strlen(alias) + 1);
|
||||
if (!name)
|
||||
return FALSE;
|
||||
strcpy(name, alias);
|
||||
ext->aliases[ext->num_aliases] = name;
|
||||
ext->num_aliases++;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int
|
||||
FindExtension(char *extname, int len)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
for (i=0; i<NumExtensions; i++)
|
||||
{
|
||||
if ((strlen(extensions[i]->name) == len) &&
|
||||
!strncmp(extname, extensions[i]->name, len))
|
||||
break;
|
||||
for (j = extensions[i]->num_aliases; --j >= 0;)
|
||||
{
|
||||
if ((strlen(extensions[i]->aliases[j]) == len) &&
|
||||
!strncmp(extname, extensions[i]->aliases[j], len))
|
||||
break;
|
||||
}
|
||||
if (j >= 0) break;
|
||||
}
|
||||
return ((i == NumExtensions) ? -1 : i);
|
||||
}
|
||||
|
||||
/*
|
||||
* CheckExtension returns the extensions[] entry for the requested
|
||||
* extension name. Maybe this could just return a Bool instead?
|
||||
*/
|
||||
ExtensionEntry *
|
||||
CheckExtension(const char *extname)
|
||||
{
|
||||
int n;
|
||||
|
||||
n = FindExtension((char*)extname, strlen(extname));
|
||||
if (n != -1)
|
||||
return extensions[n];
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Added as part of Xace.
|
||||
*/
|
||||
ExtensionEntry *
|
||||
GetExtensionEntry(int major)
|
||||
{
|
||||
if (major < EXTENSION_BASE)
|
||||
return NULL;
|
||||
major -= EXTENSION_BASE;
|
||||
if (major >= NumExtensions)
|
||||
return NULL;
|
||||
return extensions[major];
|
||||
}
|
||||
|
||||
void
|
||||
DeclareExtensionSecurity(char *extname, Bool secure)
|
||||
{
|
||||
#ifdef XCSECURITY
|
||||
int i = FindExtension(extname, strlen(extname));
|
||||
if (i >= 0)
|
||||
{
|
||||
int majorop = extensions[i]->base;
|
||||
extensions[i]->secure = secure;
|
||||
if (secure)
|
||||
{
|
||||
UntrustedProcVector[majorop] = ProcVector[majorop];
|
||||
SwappedUntrustedProcVector[majorop] = SwappedProcVector[majorop];
|
||||
}
|
||||
else
|
||||
{
|
||||
UntrustedProcVector[majorop] = ProcBadRequest;
|
||||
SwappedUntrustedProcVector[majorop] = ProcBadRequest;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
unsigned short
|
||||
StandardMinorOpcode(ClientPtr client)
|
||||
{
|
||||
return ((xReq *)client->requestBuffer)->data;
|
||||
}
|
||||
|
||||
unsigned short
|
||||
MinorOpcodeOfRequest(ClientPtr client)
|
||||
{
|
||||
unsigned char major;
|
||||
|
||||
major = ((xReq *)client->requestBuffer)->reqType;
|
||||
if (major < EXTENSION_BASE)
|
||||
return 0;
|
||||
major -= EXTENSION_BASE;
|
||||
if (major >= NumExtensions)
|
||||
return 0;
|
||||
return (*extensions[major]->MinorOpcode)(client);
|
||||
}
|
||||
|
||||
void
|
||||
CloseDownExtensions()
|
||||
{
|
||||
register int i,j;
|
||||
|
||||
for (i = NumExtensions - 1; i >= 0; i--)
|
||||
{
|
||||
if (extensions[i]->CloseDown)
|
||||
(* extensions[i]->CloseDown)(extensions[i]);
|
||||
NumExtensions = i;
|
||||
free(extensions[i]->name);
|
||||
for (j = extensions[i]->num_aliases; --j >= 0;)
|
||||
free(extensions[i]->aliases[j]);
|
||||
free(extensions[i]->aliases);
|
||||
free(extensions[i]);
|
||||
}
|
||||
free(extensions);
|
||||
extensions = (ExtensionEntry **)NULL;
|
||||
lastEvent = EXTENSION_EVENT_BASE;
|
||||
lastError = FirstExtensionError;
|
||||
for (i=0; i<MAXSCREENS; i++)
|
||||
{
|
||||
register ScreenProcEntry *spentry = &AuxillaryScreenProcs[i];
|
||||
|
||||
while (spentry->num)
|
||||
{
|
||||
spentry->num--;
|
||||
free(spentry->procList[spentry->num].name);
|
||||
}
|
||||
free(spentry->procList);
|
||||
spentry->procList = (ProcEntryPtr)NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
ProcQueryExtension(ClientPtr client)
|
||||
{
|
||||
xQueryExtensionReply reply;
|
||||
int i;
|
||||
REQUEST(xQueryExtensionReq);
|
||||
|
||||
REQUEST_FIXED_SIZE(xQueryExtensionReq, stuff->nbytes);
|
||||
|
||||
memset(&reply, 0, sizeof(xQueryExtensionReply));
|
||||
reply.type = X_Reply;
|
||||
reply.length = 0;
|
||||
reply.major_opcode = 0;
|
||||
reply.sequenceNumber = client->sequence;
|
||||
|
||||
if ( ! NumExtensions )
|
||||
reply.present = xFalse;
|
||||
else
|
||||
{
|
||||
i = FindExtension((char *)&stuff[1], stuff->nbytes);
|
||||
if (i < 0
|
||||
#ifdef XCSECURITY
|
||||
/* don't show insecure extensions to untrusted clients */
|
||||
|| (client->trustLevel == XSecurityClientUntrusted &&
|
||||
!extensions[i]->secure)
|
||||
#endif
|
||||
)
|
||||
reply.present = xFalse;
|
||||
else
|
||||
{
|
||||
reply.present = xTrue;
|
||||
reply.major_opcode = extensions[i]->base;
|
||||
reply.first_event = extensions[i]->eventBase;
|
||||
reply.first_error = extensions[i]->errorBase;
|
||||
}
|
||||
}
|
||||
WriteReplyToClient(client, sizeof(xQueryExtensionReply), &reply);
|
||||
return(client->noClientException);
|
||||
}
|
||||
|
||||
int
|
||||
ProcListExtensions(ClientPtr client)
|
||||
{
|
||||
xListExtensionsReply reply;
|
||||
char *bufptr, *buffer;
|
||||
int total_length = 0;
|
||||
|
||||
REQUEST_SIZE_MATCH(xReq);
|
||||
|
||||
memset(&reply, 0, sizeof(xListExtensionsReply));
|
||||
reply.type = X_Reply;
|
||||
reply.nExtensions = 0;
|
||||
reply.length = 0;
|
||||
reply.sequenceNumber = client->sequence;
|
||||
buffer = NULL;
|
||||
|
||||
if ( NumExtensions )
|
||||
{
|
||||
register int i, j;
|
||||
|
||||
for (i=0; i<NumExtensions; i++)
|
||||
{
|
||||
#ifdef XCSECURITY
|
||||
/* don't show insecure extensions to untrusted clients */
|
||||
if (client->trustLevel == XSecurityClientUntrusted &&
|
||||
!extensions[i]->secure)
|
||||
continue;
|
||||
#endif
|
||||
total_length += strlen(extensions[i]->name) + 1;
|
||||
reply.nExtensions += 1 + extensions[i]->num_aliases;
|
||||
for (j = extensions[i]->num_aliases; --j >= 0;)
|
||||
total_length += strlen(extensions[i]->aliases[j]) + 1;
|
||||
}
|
||||
reply.length = (total_length + 3) >> 2;
|
||||
buffer = bufptr = (char *)malloc(total_length);
|
||||
if (!buffer)
|
||||
return(BadAlloc);
|
||||
for (i=0; i<NumExtensions; i++)
|
||||
{
|
||||
int len;
|
||||
#ifdef XCSECURITY
|
||||
if (client->trustLevel == XSecurityClientUntrusted &&
|
||||
!extensions[i]->secure)
|
||||
continue;
|
||||
#endif
|
||||
*bufptr++ = len = strlen(extensions[i]->name);
|
||||
memmove(bufptr, extensions[i]->name, len);
|
||||
bufptr += len;
|
||||
for (j = extensions[i]->num_aliases; --j >= 0;)
|
||||
{
|
||||
*bufptr++ = len = strlen(extensions[i]->aliases[j]);
|
||||
memmove(bufptr, extensions[i]->aliases[j], len);
|
||||
bufptr += len;
|
||||
}
|
||||
}
|
||||
}
|
||||
WriteReplyToClient(client, sizeof(xListExtensionsReply), &reply);
|
||||
if (reply.length)
|
||||
{
|
||||
WriteToClient(client, total_length, buffer);
|
||||
free(buffer);
|
||||
}
|
||||
return(client->noClientException);
|
||||
}
|
||||
|
||||
ExtensionLookupProc
|
||||
LookupProc(char *name, GCPtr pGC)
|
||||
{
|
||||
register int i;
|
||||
register ScreenProcEntry *spentry;
|
||||
spentry = &AuxillaryScreenProcs[pGC->pScreen->myNum];
|
||||
if (spentry->num)
|
||||
{
|
||||
for (i = 0; i < spentry->num; i++)
|
||||
if (strcmp(name, spentry->procList[i].name) == 0)
|
||||
return(spentry->procList[i].proc);
|
||||
}
|
||||
return (ExtensionLookupProc)NULL;
|
||||
}
|
||||
|
||||
Bool
|
||||
RegisterProc(char *name, GC *pGC, ExtensionLookupProc proc)
|
||||
{
|
||||
return RegisterScreenProc(name, pGC->pScreen, proc);
|
||||
}
|
||||
|
||||
Bool
|
||||
RegisterScreenProc(char *name, ScreenPtr pScreen, ExtensionLookupProc proc)
|
||||
{
|
||||
register ScreenProcEntry *spentry;
|
||||
register ProcEntryPtr procEntry = (ProcEntryPtr)NULL;
|
||||
char *newname;
|
||||
int i;
|
||||
|
||||
spentry = &AuxillaryScreenProcs[pScreen->myNum];
|
||||
/* first replace duplicates */
|
||||
if (spentry->num)
|
||||
{
|
||||
for (i = 0; i < spentry->num; i++)
|
||||
if (strcmp(name, spentry->procList[i].name) == 0)
|
||||
{
|
||||
procEntry = &spentry->procList[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (procEntry)
|
||||
procEntry->proc = proc;
|
||||
else
|
||||
{
|
||||
newname = (char *)malloc(strlen(name)+1);
|
||||
if (!newname)
|
||||
return FALSE;
|
||||
procEntry = (ProcEntryPtr)
|
||||
realloc(spentry->procList,
|
||||
sizeof(ProcEntryRec) * (spentry->num+1));
|
||||
if (!procEntry)
|
||||
{
|
||||
free(newname);
|
||||
return FALSE;
|
||||
}
|
||||
spentry->procList = procEntry;
|
||||
procEntry += spentry->num;
|
||||
procEntry->name = newname;
|
||||
strcpy(newname, name);
|
||||
procEntry->proc = proc;
|
||||
spentry->num++;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
38
nx-X11/programs/Xserver/dix/ffs.c
Normal file
38
nx-X11/programs/Xserver/dix/ffs.c
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
|
||||
Copyright 1996, 1998 The Open Group
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this software and its
|
||||
documentation for any purpose is hereby granted without fee, provided that
|
||||
the above copyright notice appear in all copies and that both that
|
||||
copyright notice and this permission notice appear in supporting
|
||||
documentation.
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
|
||||
ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
||||
SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABIL-
|
||||
ITY, 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.
|
||||
|
||||
*/
|
||||
|
||||
int
|
||||
ffs(int i)
|
||||
{
|
||||
int j;
|
||||
if (i == 0)
|
||||
return 0;
|
||||
for (j = 1; (i & 1) == 0; j++)
|
||||
i >>= 1;
|
||||
return j;
|
||||
}
|
||||
1286
nx-X11/programs/Xserver/dix/gc.c
Normal file
1286
nx-X11/programs/Xserver/dix/gc.c
Normal file
File diff suppressed because it is too large
Load Diff
161
nx-X11/programs/Xserver/dix/globals.c
Normal file
161
nx-X11/programs/Xserver/dix/globals.c
Normal file
@@ -0,0 +1,161 @@
|
||||
/************************************************************
|
||||
|
||||
Copyright 1987, 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 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.
|
||||
|
||||
********************************************************/
|
||||
|
||||
|
||||
#ifdef HAVE_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#include <nx-X11/X.h>
|
||||
#include <nx-X11/Xmd.h>
|
||||
#include "misc.h"
|
||||
#include "windowstr.h"
|
||||
#include "scrnintstr.h"
|
||||
#include "input.h"
|
||||
#include "dixfont.h"
|
||||
#include "site.h"
|
||||
#include "dixstruct.h"
|
||||
#include "os.h"
|
||||
|
||||
ScreenInfo screenInfo;
|
||||
KeybdCtrl defaultKeyboardControl = {
|
||||
DEFAULT_KEYBOARD_CLICK,
|
||||
DEFAULT_BELL,
|
||||
DEFAULT_BELL_PITCH,
|
||||
DEFAULT_BELL_DURATION,
|
||||
DEFAULT_AUTOREPEAT,
|
||||
DEFAULT_AUTOREPEATS,
|
||||
DEFAULT_LEDS,
|
||||
0};
|
||||
|
||||
PtrCtrl defaultPointerControl = {
|
||||
DEFAULT_PTR_NUMERATOR,
|
||||
DEFAULT_PTR_DENOMINATOR,
|
||||
DEFAULT_PTR_THRESHOLD,
|
||||
0};
|
||||
|
||||
ClientPtr *clients;
|
||||
ClientPtr serverClient;
|
||||
int currentMaxClients; /* current size of clients array */
|
||||
long maxBigRequestSize = MAX_BIG_REQUEST_SIZE;
|
||||
|
||||
unsigned long globalSerialNumber = 0;
|
||||
unsigned long serverGeneration = 0;
|
||||
|
||||
/* these next four are initialized in main.c */
|
||||
CARD32 ScreenSaverTime;
|
||||
CARD32 ScreenSaverInterval;
|
||||
int ScreenSaverBlanking;
|
||||
int ScreenSaverAllowExposures;
|
||||
|
||||
#ifdef DPMSExtension
|
||||
# ifndef DEFAULT_STANDBY_TIME
|
||||
# define DEFAULT_STANDBY_TIME DEFAULT_SCREEN_SAVER_TIME * 2
|
||||
# endif
|
||||
# ifndef DEFAULT_SUSPEND_TIME
|
||||
# define DEFAULT_SUSPEND_TIME DEFAULT_SCREEN_SAVER_TIME * 3
|
||||
# endif
|
||||
# ifndef DEFAULT_OFF_TIME
|
||||
# define DEFAULT_OFF_TIME DEFAULT_SCREEN_SAVER_TIME * 4
|
||||
# endif
|
||||
# ifndef DEFAULT_DPMS_ENABLED
|
||||
# define DEFAULT_DPMS_ENABLED TRUE
|
||||
# endif
|
||||
CARD32 defaultDPMSStandbyTime = DEFAULT_STANDBY_TIME;
|
||||
CARD32 defaultDPMSSuspendTime = DEFAULT_SUSPEND_TIME;
|
||||
CARD32 defaultDPMSOffTime = DEFAULT_OFF_TIME;
|
||||
CARD16 DPMSPowerLevel = 0;
|
||||
Bool defaultDPMSEnabled = DEFAULT_DPMS_ENABLED;
|
||||
Bool DPMSEnabledSwitch = FALSE; /* these denote the DPMS command */
|
||||
Bool DPMSDisabledSwitch = FALSE; /* line switch states */
|
||||
Bool DPMSCapableFlag = FALSE;
|
||||
CARD32 DPMSStandbyTime;
|
||||
CARD32 DPMSSuspendTime;
|
||||
CARD32 DPMSOffTime;
|
||||
Bool DPMSEnabled;
|
||||
#endif
|
||||
|
||||
CARD32 defaultScreenSaverTime = DEFAULT_SCREEN_SAVER_TIME;
|
||||
CARD32 defaultScreenSaverInterval = DEFAULT_SCREEN_SAVER_INTERVAL;
|
||||
int defaultScreenSaverBlanking = DEFAULT_SCREEN_SAVER_BLANKING;
|
||||
int defaultScreenSaverAllowExposures = DEFAULT_SCREEN_SAVER_EXPOSURES;
|
||||
#ifndef NOLOGOHACK
|
||||
int logoScreenSaver = DEFAULT_LOGO_SCREEN_SAVER;
|
||||
#endif
|
||||
|
||||
#ifdef SCREENSAVER
|
||||
Bool screenSaverSuspended = FALSE;
|
||||
#endif
|
||||
|
||||
char *defaultFontPath = COMPILEDDEFAULTFONTPATH;
|
||||
char *defaultTextFont = COMPILEDDEFAULTFONT;
|
||||
char *defaultCursorFont = COMPILEDCURSORFONT;
|
||||
char *defaultDisplayClass = COMPILEDDISPLAYCLASS;
|
||||
FontPtr defaultFont; /* not declared in dix.h to avoid including font.h in
|
||||
every compilation of dix code */
|
||||
Bool loadableFonts = FALSE;
|
||||
CursorPtr rootCursor;
|
||||
Bool blackRoot=FALSE;
|
||||
Bool whiteRoot=FALSE;
|
||||
|
||||
TimeStamp currentTime;
|
||||
TimeStamp lastDeviceEventTime;
|
||||
|
||||
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;
|
||||
195
nx-X11/programs/Xserver/dix/glyphcurs.c
Normal file
195
nx-X11/programs/Xserver/dix/glyphcurs.c
Normal file
@@ -0,0 +1,195 @@
|
||||
/************************************************************************
|
||||
|
||||
Copyright 1987, 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 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.
|
||||
|
||||
************************************************************************/
|
||||
|
||||
|
||||
#ifdef HAVE_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#include "misc.h"
|
||||
#include <X11/fonts/fontstruct.h>
|
||||
#include "dixfontstr.h"
|
||||
#include "scrnintstr.h"
|
||||
#include "gcstruct.h"
|
||||
#include "resource.h"
|
||||
#include "dix.h"
|
||||
#include "cursorstr.h"
|
||||
#include "opaque.h"
|
||||
#include "servermd.h"
|
||||
|
||||
|
||||
/*
|
||||
get the bits out of the font in a portable way. to avoid
|
||||
dealing with padding and such-like, we draw the glyph into
|
||||
a bitmap, then read the bits out with GetImage, which
|
||||
uses server-natural format.
|
||||
since all screens return the same bitmap format, we'll just use
|
||||
the first one we find.
|
||||
the character origin lines up with the hotspot in the
|
||||
cursor metrics.
|
||||
*/
|
||||
|
||||
#ifndef NXAGENT_SERVER
|
||||
int
|
||||
ServerBitsFromGlyph(FontPtr pfont, unsigned ch, register CursorMetricPtr cm, unsigned char **ppbits)
|
||||
{
|
||||
register ScreenPtr pScreen;
|
||||
register GCPtr pGC;
|
||||
xRectangle rect;
|
||||
PixmapPtr ppix;
|
||||
long nby;
|
||||
char *pbits;
|
||||
ChangeGCVal gcval[3];
|
||||
unsigned char char2b[2];
|
||||
|
||||
/* turn glyph index into a protocol-format char2b */
|
||||
char2b[0] = (unsigned char)(ch >> 8);
|
||||
char2b[1] = (unsigned char)(ch & 0xff);
|
||||
|
||||
pScreen = screenInfo.screens[0];
|
||||
nby = BitmapBytePad(cm->width) * (long)cm->height;
|
||||
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,
|
||||
CREATE_PIXMAP_USAGE_SCRATCH);
|
||||
pGC = GetScratchGC(1, pScreen);
|
||||
if (!ppix || !pGC)
|
||||
{
|
||||
if (ppix)
|
||||
(*pScreen->DestroyPixmap)(ppix);
|
||||
if (pGC)
|
||||
FreeScratchGC(pGC);
|
||||
free(pbits);
|
||||
return BadAlloc;
|
||||
}
|
||||
|
||||
rect.x = 0;
|
||||
rect.y = 0;
|
||||
rect.width = cm->width;
|
||||
rect.height = cm->height;
|
||||
|
||||
/* fill the pixmap with 0 */
|
||||
gcval[0].val = GXcopy;
|
||||
gcval[1].val = 0;
|
||||
gcval[2].ptr = (void *)pfont;
|
||||
dixChangeGC(NullClient, pGC, GCFunction | GCForeground | GCFont,
|
||||
NULL, gcval);
|
||||
ValidateGC((DrawablePtr)ppix, pGC);
|
||||
(*pGC->ops->PolyFillRect)((DrawablePtr)ppix, pGC, 1, &rect);
|
||||
|
||||
/* draw the glyph */
|
||||
gcval[0].val = 1;
|
||||
dixChangeGC(NullClient, pGC, GCForeground, NULL, gcval);
|
||||
ValidateGC((DrawablePtr)ppix, pGC);
|
||||
(*pGC->ops->PolyText16)((DrawablePtr)ppix, pGC, cm->xhot, cm->yhot,
|
||||
1, (unsigned short *)char2b);
|
||||
(*pScreen->GetImage)((DrawablePtr)ppix, 0, 0, cm->width, cm->height,
|
||||
XYPixmap, 1, pbits);
|
||||
*ppbits = (unsigned char *)pbits;
|
||||
FreeScratchGC(pGC);
|
||||
(*pScreen->DestroyPixmap)(ppix);
|
||||
return Success;
|
||||
}
|
||||
#endif /* NXAGENT_SERVER */
|
||||
|
||||
Bool
|
||||
CursorMetricsFromGlyph(register FontPtr pfont, unsigned ch, register CursorMetricPtr cm)
|
||||
{
|
||||
CharInfoPtr pci;
|
||||
unsigned long nglyphs;
|
||||
CARD8 chs[2];
|
||||
FontEncoding encoding;
|
||||
|
||||
chs[0] = ch >> 8;
|
||||
chs[1] = ch;
|
||||
encoding = (FONTLASTROW(pfont) == 0) ? Linear16Bit : TwoD16Bit;
|
||||
if (encoding == Linear16Bit)
|
||||
{
|
||||
if (ch < pfont->info.firstCol || pfont->info.lastCol < ch)
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (chs[0] < pfont->info.firstRow || pfont->info.lastRow < chs[0])
|
||||
return FALSE;
|
||||
if (chs[1] < pfont->info.firstCol || pfont->info.lastCol < chs[1])
|
||||
return FALSE;
|
||||
}
|
||||
(*pfont->get_glyphs) (pfont, 1, chs, encoding, &nglyphs, &pci);
|
||||
if (nglyphs == 0)
|
||||
return FALSE;
|
||||
cm->width = pci->metrics.rightSideBearing - pci->metrics.leftSideBearing;
|
||||
cm->height = pci->metrics.descent + pci->metrics.ascent;
|
||||
if (pci->metrics.leftSideBearing > 0)
|
||||
{
|
||||
cm->width += pci->metrics.leftSideBearing;
|
||||
cm->xhot = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
cm->xhot = -pci->metrics.leftSideBearing;
|
||||
if (pci->metrics.rightSideBearing < 0)
|
||||
cm->width -= pci->metrics.rightSideBearing;
|
||||
}
|
||||
if (pci->metrics.ascent < 0)
|
||||
{
|
||||
cm->height -= pci->metrics.ascent;
|
||||
cm->yhot = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
cm->yhot = pci->metrics.ascent;
|
||||
if (pci->metrics.descent < 0)
|
||||
cm->height -= pci->metrics.descent;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
435
nx-X11/programs/Xserver/dix/grabs.c
Normal file
435
nx-X11/programs/Xserver/dix/grabs.c
Normal file
@@ -0,0 +1,435 @@
|
||||
/*
|
||||
|
||||
Copyright 1987, 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 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.
|
||||
|
||||
*/
|
||||
|
||||
#ifdef HAVE_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#include <nx-X11/X.h>
|
||||
#include "misc.h"
|
||||
#include <nx-X11/Xproto.h>
|
||||
#include "windowstr.h"
|
||||
#include "inputstr.h"
|
||||
#include "cursorstr.h"
|
||||
#include "dixgrabs.h"
|
||||
|
||||
#define BITMASK(i) (((Mask)1) << ((i) & 31))
|
||||
#define MASKIDX(i) ((i) >> 5)
|
||||
#define MASKWORD(buf, i) buf[MASKIDX(i)]
|
||||
#define BITSET(buf, i) MASKWORD(buf, i) |= BITMASK(i)
|
||||
#define BITCLEAR(buf, i) MASKWORD(buf, i) &= ~BITMASK(i)
|
||||
#define GETBIT(buf, i) (MASKWORD(buf, i) & BITMASK(i))
|
||||
|
||||
GrabPtr
|
||||
CreateGrab(
|
||||
int client,
|
||||
DeviceIntPtr device,
|
||||
WindowPtr window,
|
||||
Mask eventMask,
|
||||
Bool ownerEvents, Bool keyboardMode, Bool pointerMode,
|
||||
DeviceIntPtr modDevice,
|
||||
unsigned short modifiers,
|
||||
int type,
|
||||
KeyCode keybut, /* key or button */
|
||||
WindowPtr confineTo,
|
||||
CursorPtr cursor)
|
||||
{
|
||||
GrabPtr grab;
|
||||
|
||||
grab = (GrabPtr)malloc(sizeof(GrabRec));
|
||||
if (!grab)
|
||||
return (GrabPtr)NULL;
|
||||
grab->resource = FakeClientID(client);
|
||||
grab->device = device;
|
||||
grab->coreGrab = ((device == inputInfo.keyboard) ||
|
||||
(device == inputInfo.pointer));
|
||||
grab->window = window;
|
||||
grab->eventMask = eventMask;
|
||||
grab->ownerEvents = ownerEvents;
|
||||
grab->keyboardMode = keyboardMode;
|
||||
grab->pointerMode = pointerMode;
|
||||
grab->modifiersDetail.exact = modifiers;
|
||||
grab->modifiersDetail.pMask = NULL;
|
||||
grab->modifierDevice = modDevice;
|
||||
grab->coreMods = ((modDevice == inputInfo.keyboard) ||
|
||||
(modDevice == inputInfo.pointer));
|
||||
grab->type = type;
|
||||
grab->detail.exact = keybut;
|
||||
grab->detail.pMask = NULL;
|
||||
grab->confineTo = confineTo;
|
||||
grab->cursor = cursor;
|
||||
if (cursor)
|
||||
cursor->refcnt++;
|
||||
return grab;
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
FreeGrab(GrabPtr pGrab)
|
||||
{
|
||||
if (pGrab->modifiersDetail.pMask != NULL)
|
||||
free(pGrab->modifiersDetail.pMask);
|
||||
|
||||
if (pGrab->detail.pMask != NULL)
|
||||
free(pGrab->detail.pMask);
|
||||
|
||||
if (pGrab->cursor)
|
||||
FreeCursor(pGrab->cursor, (Cursor)0);
|
||||
|
||||
free(pGrab);
|
||||
}
|
||||
|
||||
int
|
||||
DeletePassiveGrab(void * value, XID id)
|
||||
{
|
||||
register GrabPtr g, prev;
|
||||
GrabPtr pGrab = (GrabPtr)value;
|
||||
|
||||
/* it is OK if the grab isn't found */
|
||||
prev = 0;
|
||||
for (g = (wPassiveGrabs (pGrab->window)); g; g = g->next)
|
||||
{
|
||||
if (pGrab == g)
|
||||
{
|
||||
if (prev)
|
||||
prev->next = g->next;
|
||||
else
|
||||
if (!(pGrab->window->optional->passiveGrabs = g->next))
|
||||
CheckWindowOptionalNeed (pGrab->window);
|
||||
break;
|
||||
}
|
||||
prev = g;
|
||||
}
|
||||
FreeGrab(pGrab);
|
||||
return Success;
|
||||
}
|
||||
|
||||
static Mask *
|
||||
DeleteDetailFromMask(Mask *pDetailMask, unsigned short detail)
|
||||
{
|
||||
register Mask *mask;
|
||||
register int i;
|
||||
|
||||
mask = (Mask *)malloc(sizeof(Mask) * MasksPerDetailMask);
|
||||
if (mask)
|
||||
{
|
||||
if (pDetailMask)
|
||||
for (i = 0; i < MasksPerDetailMask; i++)
|
||||
mask[i]= pDetailMask[i];
|
||||
else
|
||||
for (i = 0; i < MasksPerDetailMask; i++)
|
||||
mask[i]= ~0L;
|
||||
BITCLEAR(mask, detail);
|
||||
}
|
||||
return mask;
|
||||
}
|
||||
|
||||
static Bool
|
||||
IsInGrabMask(
|
||||
DetailRec firstDetail,
|
||||
DetailRec secondDetail,
|
||||
unsigned short exception)
|
||||
{
|
||||
if (firstDetail.exact == exception)
|
||||
{
|
||||
if (firstDetail.pMask == NULL)
|
||||
return TRUE;
|
||||
|
||||
/* (at present) never called with two non-null pMasks */
|
||||
if (secondDetail.exact == exception)
|
||||
return FALSE;
|
||||
|
||||
if (GETBIT(firstDetail.pMask, secondDetail.exact))
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static Bool
|
||||
IdenticalExactDetails(
|
||||
unsigned short firstExact,
|
||||
unsigned short secondExact,
|
||||
unsigned short exception)
|
||||
{
|
||||
if ((firstExact == exception) || (secondExact == exception))
|
||||
return FALSE;
|
||||
|
||||
if (firstExact == secondExact)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static Bool
|
||||
DetailSupersedesSecond(
|
||||
DetailRec firstDetail,
|
||||
DetailRec secondDetail,
|
||||
unsigned short exception)
|
||||
{
|
||||
if (IsInGrabMask(firstDetail, secondDetail, exception))
|
||||
return TRUE;
|
||||
|
||||
if (IdenticalExactDetails(firstDetail.exact, secondDetail.exact,
|
||||
exception))
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static Bool
|
||||
GrabSupersedesSecond(GrabPtr pFirstGrab, GrabPtr pSecondGrab)
|
||||
{
|
||||
if (!DetailSupersedesSecond(pFirstGrab->modifiersDetail,
|
||||
pSecondGrab->modifiersDetail,
|
||||
(unsigned short)AnyModifier))
|
||||
return FALSE;
|
||||
|
||||
if (DetailSupersedesSecond(pFirstGrab->detail,
|
||||
pSecondGrab->detail, (unsigned short)AnyKey))
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Bool
|
||||
GrabMatchesSecond(GrabPtr pFirstGrab, GrabPtr pSecondGrab)
|
||||
{
|
||||
if ((pFirstGrab->device != pSecondGrab->device) ||
|
||||
(pFirstGrab->modifierDevice != pSecondGrab->modifierDevice) ||
|
||||
(pFirstGrab->type != pSecondGrab->type))
|
||||
return FALSE;
|
||||
|
||||
if (GrabSupersedesSecond(pFirstGrab, pSecondGrab) ||
|
||||
GrabSupersedesSecond(pSecondGrab, pFirstGrab))
|
||||
return TRUE;
|
||||
|
||||
if (DetailSupersedesSecond(pSecondGrab->detail, pFirstGrab->detail,
|
||||
(unsigned short)AnyKey)
|
||||
&&
|
||||
DetailSupersedesSecond(pFirstGrab->modifiersDetail,
|
||||
pSecondGrab->modifiersDetail,
|
||||
(unsigned short)AnyModifier))
|
||||
return TRUE;
|
||||
|
||||
if (DetailSupersedesSecond(pFirstGrab->detail, pSecondGrab->detail,
|
||||
(unsigned short)AnyKey)
|
||||
&&
|
||||
DetailSupersedesSecond(pSecondGrab->modifiersDetail,
|
||||
pFirstGrab->modifiersDetail,
|
||||
(unsigned short)AnyModifier))
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int
|
||||
AddPassiveGrabToList(GrabPtr pGrab)
|
||||
{
|
||||
GrabPtr grab;
|
||||
|
||||
for (grab = wPassiveGrabs(pGrab->window); grab; grab = grab->next)
|
||||
{
|
||||
if (GrabMatchesSecond(pGrab, grab))
|
||||
{
|
||||
if (CLIENT_BITS(pGrab->resource) != CLIENT_BITS(grab->resource))
|
||||
{
|
||||
FreeGrab(pGrab);
|
||||
return BadAccess;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!pGrab->window->optional && !MakeWindowOptional (pGrab->window))
|
||||
{
|
||||
FreeGrab(pGrab);
|
||||
return BadAlloc;
|
||||
}
|
||||
pGrab->next = pGrab->window->optional->passiveGrabs;
|
||||
pGrab->window->optional->passiveGrabs = pGrab;
|
||||
if (AddResource(pGrab->resource, RT_PASSIVEGRAB, (void *)pGrab))
|
||||
return Success;
|
||||
return BadAlloc;
|
||||
}
|
||||
|
||||
/* the following is kinda complicated, because we need to be able to back out
|
||||
* if any allocation fails
|
||||
*/
|
||||
|
||||
Bool
|
||||
DeletePassiveGrabFromList(GrabPtr pMinuendGrab)
|
||||
{
|
||||
register GrabPtr grab;
|
||||
GrabPtr *deletes, *adds;
|
||||
Mask ***updates, **details;
|
||||
int i, ndels, nadds, nups;
|
||||
Bool ok;
|
||||
|
||||
#define UPDATE(mask,exact) \
|
||||
if (!(details[nups] = DeleteDetailFromMask(mask, exact))) \
|
||||
ok = FALSE; \
|
||||
else \
|
||||
updates[nups++] = &(mask)
|
||||
|
||||
i = 0;
|
||||
for (grab = wPassiveGrabs(pMinuendGrab->window); grab; grab = grab->next)
|
||||
i++;
|
||||
if (!i)
|
||||
return TRUE;
|
||||
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) free(details);
|
||||
if (updates) free(updates);
|
||||
if (adds) free(adds);
|
||||
if (deletes) free(deletes);
|
||||
return FALSE;
|
||||
}
|
||||
ndels = nadds = nups = 0;
|
||||
ok = TRUE;
|
||||
for (grab = wPassiveGrabs(pMinuendGrab->window);
|
||||
grab && ok;
|
||||
grab = grab->next)
|
||||
{
|
||||
if ((CLIENT_BITS(grab->resource) != CLIENT_BITS(pMinuendGrab->resource)) ||
|
||||
!GrabMatchesSecond(grab, pMinuendGrab))
|
||||
continue;
|
||||
if (GrabSupersedesSecond(pMinuendGrab, grab))
|
||||
{
|
||||
deletes[ndels++] = grab;
|
||||
}
|
||||
else if ((grab->detail.exact == AnyKey)
|
||||
&& (grab->modifiersDetail.exact != AnyModifier))
|
||||
{
|
||||
UPDATE(grab->detail.pMask, pMinuendGrab->detail.exact);
|
||||
}
|
||||
else if ((grab->modifiersDetail.exact == AnyModifier)
|
||||
&& (grab->detail.exact != AnyKey))
|
||||
{
|
||||
UPDATE(grab->modifiersDetail.pMask,
|
||||
pMinuendGrab->modifiersDetail.exact);
|
||||
}
|
||||
else if ((pMinuendGrab->detail.exact != AnyKey)
|
||||
&& (pMinuendGrab->modifiersDetail.exact != AnyModifier))
|
||||
{
|
||||
GrabPtr pNewGrab;
|
||||
|
||||
UPDATE(grab->detail.pMask, pMinuendGrab->detail.exact);
|
||||
|
||||
pNewGrab = CreateGrab(CLIENT_ID(grab->resource), grab->device,
|
||||
grab->window, (Mask)grab->eventMask,
|
||||
(Bool)grab->ownerEvents,
|
||||
(Bool)grab->keyboardMode,
|
||||
(Bool)grab->pointerMode,
|
||||
grab->modifierDevice,
|
||||
AnyModifier, (int)grab->type,
|
||||
pMinuendGrab->detail.exact,
|
||||
grab->confineTo, grab->cursor);
|
||||
if (!pNewGrab)
|
||||
ok = FALSE;
|
||||
else if (!(pNewGrab->modifiersDetail.pMask =
|
||||
DeleteDetailFromMask(grab->modifiersDetail.pMask,
|
||||
pMinuendGrab->modifiersDetail.exact))
|
||||
||
|
||||
(!pNewGrab->window->optional &&
|
||||
!MakeWindowOptional(pNewGrab->window)))
|
||||
{
|
||||
FreeGrab(pNewGrab);
|
||||
ok = FALSE;
|
||||
}
|
||||
else if (!AddResource(pNewGrab->resource, RT_PASSIVEGRAB,
|
||||
(void *)pNewGrab))
|
||||
ok = FALSE;
|
||||
else
|
||||
adds[nadds++] = pNewGrab;
|
||||
}
|
||||
else if (pMinuendGrab->detail.exact == AnyKey)
|
||||
{
|
||||
UPDATE(grab->modifiersDetail.pMask,
|
||||
pMinuendGrab->modifiersDetail.exact);
|
||||
}
|
||||
else
|
||||
{
|
||||
UPDATE(grab->detail.pMask, pMinuendGrab->detail.exact);
|
||||
}
|
||||
}
|
||||
|
||||
if (!ok)
|
||||
{
|
||||
for (i = 0; i < nadds; i++)
|
||||
FreeResource(adds[i]->resource, RT_NONE);
|
||||
for (i = 0; i < nups; i++)
|
||||
free(details[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < ndels; i++)
|
||||
FreeResource(deletes[i]->resource, RT_NONE);
|
||||
for (i = 0; i < nadds; i++)
|
||||
{
|
||||
grab = adds[i];
|
||||
grab->next = grab->window->optional->passiveGrabs;
|
||||
grab->window->optional->passiveGrabs = grab;
|
||||
}
|
||||
for (i = 0; i < nups; i++)
|
||||
{
|
||||
free(*updates[i]);
|
||||
*updates[i] = details[i];
|
||||
}
|
||||
}
|
||||
free(details);
|
||||
free(updates);
|
||||
free(adds);
|
||||
free(deletes);
|
||||
return ok;
|
||||
|
||||
#undef UPDATE
|
||||
}
|
||||
84
nx-X11/programs/Xserver/dix/initatoms.c
Normal file
84
nx-X11/programs/Xserver/dix/initatoms.c
Normal file
@@ -0,0 +1,84 @@
|
||||
/* THIS IS A GENERATED FILE
|
||||
*
|
||||
* Do not change! Changing this file implies a protocol change!
|
||||
*/
|
||||
|
||||
#ifdef HAVE_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#include <nx-X11/X.h>
|
||||
#include <nx-X11/Xatom.h>
|
||||
#include "misc.h"
|
||||
#include "dix.h"
|
||||
void MakePredeclaredAtoms()
|
||||
{
|
||||
if (MakeAtom("PRIMARY", 7, 1) != XA_PRIMARY) AtomError();
|
||||
if (MakeAtom("SECONDARY", 9, 1) != XA_SECONDARY) AtomError();
|
||||
if (MakeAtom("ARC", 3, 1) != XA_ARC) AtomError();
|
||||
if (MakeAtom("ATOM", 4, 1) != XA_ATOM) AtomError();
|
||||
if (MakeAtom("BITMAP", 6, 1) != XA_BITMAP) AtomError();
|
||||
if (MakeAtom("CARDINAL", 8, 1) != XA_CARDINAL) AtomError();
|
||||
if (MakeAtom("COLORMAP", 8, 1) != XA_COLORMAP) AtomError();
|
||||
if (MakeAtom("CURSOR", 6, 1) != XA_CURSOR) AtomError();
|
||||
if (MakeAtom("CUT_BUFFER0", 11, 1) != XA_CUT_BUFFER0) AtomError();
|
||||
if (MakeAtom("CUT_BUFFER1", 11, 1) != XA_CUT_BUFFER1) AtomError();
|
||||
if (MakeAtom("CUT_BUFFER2", 11, 1) != XA_CUT_BUFFER2) AtomError();
|
||||
if (MakeAtom("CUT_BUFFER3", 11, 1) != XA_CUT_BUFFER3) AtomError();
|
||||
if (MakeAtom("CUT_BUFFER4", 11, 1) != XA_CUT_BUFFER4) AtomError();
|
||||
if (MakeAtom("CUT_BUFFER5", 11, 1) != XA_CUT_BUFFER5) AtomError();
|
||||
if (MakeAtom("CUT_BUFFER6", 11, 1) != XA_CUT_BUFFER6) AtomError();
|
||||
if (MakeAtom("CUT_BUFFER7", 11, 1) != XA_CUT_BUFFER7) AtomError();
|
||||
if (MakeAtom("DRAWABLE", 8, 1) != XA_DRAWABLE) AtomError();
|
||||
if (MakeAtom("FONT", 4, 1) != XA_FONT) AtomError();
|
||||
if (MakeAtom("INTEGER", 7, 1) != XA_INTEGER) AtomError();
|
||||
if (MakeAtom("PIXMAP", 6, 1) != XA_PIXMAP) AtomError();
|
||||
if (MakeAtom("POINT", 5, 1) != XA_POINT) AtomError();
|
||||
if (MakeAtom("RECTANGLE", 9, 1) != XA_RECTANGLE) AtomError();
|
||||
if (MakeAtom("RESOURCE_MANAGER", 16, 1) != XA_RESOURCE_MANAGER) AtomError();
|
||||
if (MakeAtom("RGB_COLOR_MAP", 13, 1) != XA_RGB_COLOR_MAP) AtomError();
|
||||
if (MakeAtom("RGB_BEST_MAP", 12, 1) != XA_RGB_BEST_MAP) AtomError();
|
||||
if (MakeAtom("RGB_BLUE_MAP", 12, 1) != XA_RGB_BLUE_MAP) AtomError();
|
||||
if (MakeAtom("RGB_DEFAULT_MAP", 15, 1) != XA_RGB_DEFAULT_MAP) AtomError();
|
||||
if (MakeAtom("RGB_GRAY_MAP", 12, 1) != XA_RGB_GRAY_MAP) AtomError();
|
||||
if (MakeAtom("RGB_GREEN_MAP", 13, 1) != XA_RGB_GREEN_MAP) AtomError();
|
||||
if (MakeAtom("RGB_RED_MAP", 11, 1) != XA_RGB_RED_MAP) AtomError();
|
||||
if (MakeAtom("STRING", 6, 1) != XA_STRING) AtomError();
|
||||
if (MakeAtom("VISUALID", 8, 1) != XA_VISUALID) AtomError();
|
||||
if (MakeAtom("WINDOW", 6, 1) != XA_WINDOW) AtomError();
|
||||
if (MakeAtom("WM_COMMAND", 10, 1) != XA_WM_COMMAND) AtomError();
|
||||
if (MakeAtom("WM_HINTS", 8, 1) != XA_WM_HINTS) AtomError();
|
||||
if (MakeAtom("WM_CLIENT_MACHINE", 17, 1) != XA_WM_CLIENT_MACHINE) AtomError();
|
||||
if (MakeAtom("WM_ICON_NAME", 12, 1) != XA_WM_ICON_NAME) AtomError();
|
||||
if (MakeAtom("WM_ICON_SIZE", 12, 1) != XA_WM_ICON_SIZE) AtomError();
|
||||
if (MakeAtom("WM_NAME", 7, 1) != XA_WM_NAME) AtomError();
|
||||
if (MakeAtom("WM_NORMAL_HINTS", 15, 1) != XA_WM_NORMAL_HINTS) AtomError();
|
||||
if (MakeAtom("WM_SIZE_HINTS", 13, 1) != XA_WM_SIZE_HINTS) AtomError();
|
||||
if (MakeAtom("WM_ZOOM_HINTS", 13, 1) != XA_WM_ZOOM_HINTS) AtomError();
|
||||
if (MakeAtom("MIN_SPACE", 9, 1) != XA_MIN_SPACE) AtomError();
|
||||
if (MakeAtom("NORM_SPACE", 10, 1) != XA_NORM_SPACE) AtomError();
|
||||
if (MakeAtom("MAX_SPACE", 9, 1) != XA_MAX_SPACE) AtomError();
|
||||
if (MakeAtom("END_SPACE", 9, 1) != XA_END_SPACE) AtomError();
|
||||
if (MakeAtom("SUPERSCRIPT_X", 13, 1) != XA_SUPERSCRIPT_X) AtomError();
|
||||
if (MakeAtom("SUPERSCRIPT_Y", 13, 1) != XA_SUPERSCRIPT_Y) AtomError();
|
||||
if (MakeAtom("SUBSCRIPT_X", 11, 1) != XA_SUBSCRIPT_X) AtomError();
|
||||
if (MakeAtom("SUBSCRIPT_Y", 11, 1) != XA_SUBSCRIPT_Y) AtomError();
|
||||
if (MakeAtom("UNDERLINE_POSITION", 18, 1) != XA_UNDERLINE_POSITION) AtomError();
|
||||
if (MakeAtom("UNDERLINE_THICKNESS", 19, 1) != XA_UNDERLINE_THICKNESS) AtomError();
|
||||
if (MakeAtom("STRIKEOUT_ASCENT", 16, 1) != XA_STRIKEOUT_ASCENT) AtomError();
|
||||
if (MakeAtom("STRIKEOUT_DESCENT", 17, 1) != XA_STRIKEOUT_DESCENT) AtomError();
|
||||
if (MakeAtom("ITALIC_ANGLE", 12, 1) != XA_ITALIC_ANGLE) AtomError();
|
||||
if (MakeAtom("X_HEIGHT", 8, 1) != XA_X_HEIGHT) AtomError();
|
||||
if (MakeAtom("QUAD_WIDTH", 10, 1) != XA_QUAD_WIDTH) AtomError();
|
||||
if (MakeAtom("WEIGHT", 6, 1) != XA_WEIGHT) AtomError();
|
||||
if (MakeAtom("POINT_SIZE", 10, 1) != XA_POINT_SIZE) AtomError();
|
||||
if (MakeAtom("RESOLUTION", 10, 1) != XA_RESOLUTION) AtomError();
|
||||
if (MakeAtom("COPYRIGHT", 9, 1) != XA_COPYRIGHT) AtomError();
|
||||
if (MakeAtom("NOTICE", 6, 1) != XA_NOTICE) AtomError();
|
||||
if (MakeAtom("FONT_NAME", 9, 1) != XA_FONT_NAME) AtomError();
|
||||
if (MakeAtom("FAMILY_NAME", 11, 1) != XA_FAMILY_NAME) AtomError();
|
||||
if (MakeAtom("FULL_NAME", 9, 1) != XA_FULL_NAME) AtomError();
|
||||
if (MakeAtom("CAP_HEIGHT", 10, 1) != XA_CAP_HEIGHT) AtomError();
|
||||
if (MakeAtom("WM_CLASS", 8, 1) != XA_WM_CLASS) AtomError();
|
||||
if (MakeAtom("WM_TRANSIENT_FOR", 16, 1) != XA_WM_TRANSIENT_FOR) AtomError();
|
||||
}
|
||||
570
nx-X11/programs/Xserver/dix/main.c
Normal file
570
nx-X11/programs/Xserver/dix/main.c
Normal file
@@ -0,0 +1,570 @@
|
||||
/***********************************************************
|
||||
|
||||
Copyright 1987, 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 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.
|
||||
|
||||
******************************************************************/
|
||||
|
||||
/* $TOG: main.c /main/86 1998/02/09 14:20:03 kaleb $ */
|
||||
|
||||
#ifdef HAVE_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#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"
|
||||
#include "windowstr.h"
|
||||
#include "resource.h"
|
||||
#include "dixstruct.h"
|
||||
#include "gcstruct.h"
|
||||
#include "extension.h"
|
||||
#include "colormap.h"
|
||||
#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"
|
||||
#include "client.h"
|
||||
#ifdef PANORAMIX
|
||||
#include "panoramiXsrv.h"
|
||||
#else
|
||||
#include "dixevents.h" /* InitEvents() */
|
||||
#include "dispatch.h" /* InitProcVectors() */
|
||||
#endif
|
||||
|
||||
#ifdef DPMSExtension
|
||||
#define DPMS_SERVER
|
||||
#include <nx-X11/extensions/dpms.h>
|
||||
#include "dpmsproc.h"
|
||||
#endif
|
||||
|
||||
extern int InitClientPrivates(ClientPtr client);
|
||||
|
||||
extern void Dispatch(void);
|
||||
|
||||
xConnSetupPrefix connSetupPrefix;
|
||||
|
||||
extern FontPtr defaultFont;
|
||||
|
||||
extern void InitProcVectors(void);
|
||||
extern Bool CreateGCperDepthArray(void);
|
||||
|
||||
extern void FreeScreen(ScreenPtr pScreen);
|
||||
|
||||
#ifndef PANORAMIX
|
||||
static
|
||||
#endif
|
||||
Bool CreateConnectionBlock(void);
|
||||
|
||||
PaddingInfo PixmapWidthPaddingInfo[33];
|
||||
|
||||
int connBlockScreenStart;
|
||||
|
||||
static int restart = 0;
|
||||
|
||||
void
|
||||
NotImplemented(xEvent *from, xEvent *to)
|
||||
{
|
||||
FatalError("Not implemented");
|
||||
}
|
||||
|
||||
/*
|
||||
* Dummy entry for ReplySwapVector[]
|
||||
*/
|
||||
|
||||
void
|
||||
ReplyNotSwappd(
|
||||
ClientPtr pClient ,
|
||||
int size ,
|
||||
void * pbuf
|
||||
)
|
||||
{
|
||||
FatalError("Not implemented");
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[], char *envp[])
|
||||
{
|
||||
int i;
|
||||
char *xauthfile;
|
||||
HWEventQueueType alwaysCheckForInput[2];
|
||||
|
||||
display = "0";
|
||||
|
||||
InitGlobals();
|
||||
|
||||
/* 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
|
||||
* from another thread. */
|
||||
#if defined(__DARWIN__) && defined(DARWIN_WITH_QUARTZ)
|
||||
DarwinHandleGUI(argc, argv, envp);
|
||||
#endif
|
||||
|
||||
/* Notice if we're restarted. Probably this is because we jumped through
|
||||
* an uninitialized pointer */
|
||||
if (restart)
|
||||
FatalError("server restarted. Jumped through uninitialized pointer?\n");
|
||||
else
|
||||
restart = 1;
|
||||
|
||||
CheckUserParameters(argc, argv, envp);
|
||||
|
||||
CheckUserAuthorization();
|
||||
|
||||
#ifdef COMMANDLINE_CHALLENGED_OPERATING_SYSTEMS
|
||||
ExpandCommandLine(&argc, &argv);
|
||||
#endif
|
||||
|
||||
InitConnectionLimits();
|
||||
|
||||
/* These are needed by some routines which are called from interrupt
|
||||
* handlers, thus have no direct calling path back to main and thus
|
||||
* can't be passed argc, argv as parameters */
|
||||
argcGlobal = argc;
|
||||
argvGlobal = argv;
|
||||
/* prep X authority file from environment; this can be overriden by a
|
||||
* command line option */
|
||||
xauthfile = getenv("XAUTHORITY");
|
||||
if (xauthfile) InitAuthorization (xauthfile);
|
||||
ProcessCommandLine(argc, argv);
|
||||
|
||||
alwaysCheckForInput[0] = 0;
|
||||
alwaysCheckForInput[1] = 1;
|
||||
while(1)
|
||||
{
|
||||
serverGeneration++;
|
||||
ScreenSaverTime = defaultScreenSaverTime;
|
||||
ScreenSaverInterval = defaultScreenSaverInterval;
|
||||
ScreenSaverBlanking = defaultScreenSaverBlanking;
|
||||
ScreenSaverAllowExposures = defaultScreenSaverAllowExposures;
|
||||
#ifdef DPMSExtension
|
||||
DPMSStandbyTime = defaultDPMSStandbyTime;
|
||||
DPMSSuspendTime = defaultDPMSSuspendTime;
|
||||
DPMSOffTime = defaultDPMSOffTime;
|
||||
DPMSEnabled = defaultDPMSEnabled;
|
||||
DPMSPowerLevel = 0;
|
||||
#endif
|
||||
InitBlockAndWakeupHandlers();
|
||||
/* Perform any operating system dependent initializations you'd like */
|
||||
OsInit();
|
||||
if(serverGeneration == 1)
|
||||
{
|
||||
CreateWellKnownSockets();
|
||||
InitProcVectors();
|
||||
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)malloc(sizeof(ClientRec));
|
||||
if (!serverClient)
|
||||
FatalError("couldn't create server client");
|
||||
InitClient(serverClient, 0, (void *)NULL);
|
||||
}
|
||||
else
|
||||
ResetWellKnownSockets ();
|
||||
clients[0] = serverClient;
|
||||
currentMaxClients = 1;
|
||||
|
||||
if (!InitClientResources(serverClient)) /* for root resources */
|
||||
FatalError("couldn't init server resources");
|
||||
|
||||
SetInputCheck(&alwaysCheckForInput[0], &alwaysCheckForInput[1]);
|
||||
screenInfo.arraySize = MAXSCREENS;
|
||||
screenInfo.numScreens = 0;
|
||||
|
||||
InitAtoms();
|
||||
InitEvents();
|
||||
#ifdef HAS_XFONT2
|
||||
xfont2_init_glyph_caching();
|
||||
#else
|
||||
InitGlyphCaching();
|
||||
#endif /* of HAS_XFONT2 */
|
||||
ResetExtensionPrivates();
|
||||
ResetClientPrivates();
|
||||
ResetScreenPrivates();
|
||||
ResetWindowPrivates();
|
||||
ResetGCPrivates();
|
||||
#ifdef PIXPRIV
|
||||
ResetPixmapPrivates();
|
||||
#endif
|
||||
ResetColormapPrivates();
|
||||
ResetDevicePrivateIndex();
|
||||
InitFonts();
|
||||
InitCallbackManager();
|
||||
InitVisualWrap();
|
||||
InitOutput(&screenInfo, argc, argv);
|
||||
|
||||
if (screenInfo.numScreens < 1)
|
||||
FatalError("no screens found");
|
||||
InitExtensions(argc, argv);
|
||||
if (!InitClientPrivates(serverClient))
|
||||
FatalError("failed to allocate serverClient devprivates");
|
||||
for (i = 0; i < screenInfo.numScreens; i++)
|
||||
{
|
||||
ScreenPtr pScreen = screenInfo.screens[i];
|
||||
if (!CreateScratchPixmapsForScreen(i))
|
||||
FatalError("failed to create scratch pixmaps");
|
||||
if (pScreen->CreateScreenResources &&
|
||||
!(*pScreen->CreateScreenResources)(pScreen))
|
||||
FatalError("failed to create screen resources");
|
||||
if (!CreateGCperDepth(i))
|
||||
FatalError("failed to create scratch GCs");
|
||||
if (!CreateDefaultStipple(i))
|
||||
FatalError("failed to create default stipple");
|
||||
if (!CreateRootWindow(pScreen))
|
||||
FatalError("failed to create root window");
|
||||
}
|
||||
InitInput(argc, argv);
|
||||
if (InitAndStartDevices() != Success)
|
||||
FatalError("failed to initialize core devices");
|
||||
ReserveClientIds(serverClient);
|
||||
|
||||
if (loadableFonts) {
|
||||
SetFontPath(serverClient, 0, (unsigned char *)defaultFontPath);
|
||||
} else {
|
||||
if (SetDefaultFontPath(defaultFontPath) != Success)
|
||||
ErrorF("failed to set default font path '%s'\n",
|
||||
defaultFontPath);
|
||||
}
|
||||
if (!SetDefaultFont(defaultTextFont))
|
||||
FatalError("could not open default font '%s'", defaultTextFont);
|
||||
if (!(rootCursor = CreateRootCursor(defaultCursorFont, 0)))
|
||||
FatalError("could not open default cursor font '%s'",
|
||||
defaultCursorFont);
|
||||
#ifdef DPMSExtension
|
||||
/* check all screens, looking for DPMS Capabilities */
|
||||
DPMSCapableFlag = DPMSSupported();
|
||||
if (!DPMSCapableFlag)
|
||||
DPMSEnabled = FALSE;
|
||||
#endif
|
||||
|
||||
#ifdef PANORAMIX
|
||||
/*
|
||||
* Consolidate window and colourmap information for each screen
|
||||
*/
|
||||
if (!noPanoramiXExtension)
|
||||
PanoramiXConsolidate();
|
||||
#endif
|
||||
|
||||
for (i = 0; i < screenInfo.numScreens; i++)
|
||||
InitRootWindow(screenInfo.screens[i]->root);
|
||||
DefineInitialRootWindow(screenInfo.screens[0]->root);
|
||||
SaveScreens(SCREEN_SAVER_FORCER, ScreenSaverReset);
|
||||
|
||||
#ifdef PANORAMIX
|
||||
if (!noPanoramiXExtension) {
|
||||
if (!PanoramiXCreateConnectionBlock())
|
||||
FatalError("could not create connection block info");
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
if (!CreateConnectionBlock())
|
||||
FatalError("could not create connection block info");
|
||||
}
|
||||
|
||||
NotifyParentProcess();
|
||||
|
||||
Dispatch();
|
||||
|
||||
/* Now free up whatever must be freed */
|
||||
if (screenIsSaved == SCREEN_SAVER_ON)
|
||||
SaveScreens(SCREEN_SAVER_OFF, ScreenSaverReset);
|
||||
FreeScreenSaverTimer();
|
||||
CloseDownExtensions();
|
||||
|
||||
#ifdef PANORAMIX
|
||||
{
|
||||
Bool remember_it = noPanoramiXExtension;
|
||||
noPanoramiXExtension = TRUE;
|
||||
FreeAllResources();
|
||||
noPanoramiXExtension = remember_it;
|
||||
}
|
||||
#else
|
||||
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)(screenInfo.screens[i]);
|
||||
FreeScreen(screenInfo.screens[i]);
|
||||
screenInfo.numScreens = i;
|
||||
}
|
||||
FreeFonts();
|
||||
|
||||
FreeAuditTimer();
|
||||
|
||||
ReleaseClientIds(serverClient);
|
||||
free(serverClient->devPrivates);
|
||||
serverClient->devPrivates = NULL;
|
||||
|
||||
if (dispatchException & DE_TERMINATE)
|
||||
{
|
||||
CloseWellKnownConnections();
|
||||
}
|
||||
|
||||
OsCleanup((dispatchException & DE_TERMINATE) != 0);
|
||||
|
||||
if (dispatchException & DE_TERMINATE)
|
||||
{
|
||||
ddxGiveUp();
|
||||
break;
|
||||
}
|
||||
|
||||
free(ConnectionInfo);
|
||||
ConnectionInfo = NULL;
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
static int VendorRelease = VENDOR_RELEASE;
|
||||
static char *VendorString = VENDOR_STRING;
|
||||
|
||||
void
|
||||
SetVendorRelease(int release)
|
||||
{
|
||||
VendorRelease = release;
|
||||
}
|
||||
|
||||
void
|
||||
SetVendorString(char *string)
|
||||
{
|
||||
VendorString = string;
|
||||
}
|
||||
|
||||
static int padlength[4] = {0, 3, 2, 1};
|
||||
|
||||
#ifndef PANORAMIX
|
||||
static
|
||||
#endif
|
||||
Bool
|
||||
CreateConnectionBlock()
|
||||
{
|
||||
xConnSetup setup;
|
||||
xWindowRoot root;
|
||||
xDepth depth;
|
||||
xVisualType visual;
|
||||
xPixmapFormat format;
|
||||
unsigned long vid;
|
||||
int i, j, k,
|
||||
lenofblock,
|
||||
sizesofar = 0;
|
||||
char *pBuf;
|
||||
|
||||
|
||||
memset(&setup, 0, sizeof(xConnSetup));
|
||||
/* Leave off the ridBase and ridMask, these must be sent with
|
||||
connection */
|
||||
|
||||
setup.release = VendorRelease;
|
||||
/*
|
||||
* per-server image and bitmap parameters are defined in Xmd.h
|
||||
*/
|
||||
setup.imageByteOrder = screenInfo.imageByteOrder;
|
||||
|
||||
setup.bitmapScanlineUnit = screenInfo.bitmapScanlineUnit;
|
||||
setup.bitmapScanlinePad = screenInfo.bitmapScanlinePad;
|
||||
|
||||
setup.bitmapBitOrder = screenInfo.bitmapBitOrder;
|
||||
setup.motionBufferSize = NumMotionEvents();
|
||||
setup.numRoots = screenInfo.numScreens;
|
||||
setup.nbytesVendor = strlen(VendorString);
|
||||
setup.numFormats = screenInfo.numPixmapFormats;
|
||||
setup.maxRequestSize = MAX_REQUEST_SIZE;
|
||||
QueryMinMaxKeyCodes(&setup.minKeyCode, &setup.maxKeyCode);
|
||||
|
||||
lenofblock = sizeof(xConnSetup) +
|
||||
((setup.nbytesVendor + 3) & ~3) +
|
||||
(setup.numFormats * sizeof(xPixmapFormat)) +
|
||||
(setup.numRoots * sizeof(xWindowRoot));
|
||||
ConnectionInfo = (char *) malloc(lenofblock);
|
||||
if (!ConnectionInfo)
|
||||
return FALSE;
|
||||
|
||||
memmove(ConnectionInfo, (char *)&setup, sizeof(xConnSetup));
|
||||
sizesofar = sizeof(xConnSetup);
|
||||
pBuf = ConnectionInfo + sizeof(xConnSetup);
|
||||
|
||||
memmove(pBuf, VendorString, (int)setup.nbytesVendor);
|
||||
sizesofar += setup.nbytesVendor;
|
||||
pBuf += setup.nbytesVendor;
|
||||
i = padlength[setup.nbytesVendor & 3];
|
||||
sizesofar += i;
|
||||
while (--i >= 0)
|
||||
*pBuf++ = 0;
|
||||
|
||||
memset(&format, 0, sizeof(xPixmapFormat));
|
||||
for (i=0; i<screenInfo.numPixmapFormats; i++)
|
||||
{
|
||||
format.depth = screenInfo.formats[i].depth;
|
||||
format.bitsPerPixel = screenInfo.formats[i].bitsPerPixel;
|
||||
format.scanLinePad = screenInfo.formats[i].scanlinePad;
|
||||
memmove(pBuf, (char *)&format, sizeof(xPixmapFormat));
|
||||
pBuf += sizeof(xPixmapFormat);
|
||||
sizesofar += sizeof(xPixmapFormat);
|
||||
}
|
||||
|
||||
connBlockScreenStart = sizesofar;
|
||||
memset(&depth, 0, sizeof(xDepth));
|
||||
memset(&visual, 0, sizeof(xVisualType));
|
||||
for (i=0; i<screenInfo.numScreens; i++)
|
||||
{
|
||||
ScreenPtr pScreen;
|
||||
DepthPtr pDepth;
|
||||
VisualPtr pVisual;
|
||||
|
||||
pScreen = screenInfo.screens[i];
|
||||
root.windowId = screenInfo.screens[i]->root->drawable.id;
|
||||
root.defaultColormap = pScreen->defColormap;
|
||||
root.whitePixel = pScreen->whitePixel;
|
||||
root.blackPixel = pScreen->blackPixel;
|
||||
root.currentInputMask = 0; /* filled in when sent */
|
||||
root.pixWidth = pScreen->width;
|
||||
root.pixHeight = pScreen->height;
|
||||
root.mmWidth = pScreen->mmWidth;
|
||||
root.mmHeight = pScreen->mmHeight;
|
||||
root.minInstalledMaps = pScreen->minInstalledCmaps;
|
||||
root.maxInstalledMaps = pScreen->maxInstalledCmaps;
|
||||
root.rootVisualID = pScreen->rootVisual;
|
||||
root.backingStore = pScreen->backingStoreSupport;
|
||||
root.saveUnders = pScreen->saveUnderSupport != NotUseful;
|
||||
root.rootDepth = pScreen->rootDepth;
|
||||
root.nDepths = pScreen->numDepths;
|
||||
memmove(pBuf, (char *)&root, sizeof(xWindowRoot));
|
||||
sizesofar += sizeof(xWindowRoot);
|
||||
pBuf += sizeof(xWindowRoot);
|
||||
|
||||
pDepth = pScreen->allowedDepths;
|
||||
for(j = 0; j < pScreen->numDepths; j++, pDepth++)
|
||||
{
|
||||
lenofblock += sizeof(xDepth) +
|
||||
(pDepth->numVids * sizeof(xVisualType));
|
||||
pBuf = (char *)realloc(ConnectionInfo, lenofblock);
|
||||
if (!pBuf)
|
||||
{
|
||||
free(ConnectionInfo);
|
||||
return FALSE;
|
||||
}
|
||||
ConnectionInfo = pBuf;
|
||||
pBuf += sizesofar;
|
||||
depth.depth = pDepth->depth;
|
||||
depth.nVisuals = pDepth->numVids;
|
||||
memmove(pBuf, (char *)&depth, sizeof(xDepth));
|
||||
pBuf += sizeof(xDepth);
|
||||
sizesofar += sizeof(xDepth);
|
||||
for(k = 0; k < pDepth->numVids; k++)
|
||||
{
|
||||
vid = pDepth->vids[k];
|
||||
for (pVisual = pScreen->visuals;
|
||||
pVisual->vid != vid;
|
||||
pVisual++)
|
||||
;
|
||||
visual.visualID = vid;
|
||||
visual.class = pVisual->class;
|
||||
visual.bitsPerRGB = pVisual->bitsPerRGBValue;
|
||||
visual.colormapEntries = pVisual->ColormapEntries;
|
||||
visual.redMask = pVisual->redMask;
|
||||
visual.greenMask = pVisual->greenMask;
|
||||
visual.blueMask = pVisual->blueMask;
|
||||
memmove(pBuf, (char *)&visual, sizeof(xVisualType));
|
||||
pBuf += sizeof(xVisualType);
|
||||
sizesofar += sizeof(xVisualType);
|
||||
}
|
||||
}
|
||||
}
|
||||
connSetupPrefix.success = xTrue;
|
||||
connSetupPrefix.length = lenofblock/4;
|
||||
connSetupPrefix.majorVersion = X_PROTOCOL;
|
||||
connSetupPrefix.minorVersion = X_PROTOCOL_REVISION;
|
||||
return TRUE;
|
||||
}
|
||||
159
nx-X11/programs/Xserver/dix/pixmap.c
Normal file
159
nx-X11/programs/Xserver/dix/pixmap.c
Normal file
@@ -0,0 +1,159 @@
|
||||
/*
|
||||
|
||||
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.
|
||||
|
||||
*/
|
||||
|
||||
#ifdef HAVE_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#include <nx-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, void * 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, 0);
|
||||
|
||||
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.
|
||||
* This is not included in xorg upstream!
|
||||
*/
|
||||
|
||||
pPixmap = (PixmapPtr)calloc(1, 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 = (void *)ptr;
|
||||
ptr += size;
|
||||
}
|
||||
else
|
||||
ppriv->ptr = (void *)NULL;
|
||||
}
|
||||
#else
|
||||
pPixmap = (PixmapPtr)calloc(1, sizeof(PixmapRec) + pixDataSize);
|
||||
#endif
|
||||
|
||||
#ifdef _XSERVER64
|
||||
if (pPixmap) {
|
||||
pPixmap->drawable.pad0 = 0;
|
||||
pPixmap->drawable.pad1 = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
return pPixmap;
|
||||
}
|
||||
456
nx-X11/programs/Xserver/dix/privates.c
Normal file
456
nx-X11/programs/Xserver/dix/privates.c
Normal file
@@ -0,0 +1,456 @@
|
||||
/*
|
||||
|
||||
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.
|
||||
|
||||
*/
|
||||
|
||||
#ifdef HAVE_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#include <nx-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 "colormapst.h"
|
||||
#include "servermd.h"
|
||||
#include "site.h"
|
||||
#include "inputstr.h"
|
||||
#include "extnsionst.h"
|
||||
|
||||
/*
|
||||
* See the Wrappers and devPrivates section in "Definition of the
|
||||
* Porting Layer for the X v11 Sample Server" (doc/Server/ddx.tbl.ms)
|
||||
* for information on how to use devPrivates.
|
||||
*/
|
||||
|
||||
/*
|
||||
* extension private machinery
|
||||
*/
|
||||
|
||||
static int extensionPrivateCount;
|
||||
int extensionPrivateLen;
|
||||
unsigned *extensionPrivateSizes;
|
||||
unsigned totalExtensionSize;
|
||||
|
||||
void
|
||||
ResetExtensionPrivates()
|
||||
{
|
||||
extensionPrivateCount = 0;
|
||||
extensionPrivateLen = 0;
|
||||
free(extensionPrivateSizes);
|
||||
extensionPrivateSizes = (unsigned *)NULL;
|
||||
totalExtensionSize =
|
||||
((sizeof(ExtensionEntry) + sizeof(long) - 1) / sizeof(long)) * sizeof(long);
|
||||
}
|
||||
|
||||
int
|
||||
AllocateExtensionPrivateIndex()
|
||||
{
|
||||
return extensionPrivateCount++;
|
||||
}
|
||||
|
||||
Bool
|
||||
AllocateExtensionPrivate(int index2, unsigned amount)
|
||||
{
|
||||
unsigned oldamount;
|
||||
|
||||
/* Round up sizes for proper alignment */
|
||||
amount = ((amount + (sizeof(long) - 1)) / sizeof(long)) * sizeof(long);
|
||||
|
||||
if (index2 >= extensionPrivateLen)
|
||||
{
|
||||
unsigned *nsizes;
|
||||
nsizes = (unsigned *)realloc(extensionPrivateSizes,
|
||||
(index2 + 1) * sizeof(unsigned));
|
||||
if (!nsizes)
|
||||
return FALSE;
|
||||
while (extensionPrivateLen <= index2)
|
||||
{
|
||||
nsizes[extensionPrivateLen++] = 0;
|
||||
totalExtensionSize += sizeof(DevUnion);
|
||||
}
|
||||
extensionPrivateSizes = nsizes;
|
||||
}
|
||||
oldamount = extensionPrivateSizes[index2];
|
||||
if (amount > oldamount)
|
||||
{
|
||||
extensionPrivateSizes[index2] = amount;
|
||||
totalExtensionSize += (amount - oldamount);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* client private machinery
|
||||
*/
|
||||
|
||||
static int clientPrivateCount;
|
||||
int clientPrivateLen;
|
||||
unsigned *clientPrivateSizes;
|
||||
unsigned totalClientSize;
|
||||
|
||||
void
|
||||
ResetClientPrivates()
|
||||
{
|
||||
clientPrivateCount = 0;
|
||||
clientPrivateLen = 0;
|
||||
free(clientPrivateSizes);
|
||||
clientPrivateSizes = (unsigned *)NULL;
|
||||
totalClientSize =
|
||||
((sizeof(ClientRec) + sizeof(long) - 1) / sizeof(long)) * sizeof(long);
|
||||
}
|
||||
|
||||
int
|
||||
AllocateClientPrivateIndex()
|
||||
{
|
||||
return clientPrivateCount++;
|
||||
}
|
||||
|
||||
Bool
|
||||
AllocateClientPrivate(int index2, unsigned amount)
|
||||
{
|
||||
unsigned oldamount;
|
||||
|
||||
/* Round up sizes for proper alignment */
|
||||
amount = ((amount + (sizeof(long) - 1)) / sizeof(long)) * sizeof(long);
|
||||
|
||||
if (index2 >= clientPrivateLen)
|
||||
{
|
||||
unsigned *nsizes;
|
||||
nsizes = (unsigned *)realloc(clientPrivateSizes,
|
||||
(index2 + 1) * sizeof(unsigned));
|
||||
if (!nsizes)
|
||||
return FALSE;
|
||||
while (clientPrivateLen <= index2)
|
||||
{
|
||||
nsizes[clientPrivateLen++] = 0;
|
||||
totalClientSize += sizeof(DevUnion);
|
||||
}
|
||||
clientPrivateSizes = nsizes;
|
||||
}
|
||||
oldamount = clientPrivateSizes[index2];
|
||||
if (amount > oldamount)
|
||||
{
|
||||
clientPrivateSizes[index2] = amount;
|
||||
totalClientSize += (amount - oldamount);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* screen private machinery
|
||||
*/
|
||||
|
||||
int screenPrivateCount;
|
||||
|
||||
void
|
||||
ResetScreenPrivates()
|
||||
{
|
||||
screenPrivateCount = 0;
|
||||
}
|
||||
|
||||
/* this can be called after some screens have been created,
|
||||
* so we have to worry about resizing existing devPrivates
|
||||
*/
|
||||
int
|
||||
AllocateScreenPrivateIndex()
|
||||
{
|
||||
int idx;
|
||||
int i;
|
||||
ScreenPtr pScreen;
|
||||
DevUnion *nprivs;
|
||||
|
||||
idx = screenPrivateCount++;
|
||||
for (i = 0; i < screenInfo.numScreens; i++)
|
||||
{
|
||||
pScreen = screenInfo.screens[i];
|
||||
nprivs = (DevUnion *)realloc(pScreen->devPrivates,
|
||||
screenPrivateCount * sizeof(DevUnion));
|
||||
if (!nprivs)
|
||||
{
|
||||
screenPrivateCount--;
|
||||
return -1;
|
||||
}
|
||||
/* Zero the new private */
|
||||
bzero(&nprivs[idx], sizeof(DevUnion));
|
||||
pScreen->devPrivates = nprivs;
|
||||
}
|
||||
return idx;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* window private machinery
|
||||
*/
|
||||
|
||||
static int windowPrivateCount;
|
||||
|
||||
void
|
||||
ResetWindowPrivates()
|
||||
{
|
||||
windowPrivateCount = 0;
|
||||
}
|
||||
|
||||
int
|
||||
AllocateWindowPrivateIndex()
|
||||
{
|
||||
return windowPrivateCount++;
|
||||
}
|
||||
|
||||
Bool
|
||||
AllocateWindowPrivate(register ScreenPtr pScreen, int index2, unsigned amount)
|
||||
{
|
||||
unsigned oldamount;
|
||||
|
||||
/* Round up sizes for proper alignment */
|
||||
amount = ((amount + (sizeof(long) - 1)) / sizeof(long)) * sizeof(long);
|
||||
|
||||
if (index2 >= pScreen->WindowPrivateLen)
|
||||
{
|
||||
unsigned *nsizes;
|
||||
nsizes = (unsigned *)realloc(pScreen->WindowPrivateSizes,
|
||||
(index2 + 1) * sizeof(unsigned));
|
||||
if (!nsizes)
|
||||
return FALSE;
|
||||
while (pScreen->WindowPrivateLen <= index2)
|
||||
{
|
||||
nsizes[pScreen->WindowPrivateLen++] = 0;
|
||||
pScreen->totalWindowSize += sizeof(DevUnion);
|
||||
}
|
||||
pScreen->WindowPrivateSizes = nsizes;
|
||||
}
|
||||
oldamount = pScreen->WindowPrivateSizes[index2];
|
||||
if (amount > oldamount)
|
||||
{
|
||||
pScreen->WindowPrivateSizes[index2] = amount;
|
||||
pScreen->totalWindowSize += (amount - oldamount);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* gc private machinery
|
||||
*/
|
||||
|
||||
static int gcPrivateCount;
|
||||
|
||||
void
|
||||
ResetGCPrivates()
|
||||
{
|
||||
gcPrivateCount = 0;
|
||||
}
|
||||
|
||||
int
|
||||
AllocateGCPrivateIndex()
|
||||
{
|
||||
return gcPrivateCount++;
|
||||
}
|
||||
|
||||
Bool
|
||||
AllocateGCPrivate(register ScreenPtr pScreen, int index2, unsigned amount)
|
||||
{
|
||||
unsigned oldamount;
|
||||
|
||||
/* Round up sizes for proper alignment */
|
||||
amount = ((amount + (sizeof(long) - 1)) / sizeof(long)) * sizeof(long);
|
||||
|
||||
if (index2 >= pScreen->GCPrivateLen)
|
||||
{
|
||||
unsigned *nsizes;
|
||||
nsizes = (unsigned *)realloc(pScreen->GCPrivateSizes,
|
||||
(index2 + 1) * sizeof(unsigned));
|
||||
if (!nsizes)
|
||||
return FALSE;
|
||||
while (pScreen->GCPrivateLen <= index2)
|
||||
{
|
||||
nsizes[pScreen->GCPrivateLen++] = 0;
|
||||
pScreen->totalGCSize += sizeof(DevUnion);
|
||||
}
|
||||
pScreen->GCPrivateSizes = nsizes;
|
||||
}
|
||||
oldamount = pScreen->GCPrivateSizes[index2];
|
||||
if (amount > oldamount)
|
||||
{
|
||||
pScreen->GCPrivateSizes[index2] = amount;
|
||||
pScreen->totalGCSize += (amount - oldamount);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* pixmap private machinery
|
||||
*/
|
||||
#ifdef PIXPRIV
|
||||
static int pixmapPrivateCount;
|
||||
|
||||
void
|
||||
ResetPixmapPrivates()
|
||||
{
|
||||
pixmapPrivateCount = 0;
|
||||
}
|
||||
|
||||
int
|
||||
AllocatePixmapPrivateIndex()
|
||||
{
|
||||
return pixmapPrivateCount++;
|
||||
}
|
||||
|
||||
Bool
|
||||
AllocatePixmapPrivate(register ScreenPtr pScreen, int index2, unsigned amount)
|
||||
{
|
||||
unsigned oldamount;
|
||||
|
||||
/* Round up sizes for proper alignment */
|
||||
amount = ((amount + (sizeof(long) - 1)) / sizeof(long)) * sizeof(long);
|
||||
|
||||
if (index2 >= pScreen->PixmapPrivateLen)
|
||||
{
|
||||
unsigned *nsizes;
|
||||
nsizes = (unsigned *)realloc(pScreen->PixmapPrivateSizes,
|
||||
(index2 + 1) * sizeof(unsigned));
|
||||
if (!nsizes)
|
||||
return FALSE;
|
||||
while (pScreen->PixmapPrivateLen <= index2)
|
||||
{
|
||||
nsizes[pScreen->PixmapPrivateLen++] = 0;
|
||||
pScreen->totalPixmapSize += sizeof(DevUnion);
|
||||
}
|
||||
pScreen->PixmapPrivateSizes = nsizes;
|
||||
}
|
||||
oldamount = pScreen->PixmapPrivateSizes[index2];
|
||||
if (amount > oldamount)
|
||||
{
|
||||
pScreen->PixmapPrivateSizes[index2] = amount;
|
||||
pScreen->totalPixmapSize += (amount - oldamount);
|
||||
}
|
||||
pScreen->totalPixmapSize = BitmapBytePad(pScreen->totalPixmapSize * 8);
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* colormap private machinery
|
||||
*/
|
||||
|
||||
int colormapPrivateCount;
|
||||
|
||||
void
|
||||
ResetColormapPrivates()
|
||||
{
|
||||
colormapPrivateCount = 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
AllocateColormapPrivateIndex (InitCmapPrivFunc initPrivFunc)
|
||||
{
|
||||
int index;
|
||||
int i;
|
||||
ColormapPtr pColormap;
|
||||
DevUnion *privs;
|
||||
|
||||
index = colormapPrivateCount++;
|
||||
|
||||
for (i = 0; i < screenInfo.numScreens; i++)
|
||||
{
|
||||
/*
|
||||
* AllocateColormapPrivateIndex may be called after the
|
||||
* default colormap has been created on each screen!
|
||||
*
|
||||
* We must resize the devPrivates array for the default
|
||||
* colormap on each screen, making room for this new private.
|
||||
* We also call the initialization function 'initPrivFunc' on
|
||||
* the new private allocated for each default colormap.
|
||||
*/
|
||||
|
||||
ScreenPtr pScreen = screenInfo.screens[i];
|
||||
|
||||
pColormap = (ColormapPtr) LookupIDByType (
|
||||
pScreen->defColormap, RT_COLORMAP);
|
||||
|
||||
if (pColormap)
|
||||
{
|
||||
privs = (DevUnion *) realloc (pColormap->devPrivates,
|
||||
colormapPrivateCount * sizeof(DevUnion));
|
||||
if (!privs) {
|
||||
colormapPrivateCount--;
|
||||
return -1;
|
||||
}
|
||||
bzero(&privs[index], sizeof(DevUnion));
|
||||
pColormap->devPrivates = privs;
|
||||
if (!(*initPrivFunc)(pColormap,index))
|
||||
{
|
||||
colormapPrivateCount--;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
/*
|
||||
* device private machinery
|
||||
*/
|
||||
|
||||
static int devicePrivateIndex = 0;
|
||||
|
||||
int
|
||||
AllocateDevicePrivateIndex()
|
||||
{
|
||||
return devicePrivateIndex++;
|
||||
}
|
||||
|
||||
Bool
|
||||
AllocateDevicePrivate(DeviceIntPtr device, int index)
|
||||
{
|
||||
if (device->nPrivates < ++index) {
|
||||
DevUnion *nprivs = (DevUnion *) realloc(device->devPrivates,
|
||||
index * sizeof(DevUnion));
|
||||
if (!nprivs)
|
||||
return FALSE;
|
||||
device->devPrivates = nprivs;
|
||||
bzero(&nprivs[device->nPrivates], sizeof(DevUnion)
|
||||
* (index - device->nPrivates));
|
||||
device->nPrivates = index;
|
||||
return TRUE;
|
||||
} else {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ResetDevicePrivateIndex(void)
|
||||
{
|
||||
devicePrivateIndex = 0;
|
||||
}
|
||||
704
nx-X11/programs/Xserver/dix/property.c
Normal file
704
nx-X11/programs/Xserver/dix/property.c
Normal file
@@ -0,0 +1,704 @@
|
||||
/***********************************************************
|
||||
|
||||
Copyright 1987, 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 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.
|
||||
|
||||
******************************************************************/
|
||||
|
||||
#ifdef HAVE_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#include <nx-X11/X.h>
|
||||
#include <nx-X11/Xproto.h>
|
||||
#include "windowstr.h"
|
||||
#include "propertyst.h"
|
||||
#include "dixstruct.h"
|
||||
#include "dispatch.h"
|
||||
#include "swaprep.h"
|
||||
#ifdef XCSECURITY
|
||||
#define _SECURITY_SERVER
|
||||
#include <nx-X11/extensions/security.h>
|
||||
#endif
|
||||
|
||||
/*****************************************************************
|
||||
* Property Stuff
|
||||
*
|
||||
* ChangeProperty, DeleteProperty, GetProperties,
|
||||
* ListProperties
|
||||
*
|
||||
* Properties below to windows. A allocate slots each time
|
||||
* a property is added. No fancy searching done.
|
||||
*
|
||||
*****************************************************************/
|
||||
|
||||
#ifdef notdef
|
||||
static void
|
||||
PrintPropertys(WindowPtr pWin)
|
||||
{
|
||||
PropertyPtr pProp;
|
||||
register int j;
|
||||
|
||||
pProp = pWin->userProps;
|
||||
while (pProp)
|
||||
{
|
||||
ErrorF( "%x %x\n", pProp->propertyName, pProp->type);
|
||||
ErrorF("property format: %d\n", pProp->format);
|
||||
ErrorF("property data: \n");
|
||||
for (j=0; j<(pProp->format/8)*pProp->size; j++)
|
||||
ErrorF("%c\n", pProp->data[j]);
|
||||
pProp = pProp->next;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
ProcRotateProperties(ClientPtr client)
|
||||
{
|
||||
int i, j, delta;
|
||||
REQUEST(xRotatePropertiesReq);
|
||||
WindowPtr pWin;
|
||||
register Atom * atoms;
|
||||
PropertyPtr * props; /* array of pointer */
|
||||
PropertyPtr pProp;
|
||||
|
||||
REQUEST_FIXED_SIZE(xRotatePropertiesReq, stuff->nAtoms << 2);
|
||||
UpdateCurrentTime();
|
||||
pWin = (WindowPtr) SecurityLookupWindow(stuff->window, client,
|
||||
DixWriteAccess);
|
||||
if (!pWin)
|
||||
return(BadWindow);
|
||||
if (!stuff->nAtoms)
|
||||
return(Success);
|
||||
atoms = (Atom *) & stuff[1];
|
||||
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],
|
||||
DixReadAccess|DixWriteAccess);
|
||||
#endif
|
||||
if (!ValidAtom(atoms[i])
|
||||
#ifdef XCSECURITY
|
||||
|| (SecurityErrorOperation == action)
|
||||
#endif
|
||||
)
|
||||
{
|
||||
free(props);
|
||||
client->errorValue = atoms[i];
|
||||
return BadAtom;
|
||||
}
|
||||
#ifdef XCSECURITY
|
||||
if (SecurityIgnoreOperation == action)
|
||||
{
|
||||
free(props);
|
||||
return Success;
|
||||
}
|
||||
#endif
|
||||
for (j = i + 1; j < stuff->nAtoms; j++)
|
||||
if (atoms[j] == atoms[i])
|
||||
{
|
||||
free(props);
|
||||
return BadMatch;
|
||||
}
|
||||
pProp = wUserProps (pWin);
|
||||
while (pProp)
|
||||
{
|
||||
if (pProp->propertyName == atoms[i])
|
||||
goto found;
|
||||
pProp = pProp->next;
|
||||
}
|
||||
free(props);
|
||||
return BadMatch;
|
||||
found:
|
||||
props[i] = pProp;
|
||||
}
|
||||
delta = stuff->nPositions;
|
||||
|
||||
/* If the rotation is a complete 360 degrees, then moving the properties
|
||||
around and generating PropertyNotify events should be skipped. */
|
||||
|
||||
if ( (stuff->nAtoms != 0) && (abs(delta) % stuff->nAtoms) != 0 )
|
||||
{
|
||||
while (delta < 0) /* faster if abs value is small */
|
||||
delta += stuff->nAtoms;
|
||||
for (i = 0; i < stuff->nAtoms; i++)
|
||||
{
|
||||
/* 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;
|
||||
event.u.property.atom = props[i]->propertyName;
|
||||
event.u.property.time = currentTime.milliseconds;
|
||||
DeliverEvents(pWin, &event, 1, (WindowPtr)NULL);
|
||||
|
||||
props[i]->propertyName = atoms[(i + delta) % stuff->nAtoms];
|
||||
}
|
||||
}
|
||||
free(props);
|
||||
return Success;
|
||||
}
|
||||
|
||||
#ifndef NXAGENT_SERVER
|
||||
int
|
||||
ProcChangeProperty(ClientPtr client)
|
||||
{
|
||||
WindowPtr pWin;
|
||||
char format, mode;
|
||||
unsigned long len;
|
||||
int sizeInBytes;
|
||||
int totalSize;
|
||||
int err;
|
||||
REQUEST(xChangePropertyReq);
|
||||
|
||||
REQUEST_AT_LEAST_SIZE(xChangePropertyReq);
|
||||
UpdateCurrentTime();
|
||||
format = stuff->format;
|
||||
mode = stuff->mode;
|
||||
if ((mode != PropModeReplace) && (mode != PropModeAppend) &&
|
||||
(mode != PropModePrepend))
|
||||
{
|
||||
client->errorValue = mode;
|
||||
return BadValue;
|
||||
}
|
||||
if ((format != 8) && (format != 16) && (format != 32))
|
||||
{
|
||||
client->errorValue = format;
|
||||
return BadValue;
|
||||
}
|
||||
len = stuff->nUnits;
|
||||
if (len > ((0xffffffff - sizeof(xChangePropertyReq)) >> 2))
|
||||
return BadLength;
|
||||
sizeInBytes = format>>3;
|
||||
totalSize = len * sizeInBytes;
|
||||
REQUEST_FIXED_SIZE(xChangePropertyReq, totalSize);
|
||||
|
||||
pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
|
||||
DixWriteAccess);
|
||||
if (!pWin)
|
||||
return(BadWindow);
|
||||
if (!ValidAtom(stuff->property))
|
||||
{
|
||||
client->errorValue = stuff->property;
|
||||
return(BadAtom);
|
||||
}
|
||||
if (!ValidAtom(stuff->type))
|
||||
{
|
||||
client->errorValue = stuff->type;
|
||||
return(BadAtom);
|
||||
}
|
||||
|
||||
#ifdef XCSECURITY
|
||||
switch (SecurityCheckPropertyAccess(client, pWin, stuff->property,
|
||||
DixWriteAccess))
|
||||
{
|
||||
case SecurityErrorOperation:
|
||||
client->errorValue = stuff->property;
|
||||
return BadAtom;
|
||||
case SecurityIgnoreOperation:
|
||||
return Success;
|
||||
}
|
||||
#endif
|
||||
|
||||
err = ChangeWindowProperty(pWin, stuff->property, stuff->type, (int)format,
|
||||
(int)mode, len, (void *)&stuff[1], TRUE);
|
||||
if (err != Success)
|
||||
return err;
|
||||
else
|
||||
return client->noClientException;
|
||||
}
|
||||
#endif /* NXAGENT_SERVER */
|
||||
|
||||
int
|
||||
#ifdef NXAGENT_SERVER
|
||||
xorg_ChangeWindowProperty(WindowPtr pWin, Atom property, Atom type, int format,
|
||||
int mode, unsigned long len, void * value,
|
||||
Bool sendevent)
|
||||
#else
|
||||
ChangeWindowProperty(WindowPtr pWin, Atom property, Atom type, int format,
|
||||
int mode, unsigned long len, void * value,
|
||||
Bool sendevent)
|
||||
#endif
|
||||
{
|
||||
PropertyPtr pProp;
|
||||
int sizeInBytes;
|
||||
int totalSize;
|
||||
void * data;
|
||||
|
||||
sizeInBytes = format>>3;
|
||||
totalSize = len * sizeInBytes;
|
||||
|
||||
/* first see if property already exists */
|
||||
|
||||
pProp = wUserProps (pWin);
|
||||
while (pProp)
|
||||
{
|
||||
if (pProp->propertyName == property)
|
||||
break;
|
||||
pProp = pProp->next;
|
||||
}
|
||||
if (!pProp) /* just add to list */
|
||||
{
|
||||
if (!pWin->optional && !MakeWindowOptional (pWin))
|
||||
return(BadAlloc);
|
||||
pProp = (PropertyPtr)malloc(sizeof(PropertyRec));
|
||||
if (!pProp)
|
||||
return(BadAlloc);
|
||||
data = (void *)malloc(totalSize);
|
||||
if (!data && len)
|
||||
{
|
||||
free(pProp);
|
||||
return(BadAlloc);
|
||||
}
|
||||
pProp->propertyName = property;
|
||||
pProp->type = type;
|
||||
pProp->format = format;
|
||||
pProp->data = data;
|
||||
if (len)
|
||||
memmove((char *)data, (char *)value, totalSize);
|
||||
pProp->size = len;
|
||||
pProp->next = pWin->optional->userProps;
|
||||
pWin->optional->userProps = pProp;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* To append or prepend to a property the request format and type
|
||||
must match those of the already defined property. The
|
||||
existing format and type are irrelevant when using the mode
|
||||
"PropModeReplace" since they will be written over. */
|
||||
|
||||
if ((format != pProp->format) && (mode != PropModeReplace))
|
||||
return(BadMatch);
|
||||
if ((pProp->type != type) && (mode != PropModeReplace))
|
||||
return(BadMatch);
|
||||
if (mode == PropModeReplace)
|
||||
{
|
||||
if (totalSize != pProp->size * (pProp->format >> 3))
|
||||
{
|
||||
data = (void *)realloc(pProp->data, totalSize);
|
||||
if (!data && len)
|
||||
return(BadAlloc);
|
||||
pProp->data = data;
|
||||
}
|
||||
if (len)
|
||||
memmove((char *)pProp->data, (char *)value, totalSize);
|
||||
pProp->size = len;
|
||||
pProp->type = type;
|
||||
pProp->format = format;
|
||||
}
|
||||
else if (len == 0)
|
||||
{
|
||||
/* do nothing */
|
||||
}
|
||||
else if (mode == PropModeAppend)
|
||||
{
|
||||
data = (void *)realloc(pProp->data,
|
||||
sizeInBytes * (len + pProp->size));
|
||||
if (!data)
|
||||
return(BadAlloc);
|
||||
pProp->data = data;
|
||||
memmove(&((char *)data)[pProp->size * sizeInBytes],
|
||||
(char *)value,
|
||||
totalSize);
|
||||
pProp->size += len;
|
||||
}
|
||||
else if (mode == PropModePrepend)
|
||||
{
|
||||
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);
|
||||
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;
|
||||
event.u.property.atom = pProp->propertyName;
|
||||
event.u.property.time = currentTime.milliseconds;
|
||||
DeliverEvents(pWin, &event, 1, (WindowPtr)NULL);
|
||||
}
|
||||
return(Success);
|
||||
}
|
||||
|
||||
int
|
||||
DeleteProperty(WindowPtr pWin, Atom propName)
|
||||
{
|
||||
PropertyPtr pProp, prevProp;
|
||||
|
||||
if (!(pProp = wUserProps (pWin)))
|
||||
return(Success);
|
||||
prevProp = (PropertyPtr)NULL;
|
||||
while (pProp)
|
||||
{
|
||||
if (pProp->propertyName == propName)
|
||||
break;
|
||||
prevProp = pProp;
|
||||
pProp = pProp->next;
|
||||
}
|
||||
if (pProp)
|
||||
{
|
||||
xEvent event;
|
||||
if (prevProp == (PropertyPtr)NULL) /* takes care of head */
|
||||
{
|
||||
if (!(pWin->optional->userProps = pProp->next))
|
||||
CheckWindowOptionalNeed (pWin);
|
||||
}
|
||||
else
|
||||
{
|
||||
prevProp->next = pProp->next;
|
||||
}
|
||||
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);
|
||||
free(pProp->data);
|
||||
free(pProp);
|
||||
}
|
||||
return(Success);
|
||||
}
|
||||
|
||||
void
|
||||
DeleteAllWindowProperties(WindowPtr pWin)
|
||||
{
|
||||
PropertyPtr pProp, pNextProp;
|
||||
xEvent event;
|
||||
|
||||
memset(&event, 0, sizeof(xEvent));
|
||||
pProp = wUserProps (pWin);
|
||||
while (pProp)
|
||||
{
|
||||
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);
|
||||
pNextProp = pProp->next;
|
||||
free(pProp->data);
|
||||
free(pProp);
|
||||
pProp = pNextProp;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
NullPropertyReply(
|
||||
ClientPtr client,
|
||||
ATOM propertyType,
|
||||
int format,
|
||||
xGetPropertyReply *reply)
|
||||
{
|
||||
reply->nItems = 0;
|
||||
reply->length = 0;
|
||||
reply->bytesAfter = 0;
|
||||
reply->propertyType = propertyType;
|
||||
reply->format = format;
|
||||
WriteReplyToClient(client, sizeof(xGenericReply), reply);
|
||||
return(client->noClientException);
|
||||
}
|
||||
|
||||
#ifndef NXAGENT_SERVER
|
||||
|
||||
/*****************
|
||||
* GetProperty
|
||||
* If type Any is specified, returns the property from the specified
|
||||
* window regardless of its type. If a type is specified, returns the
|
||||
* property only if its type equals the specified type.
|
||||
* If delete is True and a property is returned, the property is also
|
||||
* deleted from the window and a PropertyNotify event is generated on the
|
||||
* window.
|
||||
*****************/
|
||||
|
||||
int
|
||||
ProcGetProperty(ClientPtr client)
|
||||
{
|
||||
PropertyPtr pProp, prevProp;
|
||||
unsigned long n, len, ind;
|
||||
WindowPtr pWin;
|
||||
xGetPropertyReply reply;
|
||||
REQUEST(xGetPropertyReq);
|
||||
|
||||
REQUEST_SIZE_MATCH(xGetPropertyReq);
|
||||
if (stuff->delete)
|
||||
UpdateCurrentTime();
|
||||
pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
|
||||
DixReadAccess);
|
||||
if (!pWin)
|
||||
return BadWindow;
|
||||
|
||||
if (!ValidAtom(stuff->property))
|
||||
{
|
||||
client->errorValue = stuff->property;
|
||||
return(BadAtom);
|
||||
}
|
||||
if ((stuff->delete != xTrue) && (stuff->delete != xFalse))
|
||||
{
|
||||
client->errorValue = stuff->delete;
|
||||
return(BadValue);
|
||||
}
|
||||
if ((stuff->type != AnyPropertyType) && !ValidAtom(stuff->type))
|
||||
{
|
||||
client->errorValue = stuff->type;
|
||||
return(BadAtom);
|
||||
}
|
||||
|
||||
pProp = wUserProps (pWin);
|
||||
prevProp = (PropertyPtr)NULL;
|
||||
while (pProp)
|
||||
{
|
||||
if (pProp->propertyName == stuff->property)
|
||||
break;
|
||||
prevProp = pProp;
|
||||
pProp = pProp->next;
|
||||
}
|
||||
|
||||
memset(&reply, 0, sizeof(xGetPropertyReply));
|
||||
reply.type = X_Reply;
|
||||
reply.sequenceNumber = client->sequence;
|
||||
if (!pProp)
|
||||
return NullPropertyReply(client, None, 0, &reply);
|
||||
|
||||
#ifdef XCSECURITY
|
||||
{
|
||||
Mask access_mode = DixReadAccess;
|
||||
|
||||
if (stuff->delete)
|
||||
access_mode |= DixDestroyAccess;
|
||||
switch(SecurityCheckPropertyAccess(client, pWin, stuff->property,
|
||||
access_mode))
|
||||
{
|
||||
case SecurityErrorOperation:
|
||||
client->errorValue = stuff->property;
|
||||
return BadAtom;;
|
||||
case SecurityIgnoreOperation:
|
||||
return NullPropertyReply(client, pProp->type, pProp->format,
|
||||
&reply);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/* If the request type and actual type don't match. Return the
|
||||
property information, but not the data. */
|
||||
|
||||
if (((stuff->type != pProp->type) &&
|
||||
(stuff->type != AnyPropertyType))
|
||||
)
|
||||
{
|
||||
reply.bytesAfter = pProp->size;
|
||||
reply.format = pProp->format;
|
||||
reply.length = 0;
|
||||
reply.nItems = 0;
|
||||
reply.propertyType = pProp->type;
|
||||
WriteReplyToClient(client, sizeof(xGenericReply), &reply);
|
||||
return(Success);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return type, format, value to client
|
||||
*/
|
||||
n = (pProp->format/8) * pProp->size; /* size (bytes) of prop */
|
||||
ind = stuff->longOffset << 2;
|
||||
|
||||
/* If longOffset is invalid such that it causes "len" to
|
||||
be negative, it's a value error. */
|
||||
|
||||
if (n < ind)
|
||||
{
|
||||
client->errorValue = stuff->longOffset;
|
||||
return BadValue;
|
||||
}
|
||||
|
||||
len = min(n - ind, 4 * stuff->longLength);
|
||||
|
||||
reply.bytesAfter = n - (ind + len);
|
||||
reply.format = pProp->format;
|
||||
reply.length = (len + 3) >> 2;
|
||||
reply.nItems = len / (pProp->format / 8 );
|
||||
reply.propertyType = pProp->type;
|
||||
|
||||
if (stuff->delete && (reply.bytesAfter == 0))
|
||||
{ /* 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;
|
||||
event.u.property.atom = pProp->propertyName;
|
||||
event.u.property.time = currentTime.milliseconds;
|
||||
DeliverEvents(pWin, &event, 1, (WindowPtr)NULL);
|
||||
}
|
||||
|
||||
WriteReplyToClient(client, sizeof(xGenericReply), &reply);
|
||||
if (len)
|
||||
{
|
||||
switch (reply.format) {
|
||||
case 32: client->pSwapReplyFunc = (ReplySwapPtr)CopySwap32Write; break;
|
||||
case 16: client->pSwapReplyFunc = (ReplySwapPtr)CopySwap16Write; break;
|
||||
default: client->pSwapReplyFunc = (ReplySwapPtr)WriteToClient; break;
|
||||
}
|
||||
WriteSwappedDataToClient(client, len,
|
||||
(char *)pProp->data + ind);
|
||||
}
|
||||
|
||||
if (stuff->delete && (reply.bytesAfter == 0))
|
||||
{ /* delete the Property */
|
||||
if (prevProp == (PropertyPtr)NULL) /* takes care of head */
|
||||
{
|
||||
if (!(pWin->optional->userProps = pProp->next))
|
||||
CheckWindowOptionalNeed (pWin);
|
||||
}
|
||||
else
|
||||
prevProp->next = pProp->next;
|
||||
free(pProp->data);
|
||||
free(pProp);
|
||||
}
|
||||
return(client->noClientException);
|
||||
}
|
||||
#endif /* NXAGENT_SERVER */
|
||||
|
||||
int
|
||||
ProcListProperties(ClientPtr client)
|
||||
{
|
||||
Atom *pAtoms = NULL, *temppAtoms;
|
||||
xListPropertiesReply xlpr;
|
||||
int numProps = 0;
|
||||
WindowPtr pWin;
|
||||
PropertyPtr pProp;
|
||||
REQUEST(xResourceReq);
|
||||
|
||||
REQUEST_SIZE_MATCH(xResourceReq);
|
||||
pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client,
|
||||
DixReadAccess);
|
||||
if (!pWin)
|
||||
return(BadWindow);
|
||||
|
||||
pProp = wUserProps (pWin);
|
||||
while (pProp)
|
||||
{
|
||||
pProp = pProp->next;
|
||||
numProps++;
|
||||
}
|
||||
if (numProps)
|
||||
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;
|
||||
xlpr.sequenceNumber = client->sequence;
|
||||
pProp = wUserProps (pWin);
|
||||
temppAtoms = pAtoms;
|
||||
while (pProp)
|
||||
{
|
||||
*temppAtoms++ = pProp->propertyName;
|
||||
pProp = pProp->next;
|
||||
}
|
||||
WriteReplyToClient(client, sizeof(xGenericReply), &xlpr);
|
||||
if (numProps)
|
||||
{
|
||||
client->pSwapReplyFunc = (ReplySwapPtr)Swap32Write;
|
||||
WriteSwappedDataToClient(client, numProps * sizeof(Atom), pAtoms);
|
||||
free(pAtoms);
|
||||
}
|
||||
return(client->noClientException);
|
||||
}
|
||||
|
||||
int
|
||||
#ifdef NXAGENT_SERVER
|
||||
xorg_ProcDeleteProperty(register ClientPtr client)
|
||||
#else
|
||||
ProcDeleteProperty(register ClientPtr client)
|
||||
#endif
|
||||
{
|
||||
WindowPtr pWin;
|
||||
REQUEST(xDeletePropertyReq);
|
||||
int result;
|
||||
|
||||
REQUEST_SIZE_MATCH(xDeletePropertyReq);
|
||||
UpdateCurrentTime();
|
||||
pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
|
||||
DixWriteAccess);
|
||||
if (!pWin)
|
||||
return(BadWindow);
|
||||
if (!ValidAtom(stuff->property))
|
||||
{
|
||||
client->errorValue = stuff->property;
|
||||
return (BadAtom);
|
||||
}
|
||||
|
||||
#ifdef XCSECURITY
|
||||
switch(SecurityCheckPropertyAccess(client, pWin, stuff->property,
|
||||
DixDestroyAccess))
|
||||
{
|
||||
case SecurityErrorOperation:
|
||||
client->errorValue = stuff->property;
|
||||
return BadAtom;;
|
||||
case SecurityIgnoreOperation:
|
||||
return Success;
|
||||
}
|
||||
#endif
|
||||
|
||||
result = DeleteProperty(pWin, stuff->property);
|
||||
if (client->noClientException != Success)
|
||||
return(client->noClientException);
|
||||
else
|
||||
return(result);
|
||||
}
|
||||
1742
nx-X11/programs/Xserver/dix/region.c
Normal file
1742
nx-X11/programs/Xserver/dix/region.c
Normal file
File diff suppressed because it is too large
Load Diff
936
nx-X11/programs/Xserver/dix/resource.c
Normal file
936
nx-X11/programs/Xserver/dix/resource.c
Normal file
@@ -0,0 +1,936 @@
|
||||
/************************************************************
|
||||
|
||||
Copyright 1987, 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 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.
|
||||
|
||||
******************************************************************/
|
||||
|
||||
/* $TOG: resource.c /main/41 1998/02/09 14:20:31 kaleb $ */
|
||||
|
||||
/* Routines to manage various kinds of resources:
|
||||
*
|
||||
* CreateNewResourceType, CreateNewResourceClass, InitClientResources,
|
||||
* FakeClientID, AddResource, FreeResource, FreeClientResources,
|
||||
* FreeAllResources, LookupIDByType, LookupIDByClass, GetXIDRange
|
||||
*/
|
||||
|
||||
/*
|
||||
* A resource ID is a 32 bit quantity, the upper 2 bits of which are
|
||||
* off-limits for client-visible resources. The next 8 bits are
|
||||
* used as client ID, and the low 22 bits come from the client.
|
||||
* A resource ID is "hashed" by extracting and xoring subfields
|
||||
* (varying with the size of the hash table).
|
||||
*
|
||||
* It is sometimes necessary for the server to create an ID that looks
|
||||
* like it belongs to a client. This ID, however, must not be one
|
||||
* the client actually can create, or we have the potential for conflict.
|
||||
* The 31st bit of the ID is reserved for the server's use for this
|
||||
* purpose. By setting CLIENT_ID(id) to the client, the SERVER_BIT to
|
||||
* 1, and an otherwise arbitrary ID in the low 22 bits, we can create a
|
||||
* resource "owned" by the client.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#include <nx-X11/X.h>
|
||||
#include "misc.h"
|
||||
#include "os.h"
|
||||
#include "resource.h"
|
||||
#include "dixstruct.h"
|
||||
#include "opaque.h"
|
||||
#include "windowstr.h"
|
||||
#include "dixfont.h"
|
||||
#include "colormap.h"
|
||||
#include "inputstr.h"
|
||||
#include "dixevents.h"
|
||||
#include "dixgrabs.h"
|
||||
#include "cursor.h"
|
||||
#ifdef PANORAMIX
|
||||
#include "panoramiX.h"
|
||||
#include "panoramiXsrv.h"
|
||||
#endif
|
||||
#include <assert.h>
|
||||
|
||||
static void RebuildTable(
|
||||
int /*client*/
|
||||
);
|
||||
|
||||
#define SERVER_MINID 32
|
||||
|
||||
#define INITBUCKETS 64
|
||||
#define INITHASHSIZE 6
|
||||
#define MAXHASHSIZE 11
|
||||
|
||||
typedef struct _Resource {
|
||||
struct _Resource *next;
|
||||
XID id;
|
||||
RESTYPE type;
|
||||
void * value;
|
||||
} ResourceRec, *ResourcePtr;
|
||||
#define NullResource ((ResourcePtr)NULL)
|
||||
|
||||
typedef struct _ClientResource {
|
||||
ResourcePtr *resources;
|
||||
int elements;
|
||||
int buckets;
|
||||
int hashsize; /* log(2)(buckets) */
|
||||
XID fakeID;
|
||||
XID endFakeID;
|
||||
XID expectID;
|
||||
} ClientResourceRec;
|
||||
|
||||
RESTYPE lastResourceType;
|
||||
static RESTYPE lastResourceClass;
|
||||
RESTYPE TypeMask;
|
||||
|
||||
static DeleteType *DeleteFuncs = (DeleteType *)NULL;
|
||||
|
||||
#ifdef XResExtension
|
||||
|
||||
Atom * ResourceNames = NULL;
|
||||
|
||||
void RegisterResourceName (RESTYPE type, char *name)
|
||||
{
|
||||
ResourceNames[type & TypeMask] = MakeAtom(name, strlen(name), TRUE);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
RESTYPE
|
||||
CreateNewResourceType(DeleteType deleteFunc)
|
||||
{
|
||||
RESTYPE next = lastResourceType + 1;
|
||||
DeleteType *funcs;
|
||||
|
||||
if (next & lastResourceClass)
|
||||
return 0;
|
||||
funcs = (DeleteType *)realloc(DeleteFuncs,
|
||||
(next + 1) * sizeof(DeleteType));
|
||||
if (!funcs)
|
||||
return 0;
|
||||
|
||||
#ifdef XResExtension
|
||||
{
|
||||
Atom *newnames;
|
||||
newnames = realloc(ResourceNames, (next + 1) * sizeof(Atom));
|
||||
if(!newnames)
|
||||
return 0;
|
||||
ResourceNames = newnames;
|
||||
ResourceNames[next] = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
lastResourceType = next;
|
||||
DeleteFuncs = funcs;
|
||||
DeleteFuncs[next] = deleteFunc;
|
||||
return next;
|
||||
}
|
||||
|
||||
RESTYPE
|
||||
CreateNewResourceClass()
|
||||
{
|
||||
RESTYPE next = lastResourceClass >> 1;
|
||||
|
||||
if (next & lastResourceType)
|
||||
return 0;
|
||||
lastResourceClass = next;
|
||||
TypeMask = next - 1;
|
||||
return next;
|
||||
}
|
||||
|
||||
ClientResourceRec clientTable[MAXCLIENTS];
|
||||
|
||||
/*****************
|
||||
* InitClientResources
|
||||
* When a new client is created, call this to allocate space
|
||||
* in resource table
|
||||
*****************/
|
||||
|
||||
Bool
|
||||
InitClientResources(ClientPtr client)
|
||||
{
|
||||
register int i, j;
|
||||
|
||||
if (client == serverClient)
|
||||
{
|
||||
lastResourceType = RT_LASTPREDEF;
|
||||
lastResourceClass = RC_LASTPREDEF;
|
||||
TypeMask = RC_LASTPREDEF - 1;
|
||||
if (DeleteFuncs)
|
||||
free(DeleteFuncs);
|
||||
DeleteFuncs = (DeleteType *)malloc((lastResourceType + 1) *
|
||||
sizeof(DeleteType));
|
||||
if (!DeleteFuncs)
|
||||
return FALSE;
|
||||
DeleteFuncs[RT_NONE & TypeMask] = (DeleteType)NoopDDA;
|
||||
DeleteFuncs[RT_WINDOW & TypeMask] = DeleteWindow;
|
||||
DeleteFuncs[RT_PIXMAP & TypeMask] = dixDestroyPixmap;
|
||||
DeleteFuncs[RT_GC & TypeMask] = FreeGC;
|
||||
DeleteFuncs[RT_FONT & TypeMask] = CloseFont;
|
||||
DeleteFuncs[RT_CURSOR & TypeMask] = FreeCursor;
|
||||
DeleteFuncs[RT_COLORMAP & TypeMask] = FreeColormap;
|
||||
DeleteFuncs[RT_CMAPENTRY & TypeMask] = FreeClientPixels;
|
||||
DeleteFuncs[RT_OTHERCLIENT & TypeMask] = OtherClientGone;
|
||||
DeleteFuncs[RT_PASSIVEGRAB & TypeMask] = DeletePassiveGrab;
|
||||
|
||||
#ifdef XResExtension
|
||||
if(ResourceNames)
|
||||
free(ResourceNames);
|
||||
ResourceNames = malloc((lastResourceType + 1) * sizeof(Atom));
|
||||
if(!ResourceNames)
|
||||
return FALSE;
|
||||
#endif
|
||||
}
|
||||
clientTable[i = client->index].resources =
|
||||
(ResourcePtr *)malloc(INITBUCKETS*sizeof(ResourcePtr));
|
||||
if (!clientTable[i].resources)
|
||||
return FALSE;
|
||||
clientTable[i].buckets = INITBUCKETS;
|
||||
clientTable[i].elements = 0;
|
||||
clientTable[i].hashsize = INITHASHSIZE;
|
||||
/* Many IDs allocated from the server client are visible to clients,
|
||||
* so we don't use the SERVER_BIT for them, but we have to start
|
||||
* past the magic value constants used in the protocol. For normal
|
||||
* clients, we can start from zero, with SERVER_BIT set.
|
||||
*/
|
||||
clientTable[i].fakeID = client->clientAsMask |
|
||||
(client->index ? SERVER_BIT : SERVER_MINID);
|
||||
clientTable[i].endFakeID = (clientTable[i].fakeID | RESOURCE_ID_MASK) + 1;
|
||||
clientTable[i].expectID = client->clientAsMask;
|
||||
for (j=0; j<INITBUCKETS; j++)
|
||||
{
|
||||
clientTable[i].resources[j] = NullResource;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
Hash(int client, register XID id)
|
||||
{
|
||||
id &= RESOURCE_ID_MASK;
|
||||
switch (clientTable[client].hashsize)
|
||||
{
|
||||
case 6:
|
||||
return ((int)(0x03F & (id ^ (id>>6) ^ (id>>12))));
|
||||
case 7:
|
||||
return ((int)(0x07F & (id ^ (id>>7) ^ (id>>13))));
|
||||
case 8:
|
||||
return ((int)(0x0FF & (id ^ (id>>8) ^ (id>>16))));
|
||||
case 9:
|
||||
return ((int)(0x1FF & (id ^ (id>>9))));
|
||||
case 10:
|
||||
return ((int)(0x3FF & (id ^ (id>>10))));
|
||||
case 11:
|
||||
return ((int)(0x7FF & (id ^ (id>>11))));
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static XID
|
||||
AvailableID(
|
||||
register int client,
|
||||
register XID id,
|
||||
register XID maxid,
|
||||
register XID goodid)
|
||||
{
|
||||
register ResourcePtr res;
|
||||
|
||||
if ((goodid >= id) && (goodid <= maxid))
|
||||
return goodid;
|
||||
for (; id <= maxid; id++)
|
||||
{
|
||||
res = clientTable[client].resources[Hash(client, id)];
|
||||
while (res && (res->id != id))
|
||||
res = res->next;
|
||||
if (!res)
|
||||
return id;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
GetXIDRange(int client, Bool server, XID *minp, XID *maxp)
|
||||
{
|
||||
register XID id, maxid;
|
||||
register ResourcePtr *resp;
|
||||
register ResourcePtr res;
|
||||
register int i;
|
||||
XID goodid;
|
||||
|
||||
id = (Mask)client << CLIENTOFFSET;
|
||||
if (server)
|
||||
id |= client ? SERVER_BIT : SERVER_MINID;
|
||||
maxid = id | RESOURCE_ID_MASK;
|
||||
goodid = 0;
|
||||
for (resp = clientTable[client].resources, i = clientTable[client].buckets;
|
||||
--i >= 0;)
|
||||
{
|
||||
for (res = *resp++; res; res = res->next)
|
||||
{
|
||||
if ((res->id < id) || (res->id > maxid))
|
||||
continue;
|
||||
if (((res->id - id) >= (maxid - res->id)) ?
|
||||
(goodid = AvailableID(client, id, res->id - 1, goodid)) :
|
||||
!(goodid = AvailableID(client, res->id + 1, maxid, goodid)))
|
||||
maxid = res->id - 1;
|
||||
else
|
||||
id = res->id + 1;
|
||||
}
|
||||
}
|
||||
if (id > maxid)
|
||||
id = maxid = 0;
|
||||
*minp = id;
|
||||
*maxp = maxid;
|
||||
}
|
||||
|
||||
/**
|
||||
* GetXIDList is called by the XC-MISC extension's MiscGetXIDList function.
|
||||
* This function tries to find count unused XIDs for the given client. It
|
||||
* puts the IDs in the array pids and returns the number found, which should
|
||||
* almost always be the number requested.
|
||||
*
|
||||
* The circumstances that lead to a call to this function are very rare.
|
||||
* Xlib must run out of IDs while trying to generate a request that wants
|
||||
* multiple ID's, like the Multi-buffering CreateImageBuffers request.
|
||||
*
|
||||
* No rocket science in the implementation; just iterate over all
|
||||
* possible IDs for the given client and pick the first count IDs
|
||||
* that aren't in use. A more efficient algorithm could probably be
|
||||
* invented, but this will be used so rarely that this should suffice.
|
||||
*/
|
||||
|
||||
unsigned int
|
||||
GetXIDList(ClientPtr pClient, unsigned count, XID *pids)
|
||||
{
|
||||
unsigned int found = 0;
|
||||
XID id = pClient->clientAsMask;
|
||||
XID maxid;
|
||||
|
||||
maxid = id | RESOURCE_ID_MASK;
|
||||
while ( (found < count) && (id <= maxid) )
|
||||
{
|
||||
if (!LookupIDByClass(id, RC_ANY))
|
||||
{
|
||||
pids[found++] = id;
|
||||
}
|
||||
id++;
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the next usable fake client ID.
|
||||
*
|
||||
* Normally this is just the next one in line, but if we've used the last
|
||||
* in the range, we need to find a new range of safe IDs to avoid
|
||||
* over-running another client.
|
||||
*/
|
||||
|
||||
XID
|
||||
FakeClientID(register int client)
|
||||
{
|
||||
XID id, maxid;
|
||||
|
||||
id = clientTable[client].fakeID++;
|
||||
if (id != clientTable[client].endFakeID)
|
||||
return id;
|
||||
GetXIDRange(client, TRUE, &id, &maxid);
|
||||
if (!id) {
|
||||
if (!client)
|
||||
FatalError("FakeClientID: server internal ids exhausted\n");
|
||||
MarkClientException(clients[client]);
|
||||
id = ((Mask)client << CLIENTOFFSET) | (SERVER_BIT * 3);
|
||||
maxid = id | RESOURCE_ID_MASK;
|
||||
}
|
||||
clientTable[client].fakeID = id + 1;
|
||||
clientTable[client].endFakeID = maxid + 1;
|
||||
return id;
|
||||
}
|
||||
|
||||
#ifndef NXAGENT_SERVER
|
||||
Bool
|
||||
AddResource(XID id, RESTYPE type, void * value)
|
||||
{
|
||||
int client;
|
||||
register ClientResourceRec *rrec;
|
||||
register ResourcePtr res, *head;
|
||||
|
||||
client = CLIENT_ID(id);
|
||||
rrec = &clientTable[client];
|
||||
if (!rrec->buckets)
|
||||
{
|
||||
ErrorF("AddResource(%lx, %lx, %lx), client=%d \n",
|
||||
(unsigned long)id, type, (unsigned long)value, client);
|
||||
FatalError("client not in use\n");
|
||||
}
|
||||
if ((rrec->elements >= 4*rrec->buckets) &&
|
||||
(rrec->hashsize < MAXHASHSIZE))
|
||||
RebuildTable(client);
|
||||
head = &rrec->resources[Hash(client, id)];
|
||||
res = (ResourcePtr)malloc(sizeof(ResourceRec));
|
||||
if (!res)
|
||||
{
|
||||
(*DeleteFuncs[type & TypeMask])(value, id);
|
||||
return FALSE;
|
||||
}
|
||||
res->next = *head;
|
||||
res->id = id;
|
||||
res->type = type;
|
||||
res->value = value;
|
||||
*head = res;
|
||||
rrec->elements++;
|
||||
if (!(id & SERVER_BIT) && (id >= rrec->expectID))
|
||||
rrec->expectID = id + 1;
|
||||
return TRUE;
|
||||
}
|
||||
#endif /* NXAGENT_SERVER */
|
||||
|
||||
static void
|
||||
RebuildTable(int client)
|
||||
{
|
||||
register int j;
|
||||
register ResourcePtr res, next;
|
||||
ResourcePtr **tails, *resources;
|
||||
register ResourcePtr **tptr, *rptr;
|
||||
|
||||
/*
|
||||
* For now, preserve insertion order, since some ddx layers depend
|
||||
* on resources being free in the opposite order they are added.
|
||||
*/
|
||||
|
||||
j = 2 * clientTable[client].buckets;
|
||||
tails = (ResourcePtr **)malloc(j * sizeof(ResourcePtr *));
|
||||
if (!tails)
|
||||
return;
|
||||
resources = (ResourcePtr *)malloc(j * sizeof(ResourcePtr));
|
||||
if (!resources)
|
||||
{
|
||||
free(tails);
|
||||
return;
|
||||
}
|
||||
for (rptr = resources, tptr = tails; --j >= 0; rptr++, tptr++)
|
||||
{
|
||||
*rptr = NullResource;
|
||||
*tptr = rptr;
|
||||
}
|
||||
clientTable[client].hashsize++;
|
||||
for (j = clientTable[client].buckets,
|
||||
rptr = clientTable[client].resources;
|
||||
--j >= 0;
|
||||
rptr++)
|
||||
{
|
||||
for (res = *rptr; res; res = next)
|
||||
{
|
||||
next = res->next;
|
||||
res->next = NullResource;
|
||||
tptr = &tails[Hash(client, res->id)];
|
||||
**tptr = res;
|
||||
*tptr = &res->next;
|
||||
}
|
||||
}
|
||||
free(tails);
|
||||
clientTable[client].buckets *= 2;
|
||||
free(clientTable[client].resources);
|
||||
clientTable[client].resources = resources;
|
||||
}
|
||||
|
||||
#ifndef NXAGENT_SERVER
|
||||
void
|
||||
FreeResource(XID id, RESTYPE skipDeleteFuncType)
|
||||
{
|
||||
int cid;
|
||||
register ResourcePtr res;
|
||||
register ResourcePtr *prev, *head;
|
||||
register int *eltptr;
|
||||
int elements;
|
||||
Bool gotOne = FALSE;
|
||||
|
||||
if (((cid = CLIENT_ID(id)) < MAXCLIENTS) && clientTable[cid].buckets)
|
||||
{
|
||||
head = &clientTable[cid].resources[Hash(cid, id)];
|
||||
eltptr = &clientTable[cid].elements;
|
||||
|
||||
prev = head;
|
||||
while ( (res = *prev) )
|
||||
{
|
||||
if (res->id == id)
|
||||
{
|
||||
RESTYPE rtype = res->type;
|
||||
*prev = res->next;
|
||||
elements = --*eltptr;
|
||||
if (rtype != skipDeleteFuncType)
|
||||
(*DeleteFuncs[rtype & TypeMask])(res->value, res->id);
|
||||
free(res);
|
||||
if (*eltptr != elements)
|
||||
prev = head; /* prev may no longer be valid */
|
||||
gotOne = TRUE;
|
||||
}
|
||||
else
|
||||
prev = &res->next;
|
||||
}
|
||||
}
|
||||
if (!gotOne)
|
||||
ErrorF("Freeing resource id=%lX which isn't there.\n",
|
||||
(unsigned long)id);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FreeResourceByType(XID id, RESTYPE type, Bool skipFree)
|
||||
{
|
||||
int cid;
|
||||
register ResourcePtr res;
|
||||
register ResourcePtr *prev, *head;
|
||||
if (((cid = CLIENT_ID(id)) < MAXCLIENTS) && clientTable[cid].buckets)
|
||||
{
|
||||
head = &clientTable[cid].resources[Hash(cid, id)];
|
||||
|
||||
prev = head;
|
||||
while ( (res = *prev) )
|
||||
{
|
||||
if (res->id == id && res->type == type)
|
||||
{
|
||||
*prev = res->next;
|
||||
if (!skipFree)
|
||||
(*DeleteFuncs[type & TypeMask])(res->value, res->id);
|
||||
free(res);
|
||||
break;
|
||||
}
|
||||
else
|
||||
prev = &res->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* NXAGENT_SERVER */
|
||||
|
||||
/*
|
||||
* Change the value associated with a resource id. Caller
|
||||
* is responsible for "doing the right thing" with the old
|
||||
* data
|
||||
*/
|
||||
|
||||
Bool
|
||||
ChangeResourceValue (XID id, RESTYPE rtype, void * value)
|
||||
{
|
||||
int cid;
|
||||
register ResourcePtr res;
|
||||
|
||||
if (((cid = CLIENT_ID(id)) < MAXCLIENTS) && clientTable[cid].buckets)
|
||||
{
|
||||
res = clientTable[cid].resources[Hash(cid, id)];
|
||||
|
||||
for (; res; res = res->next)
|
||||
if ((res->id == id) && (res->type == rtype))
|
||||
{
|
||||
res->value = value;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Note: if func adds or deletes resources, then func can get called
|
||||
* more than once for some resources. If func adds new resources,
|
||||
* func might or might not get called for them. func cannot both
|
||||
* add and delete an equal number of resources!
|
||||
*/
|
||||
|
||||
#ifndef NXAGENT_SERVER
|
||||
void
|
||||
FindClientResourcesByType(
|
||||
ClientPtr client,
|
||||
RESTYPE type,
|
||||
FindResType func,
|
||||
void * cdata
|
||||
){
|
||||
register ResourcePtr *resources;
|
||||
register ResourcePtr this, next;
|
||||
int i, elements;
|
||||
register int *eltptr;
|
||||
|
||||
if (!client)
|
||||
client = serverClient;
|
||||
|
||||
resources = clientTable[client->index].resources;
|
||||
eltptr = &clientTable[client->index].elements;
|
||||
for (i = 0; i < clientTable[client->index].buckets; i++)
|
||||
{
|
||||
for (this = resources[i]; this; this = next)
|
||||
{
|
||||
next = this->next;
|
||||
if (!type || this->type == type) {
|
||||
elements = *eltptr;
|
||||
(*func)(this->value, this->id, cdata);
|
||||
if (*eltptr != elements)
|
||||
next = resources[i]; /* start over */
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
FindAllClientResources(
|
||||
ClientPtr client,
|
||||
FindAllRes func,
|
||||
void * cdata
|
||||
){
|
||||
register ResourcePtr *resources;
|
||||
register ResourcePtr this, next;
|
||||
int i, elements;
|
||||
register int *eltptr;
|
||||
|
||||
if (!client)
|
||||
client = serverClient;
|
||||
|
||||
resources = clientTable[client->index].resources;
|
||||
eltptr = &clientTable[client->index].elements;
|
||||
for (i = 0; i < clientTable[client->index].buckets; i++)
|
||||
{
|
||||
for (this = resources[i]; this; this = next)
|
||||
{
|
||||
next = this->next;
|
||||
elements = *eltptr;
|
||||
(*func)(this->value, this->id, this->type, cdata);
|
||||
if (*eltptr != elements)
|
||||
next = resources[i]; /* start over */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void *
|
||||
LookupClientResourceComplex(
|
||||
ClientPtr client,
|
||||
RESTYPE type,
|
||||
FindComplexResType func,
|
||||
void * cdata
|
||||
){
|
||||
ResourcePtr *resources;
|
||||
ResourcePtr this;
|
||||
int i;
|
||||
|
||||
if (!client)
|
||||
client = serverClient;
|
||||
|
||||
resources = clientTable[client->index].resources;
|
||||
for (i = 0; i < clientTable[client->index].buckets; i++) {
|
||||
for (this = resources[i]; this; this = this->next) {
|
||||
if (!type || this->type == type) {
|
||||
if((*func)(this->value, this->id, cdata))
|
||||
return this->value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
#endif /* NXAGENT_SERVER */
|
||||
|
||||
|
||||
void
|
||||
FreeClientNeverRetainResources(ClientPtr client)
|
||||
{
|
||||
ResourcePtr *resources;
|
||||
ResourcePtr this;
|
||||
ResourcePtr *prev;
|
||||
int j;
|
||||
|
||||
if (!client)
|
||||
return;
|
||||
|
||||
resources = clientTable[client->index].resources;
|
||||
for (j=0; j < clientTable[client->index].buckets; j++)
|
||||
{
|
||||
prev = &resources[j];
|
||||
while ( (this = *prev) )
|
||||
{
|
||||
RESTYPE rtype = this->type;
|
||||
if (rtype & RC_NEVERRETAIN)
|
||||
{
|
||||
*prev = this->next;
|
||||
(*DeleteFuncs[rtype & TypeMask])(this->value, this->id);
|
||||
free(this);
|
||||
}
|
||||
else
|
||||
prev = &this->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
FreeClientResources(ClientPtr client)
|
||||
{
|
||||
register ResourcePtr *resources;
|
||||
register ResourcePtr this;
|
||||
int j;
|
||||
|
||||
/* This routine shouldn't be called with a null client, but just in
|
||||
case ... */
|
||||
|
||||
if (!client)
|
||||
return;
|
||||
|
||||
HandleSaveSet(client);
|
||||
|
||||
resources = clientTable[client->index].resources;
|
||||
for (j=0; j < clientTable[client->index].buckets; j++)
|
||||
{
|
||||
/* It may seem silly to update the head of this resource list as
|
||||
we delete the members, since the entire list will be deleted any way,
|
||||
but there are some resource deletion functions "FreeClientPixels" for
|
||||
one which do a LookupID on another resource id (a Colormap id in this
|
||||
case), so the resource list must be kept valid up to the point that
|
||||
it is deleted, so every time we delete a resource, we must update the
|
||||
head, just like in FreeResource. I hope that this doesn't slow down
|
||||
mass deletion appreciably. PRH */
|
||||
|
||||
ResourcePtr *head;
|
||||
|
||||
head = &resources[j];
|
||||
|
||||
for (this = *head; this; this = *head)
|
||||
{
|
||||
RESTYPE rtype = this->type;
|
||||
*head = this->next;
|
||||
(*DeleteFuncs[rtype & TypeMask])(this->value, this->id);
|
||||
free(this);
|
||||
}
|
||||
}
|
||||
free(clientTable[client->index].resources);
|
||||
clientTable[client->index].resources = NULL;
|
||||
clientTable[client->index].buckets = 0;
|
||||
}
|
||||
|
||||
void
|
||||
FreeAllResources()
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = currentMaxClients; --i >= 0; )
|
||||
{
|
||||
if (clientTable[i].buckets)
|
||||
FreeClientResources(clients[i]);
|
||||
}
|
||||
}
|
||||
|
||||
Bool
|
||||
LegalNewID(XID id, register ClientPtr client)
|
||||
{
|
||||
|
||||
#ifdef PANORAMIX
|
||||
XID minid, maxid;
|
||||
|
||||
if (!noPanoramiXExtension) {
|
||||
minid = client->clientAsMask | (client->index ?
|
||||
SERVER_BIT : SERVER_MINID);
|
||||
maxid = (clientTable[client->index].fakeID | RESOURCE_ID_MASK) + 1;
|
||||
if ((id >= minid) && (id <= maxid))
|
||||
return TRUE;
|
||||
}
|
||||
#endif /* PANORAMIX */
|
||||
return ((client->clientAsMask == (id & ~RESOURCE_ID_MASK)) &&
|
||||
((clientTable[client->index].expectID <= id) ||
|
||||
!LookupIDByClass(id, RC_ANY)));
|
||||
}
|
||||
|
||||
#ifdef XCSECURITY
|
||||
|
||||
/* SecurityLookupIDByType and SecurityLookupIDByClass:
|
||||
* These are the heart of the resource ID security system. They take
|
||||
* two additional arguments compared to the old LookupID functions:
|
||||
* the client doing the lookup, and the access mode (see resource.h).
|
||||
* The resource is returned if it exists and the client is allowed access,
|
||||
* else NULL is returned.
|
||||
*/
|
||||
|
||||
void *
|
||||
SecurityLookupIDByType(ClientPtr client, XID id, RESTYPE rtype, Mask mode)
|
||||
{
|
||||
int cid;
|
||||
register ResourcePtr res;
|
||||
void * retval = NULL;
|
||||
|
||||
assert(client == NullClient ||
|
||||
(client->index <= currentMaxClients && clients[client->index] == client));
|
||||
assert( (rtype & TypeMask) <= lastResourceType);
|
||||
|
||||
if (((cid = CLIENT_ID(id)) < MAXCLIENTS) &&
|
||||
clientTable[cid].buckets)
|
||||
{
|
||||
res = clientTable[cid].resources[Hash(cid, id)];
|
||||
|
||||
for (; res; res = res->next)
|
||||
if ((res->id == id) && (res->type == rtype))
|
||||
{
|
||||
retval = res->value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (retval && client && client->CheckAccess)
|
||||
retval = (* client->CheckAccess)(client, id, rtype, mode, retval);
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
void *
|
||||
SecurityLookupIDByClass(ClientPtr client, XID id, RESTYPE classes, Mask mode)
|
||||
{
|
||||
int cid;
|
||||
register ResourcePtr res = NULL;
|
||||
void * retval = NULL;
|
||||
|
||||
assert(client == NullClient ||
|
||||
(client->index <= currentMaxClients && clients[client->index] == client));
|
||||
assert (classes >= lastResourceClass);
|
||||
|
||||
if (((cid = CLIENT_ID(id)) < MAXCLIENTS) &&
|
||||
clientTable[cid].buckets)
|
||||
{
|
||||
res = clientTable[cid].resources[Hash(cid, id)];
|
||||
|
||||
for (; res; res = res->next)
|
||||
if ((res->id == id) && (res->type & classes))
|
||||
{
|
||||
retval = res->value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (retval && client && client->CheckAccess)
|
||||
retval = (* client->CheckAccess)(client, id, res->type, mode, retval);
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* We can't replace the LookupIDByType and LookupIDByClass functions with
|
||||
* macros because of compatibility with loadable servers.
|
||||
*/
|
||||
|
||||
void *
|
||||
LookupIDByType(XID id, RESTYPE rtype)
|
||||
{
|
||||
return SecurityLookupIDByType(NullClient, id, rtype,
|
||||
DixUnknownAccess);
|
||||
}
|
||||
|
||||
void *
|
||||
LookupIDByClass(XID id, RESTYPE classes)
|
||||
{
|
||||
return SecurityLookupIDByClass(NullClient, id, classes,
|
||||
DixUnknownAccess);
|
||||
}
|
||||
|
||||
#else /* not XCSECURITY */
|
||||
|
||||
/*
|
||||
* LookupIDByType returns the object with the given id and type, else NULL.
|
||||
*/
|
||||
void *
|
||||
LookupIDByType(XID id, RESTYPE rtype)
|
||||
{
|
||||
int cid;
|
||||
register ResourcePtr res;
|
||||
|
||||
if (((cid = CLIENT_ID(id)) < MAXCLIENTS) &&
|
||||
clientTable[cid].buckets)
|
||||
{
|
||||
res = clientTable[cid].resources[Hash(cid, id)];
|
||||
|
||||
for (; res; res = res->next)
|
||||
if ((res->id == id) && (res->type == rtype))
|
||||
return res->value;
|
||||
}
|
||||
return (void *)NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* LookupIDByClass returns the object with the given id and any one of the
|
||||
* given classes, else NULL.
|
||||
*/
|
||||
void *
|
||||
LookupIDByClass(XID id, RESTYPE classes)
|
||||
{
|
||||
int cid;
|
||||
register ResourcePtr res;
|
||||
|
||||
if (((cid = CLIENT_ID(id)) < MAXCLIENTS) &&
|
||||
clientTable[cid].buckets)
|
||||
{
|
||||
res = clientTable[cid].resources[Hash(cid, id)];
|
||||
|
||||
for (; res; res = res->next)
|
||||
if ((res->id == id) && (res->type & classes))
|
||||
return res->value;
|
||||
}
|
||||
return (void *)NULL;
|
||||
}
|
||||
|
||||
#endif /* XCSECURITY */
|
||||
1218
nx-X11/programs/Xserver/dix/swaprep.c
Normal file
1218
nx-X11/programs/Xserver/dix/swaprep.c
Normal file
File diff suppressed because it is too large
Load Diff
1017
nx-X11/programs/Xserver/dix/swapreq.c
Normal file
1017
nx-X11/programs/Xserver/dix/swapreq.c
Normal file
File diff suppressed because it is too large
Load Diff
510
nx-X11/programs/Xserver/dix/tables.c
Normal file
510
nx-X11/programs/Xserver/dix/tables.c
Normal file
@@ -0,0 +1,510 @@
|
||||
/***********************************************************
|
||||
|
||||
Copyright 1987, 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 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.
|
||||
|
||||
******************************************************************/
|
||||
|
||||
#ifdef HAVE_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#include <nx-X11/X.h>
|
||||
#include <nx-X11/Xproto.h>
|
||||
#include "windowstr.h"
|
||||
#include "extnsionst.h"
|
||||
#include "dixstruct.h"
|
||||
#include "dixevents.h"
|
||||
#include "dispatch.h"
|
||||
#include "swaprep.h"
|
||||
#include "swapreq.h"
|
||||
|
||||
int (* InitialVector[3]) (
|
||||
ClientPtr /* client */
|
||||
) =
|
||||
{
|
||||
0,
|
||||
ProcInitialConnection,
|
||||
ProcEstablishConnection
|
||||
};
|
||||
|
||||
int (* ProcVector[256]) (
|
||||
ClientPtr /* client */
|
||||
) =
|
||||
{
|
||||
ProcBadRequest,
|
||||
ProcCreateWindow,
|
||||
ProcChangeWindowAttributes,
|
||||
ProcGetWindowAttributes,
|
||||
ProcDestroyWindow,
|
||||
ProcDestroySubwindows, /* 5 */
|
||||
ProcChangeSaveSet,
|
||||
ProcReparentWindow,
|
||||
ProcMapWindow,
|
||||
ProcMapSubwindows,
|
||||
ProcUnmapWindow, /* 10 */
|
||||
ProcUnmapSubwindows,
|
||||
ProcConfigureWindow,
|
||||
ProcCirculateWindow,
|
||||
ProcGetGeometry,
|
||||
ProcQueryTree, /* 15 */
|
||||
ProcInternAtom,
|
||||
ProcGetAtomName,
|
||||
ProcChangeProperty,
|
||||
ProcDeleteProperty,
|
||||
ProcGetProperty, /* 20 */
|
||||
ProcListProperties,
|
||||
ProcSetSelectionOwner,
|
||||
ProcGetSelectionOwner,
|
||||
ProcConvertSelection,
|
||||
ProcSendEvent, /* 25 */
|
||||
ProcGrabPointer,
|
||||
ProcUngrabPointer,
|
||||
ProcGrabButton,
|
||||
ProcUngrabButton,
|
||||
ProcChangeActivePointerGrab, /* 30 */
|
||||
ProcGrabKeyboard,
|
||||
ProcUngrabKeyboard,
|
||||
ProcGrabKey,
|
||||
ProcUngrabKey,
|
||||
ProcAllowEvents, /* 35 */
|
||||
ProcGrabServer,
|
||||
ProcUngrabServer,
|
||||
ProcQueryPointer,
|
||||
ProcGetMotionEvents,
|
||||
ProcTranslateCoords, /* 40 */
|
||||
ProcWarpPointer,
|
||||
ProcSetInputFocus,
|
||||
ProcGetInputFocus,
|
||||
ProcQueryKeymap,
|
||||
ProcOpenFont, /* 45 */
|
||||
ProcCloseFont,
|
||||
ProcQueryFont,
|
||||
ProcQueryTextExtents,
|
||||
ProcListFonts,
|
||||
ProcListFontsWithInfo, /* 50 */
|
||||
ProcSetFontPath,
|
||||
ProcGetFontPath,
|
||||
ProcCreatePixmap,
|
||||
ProcFreePixmap,
|
||||
ProcCreateGC, /* 55 */
|
||||
ProcChangeGC,
|
||||
ProcCopyGC,
|
||||
ProcSetDashes,
|
||||
ProcSetClipRectangles,
|
||||
ProcFreeGC, /* 60 */
|
||||
ProcClearToBackground,
|
||||
ProcCopyArea,
|
||||
ProcCopyPlane,
|
||||
ProcPolyPoint,
|
||||
ProcPolyLine, /* 65 */
|
||||
ProcPolySegment,
|
||||
ProcPolyRectangle,
|
||||
ProcPolyArc,
|
||||
ProcFillPoly,
|
||||
ProcPolyFillRectangle, /* 70 */
|
||||
ProcPolyFillArc,
|
||||
ProcPutImage,
|
||||
ProcGetImage,
|
||||
ProcPolyText,
|
||||
ProcPolyText, /* 75 */
|
||||
ProcImageText8,
|
||||
ProcImageText16,
|
||||
ProcCreateColormap,
|
||||
ProcFreeColormap,
|
||||
ProcCopyColormapAndFree, /* 80 */
|
||||
ProcInstallColormap,
|
||||
ProcUninstallColormap,
|
||||
ProcListInstalledColormaps,
|
||||
ProcAllocColor,
|
||||
ProcAllocNamedColor, /* 85 */
|
||||
ProcAllocColorCells,
|
||||
ProcAllocColorPlanes,
|
||||
ProcFreeColors,
|
||||
ProcStoreColors,
|
||||
ProcStoreNamedColor, /* 90 */
|
||||
ProcQueryColors,
|
||||
ProcLookupColor,
|
||||
ProcCreateCursor,
|
||||
ProcCreateGlyphCursor,
|
||||
ProcFreeCursor, /* 95 */
|
||||
ProcRecolorCursor,
|
||||
ProcQueryBestSize,
|
||||
ProcQueryExtension,
|
||||
ProcListExtensions,
|
||||
ProcChangeKeyboardMapping, /* 100 */
|
||||
ProcGetKeyboardMapping,
|
||||
ProcChangeKeyboardControl,
|
||||
ProcGetKeyboardControl,
|
||||
ProcBell,
|
||||
ProcChangePointerControl, /* 105 */
|
||||
ProcGetPointerControl,
|
||||
ProcSetScreenSaver,
|
||||
ProcGetScreenSaver,
|
||||
ProcChangeHosts,
|
||||
ProcListHosts, /* 110 */
|
||||
ProcChangeAccessControl,
|
||||
ProcChangeCloseDownMode,
|
||||
ProcKillClient,
|
||||
ProcRotateProperties,
|
||||
ProcForceScreenSaver, /* 115 */
|
||||
ProcSetPointerMapping,
|
||||
ProcGetPointerMapping,
|
||||
ProcSetModifierMapping,
|
||||
ProcGetModifierMapping,
|
||||
0, /* 120 */
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0, /* 125 */
|
||||
0,
|
||||
ProcNoOperation
|
||||
};
|
||||
|
||||
int (* SwappedProcVector[256]) (
|
||||
ClientPtr /* client */
|
||||
) =
|
||||
{
|
||||
ProcBadRequest,
|
||||
SProcCreateWindow,
|
||||
SProcChangeWindowAttributes,
|
||||
SProcResourceReq, /* GetWindowAttributes */
|
||||
SProcResourceReq, /* DestroyWindow */
|
||||
SProcResourceReq, /* 5 DestroySubwindows */
|
||||
SProcResourceReq, /* SProcChangeSaveSet, */
|
||||
SProcReparentWindow,
|
||||
SProcResourceReq, /* MapWindow */
|
||||
SProcResourceReq, /* MapSubwindows */
|
||||
SProcResourceReq, /* 10 UnmapWindow */
|
||||
SProcResourceReq, /* UnmapSubwindows */
|
||||
SProcConfigureWindow,
|
||||
SProcResourceReq, /* SProcCirculateWindow, */
|
||||
SProcResourceReq, /* GetGeometry */
|
||||
SProcResourceReq, /* 15 QueryTree */
|
||||
SProcInternAtom,
|
||||
SProcResourceReq, /* SProcGetAtomName, */
|
||||
SProcChangeProperty,
|
||||
SProcDeleteProperty,
|
||||
SProcGetProperty, /* 20 */
|
||||
SProcResourceReq, /* SProcListProperties, */
|
||||
SProcSetSelectionOwner,
|
||||
SProcResourceReq, /* SProcGetSelectionOwner, */
|
||||
SProcConvertSelection,
|
||||
SProcSendEvent, /* 25 */
|
||||
SProcGrabPointer,
|
||||
SProcResourceReq, /* SProcUngrabPointer, */
|
||||
SProcGrabButton,
|
||||
SProcUngrabButton,
|
||||
SProcChangeActivePointerGrab, /* 30 */
|
||||
SProcGrabKeyboard,
|
||||
SProcResourceReq, /* SProcUngrabKeyboard, */
|
||||
SProcGrabKey,
|
||||
SProcUngrabKey,
|
||||
SProcResourceReq, /* 35 SProcAllowEvents, */
|
||||
SProcSimpleReq, /* SProcGrabServer, */
|
||||
SProcSimpleReq, /* SProcUngrabServer, */
|
||||
SProcResourceReq, /* SProcQueryPointer, */
|
||||
SProcGetMotionEvents,
|
||||
SProcTranslateCoords, /*40 */
|
||||
SProcWarpPointer,
|
||||
SProcSetInputFocus,
|
||||
SProcSimpleReq, /* SProcGetInputFocus, */
|
||||
SProcSimpleReq, /* QueryKeymap, */
|
||||
SProcOpenFont, /* 45 */
|
||||
SProcResourceReq, /* SProcCloseFont, */
|
||||
SProcResourceReq, /* SProcQueryFont, */
|
||||
SProcResourceReq, /* SProcQueryTextExtents, */
|
||||
SProcListFonts,
|
||||
SProcListFontsWithInfo, /* 50 */
|
||||
SProcSetFontPath,
|
||||
SProcSimpleReq, /* GetFontPath, */
|
||||
SProcCreatePixmap,
|
||||
SProcResourceReq, /* SProcFreePixmap, */
|
||||
SProcCreateGC, /* 55 */
|
||||
SProcChangeGC,
|
||||
SProcCopyGC,
|
||||
SProcSetDashes,
|
||||
SProcSetClipRectangles,
|
||||
SProcResourceReq, /* 60 SProcFreeGC, */
|
||||
SProcClearToBackground,
|
||||
SProcCopyArea,
|
||||
SProcCopyPlane,
|
||||
SProcPoly, /* PolyPoint, */
|
||||
SProcPoly, /* 65 PolyLine */
|
||||
SProcPoly, /* PolySegment, */
|
||||
SProcPoly, /* PolyRectangle, */
|
||||
SProcPoly, /* PolyArc, */
|
||||
SProcFillPoly,
|
||||
SProcPoly, /* 70 PolyFillRectangle */
|
||||
SProcPoly, /* PolyFillArc, */
|
||||
SProcPutImage,
|
||||
SProcGetImage,
|
||||
SProcPolyText,
|
||||
SProcPolyText, /* 75 */
|
||||
SProcImageText,
|
||||
SProcImageText,
|
||||
SProcCreateColormap,
|
||||
SProcResourceReq, /* SProcFreeColormap, */
|
||||
SProcCopyColormapAndFree, /* 80 */
|
||||
SProcResourceReq, /* SProcInstallColormap, */
|
||||
SProcResourceReq, /* SProcUninstallColormap, */
|
||||
SProcResourceReq, /* SProcListInstalledColormaps, */
|
||||
SProcAllocColor,
|
||||
SProcAllocNamedColor, /* 85 */
|
||||
SProcAllocColorCells,
|
||||
SProcAllocColorPlanes,
|
||||
SProcFreeColors,
|
||||
SProcStoreColors,
|
||||
SProcStoreNamedColor, /* 90 */
|
||||
SProcQueryColors,
|
||||
SProcLookupColor,
|
||||
SProcCreateCursor,
|
||||
SProcCreateGlyphCursor,
|
||||
SProcResourceReq, /* 95 SProcFreeCursor, */
|
||||
SProcRecolorCursor,
|
||||
SProcQueryBestSize,
|
||||
SProcQueryExtension,
|
||||
SProcSimpleReq, /* ListExtensions, */
|
||||
SProcChangeKeyboardMapping, /* 100 */
|
||||
SProcSimpleReq, /* GetKeyboardMapping, */
|
||||
SProcChangeKeyboardControl,
|
||||
SProcSimpleReq, /* GetKeyboardControl, */
|
||||
SProcSimpleReq, /* Bell, */
|
||||
SProcChangePointerControl, /* 105 */
|
||||
SProcSimpleReq, /* GetPointerControl, */
|
||||
SProcSetScreenSaver,
|
||||
SProcSimpleReq, /* GetScreenSaver, */
|
||||
SProcChangeHosts,
|
||||
SProcSimpleReq, /* 110 ListHosts, */
|
||||
SProcSimpleReq, /* SProcChangeAccessControl, */
|
||||
SProcSimpleReq, /* SProcChangeCloseDownMode, */
|
||||
SProcResourceReq, /* SProcKillClient, */
|
||||
SProcRotateProperties,
|
||||
SProcSimpleReq, /* 115 ForceScreenSaver */
|
||||
SProcSimpleReq, /* SetPointerMapping, */
|
||||
SProcSimpleReq, /* GetPointerMapping, */
|
||||
SProcSimpleReq, /* SetModifierMapping, */
|
||||
SProcSimpleReq, /* GetModifierMapping, */
|
||||
0, /* 120 */
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0, /* 125 */
|
||||
0,
|
||||
SProcNoOperation
|
||||
};
|
||||
|
||||
EventSwapPtr EventSwapVector[128] =
|
||||
{
|
||||
(EventSwapPtr)SErrorEvent,
|
||||
NotImplemented,
|
||||
SKeyButtonPtrEvent,
|
||||
SKeyButtonPtrEvent,
|
||||
SKeyButtonPtrEvent,
|
||||
SKeyButtonPtrEvent, /* 5 */
|
||||
SKeyButtonPtrEvent,
|
||||
SEnterLeaveEvent,
|
||||
SEnterLeaveEvent,
|
||||
SFocusEvent,
|
||||
SFocusEvent, /* 10 */
|
||||
SKeymapNotifyEvent,
|
||||
SExposeEvent,
|
||||
SGraphicsExposureEvent,
|
||||
SNoExposureEvent,
|
||||
SVisibilityEvent, /* 15 */
|
||||
SCreateNotifyEvent,
|
||||
SDestroyNotifyEvent,
|
||||
SUnmapNotifyEvent,
|
||||
SMapNotifyEvent,
|
||||
SMapRequestEvent, /* 20 */
|
||||
SReparentEvent,
|
||||
SConfigureNotifyEvent,
|
||||
SConfigureRequestEvent,
|
||||
SGravityEvent,
|
||||
SResizeRequestEvent, /* 25 */
|
||||
SCirculateEvent,
|
||||
SCirculateEvent,
|
||||
SPropertyEvent,
|
||||
SSelectionClearEvent,
|
||||
SSelectionRequestEvent, /* 30 */
|
||||
SSelectionNotifyEvent,
|
||||
SColormapEvent,
|
||||
SClientMessageEvent,
|
||||
SMappingEvent,
|
||||
};
|
||||
|
||||
|
||||
ReplySwapPtr ReplySwapVector[256] =
|
||||
{
|
||||
ReplyNotSwappd,
|
||||
ReplyNotSwappd,
|
||||
ReplyNotSwappd,
|
||||
(ReplySwapPtr)SGetWindowAttributesReply,
|
||||
ReplyNotSwappd,
|
||||
ReplyNotSwappd, /* 5 */
|
||||
ReplyNotSwappd,
|
||||
ReplyNotSwappd,
|
||||
ReplyNotSwappd,
|
||||
ReplyNotSwappd,
|
||||
ReplyNotSwappd, /* 10 */
|
||||
ReplyNotSwappd,
|
||||
ReplyNotSwappd,
|
||||
ReplyNotSwappd,
|
||||
(ReplySwapPtr)SGetGeometryReply,
|
||||
(ReplySwapPtr)SQueryTreeReply, /* 15 */
|
||||
(ReplySwapPtr)SInternAtomReply,
|
||||
(ReplySwapPtr)SGetAtomNameReply,
|
||||
ReplyNotSwappd,
|
||||
ReplyNotSwappd,
|
||||
(ReplySwapPtr)SGetPropertyReply, /* 20 */
|
||||
(ReplySwapPtr)SListPropertiesReply,
|
||||
ReplyNotSwappd,
|
||||
(ReplySwapPtr)SGetSelectionOwnerReply,
|
||||
ReplyNotSwappd,
|
||||
ReplyNotSwappd, /* 25 */
|
||||
(ReplySwapPtr)SGenericReply, /* SGrabPointerReply, */
|
||||
ReplyNotSwappd,
|
||||
ReplyNotSwappd,
|
||||
ReplyNotSwappd,
|
||||
ReplyNotSwappd, /* 30 */
|
||||
(ReplySwapPtr)SGenericReply, /* SGrabKeyboardReply, */
|
||||
ReplyNotSwappd,
|
||||
ReplyNotSwappd,
|
||||
ReplyNotSwappd,
|
||||
ReplyNotSwappd, /* 35 */
|
||||
ReplyNotSwappd,
|
||||
ReplyNotSwappd,
|
||||
(ReplySwapPtr)SQueryPointerReply,
|
||||
(ReplySwapPtr)SGetMotionEventsReply,
|
||||
(ReplySwapPtr)STranslateCoordsReply, /* 40 */
|
||||
ReplyNotSwappd,
|
||||
ReplyNotSwappd,
|
||||
(ReplySwapPtr)SGetInputFocusReply,
|
||||
(ReplySwapPtr)SQueryKeymapReply,
|
||||
ReplyNotSwappd, /* 45 */
|
||||
ReplyNotSwappd,
|
||||
(ReplySwapPtr)SQueryFontReply,
|
||||
(ReplySwapPtr)SQueryTextExtentsReply,
|
||||
(ReplySwapPtr)SListFontsReply,
|
||||
(ReplySwapPtr)SListFontsWithInfoReply, /* 50 */
|
||||
ReplyNotSwappd,
|
||||
(ReplySwapPtr)SGetFontPathReply,
|
||||
ReplyNotSwappd,
|
||||
ReplyNotSwappd,
|
||||
ReplyNotSwappd, /* 55 */
|
||||
ReplyNotSwappd,
|
||||
ReplyNotSwappd,
|
||||
ReplyNotSwappd,
|
||||
ReplyNotSwappd,
|
||||
ReplyNotSwappd, /* 60 */
|
||||
ReplyNotSwappd,
|
||||
ReplyNotSwappd,
|
||||
ReplyNotSwappd,
|
||||
ReplyNotSwappd,
|
||||
ReplyNotSwappd, /* 65 */
|
||||
ReplyNotSwappd,
|
||||
ReplyNotSwappd,
|
||||
ReplyNotSwappd,
|
||||
ReplyNotSwappd,
|
||||
ReplyNotSwappd, /* 70 */
|
||||
ReplyNotSwappd,
|
||||
ReplyNotSwappd,
|
||||
(ReplySwapPtr)SGetImageReply,
|
||||
ReplyNotSwappd,
|
||||
ReplyNotSwappd, /* 75 */
|
||||
ReplyNotSwappd,
|
||||
ReplyNotSwappd,
|
||||
ReplyNotSwappd,
|
||||
ReplyNotSwappd,
|
||||
ReplyNotSwappd, /* 80 */
|
||||
ReplyNotSwappd,
|
||||
ReplyNotSwappd,
|
||||
(ReplySwapPtr)SListInstalledColormapsReply,
|
||||
(ReplySwapPtr)SAllocColorReply,
|
||||
(ReplySwapPtr)SAllocNamedColorReply, /* 85 */
|
||||
(ReplySwapPtr)SAllocColorCellsReply,
|
||||
(ReplySwapPtr)SAllocColorPlanesReply,
|
||||
ReplyNotSwappd,
|
||||
ReplyNotSwappd,
|
||||
ReplyNotSwappd, /* 90 */
|
||||
(ReplySwapPtr)SQueryColorsReply,
|
||||
(ReplySwapPtr)SLookupColorReply,
|
||||
ReplyNotSwappd,
|
||||
ReplyNotSwappd,
|
||||
ReplyNotSwappd, /* 95 */
|
||||
ReplyNotSwappd,
|
||||
(ReplySwapPtr)SQueryBestSizeReply,
|
||||
(ReplySwapPtr)SGenericReply, /* SQueryExtensionReply, */
|
||||
(ReplySwapPtr)SListExtensionsReply,
|
||||
ReplyNotSwappd, /* 100 */
|
||||
(ReplySwapPtr)SGetKeyboardMappingReply,
|
||||
ReplyNotSwappd,
|
||||
(ReplySwapPtr)SGetKeyboardControlReply,
|
||||
ReplyNotSwappd,
|
||||
ReplyNotSwappd, /* 105 */
|
||||
(ReplySwapPtr)SGetPointerControlReply,
|
||||
ReplyNotSwappd,
|
||||
(ReplySwapPtr)SGetScreenSaverReply,
|
||||
ReplyNotSwappd,
|
||||
(ReplySwapPtr)SListHostsReply, /* 110 */
|
||||
ReplyNotSwappd,
|
||||
ReplyNotSwappd,
|
||||
ReplyNotSwappd,
|
||||
ReplyNotSwappd,
|
||||
ReplyNotSwappd, /* 115 */
|
||||
(ReplySwapPtr)SGenericReply, /* SetPointerMapping */
|
||||
(ReplySwapPtr)SGetPointerMappingReply,
|
||||
(ReplySwapPtr)SGenericReply, /* SetModifierMapping */
|
||||
(ReplySwapPtr)SGetModifierMappingReply, /* 119 */
|
||||
ReplyNotSwappd, /* 120 */
|
||||
ReplyNotSwappd, /* 121 */
|
||||
ReplyNotSwappd, /* 122 */
|
||||
ReplyNotSwappd, /* 123 */
|
||||
ReplyNotSwappd, /* 124 */
|
||||
ReplyNotSwappd, /* 125 */
|
||||
ReplyNotSwappd, /* 126 */
|
||||
ReplyNotSwappd, /* NoOperation */
|
||||
ReplyNotSwappd
|
||||
};
|
||||
3891
nx-X11/programs/Xserver/dix/window.c
Normal file
3891
nx-X11/programs/Xserver/dix/window.c
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user