summaryrefslogtreecommitdiff
path: root/programs
diff options
context:
space:
mode:
Diffstat (limited to 'programs')
-rw-r--r--programs/Xserver/Imakefile30
-rw-r--r--programs/Xserver/Xprint/Imakefile10
-rw-r--r--programs/Xserver/Xserver.man7
-rw-r--r--programs/Xserver/cfb/cfbcmap.c50
-rw-r--r--programs/Xserver/hw/dec/ws/Xdec.man4
-rw-r--r--programs/Xserver/hw/hp/Xhp.man4
-rw-r--r--programs/Xserver/hw/sun/Xsun.man4
-rw-r--r--programs/Xserver/hw/sun/constype.man4
-rw-r--r--programs/Xserver/hw/sun/kbd_mode.man4
-rw-r--r--programs/Xserver/hw/vfb/Imakefile15
-rw-r--r--programs/Xserver/hw/vfb/Xvfb.man4
-rw-r--r--programs/Xserver/hw/xfree86/CHANGELOG8
-rw-r--r--programs/Xserver/hw/xfree86/doc/Japanese/man/XF86Config.man4
-rw-r--r--programs/Xserver/hw/xnest/Imakefile4
-rw-r--r--programs/Xserver/hw/xnest/Xnest.man4
-rw-r--r--programs/Xserver/mi/migc.c4
-rw-r--r--programs/Xserver/mi/migc.h4
-rw-r--r--programs/Xserver/mi/miinitext.c27
-rw-r--r--programs/Xserver/pandix/Imakefile109
-rw-r--r--programs/Xserver/pandix/dispatch.c4100
-rw-r--r--programs/Xserver/pandix/dixfonts.c2142
-rw-r--r--programs/Xserver/pandix/events.c4470
-rw-r--r--programs/Xserver/pandix/main.c756
-rw-r--r--programs/Xserver/pandix/resource.c981
-rw-r--r--programs/Xserver/pandix/window.c3830
-rw-r--r--programs/Xserver/panmi/Imakefile117
-rw-r--r--programs/Xserver/panmi/miexpose.c902
-rw-r--r--programs/Xserver/panmi/miregion.c2449
-rw-r--r--programs/Xserver/panmi/mivaltree.c1282
-rw-r--r--programs/appres/appres.man4
-rw-r--r--programs/bdftopcf/bdftopcf.man4
-rw-r--r--programs/bitmap/bitmap.man4
-rw-r--r--programs/editres/editres.man4
-rw-r--r--programs/fsinfo/fsinfo.man4
-rw-r--r--programs/fslsfonts/fslsfonts.man4
-rw-r--r--programs/fstobdf/fstobdf.man4
-rw-r--r--programs/iceauth/iceauth.man4
-rw-r--r--programs/lbxproxy/lbxproxy.man4
-rw-r--r--programs/mkfontdir/mkfontdir.man4
-rw-r--r--programs/oclock/oclock.man4
-rw-r--r--programs/proxymngr/proxymngr.man8
-rw-r--r--programs/rgb/showrgb.man4
-rw-r--r--programs/rstart/rstart.man4
-rw-r--r--programs/rstart/rstartd.man4
-rw-r--r--programs/scripts/xon.man4
-rw-r--r--programs/smproxy/smproxy.man4
-rw-r--r--programs/twm/twm.man4
-rw-r--r--programs/x11perf/x11pcomp.man4
-rw-r--r--programs/x11perf/x11perf.man4
-rw-r--r--programs/xauth/xauth.man4
-rw-r--r--programs/xclipboard/xclipboard.man4
-rw-r--r--programs/xclipboard/xcutsel.man4
-rw-r--r--programs/xclock/xclock.man4
-rw-r--r--programs/xcmsdb/xcmsdb.man4
-rw-r--r--programs/xconsole/xconsole.man4
-rw-r--r--programs/xdm/sessreg.man4
-rw-r--r--programs/xdm/xdm.man6
-rw-r--r--programs/xdpyinfo/xdpyinfo.man6
-rw-r--r--programs/xfd/xfd.man4
-rw-r--r--programs/xfindproxy/xfindproxy.man4
-rw-r--r--programs/xfs/xfs.man4
-rw-r--r--programs/xfwp/xfwp.man4
-rw-r--r--programs/xhost/xhost.man4
-rw-r--r--programs/xieperf/xieperf.man4
-rw-r--r--programs/xinit/startx.man4
-rw-r--r--programs/xinit/xinit.man6
-rw-r--r--programs/xkbcomp/xkbcomp.man4
-rw-r--r--programs/xkbevd/xkbevd.man4
-rw-r--r--programs/xkbprint/xkbprint.man4
-rw-r--r--programs/xkill/xkill.man4
-rw-r--r--programs/xlogo/xlogo.man4
-rw-r--r--programs/xlsatoms/xlsatoms.man4
-rw-r--r--programs/xlsclients/xlscli.man4
-rw-r--r--programs/xlsfonts/xlsfonts.man4
-rw-r--r--programs/xmag/xmag.man4
-rw-r--r--programs/xmodmap/xmodmap.man6
-rw-r--r--programs/xprop/xprop.man4
-rw-r--r--programs/xrdb/xrdb.man4
-rw-r--r--programs/xrefresh/xrefresh.man4
-rw-r--r--programs/xrx/helper/xrx.man4
-rw-r--r--programs/xrx/plugin/libxrx.man6
-rw-r--r--programs/xrx/testplugin/testplugin.man4
-rw-r--r--programs/xset/xset.man6
-rw-r--r--programs/xsetroot/xsetroot.man4
-rw-r--r--programs/xsm/xsm.man4
-rw-r--r--programs/xstdcmap/xstdcmap.man4
-rw-r--r--programs/xterm/resize.man6
-rw-r--r--programs/xterm/xterm.man7
-rw-r--r--programs/xwd/xwd.man4
-rw-r--r--programs/xwininfo/xwininfo.man6
-rw-r--r--programs/xwud/xwud.man4
91 files changed, 181 insertions, 21419 deletions
diff --git a/programs/Xserver/Imakefile b/programs/Xserver/Imakefile
index c1f842c35..7b0db0ee0 100644
--- a/programs/Xserver/Imakefile
+++ b/programs/Xserver/Imakefile
@@ -2,7 +2,7 @@ XCOMM $TOG: Imakefile /main/249 1997/12/11 11:18:14 kaleb $
/*
* Server Master Makefile
*/
-XCOMM $XFree86: xc/programs/Xserver/Imakefile,v 3.129 1998/03/20 21:04:46 hohndel Exp $
+XCOMM $XFree86: xc/programs/Xserver/Imakefile,v 3.130 1998/03/22 05:09:25 dawes Exp $
#ifndef InstallXserverSetUID
#define InstallXserverSetUID NO
@@ -20,11 +20,7 @@ INSTPGMFLAGS =
#define BarePostFbLibs $(MFB) $(XPFBLIBS) $(MI)
#define PostFbLibs BarePostFbLibs $(EXTENSIONS)
#define NoMfbBarePostFbLibs $(XPFBLIBS) $(MI)
-#ifndef BuildXinerama
#define NoMfbPostFbLibs NoMfbBarePostFbLibs $(EXTENSIONS)
-#else
-#define NoMfbPostFbLibs $(EXTENSIONS) NoMfbBarePostFbLibs $(EXTENSIONS)
-#endif
#define MFBBareLibs PreFbLibs BarePostFbLibs
#define NoMFBBareLibs PreFbLibs NoMfbBarePostFbLibs
@@ -136,12 +132,8 @@ XPDDXFBLIBS = $(MFB) $(CFB32)
XPDDXDIR = Xprint
#endif
#if !BuildXprint || PrintOnlyServer
-#if BuildXinerama
-XPFBLIBS = pandix/LibraryTargetName(xpstubs)
-#else
XPFBLIBS = dix/LibraryTargetName(xpstubs)
#endif
-#endif
#if DoLoadableServer
EXTENSIONS = $(OTHEREXTS)
@@ -182,14 +174,9 @@ XPFBLIBS = dix/LibraryTargetName(xpstubs)
CFB24 = cfb/LibraryTargetName(cfb) cfb24/LibraryTargetName(cfb)
CFB32 = cfb/LibraryTargetName(cfb) cfb32/LibraryTargetName(cfb)
#endif
-#if BuildXinerama
- MI = panmi/LibraryTargetName(mi)
- DIX = pandix/LibraryTargetName(dix)
-#else
MI = mi/LibraryTargetName(mi)
MIINITEXTOBJ = mi/miinitext.o
DIX = dix/LibraryTargetName(dix)
-#endif
FONT = $(DEPFONTLIB)
#ifdef ServerExtraSysLibs
EXTRASYSLIBS = ServerExtraSysLibs
@@ -199,13 +186,8 @@ XPFBLIBS = dix/LibraryTargetName(xpstubs)
#else
SYSLIBS = $(ZLIB) MathLibrary Krb5Libraries DBMLibrary $(EXTRASYSLIBS)
#endif
-#if BuildXinerama
- CBRT = panmi/LibraryTargetName(cbrt)
- STDDIRS = include pandix os panmi $(XPDDXDIR) $(EXTDIRS)
-#else
CBRT = mi/LibraryTargetName(cbrt)
STDDIRS = include dix os mi $(XPDDXDIR) $(EXTDIRS)
-#endif
XCOMM
XCOMM This turns off the default rule for compiling .c files because
@@ -1739,13 +1721,10 @@ CFB8DIR = cfb
CFB32DIR = cfb32
XPSUBDIRS = $(STDDIRS) $(MFBDIR) $(CFB8DIR) $(CFB32DIR) $(DEPDIRS)
#if PrintOnlyServer
-#if BuildXinerama
-XPPANSTUBOBJS = Xprint/panoramiXstubs.o
-#endif
#if BuildDPMS
XPDPMSSTUBOBJS = Xprint/dpmsstubs.o
#endif
-XPOBJS = Xprint/ddxInit.o Xprint/miinitext.o $(XPPANSTUBOBJS) $(XPDPMSSTUBOBJS)
+XPOBJS = Xprint/ddxInit.o Xprint/miinitext.o $(XPDPMSSTUBOBJS)
XPLIBS = PreFbLibs $(XPDDXLIBS) $(XPDDXFBLIBS) PostFbLibs
#else
XPOBJS = Xprint/ddxInit.o
@@ -1847,13 +1826,10 @@ XVFBDDXDIR = hw
#endif
XVFBDIRS = $(STDDIRS) $(MFBDIR) $(CFB8DIR) $(CFB16DIR) $(CFB24DIR) $(CFB32DIR) $(XVFBDDXDIR) $(DEPDIRS)
#if !defined(LynxOSArchitecture) && !defined(Win32Architecture)
-#if BuildXinerama
-XVFBPANSTUBOBJS = hw/vfb/panoramiXstubs.o
-#endif
#if BuildDPMS
XVFBDPMSSTUBOBJS = hw/vfb/dpmsstubs.o
#endif
-XVFBOBJS = hw/vfb/stubs.o hw/vfb/miinitext.o $(XVFBPANSTUBOBJS) $(XVFBDPMSSTUBOBJS)
+XVFBOBJS = hw/vfb/stubs.o hw/vfb/miinitext.o $(XVFBDPMSSTUBOBJS)
#else
XVFBOBJS = dix/main.o hw/vfb/stubs.o hw/vfb/miinitext.o
#endif
diff --git a/programs/Xserver/Xprint/Imakefile b/programs/Xserver/Xprint/Imakefile
index 18ab38210..ddad3821d 100644
--- a/programs/Xserver/Xprint/Imakefile
+++ b/programs/Xserver/Xprint/Imakefile
@@ -1,9 +1,9 @@
-XCOMM $TOG: Imakefile /main/5 1997/11/14 11:11:40 kaleb $
+XCOMM $TOG: Imakefile /main/3 1997/06/11 16:26:50 samborn $
-XCOMM $XFree86: xc/programs/Xserver/Xprint/Imakefile,v 1.9 1997/11/16 06:17:53 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/Xprint/Imakefile,v 1.10 1997/11/22 06:50:20 dawes Exp $
#include <Server.tmpl>
#ifndef XpRasterDDX
@@ -40,8 +40,8 @@ XPEXT_DEFINES = PrintServerExtensions
#else
XPEXT_DEFINES = $(EXT_DEFINES)
#endif
-SRCS3 = miinitext.c panoramiXstubs.c dpmsstubs.c
-OBJS3 = miinitext.o panoramiXstubs.o dpmsstubs.o
+SRCS3 = miinitext.c dpmsstubs.c
+OBJS3 = miinitext.o dpmsstubs.o
#endif
SRCS2 = ddxInit.c
OBJS2 = ddxInit.o
@@ -105,8 +105,6 @@ SpecialCObjectRule(ddxInit,$(ICONFIGFILES),$(PO_DEFINES) $(OS_DEFINES) $(EXT_DEF
LinkSourceFile(miinitext.c,$(SERVERSRC)/mi)
SpecialCObjectRule(miinitext,$(ICONFIGFILES),$(PO_DEFINES) $(OS_DEFINES) $(XPEXT_DEFINES) -DXPRINT -UGLXEXT)
#if PrintOnlyServer
-LinkSourceFile(panoramiXstubs.c,$(SERVERSRC)/Xext)
-SpecialCObjectRule(panoramiXstubs,$(ICONFIGFILES),$(PO_DEFINES) $(OS_DEFINES) $(XPEXT_DEFINES) -DXPRINT)
LinkSourceFile(dpmsstubs.c,$(SERVERSRC)/Xext)
SpecialCObjectRule(dpmsstubs,$(ICONFIGFILES),$(PO_DEFINES) $(OS_DEFINES) $(XPEXT_DEFINES) -DXPRINT)
#endif
diff --git a/programs/Xserver/Xserver.man b/programs/Xserver/Xserver.man
index c885da318..02ded52d0 100644
--- a/programs/Xserver/Xserver.man
+++ b/programs/Xserver/Xserver.man
@@ -1,5 +1,5 @@
.\" $TOG: Xserver.man /main/67 1997/11/08 19:26:20 barstow $
-.\" $XFree86: xc/programs/Xserver/Xserver.man,v 3.8 1997/11/16 06:17:49 dawes Exp $
+.\" $XFree86: xc/programs/Xserver/Xserver.man,v 3.9 1997/12/06 09:37:41 dawes Exp $
.\" Copyright (c) 1984 - 1991, 1993, 1994 X Consortium
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
@@ -25,7 +25,7 @@
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
-.TH XSERVER 1 "Release 6.4" "X Version 11"
+.TH XSERVER 1 "Release 6.3" "X Version 11"
.SH NAME
Xserver \- X Window System display server
.SH SYNOPSIS
@@ -220,9 +220,6 @@ the client that it is doing so.
.B \-x \fIextension\fP
loads the specified extension at init.
This is a no-op for most implementations.
-.TP 8
-.B [+-]xinerama
-enable(+) or disable(-) XINERAMA extension. Default is disabled.
.SH SERVER DEPENDENT OPTIONS
Some X servers accept the following options:
.TP 8
diff --git a/programs/Xserver/cfb/cfbcmap.c b/programs/Xserver/cfb/cfbcmap.c
index a02b11a36..548be6e0a 100644
--- a/programs/Xserver/cfb/cfbcmap.c
+++ b/programs/Xserver/cfb/cfbcmap.c
@@ -1,4 +1,4 @@
-/* $TOG: cfbcmap.c /main/24 1997/11/04 09:47:14 kaleb $ */
+/* $XConsortium: cfbcmap.c,v 4.19 94/04/17 20:28:46 dpw Exp $ */
/************************************************************
Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
@@ -27,7 +27,7 @@ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
THE USE OR PERFORMANCE OF THIS SOFTWARE.
********************************************************/
-/* $XFree86: xc/programs/Xserver/cfb/cfbcmap.c,v 3.4 1997/11/16 06:17:53 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/cfb/cfbcmap.c,v 3.5 1998/01/25 01:22:55 dawes Exp $ */
#include "X.h"
@@ -313,45 +313,10 @@ Bool
cfbCreateDefColormap(pScreen)
ScreenPtr pScreen;
{
-/*
- * In the following sources PC X server vendors may want to delete
- * "_not_tog" from "#ifdef WIN32_not_tog"
- */
-#ifdef WIN32_not_tog
- /*
- * these are the MS-Windows desktop colors, adjusted for X's 16-bit
- * color specifications.
- */
- static xColorItem citems[] = {
- { 0, 0, 0, 0, 0, 0 },
- { 1, 0x8000, 0, 0, 0, 0 },
- { 2, 0, 0x8000, 0, 0, 0 },
- { 3, 0x8000, 0x8000, 0, 0, 0 },
- { 4, 0, 0, 0x8000, 0, 0 },
- { 5, 0x8000, 0, 0x8000, 0, 0 },
- { 6, 0, 0x8000, 0x8000, 0, 0 },
- { 7, 0xc000, 0xc000, 0xc000, 0, 0 },
- { 8, 0xc000, 0xdc00, 0xc000, 0, 0 },
- { 9, 0xa600, 0xca00, 0xf000, 0, 0 },
- { 246, 0xff00, 0xfb00, 0xf000, 0, 0 },
- { 247, 0xa000, 0xa000, 0xa400, 0, 0 },
- { 248, 0x8000, 0x8000, 0x8000, 0, 0 },
- { 249, 0xff00, 0, 0, 0, 0 },
- { 250, 0, 0xff00, 0, 0, 0 },
- { 251, 0xff00, 0xff00, 0, 0, 0 },
- { 252, 0, 0, 0xff00, 0, 0 },
- { 253, 0xff00, 0, 0xff00, 0, 0 },
- { 254, 0, 0xff00, 0xff00, 0, 0 },
- { 255, 0xff00, 0xff00, 0xff00, 0, 0 }
- };
-#define NUM_DESKTOP_COLORS sizeof citems / sizeof citems[0]
- int i;
-#else
unsigned short zero = 0, ones = 0xFFFF;
-#endif
- Pixel wp, bp;
VisualPtr pVisual;
ColormapPtr cmap;
+ Pixel wp, bp;
for (pVisual = pScreen->visuals;
pVisual->vid != pScreen->rootVisual;
@@ -365,14 +330,6 @@ cfbCreateDefColormap(pScreen)
return FALSE;
wp = pScreen->whitePixel;
bp = pScreen->blackPixel;
-#ifdef WIN32_not_tog
- for (i = 0; i < NUM_DESKTOP_COLORS; i++) {
- if (AllocColor (cmap,
- &citems[i].red, &citems[i].green, &citems[i].blue,
- &citems[i].pixel, 0) != Success)
- return FALSE;
- }
-#else
if ((AllocColor(cmap, &ones, &ones, &ones, &wp, 0) !=
Success) ||
(AllocColor(cmap, &zero, &zero, &zero, &bp, 0) !=
@@ -380,7 +337,6 @@ cfbCreateDefColormap(pScreen)
return FALSE;
pScreen->whitePixel = wp;
pScreen->blackPixel = bp;
-#endif
(*pScreen->InstallColormap)(cmap);
return TRUE;
}
diff --git a/programs/Xserver/hw/dec/ws/Xdec.man b/programs/Xserver/hw/dec/ws/Xdec.man
index 848dd82f9..995cb764c 100644
--- a/programs/Xserver/hw/dec/ws/Xdec.man
+++ b/programs/Xserver/hw/dec/ws/Xdec.man
@@ -1,4 +1,4 @@
-.\" $TOG: Xdec.man /main/8 1997/11/04 21:19:23 kaleb $
+.\" $XConsortium: Xdec.man /main/7 1995/12/15 14:02:33 gildea $
.\" Copyright 1991 Digital Equipment Corporation
.\" Copyright (c) 1993 X Consortium
.\"
@@ -25,7 +25,7 @@
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
-.TH XDEC 1 "Release 6.4" "X Version 11"
+.TH XDEC 1 "Release 6.1" "X Version 11"
.SH Name
Xdec \- X server for Digital RISC machines
.SH Syntax
diff --git a/programs/Xserver/hw/hp/Xhp.man b/programs/Xserver/hw/hp/Xhp.man
index 11fb6abb7..0fb56d972 100644
--- a/programs/Xserver/hw/hp/Xhp.man
+++ b/programs/Xserver/hw/hp/Xhp.man
@@ -1,4 +1,4 @@
-.\" $TOG: Xhp.man /main/5 1997/11/04 21:19:30 kaleb $
+.\" $XConsortium: Xhp.man /main/4 1996/12/09 17:32:35 kaleb $
.\" Copyright (c) 1994 Hewlett-Packard Company
.\" Copyright (c) 1994 X Consortium
.\"
@@ -31,7 +31,7 @@
.\" for errors contained herein or direct, indirect, special, incidental or
.\" consequential damages in connection with the furnishing, performance, or
.\" use of this material.
-.TH Xhp 1 "Release 6.4" "X Version 11"
+.TH Xhp 1 "Release 6.3" "X Version 11"
.SH NAME
Xhp \- cfb-based X window system server for Hewlett-Packard workstations
.SH SYNOPSIS
diff --git a/programs/Xserver/hw/sun/Xsun.man b/programs/Xserver/hw/sun/Xsun.man
index 717e4a0ad..23780aba9 100644
--- a/programs/Xserver/hw/sun/Xsun.man
+++ b/programs/Xserver/hw/sun/Xsun.man
@@ -1,4 +1,4 @@
-.\" $TOG: Xsun.man /main/28 1997/11/04 21:19:34 kaleb $
+.\" $XConsortium: Xsun.man /main/27 1996/12/09 17:32:41 kaleb $
.\" Copyright 1988 Sun Microsystems, Inc.
.\" Copyright (c) 1993, 1994 X Consortium
.\"
@@ -25,7 +25,7 @@
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
-.TH XSUN 1 "Release 6.4" "X Version 11"
+.TH XSUN 1 "Release 6.3" "X Version 11"
.SH NAME
Xsun, XsunMono, Xsun24 \- Sun server for X Version 11
.SH SYNOPSIS
diff --git a/programs/Xserver/hw/sun/constype.man b/programs/Xserver/hw/sun/constype.man
index 511dc9565..a7ffbea88 100644
--- a/programs/Xserver/hw/sun/constype.man
+++ b/programs/Xserver/hw/sun/constype.man
@@ -1,5 +1,5 @@
-.\" $TOG: constype.man /main/13 1997/11/04 21:19:39 kaleb $
-.TH CONSTYPE 1 "Release 6.4" "X Version 11"
+.\" $XConsortium: constype.man /main/12 1996/12/09 17:32:45 kaleb $
+.TH CONSTYPE 1 "Release 6.3" "X Version 11"
.SH NAME
constype \- print type of Sun console
.SH SYNOPSIS
diff --git a/programs/Xserver/hw/sun/kbd_mode.man b/programs/Xserver/hw/sun/kbd_mode.man
index 99cdf8096..c53533ad8 100644
--- a/programs/Xserver/hw/sun/kbd_mode.man
+++ b/programs/Xserver/hw/sun/kbd_mode.man
@@ -1,4 +1,4 @@
-.\" $TOG: kbd_mode.man /main/13 1997/11/04 21:19:43 kaleb $
+.\" $XConsortium: kbd_mode.man /main/12 1996/12/09 17:32:49 kaleb $
.\" Copyright 1987 Sun Microsystems, Inc.
.\" Copyright (c) 1993 X Consortium
.\"
@@ -25,7 +25,7 @@
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
-.TH KBD_MODE 1 "Release 6.4" "X Version 11"
+.TH KBD_MODE 1 "Release 6.3" "X Version 11"
.SH NAME
kbd_mode \- recover the Sun console keyboard
.SH SYNOPSIS
diff --git a/programs/Xserver/hw/vfb/Imakefile b/programs/Xserver/hw/vfb/Imakefile
index 9956f4def..d6ce11270 100644
--- a/programs/Xserver/hw/vfb/Imakefile
+++ b/programs/Xserver/hw/vfb/Imakefile
@@ -1,5 +1,5 @@
-XCOMM $TOG: Imakefile /main/12 1997/11/16 16:01:28 kaleb $
-XCOMM $XFree86: xc/programs/Xserver/hw/vfb/Imakefile,v 3.13 1997/11/22 06:50:25 dawes Exp $
+OMM $XConsortium: Imakefile /main/10 1996/12/02 10:20:33 lehors $
+XCOMM $XFree86: xc/programs/Xserver/hw/vfb/Imakefile,v 3.14 1997/11/22 08:17:34 dawes Exp $
#include <Server.tmpl>
#if HasShm
@@ -27,12 +27,6 @@ INCLUDES = -I. -I$(XBUILDINCDIR) -I$(FONTINCSRC) \
DEFINES = ServerOSDefines $(SHMDEF) $(MMAPDEF)
DEPEND_DEFINES = -UXFree86LOADER
-#if BuildXinerama
-PAN_DEFINES = -DNO_PANORAMIX
-SRCSB = panoramiXstubs.c
-OBJSB = panoramiXstubs.o
-#endif
-
#if BuildDPMS
SRCSC = dpmsstubs.c
OBJSC = dpmsstubs.o
@@ -55,11 +49,6 @@ SpecialCObjectRule(InitInput,$(ICONFIGFILES),$(EXT_DEFINES))
LinkSourceFile(miinitext.c,$(SERVERSRC)/mi)
SpecialCObjectRule(miinitext,$(ICONFIGFILES),$(EXT_DEFINES) $(PAN_DEFINES) -DNO_HW_ONLY_EXTS -DNO_MODULE_EXTS $(EXT_MODULE_DEFINES) -UXFree86LOADER)
-#if BuildXinerama
-LinkSourceFile(panoramiXstubs.c,$(SERVERSRC)/Xext)
-SpecialCObjectRule(panoramiXstubs,$(ICONFIGFILES),$(EXT_DEFINES) $(PAN_DEFINES))
-#endif
-
#if BuildDPMS
LinkSourceFile(dpmsstubs.c,$(SERVERSRC)/Xext)
SpecialCObjectRule(dpmsstubs,$(ICONFIGFILES),$(EXT_DEFINES))
diff --git a/programs/Xserver/hw/vfb/Xvfb.man b/programs/Xserver/hw/vfb/Xvfb.man
index 076353d7b..2412bf114 100644
--- a/programs/Xserver/hw/vfb/Xvfb.man
+++ b/programs/Xserver/hw/vfb/Xvfb.man
@@ -1,4 +1,4 @@
-.\" $TOG: Xvfb.man /main/11 1997/11/04 21:19:47 kaleb $
+.\" $XConsortium: Xvfb.man /main/10 1996/12/09 17:32:53 kaleb $
.\" Copyright (c) 1993 X Consortium
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
@@ -24,7 +24,7 @@
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
-.TH XVFB 1 "Release 6.4" "X Version 11"
+.TH XVFB 1 "Release 6.3" "X Version 11"
.SH NAME
Xvfb \- virtual framebuffer X server for X Version 11
.SH SYNOPSIS
diff --git a/programs/Xserver/hw/xfree86/CHANGELOG b/programs/Xserver/hw/xfree86/CHANGELOG
index 09bd908aa..fb28f8c04 100644
--- a/programs/Xserver/hw/xfree86/CHANGELOG
+++ b/programs/Xserver/hw/xfree86/CHANGELOG
@@ -1,4 +1,10 @@
XFree86 3.9Ag (05 April 1998)
+1646. Back out the following R6.4-related changes:
+ #1169, 1170, 1342 -- version numbering changes,
+ #1167 -- CUP extension,
+ #1225, 1282, 1341 -- EVI extension,
+ #1171-1178, 1198, 1246, 1305 -- Xinerama extension,
+ #1165 -- Xt Resource Configuration Management.
1645. XAA fixes for xf86bpp (#1633, Alan Hourihane).
1644. More 3.3.2 syncs, PC98 sync, usleep problem with FreeBSD,
SVR4.0 build problem fixes (#1631, Takaaki Nomura).
@@ -6077,4 +6083,4 @@ XFree86 3.0 (26 April 1994)
-$XFree86: xc/programs/Xserver/hw/xfree86/CHANGELOG,v 3.578 1998/03/28 06:35:54 hohndel Exp $
+$XFree86: xc/programs/Xserver/hw/xfree86/CHANGELOG,v 3.579 1998/04/05 00:45:45 robin Exp $
diff --git a/programs/Xserver/hw/xfree86/doc/Japanese/man/XF86Config.man b/programs/Xserver/hw/xfree86/doc/Japanese/man/XF86Config.man
index 422d778a0..ed7903b6b 100644
--- a/programs/Xserver/hw/xfree86/doc/Japanese/man/XF86Config.man
+++ b/programs/Xserver/hw/xfree86/doc/Japanese/man/XF86Config.man
@@ -1,4 +1,4 @@
-.\" $XFree86: xc/programs/Xserver/hw/xfree86/doc/Japanese/man/XF86Config.man,v 1.1.2.1 1997/08/04 02:10:41 dawes Exp $
+.\" $XFree86: xc/programs/Xserver/hw/xfree86/doc/Japanese/man/XF86Config.man,v 1.2 1997/11/16 06:32:48 dawes Exp $
.\"
.\" Japanese Version Copyright (c) 1996 Kazuyuki Okamoto
.\" all rights reserved.
@@ -1508,5 +1508,5 @@ XF86_P9000(1), XF86_AGX(1), XF86_W32(1).
.\" manual page.
¤Î¥ª¥ó¥é¥¤¥ó¥Þ¥Ë¥å¥¢¥ë¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£
-.\" $XConsortium: XF86Conf.man /main/15 1996/01/29 18:51:26 kaleb $
+.\" $TOG: XF86Config.man /main/1 1997/08/10 13:13:30 kaleb $
diff --git a/programs/Xserver/hw/xnest/Imakefile b/programs/Xserver/hw/xnest/Imakefile
index 916303666..123700af4 100644
--- a/programs/Xserver/hw/xnest/Imakefile
+++ b/programs/Xserver/hw/xnest/Imakefile
@@ -1,5 +1,5 @@
-XCOMM $TOG: Imakefile /main/12 1997/11/03 14:13:20 kaleb $
-XCOMM $XFree86: xc/programs/Xserver/hw/xnest/Imakefile,v 3.7 1996/12/23 07:09:15 dawes Exp $
+XCOMM $XConsortium: Imakefile /main/8 1996/12/02 10:21:32 lehors $
+XCOMM $XFree86: xc/programs/Xserver/hw/xnest/Imakefile,v 3.8 1997/11/16 06:42:16 dawes Exp $
#include <Server.tmpl>
#ifdef OS2Architecture
diff --git a/programs/Xserver/hw/xnest/Xnest.man b/programs/Xserver/hw/xnest/Xnest.man
index e4009b662..a234d11d7 100644
--- a/programs/Xserver/hw/xnest/Xnest.man
+++ b/programs/Xserver/hw/xnest/Xnest.man
@@ -1,4 +1,4 @@
-.\" $TOG: Xnest.man /main/7 1997/11/04 21:21:03 kaleb $
+.\" $XConsortium: Xnest.man /main/6 1996/12/09 17:33:26 kaleb $
.\" Copyright (c) 1993, 1994 X Consortium
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
@@ -24,7 +24,7 @@
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
-.TH XNEST 1 "Release 6.4" "X Version 11"
+.TH XNEST 1 "Release 6.3" "X Version 11"
.SH NAME
Xnest \- a nested X server
.SH SYNOPSIS
diff --git a/programs/Xserver/mi/migc.c b/programs/Xserver/mi/migc.c
index 526448828..b36f492d6 100644
--- a/programs/Xserver/mi/migc.c
+++ b/programs/Xserver/mi/migc.c
@@ -1,4 +1,4 @@
-/* $TOG: migc.c /main/5 1997/11/04 10:35:56 kaleb $ */
+/* $XConsortium: migc.c,v 1.4 94/04/17 20:27:36 dpw Exp $ */
/*
Copyright (c) 1993 X Consortium
@@ -29,7 +29,7 @@ from the X Consortium.
*/
-/* $XFree86: xc/programs/Xserver/mi/migc.c,v 1.0tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/mi/migc.c,v 1.3 1998/03/20 21:08:22 hohndel Exp $ */
#include "scrnintstr.h"
#include "gcstruct.h"
diff --git a/programs/Xserver/mi/migc.h b/programs/Xserver/mi/migc.h
index 0feac35e9..b6d0fca90 100644
--- a/programs/Xserver/mi/migc.h
+++ b/programs/Xserver/mi/migc.h
@@ -1,4 +1,4 @@
-/* $TOG: migc.h /main/4 1997/11/04 10:36:00 kaleb $ */
+/* $XConsortium: migc.h,v 1.3 94/04/17 20:27:37 dpw Exp $ */
/*
Copyright (c) 1993 X Consortium
@@ -29,7 +29,7 @@ from the X Consortium.
*/
-/* $XFree86: xc/programs/Xserver/mi/migc.h,v 1.0tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/mi/migc.h,v 1.3 1998/03/20 21:08:22 hohndel Exp $ */
extern void miChangeGC(
#if NeedFunctionPrototypes
diff --git a/programs/Xserver/mi/miinitext.c b/programs/Xserver/mi/miinitext.c
index a63d88c4b..017b5d9e5 100644
--- a/programs/Xserver/mi/miinitext.c
+++ b/programs/Xserver/mi/miinitext.c
@@ -45,8 +45,8 @@ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
******************************************************************/
-/* $TOG: miinitext.c /main/46 1997/11/24 16:48:50 kaleb $ */
-/* $XFree86: xc/programs/Xserver/mi/miinitext.c,v 3.28 1997/11/22 08:17:36 dawes Exp $ */
+/* $XConsortium: miinitext.c /main/41 1996/09/28 17:15:08 rws $ */
+/* $XFree86: xc/programs/Xserver/mi/miinitext.c,v 3.29 1997/12/14 02:55:39 dawes Exp $ */
#include "misc.h"
#include "extension.h"
@@ -54,9 +54,6 @@ SOFTWARE.
#ifdef NOPEXEXT /* sleaze for Solaris cpp building XsunMono */
#undef PEXEXT
#endif
-#ifdef PANORAMIX
-extern Bool noPanoramiXExtension;
-#endif
extern Bool noTestExtensions;
#ifdef XKB
extern Bool noXkbExtension;
@@ -83,9 +80,6 @@ extern void XTestExtension1Init(INITARGS);
#ifdef SHAPE
extern void ShapeExtensionInit(INITARGS);
#endif
-#ifdef EVI
-extern void EVIExtensionInit(INITARGS);
-#endif
#ifdef MITSHM
extern void ShmExtensionInit(INITARGS);
#endif
@@ -100,9 +94,6 @@ InitExtension PexExtensionInitPtr = NULL;
#ifdef MULTIBUFFER
extern void MultibufferExtensionInit(INITARGS);
#endif
-#ifdef PANORAMIX
-extern void PanoramiXExtensionInit(INITARGS);
-#endif
#ifdef XINPUT
extern void XInputExtensionInit(INITARGS);
#endif
@@ -162,9 +153,6 @@ extern void SecurityExtensionInit(INITARGS);
#ifdef XPRINT
extern void XpExtensionInit(INITARGS);
#endif
-#ifdef TOGCUP
-extern void XcupExtensionInit(INITARGS);
-#endif
#ifdef DPMSExtension
extern void DPMSExtensionInit(INITARGS);
#endif
@@ -193,11 +181,6 @@ InitExtensions(argc, argv)
int argc;
char *argv[];
{
-#ifdef PANORAMIX
-#if !defined(PRINT_ONLY_SERVER) && !defined(NO_PANORAMIX)
- if (!noPanoramiXExtension) PanoramiXExtensionInit();
-#endif
-#endif
#ifdef BEZIER
BezierExtensionInit();
#endif
@@ -210,9 +193,6 @@ InitExtensions(argc, argv)
#ifdef MITSHM
ShmExtensionInit();
#endif
-#ifdef EVI
- EVIExtensionInit();
-#endif
#if defined(PEXEXT) && !(defined(PEX_MODULE) && defined(NO_MODULES_EXTS))
#ifndef PEX_MODULE
PexExtensionInit();
@@ -291,9 +271,6 @@ InitExtensions(argc, argv)
#ifdef XPRINT
XpExtensionInit();
#endif
-#ifdef TOGCUP
- XcupExtensionInit();
-#endif
#if defined(DPMSExtension) && !defined(PRINT_ONLY_SERVER)
DPMSExtensionInit();
#endif
diff --git a/programs/Xserver/pandix/Imakefile b/programs/Xserver/pandix/Imakefile
deleted file mode 100644
index b78c7dc8a..000000000
--- a/programs/Xserver/pandix/Imakefile
+++ /dev/null
@@ -1,109 +0,0 @@
-XCOMM $TOG: Imakefile /main/1 1997/10/29 13:27:00 kaleb $
-#include <Server.tmpl>
-
-#if PrintOnlyServer
-XPSRC = xpstubs.c
-XPOBJ = xpstubs.o
-#endif
-
-#if !HasFfs
-FFS_SRC = ffs.c
-FFS_OBJ = ffs.o
-#endif
-
-SRCS = atom.c colormap.c cursor.c devices.c dispatch.c dixutils.c events.c \
- extension.c gc.c globals.c glyphcurs.c grabs.c \
- main.c property.c resource.c swaprep.c swapreq.c \
- tables.c window.c initatoms.c dixfonts.c privates.c pixmap.c $(FFS_SRC)
-OBJS = atom.o colormap.o cursor.o devices.o dispatch.o dixutils.o events.o \
- extension.o gc.o globals.o glyphcurs.o grabs.o \
- main.o property.o resource.o swaprep.o swapreq.o \
- tables.o window.o initatoms.o dixfonts.o privates.o pixmap.o $(FFS_OBJ)
-
- INCLUDES = -I../include -I$(XINCLUDESRC) -I$(FONTINCSRC) -I$(EXTINCSRC)
- 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
- * DefaultRGBDatabase RGB_DB
- *
- * The sample util/imake.includes/Imake.tmpl will provide generic defaults.
- * The values in site.h are simply a last line of defense and should not be
- * changed.
- */
-
-#ifdef DefaultFontPath
-DEFAULTFONTPATH = DefaultFontPath
-SITE_FONT_PATH = -DCOMPILEDDEFAULTFONTPATH=\"$(DEFAULTFONTPATH)\"
-#endif
-
-#ifdef DefaultRGBDatabase
-DEFAULTRGBDATABASE = DefaultRGBDatabase
- SITE_RGB_DB = -DRGB_DB=\"$(DEFAULTRGBDATABASE)\"
-#endif
-
-#ifdef DefaultDisplayClass
-DEFAULTDISPLAYCLASS = DefaultDisplayClass
- SITE_DISPLAY_CLASS = -DCOMPILEDDISPLAYCLASS=\"$(DEFAULTDISPLAYCLASS)\"
-#endif
-
-#ifdef XVendorString
-VENDORSTRING = XVendorString
- VENDOR_STRING = -DVENDOR_STRING=\"$(VENDORSTRING)\"
-#endif
-
-#ifdef XVendorRelease
-VENDORRELEASE = XVendorRelease
- VENDOR_RELEASE = -DVENDOR_RELEASE=$(VENDORRELEASE)
-#endif
-
-#if HasKrb5
- K5DEFS = Krb5Defines
-#endif
-
-SITE_DEFINES = $(SITE_FONT_PATH) $(SITE_RGB_DB) $(SITE_DISPLAY_CLASS)
-
-VENDOR_DEFINES = $(VENDOR_STRING) $(VENDOR_RELEASE)
-
-NormalLibraryObjectRule()
-NormalLibraryTarget(dix,$(OBJS))
-LintLibraryTarget(dix,$(SRCS) $(XPSRC))
-NormalLintTarget($(SRCS) $(XPSRC))
-
-SpecialCObjectRule(globals,$(ICONFIGFILES),$(SITE_DEFINES))
-SpecialCObjectRule(tables,$(ICONFIGFILES),$(K5DEFS))
-SpecialCObjectRule(dispatch,$(ICONFIGFILES),$(K5DEFS))
-SpecialCObjectRule(main,$(ICONFIGFILES),$(VENDOR_DEFINES))
-SpecialCObjectRule(pixmap,$(ICONFIGFILES),$(_NOOP_))
-SpecialCObjectRule(privates,$(ICONFIGFILES),$(_NOOP_))
-
-#if PrintOnlyServer
-NormalLibraryTarget(xpstubs,$(XPOBJ))
-#endif
-
-InstallLinkKitLibrary(dix,$(LINKKITDIR)/lib)
-
-LinkSourceFile(atom.c,../dix)
-LinkSourceFile(colormap.c,../dix)
-LinkSourceFile(cursor.c,../dix)
-LinkSourceFile(devices.c,../dix)
-LinkSourceFile(dixutils.c,../dix)
-LinkSourceFile(extension.c,../dix)
-LinkSourceFile(ffs.c,../dix)
-LinkSourceFile(gc.c,../dix)
-LinkSourceFile(globals.c,../dix)
-LinkSourceFile(glyphcurs.c,../dix)
-LinkSourceFile(grabs.c,../dix)
-LinkSourceFile(initatoms.c,../dix)
-LinkSourceFile(pixmap.c,../dix)
-LinkSourceFile(privates.c,../dix)
-LinkSourceFile(property.c,../dix)
-LinkSourceFile(swaprep.c,../dix)
-LinkSourceFile(swapreq.c,../dix)
-LinkSourceFile(tables.c,../dix)
-LinkSourceFile(xpstubs.c,../dix)
-
-DependTarget()
diff --git a/programs/Xserver/pandix/dispatch.c b/programs/Xserver/pandix/dispatch.c
deleted file mode 100644
index 4b21889c0..000000000
--- a/programs/Xserver/pandix/dispatch.c
+++ /dev/null
@@ -1,4100 +0,0 @@
-
-/****************************************************************
-* *
-* Copyright (c) Digital Equipment Corporation, 1991, 1997 *
-* *
-* All Rights Reserved. Unpublished rights reserved under *
-* the copyright laws of the United States. *
-* *
-* The software contained on this media is proprietary to *
-* and embodies the confidential technology of Digital *
-* Equipment Corporation. Possession, use, duplication or *
-* dissemination of the software and media is authorized only *
-* pursuant to a valid written license from Digital Equipment *
-* Corporation. *
-* *
-* RESTRICTED RIGHTS LEGEND Use, duplication, or disclosure *
-* by the U.S. Government is subject to restrictions as set *
-* forth in Subparagraph (c)(1)(ii) of DFARS 252.227-7013, *
-* or in FAR 52.227-19, as applicable. *
-* *
-*****************************************************************/
-/* $TOG: dispatch.c /main/1 1997/10/29 13:27:04 kaleb $ */
-/************************************************************
-
-Copyright (c) 1987, 1989 X Consortium
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-X CONSORTIUM 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 X Consortium 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 X Consortium.
-
-
-Copyright 1987, 1989 by Digital Equipment Corporation, Maynard, Massachusetts.
-
- All Rights Reserved
-
-Permission to use, copy, modify, and distribute this software and its
-documentation for any purpose and without fee is hereby granted,
-provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in
-supporting documentation, and that the name of Digital not be
-used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.
-
-DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
-ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-SOFTWARE.
-
-********************************************************/
-
-#ifdef PANORAMIX_DEBUG
-#include <stdio.h>
-int ProcInitialConnection();
-#endif
-
-#include "windowstr.h"
-#include "fontstruct.h"
-#include "dixfontstr.h"
-#include "gcstruct.h"
-#include "selection.h"
-#include "colormapst.h"
-#include "cursorstr.h"
-#include "scrnintstr.h"
-#include "opaque.h"
-#include "input.h"
-#include "servermd.h"
-#include "extnsionst.h"
-#include "dixfont.h"
-#ifdef PANORAMIX
-#include "panoramiX.h"
-#endif
-#ifdef XCSECURITY
-#define _SECURITY_SERVER
-#include "extensions/security.h"
-#endif
-#ifdef XAPPGROUP
-#include "extensions/Xagsrv.h"
-#endif
-
-#define mskcnt ((MAXCLIENTS + 31) / 32)
-#define BITMASK(i) (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))
-
-#ifdef PANORAMIX
-extern PanoramiXWindow *PanoramiXWinRoot;
-extern PanoramiXGC *PanoramiXGCRoot;
-extern PanoramiXCmap *PanoramiXCmapRoot;
-extern PanoramiXPmap *PanoramiXPmapRoot;
-extern PanoramiXData *panoramiXdataPtr;
-extern Bool noPanoramiXExtension;
-extern int PanoramiXNumScreens;
-#endif /* PANORAMIX */
-
-extern WindowPtr *WindowTable;
-extern xConnSetupPrefix connSetupPrefix;
-extern char *ConnectionInfo;
-extern void ReleaseActiveGrabs();
-extern void NotImplemented();
-extern void SwapConnClientPrefix(
-#if NeedFunctionPrototypes
- xConnClientPrefix *
-#endif
-);
-
-Selection *CurrentSelections;
-int NumCurrentSelections;
-
-extern CARD32 defaultScreenSaverTime;
-extern CARD32 defaultScreenSaverInterval;
-extern int defaultScreenSaverBlanking;
-extern int defaultScreenSaverAllowExposures;
-static ClientPtr grabClient;
-#define GrabNone 0
-#define GrabActive 1
-#define GrabKickout 2
-static int grabState = GrabNone;
-static long grabWaiters[mskcnt];
-CallbackListPtr ServerGrabCallback = NULL;
-HWEventQueuePtr checkForInput[2];
-extern int connBlockScreenStart;
-
-#ifdef XKB
-extern Bool noXkbExtension;
-#endif
-
-extern void Swap32Write(), SLHostsExtend(), SQColorsExtend(), WriteSConnectionInfo();
-extern void WriteSConnSetupPrefix();
-
-static void KillAllClients(
-#if NeedFunctionPrototypes
- void
-#endif
-);
-
-static void DeleteClientFromAnySelections(
-#if NeedFunctionPrototypes
- ClientPtr /*client*/
-#endif
-);
-
-#ifdef LBX
-extern unsigned long StandardRequestLength();
-#endif
-
-static int nextFreeClientID; /* always MIN free client ID */
-
-static int nClients; /* number of authorized clients */
-
-CallbackListPtr ClientStateCallback;
-char dispatchException = 0;
-char isItTimeToYield;
-
-/* Various of the DIX function interfaces were not designed to allow
- * the client->errorValue to be set on BadValue and other errors.
- * Rather than changing interfaces and breaking untold code we introduce
- * a new global that dispatch can use.
- */
-XID clientErrorValue; /* XXX this is a kludge */
-
-#define SAME_SCREENS(a, b) (\
- (a.pScreen == b.pScreen))
-
-void
-SetInputCheck(c0, c1)
- HWEventQueuePtr c0, c1;
-{
- checkForInput[0] = c0;
- checkForInput[1] = c1;
-}
-
-void
-UpdateCurrentTime()
-{
- TimeStamp systime;
-
- /* To avoid time running backwards, we must call GetTimeInMillis before
- * calling ProcessInputEvents.
- */
- systime.months = currentTime.months;
- systime.milliseconds = GetTimeInMillis();
- if (systime.milliseconds < currentTime.milliseconds)
- systime.months++;
- if (*checkForInput[0] != *checkForInput[1])
- ProcessInputEvents();
- if (CompareTimeStamps(systime, currentTime) == LATER)
- currentTime = systime;
-}
-
-/* Like UpdateCurrentTime, but can't call ProcessInputEvents */
-void
-UpdateCurrentTimeIf()
-{
- TimeStamp systime;
-
- systime.months = currentTime.months;
- systime.milliseconds = GetTimeInMillis();
- if (systime.milliseconds < currentTime.milliseconds)
- systime.months++;
- if (*checkForInput[0] == *checkForInput[1])
- currentTime = systime;
-}
-
-void
-InitSelections()
-{
- if (CurrentSelections)
- xfree(CurrentSelections);
- CurrentSelections = (Selection *)NULL;
- NumCurrentSelections = 0;
-}
-
-void
-FlushClientCaches(id)
- XID id;
-{
- int i;
- register ClientPtr client;
-
- client = clients[CLIENT_ID(id)];
- if (client == NullClient)
- return ;
- for (i=0; i<currentMaxClients; i++)
- {
- client = clients[i];
- if (client != NullClient)
- {
- if (client->lastDrawableID == id)
- {
- client->lastDrawableID = WindowTable[0]->drawable.id;
- client->lastDrawable = (DrawablePtr)WindowTable[0];
- }
- else if (client->lastGCID == id)
- {
- client->lastGCID = INVALID;
- client->lastGC = (GCPtr)NULL;
- }
- }
- }
-}
-
-#define MAJOROP ((xReq *)client->requestBuffer)->reqType
-
-void
-Dispatch()
-{
- register int *clientReady; /* array of request ready clients */
- register int result;
- register ClientPtr client;
- register int nready;
- register HWEventQueuePtr* icheck = checkForInput;
-
- nextFreeClientID = 1;
- InitSelections();
- nClients = 0;
-
- clientReady = (int *) ALLOCATE_LOCAL(sizeof(int) * MaxClients);
- if (!clientReady)
- return;
-
- while (!dispatchException)
- {
- if (*icheck[0] != *icheck[1])
- {
- ProcessInputEvents();
- FlushIfCriticalOutputPending();
- }
-
- nready = WaitForSomething(clientReady);
-
- /*****************
- * Handle events in round robin fashion, doing input between
- * each round
- *****************/
-
- while (!dispatchException && (--nready >= 0))
- {
- client = clients[clientReady[nready]];
- if (! client)
- {
- /* KillClient can cause this to happen */
- continue;
- }
- /* GrabServer activation can cause this to be true */
- if (grabState == GrabKickout)
- {
- grabState = GrabActive;
- break;
- }
- isItTimeToYield = FALSE;
-
- requestingClient = client;
- while (!isItTimeToYield)
- {
- if (*icheck[0] != *icheck[1])
- {
- ProcessInputEvents();
- FlushIfCriticalOutputPending();
- }
-
- /* now, finally, deal with client requests */
-
- result = ReadRequestFromClient(client);
- if (result <= 0)
- {
- if (result < 0)
- CloseDownClient(client);
- break;
- }
-
- client->sequence++;
-#ifdef DEBUG
- if (client->requestLogIndex == MAX_REQUEST_LOG)
- client->requestLogIndex = 0;
- client->requestLog[client->requestLogIndex] = MAJOROP;
- client->requestLogIndex++;
-#endif
- if (result > (MAX_BIG_REQUEST_SIZE << 2))
- result = BadLength;
- else
- result = (* client->requestVector[MAJOROP])(client);
-
- if (result != Success)
- {
- if (client->noClientException != Success)
- CloseDownClient(client);
- else
- SendErrorToClient(client, MAJOROP,
- MinorOpcodeOfRequest(client),
- client->errorValue, result);
- break;
- }
- }
- FlushAllOutput();
-
- requestingClient = NULL;
- }
- dispatchException &= ~DE_PRIORITYCHANGE;
- }
- KillAllClients();
- DEALLOCATE_LOCAL(clientReady);
- dispatchException &= ~DE_RESET;
-}
-
-#undef MAJOROP
-
-/*ARGSUSED*/
-int
-ProcBadRequest(client)
- ClientPtr client;
-{
- return (BadRequest);
-}
-
-int
-ProcCreateWindow(client)
- register ClientPtr client;
-{
- register WindowPtr pParent, pWin;
- REQUEST(xCreateWindowReq);
- int result;
- int len;
-
- REQUEST_AT_LEAST_SIZE(xCreateWindowReq);
-
- LEGAL_NEW_RESOURCE(stuff->wid, client);
- if (!(pParent = (WindowPtr)SecurityLookupWindow(stuff->parent, client,
- SecurityWriteAccess)))
- return BadWindow;
- len = client->req_len - (sizeof(xCreateWindowReq) >> 2);
- if (Ones(stuff->mask) != len)
- return BadLength;
- if (!stuff->width || !stuff->height)
- {
- client->errorValue = 0;
- return BadValue;
- }
- pWin = CreateWindow(stuff->wid, pParent, stuff->x,
- stuff->y, stuff->width, stuff->height,
- stuff->borderWidth, stuff->class,
- stuff->mask, (XID *) &stuff[1],
- (int)stuff->depth,
- client, stuff->visual, &result);
- if (pWin)
- {
- Mask mask = pWin->eventMask;
-
- pWin->eventMask = 0; /* subterfuge in case AddResource fails */
- if (!AddResource(stuff->wid, RT_WINDOW, (pointer)pWin))
- return BadAlloc;
- pWin->eventMask = mask;
- }
- if (client->noClientException != Success)
- return(client->noClientException);
- else
- return(result);
-}
-
-int
-ProcChangeWindowAttributes(client)
- register ClientPtr client;
-{
- register WindowPtr pWin;
- REQUEST(xChangeWindowAttributesReq);
- register int result;
- int len;
-
- REQUEST_AT_LEAST_SIZE(xChangeWindowAttributesReq);
- pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
- SecurityWriteAccess);
- if (!pWin)
- return(BadWindow);
- len = client->req_len - (sizeof(xChangeWindowAttributesReq) >> 2);
- if (len != Ones(stuff->valueMask))
- return BadLength;
- result = ChangeWindowAttributes(pWin,
- stuff->valueMask,
- (XID *) &stuff[1],
- client);
- if (client->noClientException != Success)
- return(client->noClientException);
- else
- return(result);
-}
-
-int
-ProcGetWindowAttributes(client)
- register ClientPtr client;
-{
- register WindowPtr pWin;
- REQUEST(xResourceReq);
- xGetWindowAttributesReply wa;
-
- REQUEST_SIZE_MATCH(xResourceReq);
- pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client,
- SecurityReadAccess);
- if (!pWin)
- return(BadWindow);
- GetWindowAttributes(pWin, client, &wa);
- WriteReplyToClient(client, sizeof(xGetWindowAttributesReply), &wa);
- return(client->noClientException);
-}
-
-int
-ProcDestroyWindow(client)
- register ClientPtr client;
-{
- register WindowPtr pWin;
- REQUEST(xResourceReq);
-
- REQUEST_SIZE_MATCH(xResourceReq);
- pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client,
- SecurityDestroyAccess);
- if (!pWin)
- return(BadWindow);
- if (pWin->parent)
- FreeResource(stuff->id, RT_NONE);
- return(client->noClientException);
-}
-
-int
-ProcDestroySubwindows(client)
- register ClientPtr client;
-{
- register WindowPtr pWin;
- REQUEST(xResourceReq);
-
- REQUEST_SIZE_MATCH(xResourceReq);
- pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client,
- SecurityDestroyAccess);
- if (!pWin)
- return(BadWindow);
- DestroySubwindows(pWin, client);
- return(client->noClientException);
-}
-
-int
-ProcChangeSaveSet(client)
- register ClientPtr client;
-{
- register WindowPtr pWin;
- REQUEST(xChangeSaveSetReq);
- register int result;
-
- REQUEST_SIZE_MATCH(xChangeSaveSetReq);
- pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
- SecurityReadAccess);
- if (!pWin)
- return(BadWindow);
- if (client->clientAsMask == (CLIENT_BITS(pWin->drawable.id)))
- return BadMatch;
- if ((stuff->mode == SetModeInsert) || (stuff->mode == SetModeDelete))
- {
- result = AlterSaveSetForClient(client, pWin, stuff->mode);
- if (client->noClientException != Success)
- return(client->noClientException);
- else
- return(result);
- }
- else
- {
- client->errorValue = stuff->mode;
- return( BadValue );
- }
-}
-
-int
-ProcReparentWindow(client)
- register ClientPtr client;
-{
- register WindowPtr pWin, pParent;
- REQUEST(xReparentWindowReq);
- register int result;
-
- REQUEST_SIZE_MATCH(xReparentWindowReq);
- pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
- SecurityWriteAccess);
- if (!pWin)
- return(BadWindow);
- pParent = (WindowPtr)SecurityLookupWindow(stuff->parent, client,
- SecurityWriteAccess);
- if (!pParent)
- return(BadWindow);
- if (SAME_SCREENS(pWin->drawable, pParent->drawable))
- {
- if ((pWin->backgroundState == ParentRelative) &&
- (pParent->drawable.depth != pWin->drawable.depth))
- return BadMatch;
- if ((pWin->drawable.class != InputOnly) &&
- (pParent->drawable.class == InputOnly))
- return BadMatch;
- result = ReparentWindow(pWin, pParent,
- (short)stuff->x, (short)stuff->y, client);
- if (client->noClientException != Success)
- return(client->noClientException);
- else
- return(result);
- }
- else
- return (BadMatch);
-}
-
-int
-ProcMapWindow(client)
- register ClientPtr client;
-{
- register WindowPtr pWin;
- REQUEST(xResourceReq);
-
- REQUEST_SIZE_MATCH(xResourceReq);
- pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client,
- SecurityReadAccess);
- if (!pWin)
- return(BadWindow);
- MapWindow(pWin, client);
- /* update cache to say it is mapped */
- return(client->noClientException);
-}
-
-int
-ProcMapSubwindows(client)
- register ClientPtr client;
-{
- register WindowPtr pWin;
- REQUEST(xResourceReq);
-
- REQUEST_SIZE_MATCH(xResourceReq);
- pWin = (WindowPtr)SecurityLookupWindow( stuff->id, client,
- SecurityReadAccess);
- if (!pWin)
- return(BadWindow);
- MapSubwindows(pWin, client);
- /* update cache to say it is mapped */
- return(client->noClientException);
-}
-
-int
-ProcUnmapWindow(client)
- register ClientPtr client;
-{
- register WindowPtr pWin;
- REQUEST(xResourceReq);
-
- REQUEST_SIZE_MATCH(xResourceReq);
- pWin = (WindowPtr)SecurityLookupWindow( stuff->id, client,
- SecurityReadAccess);
- if (!pWin)
- return(BadWindow);
- UnmapWindow(pWin, FALSE);
- /* update cache to say it is mapped */
- return(client->noClientException);
-}
-
-int
-ProcUnmapSubwindows(client)
- register ClientPtr client;
-{
- register WindowPtr pWin;
- REQUEST(xResourceReq);
-
- REQUEST_SIZE_MATCH(xResourceReq);
- pWin = (WindowPtr)SecurityLookupWindow( stuff->id, client,
- SecurityReadAccess);
- if (!pWin)
- return(BadWindow);
- UnmapSubwindows(pWin);
- return(client->noClientException);
-}
-
-int
-ProcConfigureWindow(client)
- register ClientPtr client;
-{
- register WindowPtr pWin;
- REQUEST(xConfigureWindowReq);
- register int result;
- int len;
-
- REQUEST_AT_LEAST_SIZE(xConfigureWindowReq);
- pWin = (WindowPtr)SecurityLookupWindow( stuff->window, client,
- SecurityWriteAccess);
- if (!pWin)
- return(BadWindow);
- len = client->req_len - (sizeof(xConfigureWindowReq) >> 2);
- if (Ones((Mask)stuff->mask) != len)
- return BadLength;
- result = ConfigureWindow(pWin, (Mask)stuff->mask, (XID *) &stuff[1],
- client);
- if (client->noClientException != Success)
- return(client->noClientException);
- else
- return(result);
-}
-
-int
-ProcCirculateWindow(client)
- register ClientPtr client;
-{
- register WindowPtr pWin;
- REQUEST(xCirculateWindowReq);
-
- REQUEST_SIZE_MATCH(xCirculateWindowReq);
- if ((stuff->direction != RaiseLowest) &&
- (stuff->direction != LowerHighest))
- {
- client->errorValue = stuff->direction;
- return BadValue;
- }
- pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
- SecurityWriteAccess);
- if (!pWin)
- return(BadWindow);
- CirculateWindow(pWin, (int)stuff->direction, client);
- return(client->noClientException);
-}
-
-int
-GetGeometry(client, rep)
- register ClientPtr client;
- xGetGeometryReply *rep;
-{
- register DrawablePtr pDraw;
- REQUEST(xResourceReq);
-
- REQUEST_SIZE_MATCH(xResourceReq);
- SECURITY_VERIFY_GEOMETRABLE (pDraw, stuff->id, client, SecurityReadAccess);
- rep->type = X_Reply;
- rep->length = 0;
- rep->sequenceNumber = client->sequence;
- rep->root = WindowTable[pDraw->pScreen->myNum]->drawable.id;
- rep->depth = pDraw->depth;
- rep->width = pDraw->width;
- rep->height = pDraw->height;
-
- /* XXX - Because the pixmap-implementation of the multibuffer extension
- * may have the buffer-id's drawable resource value be a pointer
- * to the buffer's window instead of the buffer itself
- * (this happens if the buffer is the displayed buffer),
- * we also have to check that the id matches before we can
- * truly say that it is a DRAWABLE_WINDOW.
- */
-
- if ((pDraw->type == UNDRAWABLE_WINDOW) ||
- ((pDraw->type == DRAWABLE_WINDOW) && (stuff->id == pDraw->id)))
- {
- register WindowPtr pWin = (WindowPtr)pDraw;
- rep->x = pWin->origin.x - wBorderWidth (pWin);
- rep->y = pWin->origin.y - wBorderWidth (pWin);
- rep->borderWidth = pWin->borderWidth;
- }
- else /* DRAWABLE_PIXMAP or DRAWABLE_BUFFER */
- {
- rep->x = rep->y = rep->borderWidth = 0;
- }
-
- return Success;
-}
-
-
-int
-ProcGetGeometry(client)
- register ClientPtr client;
-{
- xGetGeometryReply rep;
- int status;
-
- if ((status = GetGeometry(client, &rep)) != Success)
- return status;
-
- WriteReplyToClient(client, sizeof(xGetGeometryReply), &rep);
- return(client->noClientException);
-}
-
-
-int
-ProcQueryTree(client)
- register ClientPtr client;
-{
-
- xQueryTreeReply reply;
- int numChildren = 0;
- register WindowPtr pChild, pWin, pHead;
- Window *childIDs = (Window *)NULL;
-#ifdef PANORAMIX
- PanoramiXWindow *pPanoramiXWin = PanoramiXWinRoot;
- int j, thisScreen;
-#endif
- REQUEST(xResourceReq);
-
- REQUEST_SIZE_MATCH(xResourceReq);
- pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client,
- SecurityReadAccess);
- if (!pWin)
- return(BadWindow);
- reply.type = X_Reply;
- reply.root = WindowTable[pWin->drawable.pScreen->myNum]->drawable.id;
- reply.sequenceNumber = client->sequence;
- if (pWin->parent)
- reply.parent = pWin->parent->drawable.id;
- else
- reply.parent = (Window)None;
-#ifdef PANORAMIX
- if ( !noPanoramiXExtension ) {
- thisScreen = 0;
- for (j = 0; j <= PanoramiXNumScreens - 1; j++) {
- if ( pWin->winSize.extents.x1 < (panoramiXdataPtr[j].x + panoramiXdataPtr[j].width)) {
- thisScreen = j;
- break;
- }
- }
- }
- if ( !noPanoramiXExtension && thisScreen ) {
- PANORAMIXFIND_ID(pPanoramiXWin, pWin->drawable.id);
- IF_RETURN(!pPanoramiXWin, BadWindow);
- pWin = (WindowPtr)SecurityLookupWindow(pPanoramiXWin->info[thisScreen].id, client,
- SecurityReadAccess);
- if (!pWin)
- return(BadWindow);
- pHead = RealChildHead(pWin);
- for (pChild = pWin->lastChild; pChild != pHead; pChild = pChild->prevSib)
- numChildren++;
- if (numChildren)
- {
- int curChild = 0;
- childIDs = (Window *) ALLOCATE_LOCAL(numChildren * sizeof(Window));
- if (!childIDs)
- return BadAlloc;
- for (pChild = pWin->lastChild; pChild != pHead; pChild = pChild->prevSib) {
- pPanoramiXWin = PanoramiXWinRoot;
- PANORAMIXFIND_ID_BY_SCRNUM(pPanoramiXWin, pChild->drawable.id, thisScreen);
- IF_RETURN(!pPanoramiXWin, BadWindow);
- childIDs[curChild++] = pPanoramiXWin->info[0].id;
- }
- } /* numChildren */
- }else { /* otherwise its screen 0, and nothing changes */
- pHead = RealChildHead(pWin);
- for (pChild = pWin->lastChild; pChild != pHead; pChild = pChild->prevSib)
- numChildren++;
- if (numChildren)
- {
- int curChild = 0;
-
- childIDs = (Window *) ALLOCATE_LOCAL(numChildren * sizeof(Window));
- if (!childIDs)
- return BadAlloc;
- for (pChild = pWin->lastChild; pChild != pHead; pChild = pChild->prevSib)
- childIDs[curChild++] = pChild->drawable.id;
- }
- }
-#else
- pHead = RealChildHead(pWin);
- for (pChild = pWin->lastChild; pChild != pHead; pChild = pChild->prevSib)
- numChildren++;
- if (numChildren)
- {
- int curChild = 0;
-
- childIDs = (Window *) ALLOCATE_LOCAL(numChildren * sizeof(Window));
- if (!childIDs)
- return BadAlloc;
- for (pChild = pWin->lastChild; pChild != pHead; pChild = pChild->prevSib)
- childIDs[curChild++] = pChild->drawable.id;
- }
-#endif
-
- reply.nChildren = numChildren;
- reply.length = (numChildren * sizeof(Window)) >> 2;
-
- WriteReplyToClient(client, sizeof(xQueryTreeReply), &reply);
- if (numChildren)
- {
- client->pSwapReplyFunc = Swap32Write;
- WriteSwappedDataToClient(client, numChildren * sizeof(Window), childIDs);
- DEALLOCATE_LOCAL(childIDs);
- }
-
- return(client->noClientException);
-}
-
-int
-ProcInternAtom(client)
- register ClientPtr client;
-{
- Atom atom;
- char *tchar;
- REQUEST(xInternAtomReq);
-
- REQUEST_FIXED_SIZE(xInternAtomReq, stuff->nbytes);
- if ((stuff->onlyIfExists != xTrue) && (stuff->onlyIfExists != xFalse))
- {
- client->errorValue = stuff->onlyIfExists;
- return(BadValue);
- }
- tchar = (char *) &stuff[1];
- atom = MakeAtom(tchar, stuff->nbytes, !stuff->onlyIfExists);
- if (atom != BAD_RESOURCE)
- {
- xInternAtomReply reply;
- reply.type = X_Reply;
- reply.length = 0;
- reply.sequenceNumber = client->sequence;
- reply.atom = atom;
- WriteReplyToClient(client, sizeof(xInternAtomReply), &reply);
- return(client->noClientException);
- }
- else
- return (BadAlloc);
-}
-
-int
-ProcGetAtomName(client)
- register ClientPtr client;
-{
- char *str;
- xGetAtomNameReply reply;
- int len;
- REQUEST(xResourceReq);
-
- REQUEST_SIZE_MATCH(xResourceReq);
- if ( (str = NameForAtom(stuff->id)) )
- {
- len = strlen(str);
- reply.type = X_Reply;
- reply.length = (len + 3) >> 2;
- reply.sequenceNumber = client->sequence;
- reply.nameLength = len;
- WriteReplyToClient(client, sizeof(xGetAtomNameReply), &reply);
- (void)WriteToClient(client, len, str);
- return(client->noClientException);
- }
- else
- {
- client->errorValue = stuff->id;
- return (BadAtom);
- }
-}
-
-#ifdef K5AUTH
-extern int k5_bad();
-#endif
-
-int
-ProcSetSelectionOwner(client)
- register ClientPtr client;
-{
- WindowPtr pWin;
- TimeStamp time;
- REQUEST(xSetSelectionOwnerReq);
-
- REQUEST_SIZE_MATCH(xSetSelectionOwnerReq);
- UpdateCurrentTime();
- time = ClientTimeToServerTime(stuff->time);
-
- /* If the client's time stamp is in the future relative to the server's
- time stamp, do not set the selection, just return success. */
- if (CompareTimeStamps(time, currentTime) == LATER)
- return Success;
- if (stuff->window != None)
- {
- pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
- SecurityReadAccess);
- if (!pWin)
- return(BadWindow);
- }
- else
- pWin = (WindowPtr)None;
- if (ValidAtom(stuff->selection))
- {
- int i = 0;
-
- /*
- * First, see if the selection is already set...
- */
- while ((i < NumCurrentSelections) &&
- CurrentSelections[i].selection != stuff->selection)
- i++;
- if (i < NumCurrentSelections)
- {
- xEvent event;
-
- /* If the timestamp in client's request is in the past relative
- to the time stamp indicating the last time the owner of the
- selection was set, do not set the selection, just return
- success. */
- if (CompareTimeStamps(time, CurrentSelections[i].lastTimeChanged)
- == EARLIER)
- return Success;
- if (CurrentSelections[i].client &&
- (!pWin || (CurrentSelections[i].client != client)))
- {
- event.u.u.type = SelectionClear;
- event.u.selectionClear.time = time.milliseconds;
- event.u.selectionClear.window = CurrentSelections[i].window;
- event.u.selectionClear.atom = CurrentSelections[i].selection;
- (void) TryClientEvents (CurrentSelections[i].client, &event, 1,
- NoEventMask, NoEventMask /* CantBeFiltered */,
- NullGrab);
- }
- }
- else
- {
- /*
- * It doesn't exist, so add it...
- */
- Selection *newsels;
-
- if (i == 0)
- newsels = (Selection *)xalloc(sizeof(Selection));
- else
- newsels = (Selection *)xrealloc(CurrentSelections,
- (NumCurrentSelections + 1) * sizeof(Selection));
- if (!newsels)
- return BadAlloc;
- NumCurrentSelections++;
- CurrentSelections = newsels;
- CurrentSelections[i].selection = stuff->selection;
- }
- CurrentSelections[i].lastTimeChanged = time;
- CurrentSelections[i].window = stuff->window;
- CurrentSelections[i].pWin = pWin;
- CurrentSelections[i].client = (pWin ? client : NullClient);
- return (client->noClientException);
- }
- else
- {
- client->errorValue = stuff->selection;
- return (BadAtom);
- }
-}
-
-int
-ProcGetSelectionOwner(client)
- register ClientPtr client;
-{
- REQUEST(xResourceReq);
-
- REQUEST_SIZE_MATCH(xResourceReq);
- if (ValidAtom(stuff->id))
- {
- int i;
- xGetSelectionOwnerReply reply;
-
- i = 0;
- while ((i < NumCurrentSelections) &&
- CurrentSelections[i].selection != stuff->id) i++;
- reply.type = X_Reply;
- reply.length = 0;
- reply.sequenceNumber = client->sequence;
- if (i < NumCurrentSelections)
- reply.owner = CurrentSelections[i].window;
- else
- reply.owner = None;
- WriteReplyToClient(client, sizeof(xGetSelectionOwnerReply), &reply);
- return(client->noClientException);
- }
- else
- {
- client->errorValue = stuff->id;
- return (BadAtom);
- }
-}
-
-int
-ProcConvertSelection(client)
- register ClientPtr client;
-{
- Bool paramsOkay;
- xEvent event;
- WindowPtr pWin;
- REQUEST(xConvertSelectionReq);
-
- REQUEST_SIZE_MATCH(xConvertSelectionReq);
- pWin = (WindowPtr)SecurityLookupWindow(stuff->requestor, client,
- SecurityReadAccess);
- if (!pWin)
- return(BadWindow);
-
- paramsOkay = (ValidAtom(stuff->selection) && ValidAtom(stuff->target));
- if (stuff->property != None)
- paramsOkay &= ValidAtom(stuff->property);
- if (paramsOkay)
- {
- int i;
-
- i = 0;
- while ((i < NumCurrentSelections) &&
- CurrentSelections[i].selection != stuff->selection) i++;
- if ((i < NumCurrentSelections) &&
- (CurrentSelections[i].window != None)
-#ifdef XCSECURITY
- && (!client->CheckAccess ||
- (* client->CheckAccess)(client, CurrentSelections[i].window,
- RT_WINDOW, SecurityReadAccess,
- CurrentSelections[i].pWin))
-#endif
- )
- {
- event.u.u.type = SelectionRequest;
- event.u.selectionRequest.time = stuff->time;
- event.u.selectionRequest.owner =
- CurrentSelections[i].window;
- event.u.selectionRequest.requestor = stuff->requestor;
- event.u.selectionRequest.selection = stuff->selection;
- event.u.selectionRequest.target = stuff->target;
- event.u.selectionRequest.property = stuff->property;
- if (TryClientEvents(
- CurrentSelections[i].client, &event, 1, NoEventMask,
- NoEventMask /* CantBeFiltered */, NullGrab))
- return (client->noClientException);
- }
- event.u.u.type = SelectionNotify;
- event.u.selectionNotify.time = stuff->time;
- event.u.selectionNotify.requestor = stuff->requestor;
- event.u.selectionNotify.selection = stuff->selection;
- event.u.selectionNotify.target = stuff->target;
- event.u.selectionNotify.property = None;
- (void) TryClientEvents(client, &event, 1, NoEventMask,
- NoEventMask /* CantBeFiltered */, NullGrab);
- return (client->noClientException);
- }
- else
- {
- client->errorValue = stuff->property;
- return (BadAtom);
- }
-}
-
-int
-ProcGrabServer(client)
- register ClientPtr client;
-{
- REQUEST(xReq);
- REQUEST_SIZE_MATCH(xReq);
- if (grabState != GrabNone && client != grabClient)
- {
- ResetCurrentRequest(client);
- client->sequence--;
- BITSET(grabWaiters, client->index);
- IgnoreClient(client);
- return(client->noClientException);
- }
- OnlyListenToOneClient(client);
- grabState = GrabKickout;
- grabClient = client;
-
- if (ServerGrabCallback)
- {
- ServerGrabInfoRec grabinfo;
- grabinfo.client = client;
- grabinfo.grabstate = SERVER_GRABBED;
- CallCallbacks(&ServerGrabCallback, (pointer)&grabinfo);
- }
-
- return(client->noClientException);
-}
-
-static void
-UngrabServer(client)
- ClientPtr client;
-{
- int i;
-
- grabState = GrabNone;
- ListenToAllClients();
- for (i = mskcnt; --i >= 0 && !grabWaiters[i]; )
- ;
- if (i >= 0)
- {
- i <<= 5;
- while (!GETBIT(grabWaiters, i))
- i++;
- BITCLEAR(grabWaiters, i);
- AttendClient(clients[i]);
- }
-
- if (ServerGrabCallback)
- {
- ServerGrabInfoRec grabinfo;
- grabinfo.client = client;
- grabinfo.grabstate = SERVER_UNGRABBED;
- CallCallbacks(&ServerGrabCallback, (pointer)&grabinfo);
- }
-}
-
-int
-ProcUngrabServer(client)
- register ClientPtr client;
-{
- REQUEST(xReq);
- REQUEST_SIZE_MATCH(xReq);
- UngrabServer(client);
- return(client->noClientException);
-}
-
-int
-ProcTranslateCoords(client)
- register ClientPtr client;
-{
- REQUEST(xTranslateCoordsReq);
-
- register WindowPtr pWin, pDst;
- xTranslateCoordsReply rep;
-
- REQUEST_SIZE_MATCH(xTranslateCoordsReq);
- pWin = (WindowPtr)SecurityLookupWindow(stuff->srcWid, client,
- SecurityReadAccess);
- if (!pWin)
- return(BadWindow);
- pDst = (WindowPtr)SecurityLookupWindow(stuff->dstWid, client,
- SecurityReadAccess);
- if (!pDst)
- return(BadWindow);
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- if (!SAME_SCREENS(pWin->drawable, pDst->drawable))
- {
- rep.sameScreen = xFalse;
- rep.child = None;
- rep.dstX = rep.dstY = 0;
- }
- else
- {
- INT16 x, y;
- rep.sameScreen = xTrue;
- rep.child = None;
- /* computing absolute coordinates -- adjust to destination later */
- x = pWin->drawable.x + stuff->srcX;
- y = pWin->drawable.y + stuff->srcY;
- pWin = pDst->firstChild;
- while (pWin)
- {
-#ifdef SHAPE
- BoxRec box;
-#endif
- if ((pWin->mapped) &&
- (x >= pWin->drawable.x - wBorderWidth (pWin)) &&
- (x < pWin->drawable.x + (int)pWin->drawable.width +
- wBorderWidth (pWin)) &&
- (y >= pWin->drawable.y - wBorderWidth (pWin)) &&
- (y < pWin->drawable.y + (int)pWin->drawable.height +
- wBorderWidth (pWin))
-#ifdef SHAPE
- /* When a window is shaped, a further check
- * is made to see if the point is inside
- * borderSize
- */
- && (!wBoundingShape(pWin) ||
- POINT_IN_REGION(pWin->drawable.pScreen,
- &pWin->borderSize, x, y, &box))
-#endif
- )
- {
- rep.child = pWin->drawable.id;
- pWin = (WindowPtr) NULL;
- }
- else
- pWin = pWin->nextSib;
- }
- /* adjust to destination coordinates */
- rep.dstX = x - pDst->drawable.x;
- rep.dstY = y - pDst->drawable.y;
- }
- WriteReplyToClient(client, sizeof(xTranslateCoordsReply), &rep);
- return(client->noClientException);
-}
-
-int
-ProcOpenFont(client)
- register ClientPtr client;
-{
- int err;
- REQUEST(xOpenFontReq);
-
- REQUEST_FIXED_SIZE(xOpenFontReq, stuff->nbytes);
- client->errorValue = stuff->fid;
- LEGAL_NEW_RESOURCE(stuff->fid, client);
- err = OpenFont(client, stuff->fid, (Mask) 0,
- stuff->nbytes, (char *)&stuff[1]);
- if (err == Success)
- {
- return(client->noClientException);
- }
- else
- return err;
-}
-
-int
-ProcCloseFont(client)
- register ClientPtr client;
-{
- FontPtr pFont;
- REQUEST(xResourceReq);
-
- REQUEST_SIZE_MATCH(xResourceReq);
- pFont = (FontPtr)SecurityLookupIDByType(client, stuff->id, RT_FONT,
- SecurityDestroyAccess);
- if ( pFont != (FontPtr)NULL) /* id was valid */
- {
- FreeResource(stuff->id, RT_NONE);
- return(client->noClientException);
- }
- else
- {
- client->errorValue = stuff->id;
- return (BadFont);
- }
-}
-
-int
-ProcQueryFont(client)
- register ClientPtr client;
-{
- xQueryFontReply *reply;
- FontPtr pFont;
- register GC *pGC;
- REQUEST(xResourceReq);
-
- REQUEST_SIZE_MATCH(xResourceReq);
- client->errorValue = stuff->id; /* EITHER font or gc */
- pFont = (FontPtr)SecurityLookupIDByType(client, stuff->id, RT_FONT,
- SecurityReadAccess);
- if (!pFont)
- {
- /* can't use VERIFY_GC because it might return BadGC */
- pGC = (GC *) SecurityLookupIDByType(client, stuff->id, RT_GC,
- SecurityReadAccess);
- if (!pGC)
- {
- client->errorValue = stuff->id;
- return(BadFont); /* procotol spec says only error is BadFont */
- }
- pFont = pGC->font;
- }
-
- {
- xCharInfo *pmax = FONTINKMAX(pFont);
- xCharInfo *pmin = FONTINKMIN(pFont);
- int nprotoxcistructs;
- int rlength;
-
- nprotoxcistructs = (
- pmax->rightSideBearing == pmin->rightSideBearing &&
- pmax->leftSideBearing == pmin->leftSideBearing &&
- pmax->descent == pmin->descent &&
- pmax->ascent == pmin->ascent &&
- pmax->characterWidth == pmin->characterWidth) ?
- 0 : N2dChars(pFont);
-
- rlength = sizeof(xQueryFontReply) +
- FONTINFONPROPS(FONTCHARSET(pFont)) * sizeof(xFontProp) +
- nprotoxcistructs * sizeof(xCharInfo);
- reply = (xQueryFontReply *)ALLOCATE_LOCAL(rlength);
- if(!reply)
- {
- return(BadAlloc);
- }
-
- reply->type = X_Reply;
- reply->length = (rlength - sizeof(xGenericReply)) >> 2;
- reply->sequenceNumber = client->sequence;
- QueryFont( pFont, reply, nprotoxcistructs);
-
- WriteReplyToClient(client, rlength, reply);
- DEALLOCATE_LOCAL(reply);
- return(client->noClientException);
- }
-}
-
-int
-ProcQueryTextExtents(client)
- register ClientPtr client;
-{
- REQUEST(xQueryTextExtentsReq);
- xQueryTextExtentsReply reply;
- FontPtr pFont;
- GC *pGC;
- ExtentInfoRec info;
- unsigned long length;
-
- REQUEST_AT_LEAST_SIZE(xQueryTextExtentsReq);
-
- pFont = (FontPtr)SecurityLookupIDByType(client, stuff->fid, RT_FONT,
- SecurityReadAccess);
- if (!pFont)
- {
- pGC = (GC *)SecurityLookupIDByType(client, stuff->fid, RT_GC,
- SecurityReadAccess);
- if (!pGC)
- {
- client->errorValue = stuff->fid;
- return(BadFont);
- }
- pFont = pGC->font;
- }
- length = client->req_len - (sizeof(xQueryTextExtentsReq) >> 2);
- length = length << 1;
- if (stuff->oddLength)
- {
- if (length == 0)
- return(BadLength);
- length--;
- }
- if (!QueryTextExtents(pFont, length, (unsigned char *)&stuff[1], &info))
- return(BadAlloc);
- reply.type = X_Reply;
- reply.length = 0;
- reply.sequenceNumber = client->sequence;
- reply.drawDirection = info.drawDirection;
- reply.fontAscent = info.fontAscent;
- reply.fontDescent = info.fontDescent;
- reply.overallAscent = info.overallAscent;
- reply.overallDescent = info.overallDescent;
- reply.overallWidth = info.overallWidth;
- reply.overallLeft = info.overallLeft;
- reply.overallRight = info.overallRight;
- WriteReplyToClient(client, sizeof(xQueryTextExtentsReply), &reply);
- return(client->noClientException);
-}
-
-int
-ProcListFonts(client)
- register ClientPtr client;
-{
- REQUEST(xListFontsReq);
-
- REQUEST_FIXED_SIZE(xListFontsReq, stuff->nbytes);
-
- return ListFonts(client, (unsigned char *) &stuff[1], stuff->nbytes,
- stuff->maxNames);
-}
-
-int
-ProcListFontsWithInfo(client)
- register ClientPtr client;
-{
- REQUEST(xListFontsWithInfoReq);
-
- REQUEST_FIXED_SIZE(xListFontsWithInfoReq, stuff->nbytes);
-
- return StartListFontsWithInfo(client, stuff->nbytes,
- (unsigned char *) &stuff[1], stuff->maxNames);
-}
-
-/*ARGSUSED*/
-int
-dixDestroyPixmap(value, pid)
- pointer value; /* must conform to DeleteType */
- XID pid;
-{
- PixmapPtr pPixmap = (PixmapPtr)value;
- return (*pPixmap->drawable.pScreen->DestroyPixmap)(pPixmap);
-}
-
-int
-ProcCreatePixmap(client)
- register ClientPtr client;
-{
- PixmapPtr pMap;
- register DrawablePtr pDraw;
- REQUEST(xCreatePixmapReq);
- DepthPtr pDepth;
- register int i;
-
- REQUEST_SIZE_MATCH(xCreatePixmapReq);
- client->errorValue = stuff->pid;
- LEGAL_NEW_RESOURCE(stuff->pid, client);
- SECURITY_VERIFY_GEOMETRABLE (pDraw, stuff->drawable, client,
- SecurityReadAccess);
- if (!stuff->width || !stuff->height)
- {
- client->errorValue = 0;
- return BadValue;
- }
- if (stuff->depth != 1)
- {
- pDepth = pDraw->pScreen->allowedDepths;
- for (i=0; i<pDraw->pScreen->numDepths; i++, pDepth++)
- if (pDepth->depth == stuff->depth)
- goto CreatePmap;
- client->errorValue = stuff->depth;
- return BadValue;
- }
-CreatePmap:
- pMap = (PixmapPtr)(*pDraw->pScreen->CreatePixmap)
- (pDraw->pScreen, stuff->width,
- stuff->height, stuff->depth);
- if (pMap)
- {
- pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
- pMap->drawable.id = stuff->pid;
- if (AddResource(stuff->pid, RT_PIXMAP, (pointer)pMap))
- return(client->noClientException);
- }
- return (BadAlloc);
-}
-
-int
-ProcFreePixmap(client)
- register ClientPtr client;
-{
- PixmapPtr pMap;
-
- REQUEST(xResourceReq);
-
- REQUEST_SIZE_MATCH(xResourceReq);
- pMap = (PixmapPtr)SecurityLookupIDByType(client, stuff->id, RT_PIXMAP,
- SecurityDestroyAccess);
- if (pMap)
- {
- FreeResource(stuff->id, RT_NONE);
- return(client->noClientException);
- }
- else
- {
- client->errorValue = stuff->id;
- return (BadPixmap);
- }
-}
-
-int
-ProcCreateGC(client)
- register ClientPtr client;
-{
- int error;
- GC *pGC;
- register DrawablePtr pDraw;
- unsigned len;
- REQUEST(xCreateGCReq);
-
- REQUEST_AT_LEAST_SIZE(xCreateGCReq);
- client->errorValue = stuff->gc;
- LEGAL_NEW_RESOURCE(stuff->gc, client);
- SECURITY_VERIFY_DRAWABLE (pDraw, stuff->drawable, client,
- SecurityReadAccess);
- len = client->req_len - (sizeof(xCreateGCReq) >> 2);
- if (len != Ones(stuff->mask))
- return BadLength;
- pGC = (GC *)CreateGC(pDraw, stuff->mask,
- (XID *) &stuff[1], &error);
- if (error != Success)
- return error;
- if (!AddResource(stuff->gc, RT_GC, (pointer)pGC))
- return (BadAlloc);
- return(client->noClientException);
-}
-
-int
-ProcChangeGC(client)
- register ClientPtr client;
-{
- GC *pGC;
- REQUEST(xChangeGCReq);
- int result;
- unsigned len;
-
- REQUEST_AT_LEAST_SIZE(xChangeGCReq);
- SECURITY_VERIFY_GC(pGC, stuff->gc, client, SecurityWriteAccess);
- len = client->req_len - (sizeof(xChangeGCReq) >> 2);
- if (len != Ones(stuff->mask))
- return BadLength;
- result = dixChangeGC(client, pGC, stuff->mask, (CARD32 *) &stuff[1], 0);
- if (client->noClientException != Success)
- return(client->noClientException);
- else
- {
- client->errorValue = clientErrorValue;
- return(result);
- }
-}
-
-int
-ProcCopyGC(client)
- register ClientPtr client;
-{
- register GC *dstGC;
- register GC *pGC;
- int result;
- REQUEST(xCopyGCReq);
-
- REQUEST_SIZE_MATCH(xCopyGCReq);
- SECURITY_VERIFY_GC( pGC, stuff->srcGC, client, SecurityReadAccess);
- SECURITY_VERIFY_GC( dstGC, stuff->dstGC, client, SecurityWriteAccess);
- if ((dstGC->pScreen != pGC->pScreen) || (dstGC->depth != pGC->depth))
- return (BadMatch);
- result = CopyGC(pGC, dstGC, stuff->mask);
- if (client->noClientException != Success)
- return(client->noClientException);
- else
- {
- client->errorValue = clientErrorValue;
- return(result);
- }
-}
-
-int
-ProcSetDashes(client)
- register ClientPtr client;
-{
- register GC *pGC;
- int result;
- REQUEST(xSetDashesReq);
-
- REQUEST_FIXED_SIZE(xSetDashesReq, stuff->nDashes);
- if (stuff->nDashes == 0)
- {
- client->errorValue = 0;
- return BadValue;
- }
-
- SECURITY_VERIFY_GC(pGC,stuff->gc, client, SecurityWriteAccess);
-
- result = SetDashes(pGC, stuff->dashOffset, stuff->nDashes,
- (unsigned char *)&stuff[1]);
- if (client->noClientException != Success)
- return(client->noClientException);
- else
- {
- client->errorValue = clientErrorValue;
- return(result);
- }
-}
-
-int
-ProcSetClipRectangles(client)
- register ClientPtr client;
-{
- int nr;
- int result;
- register GC *pGC;
- REQUEST(xSetClipRectanglesReq);
-
- REQUEST_AT_LEAST_SIZE(xSetClipRectanglesReq);
- if ((stuff->ordering != Unsorted) && (stuff->ordering != YSorted) &&
- (stuff->ordering != YXSorted) && (stuff->ordering != YXBanded))
- {
- client->errorValue = stuff->ordering;
- return BadValue;
- }
- SECURITY_VERIFY_GC(pGC,stuff->gc, client, SecurityWriteAccess);
-
- nr = (client->req_len << 2) - sizeof(xSetClipRectanglesReq);
- if (nr & 4)
- return(BadLength);
- nr >>= 3;
- result = SetClipRects(pGC, stuff->xOrigin, stuff->yOrigin,
- nr, (xRectangle *)&stuff[1], (int)stuff->ordering);
- if (client->noClientException != Success)
- return(client->noClientException);
- else
- return(result);
-}
-
-int
-ProcFreeGC(client)
- register ClientPtr client;
-{
- register GC *pGC;
- REQUEST(xResourceReq);
-
- REQUEST_SIZE_MATCH(xResourceReq);
- SECURITY_VERIFY_GC(pGC, stuff->id, client, SecurityDestroyAccess);
- FreeResource(stuff->id, RT_NONE);
- return(client->noClientException);
-}
-
-int
-ProcClearToBackground(client)
- register ClientPtr client;
-{
- REQUEST(xClearAreaReq);
- register WindowPtr pWin;
-
- REQUEST_SIZE_MATCH(xClearAreaReq);
- pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
- SecurityWriteAccess);
- if (!pWin)
- return(BadWindow);
- if (pWin->drawable.class == InputOnly)
- {
- client->errorValue = stuff->window;
- return (BadMatch);
- }
- if ((stuff->exposures != xTrue) && (stuff->exposures != xFalse))
- {
- client->errorValue = stuff->exposures;
- return(BadValue);
- }
- (*pWin->drawable.pScreen->ClearToBackground)(pWin, stuff->x, stuff->y,
- stuff->width, stuff->height,
- (Bool)stuff->exposures);
- return(client->noClientException);
-}
-
-int
-ProcCopyArea(client)
- register ClientPtr client;
-{
- register DrawablePtr pDst;
- register DrawablePtr pSrc;
- register GC *pGC;
- REQUEST(xCopyAreaReq);
- RegionPtr pRgn;
-
- REQUEST_SIZE_MATCH(xCopyAreaReq);
-
- VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pDst, pGC, client);
- if (stuff->dstDrawable != stuff->srcDrawable)
- {
- SECURITY_VERIFY_DRAWABLE(pSrc, stuff->srcDrawable, client,
- SecurityReadAccess);
- if ((pDst->pScreen != pSrc->pScreen) || (pDst->depth != pSrc->depth))
- {
- client->errorValue = stuff->dstDrawable;
- return (BadMatch);
- }
- }
- else
- pSrc = pDst;
-
- SET_DBE_SRCBUF(pSrc, stuff->srcDrawable);
-
- pRgn = (*pGC->ops->CopyArea)(pSrc, pDst, pGC, stuff->srcX, stuff->srcY,
- stuff->width, stuff->height,
- stuff->dstX, stuff->dstY);
- if (pGC->graphicsExposures)
- {
- (*pDst->pScreen->SendGraphicsExpose)
- (client, pRgn, stuff->dstDrawable, X_CopyArea, 0);
- if (pRgn)
- REGION_DESTROY(pDst->pScreen, pRgn);
- }
-
- return(client->noClientException);
-}
-
-int
-ProcCopyPlane(client)
- register ClientPtr client;
-{
- register DrawablePtr psrcDraw, pdstDraw;
- register GC *pGC;
- REQUEST(xCopyPlaneReq);
- RegionPtr pRgn;
-
- REQUEST_SIZE_MATCH(xCopyPlaneReq);
-
- VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pdstDraw, pGC, client);
- if (stuff->dstDrawable != stuff->srcDrawable)
- {
- SECURITY_VERIFY_DRAWABLE(psrcDraw, stuff->srcDrawable, client,
- SecurityReadAccess);
- if (pdstDraw->pScreen != psrcDraw->pScreen)
- {
- client->errorValue = stuff->dstDrawable;
- return (BadMatch);
- }
- }
- else
- psrcDraw = pdstDraw;
-
- SET_DBE_SRCBUF(psrcDraw, stuff->srcDrawable);
-
- /* Check to see if stuff->bitPlane has exactly ONE good bit set */
- if(stuff->bitPlane == 0 || (stuff->bitPlane & (stuff->bitPlane - 1)) ||
- (stuff->bitPlane > (1L << (psrcDraw->depth - 1))))
- {
- client->errorValue = stuff->bitPlane;
- return(BadValue);
- }
-
- pRgn = (*pGC->ops->CopyPlane)(psrcDraw, pdstDraw, pGC, stuff->srcX, stuff->srcY,
- stuff->width, stuff->height,
- stuff->dstX, stuff->dstY, stuff->bitPlane);
- if (pGC->graphicsExposures)
- {
- (*pdstDraw->pScreen->SendGraphicsExpose)
- (client, pRgn, stuff->dstDrawable, X_CopyPlane, 0);
- if (pRgn)
- REGION_DESTROY(pdstDraw->pScreen, pRgn);
- }
- return(client->noClientException);
-}
-
-int
-ProcPolyPoint(client)
- register ClientPtr client;
-{
- int npoint;
- register GC *pGC;
- register DrawablePtr pDraw;
- REQUEST(xPolyPointReq);
-
- REQUEST_AT_LEAST_SIZE(xPolyPointReq);
- if ((stuff->coordMode != CoordModeOrigin) &&
- (stuff->coordMode != CoordModePrevious))
- {
- client->errorValue = stuff->coordMode;
- return BadValue;
- }
- VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
- npoint = ((client->req_len << 2) - sizeof(xPolyPointReq)) >> 2;
- if (npoint)
- (*pGC->ops->PolyPoint)(pDraw, pGC, stuff->coordMode, npoint,
- (xPoint *) &stuff[1]);
- return (client->noClientException);
-}
-
-int
-ProcPolyLine(client)
- register ClientPtr client;
-{
- int npoint;
- register GC *pGC;
- register DrawablePtr pDraw;
- REQUEST(xPolyLineReq);
-
- REQUEST_AT_LEAST_SIZE(xPolyLineReq);
- if ((stuff->coordMode != CoordModeOrigin) &&
- (stuff->coordMode != CoordModePrevious))
- {
- client->errorValue = stuff->coordMode;
- return BadValue;
- }
- VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
- npoint = ((client->req_len << 2) - sizeof(xPolyLineReq)) >> 2;
- if (npoint > 1)
- (*pGC->ops->Polylines)(pDraw, pGC, stuff->coordMode, npoint,
- (DDXPointPtr) &stuff[1]);
- return(client->noClientException);
-}
-
-int
-ProcPolySegment(client)
- register ClientPtr client;
-{
- int nsegs;
- register GC *pGC;
- register DrawablePtr pDraw;
- REQUEST(xPolySegmentReq);
-
- REQUEST_AT_LEAST_SIZE(xPolySegmentReq);
- VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
- nsegs = (client->req_len << 2) - sizeof(xPolySegmentReq);
- if (nsegs & 4)
- return(BadLength);
- nsegs >>= 3;
- if (nsegs)
- (*pGC->ops->PolySegment)(pDraw, pGC, nsegs, (xSegment *) &stuff[1]);
- return (client->noClientException);
-}
-
-int
-ProcPolyRectangle (client)
- register ClientPtr client;
-{
- int nrects;
- register GC *pGC;
- register DrawablePtr pDraw;
- REQUEST(xPolyRectangleReq);
-
- REQUEST_AT_LEAST_SIZE(xPolyRectangleReq);
- VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
- nrects = (client->req_len << 2) - sizeof(xPolyRectangleReq);
- if (nrects & 4)
- return(BadLength);
- nrects >>= 3;
- if (nrects)
- (*pGC->ops->PolyRectangle)(pDraw, pGC,
- nrects, (xRectangle *) &stuff[1]);
- return(client->noClientException);
-}
-
-int
-ProcPolyArc(client)
- register ClientPtr client;
-{
- int narcs;
- register GC *pGC;
- register DrawablePtr pDraw;
- REQUEST(xPolyArcReq);
-
- REQUEST_AT_LEAST_SIZE(xPolyArcReq);
- VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
- narcs = (client->req_len << 2) - sizeof(xPolyArcReq);
- if (narcs % sizeof(xArc))
- return(BadLength);
- narcs /= sizeof(xArc);
- if (narcs)
- (*pGC->ops->PolyArc)(pDraw, pGC, narcs, (xArc *) &stuff[1]);
- return (client->noClientException);
-}
-
-int
-ProcFillPoly(client)
- register ClientPtr client;
-{
- int things;
- register GC *pGC;
- register DrawablePtr pDraw;
- REQUEST(xFillPolyReq);
-
- REQUEST_AT_LEAST_SIZE(xFillPolyReq);
- if ((stuff->shape != Complex) && (stuff->shape != Nonconvex) &&
- (stuff->shape != Convex))
- {
- client->errorValue = stuff->shape;
- return BadValue;
- }
- if ((stuff->coordMode != CoordModeOrigin) &&
- (stuff->coordMode != CoordModePrevious))
- {
- client->errorValue = stuff->coordMode;
- return BadValue;
- }
-
- VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
- things = ((client->req_len << 2) - sizeof(xFillPolyReq)) >> 2;
- if (things)
- (*pGC->ops->FillPolygon) (pDraw, pGC, stuff->shape,
- stuff->coordMode, things,
- (DDXPointPtr) &stuff[1]);
- return(client->noClientException);
-}
-
-int
-ProcPolyFillRectangle(client)
- register ClientPtr client;
-{
- int things;
- register GC *pGC;
- register DrawablePtr pDraw;
- REQUEST(xPolyFillRectangleReq);
-
- REQUEST_AT_LEAST_SIZE(xPolyFillRectangleReq);
- VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
- things = (client->req_len << 2) - sizeof(xPolyFillRectangleReq);
- if (things & 4)
- return(BadLength);
- things >>= 3;
- if (things)
- (*pGC->ops->PolyFillRect) (pDraw, pGC, things,
- (xRectangle *) &stuff[1]);
- return (client->noClientException);
-}
-
-int
-ProcPolyFillArc(client)
- register ClientPtr client;
-{
- int narcs;
- register GC *pGC;
- register DrawablePtr pDraw;
- REQUEST(xPolyFillArcReq);
-
- REQUEST_AT_LEAST_SIZE(xPolyFillArcReq);
- VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
- narcs = (client->req_len << 2) - sizeof(xPolyFillArcReq);
- if (narcs % sizeof(xArc))
- return(BadLength);
- narcs /= sizeof(xArc);
- if (narcs)
- (*pGC->ops->PolyFillArc) (pDraw, pGC, narcs, (xArc *) &stuff[1]);
- return (client->noClientException);
-}
-
-/* 64-bit server notes: the protocol restricts padding of images to
- * 8-, 16-, or 32-bits. We would like to have 64-bits for the server
- * to use internally. Removes need for internal alignment checking.
- * All of the PutImage functions could be changed individually, but
- * as currently written, they call other routines which require things
- * to be 64-bit padded on scanlines, so we changed things here.
- * If an image would be padded differently for 64- versus 32-, then
- * copy each scanline to a 64-bit padded scanline.
- * Also, we need to make sure that the image is aligned on a 64-bit
- * boundary, even if the scanlines are padded to our satisfaction.
- */
-int
-ProcPutImage(client)
- register ClientPtr client;
-{
- register GC *pGC;
- register DrawablePtr pDraw;
- long length; /* length of scanline server padded */
- long lengthProto; /* length of scanline protocol padded */
- char *tmpImage;
- REQUEST(xPutImageReq);
-
- REQUEST_AT_LEAST_SIZE(xPutImageReq);
- VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
- if (stuff->format == XYBitmap)
- {
- if ((stuff->depth != 1) ||
- (stuff->leftPad >= (unsigned int)screenInfo.bitmapScanlinePad))
- return BadMatch;
- length = BitmapBytePad(stuff->width + stuff->leftPad);
-#ifdef INTERNAL_VS_EXTERNAL_PADDING
- lengthProto = BitmapBytePadProto(stuff->width + stuff->leftPad);
-#endif
- }
- else if (stuff->format == XYPixmap)
- {
- if ((pDraw->depth != stuff->depth) ||
- (stuff->leftPad >= (unsigned int)screenInfo.bitmapScanlinePad))
- return BadMatch;
- length = BitmapBytePad(stuff->width + stuff->leftPad);
- length *= stuff->depth;
-#ifdef INTERNAL_VS_EXTERNAL_PADDING
- lengthProto = BitmapBytePadProto(stuff->width + stuff->leftPad);
- lengthProto *= stuff->depth;
-#endif
- }
- else if (stuff->format == ZPixmap)
- {
- if ((pDraw->depth != stuff->depth) || (stuff->leftPad != 0))
- return BadMatch;
- length = PixmapBytePad(stuff->width, stuff->depth);
-#ifdef INTERNAL_VS_EXTERNAL_PADDING
- lengthProto = PixmapBytePadProto(stuff->width, stuff->depth);
-#endif
- }
- else
- {
- client->errorValue = stuff->format;
- return BadValue;
- }
-
-#ifdef INTERNAL_VS_EXTERNAL_PADDING
- /* handle 64 bit case where protocol may pad to 32 and we want 64 */
- if ( length != lengthProto ) {
- register int i;
- char * stuffptr, /* pointer into protocol data */
- * tmpptr; /* new location to copy to */
-
- if(!(tmpImage = (char *) ALLOCATE_LOCAL(length*stuff->height)))
- return (BadAlloc);
-
- bzero(tmpImage,length*stuff->height);
-
- if ( stuff->format == XYPixmap ) {
- int lineBytes = BitmapBytePad(stuff->width + stuff->leftPad);
- int lineBytesProto =
- BitmapBytePadProto(stuff->width + stuff->leftPad);
- int depth = stuff->depth;
-
- stuffptr = (char *)&stuff[1];
- tmpptr = tmpImage;
- for ( i = 0; i < stuff->height*stuff->depth;
- stuffptr += lineBytesProto,tmpptr += lineBytes, i++)
- memmove(tmpptr,stuffptr,lineBytesProto);
- }
- else {
- for ( i = 0,stuffptr = (char *)&stuff[1],tmpptr=tmpImage;
- i < stuff->height;
- stuffptr += lengthProto,tmpptr += length, i++)
- memmove(tmpptr,stuffptr,lengthProto);
- }
- }
-
- /* handle 64-bit case where stuff is not 64-bit aligned */
- else if ((unsigned long)&stuff[1] & (sizeof(long)-1)) {
- if(!(tmpImage = (char *) ALLOCATE_LOCAL(length*stuff->height)))
- return (BadAlloc);
- memmove(tmpImage,(char *)&stuff[1],length*stuff->height);
- }
- else
- tmpImage = (char *)&stuff[1];
-#else
- tmpImage = (char *)&stuff[1];
- lengthProto = length;
-#endif /* INTERNAL_VS_EXTERNAL_PADDING */
-
- if (((((lengthProto * stuff->height) + (unsigned)3) >> 2) +
- (sizeof(xPutImageReq) >> 2)) != client->req_len)
- return BadLength;
-
- (*pGC->ops->PutImage) (pDraw, pGC, stuff->depth, stuff->dstX, stuff->dstY,
- stuff->width, stuff->height,
- stuff->leftPad, stuff->format, tmpImage);
-
-#ifdef INTERNAL_VS_EXTERNAL_PADDING
- /* free up our temporary space if used */
- if (tmpImage != (char *)&stuff[1])
- DEALLOCATE_LOCAL(tmpImage);
-#endif /* INTERNAL_VS_EXTERNAL_PADDING */
-
- return (client->noClientException);
-}
-
-
-int
-DoGetImage(client, format, drawable, x, y, width, height, planemask, im_return)
- register ClientPtr client;
- Drawable drawable;
- int format;
- int x, y, width, height;
- Mask planemask;
- xGetImageReply **im_return;
-{
- register DrawablePtr pDraw;
- int nlines, linesPerBuf;
- register int linesDone;
- long widthBytesLine, length;
-#ifdef INTERNAL_VS_EXTERNAL_PADDING
- long widthBytesLineProto, lengthProto;
-#endif
- Mask plane;
- char *pBuf;
- xGetImageReply xgi;
- RegionPtr pVisibleRegion = NULL;
-
- if ((format != XYPixmap) && (format != ZPixmap))
- {
- client->errorValue = format;
- return(BadValue);
- }
- SECURITY_VERIFY_DRAWABLE(pDraw, drawable, client, SecurityReadAccess);
- if(pDraw->type == DRAWABLE_WINDOW)
- {
- if( /* check for being viewable */
- !((WindowPtr) pDraw)->realized ||
- /* check for being on screen */
- pDraw->x + x < 0 ||
- pDraw->x + x + width > pDraw->pScreen->width ||
- pDraw->y + y < 0 ||
- pDraw->y + y + height > pDraw->pScreen->height ||
- /* check for being inside of border */
- x < - wBorderWidth((WindowPtr)pDraw) ||
- x + width > wBorderWidth((WindowPtr)pDraw) + (int)pDraw->width ||
- y < -wBorderWidth((WindowPtr)pDraw) ||
- y + height > wBorderWidth ((WindowPtr)pDraw) + (int)pDraw->height
- )
- return(BadMatch);
- xgi.visual = wVisual (((WindowPtr) pDraw));
- }
- else
- {
- if(x < 0 ||
- x+width > (int)pDraw->width ||
- y < 0 ||
- y+height > (int)pDraw->height
- )
- return(BadMatch);
- xgi.visual = None;
- }
-
- SET_DBE_SRCBUF(pDraw, drawable);
-
- xgi.type = X_Reply;
- xgi.sequenceNumber = client->sequence;
- xgi.depth = pDraw->depth;
- if(format == ZPixmap)
- {
- widthBytesLine = PixmapBytePad(width, pDraw->depth);
- length = widthBytesLine * height;
-
-#ifdef INTERNAL_VS_EXTERNAL_PADDING
- widthBytesLineProto = PixmapBytePadProto(width, pDraw->depth);
- lengthProto = widthBytesLineProto * height;
-#endif
- }
- else
- {
- widthBytesLine = BitmapBytePad(width);
- plane = ((Mask)1) << (pDraw->depth - 1);
- /* only planes asked for */
- length = widthBytesLine * height *
- Ones(planemask & (plane | (plane - 1)));
-
-#ifdef INTERNAL_VS_EXTERNAL_PADDING
- widthBytesLineProto = BitmapBytePadProto(width);
- lengthProto = widthBytesLineProto * height *
- Ones(planemask & (plane | (plane - 1)));
-#endif
- }
-
-#ifdef INTERNAL_VS_EXTERNAL_PADDING
- xgi.length = lengthProto;
-#else
- xgi.length = length;
-#endif
-
- if (im_return) {
- pBuf = (char *)xalloc(sz_xGetImageReply + length);
- if (!pBuf)
- return (BadAlloc);
- if (widthBytesLine == 0)
- linesPerBuf = 0;
- else
- linesPerBuf = height;
- *im_return = (xGetImageReply *)pBuf;
- *(xGetImageReply *)pBuf = xgi;
- pBuf += sz_xGetImageReply;
- } else {
- xgi.length = (xgi.length + 3) >> 2;
- if (widthBytesLine == 0 || height == 0)
- linesPerBuf = 0;
- else if (widthBytesLine >= IMAGE_BUFSIZE)
- linesPerBuf = 1;
- else
- {
- linesPerBuf = IMAGE_BUFSIZE / widthBytesLine;
- if (linesPerBuf > height)
- linesPerBuf = height;
- }
- length = linesPerBuf * widthBytesLine;
- if (linesPerBuf < height)
- {
- /* we have to make sure intermediate buffers don't need padding */
- while ((linesPerBuf > 1) &&
- (length & ((1 << LOG2_BYTES_PER_SCANLINE_PAD)-1)))
- {
- linesPerBuf--;
- length -= widthBytesLine;
- }
- while (length & ((1 << LOG2_BYTES_PER_SCANLINE_PAD)-1))
- {
- linesPerBuf++;
- length += widthBytesLine;
- }
- }
- if(!(pBuf = (char *) ALLOCATE_LOCAL(length)))
- return (BadAlloc);
- WriteReplyToClient(client, sizeof (xGetImageReply), &xgi);
- }
-
-#ifdef XCSECURITY
- if (client->trustLevel != XSecurityClientTrusted &&
- pDraw->type == DRAWABLE_WINDOW)
- {
- pVisibleRegion = NotClippedByChildren((WindowPtr)pDraw);
- if (pVisibleRegion)
- {
- REGION_TRANSLATE(pScreen, pVisibleRegion, -pDraw->x, -pDraw->y);
- }
- }
-#endif
-
- if (linesPerBuf == 0)
- {
- /* nothing to do */
- }
- else if (format == ZPixmap)
- {
- linesDone = 0;
- while (height - linesDone > 0)
- {
- nlines = min(linesPerBuf, height - linesDone);
- (*pDraw->pScreen->GetImage) (pDraw,
- x,
- y + linesDone,
- width,
- nlines,
- format,
- planemask,
- (pointer) pBuf);
-#ifdef XCSECURITY
- if (pVisibleRegion)
- SecurityCensorImage(client, pVisibleRegion, widthBytesLine,
- pDraw, x, y + linesDone, width,
- nlines, format, pBuf);
-#endif
-
-#ifdef INTERNAL_VS_EXTERNAL_PADDING
- /* for 64-bit server, convert image to pad to 32 bits */
- if ( widthBytesLine != widthBytesLineProto ) {
- register char * bufPtr, * protoPtr;
- register int i;
-
- for (i = 1,
- bufPtr = pBuf + widthBytesLine,
- protoPtr = pBuf + widthBytesLineProto;
- i < nlines;
- bufPtr += widthBytesLine,
- protoPtr += widthBytesLineProto,
- i++)
- memmove(protoPtr, bufPtr, widthBytesLineProto);
- }
-#endif
- /* Note that this is NOT a call to WriteSwappedDataToClient,
- as we do NOT byte swap */
- if (!im_return)
-/* Don't split me, gcc pukes when you do */
-#ifdef INTERNAL_VS_EXTERNAL_PADDING
- (void)WriteToClient(client,
- (int)(nlines * widthBytesLineProto),
- pBuf);
-#else
- (void)WriteToClient(client,
- (int)(nlines * widthBytesLine),
- pBuf);
-#endif
- linesDone += nlines;
- }
- }
- else /* XYPixmap */
- {
- for (; plane; plane >>= 1)
- {
- if (planemask & plane)
- {
- linesDone = 0;
- while (height - linesDone > 0)
- {
- nlines = min(linesPerBuf, height - linesDone);
- (*pDraw->pScreen->GetImage) (pDraw,
- x,
- y + linesDone,
- width,
- nlines,
- format,
- plane,
- (pointer)pBuf);
-#ifdef XCSECURITY
- if (pVisibleRegion)
- SecurityCensorImage(client, pVisibleRegion,
- widthBytesLine,
- pDraw, x, y + linesDone, width,
- nlines, format, pBuf);
-#endif
-
-#ifdef INTERNAL_VS_EXTERNAL_PADDING
- /* for 64-bit server, convert image to pad to 32 bits */
- if ( widthBytesLine != widthBytesLineProto ) {
- register char * bufPtr, * protoPtr;
- register int i;
-
- for (i = 1,
- bufPtr = pBuf + widthBytesLine,
- protoPtr = pBuf + widthBytesLineProto;
- i < nlines;
- bufPtr += widthBytesLine,
- protoPtr += widthBytesLineProto,
- i++)
- memmove(protoPtr, bufPtr, widthBytesLineProto);
- }
-#endif
- /* Note: NOT a call to WriteSwappedDataToClient,
- as we do NOT byte swap */
- if (im_return) {
-#ifdef INTERNAL_VS_EXTERNAL_PADDING
- pBuf += nlines * widthBytesLineProto;
-#else
- pBuf += nlines * widthBytesLine;
-#endif
- } else
-/* Don't split me, gcc pukes when you do */
-#ifdef INTERNAL_VS_EXTERNAL_PADDING
- (void)WriteToClient(client,
- (int)(nlines * widthBytesLineProto),
- pBuf);
-#else
- (void)WriteToClient(client,
- (int)(nlines * widthBytesLine),
- pBuf);
-#endif
- linesDone += nlines;
- }
- }
- }
- }
-#ifdef XCSECURITY
- if (pVisibleRegion)
- REGION_DESTROY(pScreen, pVisibleRegion);
-#endif
- if (!im_return)
- DEALLOCATE_LOCAL(pBuf);
- return (client->noClientException);
-}
-
-int
-ProcGetImage(client)
- register ClientPtr client;
-{
- REQUEST(xGetImageReq);
-
- REQUEST_SIZE_MATCH(xGetImageReq);
-
- return DoGetImage(client, stuff->format, stuff->drawable,
- stuff->x, stuff->y,
- (int)stuff->width, (int)stuff->height,
- stuff->planeMask, (xGetImageReply **)NULL);
-}
-
-int
-ProcPolyText(client)
- register ClientPtr client;
-{
- int err;
- REQUEST(xPolyTextReq);
- DrawablePtr pDraw;
- GC *pGC;
-
- REQUEST_AT_LEAST_SIZE(xPolyTextReq);
- VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
-
- err = PolyText(client,
- pDraw,
- pGC,
- (unsigned char *)&stuff[1],
- ((unsigned char *) stuff) + (client->req_len << 2),
- stuff->x,
- stuff->y,
- stuff->reqType,
- stuff->drawable);
-
- if (err == Success)
- {
- return(client->noClientException);
- }
- else
- return err;
-}
-
-int
-ProcImageText8(client)
- register ClientPtr client;
-{
- int err;
- register DrawablePtr pDraw;
- register GC *pGC;
-
- REQUEST(xImageTextReq);
-
- REQUEST_FIXED_SIZE(xImageTextReq, stuff->nChars);
- VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
-
- err = ImageText(client,
- pDraw,
- pGC,
- stuff->nChars,
- (unsigned char *)&stuff[1],
- stuff->x,
- stuff->y,
- stuff->reqType,
- stuff->drawable);
-
- if (err == Success)
- {
- return(client->noClientException);
- }
- else
- return err;
-}
-
-int
-ProcImageText16(client)
- register ClientPtr client;
-{
- int err;
- register DrawablePtr pDraw;
- register GC *pGC;
-
- REQUEST(xImageTextReq);
-
- REQUEST_FIXED_SIZE(xImageTextReq, stuff->nChars << 1);
- VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
-
- err = ImageText(client,
- pDraw,
- pGC,
- stuff->nChars,
- (unsigned char *)&stuff[1],
- stuff->x,
- stuff->y,
- stuff->reqType,
- stuff->drawable);
-
- if (err == Success)
- {
- return(client->noClientException);
- }
- else
- return err;
-}
-
-
-int
-ProcCreateColormap(client)
- register ClientPtr client;
-{
- VisualPtr pVisual;
- ColormapPtr pmap;
- Colormap mid;
- register WindowPtr pWin;
- ScreenPtr pScreen;
- REQUEST(xCreateColormapReq);
- int i, result;
-
- REQUEST_SIZE_MATCH(xCreateColormapReq);
-
- if ((stuff->alloc != AllocNone) && (stuff->alloc != AllocAll))
- {
- client->errorValue = stuff->alloc;
- return(BadValue);
- }
- mid = stuff->mid;
- LEGAL_NEW_RESOURCE(mid, client);
- pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
- SecurityReadAccess);
- if (!pWin)
- return(BadWindow);
-
- pScreen = pWin->drawable.pScreen;
- for (i = 0, pVisual = pScreen->visuals;
- i < pScreen->numVisuals;
- i++, pVisual++)
- {
- if (pVisual->vid != stuff->visual)
- continue;
- result = CreateColormap(mid, pScreen, pVisual, &pmap,
- (int)stuff->alloc, client->index);
- if (client->noClientException != Success)
- return(client->noClientException);
- else
- return(result);
- }
- client->errorValue = stuff->visual;
- return(BadValue);
-}
-
-int
-ProcFreeColormap(client)
- register ClientPtr client;
-{
- ColormapPtr pmap;
- REQUEST(xResourceReq);
-
- REQUEST_SIZE_MATCH(xResourceReq);
- pmap = (ColormapPtr )SecurityLookupIDByType(client, stuff->id, RT_COLORMAP,
- SecurityDestroyAccess);
- if (pmap)
- {
- /* Freeing a default colormap is a no-op */
- if (!(pmap->flags & IsDefault))
- FreeResource(stuff->id, RT_NONE);
- return (client->noClientException);
- }
- else
- {
- client->errorValue = stuff->id;
- return (BadColor);
- }
-}
-
-
-int
-ProcCopyColormapAndFree(client)
- register ClientPtr client;
-{
- Colormap mid;
- ColormapPtr pSrcMap;
- REQUEST(xCopyColormapAndFreeReq);
- int result;
-
- REQUEST_SIZE_MATCH(xCopyColormapAndFreeReq);
- mid = stuff->mid;
- LEGAL_NEW_RESOURCE(mid, client);
- if( (pSrcMap = (ColormapPtr )SecurityLookupIDByType(client, stuff->srcCmap,
- RT_COLORMAP, SecurityReadAccess|SecurityWriteAccess)) )
- {
- result = CopyColormapAndFree(mid, pSrcMap, client->index);
- if (client->noClientException != Success)
- return(client->noClientException);
- else
- return(result);
- }
- else
- {
- client->errorValue = stuff->srcCmap;
- return(BadColor);
- }
-}
-
-int
-ProcInstallColormap(client)
- register ClientPtr client;
-{
- ColormapPtr pcmp;
- REQUEST(xResourceReq);
-
- REQUEST_SIZE_MATCH(xResourceReq);
- pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->id,
- RT_COLORMAP, SecurityReadAccess);
- if (pcmp)
- {
- (*(pcmp->pScreen->InstallColormap)) (pcmp);
- return (client->noClientException);
- }
- else
- {
- client->errorValue = stuff->id;
- return (BadColor);
- }
-}
-
-int
-ProcUninstallColormap(client)
- register ClientPtr client;
-{
- ColormapPtr pcmp;
- REQUEST(xResourceReq);
-
- REQUEST_SIZE_MATCH(xResourceReq);
- pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->id,
- RT_COLORMAP, SecurityReadAccess);
- if (pcmp)
- {
- if(pcmp->mid != pcmp->pScreen->defColormap)
- (*(pcmp->pScreen->UninstallColormap)) (pcmp);
- return (client->noClientException);
- }
- else
- {
- client->errorValue = stuff->id;
- return (BadColor);
- }
-}
-
-int
-ProcListInstalledColormaps(client)
- register ClientPtr client;
-{
- xListInstalledColormapsReply *preply;
- int nummaps;
- WindowPtr pWin;
- REQUEST(xResourceReq);
-
- REQUEST_SIZE_MATCH(xResourceReq);
- pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client,
- SecurityReadAccess);
-
- if (!pWin)
- return(BadWindow);
-
- preply = (xListInstalledColormapsReply *)
- ALLOCATE_LOCAL(sizeof(xListInstalledColormapsReply) +
- pWin->drawable.pScreen->maxInstalledCmaps *
- sizeof(Colormap));
- if(!preply)
- return(BadAlloc);
-
- preply->type = X_Reply;
- preply->sequenceNumber = client->sequence;
- nummaps = (*pWin->drawable.pScreen->ListInstalledColormaps)
- (pWin->drawable.pScreen, (Colormap *)&preply[1]);
- preply->nColormaps = nummaps;
- preply->length = nummaps;
- WriteReplyToClient(client, sizeof (xListInstalledColormapsReply), preply);
- client->pSwapReplyFunc = Swap32Write;
- WriteSwappedDataToClient(client, nummaps * sizeof(Colormap), &preply[1]);
- DEALLOCATE_LOCAL(preply);
- return(client->noClientException);
-}
-
-int
-ProcAllocColor(client)
- register ClientPtr client;
-{
- ColormapPtr pmap;
- int retval;
- xAllocColorReply acr;
- REQUEST(xAllocColorReq);
-
- REQUEST_SIZE_MATCH(xAllocColorReq);
- pmap = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap,
- RT_COLORMAP, SecurityWriteAccess);
- if (pmap)
- {
-#ifdef LBX
- /*
- * If the colormap is grabbed by a proxy, the server will have
- * to regain control over the colormap. This AllocColor request
- * will be handled after the server gets back the colormap control.
- */
- if (LbxCheckColorRequest (client, pmap, (xReq *) stuff))
- return Success;
-#endif
- acr.type = X_Reply;
- acr.length = 0;
- acr.sequenceNumber = client->sequence;
- acr.red = stuff->red;
- acr.green = stuff->green;
- acr.blue = stuff->blue;
- acr.pixel = 0;
- if( (retval = AllocColor(pmap, &acr.red, &acr.green, &acr.blue,
- &acr.pixel, client->index)) )
- {
- if (client->noClientException != Success)
- return(client->noClientException);
- else
- return (retval);
- }
-#ifdef PANORAMIX
- if (noPanoramiXExtension)
-#endif
- WriteReplyToClient(client, sizeof(xAllocColorReply), &acr);
- return (client->noClientException);
-
- }
- else
- {
- client->errorValue = stuff->cmap;
- return (BadColor);
- }
-}
-
-int
-ProcAllocNamedColor (client)
- register ClientPtr client;
-{
- ColormapPtr pcmp;
- REQUEST(xAllocNamedColorReq);
-
- REQUEST_FIXED_SIZE(xAllocNamedColorReq, stuff->nbytes);
- pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap,
- RT_COLORMAP, SecurityWriteAccess);
- if (pcmp)
- {
- int retval;
-
- xAllocNamedColorReply ancr;
-
-#ifdef LBX
- /*
- * If the colormap is grabbed by a proxy, the server will have
- * to regain control over the colormap. This AllocNamedColor request
- * will be handled after the server gets back the colormap control.
- */
- if (LbxCheckColorRequest (client, pcmp, (xReq *) stuff))
- return Success;
-#endif
- ancr.type = X_Reply;
- ancr.length = 0;
- ancr.sequenceNumber = client->sequence;
-
- if(OsLookupColor(pcmp->pScreen->myNum, (char *)&stuff[1], stuff->nbytes,
- &ancr.exactRed, &ancr.exactGreen, &ancr.exactBlue))
- {
- ancr.screenRed = ancr.exactRed;
- ancr.screenGreen = ancr.exactGreen;
- ancr.screenBlue = ancr.exactBlue;
- ancr.pixel = 0;
- if( (retval = AllocColor(pcmp,
- &ancr.screenRed, &ancr.screenGreen, &ancr.screenBlue,
- &ancr.pixel, client->index)) )
- {
- if (client->noClientException != Success)
- return(client->noClientException);
- else
- return(retval);
- }
-#ifdef PANORAMIX
- if (noPanoramiXExtension)
-#endif
- WriteReplyToClient(client, sizeof (xAllocNamedColorReply), &ancr);
- return (client->noClientException);
- }
- else
- return(BadName);
-
- }
- else
- {
- client->errorValue = stuff->cmap;
- return (BadColor);
- }
-}
-
-int
-ProcAllocColorCells (client)
- register ClientPtr client;
-{
- ColormapPtr pcmp;
- REQUEST(xAllocColorCellsReq);
-
- REQUEST_SIZE_MATCH(xAllocColorCellsReq);
- pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap,
- RT_COLORMAP, SecurityWriteAccess);
- if (pcmp)
- {
- xAllocColorCellsReply accr;
- int npixels, nmasks, retval;
- long length;
- Pixel *ppixels, *pmasks;
-
-#ifdef LBX
- /*
- * If the colormap is grabbed by a proxy, the server will have
- * to regain control over the colormap. This AllocColorCells request
- * will be handled after the server gets back the colormap control.
- */
- if (LbxCheckColorRequest (client, pcmp, (xReq *) stuff))
- return Success;
-#endif
- npixels = stuff->colors;
- if (!npixels)
- {
- client->errorValue = npixels;
- return (BadValue);
- }
- if (stuff->contiguous != xTrue && stuff->contiguous != xFalse)
- {
- client->errorValue = stuff->contiguous;
- return (BadValue);
- }
- nmasks = stuff->planes;
- length = ((long)npixels + (long)nmasks) * sizeof(Pixel);
- ppixels = (Pixel *)ALLOCATE_LOCAL(length);
- if(!ppixels)
- return(BadAlloc);
- pmasks = ppixels + npixels;
-
- if( (retval = AllocColorCells(client->index, pcmp, npixels, nmasks,
- (Bool)stuff->contiguous, ppixels, pmasks)) )
- {
- DEALLOCATE_LOCAL(ppixels);
- if (client->noClientException != Success)
- return(client->noClientException);
- else
- return(retval);
- }
-#ifdef PANORAMIX
- if (noPanoramiXExtension)
-#endif
- {
- accr.type = X_Reply;
- accr.length = length >> 2;
- accr.sequenceNumber = client->sequence;
- accr.nPixels = npixels;
- accr.nMasks = nmasks;
- WriteReplyToClient(client, sizeof (xAllocColorCellsReply), &accr);
- client->pSwapReplyFunc = Swap32Write;
- WriteSwappedDataToClient(client, length, ppixels);
- }
- DEALLOCATE_LOCAL(ppixels);
- return (client->noClientException);
- }
- else
- {
- client->errorValue = stuff->cmap;
- return (BadColor);
- }
-}
-
-int
-ProcAllocColorPlanes(client)
- register ClientPtr client;
-{
- ColormapPtr pcmp;
- REQUEST(xAllocColorPlanesReq);
-
- REQUEST_SIZE_MATCH(xAllocColorPlanesReq);
- pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap,
- RT_COLORMAP, SecurityWriteAccess);
- if (pcmp)
- {
- xAllocColorPlanesReply acpr;
- int npixels, retval;
- long length;
- Pixel *ppixels;
-
-#ifdef LBX
- /*
- * If the colormap is grabbed by a proxy, the server will have
- * to regain control over the colormap. This AllocColorPlanes request
- * will be handled after the server gets back the colormap control.
- */
- if (LbxCheckColorRequest (client, pcmp, (xReq *) stuff))
- return Success;
-#endif
- npixels = stuff->colors;
- if (!npixels)
- {
- client->errorValue = npixels;
- return (BadValue);
- }
- if (stuff->contiguous != xTrue && stuff->contiguous != xFalse)
- {
- client->errorValue = stuff->contiguous;
- return (BadValue);
- }
- acpr.type = X_Reply;
- acpr.sequenceNumber = client->sequence;
- acpr.nPixels = npixels;
- length = (long)npixels * sizeof(Pixel);
- ppixels = (Pixel *)ALLOCATE_LOCAL(length);
- if(!ppixels)
- return(BadAlloc);
- if( (retval = AllocColorPlanes(client->index, pcmp, npixels,
- (int)stuff->red, (int)stuff->green, (int)stuff->blue,
- (Bool)stuff->contiguous, ppixels,
- &acpr.redMask, &acpr.greenMask, &acpr.blueMask)) )
- {
- DEALLOCATE_LOCAL(ppixels);
- if (client->noClientException != Success)
- return(client->noClientException);
- else
- return(retval);
- }
- acpr.length = length >> 2;
- WriteReplyToClient(client, sizeof(xAllocColorPlanesReply), &acpr);
- client->pSwapReplyFunc = Swap32Write;
- WriteSwappedDataToClient(client, length, ppixels);
- DEALLOCATE_LOCAL(ppixels);
- return (client->noClientException);
- }
- else
- {
- client->errorValue = stuff->cmap;
- return (BadColor);
- }
-}
-
-int
-ProcFreeColors (client)
- register ClientPtr client;
-{
- ColormapPtr pcmp;
- REQUEST(xFreeColorsReq);
-
- REQUEST_AT_LEAST_SIZE(xFreeColorsReq);
- pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap,
- RT_COLORMAP, SecurityWriteAccess);
- if (pcmp)
- {
- int count;
- int retval;
-
- if(pcmp->flags & AllAllocated)
- return(BadAccess);
- count = ((client->req_len << 2)- sizeof(xFreeColorsReq)) >> 2;
- retval = FreeColors(pcmp, client->index, count,
- (Pixel *)&stuff[1], (Pixel)stuff->planeMask);
- if (client->noClientException != Success)
- return(client->noClientException);
- else
- {
- client->errorValue = clientErrorValue;
- return(retval);
- }
-
- }
- else
- {
- client->errorValue = stuff->cmap;
- return (BadColor);
- }
-}
-
-int
-ProcStoreColors (client)
- register ClientPtr client;
-{
- ColormapPtr pcmp;
- REQUEST(xStoreColorsReq);
-
- REQUEST_AT_LEAST_SIZE(xStoreColorsReq);
- pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap,
- RT_COLORMAP, SecurityWriteAccess);
- if (pcmp)
- {
- int count;
- int retval;
-
- count = (client->req_len << 2) - sizeof(xStoreColorsReq);
- if (count % sizeof(xColorItem))
- return(BadLength);
- count /= sizeof(xColorItem);
- retval = StoreColors(pcmp, count, (xColorItem *)&stuff[1]);
- if (client->noClientException != Success)
- return(client->noClientException);
- else
- {
- client->errorValue = clientErrorValue;
- return(retval);
- }
- }
- else
- {
- client->errorValue = stuff->cmap;
- return (BadColor);
- }
-}
-
-int
-ProcStoreNamedColor (client)
- register ClientPtr client;
-{
- ColormapPtr pcmp;
- REQUEST(xStoreNamedColorReq);
-
- REQUEST_FIXED_SIZE(xStoreNamedColorReq, stuff->nbytes);
- pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap,
- RT_COLORMAP, SecurityWriteAccess);
- if (pcmp)
- {
- xColorItem def;
- int retval;
-
- if(OsLookupColor(pcmp->pScreen->myNum, (char *)&stuff[1],
- stuff->nbytes, &def.red, &def.green, &def.blue))
- {
- def.flags = stuff->flags;
- def.pixel = stuff->pixel;
- retval = StoreColors(pcmp, 1, &def);
- if (client->noClientException != Success)
- return(client->noClientException);
- else
- return(retval);
- }
- return (BadName);
- }
- else
- {
- client->errorValue = stuff->cmap;
- return (BadColor);
- }
-}
-
-int
-ProcQueryColors(client)
- register ClientPtr client;
-{
- ColormapPtr pcmp;
- REQUEST(xQueryColorsReq);
-
- REQUEST_AT_LEAST_SIZE(xQueryColorsReq);
- pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap,
- RT_COLORMAP, SecurityReadAccess);
- if (pcmp)
- {
- int count, retval;
- xrgb *prgbs;
- xQueryColorsReply qcr;
-
- count = ((client->req_len << 2) - sizeof(xQueryColorsReq)) >> 2;
- prgbs = (xrgb *)ALLOCATE_LOCAL(count * sizeof(xrgb));
- if(!prgbs && count)
- return(BadAlloc);
- if( (retval = QueryColors(pcmp, count, (Pixel *)&stuff[1], prgbs)) )
- {
- if (prgbs) DEALLOCATE_LOCAL(prgbs);
- if (client->noClientException != Success)
- return(client->noClientException);
- else
- {
- client->errorValue = clientErrorValue;
- return (retval);
- }
- }
- qcr.type = X_Reply;
- qcr.length = (count * sizeof(xrgb)) >> 2;
- qcr.sequenceNumber = client->sequence;
- qcr.nColors = count;
- WriteReplyToClient(client, sizeof(xQueryColorsReply), &qcr);
- if (count)
- {
- client->pSwapReplyFunc = SQColorsExtend;
- WriteSwappedDataToClient(client, count * sizeof(xrgb), prgbs);
- }
- if (prgbs) DEALLOCATE_LOCAL(prgbs);
- return(client->noClientException);
-
- }
- else
- {
- client->errorValue = stuff->cmap;
- return (BadColor);
- }
-}
-
-int
-ProcLookupColor(client)
- register ClientPtr client;
-{
- ColormapPtr pcmp;
- REQUEST(xLookupColorReq);
-
- REQUEST_FIXED_SIZE(xLookupColorReq, stuff->nbytes);
- pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap,
- RT_COLORMAP, SecurityReadAccess);
- if (pcmp)
- {
- xLookupColorReply lcr;
-
- if(OsLookupColor(pcmp->pScreen->myNum, (char *)&stuff[1], stuff->nbytes,
- &lcr.exactRed, &lcr.exactGreen, &lcr.exactBlue))
- {
- lcr.type = X_Reply;
- lcr.length = 0;
- lcr.sequenceNumber = client->sequence;
- lcr.screenRed = lcr.exactRed;
- lcr.screenGreen = lcr.exactGreen;
- lcr.screenBlue = lcr.exactBlue;
- (*pcmp->pScreen->ResolveColor)(&lcr.screenRed,
- &lcr.screenGreen,
- &lcr.screenBlue,
- pcmp->pVisual);
- WriteReplyToClient(client, sizeof(xLookupColorReply), &lcr);
- return(client->noClientException);
- }
- return (BadName);
- }
- else
- {
- client->errorValue = stuff->cmap;
- return (BadColor);
- }
-}
-
-int
-ProcCreateCursor( client)
- register ClientPtr client;
-{
- CursorPtr pCursor;
-
- register PixmapPtr src;
- register PixmapPtr msk;
- unsigned char * srcbits;
- unsigned char * mskbits;
- unsigned short width, height;
- long n;
- CursorMetricRec cm;
-
-
- REQUEST(xCreateCursorReq);
-
- REQUEST_SIZE_MATCH(xCreateCursorReq);
- LEGAL_NEW_RESOURCE(stuff->cid, client);
-
- src = (PixmapPtr)SecurityLookupIDByType(client, stuff->source,
- RT_PIXMAP, SecurityReadAccess);
- msk = (PixmapPtr)SecurityLookupIDByType(client, stuff->mask,
- RT_PIXMAP, SecurityReadAccess);
- if ( src == (PixmapPtr)NULL)
- {
- client->errorValue = stuff->source;
- return (BadPixmap);
- }
- if ( msk == (PixmapPtr)NULL)
- {
- if (stuff->mask != None)
- {
- client->errorValue = stuff->mask;
- return (BadPixmap);
- }
- }
- else if ( src->drawable.width != msk->drawable.width
- || src->drawable.height != msk->drawable.height
- || src->drawable.depth != 1
- || msk->drawable.depth != 1)
- return (BadMatch);
-
- width = src->drawable.width;
- height = src->drawable.height;
-
- if ( stuff->x > width
- || stuff->y > height )
- return (BadMatch);
-
- n = BitmapBytePad(width)*height;
- srcbits = (unsigned char *)xalloc(n);
- if (!srcbits)
- return (BadAlloc);
- mskbits = (unsigned char *)xalloc(n);
- if (!mskbits)
- {
- xfree(srcbits);
- return (BadAlloc);
- }
-
- /* zeroing the (pad) bits helps some ddx cursor handling */
- bzero((char *)srcbits, n);
- (* src->drawable.pScreen->GetImage)( (DrawablePtr)src, 0, 0, width, height,
- XYPixmap, 1, (pointer)srcbits);
- if ( msk == (PixmapPtr)NULL)
- {
- register unsigned char *bits = mskbits;
- while (--n >= 0)
- *bits++ = ~0;
- }
- else
- {
- /* zeroing the (pad) bits helps some ddx cursor handling */
- bzero((char *)mskbits, n);
- (* msk->drawable.pScreen->GetImage)( (DrawablePtr)msk, 0, 0, width,
- height, XYPixmap, 1, (pointer)mskbits);
- }
- cm.width = width;
- cm.height = height;
- cm.xhot = stuff->x;
- cm.yhot = stuff->y;
- pCursor = AllocCursor( srcbits, mskbits, &cm,
- stuff->foreRed, stuff->foreGreen, stuff->foreBlue,
- stuff->backRed, stuff->backGreen, stuff->backBlue);
-
- if (pCursor && AddResource(stuff->cid, RT_CURSOR, (pointer)pCursor))
- return (client->noClientException);
- return BadAlloc;
-}
-
-int
-ProcCreateGlyphCursor( client)
- register ClientPtr client;
-{
- CursorPtr pCursor;
- int res;
-
- REQUEST(xCreateGlyphCursorReq);
-
- REQUEST_SIZE_MATCH(xCreateGlyphCursorReq);
- LEGAL_NEW_RESOURCE(stuff->cid, client);
-
- res = AllocGlyphCursor(stuff->source, stuff->sourceChar,
- stuff->mask, stuff->maskChar,
- stuff->foreRed, stuff->foreGreen, stuff->foreBlue,
- stuff->backRed, stuff->backGreen, stuff->backBlue,
- &pCursor, client);
- if (res != Success)
- return res;
- if (AddResource(stuff->cid, RT_CURSOR, (pointer)pCursor))
- return client->noClientException;
- return BadAlloc;
-}
-
-
-int
-ProcFreeCursor(client)
- register ClientPtr client;
-{
- CursorPtr pCursor;
- REQUEST(xResourceReq);
-
- REQUEST_SIZE_MATCH(xResourceReq);
- pCursor = (CursorPtr)SecurityLookupIDByType(client, stuff->id,
- RT_CURSOR, SecurityDestroyAccess);
- if (pCursor)
- {
- FreeResource(stuff->id, RT_NONE);
- return (client->noClientException);
- }
- else
- {
- client->errorValue = stuff->id;
- return (BadCursor);
- }
-}
-
-int
-ProcQueryBestSize (client)
- register ClientPtr client;
-{
- xQueryBestSizeReply reply;
- register DrawablePtr pDraw;
- ScreenPtr pScreen;
- REQUEST(xQueryBestSizeReq);
-
- REQUEST_SIZE_MATCH(xQueryBestSizeReq);
- if ((stuff->class != CursorShape) &&
- (stuff->class != TileShape) &&
- (stuff->class != StippleShape))
- {
- client->errorValue = stuff->class;
- return(BadValue);
- }
- SECURITY_VERIFY_GEOMETRABLE (pDraw, stuff->drawable, client,
- SecurityReadAccess);
- if (stuff->class != CursorShape && pDraw->type == UNDRAWABLE_WINDOW)
- return (BadMatch);
- pScreen = pDraw->pScreen;
- (* pScreen->QueryBestSize)(stuff->class, &stuff->width,
- &stuff->height, pScreen);
- reply.type = X_Reply;
- reply.length = 0;
- reply.sequenceNumber = client->sequence;
- reply.width = stuff->width;
- reply.height = stuff->height;
- WriteReplyToClient(client, sizeof(xQueryBestSizeReply), &reply);
- return (client->noClientException);
-}
-
-
-int
-ProcSetScreenSaver (client)
- register ClientPtr client;
-{
- int blankingOption, exposureOption;
- REQUEST(xSetScreenSaverReq);
-
- REQUEST_SIZE_MATCH(xSetScreenSaverReq);
- blankingOption = stuff->preferBlank;
- if ((blankingOption != DontPreferBlanking) &&
- (blankingOption != PreferBlanking) &&
- (blankingOption != DefaultBlanking))
- {
- client->errorValue = blankingOption;
- return BadValue;
- }
- exposureOption = stuff->allowExpose;
- if ((exposureOption != DontAllowExposures) &&
- (exposureOption != AllowExposures) &&
- (exposureOption != DefaultExposures))
- {
- client->errorValue = exposureOption;
- return BadValue;
- }
- if (stuff->timeout < -1)
- {
- client->errorValue = stuff->timeout;
- return BadValue;
- }
- if (stuff->interval < -1)
- {
- client->errorValue = stuff->interval;
- return BadValue;
- }
-
- if (blankingOption == DefaultBlanking)
- ScreenSaverBlanking = defaultScreenSaverBlanking;
- else
- ScreenSaverBlanking = blankingOption;
- if (exposureOption == DefaultExposures)
- ScreenSaverAllowExposures = defaultScreenSaverAllowExposures;
- else
- ScreenSaverAllowExposures = exposureOption;
-
- if (stuff->timeout >= 0)
- ScreenSaverTime = stuff->timeout * MILLI_PER_SECOND;
- else
- ScreenSaverTime = defaultScreenSaverTime;
- if (stuff->interval >= 0)
- ScreenSaverInterval = stuff->interval * MILLI_PER_SECOND;
- else
- ScreenSaverInterval = defaultScreenSaverInterval;
- return (client->noClientException);
-}
-
-int
-ProcGetScreenSaver(client)
- register ClientPtr client;
-{
- REQUEST(xReq);
- xGetScreenSaverReply rep;
-
- REQUEST_SIZE_MATCH(xReq);
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.timeout = ScreenSaverTime / MILLI_PER_SECOND;
- rep.interval = ScreenSaverInterval / MILLI_PER_SECOND;
- rep.preferBlanking = ScreenSaverBlanking;
- rep.allowExposures = ScreenSaverAllowExposures;
- WriteReplyToClient(client, sizeof(xGetScreenSaverReply), &rep);
- return (client->noClientException);
-}
-
-int
-ProcChangeHosts(client)
- register ClientPtr client;
-{
- REQUEST(xChangeHostsReq);
- int result;
-
- REQUEST_FIXED_SIZE(xChangeHostsReq, stuff->hostLength);
-
- if(stuff->mode == HostInsert)
- result = AddHost(client, (int)stuff->hostFamily,
- stuff->hostLength, (pointer)&stuff[1]);
- else if (stuff->mode == HostDelete)
- result = RemoveHost(client, (int)stuff->hostFamily,
- stuff->hostLength, (pointer)&stuff[1]);
- else
- {
- client->errorValue = stuff->mode;
- return BadValue;
- }
- if (!result)
- result = client->noClientException;
- return (result);
-}
-
-int
-ProcListHosts(client)
- register ClientPtr client;
-{
-extern int GetHosts();
- xListHostsReply reply;
- int len, nHosts, result;
- pointer pdata;
- REQUEST(xListHostsReq);
-
- REQUEST_SIZE_MATCH(xListHostsReq);
-#ifdef XCSECURITY
- /* untrusted clients can't list hosts */
- if (client->trustLevel != XSecurityClientTrusted)
- {
- SecurityAudit("client %d attempted to list hosts\n", client->index);
- return BadAccess;
- }
-#endif
- result = GetHosts(&pdata, &nHosts, &len, &reply.enabled);
- if (result != Success)
- return(result);
- reply.type = X_Reply;
- reply.sequenceNumber = client->sequence;
- reply.nHosts = nHosts;
- reply.length = len >> 2;
- WriteReplyToClient(client, sizeof(xListHostsReply), &reply);
- if (nHosts)
- {
- client->pSwapReplyFunc = SLHostsExtend;
- WriteSwappedDataToClient(client, len, pdata);
- }
- xfree(pdata);
- return (client->noClientException);
-}
-
-int
-ProcChangeAccessControl(client)
- register ClientPtr client;
-{
- int result;
- REQUEST(xSetAccessControlReq);
-
- REQUEST_SIZE_MATCH(xSetAccessControlReq);
- if ((stuff->mode != EnableAccess) && (stuff->mode != DisableAccess))
- {
- client->errorValue = stuff->mode;
- return BadValue;
- }
- result = ChangeAccessControl(client, stuff->mode == EnableAccess);
- if (!result)
- result = client->noClientException;
- return (result);
-}
-
-int
-ProcKillClient(client)
- register ClientPtr client;
-{
- REQUEST(xResourceReq);
- ClientPtr killclient;
-
- REQUEST_SIZE_MATCH(xResourceReq);
- if (stuff->id == AllTemporary)
- {
- CloseDownRetainedResources();
- return (client->noClientException);
- }
-
- if ((killclient = LookupClient(stuff->id, client)))
- {
- CloseDownClient(killclient);
- /* if an LBX proxy gets killed, isItTimeToYield will be set */
- if (isItTimeToYield || (client == killclient))
- {
- /* force yield and return Success, so that Dispatch()
- * doesn't try to touch client
- */
- isItTimeToYield = TRUE;
- return (Success);
- }
- return (client->noClientException);
- }
- else
- {
- client->errorValue = stuff->id;
- return (BadValue);
- }
-}
-
-int
-ProcSetFontPath(client)
- register ClientPtr client;
-{
- unsigned char *ptr;
- unsigned long nbytes, total;
- long nfonts;
- int n, result;
- int error;
- REQUEST(xSetFontPathReq);
-
- REQUEST_AT_LEAST_SIZE(xSetFontPathReq);
-
- nbytes = (client->req_len << 2) - sizeof(xSetFontPathReq);
- total = nbytes;
- ptr = (unsigned char *)&stuff[1];
- nfonts = stuff->nFonts;
- while (--nfonts >= 0)
- {
- if ((total == 0) || (total < (n = (*ptr + 1))))
- return(BadLength);
- total -= n;
- ptr += n;
- }
- if (total >= 4)
- return(BadLength);
- result = SetFontPath(client, stuff->nFonts, (unsigned char *)&stuff[1],
- &error);
- if (!result)
- {
- result = client->noClientException;
- client->errorValue = error;
- }
- return (result);
-}
-
-int
-ProcGetFontPath(client)
- register ClientPtr client;
-{
- xGetFontPathReply reply;
- int stringLens, numpaths;
- unsigned char *bufferStart;
- REQUEST (xReq);
-
- REQUEST_SIZE_MATCH(xReq);
- bufferStart = GetFontPath(&numpaths, &stringLens);
-
- reply.type = X_Reply;
- reply.sequenceNumber = client->sequence;
- reply.length = (stringLens + numpaths + 3) >> 2;
- reply.nPaths = numpaths;
-
- WriteReplyToClient(client, sizeof(xGetFontPathReply), &reply);
- if (stringLens || numpaths)
- (void)WriteToClient(client, stringLens + numpaths, (char *)bufferStart);
- return(client->noClientException);
-}
-
-int
-ProcChangeCloseDownMode(client)
- register ClientPtr client;
-{
- REQUEST(xSetCloseDownModeReq);
-
- REQUEST_SIZE_MATCH(xSetCloseDownModeReq);
- if ((stuff->mode == AllTemporary) ||
- (stuff->mode == RetainPermanent) ||
- (stuff->mode == RetainTemporary))
- {
- client->closeDownMode = stuff->mode;
- return (client->noClientException);
- }
- else
- {
- client->errorValue = stuff->mode;
- return (BadValue);
- }
-}
-
-int ProcForceScreenSaver(client)
- register ClientPtr client;
-{
- REQUEST(xForceScreenSaverReq);
-
- REQUEST_SIZE_MATCH(xForceScreenSaverReq);
-
- if ((stuff->mode != ScreenSaverReset) &&
- (stuff->mode != ScreenSaverActive))
- {
- client->errorValue = stuff->mode;
- return BadValue;
- }
- SaveScreens(SCREEN_SAVER_FORCER, (int)stuff->mode);
- return client->noClientException;
-}
-
-int ProcNoOperation(client)
- register ClientPtr client;
-{
- REQUEST(xReq);
-
- REQUEST_AT_LEAST_SIZE(xReq);
-
- /* noop -- don't do anything */
- return(client->noClientException);
-}
-
-void
-InitProcVectors()
-{
- int i;
- for (i = 0; i<256; i++)
- {
- if(!ProcVector[i])
- {
- ProcVector[i] = SwappedProcVector[i] = ProcBadRequest;
- ReplySwapVector[i] = NotImplemented;
- }
-#ifdef K5AUTH
- if (!k5_Vector[i])
- {
- k5_Vector[i] = k5_bad;
- }
-#endif
- }
- for(i = LASTEvent; i < 128; i++)
- {
- EventSwapVector[i] = NotImplemented;
- }
-
-}
-
-/**********************
- * CloseDownClient
- *
- * Client can either mark his resources destroy or retain. If retained and
- * then killed again, the client is really destroyed.
- *********************/
-
-Bool terminateAtReset = FALSE;
-
-void
-CloseDownClient(client)
- register ClientPtr client;
-{
-#ifdef PANORAMIX
- PanoramiXGC *pPanoramiXFreeGC;
- PanoramiXGC *pPanoramiXFreeGCback = NULL;
- PanoramiXWindow *pPanoramiXFreeWin;
- PanoramiXWindow *pPanoramiXFreeWinback = NULL;
- PanoramiXCmap *pPanoramiXFreeCmap;
- PanoramiXCmap *pPanoramiXFreeCmapback = NULL;
- PanoramiXPmap *pPanoramiXFreePmap;
- PanoramiXPmap *pPanoramiXFreePmapback = NULL;
-#endif
- Bool really_close_down = client->clientGone ||
- client->closeDownMode == DestroyAll;
-
- if (!client->clientGone)
- {
- /* ungrab server if grabbing client dies */
- if (grabState != GrabNone && grabClient == client)
- {
- UngrabServer(client);
- }
- BITCLEAR(grabWaiters, client->index);
- DeleteClientFromAnySelections(client);
- ReleaseActiveGrabs(client);
- DeleteClientFontStuff(client);
- if (!really_close_down)
- {
- /* This frees resources that should never be retained
- * no matter what the close down mode is. Actually we
- * could do this unconditionally, but it's probably
- * better not to traverse all the client's resources
- * twice (once here, once a few lines down in
- * FreeClientResources) in the common case of
- * really_close_down == TRUE.
- */
- FreeClientNeverRetainResources(client);
- client->clientState = ClientStateRetained;
- if (ClientStateCallback)
- {
- NewClientInfoRec clientinfo;
-
- clientinfo.client = client;
- clientinfo.prefix = (xConnSetupPrefix *)NULL;
- clientinfo.setup = (xConnSetup *) NULL;
- CallCallbacks((&ClientStateCallback), (pointer)&clientinfo);
- }
- }
- client->clientGone = TRUE; /* so events aren't sent to client */
- if (ClientIsAsleep(client))
- ClientSignal (client);
- ProcessWorkQueueZombies();
-#ifdef LBX
- ProcessQTagZombies();
-#endif
- CloseDownConnection(client);
-
- /* If the client made it to the Running stage, nClients has
- * been incremented on its behalf, so we need to decrement it
- * now. If it hasn't gotten to Running, nClients has *not*
- * been incremented, so *don't* decrement it.
- */
- if (client->clientState != ClientStateInitial &&
- client->clientState != ClientStateAuthenticating )
- {
- --nClients;
- }
- }
-
- if (really_close_down)
- {
- if (client->clientState == ClientStateRunning && nClients == 0)
- {
- if (terminateAtReset)
- dispatchException |= DE_TERMINATE;
- else
- dispatchException |= DE_RESET;
- }
- client->clientState = ClientStateGone;
- if (ClientStateCallback)
- {
- NewClientInfoRec clientinfo;
-
- clientinfo.client = client;
- clientinfo.prefix = (xConnSetupPrefix *)NULL;
- clientinfo.setup = (xConnSetup *) NULL;
- CallCallbacks((&ClientStateCallback), (pointer)&clientinfo);
- }
- FreeClientResources(client);
-#ifdef PANORAMIX
- PANORAMIX_FREE(client);
-#endif
- if (client->index < nextFreeClientID)
- nextFreeClientID = client->index;
- clients[client->index] = NullClient;
- xfree(client);
-
- while (!clients[currentMaxClients-1])
- currentMaxClients--;
- }
-}
-
-static void
-KillAllClients()
-{
- int i;
- for (i=1; i<currentMaxClients; i++)
- if (clients[i])
- CloseDownClient(clients[i]);
-}
-
-/*********************
- * CloseDownRetainedResources
- *
- * Find all clients that are gone and have terminated in RetainTemporary
- * and destroy their resources.
- *********************/
-
-void
-CloseDownRetainedResources()
-{
- register int i;
- register ClientPtr client;
-
- for (i=1; i<currentMaxClients; i++)
- {
- client = clients[i];
- if (client && (client->closeDownMode == RetainTemporary)
- && (client->clientGone))
- CloseDownClient(client);
- }
-}
-
-void InitClient(client, i, ospriv)
- ClientPtr client;
- int i;
- pointer ospriv;
-{
- client->index = i;
- client->sequence = 0;
- client->clientAsMask = ((Mask)i) << CLIENTOFFSET;
- client->clientGone = FALSE;
- if (i)
- {
- client->closeDownMode = DestroyAll;
- client->lastDrawable = (DrawablePtr)WindowTable[0];
- client->lastDrawableID = WindowTable[0]->drawable.id;
- }
- else
- {
- client->closeDownMode = RetainPermanent;
- client->lastDrawable = (DrawablePtr)NULL;
- client->lastDrawableID = INVALID;
- }
- client->lastGC = (GCPtr) NULL;
- client->lastGCID = INVALID;
- client->numSaved = 0;
- client->saveSet = (pointer *)NULL;
- client->noClientException = Success;
-#ifdef DEBUG
- client->requestLogIndex = 0;
-#endif
- client->requestVector = InitialVector;
- client->osPrivate = ospriv;
- client->swapped = FALSE;
- client->big_requests = FALSE;
- client->priority = 0;
- client->clientState = ClientStateInitial;
-#ifdef XKB
- if (!noXkbExtension) {
- client->xkbClientFlags = 0;
- client->mapNotifyMask = 0;
- QueryMinMaxKeyCodes(&client->minKC,&client->maxKC);
- }
-#endif
- client->replyBytesRemaining = 0;
-#ifdef LBX
- client->readRequest = StandardReadRequestFromClient;
-#endif
-#ifdef XCSECURITY
- client->trustLevel = XSecurityClientTrusted;
- client->CheckAccess = NULL;
- client->authId = 0;
-#endif
-#ifdef XAPPGROUP
- client->appgroup = NULL;
-#endif
- client->fontResFunc = NULL;
-}
-
-extern int clientPrivateLen;
-extern unsigned *clientPrivateSizes;
-extern unsigned totalClientSize;
-
-int
-InitClientPrivates(client)
- ClientPtr client;
-{
- register char *ptr;
- DevUnion *ppriv;
- register unsigned *sizes;
- register unsigned size;
- register int i;
-
- if (totalClientSize == sizeof(ClientRec))
- ppriv = (DevUnion *)NULL;
- else if (client->index)
- ppriv = (DevUnion *)(client + 1);
- else
- {
- ppriv = (DevUnion *)xalloc(totalClientSize - sizeof(ClientRec));
- if (!ppriv)
- return 0;
- }
- client->devPrivates = ppriv;
- sizes = clientPrivateSizes;
- ptr = (char *)(ppriv + clientPrivateLen);
- for (i = clientPrivateLen; --i >= 0; ppriv++, sizes++)
- {
- if ( (size = *sizes) )
- {
- ppriv->ptr = (pointer)ptr;
- ptr += size;
- }
- else
- ppriv->ptr = (pointer)NULL;
- }
- return 1;
-}
-
-/************************
- * int NextAvailableClient(ospriv)
- *
- * OS dependent portion can't assign client id's because of CloseDownModes.
- * Returns NULL if there are no free clients.
- *************************/
-
-ClientPtr
-NextAvailableClient(ospriv)
- pointer ospriv;
-{
- register int i;
- register ClientPtr client;
- xReq data;
-#ifdef PANORAMIX
- PanoramiXGC *pPanoramiXFreeGC;
- PanoramiXGC *pPanoramiXFreeGCback = NULL;
- PanoramiXWindow *pPanoramiXFreeWin;
- PanoramiXWindow *pPanoramiXFreeWinback = NULL;
- PanoramiXCmap *pPanoramiXFreeCmap;
- PanoramiXCmap *pPanoramiXFreeCmapback = NULL;
- PanoramiXPmap *pPanoramiXFreePmap;
- PanoramiXPmap *pPanoramiXFreePmapback = NULL;
-#endif
-
- i = nextFreeClientID;
- if (i == MAXCLIENTS)
- return (ClientPtr)NULL;
- clients[i] = client = (ClientPtr)xalloc(totalClientSize);
- if (!client)
- return (ClientPtr)NULL;
- InitClient(client, i, ospriv);
- InitClientPrivates(client);
- if (!InitClientResources(client))
- {
- xfree(client);
- return (ClientPtr)NULL;
- }
- data.reqType = 1;
- data.length = (sz_xReq + sz_xConnClientPrefix) >> 2;
- if (!InsertFakeRequest(client, (char *)&data, sz_xReq))
- {
- FreeClientResources(client);
-#ifdef PANORAMIX
- PANORAMIX_FREE(client);
-#endif
- xfree(client);
- return (ClientPtr)NULL;
- }
- if (i == currentMaxClients)
- currentMaxClients++;
- while ((nextFreeClientID < MAXCLIENTS) && clients[nextFreeClientID])
- nextFreeClientID++;
- if (ClientStateCallback)
- {
- NewClientInfoRec clientinfo;
-
- clientinfo.client = client;
- clientinfo.prefix = (xConnSetupPrefix *)NULL;
- clientinfo.setup = (xConnSetup *) NULL;
- CallCallbacks((&ClientStateCallback), (pointer)&clientinfo);
- }
- return(client);
-}
-
-int
-ProcInitialConnection(client)
- register ClientPtr client;
-{
- REQUEST(xReq);
- register xConnClientPrefix *prefix;
- int whichbyte = 1;
-
- prefix = (xConnClientPrefix *)((char *)stuff + sz_xReq);
- if ((prefix->byteOrder != 'l') && (prefix->byteOrder != 'B'))
- return (client->noClientException = -1);
- if (((*(char *) &whichbyte) && (prefix->byteOrder == 'B')) ||
- (!(*(char *) &whichbyte) && (prefix->byteOrder == 'l')))
- {
- client->swapped = TRUE;
- SwapConnClientPrefix(prefix);
- }
- stuff->reqType = 2;
- stuff->length += ((prefix->nbytesAuthProto + (unsigned)3) >> 2) +
- ((prefix->nbytesAuthString + (unsigned)3) >> 2);
- if (client->swapped)
- {
- swaps(&stuff->length, whichbyte);
- }
- ResetCurrentRequest(client);
- return (client->noClientException);
-}
-
-#ifdef LBX
-void
-IncrementClientCount()
-{
- nClients++;
-}
-#endif
-
-int
-SendConnSetup(client, reason)
- register ClientPtr client;
- char *reason;
-{
- register xWindowRoot *root;
- register int i;
- int numScreens;
- char* lConnectionInfo;
- xConnSetupPrefix* lconnSetupPrefix;
-
- if (reason)
- {
- xConnSetupPrefix csp;
- char pad[3];
-
- csp.success = xFalse;
- csp.lengthReason = strlen(reason);
- csp.length = (csp.lengthReason + (unsigned)3) >> 2;
- csp.majorVersion = X_PROTOCOL;
- csp.minorVersion = X_PROTOCOL_REVISION;
- if (client->swapped)
- WriteSConnSetupPrefix(client, &csp);
- else
- (void)WriteToClient(client, sz_xConnSetupPrefix, (char *) &csp);
- (void)WriteToClient(client, (int)csp.lengthReason, reason);
- return (client->noClientException = -1);
- }
-
- numScreens = screenInfo.numScreens;
- lConnectionInfo = ConnectionInfo;
- lconnSetupPrefix = &connSetupPrefix;
-
- /* We're about to start speaking X protocol back to the client by
- * sending the connection setup info. This means the authorization
- * step is complete, and we can count the client as an
- * authorized one.
- */
- nClients++;
-
- client->requestVector = client->swapped ? SwappedProcVector : ProcVector;
- client->sequence = 0;
-#ifdef XAPPGROUP
- XagConnectionInfo (client, &lconnSetupPrefix, &lConnectionInfo, &numScreens);
-#endif
- ((xConnSetup *)lConnectionInfo)->ridBase = client->clientAsMask;
- ((xConnSetup *)lConnectionInfo)->ridMask = RESOURCE_ID_MASK;
- /* fill in the "currentInputMask" */
- root = (xWindowRoot *)(lConnectionInfo + connBlockScreenStart);
-#ifdef PANORAMIX
- if (noPanoramiXExtension)
- numScreens = screenInfo.numScreens;
- else
- numScreens = ((xConnSetup *)ConnectionInfo)->numRoots;
-#endif
-
- for (i=0; i<numScreens; i++)
- {
- register unsigned int j;
- register xDepth *pDepth;
-
- root->currentInputMask = WindowTable[i]->eventMask |
- wOtherEventMasks (WindowTable[i]);
- pDepth = (xDepth *)(root + 1);
- for (j = 0; j < root->nDepths; j++)
- {
- pDepth = (xDepth *)(((char *)(pDepth + 1)) +
- pDepth->nVisuals * sizeof(xVisualType));
- }
- root = (xWindowRoot *)pDepth;
- }
-
- if (client->swapped)
- {
- WriteSConnSetupPrefix(client, lconnSetupPrefix);
- WriteSConnectionInfo(client,
- (unsigned long)(lconnSetupPrefix->length << 2),
- lConnectionInfo);
- }
- else
- {
- (void)WriteToClient(client, sizeof(xConnSetupPrefix),
- (char *) lconnSetupPrefix);
- (void)WriteToClient(client, (int)(lconnSetupPrefix->length << 2),
- lConnectionInfo);
- }
- client->clientState = ClientStateRunning;
- if (ClientStateCallback)
- {
- NewClientInfoRec clientinfo;
-
- clientinfo.client = client;
- clientinfo.prefix = lconnSetupPrefix;
- clientinfo.setup = (xConnSetup *)lConnectionInfo;
- CallCallbacks((&ClientStateCallback), (pointer)&clientinfo);
- }
- return (client->noClientException);
-}
-
-int
-ProcEstablishConnection(client)
- register ClientPtr client;
-{
- char *reason, *auth_proto, *auth_string;
- register xConnClientPrefix *prefix;
- REQUEST(xReq);
-
- prefix = (xConnClientPrefix *)((char *)stuff + sz_xReq);
- auth_proto = (char *)prefix + sz_xConnClientPrefix;
- auth_string = auth_proto + ((prefix->nbytesAuthProto + 3) & ~3);
- if ((prefix->majorVersion != X_PROTOCOL) ||
- (prefix->minorVersion != X_PROTOCOL_REVISION))
- reason = "Protocol version mismatch";
- else
- reason = ClientAuthorized(client,
- (unsigned short)prefix->nbytesAuthProto,
- auth_proto,
- (unsigned short)prefix->nbytesAuthString,
- auth_string);
- /*
- * If Kerberos is being used for this client, the clientState
- * will be set to ClientStateAuthenticating at this point.
- * More messages need to be exchanged among the X server, Kerberos
- * server, and client to figure out if everyone is authorized.
- * So we don't want to send the connection setup info yet, since
- * the auth step isn't really done.
- */
- if (client->clientState == ClientStateCheckingSecurity)
- client->clientState = ClientStateCheckedSecurity;
- else if (client->clientState != ClientStateAuthenticating)
- return(SendConnSetup(client, reason));
- return(client->noClientException);
-}
-
-void
-SendErrorToClient(client, majorCode, minorCode, resId, errorCode)
- ClientPtr client;
- unsigned int majorCode;
- unsigned int minorCode;
- XID resId;
- int errorCode;
-{
- xError rep;
-
- rep.type = X_Error;
- rep.sequenceNumber = client->sequence;
- rep.errorCode = errorCode;
- rep.majorCode = majorCode;
- rep.minorCode = minorCode;
- rep.resourceID = resId;
-
- WriteEventsToClient (client, 1, (xEvent *)&rep);
-}
-
-void
-DeleteWindowFromAnySelections(pWin)
- WindowPtr pWin;
-{
- register int i;
-
- for (i = 0; i< NumCurrentSelections; i++)
- if (CurrentSelections[i].pWin == pWin)
- {
- CurrentSelections[i].pWin = (WindowPtr)NULL;
- CurrentSelections[i].window = None;
- CurrentSelections[i].client = NullClient;
- }
-}
-
-static void
-DeleteClientFromAnySelections(client)
- ClientPtr client;
-{
- register int i;
-
- for (i = 0; i< NumCurrentSelections; i++)
- if (CurrentSelections[i].client == client)
- {
- CurrentSelections[i].pWin = (WindowPtr)NULL;
- CurrentSelections[i].window = None;
- CurrentSelections[i].client = NullClient;
- }
-}
-
-void
-MarkClientException(client)
- ClientPtr client;
-{
- client->noClientException = -1;
-}
diff --git a/programs/Xserver/pandix/dixfonts.c b/programs/Xserver/pandix/dixfonts.c
deleted file mode 100644
index fc781c2c2..000000000
--- a/programs/Xserver/pandix/dixfonts.c
+++ /dev/null
@@ -1,2142 +0,0 @@
-
-/****************************************************************
-* *
-* Copyright (c) Digital Equipment Corporation, 1991, 1997 *
-* *
-* All Rights Reserved. Unpublished rights reserved under *
-* the copyright laws of the United States. *
-* *
-* The software contained on this media is proprietary to *
-* and embodies the confidential technology of Digital *
-* Equipment Corporation. Possession, use, duplication or *
-* dissemination of the software and media is authorized only *
-* pursuant to a valid written license from Digital Equipment *
-* Corporation. *
-* *
-* RESTRICTED RIGHTS LEGEND Use, duplication, or disclosure *
-* by the U.S. Government is subject to restrictions as set *
-* forth in Subparagraph (c)(1)(ii) of DFARS 252.227-7013, *
-* or in FAR 52.227-19, as applicable. *
-* *
-*****************************************************************/
-/************************************************************************
-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.
-
-************************************************************************/
-/* $TOG: dixfonts.c /main/1 1997/10/29 13:27:11 kaleb $ */
-
-#define NEED_REPLIES
-#include "X.h"
-#include "Xmd.h"
-#include "Xproto.h"
-#include "scrnintstr.h"
-#include "resource.h"
-#include "dixstruct.h"
-#include "cursorstr.h"
-#include "misc.h"
-#include "opaque.h"
-#include "dixfontstr.h"
-#include "closestr.h"
-
-#ifdef DEBUG
-#include <stdio.h>
-#endif
-
-#ifdef PANORAMIX
-#include "panoramiX.h"
-#endif
-
-#define QUERYCHARINFO(pci, pr) *(pr) = (pci)->metrics
-
-static Mask FontFormat =
-#if IMAGE_BYTE_ORDER == LSBFirst
- BitmapFormatByteOrderLSB |
-#else
- BitmapFormatByteOrderMSB |
-#endif
-
-#if BITMAP_BIT_ORDER == LSBFirst
- BitmapFormatBitOrderLSB |
-#else
- BitmapFormatBitOrderMSB |
-#endif
-
- BitmapFormatImageRectMin |
-
-#if GLYPHPADBYTES == 1
- BitmapFormatScanlinePad8 |
-#endif
-
-#if GLYPHPADBYTES == 2
- BitmapFormatScanlinePad16 |
-#endif
-
-#if GLYPHPADBYTES == 4
- BitmapFormatScanlinePad32 |
-#endif
-
-#if GLYPHPADBYTES == 8
- BitmapFormatScanlinePad64 |
-#endif
-
- BitmapFormatScanlineUnit8;
-
-extern pointer fosNaturalParams;
-extern FontPtr defaultFont;
-
-
-#ifdef PANORAMIX
-extern Bool noPanoramiXExtension;
-#endif
-
-static FontPathElementPtr *font_path_elements = (FontPathElementPtr *) 0;
-static int num_fpes = 0;
-static FPEFunctions *fpe_functions = (FPEFunctions *) 0;
-static int num_fpe_types = 0;
-
-static unsigned char *font_path_string;
-
-static int num_slept_fpes = 0;
-static int size_slept_fpes = 0;
-static FontPathElementPtr *slept_fpes = (FontPathElementPtr *) 0;
-static FontPatternCachePtr patternCache;
-
-int
-FontToXError(err)
- int err;
-{
- switch (err) {
- case Successful:
- return Success;
- case AllocError:
- return BadAlloc;
- case BadFontName:
- case BadFontPath:
- return BadName;
- case BadFontFormat: /* is there something better? */
- case BadCharRange:
- return BadValue;
- default:
- return err;
- }
-}
-
-
-/*
- * adding RT_FONT prevents conflict with default cursor font
- */
-Bool
-SetDefaultFont(defaultfontname)
- char *defaultfontname;
-{
- int err;
- FontPtr pf;
- XID fid;
-
- fid = FakeClientID(0);
- err = OpenFont(serverClient, fid, FontLoadAll | FontOpenSync,
- (unsigned) strlen(defaultfontname), defaultfontname);
- if (err != Success)
- return FALSE;
- pf = (FontPtr) LookupIDByType(fid, RT_FONT);
- if (pf == (FontPtr) NULL)
- return FALSE;
- defaultFont = pf;
- return TRUE;
-}
-
-/*
- * note that the font wakeup queue is not refcounted. this is because
- * an fpe needs to be added when it's inited, and removed when it's finally
- * freed, in order to handle any data that isn't requested, like FS events.
- *
- * since the only thing that should call these routines is the renderer's
- * init_fpe() and free_fpe(), there shouldn't be any problem in using
- * freed data.
- */
-void
-QueueFontWakeup(fpe)
- FontPathElementPtr fpe;
-{
- int i;
- FontPathElementPtr *new;
-
- for (i = 0; i < num_slept_fpes; i++) {
- if (slept_fpes[i] == fpe) {
-
-#ifdef DEBUG
- fprintf(stderr, "re-queueing fpe wakeup\n");
-#endif
-
- return;
- }
- }
- if (num_slept_fpes == size_slept_fpes) {
- new = (FontPathElementPtr *)
- xrealloc(slept_fpes,
- sizeof(FontPathElementPtr) * (size_slept_fpes + 4));
- if (!new)
- return;
- slept_fpes = new;
- size_slept_fpes += 4;
- }
- slept_fpes[num_slept_fpes] = fpe;
- num_slept_fpes++;
-}
-
-void
-RemoveFontWakeup(fpe)
- FontPathElementPtr fpe;
-{
- int i,
- j;
-
- for (i = 0; i < num_slept_fpes; i++) {
- if (slept_fpes[i] == fpe) {
- for (j = i; j < num_slept_fpes; j++) {
- slept_fpes[j] = slept_fpes[j + 1];
- }
- num_slept_fpes--;
- return;
- }
- }
-}
-
-/* ARGSUSED */
-void
-FontWakeup(data, count, LastSelectMask)
- pointer data;
- int count;
- pointer LastSelectMask;
-{
- int i;
- FontPathElementPtr fpe;
-
- if (count < 0)
- return;
- /* wake up any fpe's that may be waiting for information */
- for (i = 0; i < num_slept_fpes; i++) {
- fpe = slept_fpes[i];
- (void) (*fpe_functions[fpe->type].wakeup_fpe) (fpe, LastSelectMask);
- }
-}
-
-/* XXX -- these two funcs may want to be broken into macros */
-static void
-UseFPE(fpe)
- FontPathElementPtr fpe;
-{
- fpe->refcount++;
-}
-
-static void
-FreeFPE (fpe)
- FontPathElementPtr fpe;
-{
- fpe->refcount--;
- if (fpe->refcount == 0) {
- (*fpe_functions[fpe->type].free_fpe) (fpe);
- xfree(fpe->name);
- xfree(fpe);
- }
-}
-
-static Bool
-doOpenFont(client, c)
- ClientPtr client;
- OFclosurePtr c;
-{
- FontPtr pfont = NullFont;
- FontPathElementPtr fpe;
- ScreenPtr pScr;
- int err = Successful;
- int i;
- char *alias,
- *newname;
- int newlen;
- int aliascount = 20;
-
- if (client->clientGone)
- {
- if (c->current_fpe < c->num_fpes)
- {
- fpe = c->fpe_list[c->current_fpe];
- (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
- }
- err = Successful;
- goto bail;
- }
- while (c->current_fpe < c->num_fpes) {
- fpe = c->fpe_list[c->current_fpe];
- err = (*fpe_functions[fpe->type].open_font)
- ((pointer) client, fpe, c->flags,
- c->fontname, c->fnamelen, FontFormat,
- BitmapFormatMaskByte |
- BitmapFormatMaskBit |
- BitmapFormatMaskImageRectangle |
- BitmapFormatMaskScanLinePad |
- BitmapFormatMaskScanLineUnit,
- c->fontid, &pfont, &alias,
- c->non_cachable_font && c->non_cachable_font->fpe == fpe ?
- c->non_cachable_font :
- (FontPtr)0);
-
- if (err == FontNameAlias && alias) {
- newlen = strlen(alias);
- newname = (char *) xrealloc(c->fontname, newlen);
- if (!newname) {
- err = AllocError;
- break;
- }
- memmove(newname, alias, newlen);
- c->fontname = newname;
- c->fnamelen = newlen;
- c->current_fpe = 0;
- if (--aliascount <= 0)
- break;
- continue;
- }
- if (err == BadFontName) {
- c->current_fpe++;
- continue;
- }
- if (err == Suspended) {
- if (!c->slept) {
- c->slept = TRUE;
- ClientSleep(client, doOpenFont, (pointer) c);
- }
- return TRUE;
- }
- break;
- }
-
- if (err != Successful)
- goto bail;
- if (!pfont) {
- err = BadFontName;
- goto bail;
- }
- if (!pfont->fpe)
- pfont->fpe = fpe;
- pfont->refcnt++;
- if (pfont->refcnt == 1) {
- UseFPE(pfont->fpe);
- for (i = 0; i < screenInfo.numScreens; i++) {
- pScr = screenInfo.screens[i];
- if (pScr->RealizeFont)
- {
- if (!(*pScr->RealizeFont) (pScr, pfont))
- {
- CloseFont (pfont, (Font) 0);
- err = AllocError;
- goto bail;
- }
- }
- }
- }
- if (!AddResource(c->fontid, RT_FONT, (pointer) pfont)) {
- err = AllocError;
- goto bail;
- }
- if (patternCache && pfont != c->non_cachable_font)
- CacheFontPattern(patternCache, c->origFontName, c->origFontNameLen,
- pfont);
-bail:
- if (err != Successful && c->client != serverClient) {
- SendErrorToClient(c->client, X_OpenFont, 0,
- c->fontid, FontToXError(err));
- }
- if (c->slept)
- ClientWakeup(c->client);
- for (i = 0; i < c->num_fpes; i++) {
- FreeFPE(c->fpe_list[i]);
- }
- xfree(c->fpe_list);
- xfree(c->fontname);
- xfree(c);
- return TRUE;
-}
-
-int
-OpenFont(client, fid, flags, lenfname, pfontname)
- ClientPtr client;
- XID fid;
- Mask flags;
- unsigned lenfname;
- char *pfontname;
-{
- OFclosurePtr c;
- int i;
- FontPtr cached = (FontPtr)0;
-
- if (!lenfname)
- return BadName;
- if (patternCache)
- {
-
- /*
- ** Check name cache. If we find a cached version of this font that
- ** is cachable, immediately satisfy the request with it. If we find
- ** a cached version of this font that is non-cachable, we do not
- ** satisfy the request with it. Instead, we pass the FontPtr to the
- ** FPE's open_font code (the fontfile FPE in turn passes the
- ** information to the rasterizer; the fserve FPE ignores it).
- **
- ** Presumably, the font is marked non-cachable because the FPE has
- ** put some licensing restrictions on it. If the FPE, using
- ** whatever logic it relies on, determines that it is willing to
- ** share this existing font with the client, then it has the option
- ** to return the FontPtr we passed it as the newly-opened font.
- ** This allows the FPE to exercise its licensing logic without
- ** having to create another instance of a font that already exists.
- */
-
- cached = FindCachedFontPattern(patternCache, pfontname, lenfname);
- if (cached && cached->info.cachable)
- {
- if (!AddResource(fid, RT_FONT, (pointer) cached))
- return BadAlloc;
- cached->refcnt++;
- return Success;
- }
- }
- c = (OFclosurePtr) xalloc(sizeof(OFclosureRec));
- if (!c)
- return BadAlloc;
- c->fontname = (char *) xalloc(lenfname);
- c->origFontName = pfontname;
- c->origFontNameLen = lenfname;
- if (!c->fontname) {
- xfree(c);
- return BadAlloc;
- }
- /*
- * copy the current FPE list, so that if it gets changed by another client
- * while we're blocking, the request still appears atomic
- */
- c->fpe_list = (FontPathElementPtr *)
- xalloc(sizeof(FontPathElementPtr) * num_fpes);
- if (!c->fpe_list) {
- xfree(c->fontname);
- xfree(c);
- return BadAlloc;
- }
- memmove(c->fontname, pfontname, lenfname);
- for (i = 0; i < num_fpes; i++) {
- c->fpe_list[i] = font_path_elements[i];
- UseFPE(c->fpe_list[i]);
- }
- c->client = client;
- c->fontid = fid;
- c->current_fpe = 0;
- c->num_fpes = num_fpes;
- c->fnamelen = lenfname;
- c->slept = FALSE;
- c->flags = flags;
- c->non_cachable_font = cached;
-
- (void) doOpenFont(client, c);
- return Success;
-}
-
-/*
- * Decrement font's ref count, and free storage if ref count equals zero
- */
-/*ARGSUSED*/
-int
-CloseFont(value, fid)
- pointer value; /* must conform to DeleteType */
- XID fid;
-{
- int nscr;
- ScreenPtr pscr;
- FontPathElementPtr fpe;
- FontPtr pfont = (FontPtr)value;
-
- if (pfont == NullFont)
- return (Success);
- if (--pfont->refcnt == 0) {
- if (patternCache && pfont->info.cachable)
- RemoveCachedFontPattern (patternCache, pfont);
- /*
- * since the last reference is gone, ask each screen to free any
- * storage it may have allocated locally for it.
- */
- for (nscr = 0; nscr < screenInfo.numScreens; nscr++) {
- pscr = screenInfo.screens[nscr];
- if (pscr->UnrealizeFont)
- (*pscr->UnrealizeFont) (pscr, pfont);
- }
- if (pfont == defaultFont)
- defaultFont = NULL;
-#ifdef LBX
- LbxFreeFontTag(pfont);
-#endif
- fpe = pfont->fpe;
- (*fpe_functions[fpe->type].close_font) (fpe, pfont);
- FreeFPE(fpe);
- }
- return (Success);
-}
-
-
-/***====================================================================***/
-
- /*
- * \ Sets up pReply as the correct QueryFontReply for pFont with the first
- * nProtoCCIStructs char infos. \
- */
-
-void
-QueryFont(pFont, pReply, nProtoCCIStructs)
- FontPtr pFont;
- xQueryFontReply *pReply; /* caller must allocate this storage */
- int nProtoCCIStructs;
-{
- FontPropPtr pFP;
- int r,
- c,
- i;
- xFontProp *prFP;
- xCharInfo *prCI;
- xCharInfo *charInfos[256];
- char chars[512];
- int ninfos;
- unsigned long ncols;
- unsigned long count;
-
- /* pr->length set in dispatch */
- pReply->minCharOrByte2 = pFont->info.firstCol;
- pReply->defaultChar = pFont->info.defaultCh;
- pReply->maxCharOrByte2 = pFont->info.lastCol;
- pReply->drawDirection = pFont->info.drawDirection;
- pReply->allCharsExist = pFont->info.allExist;
- pReply->minByte1 = pFont->info.firstRow;
- pReply->maxByte1 = pFont->info.lastRow;
- pReply->fontAscent = pFont->info.fontAscent;
- pReply->fontDescent = pFont->info.fontDescent;
-
- pReply->minBounds = pFont->info.ink_minbounds;
- pReply->maxBounds = pFont->info.ink_maxbounds;
-
- pReply->nFontProps = pFont->info.nprops;
- pReply->nCharInfos = nProtoCCIStructs;
-
- for (i = 0, pFP = pFont->info.props, prFP = (xFontProp *) (&pReply[1]);
- i < pFont->info.nprops;
- i++, pFP++, prFP++) {
- prFP->name = pFP->name;
- prFP->value = pFP->value;
- }
-
- ninfos = 0;
- ncols = (unsigned long) (pFont->info.lastCol - pFont->info.firstCol + 1);
- prCI = (xCharInfo *) (prFP);
- for (r = pFont->info.firstRow;
- ninfos < nProtoCCIStructs && r <= (int)pFont->info.lastRow;
- r++) {
- i = 0;
- for (c = pFont->info.firstCol; c <= (int)pFont->info.lastCol; c++) {
- chars[i++] = r;
- chars[i++] = c;
- }
- (*pFont->get_metrics) (pFont, ncols, (unsigned char *)chars,
- TwoD16Bit, &count, charInfos);
- i = 0;
- for (i = 0; i < (int) count && ninfos < nProtoCCIStructs; i++) {
- *prCI = *charInfos[i];
- prCI++;
- ninfos++;
- }
- }
- return;
-}
-
-static Bool
-doListFontsAndAliases(client, c)
- ClientPtr client;
- LFclosurePtr c;
-{
- FontPathElementPtr fpe;
- int err = Successful;
- FontNamesPtr names = NULL;
- char *name, *resolved;
- int namelen, resolvedlen;
- int nnames;
- int stringLens;
- int i;
- xListFontsReply reply;
- char *bufptr;
- char *bufferStart;
- int aliascount;
-
- if (client->clientGone)
- {
- if (c->current.current_fpe < c->num_fpes)
- {
- fpe = c->fpe_list[c->current.current_fpe];
- (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
- }
- err = Successful;
- goto bail;
- }
-
- if (!c->current.patlen)
- goto finish;
-
- while (c->current.current_fpe < c->num_fpes) {
- fpe = c->fpe_list[c->current.current_fpe];
- err = Successful;
-
- if (!fpe_functions[fpe->type].start_list_fonts_and_aliases)
- {
- /* This FPE doesn't support/require list_fonts_and_aliases */
-
- err = (*fpe_functions[fpe->type].list_fonts)
- ((pointer) c->client, fpe, c->current.pattern,
- c->current.patlen, c->current.max_names - c->names->nnames,
- c->names);
-
- if (err == Suspended) {
- if (!c->slept) {
- c->slept = TRUE;
- ClientSleep(client, doListFontsAndAliases, (pointer) c);
- }
- return TRUE;
- }
-
- err = BadFontName;
- }
- else
- {
- /* Start of list_fonts_and_aliases functionality. Modeled
- after list_fonts_with_info in that it resolves aliases,
- except that the information collected from FPEs is just
- names, not font info. Each list_next_font_or_alias()
- returns either a name into name/namelen or an alias into
- name/namelen and its target name into resolved/resolvedlen.
- The code at this level then resolves the alias by polling
- the FPEs. */
-
- if (!c->current.list_started) {
- err = (*fpe_functions[fpe->type].start_list_fonts_and_aliases)
- ((pointer) c->client, fpe, c->current.pattern,
- c->current.patlen, c->current.max_names - c->names->nnames,
- &c->current.private);
- if (err == Suspended) {
- if (!c->slept) {
- ClientSleep(client, doListFontsAndAliases,
- (pointer) c);
- c->slept = TRUE;
- }
- return TRUE;
- }
- if (err == Successful)
- c->current.list_started = TRUE;
- }
- if (err == Successful) {
- name = 0;
- err = (*fpe_functions[fpe->type].list_next_font_or_alias)
- ((pointer) c->client, fpe, &name, &namelen, &resolved,
- &resolvedlen, c->current.private);
- if (err == Suspended) {
- if (!c->slept) {
- ClientSleep(client, doListFontsAndAliases,
- (pointer) c);
- c->slept = TRUE;
- }
- return TRUE;
- }
- }
-
- if (err == Successful)
- {
- if (c->haveSaved)
- {
- if (c->savedName)
- (void)AddFontNamesName(c->names, c->savedName,
- c->savedNameLen);
- }
- else
- (void)AddFontNamesName(c->names, name, namelen);
- }
-
- /*
- * When we get an alias back, save our state and reset back to
- * the start of the FPE looking for the specified name. As
- * soon as a real font is found for the alias, pop back to the
- * old state
- */
- else if (err == FontNameAlias) {
- char tmp_pattern[256];
- /*
- * when an alias recurses, we need to give
- * the last FPE a chance to clean up; so we call
- * it again, and assume that the error returned
- * is BadFontName, indicating the alias resolution
- * is complete.
- */
- memmove(tmp_pattern, resolved, resolvedlen);
- if (c->haveSaved)
- {
- char *tmpname;
- int tmpnamelen;
-
- tmpname = 0;
- (void) (*fpe_functions[fpe->type].list_next_font_or_alias)
- ((pointer) c->client, fpe, &tmpname, &tmpnamelen,
- &tmpname, &tmpnamelen, c->current.private);
- if (--aliascount <= 0)
- {
- err = BadFontName;
- goto ContBadFontName;
- }
- }
- else
- {
- c->saved = c->current;
- c->haveSaved = TRUE;
- if (c->savedName)
- xfree(c->savedName);
- c->savedName = (char *)xalloc(namelen + 1);
- if (c->savedName)
- memmove(c->savedName, name, namelen + 1);
- c->savedNameLen = namelen;
- aliascount = 20;
- }
- memmove(c->current.pattern, tmp_pattern, resolvedlen);
- c->current.patlen = resolvedlen;
- c->current.max_names = c->names->nnames + 1;
- c->current.current_fpe = -1;
- c->current.private = 0;
- err = BadFontName;
- }
- }
- /*
- * At the end of this FPE, step to the next. If we've finished
- * processing an alias, pop state back. If we've collected enough
- * font names, quit.
- */
- if (err == BadFontName) {
- ContBadFontName: ;
- c->current.list_started = FALSE;
- c->current.current_fpe++;
- err = Successful;
- if (c->haveSaved)
- {
- if (c->names->nnames == c->current.max_names ||
- c->current.current_fpe == c->num_fpes) {
- c->haveSaved = FALSE;
- c->current = c->saved;
- /* Give the saved namelist a chance to clean itself up */
- continue;
- }
- }
- if (c->names->nnames == c->current.max_names)
- break;
- }
- }
-
- /*
- * send the reply
- */
- if (err != Successful) {
- SendErrorToClient(client, X_ListFonts, 0, 0, FontToXError(err));
- goto bail;
- }
-
-finish:
-
- names = c->names;
- nnames = names->nnames;
- client = c->client;
- stringLens = 0;
- for (i = 0; i < nnames; i++)
- stringLens += (names->length[i] <= 255) ? names->length[i] : 0;
-
- reply.type = X_Reply;
- reply.length = (stringLens + nnames + 3) >> 2;
- reply.nFonts = nnames;
- reply.sequenceNumber = client->sequence;
-
- bufptr = bufferStart = (char *) ALLOCATE_LOCAL(reply.length << 2);
-
- if (!bufptr && reply.length) {
- SendErrorToClient(client, X_ListFonts, 0, 0, BadAlloc);
- goto bail;
- }
- /*
- * since WriteToClient long word aligns things, copy to temp buffer and
- * write all at once
- */
- for (i = 0; i < nnames; i++) {
- if (names->length[i] > 255)
- reply.nFonts--;
- else
- {
- *bufptr++ = names->length[i];
- memmove( bufptr, names->names[i], names->length[i]);
- bufptr += names->length[i];
- }
- }
- nnames = reply.nFonts;
- reply.length = (stringLens + nnames + 3) >> 2;
- client->pSwapReplyFunc = ReplySwapVector[X_ListFonts];
- WriteSwappedDataToClient(client, sizeof(xListFontsReply), &reply);
- (void) WriteToClient(client, stringLens + nnames, bufferStart);
- DEALLOCATE_LOCAL(bufferStart);
-
-bail:
- if (c->slept)
- ClientWakeup(client);
- for (i = 0; i < c->num_fpes; i++)
- FreeFPE(c->fpe_list[i]);
- xfree(c->fpe_list);
- if (c->savedName) xfree(c->savedName);
- FreeFontNames(names);
- xfree(c);
- return TRUE;
-}
-
-int
-ListFonts(client, pattern, length, max_names)
- ClientPtr client;
- unsigned char *pattern;
- unsigned int length;
- unsigned int max_names;
-{
- int i;
- LFclosurePtr c;
-
- if (!(c = (LFclosurePtr) xalloc(sizeof *c)))
- return BadAlloc;
- c->fpe_list = (FontPathElementPtr *)
- xalloc(sizeof(FontPathElementPtr) * num_fpes);
- if (!c->fpe_list) {
- xfree(c);
- return BadAlloc;
- }
- c->names = MakeFontNamesRecord(max_names < 100 ? max_names : 100);
- if (!c->names)
- {
- xfree(c->fpe_list);
- xfree(c);
- return BadAlloc;
- }
- memmove( c->current.pattern, pattern, length);
- for (i = 0; i < num_fpes; i++) {
- c->fpe_list[i] = font_path_elements[i];
- UseFPE(c->fpe_list[i]);
- }
- c->client = client;
- c->num_fpes = num_fpes;
- c->current.patlen = length;
- c->current.current_fpe = 0;
- c->current.max_names = max_names;
- c->current.list_started = FALSE;
- c->current.private = 0;
- c->haveSaved = FALSE;
- c->slept = FALSE;
- c->savedName = 0;
- doListFontsAndAliases(client, c);
- return Success;
-}
-
-int
-doListFontsWithInfo(client, c)
- ClientPtr client;
- LFWIclosurePtr c;
-{
- FontPathElementPtr fpe;
- int err = Successful;
- char *name;
- int namelen;
- int numFonts;
- FontInfoRec fontInfo,
- *pFontInfo;
- xListFontsWithInfoReply *reply;
- int length;
- xFontProp *pFP;
- int i;
- int aliascount;
- xListFontsWithInfoReply finalReply;
-
- if (client->clientGone)
- {
- if (c->current.current_fpe < c->num_fpes)
- {
- fpe = c->fpe_list[c->current.current_fpe];
- (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
- }
- err = Successful;
- goto bail;
- }
- client->pSwapReplyFunc = ReplySwapVector[X_ListFontsWithInfo];
- if (!c->current.patlen)
- goto finish;
- while (c->current.current_fpe < c->num_fpes)
- {
- fpe = c->fpe_list[c->current.current_fpe];
- err = Successful;
- if (!c->current.list_started)
- {
- err = (*fpe_functions[fpe->type].start_list_fonts_with_info)
- (client, fpe, c->current.pattern, c->current.patlen,
- c->current.max_names, &c->current.private);
- if (err == Suspended)
- {
- if (!c->slept)
- {
- ClientSleep(client, doListFontsWithInfo, c);
- c->slept = TRUE;
- }
- return TRUE;
- }
- if (err == Successful)
- c->current.list_started = TRUE;
- }
- if (err == Successful)
- {
- name = 0;
- pFontInfo = &fontInfo;
- err = (*fpe_functions[fpe->type].list_next_font_with_info)
- (client, fpe, &name, &namelen, &pFontInfo,
- &numFonts, c->current.private);
- if (err == Suspended)
- {
- if (!c->slept)
- {
- ClientSleep(client, doListFontsWithInfo, c);
- c->slept = TRUE;
- }
- return TRUE;
- }
- }
- /*
- * When we get an alias back, save our state and reset back to the
- * start of the FPE looking for the specified name. As soon as a real
- * font is found for the alias, pop back to the old state
- */
- if (err == FontNameAlias)
- {
- /*
- * when an alias recurses, we need to give
- * the last FPE a chance to clean up; so we call
- * it again, and assume that the error returned
- * is BadFontName, indicating the alias resolution
- * is complete.
- */
- if (c->haveSaved)
- {
- char *tmpname;
- int tmpnamelen;
- FontInfoPtr tmpFontInfo;
-
- tmpname = 0;
- tmpFontInfo = &fontInfo;
- (void) (*fpe_functions[fpe->type].list_next_font_with_info)
- (client, fpe, &tmpname, &tmpnamelen, &tmpFontInfo,
- &numFonts, c->current.private);
- if (--aliascount <= 0)
- {
- err = BadFontName;
- goto ContBadFontName;
- }
- }
- else
- {
- c->saved = c->current;
- c->haveSaved = TRUE;
- c->savedNumFonts = numFonts;
- c->savedName = (char *) pFontInfo;
- aliascount = 20;
- }
- memmove(c->current.pattern, name, namelen);
- c->current.patlen = namelen;
- c->current.max_names = 1;
- c->current.current_fpe = 0;
- c->current.private = 0;
- c->current.list_started = FALSE;
- }
- /*
- * At the end of this FPE, step to the next. If we've finished
- * processing an alias, pop state back. If we've sent enough font
- * names, quit. Always wait for BadFontName to let the FPE
- * have a chance to clean up.
- */
- else if (err == BadFontName)
- {
- ContBadFontName: ;
- c->current.list_started = FALSE;
- c->current.current_fpe++;
- err = Successful;
- if (c->haveSaved)
- {
- if (c->current.max_names == 0 ||
- c->current.current_fpe == c->num_fpes)
- {
- c->haveSaved = FALSE;
- c->saved.max_names -= (1 - c->current.max_names);
- c->current = c->saved;
- }
- }
- else if (c->current.max_names == 0)
- break;
- }
- else if (err == Successful)
- {
- length = sizeof(*reply) + pFontInfo->nprops * sizeof(xFontProp);
- reply = c->reply;
- if (c->length < length)
- {
- reply = (xListFontsWithInfoReply *) xrealloc(c->reply, length);
- if (!reply)
- {
- err = AllocError;
- break;
- }
- c->reply = reply;
- c->length = length;
- }
- if (c->haveSaved)
- {
- numFonts = c->savedNumFonts;
- name = c->savedName;
- namelen = strlen(name);
- }
- reply->type = X_Reply;
- reply->length = (sizeof *reply - sizeof(xGenericReply) +
- pFontInfo->nprops * sizeof(xFontProp) +
- namelen + 3) >> 2;
- reply->sequenceNumber = client->sequence;
- reply->nameLength = namelen;
- reply->minBounds = pFontInfo->ink_minbounds;
- reply->maxBounds = pFontInfo->ink_maxbounds;
- reply->minCharOrByte2 = pFontInfo->firstCol;
- reply->maxCharOrByte2 = pFontInfo->lastCol;
- reply->defaultChar = pFontInfo->defaultCh;
- reply->nFontProps = pFontInfo->nprops;
- reply->drawDirection = pFontInfo->drawDirection;
- reply->minByte1 = pFontInfo->firstRow;
- reply->maxByte1 = pFontInfo->lastRow;
- reply->allCharsExist = pFontInfo->allExist;
- reply->fontAscent = pFontInfo->fontAscent;
- reply->fontDescent = pFontInfo->fontDescent;
- reply->nReplies = numFonts;
- pFP = (xFontProp *) (reply + 1);
- for (i = 0; i < pFontInfo->nprops; i++)
- {
- pFP->name = pFontInfo->props[i].name;
- pFP->value = pFontInfo->props[i].value;
- pFP++;
- }
- WriteSwappedDataToClient(client, length, reply);
- (void) WriteToClient(client, namelen, name);
- if (pFontInfo == &fontInfo)
- {
- xfree(fontInfo.props);
- xfree(fontInfo.isStringProp);
- }
- --c->current.max_names;
- }
- }
-finish:
- length = sizeof(xListFontsWithInfoReply);
- bzero((char *) &finalReply, sizeof(xListFontsWithInfoReply));
- finalReply.type = X_Reply;
- finalReply.sequenceNumber = client->sequence;
- finalReply.length = (sizeof(xListFontsWithInfoReply)
- - sizeof(xGenericReply)) >> 2;
- WriteSwappedDataToClient(client, length, &finalReply);
-bail:
- if (c->slept)
- ClientWakeup(client);
- for (i = 0; i < c->num_fpes; i++)
- FreeFPE(c->fpe_list[i]);
- xfree(c->reply);
- xfree(c->fpe_list);
- xfree(c);
- return TRUE;
-}
-
-int
-StartListFontsWithInfo(client, length, pattern, max_names)
- ClientPtr client;
- int length;
- unsigned char *pattern;
- int max_names;
-{
- int i;
- LFWIclosurePtr c;
-
- if (!(c = (LFWIclosurePtr) xalloc(sizeof *c)))
- goto badAlloc;
- c->fpe_list = (FontPathElementPtr *)
- xalloc(sizeof(FontPathElementPtr) * num_fpes);
- if (!c->fpe_list)
- {
- xfree(c);
- goto badAlloc;
- }
- memmove(c->current.pattern, pattern, length);
- for (i = 0; i < num_fpes; i++)
- {
- c->fpe_list[i] = font_path_elements[i];
- UseFPE(c->fpe_list[i]);
- }
- c->client = client;
- c->num_fpes = num_fpes;
- c->reply = 0;
- c->length = 0;
- c->current.patlen = length;
- c->current.current_fpe = 0;
- c->current.max_names = max_names;
- c->current.list_started = FALSE;
- c->current.private = 0;
- c->savedNumFonts = 0;
- c->haveSaved = FALSE;
- c->slept = FALSE;
- doListFontsWithInfo(client, c);
- return Success;
-badAlloc:
- return BadAlloc;
-}
-
-#define TextEltHeader 2
-#define FontShiftSize 5
-static XID clearGC[] = { CT_NONE };
-#define clearGCmask (GCClipMask)
-
-int
-doPolyText(client, c)
- ClientPtr client;
- register PTclosurePtr c;
-{
- register FontPtr pFont = c->pGC->font, oldpFont;
- Font fid, oldfid;
- int err = Success, lgerr; /* err is in X error, not font error, space */
- enum { NEVER_SLEPT, START_SLEEP, SLEEPING } client_state;
- FontPathElementPtr fpe;
- GC *origGC;
-
- if (client->clientGone)
- {
- fpe = c->pGC->font->fpe;
- (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
-
- if (c->slept)
- {
- /* Client has died, but we cannot bail out right now. We
- need to clean up after the work we did when going to
- sleep. Setting the drawable pointer to 0 makes this
- happen without any attempts to render or perform other
- unnecessary activities. */
- c->pDraw = (DrawablePtr)0;
- }
- else
- {
- err = Success;
- goto bail;
- }
- }
-
- /* Make sure our drawable hasn't disappeared while we slept. */
- if (c->slept &&
- c->pDraw &&
- c->pDraw != (DrawablePtr)SecurityLookupIDByClass(client, c->did,
- RC_DRAWABLE, SecurityWriteAccess))
- {
- /* Our drawable has disappeared. Treat like client died... ask
- the FPE code to clean up after client and avoid further
- rendering while we clean up after ourself. */
- fpe = c->pGC->font->fpe;
- (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
- c->pDraw = (DrawablePtr)0;
- }
-
- client_state = c->slept ? SLEEPING : NEVER_SLEPT;
-
- while (c->endReq - c->pElt > TextEltHeader)
- {
- if (*c->pElt == FontChange)
- {
- if (c->endReq - c->pElt < FontShiftSize)
- {
- err = BadLength;
- goto bail;
- }
-
- oldpFont = pFont;
- oldfid = fid;
-
- fid = ((Font)*(c->pElt+4)) /* big-endian */
- | ((Font)*(c->pElt+3)) << 8
- | ((Font)*(c->pElt+2)) << 16
- | ((Font)*(c->pElt+1)) << 24;
- pFont = (FontPtr)SecurityLookupIDByType(client, fid, RT_FONT,
- SecurityReadAccess);
- if (!pFont)
- {
- client->errorValue = fid;
- err = BadFont;
- /* restore pFont and fid for step 4 (described below) */
- pFont = oldpFont;
- fid = oldfid;
-
- /* If we're in START_SLEEP mode, the following step
- shortens the request... in the unlikely event that
- the fid somehow becomes valid before we come through
- again to actually execute the polytext, which would
- then mess up our refcounting scheme badly. */
- c->err = err;
- c->endReq = c->pElt;
-
- goto bail;
- }
-
- /* Step 3 (described below) on our new font */
- if (client_state == START_SLEEP)
- pFont->refcnt++;
- else
- {
- if (pFont != c->pGC->font && c->pDraw)
- {
- ChangeGC( c->pGC, GCFont, &fid);
- ValidateGC(c->pDraw, c->pGC);
- if (c->reqType == X_PolyText8)
- c->polyText = c->pGC->ops->PolyText8;
- else
- c->polyText = c->pGC->ops->PolyText16;
- }
-
- /* Undo the refcnt++ we performed when going to sleep */
- if (client_state == SLEEPING)
- (void)CloseFont(c->pGC->font, (Font)0);
- }
- c->pElt += FontShiftSize;
- }
- else /* print a string */
- {
- unsigned char *pNextElt;
- pNextElt = c->pElt + TextEltHeader + (*c->pElt)*c->itemSize;
- if ( pNextElt > c->endReq)
- {
- err = BadLength;
- goto bail;
- }
- if (client_state == START_SLEEP)
- {
- c->pElt = pNextElt;
- continue;
- }
- if (c->pDraw)
- {
- lgerr = LoadGlyphs(client, c->pGC->font, *c->pElt, c->itemSize,
- c->pElt + TextEltHeader);
- }
- else lgerr = Successful;
-
- if (lgerr == Suspended)
- {
- if (!c->slept) {
- int len;
- GC *pGC;
- PTclosurePtr new_closure;
-
- /* We're putting the client to sleep. We need to do a few things
- to ensure successful and atomic-appearing execution of the
- remainder of the request. First, copy the remainder of the
- request into a safe malloc'd area. Second, create a scratch GC
- to use for the remainder of the request. Third, mark all fonts
- referenced in the remainder of the request to prevent their
- deallocation. Fourth, make the original GC look like the
- request has completed... set its font to the final font value
- from this request. These GC manipulations are for the unlikely
- (but possible) event that some other client is using the GC.
- Steps 3 and 4 are performed by running this procedure through
- the remainder of the request in a special no-render mode
- indicated by client_state = START_SLEEP. */
-
- /* Step 1 */
- /* Allocate a malloc'd closure structure to replace
- the local one we were passed */
- new_closure = (PTclosurePtr) xalloc(sizeof(PTclosureRec));
- if (!new_closure)
- {
- err = BadAlloc;
- goto bail;
- }
- *new_closure = *c;
- c = new_closure;
-
- len = c->endReq - c->pElt;
- c->data = (unsigned char *)xalloc(len);
- if (!c->data)
- {
- xfree(c);
- err = BadAlloc;
- goto bail;
- }
- memmove(c->data, c->pElt, len);
- c->pElt = c->data;
- c->endReq = c->pElt + len;
-
- /* Step 2 */
-
- pGC = GetScratchGC(c->pGC->depth, c->pGC->pScreen);
- if (!pGC)
- {
- xfree(c->data);
- xfree(c);
- err = BadAlloc;
- goto bail;
- }
- if ((err = CopyGC(c->pGC, pGC, GCFunction |
- GCPlaneMask | GCForeground |
- GCBackground | GCFillStyle |
- GCTile | GCStipple |
- GCTileStipXOrigin |
- GCTileStipYOrigin | GCFont |
- GCSubwindowMode | GCClipXOrigin |
- GCClipYOrigin | GCClipMask)) !=
- Success)
- {
- FreeScratchGC(pGC);
- xfree(c->data);
- xfree(c);
- err = BadAlloc;
- goto bail;
- }
- origGC = c->pGC;
- c->pGC = pGC;
- ValidateGC(c->pDraw, c->pGC);
-
- c->slept = TRUE;
- ClientSleep(client, doPolyText, (pointer) c);
-
- /* Set up to perform steps 3 and 4 */
- client_state = START_SLEEP;
- continue; /* on to steps 3 and 4 */
- }
- return TRUE;
- }
- else if (lgerr != Successful)
- {
- err = FontToXError(lgerr);
- goto bail;
- }
- if (c->pDraw)
- {
- c->xorg += *((INT8 *)(c->pElt + 1)); /* must be signed */
- c->xorg = (* c->polyText)(c->pDraw, c->pGC, c->xorg, c->yorg,
- *c->pElt, c->pElt + TextEltHeader);
- }
- c->pElt = pNextElt;
- }
- }
-
-bail:
-
- if (client_state == START_SLEEP)
- {
- /* Step 4 */
- if (pFont != origGC->font)
- {
- ChangeGC(origGC, GCFont, &fid);
- ValidateGC(c->pDraw, origGC);
- }
-
- /* restore pElt pointer for execution of remainder of the request */
- c->pElt = c->data;
- return TRUE;
- }
-
- if (c->err != Success) err = c->err;
- if (err != Success && c->client != serverClient) {
-#ifdef PANORAMIX
- if (noPanoramiXExtension)
-#endif
- SendErrorToClient(c->client, c->reqType, 0, 0, err);
- }
- if (c->slept)
- {
- ClientWakeup(c->client);
- ChangeGC(c->pGC, clearGCmask, clearGC);
-
- /* Unreference the font from the scratch GC */
- CloseFont(c->pGC->font, (Font)0);
- c->pGC->font = NullFont;
-
- FreeScratchGC(c->pGC);
- xfree(c->data);
- xfree(c);
- }
- return TRUE;
-}
-
-int
-PolyText(client, pDraw, pGC, pElt, endReq, xorg, yorg, reqType, did)
- ClientPtr client;
- DrawablePtr pDraw;
- GC *pGC;
- unsigned char *pElt;
- unsigned char *endReq;
- int xorg;
- int yorg;
- int reqType;
- XID did;
-{
- PTclosureRec local_closure;
-
- local_closure.pElt = pElt;
- local_closure.endReq = endReq;
- local_closure.client = client;
- local_closure.pDraw = pDraw;
- local_closure.xorg = xorg;
- local_closure.yorg = yorg;
- if ((local_closure.reqType = reqType) == X_PolyText8)
- {
- local_closure.polyText = pGC->ops->PolyText8;
- local_closure.itemSize = 1;
- }
- else
- {
- local_closure.polyText = pGC->ops->PolyText16;
- local_closure.itemSize = 2;
- }
- local_closure.pGC = pGC;
- local_closure.did = did;
- local_closure.err = Success;
- local_closure.slept = FALSE;
-
- (void) doPolyText(client, &local_closure);
- return Success;
-}
-
-
-#undef TextEltHeader
-#undef FontShiftSize
-
-int
-doImageText(client, c)
- ClientPtr client;
- register ITclosurePtr c;
-{
- int err = Success, lgerr; /* err is in X error, not font error, space */
- FontPathElementPtr fpe;
-
- if (client->clientGone)
- {
- fpe = c->pGC->font->fpe;
- (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
- err = Success;
- goto bail;
- }
-
- /* Make sure our drawable hasn't disappeared while we slept. */
- if (c->slept &&
- c->pDraw &&
- c->pDraw != (DrawablePtr)SecurityLookupIDByClass(client, c->did,
- RC_DRAWABLE, SecurityWriteAccess))
- {
- /* Our drawable has disappeared. Treat like client died... ask
- the FPE code to clean up after client. */
- fpe = c->pGC->font->fpe;
- (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
- err = Success;
- goto bail;
- }
-
- lgerr = LoadGlyphs(client, c->pGC->font, c->nChars, c->itemSize, c->data);
- if (lgerr == Suspended)
- {
- if (!c->slept) {
- GC *pGC;
- unsigned char *data;
- ITclosurePtr new_closure;
-
- /* We're putting the client to sleep. We need to
- save some state. Similar problem to that handled
- in doPolyText, but much simpler because the
- request structure is much simpler. */
-
- new_closure = (ITclosurePtr) xalloc(sizeof(ITclosureRec));
- if (!new_closure)
- {
- err = BadAlloc;
- goto bail;
- }
- *new_closure = *c;
- c = new_closure;
-
- data = (unsigned char *)xalloc(c->nChars * c->itemSize);
- if (!data)
- {
- xfree(c);
- err = BadAlloc;
- goto bail;
- }
- memmove(data, c->data, c->nChars * c->itemSize);
- c->data = data;
-
- pGC = GetScratchGC(c->pGC->depth, c->pGC->pScreen);
- if (!pGC)
- {
- xfree(c->data);
- xfree(c);
- err = BadAlloc;
- goto bail;
- }
- if ((err = CopyGC(c->pGC, pGC, GCFunction | GCPlaneMask |
- GCForeground | GCBackground | GCFillStyle |
- GCTile | GCStipple | GCTileStipXOrigin |
- GCTileStipYOrigin | GCFont |
- GCSubwindowMode | GCClipXOrigin |
- GCClipYOrigin | GCClipMask)) != Success)
- {
- FreeScratchGC(pGC);
- xfree(c->data);
- xfree(c);
- err = BadAlloc;
- goto bail;
- }
- c->pGC = pGC;
- ValidateGC(c->pDraw, c->pGC);
-
- c->slept = TRUE;
- ClientSleep(client, doImageText, (pointer) c);
- }
- return TRUE;
- }
- else if (lgerr != Successful)
- {
- err = FontToXError(lgerr);
- goto bail;
- }
- if (c->pDraw)
- {
- (* c->imageText)(c->pDraw, c->pGC, c->xorg, c->yorg,
- c->nChars, c->data);
- }
-
-bail:
-
- if (err != Success && c->client != serverClient) {
- SendErrorToClient(c->client, c->reqType, 0, 0, err);
- }
- if (c->slept)
- {
- ClientWakeup(c->client);
- ChangeGC(c->pGC, clearGCmask, clearGC);
-
- /* Unreference the font from the scratch GC */
- CloseFont(c->pGC->font, (Font)0);
- c->pGC->font = NullFont;
-
- FreeScratchGC(c->pGC);
- xfree(c->data);
- xfree(c);
- }
- return TRUE;
-}
-
-int
-ImageText(client, pDraw, pGC, nChars, data, xorg, yorg, reqType, did)
- ClientPtr client;
- DrawablePtr pDraw;
- GC *pGC;
- int nChars;
- unsigned char *data;
- int xorg;
- int yorg;
- int reqType;
- XID did;
-{
- ITclosureRec local_closure;
-
- local_closure.client = client;
- local_closure.pDraw = pDraw;
- local_closure.pGC = pGC;
- local_closure.nChars = nChars;
- local_closure.data = data;
- local_closure.xorg = xorg;
- local_closure.yorg = yorg;
- if ((local_closure.reqType = reqType) == X_ImageText8)
- {
- local_closure.imageText = pGC->ops->ImageText8;
- local_closure.itemSize = 1;
- }
- else
- {
- local_closure.imageText = pGC->ops->ImageText16;
- local_closure.itemSize = 2;
- }
- local_closure.did = did;
- local_closure.slept = FALSE;
-
- (void) doImageText(client, &local_closure);
- return Success;
-}
-
-
-/* does the necessary magic to figure out the fpe type */
-static int
-DetermineFPEType(pathname)
- char *pathname;
-{
- int i;
-
- for (i = 0; i < num_fpe_types; i++) {
- if ((*fpe_functions[i].name_check) (pathname))
- return i;
- }
- return -1;
-}
-
-
-static void
-FreeFontPath(list, n, force)
- FontPathElementPtr *list;
- Bool force;
- int n;
-{
- int i;
-
- for (i = 0; i < n; i++) {
- if (force) {
- /* Sanity check that all refcounts will be 0 by the time
- we get to the end of the list. */
- int found = 1; /* the first reference is us */
- int j;
- for (j = i+1; j < n; j++) {
- if (list[j] == list[i])
- found++;
- }
- if (list[i]->refcount != found) {
- ErrorF("FreeFontPath: FPE \"%.*s\" refcount is %d, should be %d; fixing.\n",
- list[i]->name_length, list[i]->name,
- list[i]->refcount, found);
- list[i]->refcount = found; /* ensure it will get freed */
- }
- }
- FreeFPE(list[i]);
- }
- xfree((char *) list);
-}
-
-static FontPathElementPtr
-find_existing_fpe(list, num, name, len)
- FontPathElementPtr *list;
- int num;
- unsigned char *name;
- int len;
-{
- FontPathElementPtr fpe;
- int i;
-
- for (i = 0; i < num; i++) {
- fpe = list[i];
- if (fpe->name_length == len && memcmp(name, fpe->name, len) == 0)
- return fpe;
- }
- return (FontPathElementPtr) 0;
-}
-
-
-static int
-SetFontPathElements(npaths, paths, bad)
- int npaths;
- unsigned char *paths;
- int *bad;
-{
- int i,
- err;
- int valid_paths = 0;
- unsigned int len;
- unsigned char *cp = paths;
- FontPathElementPtr fpe,
- *fplist;
-
- fplist = (FontPathElementPtr *)
- xalloc(sizeof(FontPathElementPtr) * npaths);
- if (!fplist) {
- *bad = 0;
- return BadAlloc;
- }
- for (i = 0; i < num_fpe_types; i++) {
- if (fpe_functions[i].set_path_hook)
- (*fpe_functions[i].set_path_hook) ();
- }
- for (i = 0; i < npaths; i++) {
- len = (unsigned int) (*cp++);
-
- if (len) {
- /* if it's already in our active list, just reset it */
- /*
- * note that this can miss FPE's in limbo -- may be worth catching
- * them, though it'd muck up refcounting
- */
- fpe = find_existing_fpe(font_path_elements, num_fpes, cp, len);
- if (fpe) {
- err = (*fpe_functions[fpe->type].reset_fpe) (fpe);
- if (err == Successful) {
- UseFPE(fpe);/* since it'll be decref'd later when freed
- * from the old list */
- fplist[valid_paths++] = fpe;
- cp += len;
- continue;
- }
- /* if error or can't do it, act like it's a new one */
- }
- fpe = (FontPathElementPtr) xalloc(sizeof(FontPathElementRec));
- if (!fpe) {
- err = BadAlloc;
- goto bail;
- }
- fpe->name = (char *) xalloc(len + 1);
- if (!fpe->name) {
- xfree(fpe);
- err = BadAlloc;
- goto bail;
- }
- fpe->refcount = 1;
-
- strncpy(fpe->name, (char *) cp, (int) len);
- cp += len;
- fpe->name[len] = '\0';
- fpe->name_length = len;
- fpe->type = DetermineFPEType(fpe->name);
- if (fpe->type == -1) {
- xfree(fpe->name);
- xfree(fpe);
- err = BadValue;
- goto bail;
- }
- err = (*fpe_functions[fpe->type].init_fpe) (fpe);
- if (err != Successful) {
- xfree(fpe->name);
- xfree(fpe);
- err = BadValue;
- goto bail;
- }
- fplist[valid_paths++] = fpe;
- } else {
- err = BadValue;
- goto bail;
- }
- }
-
- FreeFontPath(font_path_elements, num_fpes, FALSE);
- font_path_elements = fplist;
- if (patternCache)
- EmptyFontPatternCache(patternCache);
- num_fpes = valid_paths;
-
- return Success;
-bail:
- *bad = i;
- while (--i >= 0)
- FreeFPE(fplist[i]);
- xfree(fplist);
- return err;
-}
-
-/* XXX -- do we need to pass error down to each renderer? */
-int
-SetFontPath(client, npaths, paths, error)
- ClientPtr client;
- int npaths;
- unsigned char *paths;
- int *error;
-{
- int err = Success;
-
- if (npaths == 0) {
- if (SetDefaultFontPath(defaultFontPath) != Success)
- return BadName;
- } else {
- err = SetFontPathElements(npaths, paths, error);
- }
- return err;
-}
-
-int
-SetDefaultFontPath(path)
- char *path;
-{
- unsigned char *cp,
- *pp,
- *nump,
- *newpath;
- int num = 1,
- len,
- err,
- size = 0,
- bad;
-
- /* get enough for string, plus values -- use up commas */
- len = strlen(path) + 1;
- nump = cp = newpath = (unsigned char *) ALLOCATE_LOCAL(len);
- if (!newpath)
- return BadAlloc;
- pp = (unsigned char *) path;
- cp++;
- while (*pp) {
- if (*pp == ',') {
- *nump = (unsigned char) size;
- nump = cp++;
- pp++;
- num++;
- size = 0;
- } else {
- *cp++ = *pp++;
- size++;
- }
- }
- *nump = (unsigned char) size;
-
- err = SetFontPathElements(num, newpath, &bad);
-
- DEALLOCATE_LOCAL(newpath);
-
- return err;
-}
-
-unsigned char *
-GetFontPath(count, length)
- int *count;
- int *length;
-{
- int i;
- unsigned char *c;
- int len;
- FontPathElementPtr fpe;
-
- len = 0;
- for (i = 0; i < num_fpes; i++) {
- fpe = font_path_elements[i];
- len += fpe->name_length + 1;
- }
- font_path_string = (unsigned char *) xrealloc(font_path_string, len);
- if (!font_path_string)
- return NULL;
-
- c = font_path_string;
- *length = 0;
- for (i = 0; i < num_fpes; i++) {
- fpe = font_path_elements[i];
- *c = fpe->name_length;
- *length += *c++;
- memmove(c, fpe->name, fpe->name_length);
- c += fpe->name_length;
- }
- *count = num_fpes;
- return font_path_string;
-}
-
-int
-LoadGlyphs(client, pfont, nchars, item_size, data)
- ClientPtr client;
- FontPtr pfont;
- unsigned nchars;
- int item_size;
- unsigned char *data;
-{
- if (fpe_functions[pfont->fpe->type].load_glyphs)
- return (*fpe_functions[pfont->fpe->type].load_glyphs)
- (client, pfont, 0, nchars, item_size, data);
- else
- return Successful;
-}
-
-void
-DeleteClientFontStuff(client)
- ClientPtr client;
-{
- int i;
- FontPathElementPtr fpe;
-
- for (i = 0; i < num_fpes; i++)
- {
- fpe = font_path_elements[i];
- if (fpe_functions[fpe->type].client_died)
- (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
- }
-}
-
-void
-InitFonts ()
-{
- patternCache = MakeFontPatternCache();
-
- if (screenInfo.numScreens > screenInfo.numVideoScreens) {
- PrinterFontRegisterFpeFunctions();
- FontFileCheckRegisterFpeFunctions();
- check_fs_register_fpe_functions();
- } else {
- FontFileRegisterFpeFunctions();
- fs_register_fpe_functions();
- }
-}
-
-int
-GetDefaultPointSize ()
-{
- return 120;
-}
-
-
-FontResolutionPtr
-GetClientResolutions (num)
- int *num;
-{
- if (requestingClient && requestingClient->fontResFunc != NULL &&
- !requestingClient->clientGone)
- {
- return (*requestingClient->fontResFunc)(requestingClient, num);
- }
- else {
- static struct _FontResolution res;
- ScreenPtr pScreen;
-
- pScreen = screenInfo.screens[0];
- res.x_resolution = (pScreen->width * 25.4) / pScreen->mmWidth;
- /*
- * XXX - we'll want this as long as bitmap instances are prevalent
- so that we can match them from scalable fonts
- */
- if (res.x_resolution < 88)
- res.x_resolution = 75;
- else
- res.x_resolution = 100;
- res.y_resolution = (pScreen->height * 25.4) / pScreen->mmHeight;
- if (res.y_resolution < 88)
- res.y_resolution = 75;
- else
- res.y_resolution = 100;
- res.point_size = 120;
- *num = 1;
- return &res;
- }
-}
-
-/*
- * returns the type index of the new fpe
- *
- * should be called (only once!) by each type of fpe when initialized
- */
-
-int
-RegisterFPEFunctions(name_func, init_func, free_func, reset_func,
- open_func, close_func, list_func, start_lfwi_func, next_lfwi_func,
- wakeup_func, client_died, load_glyphs,
- start_list_alias_func, next_list_alias_func,
- set_path_func)
- Bool (*name_func) ();
- int (*init_func) ();
- int (*free_func) ();
- int (*reset_func) ();
- int (*open_func) ();
- int (*close_func) ();
- int (*list_func) ();
- int (*start_lfwi_func) ();
- int (*next_lfwi_func) ();
- int (*wakeup_func) ();
- int (*client_died) ();
- int (*load_glyphs) ();
- int (*start_list_alias_func) ();
- int (*next_list_alias_func) ();
- void (*set_path_func) ();
-{
- FPEFunctions *new;
-
- /* grow the list */
- new = (FPEFunctions *) xrealloc(fpe_functions,
- (num_fpe_types + 1) * sizeof(FPEFunctions));
- if (!new)
- return -1;
- fpe_functions = new;
-
- fpe_functions[num_fpe_types].name_check = name_func;
- fpe_functions[num_fpe_types].open_font = open_func;
- fpe_functions[num_fpe_types].close_font = close_func;
- fpe_functions[num_fpe_types].wakeup_fpe = wakeup_func;
- fpe_functions[num_fpe_types].list_fonts = list_func;
- fpe_functions[num_fpe_types].start_list_fonts_with_info =
- start_lfwi_func;
- fpe_functions[num_fpe_types].list_next_font_with_info =
- next_lfwi_func;
- fpe_functions[num_fpe_types].init_fpe = init_func;
- fpe_functions[num_fpe_types].free_fpe = free_func;
- fpe_functions[num_fpe_types].reset_fpe = reset_func;
- fpe_functions[num_fpe_types].client_died = client_died;
- fpe_functions[num_fpe_types].load_glyphs = load_glyphs;
- fpe_functions[num_fpe_types].start_list_fonts_and_aliases =
- start_list_alias_func;
- fpe_functions[num_fpe_types].list_next_font_or_alias =
- next_list_alias_func;
- fpe_functions[num_fpe_types].set_path_hook = set_path_func;
-
- return num_fpe_types++;
-}
-
-void
-FreeFonts()
-{
- if (patternCache) {
- FreeFontPatternCache(patternCache);
- patternCache = 0;
- }
- FreeFontPath(font_path_elements, num_fpes, TRUE);
- font_path_elements = 0;
- num_fpes = 0;
- xfree(fpe_functions);
- num_fpe_types = 0;
- fpe_functions = (FPEFunctions *) 0;
-}
-
-/* convenience functions for FS interface */
-
-FontPtr
-find_old_font(id)
- XID id;
-{
- return (FontPtr) SecurityLookupIDByType(NullClient, id, RT_NONE,
- SecurityUnknownAccess);
-}
-
-Font
-GetNewFontClientID()
-{
- return FakeClientID(0);
-}
-
-int
-StoreFontClientFont(pfont, id)
- FontPtr pfont;
- Font id;
-{
- return AddResource(id, RT_NONE, (pointer) pfont);
-}
-
-void
-DeleteFontClientID(id)
- Font id;
-{
- FreeResource(id, RT_NONE);
-}
-
-int
-client_auth_generation(client)
- ClientPtr client;
-{
- return 0;
-}
-
-static int fs_handlers_installed = 0;
-static unsigned int last_server_gen;
-
-int
-init_fs_handlers(fpe, block_handler)
- FontPathElementPtr fpe;
- BlockHandlerProcPtr block_handler;
-{
- /* if server has reset, make sure the b&w handlers are reinstalled */
- if (last_server_gen < serverGeneration) {
- last_server_gen = serverGeneration;
- fs_handlers_installed = 0;
- }
- if (fs_handlers_installed == 0) {
-
-#ifdef DEBUG
- fprintf(stderr, "adding FS b & w handlers\n");
-#endif
-
- if (!RegisterBlockAndWakeupHandlers(block_handler,
- FontWakeup, (pointer) 0))
- return AllocError;
- fs_handlers_installed++;
- }
- QueueFontWakeup(fpe);
- return Successful;
-}
-
-void
-remove_fs_handlers(fpe, block_handler, all)
- FontPathElementPtr fpe;
- BlockHandlerProcPtr block_handler;
- Bool all;
-{
- if (all) {
- /* remove the handlers if no one else is using them */
- if (--fs_handlers_installed == 0) {
-
-#ifdef DEBUG
- fprintf(stderr, "removing FS b & w handlers\n");
-#endif
-
- RemoveBlockAndWakeupHandlers(block_handler, FontWakeup,
- (pointer) 0);
- }
- }
- RemoveFontWakeup(fpe);
-}
-
-#ifdef DEBUG
-#define GLWIDTHBYTESPADDED(bits,nbytes) \
- ((nbytes) == 1 ? (((bits)+7)>>3) /* pad to 1 byte */ \
- :(nbytes) == 2 ? ((((bits)+15)>>3)&~1) /* pad to 2 bytes */ \
- :(nbytes) == 4 ? ((((bits)+31)>>3)&~3) /* pad to 4 bytes */ \
- :(nbytes) == 8 ? ((((bits)+63)>>3)&~7) /* pad to 8 bytes */ \
- : 0)
-
-#define GLYPH_SIZE(ch, nbytes) \
- GLWIDTHBYTESPADDED((ch)->metrics.rightSideBearing - \
- (ch)->metrics.leftSideBearing, (nbytes))
-dump_char_ascii(cip)
- CharInfoPtr cip;
-{
- int r,
- l;
- int bpr;
- int byte;
- static unsigned maskTab[] = {
- (1 << 7), (1 << 6), (1 << 5), (1 << 4),
- (1 << 3), (1 << 2), (1 << 1), (1 << 0),
- };
-
- bpr = GLYPH_SIZE(cip, 4);
- for (r = 0; r < (cip->metrics.ascent + cip->metrics.descent); r++) {
- pointer row = (pointer) cip->bits + r * bpr;
-
- byte = 0;
- for (l = 0; l <= (cip->metrics.rightSideBearing -
- cip->metrics.leftSideBearing); l++) {
- if (maskTab[l & 7] & row[l >> 3])
- putchar('X');
- else
- putchar('.');
- }
- putchar('\n');
- }
-}
-
-#endif
diff --git a/programs/Xserver/pandix/events.c b/programs/Xserver/pandix/events.c
deleted file mode 100644
index fececde33..000000000
--- a/programs/Xserver/pandix/events.c
+++ /dev/null
@@ -1,4470 +0,0 @@
-
-/****************************************************************
-* *
-* Copyright (c) Digital Equipment Corporation, 1991, 1997 *
-* *
-* All Rights Reserved. Unpublished rights reserved under *
-* the copyright laws of the United States. *
-* *
-* The software contained on this media is proprietary to *
-* and embodies the confidential technology of Digital *
-* Equipment Corporation. Possession, use, duplication or *
-* dissemination of the software and media is authorized only *
-* pursuant to a valid written license from Digital Equipment *
-* Corporation. *
-* *
-* RESTRICTED RIGHTS LEGEND Use, duplication, or disclosure *
-* by the U.S. Government is subject to restrictions as set *
-* forth in Subparagraph (c)(1)(ii) of DFARS 252.227-7013, *
-* or in FAR 52.227-19, as applicable. *
-* *
-*****************************************************************/
-/************************************************************
-
-Copyright (c) 1987 X Consortium
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-X CONSORTIUM 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 X Consortium 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 X Consortium.
-
-
-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.
-
-********************************************************/
-
-
-/* $TOG: events.c /main/2 1997/11/13 14:59:15 kaleb $ */
-
-#include "X.h"
-#include "misc.h"
-#include "resource.h"
-#define NEED_EVENTS
-#define NEED_REPLIES
-#include "Xproto.h"
-#include "windowstr.h"
-#include "inputstr.h"
-#include "scrnintstr.h"
-#include "cursorstr.h"
-
-#include "dixstruct.h"
-#ifdef PANORAMIX
-#include "panoramiX.h"
-#include "stdio.h"
-#endif
-
-#ifdef XKB
-#include "XKBsrv.h"
-#endif
-
-#ifdef PANORAMIX
-extern Bool noPanoramiXExtension;
-extern int PanoramiXNumScreens;
-extern PanoramiXWindow *PanoramiXWinRoot;
-extern PanoramiXGC *PanoramiXGCRoot;
-extern PanoramiXCmap *PanoramiXCmapRoot;
-extern PanoramiXPmap *PanoramiXPmapRoot;
-extern PanoramiXData *panoramiXdataPtr;
-#endif
-
-#ifdef XCSECURITY
-#define _SECURITY_SERVER
-#include "extensions/security.h"
-#endif
-
-extern WindowPtr *WindowTable;
-
-extern void (* EventSwapVector[128]) ();
-
-#define EXTENSION_EVENT_BASE 64
-
-#define NoSuchEvent 0x80000000 /* so doesn't match NoEventMask */
-#define StructureAndSubMask ( StructureNotifyMask | SubstructureNotifyMask )
-#define AllButtonsMask ( \
- Button1Mask | Button2Mask | Button3Mask | Button4Mask | Button5Mask )
-#define MotionMask ( \
- PointerMotionMask | Button1MotionMask | \
- Button2MotionMask | Button3MotionMask | Button4MotionMask | \
- Button5MotionMask | ButtonMotionMask )
-#define PropagateMask ( \
- KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | \
- MotionMask )
-#define PointerGrabMask ( \
- ButtonPressMask | ButtonReleaseMask | \
- EnterWindowMask | LeaveWindowMask | \
- PointerMotionHintMask | KeymapStateMask | \
- MotionMask )
-#define AllModifiersMask ( \
- ShiftMask | LockMask | ControlMask | Mod1Mask | Mod2Mask | \
- Mod3Mask | Mod4Mask | Mod5Mask )
-#define AllEventMasks (lastEventMask|(lastEventMask-1))
-/*
- * The following relies on the fact that the Button<n>MotionMasks are equal
- * to the corresponding Button<n>Masks from the current modifier/button state.
- */
-#define Motion_Filter(class) (PointerMotionMask | \
- (class)->state | (class)->motionMask)
-
-
-#define WID(w) ((w) ? ((w)->drawable.id) : 0)
-
-#define rClient(obj) (clients[CLIENT_ID((obj)->resource)])
-
-CallbackListPtr EventCallback;
-CallbackListPtr DeviceEventCallback;
-
-#define DNPMCOUNT 8
-
-Mask DontPropagateMasks[DNPMCOUNT];
-static int DontPropagateRefCnts[DNPMCOUNT];
-
-#ifdef DEBUG
-static debug_events = 0;
-#endif
-InputInfo inputInfo;
-
-static struct {
- QdEventPtr pending, *pendtail;
- DeviceIntPtr replayDev; /* kludgy rock to put flag for */
- WindowPtr replayWin; /* ComputeFreezes */
- Bool playingEvents;
- TimeStamp time;
-} syncEvents;
-
-/*
- * The window trace information is used to avoid having to compute all the
- * windows between the root and the current pointer window each time a button
- * or key goes down. The grabs on each of those windows must be checked.
- */
-static WindowPtr *spriteTrace = (WindowPtr *)NULL;
-#define ROOT spriteTrace[0]
-static int spriteTraceSize = 0;
-static int spriteTraceGood;
-
-typedef struct {
- int x, y;
- ScreenPtr pScreen;
-} HotSpot;
-
-static struct {
- CursorPtr current;
- BoxRec hotLimits; /* logical constraints of hot spot */
- Bool confined; /* confined to screen */
-#ifdef SHAPE
- RegionPtr hotShape; /* additional logical shape constraint */
-#endif
- BoxRec physLimits; /* physical constraints of hot spot */
- WindowPtr win; /* window of logical position */
- HotSpot hot; /* logical pointer position */
- HotSpot hotPhys; /* physical pointer position */
-} sprite; /* info about the cursor sprite */
-
-static void DoEnterLeaveEvents(
-#if NeedFunctionPrototypes
- WindowPtr /*fromWin*/,
- WindowPtr /*toWin*/,
- int /*mode*/
-#endif
-);
-
-static WindowPtr XYToWindow(
-#if NeedFunctionPrototypes
- int /*x*/,
- int /*y*/
-#endif
-);
-
-void DeliverFocusedEvent();
-int DeliverDeviceEvents();
-void DoFocusEvents();
-Mask EventMaskForClient();
-Bool CheckDeviceGrabs();
-void EnqueueEvent();
-
-extern GrabPtr CreateGrab(); /* Defined in grabs.c */
-extern Bool GrabMatchesSecond();
-extern Bool DeletePassiveGrabFromList();
-extern int AddPassiveGrabToList();
-
-extern Bool permitOldBugs;
-extern Bool Must_have_memory;
-extern int lastEvent;
-#ifdef XINPUT
-extern int DeviceMotionNotify, DeviceButtonPress, DeviceKeyPress;
-#endif
-
-static Mask lastEventMask;
-
-#define CantBeFiltered NoEventMask
-static Mask filters[128] =
-{
- NoSuchEvent, /* 0 */
- NoSuchEvent, /* 1 */
- KeyPressMask, /* KeyPress */
- KeyReleaseMask, /* KeyRelease */
- ButtonPressMask, /* ButtonPress */
- ButtonReleaseMask, /* ButtonRelease */
- PointerMotionMask, /* MotionNotify (initial state) */
- EnterWindowMask, /* EnterNotify */
- LeaveWindowMask, /* LeaveNotify */
- FocusChangeMask, /* FocusIn */
- FocusChangeMask, /* FocusOut */
- KeymapStateMask, /* KeymapNotify */
- ExposureMask, /* Expose */
- CantBeFiltered, /* GraphicsExpose */
- CantBeFiltered, /* NoExpose */
- VisibilityChangeMask, /* VisibilityNotify */
- SubstructureNotifyMask, /* CreateNotify */
- StructureAndSubMask, /* DestroyNotify */
- StructureAndSubMask, /* UnmapNotify */
- StructureAndSubMask, /* MapNotify */
- SubstructureRedirectMask, /* MapRequest */
- StructureAndSubMask, /* ReparentNotify */
- StructureAndSubMask, /* ConfigureNotify */
- SubstructureRedirectMask, /* ConfigureRequest */
- StructureAndSubMask, /* GravityNotify */
- ResizeRedirectMask, /* ResizeRequest */
- StructureAndSubMask, /* CirculateNotify */
- SubstructureRedirectMask, /* CirculateRequest */
- PropertyChangeMask, /* PropertyNotify */
- CantBeFiltered, /* SelectionClear */
- CantBeFiltered, /* SelectionRequest */
- CantBeFiltered, /* SelectionNotify */
- ColormapChangeMask, /* ColormapNotify */
- CantBeFiltered, /* ClientMessage */
- CantBeFiltered /* MappingNotify */
-};
-
-static CARD8 criticalEvents[32] =
-{
- 0x3c /* key and button events */
-};
-
-Mask
-GetNextEventMask()
-{
- lastEventMask <<= 1;
- return lastEventMask;
-}
-
-void
-SetMaskForEvent(mask, event)
- Mask mask;
- int event;
-{
- if ((event < LASTEvent) || (event >= 128))
- FatalError("SetMaskForEvent: bogus event number");
- filters[event] = mask;
-}
-
-void
-SetCriticalEvent(event)
- int event;
-{
- if (event >= 128)
- FatalError("SetCriticalEvent: bogus event number");
- criticalEvents[event >> 3] |= 1 << (event & 7);
-}
-
-static void
-SyntheticMotion(x, y)
- int x, y;
-{
- xEvent xE;
-
- xE.u.keyButtonPointer.rootX = x;
- xE.u.keyButtonPointer.rootY = y;
- if (syncEvents.playingEvents)
- xE.u.keyButtonPointer.time = syncEvents.time.milliseconds;
- else
- xE.u.keyButtonPointer.time = currentTime.milliseconds;
- xE.u.u.type = MotionNotify;
- (*inputInfo.pointer->public.processInputProc)(&xE, inputInfo.pointer, 1);
-}
-
-#ifdef SHAPE
-#ifdef PANORAMIX
-void
-#else
-static void
-#endif
-ConfineToShape(shape, px, py)
- RegionPtr shape;
- int *px, *py;
-{
- BoxRec box;
- int x = *px, y = *py;
- int incx = 1, incy = 1;
-
- if (POINT_IN_REGION(sprite.hot.pScreen, shape, x, y, &box))
- return;
- box = *REGION_EXTENTS(sprite.hot.pScreen, shape);
- /* this is rather crude */
- do {
- x += incx;
- if (x >= box.x2)
- {
- incx = -1;
- x = *px - 1;
- }
- else if (x < box.x1)
- {
- incx = 1;
- x = *px;
- y += incy;
- if (y >= box.y2)
- {
- incy = -1;
- y = *py - 1;
- }
- else if (y < box.y1)
- return; /* should never get here! */
- }
- } while (!POINT_IN_REGION(sprite.hot.pScreen, shape, x, y, &box));
- *px = x;
- *py = y;
-}
-#endif
-
-static void
-CheckPhysLimits(cursor, generateEvents, confineToScreen, pScreen)
- CursorPtr cursor;
- Bool generateEvents;
- Bool confineToScreen;
- ScreenPtr pScreen;
-{
- HotSpot new;
-
- if (!cursor)
- return;
- new = sprite.hotPhys;
- if (pScreen)
- new.pScreen = pScreen;
- else
- pScreen = new.pScreen;
- (*pScreen->CursorLimits) (pScreen, cursor, &sprite.hotLimits,
- &sprite.physLimits);
- sprite.confined = confineToScreen;
- (* pScreen->ConstrainCursor)(pScreen, &sprite.physLimits);
- if (new.x < sprite.physLimits.x1)
- new.x = sprite.physLimits.x1;
- else
- if (new.x >= sprite.physLimits.x2)
- new.x = sprite.physLimits.x2 - 1;
- if (new.y < sprite.physLimits.y1)
- new.y = sprite.physLimits.y1;
- else
- if (new.y >= sprite.physLimits.y2)
- new.y = sprite.physLimits.y2 - 1;
-#ifdef SHAPE
- if (sprite.hotShape)
- ConfineToShape(sprite.hotShape, &new.x, &new.y);
-#endif
- if ((pScreen != sprite.hotPhys.pScreen) ||
- (new.x != sprite.hotPhys.x) || (new.y != sprite.hotPhys.y))
- {
- if (pScreen != sprite.hotPhys.pScreen)
- sprite.hotPhys = new;
- (*pScreen->SetCursorPosition) (pScreen, new.x, new.y, generateEvents);
- if (!generateEvents)
- SyntheticMotion(new.x, new.y);
- }
-}
-
-static void
-CheckVirtualMotion(qe, pWin)
- register QdEventPtr qe;
- register WindowPtr pWin;
-{
-
- if (qe)
- {
- sprite.hot.pScreen = qe->pScreen;
- sprite.hot.x = qe->event->u.keyButtonPointer.rootX;
- sprite.hot.y = qe->event->u.keyButtonPointer.rootY;
- pWin = inputInfo.pointer->grab ? inputInfo.pointer->grab->confineTo :
- NullWindow;
- }
- if (pWin)
- {
- BoxRec lims;
-
- if (sprite.hot.pScreen != pWin->drawable.pScreen)
- {
- sprite.hot.pScreen = pWin->drawable.pScreen;
- sprite.hot.x = sprite.hot.y = 0;
- }
- lims = *REGION_EXTENTS(pWin->drawable.pScreen, &pWin->borderSize);
- if (sprite.hot.x < lims.x1)
- sprite.hot.x = lims.x1;
- else if (sprite.hot.x >= lims.x2)
- sprite.hot.x = lims.x2 - 1;
- if (sprite.hot.y < lims.y1)
- sprite.hot.y = lims.y1;
- else if (sprite.hot.y >= lims.y2)
- sprite.hot.y = lims.y2 - 1;
-#ifdef SHAPE
- if (wBoundingShape(pWin))
- ConfineToShape(&pWin->borderSize, &sprite.hot.x, &sprite.hot.y);
-#endif
- if (qe)
- {
- qe->pScreen = sprite.hot.pScreen;
- qe->event->u.keyButtonPointer.rootX = sprite.hot.x;
- qe->event->u.keyButtonPointer.rootY = sprite.hot.y;
- }
- }
- ROOT = WindowTable[sprite.hot.pScreen->myNum];
-}
-
-void
-ConfineCursorToWindow(pWin, generateEvents, confineToScreen)
- WindowPtr pWin;
- Bool generateEvents;
- Bool confineToScreen;
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
-
- if (syncEvents.playingEvents)
- {
- CheckVirtualMotion((QdEventPtr)NULL, pWin);
- SyntheticMotion(sprite.hot.x, sprite.hot.y);
- }
- else
- {
- sprite.hotLimits = *REGION_EXTENTS( pScreen, &pWin->borderSize);
-#ifdef SHAPE
- sprite.hotShape = wBoundingShape(pWin) ? &pWin->borderSize
- : NullRegion;
-#endif
- CheckPhysLimits(sprite.current, generateEvents, confineToScreen,
- pScreen);
- }
-}
-
-Bool
-PointerConfinedToScreen()
-{
- return sprite.confined;
-}
-
-static void
-ChangeToCursor(cursor)
- CursorPtr cursor;
-{
- if (cursor != sprite.current)
- {
- if ((sprite.current->bits->xhot != cursor->bits->xhot) ||
- (sprite.current->bits->yhot != cursor->bits->yhot))
- CheckPhysLimits(cursor, FALSE, PointerConfinedToScreen(),
- (ScreenPtr)NULL);
- (*sprite.hotPhys.pScreen->DisplayCursor) (sprite.hotPhys.pScreen,
- cursor);
- sprite.current = cursor;
- }
-}
-
-/* returns true if b is a descendent of a */
-Bool
-IsParent(a, b)
- register WindowPtr a, b;
-{
- for (b = b->parent; b; b = b->parent)
- if (b == a) return TRUE;
- return FALSE;
-}
-
-static void
-PostNewCursor()
-{
- register WindowPtr win;
- register GrabPtr grab = inputInfo.pointer->grab;
-
- if (syncEvents.playingEvents)
- return;
- if (grab)
- {
- if (grab->cursor)
- {
- ChangeToCursor(grab->cursor);
- return;
- }
- if (IsParent(grab->window, sprite.win))
- win = sprite.win;
- else
- win = grab->window;
- }
- else
- win = sprite.win;
- for (; win; win = win->parent)
- if (win->optional && win->optional->cursor != NullCursor)
- {
- ChangeToCursor(win->optional->cursor);
- return;
- }
-}
-
-WindowPtr
-GetCurrentRootWindow()
-{
- return ROOT;
-}
-
-WindowPtr
-GetSpriteWindow()
-{
- return sprite.win;
-}
-
-CursorPtr
-GetSpriteCursor()
-{
- return sprite.current;
-}
-
-void
-GetSpritePosition(px, py)
- int *px, *py;
-{
- *px = sprite.hotPhys.x;
- *py = sprite.hotPhys.y;
-}
-
-#define TIMESLOP (5 * 60 * 1000) /* 5 minutes */
-
-static void
-MonthChangedOrBadTime(xE)
- register xEvent *xE;
-{
- /* If the ddx/OS is careless about not processing timestamped events from
- * different sources in sorted order, then it's possible for time to go
- * backwards when it should not. Here we ensure a decent time.
- */
- if ((currentTime.milliseconds - xE->u.keyButtonPointer.time) > TIMESLOP)
- currentTime.months++;
- else
- xE->u.keyButtonPointer.time = currentTime.milliseconds;
-}
-
-#define NoticeTime(xE) { \
- if ((xE)->u.keyButtonPointer.time < currentTime.milliseconds) \
- MonthChangedOrBadTime(xE); \
- currentTime.milliseconds = (xE)->u.keyButtonPointer.time; \
- lastDeviceEventTime = currentTime; }
-
-void
-NoticeEventTime(xE)
- register xEvent *xE;
-{
- if (!syncEvents.playingEvents)
- NoticeTime(xE);
-}
-
-/**************************************************************************
- * The following procedures deal with synchronous events *
- **************************************************************************/
-
-void
-EnqueueEvent(xE, device, count)
- xEvent *xE;
- DeviceIntPtr device;
- int count;
-{
- register QdEventPtr tail = *syncEvents.pendtail;
- register QdEventPtr qe;
- xEvent *qxE;
-
- NoticeTime(xE);
- if (DeviceEventCallback)
- {
- DeviceEventInfoRec eventinfo;
- /* The RECORD spec says that the root window field of motion events
- * must be valid. At this point, it hasn't been filled in yet, so
- * we do it here. The long expression below is necessary to get
- * the current root window; the apparently reasonable alternative
- * GetCurrentRootWindow()->drawable.id doesn't give you the right
- * answer on the first motion event after a screen change because
- * the data that GetCurrentRootWindow relies on hasn't been
- * updated yet.
- */
- if (xE->u.u.type == MotionNotify)
- xE->u.keyButtonPointer.root =
- WindowTable[sprite.hotPhys.pScreen->myNum]->drawable.id;
- eventinfo.events = xE;
- eventinfo.count = count;
- CallCallbacks(&DeviceEventCallback, (pointer)&eventinfo);
- }
- if (xE->u.u.type == MotionNotify)
- {
- sprite.hotPhys.x = xE->u.keyButtonPointer.rootX;
- sprite.hotPhys.y = xE->u.keyButtonPointer.rootY;
- /* do motion compression */
- if (tail &&
- (tail->event->u.u.type == MotionNotify) &&
- (tail->pScreen == sprite.hotPhys.pScreen))
- {
- tail->event->u.keyButtonPointer.rootX = sprite.hotPhys.x;
- tail->event->u.keyButtonPointer.rootY = sprite.hotPhys.y;
- tail->event->u.keyButtonPointer.time = xE->u.keyButtonPointer.time;
- tail->months = currentTime.months;
- return;
- }
- }
- qe = (QdEventPtr)xalloc(sizeof(QdEventRec) + (count * sizeof(xEvent)));
- if (!qe)
- return;
- qe->next = (QdEventPtr)NULL;
- qe->device = device;
- qe->pScreen = sprite.hotPhys.pScreen;
- qe->months = currentTime.months;
- qe->event = (xEvent *)(qe + 1);
- qe->evcount = count;
- for (qxE = qe->event; --count >= 0; qxE++, xE++)
- *qxE = *xE;
- if (tail)
- syncEvents.pendtail = &tail->next;
- *syncEvents.pendtail = qe;
-}
-
-static void
-PlayReleasedEvents()
-{
- register QdEventPtr *prev, qe;
- register DeviceIntPtr dev;
-
- prev = &syncEvents.pending;
- while ( (qe = *prev) )
- {
- if (!qe->device->sync.frozen)
- {
- *prev = qe->next;
- if (*syncEvents.pendtail == *prev)
- syncEvents.pendtail = prev;
- if (qe->event->u.u.type == MotionNotify)
- CheckVirtualMotion(qe, NullWindow);
- syncEvents.time.months = qe->months;
- syncEvents.time.milliseconds = qe->event->u.keyButtonPointer.time;
- (*qe->device->public.processInputProc)(qe->event, qe->device,
- qe->evcount);
- xfree(qe);
- for (dev = inputInfo.devices; dev && dev->sync.frozen; dev = dev->next)
- ;
- if (!dev)
- break;
- /* Playing the event may have unfrozen another device. */
- /* So to play it safe, restart at the head of the queue */
- prev = &syncEvents.pending;
- }
- else
- prev = &qe->next;
- }
-}
-
-static void
-FreezeThaw(dev, frozen)
- register DeviceIntPtr dev;
- Bool frozen;
-{
- dev->sync.frozen = frozen;
- if (frozen)
- dev->public.processInputProc = dev->public.enqueueInputProc;
- else
- dev->public.processInputProc = dev->public.realInputProc;
-}
-
-void
-ComputeFreezes()
-{
- register DeviceIntPtr replayDev = syncEvents.replayDev;
- register int i;
- WindowPtr w;
- register xEvent *xE;
- int count;
- GrabPtr grab;
- register DeviceIntPtr dev;
-
- for (dev = inputInfo.devices; dev; dev = dev->next)
- FreezeThaw(dev, dev->sync.other || (dev->sync.state >= FROZEN));
- if (syncEvents.playingEvents || (!replayDev && !syncEvents.pending))
- return;
- syncEvents.playingEvents = TRUE;
- if (replayDev)
- {
-#ifdef PANORAMIX
- int j;
- WindowPtr tempw;
- PanoramiXWindow *pPanoramiXWin = PanoramiXWinRoot;
-#endif
- xE = replayDev->sync.event;
- count = replayDev->sync.evcount;
- syncEvents.replayDev = (DeviceIntPtr)NULL;
-#ifdef PANORAMIX
- if (!noPanoramiXExtension) {
- for (j = PanoramiXNumScreens - 1; j>=0; j--)
- if (XE_PTR.rootX >= panoramiXdataPtr[j].x
- && XE_PTR.rootX < (panoramiXdataPtr[j].x + panoramiXdataPtr[j].width)
- && XE_PTR.rootY >= panoramiXdataPtr[j].y
- && XE_PTR.rootY < (panoramiXdataPtr[j].y +panoramiXdataPtr[j].height))
- break;
- XE_PTR.rootX -= panoramiXdataPtr[j].x;
- XE_PTR.rootY -= panoramiXdataPtr[j].y;
- XE_PTR.eventX -= panoramiXdataPtr[j].x;
- XE_PTR.eventY -= panoramiXdataPtr[j].y;
- w = XYToWindow(XE_PTR.rootX, XE_PTR.rootY);
- }else
-#endif
- w = XYToWindow(
- xE->u.keyButtonPointer.rootX, xE->u.keyButtonPointer.rootY);
-#ifdef PANORAMIX
- if (!noPanoramiXExtension) {
- for (i = 0; i < spriteTraceGood; i++) {
- tempw = spriteTrace[i];
- j = (tempw->drawable.pScreen)->myNum;
- PANORAMIXFIND_ID_BY_SCRNUM(pPanoramiXWin, tempw->drawable.id, j);
- j = ((syncEvents.replayWin)->drawable.pScreen)->myNum;
- if (pPanoramiXWin)
- tempw = (WindowPtr)
- LookupIDByType(pPanoramiXWin->info[0].id, RT_WINDOW);
-
- if (syncEvents.replayWin == tempw) {
- if (!CheckDeviceGrabs(replayDev, xE, i+1, count))
- if (replayDev->focus)
- DeliverFocusedEvent(replayDev, xE, w, count);
- else
- DeliverDeviceEvents(w, xE, NullGrab, NullWindow,
- replayDev, count);
- goto playmore;
- }
- } /* for */
- } else { /* if !noPanoramiXExtension */
-#endif
- for (i = 0; i < spriteTraceGood; i++)
- if (syncEvents.replayWin == spriteTrace[i])
- {
- if (!CheckDeviceGrabs(replayDev, xE, i+1, count))
- if (replayDev->focus)
- DeliverFocusedEvent(replayDev, xE, w, count);
- else
- DeliverDeviceEvents(w, xE, NullGrab, NullWindow,
- replayDev, count);
- goto playmore;
- }
-#ifdef PANORAMIX
- }
-#endif
- /* must not still be in the same stack */
- if (replayDev->focus)
- DeliverFocusedEvent(replayDev, xE, w, count);
- else
- DeliverDeviceEvents(w, xE, NullGrab, NullWindow, replayDev, count);
- }
-playmore:
- for (dev = inputInfo.devices; dev; dev = dev->next)
- {
- if (!dev->sync.frozen)
- {
- PlayReleasedEvents();
- break;
- }
- }
- syncEvents.playingEvents = FALSE;
- /* the following may have been skipped during replay, so do it now */
- if ((grab = inputInfo.pointer->grab) && grab->confineTo)
- {
- if (grab->confineTo->drawable.pScreen != sprite.hotPhys.pScreen)
- sprite.hotPhys.x = sprite.hotPhys.y = 0;
- ConfineCursorToWindow(grab->confineTo, TRUE, TRUE);
- }
- else
- ConfineCursorToWindow(WindowTable[sprite.hotPhys.pScreen->myNum],
- TRUE, FALSE);
- PostNewCursor();
-}
-
-void
-CheckGrabForSyncs(thisDev, thisMode, otherMode)
- register DeviceIntPtr thisDev;
- Bool thisMode, otherMode;
-{
- register GrabPtr grab = thisDev->grab;
- register DeviceIntPtr dev;
-
- if (thisMode == GrabModeSync)
- thisDev->sync.state = FROZEN_NO_EVENT;
- else
- { /* free both if same client owns both */
- thisDev->sync.state = THAWED;
- if (thisDev->sync.other &&
- (CLIENT_BITS(thisDev->sync.other->resource) ==
- CLIENT_BITS(grab->resource)))
- thisDev->sync.other = NullGrab;
- }
- for (dev = inputInfo.devices; dev; dev = dev->next)
- {
- if (dev != thisDev)
- {
- if (otherMode == GrabModeSync)
- dev->sync.other = grab;
- else
- { /* free both if same client owns both */
- if (dev->sync.other &&
- (CLIENT_BITS(dev->sync.other->resource) ==
- CLIENT_BITS(grab->resource)))
- dev->sync.other = NullGrab;
- }
- }
- }
- ComputeFreezes();
-}
-
-void
-ActivatePointerGrab(mouse, grab, time, autoGrab)
- register GrabPtr grab;
- register DeviceIntPtr mouse;
- TimeStamp time;
- Bool autoGrab;
-{
- WindowPtr oldWin = (mouse->grab) ? mouse->grab->window
- : sprite.win;
-
- if (grab->confineTo)
- {
- if (grab->confineTo->drawable.pScreen != sprite.hotPhys.pScreen)
- sprite.hotPhys.x = sprite.hotPhys.y = 0;
-#ifdef PANORAMIX
- if ((!noPanoramiXExtension) &&
- ( grab->confineTo->drawable.x + grab->confineTo->drawable.width >
- (grab->confineTo->drawable.pScreen)->width ||
- grab->confineTo->drawable.x < 0) )
- ConfineCursorToWindow(grab->confineTo, FALSE, FALSE);
- else
-#endif
- ConfineCursorToWindow(grab->confineTo, FALSE, TRUE);
- }
- DoEnterLeaveEvents(oldWin, grab->window, NotifyGrab);
- mouse->valuator->motionHintWindow = NullWindow;
- if (syncEvents.playingEvents)
- mouse->grabTime = syncEvents.time;
- else
- mouse->grabTime = time;
- if (grab->cursor)
- grab->cursor->refcnt++;
- mouse->activeGrab = *grab;
- mouse->grab = &mouse->activeGrab;
- mouse->fromPassiveGrab = autoGrab;
- PostNewCursor();
- CheckGrabForSyncs(mouse,
- (Bool)grab->pointerMode, (Bool)grab->keyboardMode);
-}
-
-void
-DeactivatePointerGrab(mouse)
- register DeviceIntPtr mouse;
-{
- register GrabPtr grab = mouse->grab;
- register DeviceIntPtr dev;
-
- mouse->valuator->motionHintWindow = NullWindow;
- mouse->grab = NullGrab;
- mouse->sync.state = NOT_GRABBED;
- mouse->fromPassiveGrab = FALSE;
- for (dev = inputInfo.devices; dev; dev = dev->next)
- {
- if (dev->sync.other == grab)
- dev->sync.other = NullGrab;
- }
- DoEnterLeaveEvents(grab->window, sprite.win, NotifyUngrab);
- if (grab->confineTo)
- ConfineCursorToWindow(ROOT, FALSE, FALSE);
- PostNewCursor();
- if (grab->cursor)
- FreeCursor(grab->cursor, (Cursor)0);
- ComputeFreezes();
-}
-
-void
-ActivateKeyboardGrab(keybd, grab, time, passive)
- register DeviceIntPtr keybd;
- GrabPtr grab;
- TimeStamp time;
- Bool passive;
-{
- WindowPtr oldWin;
-
- if (keybd->grab)
- oldWin = keybd->grab->window;
- else if (keybd->focus)
- oldWin = keybd->focus->win;
- else
- oldWin = sprite.win;
- if (oldWin == FollowKeyboardWin)
- oldWin = inputInfo.keyboard->focus->win;
- if (keybd->valuator)
- keybd->valuator->motionHintWindow = NullWindow;
- DoFocusEvents(keybd, oldWin, grab->window, NotifyGrab);
- if (syncEvents.playingEvents)
- keybd->grabTime = syncEvents.time;
- else
- keybd->grabTime = time;
- keybd->activeGrab = *grab;
- keybd->grab = &keybd->activeGrab;
- keybd->fromPassiveGrab = passive;
- CheckGrabForSyncs(keybd,
- (Bool)grab->keyboardMode, (Bool)grab->pointerMode);
-}
-
-void
-DeactivateKeyboardGrab(keybd)
- register DeviceIntPtr keybd;
-{
- register GrabPtr grab = keybd->grab;
- register DeviceIntPtr dev;
- register WindowPtr focusWin = keybd->focus ? keybd->focus->win
- : sprite.win;
-
- if (focusWin == FollowKeyboardWin)
- focusWin = inputInfo.keyboard->focus->win;
- if (keybd->valuator)
- keybd->valuator->motionHintWindow = NullWindow;
- keybd->grab = NullGrab;
- keybd->sync.state = NOT_GRABBED;
- keybd->fromPassiveGrab = FALSE;
- for (dev = inputInfo.devices; dev; dev = dev->next)
- {
- if (dev->sync.other == grab)
- dev->sync.other = NullGrab;
- }
- DoFocusEvents(keybd, grab->window, focusWin, NotifyUngrab);
- ComputeFreezes();
-}
-
-void
-AllowSome(client, time, thisDev, newState)
- ClientPtr client;
- TimeStamp time;
- register DeviceIntPtr thisDev;
- int newState;
-{
- Bool thisGrabbed, otherGrabbed, othersFrozen, thisSynced;
- TimeStamp grabTime;
- register DeviceIntPtr dev;
-
- thisGrabbed = thisDev->grab && SameClient(thisDev->grab, client);
- thisSynced = FALSE;
- otherGrabbed = FALSE;
- othersFrozen = TRUE;
- grabTime = thisDev->grabTime;
- for (dev = inputInfo.devices; dev; dev = dev->next)
- {
- if (dev == thisDev)
- continue;
- if (dev->grab && SameClient(dev->grab, client))
- {
- if (!(thisGrabbed || otherGrabbed) ||
- (CompareTimeStamps(dev->grabTime, grabTime) == LATER))
- grabTime = dev->grabTime;
- otherGrabbed = TRUE;
- if (thisDev->sync.other == dev->grab)
- thisSynced = TRUE;
- if (dev->sync.state < FROZEN)
- othersFrozen = FALSE;
- }
- else if (!dev->sync.other || !SameClient(dev->sync.other, client))
- othersFrozen = FALSE;
- }
- if (!((thisGrabbed && thisDev->sync.state >= FROZEN) || thisSynced))
- return;
- if ((CompareTimeStamps(time, currentTime) == LATER) ||
- (CompareTimeStamps(time, grabTime) == EARLIER))
- return;
- switch (newState)
- {
- case THAWED: /* Async */
- if (thisGrabbed)
- thisDev->sync.state = THAWED;
- if (thisSynced)
- thisDev->sync.other = NullGrab;
- ComputeFreezes();
- break;
- case FREEZE_NEXT_EVENT: /* Sync */
- if (thisGrabbed)
- {
- thisDev->sync.state = FREEZE_NEXT_EVENT;
- if (thisSynced)
- thisDev->sync.other = NullGrab;
- ComputeFreezes();
- }
- break;
- case THAWED_BOTH: /* AsyncBoth */
- if (othersFrozen)
- {
- for (dev = inputInfo.devices; dev; dev = dev->next)
- {
- if (dev->grab && SameClient(dev->grab, client))
- dev->sync.state = THAWED;
- if (dev->sync.other && SameClient(dev->sync.other, client))
- dev->sync.other = NullGrab;
- }
- ComputeFreezes();
- }
- break;
- case FREEZE_BOTH_NEXT_EVENT: /* SyncBoth */
- if (othersFrozen)
- {
- for (dev = inputInfo.devices; dev; dev = dev->next)
- {
- if (dev->grab && SameClient(dev->grab, client))
- dev->sync.state = FREEZE_BOTH_NEXT_EVENT;
- if (dev->sync.other && SameClient(dev->sync.other, client))
- dev->sync.other = NullGrab;
- }
- ComputeFreezes();
- }
- break;
- case NOT_GRABBED: /* Replay */
- if (thisGrabbed && thisDev->sync.state == FROZEN_WITH_EVENT)
- {
- if (thisSynced)
- thisDev->sync.other = NullGrab;
- syncEvents.replayDev = thisDev;
- syncEvents.replayWin = thisDev->grab->window;
- (*thisDev->DeactivateGrab)(thisDev);
- syncEvents.replayDev = (DeviceIntPtr)NULL;
- }
- break;
- case THAW_OTHERS: /* AsyncOthers */
- if (othersFrozen)
- {
- for (dev = inputInfo.devices; dev; dev = dev->next)
- {
- if (dev == thisDev)
- continue;
- if (dev->grab && SameClient(dev->grab, client))
- dev->sync.state = THAWED;
- if (dev->sync.other && SameClient(dev->sync.other, client))
- dev->sync.other = NullGrab;
- }
- ComputeFreezes();
- }
- break;
- }
-}
-
-int
-ProcAllowEvents(client)
- register ClientPtr client;
-{
- TimeStamp time;
- DeviceIntPtr mouse = inputInfo.pointer;
- DeviceIntPtr keybd = inputInfo.keyboard;
- REQUEST(xAllowEventsReq);
-
- REQUEST_SIZE_MATCH(xAllowEventsReq);
- time = ClientTimeToServerTime(stuff->time);
- switch (stuff->mode)
- {
- case ReplayPointer:
- AllowSome(client, time, mouse, NOT_GRABBED);
- break;
- case SyncPointer:
- AllowSome(client, time, mouse, FREEZE_NEXT_EVENT);
- break;
- case AsyncPointer:
- AllowSome(client, time, mouse, THAWED);
- break;
- case ReplayKeyboard:
- AllowSome(client, time, keybd, NOT_GRABBED);
- break;
- case SyncKeyboard:
- AllowSome(client, time, keybd, FREEZE_NEXT_EVENT);
- break;
- case AsyncKeyboard:
- AllowSome(client, time, keybd, THAWED);
- break;
- case SyncBoth:
- AllowSome(client, time, keybd, FREEZE_BOTH_NEXT_EVENT);
- break;
- case AsyncBoth:
- AllowSome(client, time, keybd, THAWED_BOTH);
- break;
- default:
- client->errorValue = stuff->mode;
- return BadValue;
- }
- return Success;
-}
-
-void
-ReleaseActiveGrabs(client)
- ClientPtr client;
-{
- register DeviceIntPtr dev;
- Bool done;
-
- /* XXX CloseDownClient should remove passive grabs before
- * releasing active grabs.
- */
- do {
- done = TRUE;
- for (dev = inputInfo.devices; dev; dev = dev->next)
- {
- if (dev->grab && SameClient(dev->grab, client))
- {
- (*dev->DeactivateGrab)(dev);
- done = FALSE;
- }
- }
- } while (!done);
-}
-
-/**************************************************************************
- * The following procedures deal with delivering events *
- **************************************************************************/
-
-int
-TryClientEvents (client, pEvents, count, mask, filter, grab)
- ClientPtr client;
- GrabPtr grab;
- xEvent *pEvents;
- int count;
- Mask mask, filter;
-{
- int i;
- int type;
-
-#ifdef DEBUG
- if (debug_events) ErrorF(
- "Event([%d, %d], mask=0x%x), client=%d",
- pEvents->u.u.type, pEvents->u.u.detail, mask, client->index);
-#endif
- if ((client) && (client != serverClient) && (!client->clientGone) &&
- ((filter == CantBeFiltered) || (mask & filter)))
- {
- if (grab && !SameClient(grab, client))
- return -1; /* don't send, but notify caller */
- type = pEvents->u.u.type;
- if (type == MotionNotify)
- {
- if (mask & PointerMotionHintMask)
- {
- if (WID(inputInfo.pointer->valuator->motionHintWindow) ==
- pEvents->u.keyButtonPointer.event)
- {
-#ifdef DEBUG
- if (debug_events) ErrorF("\n");
- fprintf(stderr,"motionHintWindow == keyButtonPointer.event\n");
-#endif
- return 1; /* don't send, but pretend we did */
- }
- pEvents->u.u.detail = NotifyHint;
- }
- else
- {
- pEvents->u.u.detail = NotifyNormal;
- }
- }
-#ifdef XINPUT
- else
- {
- if ((type == DeviceMotionNotify) &&
- MaybeSendDeviceMotionNotifyHint (pEvents, mask) != 0)
- return 1;
- }
-#endif
- type &= 0177;
- if (type != KeymapNotify)
- {
- /* all extension events must have a sequence number */
- for (i = 0; i < count; i++)
- pEvents[i].u.u.sequenceNumber = client->sequence;
- }
-
- if (BitIsOn(criticalEvents, type))
- SetCriticalOutputPending();
-
- WriteEventsToClient(client, count, pEvents);
-#ifdef DEBUG
- if (debug_events) ErrorF( " delivered\n");
-#endif
- return 1;
- }
- else
- {
-#ifdef DEBUG
- if (debug_events) ErrorF("\n");
-#endif
- return 0;
- }
-}
-
-int
-DeliverEventsToWindow(pWin, pEvents, count, filter, grab, mskidx)
- register WindowPtr pWin;
- GrabPtr grab;
- xEvent *pEvents;
- int count;
- Mask filter;
- int mskidx;
-{
- int deliveries = 0, nondeliveries = 0;
- int attempt;
- register InputClients *other;
- ClientPtr client = NullClient;
- Mask deliveryMask; /* If a grab occurs due to a button press, then
- this mask is the mask of the grab. */
- int type = pEvents->u.u.type;
-
- /* CantBeFiltered means only window owner gets the event */
- if ((filter == CantBeFiltered) || !(type & EXTENSION_EVENT_BASE))
- {
- /* if nobody ever wants to see this event, skip some work */
- if (filter != CantBeFiltered &&
- !((wOtherEventMasks(pWin)|pWin->eventMask) & filter))
- return 0;
- if ( (attempt = TryClientEvents(wClient(pWin), pEvents, count,
- pWin->eventMask, filter, grab)) )
- {
- if (attempt > 0)
- {
- deliveries++;
- client = wClient(pWin);
- deliveryMask = pWin->eventMask;
- } else
- nondeliveries--;
- }
- }
- if (filter != CantBeFiltered)
- {
- if (type & EXTENSION_EVENT_BASE)
- {
- OtherInputMasks *inputMasks;
-
- inputMasks = wOtherInputMasks(pWin);
- if (!inputMasks ||
- !(inputMasks->inputEvents[mskidx] & filter))
- return 0;
- other = inputMasks->inputClients;
- }
- else
- other = (InputClients *)wOtherClients(pWin);
- for (; other; other = other->next)
- {
- if ( (attempt = TryClientEvents(rClient(other), pEvents, count,
- other->mask[mskidx], filter, grab)) )
- {
- if (attempt > 0)
- {
- deliveries++;
- client = rClient(other);
- deliveryMask = other->mask[mskidx];
- } else
- nondeliveries--;
- }
- }
- }
- if ((type == ButtonPress) && deliveries && (!grab))
- {
- GrabRec tempGrab;
-
- tempGrab.device = inputInfo.pointer;
- tempGrab.resource = client->clientAsMask;
- tempGrab.window = pWin;
- tempGrab.ownerEvents = (deliveryMask & OwnerGrabButtonMask) ? TRUE : FALSE;
- tempGrab.eventMask = deliveryMask;
- tempGrab.keyboardMode = GrabModeAsync;
- tempGrab.pointerMode = GrabModeAsync;
- tempGrab.confineTo = NullWindow;
- tempGrab.cursor = NullCursor;
- (*inputInfo.pointer->ActivateGrab)(inputInfo.pointer, &tempGrab,
- currentTime, TRUE);
- }
- else if ((type == MotionNotify) && deliveries)
- inputInfo.pointer->valuator->motionHintWindow = pWin;
-#ifdef XINPUT
- else
- {
- if (((type == DeviceMotionNotify) || (type == DeviceButtonPress)) &&
- deliveries)
- CheckDeviceGrabAndHintWindow (pWin, type, pEvents, grab, client,
- deliveryMask);
- }
-#endif
- if (deliveries)
- return deliveries;
- return nondeliveries;
-}
-
-/* If the event goes to dontClient, don't send it and return 0. if
- send works, return 1 or if send didn't work, return 2.
- Only works for core events.
-*/
-
-int
-MaybeDeliverEventsToClient(pWin, pEvents, count, filter, dontClient)
- register WindowPtr pWin;
- xEvent *pEvents;
- int count;
- Mask filter;
- ClientPtr dontClient;
-{
- register OtherClients *other;
-
- if (pWin->eventMask & filter)
- {
- if (wClient(pWin) == dontClient)
- return 0;
- return TryClientEvents(wClient(pWin), pEvents, count,
- pWin->eventMask, filter, NullGrab);
- }
- for (other = wOtherClients(pWin); other; other = other->next)
- {
- if (other->mask & filter)
- {
- if (SameClient(other, dontClient))
- return 0;
- return TryClientEvents(rClient(other), pEvents, count,
- other->mask, filter, NullGrab);
- }
- }
- return 2;
-}
-
-static void
-FixUpEventFromWindow(xE, pWin, child, calcChild)
- xEvent *xE;
- WindowPtr pWin;
- Window child;
- Bool calcChild;
-{
-
-#ifdef PANORAMIX
- int j;
- int k = (pWin->drawable.pScreen)->myNum;
- PanoramiXWindow *pPanoramiXWin = PanoramiXWinRoot;
-#endif
-
- if (calcChild)
- {
- WindowPtr w=spriteTrace[spriteTraceGood-1];
-#ifdef PANORAMIX
- if (!noPanoramiXExtension){
- j = (w->drawable.pScreen)->myNum;
- PANORAMIXFIND_ID_BY_SCRNUM(pPanoramiXWin, w->drawable.id, j);
- if (pPanoramiXWin)
- w = (WindowPtr)LookupIDByType(pPanoramiXWin->info[k].id, RT_WINDOW);
- }
-#endif
- /* If the search ends up past the root should the child field be
- set to none or should the value in the argument be passed
- through. It probably doesn't matter since everyone calls
- this function with child == None anyway. */
-
- while (w)
- {
- /* If the source window is same as event window, child should be
- none. Don't bother going all all the way back to the root. */
-
- if (w == pWin)
- {
- child = None;
- break;
- }
-
- if (w->parent == pWin)
- {
- child = w->drawable.id;
- break;
- }
- w = w->parent;
- }
- }
- xE->u.keyButtonPointer.root = ROOT->drawable.id;
-#ifdef PANORAMIX
- if (!noPanoramiXExtension){
- pPanoramiXWin=PanoramiXWinRoot;
- PANORAMIXFIND_ID_BY_SCRNUM(pPanoramiXWin, pWin->drawable.id, k);
- if (pPanoramiXWin)
- pWin = (WindowPtr)LookupIDByType(pPanoramiXWin->info[0].id, RT_WINDOW);
- if (pWin) {
- xE->u.keyButtonPointer.event = pWin->drawable.id;
- xE->u.keyButtonPointer.eventX = xE->u.keyButtonPointer.rootX -
- pWin->drawable.x +
- panoramiXdataPtr[sprite.hot.pScreen->myNum].x;
- xE->u.keyButtonPointer.eventY = xE->u.keyButtonPointer.rootY -
- pWin->drawable.y +
- panoramiXdataPtr[sprite.hot.pScreen->myNum].y;
- }else if (pPanoramiXWin)
- xE->u.keyButtonPointer.event = pPanoramiXWin->info[0].id;
- xE->u.keyButtonPointer.sameScreen = xTrue;
- xE->u.keyButtonPointer.child = child;
- }
- else {
-#endif
- xE->u.keyButtonPointer.event = pWin->drawable.id;
- if (sprite.hot.pScreen == pWin->drawable.pScreen)
- {
- xE->u.keyButtonPointer.sameScreen = xTrue;
- xE->u.keyButtonPointer.child = child;
- xE->u.keyButtonPointer.eventX =
- xE->u.keyButtonPointer.rootX - pWin->drawable.x;
- xE->u.keyButtonPointer.eventY =
- xE->u.keyButtonPointer.rootY - pWin->drawable.y;
- }
- else
- {
- xE->u.keyButtonPointer.sameScreen = xFalse;
- xE->u.keyButtonPointer.child = None;
- xE->u.keyButtonPointer.eventX = 0;
- xE->u.keyButtonPointer.eventY = 0;
- }
-#ifdef PANORAMIX
- }
-#endif
-}
-
-int
-DeliverDeviceEvents(pWin, xE, grab, stopAt, dev, count)
- register WindowPtr pWin, stopAt;
- register xEvent *xE;
- GrabPtr grab;
- DeviceIntPtr dev;
- int count;
-{
- Window child = None;
- int type = xE->u.u.type;
- Mask filter = filters[type];
- int deliveries = 0;
-
- if (type & EXTENSION_EVENT_BASE)
- {
- register OtherInputMasks *inputMasks;
- int mskidx = dev->id;
-
- inputMasks = wOtherInputMasks(pWin);
- if (inputMasks && !(filter & inputMasks->deliverableEvents[mskidx]))
- return 0;
- while (pWin)
- {
- if (inputMasks && (inputMasks->inputEvents[mskidx] & filter))
- {
- FixUpEventFromWindow(xE, pWin, child, FALSE);
- deliveries = DeliverEventsToWindow(pWin, xE, count, filter,
- grab, mskidx);
- if (deliveries > 0)
- return deliveries;
- }
- if ((deliveries < 0) ||
- (pWin == stopAt) ||
- (inputMasks &&
- (filter & inputMasks->dontPropagateMask[mskidx])))
- return 0;
- child = pWin->drawable.id;
- pWin = pWin->parent;
- if (pWin)
- inputMasks = wOtherInputMasks(pWin);
- }
- }
- else
- {
- if (!(filter & pWin->deliverableEvents))
- return 0;
- while (pWin)
- {
- if ((wOtherEventMasks(pWin)|pWin->eventMask) & filter)
- {
- FixUpEventFromWindow(xE, pWin, child, FALSE);
- deliveries = DeliverEventsToWindow(pWin, xE, count, filter,
- grab, 0);
- if (deliveries > 0)
- return deliveries;
- }
- if ((deliveries < 0) ||
- (pWin == stopAt) ||
- (filter & wDontPropagateMask(pWin)))
- return 0;
- child = pWin->drawable.id;
- pWin = pWin->parent;
- }
- }
- return 0;
-}
-
-/* not useful for events that propagate up the tree or extension events */
-int
-DeliverEvents(pWin, xE, count, otherParent)
- register WindowPtr pWin, otherParent;
- register xEvent *xE;
- int count;
-{
- Mask filter;
- int deliveries;
-
- if (!count)
- return 0;
- filter = filters[xE->u.u.type];
- if ((filter & SubstructureNotifyMask) && (xE->u.u.type != CreateNotify))
- xE->u.destroyNotify.event = pWin->drawable.id;
- if (filter != StructureAndSubMask)
- return DeliverEventsToWindow(pWin, xE, count, filter, NullGrab, 0);
- deliveries = DeliverEventsToWindow(pWin, xE, count, StructureNotifyMask,
- NullGrab, 0);
- if (pWin->parent)
- {
- xE->u.destroyNotify.event = pWin->parent->drawable.id;
- deliveries += DeliverEventsToWindow(pWin->parent, xE, count,
- SubstructureNotifyMask, NullGrab,
- 0);
- if (xE->u.u.type == ReparentNotify)
- {
- xE->u.destroyNotify.event = otherParent->drawable.id;
- deliveries += DeliverEventsToWindow(otherParent, xE, count,
- SubstructureNotifyMask,
- NullGrab, 0);
- }
- }
- return deliveries;
-}
-
-static WindowPtr
-XYToWindow(x, y)
- int x, y;
-{
- register WindowPtr pWin;
-#ifdef SHAPE
- BoxRec box;
-#endif
-
- spriteTraceGood = 1; /* root window still there */
- pWin = ROOT->firstChild;
- while (pWin)
- {
- if ((pWin->mapped) &&
- (x >= pWin->drawable.x - wBorderWidth (pWin)) &&
- (x < pWin->drawable.x + (int)pWin->drawable.width +
- wBorderWidth(pWin)) &&
- (y >= pWin->drawable.y - wBorderWidth (pWin)) &&
- (y < pWin->drawable.y + (int)pWin->drawable.height +
- wBorderWidth (pWin))
-#ifdef SHAPE
- /* When a window is shaped, a further check
- * is made to see if the point is inside
- * borderSize
- */
- && (!wBoundingShape(pWin) ||
- POINT_IN_REGION(pWin->drawable.pScreen,
- &pWin->borderSize, x, y, &box))
-#endif
- )
- {
- if (spriteTraceGood >= spriteTraceSize)
- {
- spriteTraceSize += 10;
- Must_have_memory = TRUE; /* XXX */
- spriteTrace = (WindowPtr *)xrealloc(
- spriteTrace, spriteTraceSize*sizeof(WindowPtr));
- Must_have_memory = FALSE; /* XXX */
- }
- spriteTrace[spriteTraceGood++] = pWin;
- pWin = pWin->firstChild;
- }
- else
- pWin = pWin->nextSib;
- }
- return spriteTrace[spriteTraceGood-1];
-}
-
-static Bool
-CheckMotion(xE)
- xEvent *xE;
-{
- WindowPtr prevSpriteWin = sprite.win;
-
- if (xE && !syncEvents.playingEvents)
- {
- if (sprite.hot.pScreen != sprite.hotPhys.pScreen)
- {
- sprite.hot.pScreen = sprite.hotPhys.pScreen;
- ROOT = WindowTable[sprite.hot.pScreen->myNum];
- }
- sprite.hot.x = xE->u.keyButtonPointer.rootX;
- sprite.hot.y = xE->u.keyButtonPointer.rootY;
- if (sprite.hot.x < sprite.physLimits.x1)
- sprite.hot.x = sprite.physLimits.x1;
- else if (sprite.hot.x >= sprite.physLimits.x2)
- sprite.hot.x = sprite.physLimits.x2 - 1;
- if (sprite.hot.y < sprite.physLimits.y1)
- sprite.hot.y = sprite.physLimits.y1;
- else if (sprite.hot.y >= sprite.physLimits.y2)
- sprite.hot.y = sprite.physLimits.y2 - 1;
-#ifdef SHAPE
- if (sprite.hotShape)
- ConfineToShape(sprite.hotShape, &sprite.hot.x, &sprite.hot.y);
-#endif
- sprite.hotPhys = sprite.hot;
- if ((sprite.hotPhys.x != xE->u.keyButtonPointer.rootX) ||
- (sprite.hotPhys.y != xE->u.keyButtonPointer.rootY))
- (*sprite.hotPhys.pScreen->SetCursorPosition)(
- sprite.hotPhys.pScreen,
- sprite.hotPhys.x, sprite.hotPhys.y, FALSE);
- xE->u.keyButtonPointer.rootX = sprite.hot.x;
- xE->u.keyButtonPointer.rootY = sprite.hot.y;
- }
-
- sprite.win = XYToWindow(sprite.hot.x, sprite.hot.y);
-#ifdef notyet
- if (!(sprite.win->deliverableEvents &
- Motion_Filter(inputInfo.pointer->button))
- !syncEvents.playingEvents)
- {
- /* XXX Do PointerNonInterestBox here */
- }
-#endif
- if (sprite.win != prevSpriteWin)
- {
- if (prevSpriteWin != NullWindow) {
- if (!xE)
- UpdateCurrentTimeIf();
- DoEnterLeaveEvents(prevSpriteWin, sprite.win, NotifyNormal);
- }
- PostNewCursor();
- return FALSE;
- }
- return TRUE;
-}
-
-void
-WindowsRestructured()
-{
- (void) CheckMotion((xEvent *)NULL);
-}
-
-void
-DefineInitialRootWindow(win)
- register WindowPtr win;
-{
- register ScreenPtr pScreen = win->drawable.pScreen;
-
- sprite.hotPhys.pScreen = pScreen;
- sprite.hotPhys.x = pScreen->width / 2;
- sprite.hotPhys.y = pScreen->height / 2;
- sprite.hot = sprite.hotPhys;
- sprite.hotLimits.x2 = pScreen->width;
- sprite.hotLimits.y2 = pScreen->height;
- sprite.win = win;
- sprite.current = wCursor (win);
- spriteTraceGood = 1;
- ROOT = win;
- (*pScreen->CursorLimits) (
- pScreen, sprite.current, &sprite.hotLimits, &sprite.physLimits);
- sprite.confined = FALSE;
- (*pScreen->ConstrainCursor) (pScreen, &sprite.physLimits);
- (*pScreen->SetCursorPosition) (pScreen, sprite.hot.x, sprite.hot.y, FALSE);
- (*pScreen->DisplayCursor) (pScreen, sprite.current);
-}
-
-/*
- * This does not take any shortcuts, and even ignores its argument, since
- * it does not happen very often, and one has to walk up the tree since
- * this might be a newly instantiated cursor for an intermediate window
- * between the one the pointer is in and the one that the last cursor was
- * instantiated from.
- */
-/*ARGSUSED*/
-void
-WindowHasNewCursor(pWin)
- WindowPtr pWin;
-{
- PostNewCursor();
-}
-
-void
-NewCurrentScreen(newScreen, x, y)
- ScreenPtr newScreen;
- int x,y;
-{
- sprite.hotPhys.x = x;
- sprite.hotPhys.y = y;
- if (newScreen != sprite.hotPhys.pScreen)
- ConfineCursorToWindow(WindowTable[newScreen->myNum], TRUE, FALSE);
-}
-
-int
-ProcWarpPointer(client)
- ClientPtr client;
-{
- WindowPtr dest = NULL;
- int x, y;
- ScreenPtr newScreen;
-#ifdef PANORAMIX
- int i, softx, softy;
- WindowPtr sWin = NULL;
- ScreenPtr sftScreen;
- PanoramiXWindow *pPanoramiXWin = PanoramiXWinRoot;
-#endif
-
- REQUEST(xWarpPointerReq);
-
- REQUEST_SIZE_MATCH(xWarpPointerReq);
- if (stuff->dstWid != None)
- {
- dest = SecurityLookupWindow(stuff->dstWid, client, SecurityReadAccess);
- if (!dest)
- return BadWindow;
- }
- x = sprite.hotPhys.x;
- y = sprite.hotPhys.y;
- if (stuff->srcWid != None)
- {
- int winX, winY;
- WindowPtr source = SecurityLookupWindow(stuff->srcWid, client,
- SecurityReadAccess);
- if (!source)
- return BadWindow;
- winX = source->drawable.x;
- winY = source->drawable.y;
- if (source->drawable.pScreen != sprite.hotPhys.pScreen ||
- x < winX + stuff->srcX ||
- y < winY + stuff->srcY ||
- (stuff->srcWidth != 0 &&
- winX + stuff->srcX + (int)stuff->srcWidth < x) ||
- (stuff->srcHeight != 0 &&
- winY + stuff->srcY + (int)stuff->srcHeight < y) ||
- !PointInWindowIsVisible(source, x, y))
- return Success;
- }
- if (dest)
- {
- x = dest->drawable.x;
- y = dest->drawable.y;
- newScreen = dest->drawable.pScreen;
-#ifdef PANORAMIX
- if ( !noPanoramiXExtension )
- PANORAMIXFIND_ID(pPanoramiXWin, stuff->dstWid);
-#endif
- }
- else
- newScreen = sprite.hotPhys.pScreen;
- x += stuff->dstX;
- y += stuff->dstY;
-#ifdef PANORAMIX
- if ( !noPanoramiXExtension ) {
- if (pPanoramiXWin) {
- for ( i = 0 ; i < PanoramiXNumScreens; i++) {
- sWin = SecurityLookupWindow(pPanoramiXWin->info[i].id, client,
- SecurityReadAccess);
- sftScreen = sWin->drawable.pScreen;
- softx = sftScreen->width + panoramiXdataPtr[i].x;
- softy = sftScreen->height + panoramiXdataPtr[i].y;
- /* Figure out which screen the cursor is on. The destination (x,y)
- values are coming from the client, so it believes we have a screen
- size of (sizeofScreen * NumberOfScreens )*/
- if (x < 0)
- x = 0;
- if (y < 0)
- y = 0;
- if ((x > softx) || (y > softy))
- continue;
- else
- break;
- }
- newScreen = sftScreen;
- }
- if (x < 0)
- x = 0;
- else if (x >= newScreen->width + panoramiXdataPtr[newScreen->myNum].x )
- x = newScreen->width + panoramiXdataPtr[newScreen->myNum].x - 1;
- if (y < 0)
- y = 0;
- else if (y >= newScreen->height + panoramiXdataPtr[newScreen->myNum].y )
- y = newScreen->height + panoramiXdataPtr[newScreen->myNum].y - 1;
- x -= panoramiXdataPtr[newScreen->myNum].x;
- y -= panoramiXdataPtr[newScreen->myNum].y;
- }else {
-#endif
- if (x < 0)
- x = 0;
- else if (x >= newScreen->width)
- x = newScreen->width - 1;
- if (y < 0)
- y = 0;
- else if (y >= newScreen->height)
- y = newScreen->height - 1;
-#if PANORAMIX
- }
-#endif
- if (newScreen == sprite.hotPhys.pScreen)
- {
- if (x < sprite.physLimits.x1)
- x = sprite.physLimits.x1;
- else if (x >= sprite.physLimits.x2)
- x = sprite.physLimits.x2 - 1;
- if (y < sprite.physLimits.y1)
- y = sprite.physLimits.y1;
- else if (y >= sprite.physLimits.y2)
- y = sprite.physLimits.y2 - 1;
-#ifdef SHAPE
- if (sprite.hotShape)
- ConfineToShape(sprite.hotShape, &x, &y);
-#endif
- (*newScreen->SetCursorPosition)(newScreen, x, y, TRUE);
- }
- else if (!PointerConfinedToScreen())
- {
- NewCurrentScreen(newScreen, x, y);
- }
- return Success;
-}
-
-/* "CheckPassiveGrabsOnWindow" checks to see if the event passed in causes a
- passive grab set on the window to be activated. */
-
-static Bool
-CheckPassiveGrabsOnWindow(pWin, device, xE, count)
- WindowPtr pWin;
- register DeviceIntPtr device;
- register xEvent *xE;
- int count;
-{
- register GrabPtr grab = wPassiveGrabs(pWin);
- GrabRec tempGrab;
- register xEvent *dxE;
-
- if (!grab)
- return FALSE;
- tempGrab.window = pWin;
- tempGrab.device = device;
- tempGrab.type = xE->u.u.type;
- tempGrab.detail.exact = xE->u.u.detail;
- tempGrab.detail.pMask = NULL;
- tempGrab.modifiersDetail.pMask = NULL;
- for (; grab; grab = grab->next)
- {
-#ifdef XKB
- DeviceIntPtr gdev;
- XkbSrvInfoPtr xkbi;
-
- gdev= grab->modifierDevice;
- xkbi= gdev->key->xkbInfo;
-#endif
- tempGrab.modifierDevice = grab->modifierDevice;
- if (device == grab->modifierDevice &&
- (xE->u.u.type == KeyPress
-#ifdef XINPUT
- || xE->u.u.type == DeviceKeyPress
-#endif
- ))
- tempGrab.modifiersDetail.exact =
-#ifdef XKB
- (noXkbExtension?gdev->key->prev_state:xkbi->state.grab_mods);
-#else
- grab->modifierDevice->key->prev_state;
-#endif
- else
- tempGrab.modifiersDetail.exact =
-#ifdef XKB
- (noXkbExtension ? gdev->key->state : xkbi->state.grab_mods);
-#else
- grab->modifierDevice->key->state;
-#endif
- if (GrabMatchesSecond(&tempGrab, grab) &&
- (!grab->confineTo ||
- (grab->confineTo->realized &&
- REGION_NOTEMPTY( grab->confineTo->drawable.pScreen,
- &grab->confineTo->borderSize))))
- {
-#ifdef XCSECURITY
- if (!SecurityCheckDeviceAccess(wClient(pWin), device, FALSE))
- return FALSE;
-#endif
-#ifdef XKB
- if (!noXkbExtension) {
- xE->u.keyButtonPointer.state &= 0x1f00;
- xE->u.keyButtonPointer.state |=
- tempGrab.modifiersDetail.exact&(~0x1f00);
- }
-#endif
- (*device->ActivateGrab)(device, grab, currentTime, TRUE);
-
- FixUpEventFromWindow(xE, grab->window, None, TRUE);
-
- (void) TryClientEvents(rClient(grab), xE, count,
- filters[xE->u.u.type],
- filters[xE->u.u.type], grab);
-
- if (device->sync.state == FROZEN_NO_EVENT)
- {
- if (device->sync.evcount < count)
- {
- Must_have_memory = TRUE; /* XXX */
- device->sync.event = (xEvent *)xrealloc(device->sync.event,
- count*
- sizeof(xEvent));
- Must_have_memory = FALSE; /* XXX */
- }
- device->sync.evcount = count;
- for (dxE = device->sync.event; --count >= 0; dxE++, xE++)
- *dxE = *xE;
- device->sync.state = FROZEN_WITH_EVENT;
- }
- return TRUE;
- }
- }
- return FALSE;
-}
-
-/*
-"CheckDeviceGrabs" handles both keyboard and pointer events that may cause
-a passive grab to be activated. If the event is a keyboard event, the
-ancestors of the focus window are traced down and tried to see if they have
-any passive grabs to be activated. If the focus window itself is reached and
-it's descendants contain they pointer, the ancestors of the window that the
-pointer is in are then traced down starting at the focus window, otherwise no
-grabs are activated. If the event is a pointer event, the ancestors of the
-window that the pointer is in are traced down starting at the root until
-CheckPassiveGrabs causes a passive grab to activate or all the windows are
-tried. PRH
-*/
-
-Bool
-CheckDeviceGrabs(device, xE, checkFirst, count)
- register DeviceIntPtr device;
- register xEvent *xE;
- int checkFirst;
- int count;
-{
- register int i;
-#ifdef PANORAMIX
- register int j,k;
- PanoramiXWindow *pPanoramiXWin = NULL;
-#endif
- register WindowPtr pWin;
- register FocusClassPtr focus = device->focus;
-
- if ((xE->u.u.type == ButtonPress
-#ifdef XINPUT
- || xE->u.u.type == DeviceButtonPress
-#endif
- ) && device->button->buttonsDown != 1)
- return FALSE;
-
- i = checkFirst;
-
- if (focus)
- {
-#ifdef PANORAMIX
- if (!noPanoramiXExtension) {
- k = (ROOT->drawable.pScreen)->myNum;
- for (; i < focus->traceGood; i++)
- {
- pWin = focus->trace[i];
- pPanoramiXWin = PanoramiXWinRoot;
- PANORAMIXFIND_ID(pPanoramiXWin, pWin->drawable.id);
- if (pPanoramiXWin) {
- pWin = (WindowPtr)
- LookupIDByType(pPanoramiXWin->info[k].id, RT_WINDOW);
- }
- if ( pWin && pWin->optional &&
- CheckPassiveGrabsOnWindow(pWin, device, xE, count))
- return TRUE;
- }
- }else {
-#endif
- for (; i < focus->traceGood; i++)
- {
- pWin = focus->trace[i];
- if (pWin->optional &&
- CheckPassiveGrabsOnWindow(pWin, device, xE, count))
- return TRUE;
- }
-#ifdef PANORAMIX
- }
-#endif
-
- if ((focus->win == NoneWin) ||
- (i >= spriteTraceGood) ||
- ((i > checkFirst) && (pWin != spriteTrace[i-1])))
- return FALSE;
- }
-#ifdef PANORAMIX
- if (!noPanoramiXExtension) {
- k = (ROOT->drawable.pScreen)->myNum;;
- for (; i < spriteTraceGood; i++) {
- pWin = spriteTrace[i];
- pPanoramiXWin = PanoramiXWinRoot;
- PANORAMIXFIND_ID_BY_SCRNUM(pPanoramiXWin, pWin->drawable.id, k);
- if (pPanoramiXWin) {
- for ( j= PanoramiXNumScreens - 1; j>=0; j--) {
- pWin = (WindowPtr)
- LookupIDByType(pPanoramiXWin->info[j].id, RT_WINDOW);
- if ( pWin && pWin->optional &&
- CheckPassiveGrabsOnWindow(pWin, device, xE, count))
- return TRUE;
- }
- }
- }
- return FALSE;
- }else {
-#endif
- for (; i < spriteTraceGood; i++)
- {
- pWin = spriteTrace[i];
- if (pWin->optional &&
- CheckPassiveGrabsOnWindow(pWin, device, xE, count))
- return TRUE;
- }
-
- return FALSE;
-#ifdef PANORAMIX
- }
-#endif
-}
-
-void
-DeliverFocusedEvent(keybd, xE, window, count)
- xEvent *xE;
- DeviceIntPtr keybd;
- WindowPtr window;
- int count;
-{
- WindowPtr focus = keybd->focus->win;
- int mskidx = 0;
-#ifdef PANORAMIX
- register int k;
- WindowPtr orig_focus;
- PanoramiXWindow *pPanoramiXWin = PanoramiXWinRoot;
-#endif
-
- if (focus == FollowKeyboardWin)
- focus = inputInfo.keyboard->focus->win;
- if (!focus)
- return;
- if (focus == PointerRootWin)
- {
- DeliverDeviceEvents(window, xE, NullGrab, NullWindow, keybd, count);
- return;
- }
-#ifdef PANORAMIX
- if (!noPanoramiXExtension) {
- k = (ROOT->drawable.pScreen)->myNum;
- orig_focus = focus;
- PANORAMIXFIND_ID(pPanoramiXWin, focus->drawable.id);
- if (pPanoramiXWin) {
- focus = (WindowPtr) LookupIDByType(pPanoramiXWin->info[k].id, RT_WINDOW);
- }
- }
-#endif
- if ((focus == window) || IsParent(focus, window))
- {
- if (DeliverDeviceEvents(window, xE, NullGrab, focus, keybd, count))
- return;
- }
- /* just deliver it to the focus window */
-#ifdef PANORAMIX
- if (!noPanoramiXExtension) {
- focus = orig_focus;
- }
-#endif
- FixUpEventFromWindow(xE, focus, None, FALSE);
- if (xE->u.u.type & EXTENSION_EVENT_BASE)
- mskidx = keybd->id;
- (void)DeliverEventsToWindow(focus, xE, count, filters[xE->u.u.type],
- NullGrab, mskidx);
-}
-
-void
-DeliverGrabbedEvent(xE, thisDev, deactivateGrab, count)
- register xEvent *xE;
- register DeviceIntPtr thisDev;
- Bool deactivateGrab;
- int count;
-{
- register GrabPtr grab = thisDev->grab;
- int deliveries = 0;
- register DeviceIntPtr dev;
- register xEvent *dxE;
-
- if (grab->ownerEvents)
- {
- WindowPtr focus;
-
- if (thisDev->focus)
- {
- focus = thisDev->focus->win;
- if (focus == FollowKeyboardWin)
- focus = inputInfo.keyboard->focus->win;
- }
- else
- focus = PointerRootWin;
- if (focus == PointerRootWin)
- deliveries = DeliverDeviceEvents(sprite.win, xE, grab, NullWindow,
- thisDev, count);
- else if (focus && (focus == sprite.win || IsParent(focus, sprite.win)))
- deliveries = DeliverDeviceEvents(sprite.win, xE, grab, focus,
- thisDev, count);
- else if (focus)
- deliveries = DeliverDeviceEvents(focus, xE, grab, focus,
- thisDev, count);
- }
- if (!deliveries)
- {
- FixUpEventFromWindow(xE, grab->window, None, TRUE);
- deliveries = TryClientEvents(rClient(grab), xE, count,
- (Mask)grab->eventMask,
- filters[xE->u.u.type], grab);
- if (deliveries && (xE->u.u.type == MotionNotify
-#ifdef XINPUT
- || xE->u.u.type == DeviceMotionNotify
-#endif
- ))
- thisDev->valuator->motionHintWindow = grab->window;
- }
- if (deliveries && !deactivateGrab && (xE->u.u.type != MotionNotify
-#ifdef XINPUT
- && xE->u.u.type != DeviceMotionNotify
-#endif
- ))
- switch (thisDev->sync.state)
- {
- case FREEZE_BOTH_NEXT_EVENT:
- for (dev = inputInfo.devices; dev; dev = dev->next)
- {
- if (dev == thisDev)
- continue;
- FreezeThaw(dev, TRUE);
- if ((dev->sync.state == FREEZE_BOTH_NEXT_EVENT) &&
- (CLIENT_BITS(dev->grab->resource) ==
- CLIENT_BITS(thisDev->grab->resource)))
- dev->sync.state = FROZEN_NO_EVENT;
- else
- dev->sync.other = thisDev->grab;
- }
- /* fall through */
- case FREEZE_NEXT_EVENT:
- thisDev->sync.state = FROZEN_WITH_EVENT;
- FreezeThaw(thisDev, TRUE);
- if (thisDev->sync.evcount < count)
- {
- Must_have_memory = TRUE; /* XXX */
- thisDev->sync.event = (xEvent *)xrealloc(thisDev->sync.event,
- count*sizeof(xEvent));
- Must_have_memory = FALSE; /* XXX */
- }
- thisDev->sync.evcount = count;
- for (dxE = thisDev->sync.event; --count >= 0; dxE++, xE++)
- *dxE = *xE;
- break;
- }
-}
-
-void
-#ifdef XKB
-CoreProcessKeyboardEvent (xE, keybd, count)
-#else
-ProcessKeyboardEvent (xE, keybd, count)
-#endif
- register xEvent *xE;
- register DeviceIntPtr keybd;
- int count;
-{
- int key, bit;
- register BYTE *kptr;
- register int i;
- register CARD8 modifiers;
- register CARD16 mask;
- GrabPtr grab = keybd->grab;
- Bool deactivateGrab = FALSE;
- register KeyClassPtr keyc = keybd->key;
-
- if (!syncEvents.playingEvents)
- {
- NoticeTime(xE);
- if (DeviceEventCallback)
- {
- DeviceEventInfoRec eventinfo;
- eventinfo.events = xE;
- eventinfo.count = count;
- CallCallbacks(&DeviceEventCallback, (pointer)&eventinfo);
- }
- }
- xE->u.keyButtonPointer.state = (keyc->state |
- inputInfo.pointer->button->state);
- xE->u.keyButtonPointer.rootX = sprite.hot.x;
- xE->u.keyButtonPointer.rootY = sprite.hot.y;
- key = xE->u.u.detail;
- kptr = &keyc->down[key >> 3];
- bit = 1 << (key & 7);
- modifiers = keyc->modifierMap[key];
-#ifdef DEBUG
- if ((xkbDebugFlags&0x4)&&
- ((xE->u.u.type==KeyPress)||(xE->u.u.type==KeyRelease))) {
- ErrorF("CoreProcessKbdEvent: Key %d %s\n",key,
- (xE->u.u.type==KeyPress?"down":"up"));
- }
-#endif
- switch (xE->u.u.type)
- {
- case KeyPress:
- if (*kptr & bit) /* allow ddx to generate multiple downs */
- {
- if (!modifiers)
- {
- xE->u.u.type = KeyRelease;
- (*keybd->public.processInputProc)(xE, keybd, count);
- xE->u.u.type = KeyPress;
- /* release can have side effects, don't fall through */
- (*keybd->public.processInputProc)(xE, keybd, count);
- }
- return;
- }
- inputInfo.pointer->valuator->motionHintWindow = NullWindow;
- *kptr |= bit;
- keyc->prev_state = keyc->state;
- for (i = 0, mask = 1; modifiers; i++, mask <<= 1)
- {
- if (mask & modifiers)
- {
- /* This key affects modifier "i" */
- keyc->modifierKeyCount[i]++;
- keyc->state |= mask;
- modifiers &= ~mask;
- }
- }
- if (!grab && CheckDeviceGrabs(keybd, xE, 0, count))
- {
- keybd->activatingKey = key;
- return;
- }
- break;
- case KeyRelease:
- if (!(*kptr & bit)) /* guard against duplicates */
- return;
- inputInfo.pointer->valuator->motionHintWindow = NullWindow;
- *kptr &= ~bit;
- keyc->prev_state = keyc->state;
- for (i = 0, mask = 1; modifiers; i++, mask <<= 1)
- {
- if (mask & modifiers) {
- /* This key affects modifier "i" */
- if (--keyc->modifierKeyCount[i] <= 0) {
- keyc->state &= ~mask;
- keyc->modifierKeyCount[i] = 0;
- }
- modifiers &= ~mask;
- }
- }
- if (keybd->fromPassiveGrab && (key == keybd->activatingKey))
- deactivateGrab = TRUE;
- break;
- default:
- FatalError("Impossible keyboard event");
- }
- if (grab)
- DeliverGrabbedEvent(xE, keybd, deactivateGrab, count);
- else
- DeliverFocusedEvent(keybd, xE, sprite.win, count);
- if (deactivateGrab)
- (*keybd->DeactivateGrab)(keybd);
-}
-
-void
-#ifdef XKB
-CoreProcessPointerEvent (xE, mouse, count)
-#else
-ProcessPointerEvent (xE, mouse, count)
-#endif
- register xEvent *xE;
- register DeviceIntPtr mouse;
- int count;
-{
- register GrabPtr grab = mouse->grab;
- Bool deactivateGrab = FALSE;
- register ButtonClassPtr butc = mouse->button;
-#ifdef XKB
- XkbSrvInfoPtr xkbi= inputInfo.keyboard->key->xkbInfo;
-#endif
-
- if (!syncEvents.playingEvents)
- NoticeTime(xE)
- xE->u.keyButtonPointer.state = (butc->state | (
-#ifdef XKB
- (noXkbExtension ?
- inputInfo.keyboard->key->state :
- xkbi->state.grab_mods)
-#else
- inputInfo.keyboard->key->state
-#endif
- ));
- {
- NoticeTime(xE);
- if (DeviceEventCallback)
- {
- DeviceEventInfoRec eventinfo;
- /* see comment in EnqueueEvents regarding the next three lines */
- if (xE->u.u.type == MotionNotify)
- xE->u.keyButtonPointer.root =
- WindowTable[sprite.hotPhys.pScreen->myNum]->drawable.id;
- eventinfo.events = xE;
- eventinfo.count = count;
- CallCallbacks(&DeviceEventCallback, (pointer)&eventinfo);
- }
- }
- if (xE->u.u.type != MotionNotify)
- {
- register int key;
- register BYTE *kptr;
- int bit;
-#ifdef PANORAMIX
- int j;
- PanoramiXWindow *pPanoramiXWin = PanoramiXWinRoot;
- int x_off = 0, y_off = 0;
-#endif
-
-#ifdef PANORAMIX
- if ( !noPanoramiXExtension ) {
- for (j = PanoramiXNumScreens - 1; j; j--) {
- if (xE->u.keyButtonPointer.root == PanoramiXWinRoot->info[j].id)
- break;
- }
- if (j) {
- xE->u.keyButtonPointer.root = PanoramiXWinRoot->info[0].id;
- xE->u.keyButtonPointer.sameScreen = xTrue;
- }
-
- PANORAMIXFIND_ID(pPanoramiXWin, xE->u.keyButtonPointer.event);
- if (pPanoramiXWin) {
- for (j = PanoramiXNumScreens - 1; j; j--) {
- if (pPanoramiXWin->info[j].id == xE->u.keyButtonPointer.event)
- break;
- }
- }
- if (j && pPanoramiXWin) {
- xE->u.keyButtonPointer.event = pPanoramiXWin->info[0].id;
- }
- pPanoramiXWin = PanoramiXWinRoot;
- PANORAMIXFIND_ID(pPanoramiXWin, xE->u.keyButtonPointer.child);
- if (pPanoramiXWin) {
- for (j = PanoramiXNumScreens - 1; j; j--) {
- if (pPanoramiXWin->info[j].id == xE->u.keyButtonPointer.child)
- break;
- }
- }
- if (j && pPanoramiXWin)
- xE->u.keyButtonPointer.child = pPanoramiXWin->info[0].id;
-
- xE->u.keyButtonPointer.rootX = sprite.hot.x;
- xE->u.keyButtonPointer.rootY = sprite.hot.y;
- }else {
-#endif
- xE->u.keyButtonPointer.rootX = sprite.hot.x;
- xE->u.keyButtonPointer.rootY = sprite.hot.y;
-#ifdef PANORAMIX
- }
-#endif
- key = xE->u.u.detail;
- kptr = &butc->down[key >> 3];
- bit = 1 << (key & 7);
- switch (xE->u.u.type)
- {
- case ButtonPress:
- mouse->valuator->motionHintWindow = NullWindow;
- butc->buttonsDown++;
- butc->motionMask = ButtonMotionMask;
- *kptr |= bit;
- xE->u.u.detail = butc->map[key];
- if (xE->u.u.detail == 0)
- return;
- if (xE->u.u.detail <= 5)
- butc->state |= (Button1Mask >> 1) << xE->u.u.detail;
- filters[MotionNotify] = Motion_Filter(butc);
- if (!grab)
- if (CheckDeviceGrabs(mouse, xE, 0, count))
- return;
- break;
- case ButtonRelease:
- mouse->valuator->motionHintWindow = NullWindow;
- if (!--butc->buttonsDown)
- butc->motionMask = 0;
- *kptr &= ~bit;
- xE->u.u.detail = butc->map[key];
- if (xE->u.u.detail == 0)
- return;
- if (xE->u.u.detail <= 5)
- butc->state &= ~((Button1Mask >> 1) << xE->u.u.detail);
- filters[MotionNotify] = Motion_Filter(butc);
- if (!butc->state && mouse->fromPassiveGrab)
- deactivateGrab = TRUE;
- break;
- default:
- FatalError("bogus pointer event from ddx");
- }
- }
- else if (!CheckMotion(xE))
- return;
- if (grab)
- DeliverGrabbedEvent(xE, mouse, deactivateGrab, count);
- else
- DeliverDeviceEvents(sprite.win, xE, NullGrab, NullWindow,
- mouse, count);
- if (deactivateGrab)
- (*mouse->DeactivateGrab)(mouse);
-}
-
-#define AtMostOneClient \
- (SubstructureRedirectMask | ResizeRedirectMask | ButtonPressMask)
-
-void
-RecalculateDeliverableEvents(pWin)
- register WindowPtr pWin;
-{
- register OtherClients *others;
- register WindowPtr pChild;
-
- pChild = pWin;
- while (1)
- {
- if (pChild->optional)
- {
- pChild->optional->otherEventMasks = 0;
- for (others = wOtherClients(pChild); others; others = others->next)
- {
- pChild->optional->otherEventMasks |= others->mask;
- }
- }
- pChild->deliverableEvents = pChild->eventMask|
- wOtherEventMasks(pChild);
- if (pChild->parent)
- pChild->deliverableEvents |=
- (pChild->parent->deliverableEvents &
- ~wDontPropagateMask(pChild) & PropagateMask);
- if (pChild->firstChild)
- {
- pChild = pChild->firstChild;
- continue;
- }
- while (!pChild->nextSib && (pChild != pWin))
- pChild = pChild->parent;
- if (pChild == pWin)
- break;
- pChild = pChild->nextSib;
- }
-}
-
-int
-OtherClientGone(value, id)
- pointer value; /* must conform to DeleteType */
- XID id;
-{
- register OtherClientsPtr other, prev;
- register WindowPtr pWin = (WindowPtr)value;
-
- prev = 0;
- for (other = wOtherClients(pWin); other; other = other->next)
- {
- if (other->resource == id)
- {
- if (prev)
- prev->next = other->next;
- else
- {
- if (!(pWin->optional->otherClients = other->next))
- CheckWindowOptionalNeed (pWin);
- }
- xfree(other);
- RecalculateDeliverableEvents(pWin);
- return(Success);
- }
- prev = other;
- }
- FatalError("client not on event list");
- /*NOTREACHED*/
- return -1; /* make compiler happy */
-}
-
-int
-EventSelectForWindow(pWin, client, mask)
- register WindowPtr pWin;
- register ClientPtr client;
- Mask mask;
-{
- Mask check;
- OtherClients * others;
-
- if (mask & ~AllEventMasks)
- {
- client->errorValue = mask;
- return BadValue;
- }
- check = (mask & AtMostOneClient);
- if (check & (pWin->eventMask|wOtherEventMasks(pWin)))
- { /* It is illegal for two different
- clients to select on any of the
- events for AtMostOneClient. However,
- it is OK, for some client to
- continue selecting on one of those
- events. */
- if ((wClient(pWin) != client) && (check & pWin->eventMask))
- return BadAccess;
- for (others = wOtherClients (pWin); others; others = others->next)
- {
- if (!SameClient(others, client) && (check & others->mask))
- return BadAccess;
- }
- }
- if (wClient (pWin) == client)
- {
- check = pWin->eventMask;
-#if SGIMISC
- pWin->eventMask =
- (mask & ~SGIMiscSpecialDestroyMask) | (pWin->eventMask & SGIMiscSpecialDestroyMask);
-#else
- pWin->eventMask = mask;
-#endif
- }
- else
- {
- for (others = wOtherClients (pWin); others; others = others->next)
- {
- if (SameClient(others, client))
- {
- check = others->mask;
-#if SGIMISC
- mask = (mask & ~SGIMiscSpecialDestroyMask) | (others->mask & SGIMiscSpecialDestroyMask);
-#endif
- if (mask == 0)
- {
- FreeResource(others->resource, RT_NONE);
- return Success;
- }
- else
- others->mask = mask;
- goto maskSet;
- }
- }
- check = 0;
- if (!pWin->optional && !MakeWindowOptional (pWin))
- return BadAlloc;
- others = (OtherClients *) xalloc(sizeof(OtherClients));
- if (!others)
- return BadAlloc;
- others->mask = mask;
- others->resource = FakeClientID(client->index);
- others->next = pWin->optional->otherClients;
- pWin->optional->otherClients = others;
- if (!AddResource(others->resource, RT_OTHERCLIENT, (pointer)pWin))
- return BadAlloc;
- }
-maskSet:
- if ((inputInfo.pointer->valuator->motionHintWindow == pWin) &&
- (mask & PointerMotionHintMask) &&
- !(check & PointerMotionHintMask) &&
- !inputInfo.pointer->grab)
- inputInfo.pointer->valuator->motionHintWindow = NullWindow;
- RecalculateDeliverableEvents(pWin);
- return Success;
-}
-
-/*ARGSUSED*/
-int
-EventSuppressForWindow(pWin, client, mask, checkOptional)
- register WindowPtr pWin;
- register ClientPtr client;
- Mask mask;
- Bool *checkOptional;
-{
- register int i, free;
-
- if ((mask & ~PropagateMask) && !permitOldBugs)
- {
- client->errorValue = mask;
- return BadValue;
- }
- if (pWin->dontPropagate)
- DontPropagateRefCnts[pWin->dontPropagate]--;
- if (!mask)
- i = 0;
- else
- {
- for (i = DNPMCOUNT, free = 0; --i > 0; )
- {
- if (!DontPropagateRefCnts[i])
- free = i;
- else if (mask == DontPropagateMasks[i])
- break;
- }
- if (!i && free)
- {
- i = free;
- DontPropagateMasks[i] = mask;
- }
- }
- if (i || !mask)
- {
- pWin->dontPropagate = i;
- if (i)
- DontPropagateRefCnts[i]++;
- if (pWin->optional)
- {
- pWin->optional->dontPropagateMask = mask;
- *checkOptional = TRUE;
- }
- }
- else
- {
- if (!pWin->optional && !MakeWindowOptional (pWin))
- {
- if (pWin->dontPropagate)
- DontPropagateRefCnts[pWin->dontPropagate]++;
- return BadAlloc;
- }
- pWin->dontPropagate = 0;
- pWin->optional->dontPropagateMask = mask;
- }
- RecalculateDeliverableEvents(pWin);
- return Success;
-}
-
-static WindowPtr
-CommonAncestor(a, b)
- register WindowPtr a, b;
-{
- for (b = b->parent; b; b = b->parent)
- if (IsParent(b, a)) return b;
- return NullWindow;
-}
-
-static void
-EnterLeaveEvent(type, mode, detail, pWin, child)
- int type, mode, detail;
- register WindowPtr pWin;
- Window child;
-{
- xEvent event;
- register DeviceIntPtr keybd = inputInfo.keyboard;
- WindowPtr focus;
- register DeviceIntPtr mouse = inputInfo.pointer;
- register GrabPtr grab = mouse->grab;
- Mask mask;
-
- if ((pWin == mouse->valuator->motionHintWindow) &&
- (detail != NotifyInferior))
- mouse->valuator->motionHintWindow = NullWindow;
- if (grab)
- {
- mask = (pWin == grab->window) ? grab->eventMask : 0;
- if (grab->ownerEvents)
- mask |= EventMaskForClient(pWin, rClient(grab));
- }
- else
- {
- mask = pWin->eventMask | wOtherEventMasks(pWin);
- }
- if (mask & filters[type])
- {
- event.u.u.type = type;
- event.u.u.detail = detail;
- event.u.enterLeave.time = currentTime.milliseconds;
- event.u.enterLeave.rootX = sprite.hot.x;
- event.u.enterLeave.rootY = sprite.hot.y;
- /* Counts on the same initial structure of crossing & button events! */
- FixUpEventFromWindow(&event, pWin, None, FALSE);
- /* Enter/Leave events always set child */
- event.u.enterLeave.child = child;
- event.u.enterLeave.flags = event.u.keyButtonPointer.sameScreen ?
- ELFlagSameScreen : 0;
-#ifdef XKB
- if (!noXkbExtension) {
- event.u.enterLeave.state = mouse->button->state & 0x1f00;
- event.u.enterLeave.state |=
- XkbGrabStateFromRec(&keybd->key->xkbInfo->state);
- } else
-#endif
- event.u.enterLeave.state = keybd->key->state | mouse->button->state;
- event.u.enterLeave.mode = mode;
- focus = keybd->focus->win;
- if ((focus != NoneWin) &&
- ((pWin == focus) || (focus == PointerRootWin) ||
- IsParent(focus, pWin)))
- event.u.enterLeave.flags |= ELFlagFocus;
- if (grab)
- (void)TryClientEvents(rClient(grab), &event, 1, mask,
- filters[type], grab);
- else
- (void)DeliverEventsToWindow(pWin, &event, 1, filters[type],
- NullGrab, 0);
- }
- if ((type == EnterNotify) && (mask & KeymapStateMask))
- {
- xKeymapEvent ke;
-
-#ifdef XCSECURITY
- ClientPtr client = grab ? rClient(grab)
- : clients[CLIENT_ID(pWin->drawable.id)];
- if (!SecurityCheckDeviceAccess(client, keybd, FALSE))
- {
- bzero((char *)&ke.map[0], 31);
- }
- else
-#endif
- memmove((char *)&ke.map[0], (char *)&keybd->key->down[1], 31);
- ke.type = KeymapNotify;
- if (grab)
- (void)TryClientEvents(rClient(grab), (xEvent *)&ke, 1, mask,
- KeymapStateMask, grab);
- else
- (void)DeliverEventsToWindow(pWin, (xEvent *)&ke, 1,
- KeymapStateMask, NullGrab, 0);
- }
-}
-
-static void
-EnterNotifies(ancestor, child, mode, detail)
- WindowPtr ancestor, child;
- int mode, detail;
-{
- WindowPtr parent = child->parent;
-
- if (ancestor == parent)
- return;
- EnterNotifies(ancestor, parent, mode, detail);
- EnterLeaveEvent(EnterNotify, mode, detail, parent, child->drawable.id);
-}
-
-static void
-LeaveNotifies(child, ancestor, mode, detail)
- WindowPtr child, ancestor;
- int detail, mode;
-{
- register WindowPtr pWin;
-
- if (ancestor == child)
- return;
- for (pWin = child->parent; pWin != ancestor; pWin = pWin->parent)
- {
- EnterLeaveEvent(LeaveNotify, mode, detail, pWin, child->drawable.id);
- child = pWin;
- }
-}
-
-static void
-DoEnterLeaveEvents(fromWin, toWin, mode)
- WindowPtr fromWin, toWin;
- int mode;
-{
- if (fromWin == toWin)
- return;
- if (IsParent(fromWin, toWin))
- {
- EnterLeaveEvent(LeaveNotify, mode, NotifyInferior, fromWin, None);
- EnterNotifies(fromWin, toWin, mode, NotifyVirtual);
- EnterLeaveEvent(EnterNotify, mode, NotifyAncestor, toWin, None);
- }
- else if (IsParent(toWin, fromWin))
- {
- EnterLeaveEvent(LeaveNotify, mode, NotifyAncestor, fromWin, None);
- LeaveNotifies(fromWin, toWin, mode, NotifyVirtual);
- EnterLeaveEvent(EnterNotify, mode, NotifyInferior, toWin, None);
- }
- else
- { /* neither fromWin nor toWin is descendent of the other */
- WindowPtr common = CommonAncestor(toWin, fromWin);
- /* common == NullWindow ==> different screens */
- EnterLeaveEvent(LeaveNotify, mode, NotifyNonlinear, fromWin, None);
- LeaveNotifies(fromWin, common, mode, NotifyNonlinearVirtual);
- EnterNotifies(common, toWin, mode, NotifyNonlinearVirtual);
- EnterLeaveEvent(EnterNotify, mode, NotifyNonlinear, toWin, None);
- }
-}
-
-static void
-FocusEvent(dev, type, mode, detail, pWin)
- DeviceIntPtr dev;
- int type, mode, detail;
- register WindowPtr pWin;
-{
- xEvent event;
-
-#ifdef XINPUT
- if (dev != inputInfo.keyboard)
- {
- DeviceFocusEvent(dev, type, mode, detail, pWin);
- return;
- }
-#endif
- event.u.focus.mode = mode;
- event.u.u.type = type;
- event.u.u.detail = detail;
- event.u.focus.window = pWin->drawable.id;
- (void)DeliverEventsToWindow(pWin, &event, 1, filters[type], NullGrab,
- 0);
- if ((type == FocusIn) &&
- ((pWin->eventMask | wOtherEventMasks(pWin)) & KeymapStateMask))
- {
- xKeymapEvent ke;
-#ifdef XCSECURITY
- ClientPtr client = clients[CLIENT_ID(pWin->drawable.id)];
- if (!SecurityCheckDeviceAccess(client, dev, FALSE))
- {
- bzero((char *)&ke.map[0], 31);
- }
- else
-#endif
- memmove((char *)&ke.map[0], (char *)&dev->key->down[1], 31);
- ke.type = KeymapNotify;
- (void)DeliverEventsToWindow(pWin, (xEvent *)&ke, 1,
- KeymapStateMask, NullGrab, 0);
- }
-}
-
- /*
- * recursive because it is easier
- * no-op if child not descended from ancestor
- */
-static Bool
-FocusInEvents(dev, ancestor, child, skipChild, mode, detail, doAncestor)
- DeviceIntPtr dev;
- WindowPtr ancestor, child, skipChild;
- int mode, detail;
- Bool doAncestor;
-{
- if (child == NullWindow)
- return ancestor == NullWindow;
- if (ancestor == child)
- {
- if (doAncestor)
- FocusEvent(dev, FocusIn, mode, detail, child);
- return TRUE;
- }
- if (FocusInEvents(dev, ancestor, child->parent, skipChild, mode, detail,
- doAncestor))
- {
- if (child != skipChild)
- FocusEvent(dev, FocusIn, mode, detail, child);
- return TRUE;
- }
- return FALSE;
-}
-
-/* dies horribly if ancestor is not an ancestor of child */
-static void
-FocusOutEvents(dev, child, ancestor, mode, detail, doAncestor)
- DeviceIntPtr dev;
- WindowPtr child, ancestor;
- int mode;
- int detail;
- Bool doAncestor;
-{
- register WindowPtr pWin;
-
- for (pWin = child; pWin != ancestor; pWin = pWin->parent)
- FocusEvent(dev, FocusOut, mode, detail, pWin);
- if (doAncestor)
- FocusEvent(dev, FocusOut, mode, detail, ancestor);
-}
-
-void
-DoFocusEvents(dev, fromWin, toWin, mode)
- DeviceIntPtr dev;
- WindowPtr fromWin, toWin;
- int mode;
-{
- int out, in; /* for holding details for to/from
- PointerRoot/None */
- int i;
-
- if (fromWin == toWin)
- return;
- out = (fromWin == NoneWin) ? NotifyDetailNone : NotifyPointerRoot;
- in = (toWin == NoneWin) ? NotifyDetailNone : NotifyPointerRoot;
- /* wrong values if neither, but then not referenced */
-
- if ((toWin == NullWindow) || (toWin == PointerRootWin))
- {
- if ((fromWin == NullWindow) || (fromWin == PointerRootWin))
- {
- if (fromWin == PointerRootWin)
- FocusOutEvents(dev, sprite.win, ROOT, mode, NotifyPointer,
- TRUE);
- /* Notify all the roots */
-#ifdef PANORAMIX
- if ( !noPanoramiXExtension )
- FocusEvent(dev, FocusOut, mode, out,
- WindowTable[sprite.hotPhys.pScreen->myNum]);
- else {
- for (i=0; i<screenInfo.numScreens; i++)
- FocusEvent(dev, FocusOut, mode, out, WindowTable[i]);
- }
-#else
- for (i=0; i<screenInfo.numScreens; i++)
- FocusEvent(dev, FocusOut, mode, out, WindowTable[i]);
-#endif
- }
- else
- {
- if (IsParent(fromWin, sprite.win))
- FocusOutEvents(dev, sprite.win, fromWin, mode, NotifyPointer,
- FALSE);
- FocusEvent(dev, FocusOut, mode, NotifyNonlinear, fromWin);
- /* next call catches the root too, if the screen changed */
- FocusOutEvents(dev, fromWin->parent, NullWindow, mode,
- NotifyNonlinearVirtual, FALSE);
- }
- /* Notify all the roots */
-#ifdef PANORAMIX
- if ( !noPanoramiXExtension )
- FocusEvent(dev, FocusIn, mode, in,
- WindowTable[sprite.hotPhys.pScreen->myNum]);
- else {
- for (i=0; i<screenInfo.numScreens; i++)
- FocusEvent(dev, FocusIn, mode, in, WindowTable[i]);
- }
-#else
- for (i=0; i<screenInfo.numScreens; i++)
- FocusEvent(dev, FocusIn, mode, in, WindowTable[i]);
-#endif
- if (toWin == PointerRootWin)
- (void)FocusInEvents(dev, ROOT, sprite.win, NullWindow, mode,
- NotifyPointer, TRUE);
- }
- else
- {
- if ((fromWin == NullWindow) || (fromWin == PointerRootWin))
- {
- if (fromWin == PointerRootWin)
- FocusOutEvents(dev, sprite.win, ROOT, mode, NotifyPointer,
- TRUE);
-#ifdef PANORAMIX
- if ( !noPanoramiXExtension )
- FocusEvent(dev, FocusOut, mode, out,
- WindowTable[sprite.hotPhys.pScreen->myNum]);
- else {
- for (i=0; i<screenInfo.numScreens; i++)
- FocusEvent(dev, FocusOut, mode, out, WindowTable[i]);
- }
-#else
- for (i=0; i<screenInfo.numScreens; i++)
- FocusEvent(dev, FocusOut, mode, out, WindowTable[i]);
-#endif
- if (toWin->parent != NullWindow)
- (void)FocusInEvents(dev, ROOT, toWin, toWin, mode,
- NotifyNonlinearVirtual, TRUE);
- FocusEvent(dev, FocusIn, mode, NotifyNonlinear, toWin);
- if (IsParent(toWin, sprite.win))
- (void)FocusInEvents(dev, toWin, sprite.win, NullWindow, mode,
- NotifyPointer, FALSE);
- }
- else
- {
- if (IsParent(toWin, fromWin))
- {
- FocusEvent(dev, FocusOut, mode, NotifyAncestor, fromWin);
- FocusOutEvents(dev, fromWin->parent, toWin, mode,
- NotifyVirtual, FALSE);
- FocusEvent(dev, FocusIn, mode, NotifyInferior, toWin);
- if ((IsParent(toWin, sprite.win)) &&
- (sprite.win != fromWin) &&
- (!IsParent(fromWin, sprite.win)) &&
- (!IsParent(sprite.win, fromWin)))
- (void)FocusInEvents(dev, toWin, sprite.win, NullWindow,
- mode, NotifyPointer, FALSE);
- }
- else
- if (IsParent(fromWin, toWin))
- {
- if ((IsParent(fromWin, sprite.win)) &&
- (sprite.win != fromWin) &&
- (!IsParent(toWin, sprite.win)) &&
- (!IsParent(sprite.win, toWin)))
- FocusOutEvents(dev, sprite.win, fromWin, mode,
- NotifyPointer, FALSE);
- FocusEvent(dev, FocusOut, mode, NotifyInferior, fromWin);
- (void)FocusInEvents(dev, fromWin, toWin, toWin, mode,
- NotifyVirtual, FALSE);
- FocusEvent(dev, FocusIn, mode, NotifyAncestor, toWin);
- }
- else
- {
- /* neither fromWin or toWin is child of other */
- WindowPtr common = CommonAncestor(toWin, fromWin);
- /* common == NullWindow ==> different screens */
- if (IsParent(fromWin, sprite.win))
- FocusOutEvents(dev, sprite.win, fromWin, mode,
- NotifyPointer, FALSE);
- FocusEvent(dev, FocusOut, mode, NotifyNonlinear, fromWin);
- if (fromWin->parent != NullWindow)
- FocusOutEvents(dev, fromWin->parent, common, mode,
- NotifyNonlinearVirtual, FALSE);
- if (toWin->parent != NullWindow)
- (void)FocusInEvents(dev, common, toWin, toWin, mode,
- NotifyNonlinearVirtual, FALSE);
- FocusEvent(dev, FocusIn, mode, NotifyNonlinear, toWin);
- if (IsParent(toWin, sprite.win))
- (void)FocusInEvents(dev, toWin, sprite.win, NullWindow,
- mode, NotifyPointer, FALSE);
- }
- }
- }
-}
-
-int
-SetInputFocus(client, dev, focusID, revertTo, ctime, followOK)
- ClientPtr client;
- DeviceIntPtr dev;
- Window focusID;
- CARD8 revertTo;
- Time ctime;
- Bool followOK;
-{
- register FocusClassPtr focus;
- register WindowPtr focusWin;
- int mode;
- TimeStamp time;
-
- UpdateCurrentTime();
- if ((revertTo != RevertToParent) &&
- (revertTo != RevertToPointerRoot) &&
- (revertTo != RevertToNone) &&
- ((revertTo != RevertToFollowKeyboard) || !followOK))
- {
- client->errorValue = revertTo;
- return BadValue;
- }
- time = ClientTimeToServerTime(ctime);
- if ((focusID == None) || (focusID == PointerRoot))
- focusWin = (WindowPtr)focusID;
- else if ((focusID == FollowKeyboard) && followOK)
- focusWin = inputInfo.keyboard->focus->win;
- else if (!(focusWin = SecurityLookupWindow(focusID, client,
- SecurityReadAccess)))
- return BadWindow;
- else
- {
- /* It is a match error to try to set the input focus to an
- unviewable window. */
-
- if(!focusWin->realized)
- return(BadMatch);
- }
- focus = dev->focus;
- if ((CompareTimeStamps(time, currentTime) == LATER) ||
- (CompareTimeStamps(time, focus->time) == EARLIER))
- return Success;
- mode = (dev->grab) ? NotifyWhileGrabbed : NotifyNormal;
- if (focus->win == FollowKeyboardWin)
- DoFocusEvents(dev, inputInfo.keyboard->focus->win, focusWin, mode);
- else
- DoFocusEvents(dev, focus->win, focusWin, mode);
- focus->time = time;
- focus->revert = revertTo;
- if (focusID == FollowKeyboard)
- focus->win = FollowKeyboardWin;
- else
- focus->win = focusWin;
- if ((focusWin == NoneWin) || (focusWin == PointerRootWin))
- focus->traceGood = 0;
- else
- {
- int depth = 0;
- register WindowPtr pWin;
-
- for (pWin = focusWin; pWin; pWin = pWin->parent) depth++;
- if (depth > focus->traceSize)
- {
- focus->traceSize = depth+1;
- Must_have_memory = TRUE; /* XXX */
- focus->trace = (WindowPtr *)xrealloc(focus->trace,
- focus->traceSize *
- sizeof(WindowPtr));
- Must_have_memory = FALSE; /* XXX */
- }
- focus->traceGood = depth;
- for (pWin = focusWin, depth--; pWin; pWin = pWin->parent, depth--)
- focus->trace[depth] = pWin;
- }
- return Success;
-}
-
-#ifdef PANORAMIX
-int PanoramiXSetInputFocus(ClientPtr client)
-{
- REQUEST(xSetInputFocusReq);
- int j, result;
- Window winID;
- PanoramiXWindow *pPanoramiXWin = PanoramiXWinRoot;
-
- REQUEST_SIZE_MATCH(xSetInputFocusReq);
- j = (sprite.hotPhys.pScreen)->myNum;
- PANORAMIXFIND_ID(pPanoramiXWin, stuff->focus);
- winID = pPanoramiXWin ? pPanoramiXWin->info[j].id : stuff->focus;
- result = SetInputFocus(client, inputInfo.keyboard, winID, stuff->revertTo,
- stuff->time, FALSE);
- return(result);
-}
-#endif
-
-int
-ProcSetInputFocus(client)
- ClientPtr client;
-{
- REQUEST(xSetInputFocusReq);
-
- REQUEST_SIZE_MATCH(xSetInputFocusReq);
-#ifdef PANORAMIX
- if ( !noPanoramiXExtension )
- return PanoramiXSetInputFocus(client);
-#endif
-#ifdef XCSECURITY
- if (!SecurityCheckDeviceAccess(client, inputInfo.keyboard, TRUE))
- return Success;
-#endif
- return SetInputFocus(client, inputInfo.keyboard, stuff->focus,
- stuff->revertTo, stuff->time, FALSE);
-}
-
-#ifdef PANORAMIX
-int PanoramiXGetInputFocus(ClientPtr client)
-{
- xGetInputFocusReply rep;
- REQUEST(xReq);
- int j;
- FocusClassPtr focus = inputInfo.keyboard->focus;
- PanoramiXWindow *pPanoramiXWin = PanoramiXWinRoot;
-
- REQUEST_SIZE_MATCH(xReq);
- j = (sprite.hotPhys.pScreen)->myNum;
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- if (focus->win == NoneWin)
- rep.focus = None;
- else if (focus->win == PointerRootWin)
- rep.focus = PointerRoot;
- else{
- rep.focus = focus->win->drawable.id;
- PANORAMIXFIND_ID_BY_SCRNUM(pPanoramiXWin, focus->win->drawable.id, j);
- if (pPanoramiXWin)
- rep.focus = pPanoramiXWin->info[0].id;
- }
- rep.revertTo = focus->revert;
- WriteReplyToClient(client, sizeof(xGetInputFocusReply), &rep);
- return Success;
-}
-#endif
-
-int
-ProcGetInputFocus(client)
- ClientPtr client;
-{
- xGetInputFocusReply rep;
- REQUEST(xReq);
- FocusClassPtr focus = inputInfo.keyboard->focus;
-
- REQUEST_SIZE_MATCH(xReq);
-#ifdef PANORAMIX
- if ( !noPanoramiXExtension )
- return PanoramiXGetInputFocus(client);
-#endif
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- if (focus->win == NoneWin)
- rep.focus = None;
- else if (focus->win == PointerRootWin)
- rep.focus = PointerRoot;
- else rep.focus = focus->win->drawable.id;
- rep.revertTo = focus->revert;
- WriteReplyToClient(client, sizeof(xGetInputFocusReply), &rep);
- return Success;
-}
-
-int
-ProcGrabPointer(client)
- ClientPtr client;
-{
- xGrabPointerReply rep;
- DeviceIntPtr device = inputInfo.pointer;
- GrabPtr grab;
- WindowPtr pWin, confineTo;
- CursorPtr cursor, oldCursor;
- REQUEST(xGrabPointerReq);
- TimeStamp time;
-#ifdef PANORAMIX
- int j,i, PanoramiXNum;
- Bool NotViewable, NotRealized;
- PanoramiXWindow *pPanoramiXWin = PanoramiXWinRoot;
-#endif
-
- REQUEST_SIZE_MATCH(xGrabPointerReq);
- UpdateCurrentTime();
-#ifdef PANORAMIX
- if ( !noPanoramiXExtension ) {
- PanoramiXNum = (sprite.hotPhys.pScreen)->myNum;
- NotViewable = FALSE;
- }
-#endif
- if ((stuff->pointerMode != GrabModeSync) &&
- (stuff->pointerMode != GrabModeAsync))
- {
- client->errorValue = stuff->pointerMode;
- return BadValue;
- }
- if ((stuff->keyboardMode != GrabModeSync) &&
- (stuff->keyboardMode != GrabModeAsync))
- {
- client->errorValue = stuff->keyboardMode;
- return BadValue;
- }
- if ((stuff->ownerEvents != xFalse) && (stuff->ownerEvents != xTrue))
- {
- client->errorValue = stuff->ownerEvents;
- return BadValue;
- }
- if ((stuff->eventMask & ~PointerGrabMask) && !permitOldBugs)
- {
- client->errorValue = stuff->eventMask;
- return BadValue;
- }
- pWin = SecurityLookupWindow(stuff->grabWindow, client, SecurityReadAccess);
- if (!pWin)
- return BadWindow;
-#ifdef PANORAMIX
- if ( !noPanoramiXExtension ) {
- pPanoramiXWin = PanoramiXWinRoot;
- PANORAMIXFIND_ID(pPanoramiXWin, stuff->grabWindow);
- if (pPanoramiXWin) {
- pWin = SecurityLookupWindow(pPanoramiXWin->info[PanoramiXNum].id, client,
- SecurityReadAccess);
- if (!pWin)
- return BadWindow;
- }
- if (stuff->confineTo == PanoramiXWinRoot->info[0].id)
- stuff->confineTo = None;
- }
-#endif
- if (stuff->confineTo == None)
- confineTo = NullWindow;
-#ifdef PANORAMIX
- else if ( !noPanoramiXExtension ) {
- if (stuff->confineTo) {
- pPanoramiXWin = PanoramiXWinRoot;
- PANORAMIXFIND_ID(pPanoramiXWin, stuff->confineTo);
- if (pPanoramiXWin) {
- stuff->confineTo = pPanoramiXWin->info[sprite.hotPhys.pScreen->
-myNum].id;
- confineTo = SecurityLookupWindow(stuff->confineTo, client,
- SecurityReadAccess);
- if (!confineTo)
- return BadWindow;
- }
- if ((confineTo && !(confineTo->realized &&
- REGION_NOTEMPTY(confineTo->drawable.pScreen, &confineTo->
-borderSize))))
- NotViewable = TRUE;
- }
- } else {
-#else
- else
- {
-#endif
- confineTo = SecurityLookupWindow(stuff->confineTo, client,
- SecurityReadAccess);
- if (!confineTo)
- return BadWindow;
- }
- if (stuff->cursor == None)
- cursor = NullCursor;
- else
- {
- cursor = (CursorPtr)SecurityLookupIDByType(client, stuff->cursor,
- RT_CURSOR, SecurityReadAccess);
- if (!cursor)
- {
- client->errorValue = stuff->cursor;
- return BadCursor;
- }
- }
- /* at this point, some sort of reply is guaranteed. */
- time = ClientTimeToServerTime(stuff->time);
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.length = 0;
- grab = device->grab;
- if ((grab) && !SameClient(grab, client))
- rep.status = AlreadyGrabbed;
-#ifdef PANORAMIX
- else if ((!noPanoramiXExtension ) &&
- (!(pWin->realized) || NotViewable))
- rep.status = GrabNotViewable;
- else if ((noPanoramiXExtension) && (!pWin->realized) ||
- (confineTo &&
- !(confineTo->realized &&
- REGION_NOTEMPTY( confineTo->drawable.pScreen,
- &confineTo->borderSize))))
-#else
- else if ((!pWin->realized) ||
- (confineTo &&
- !(confineTo->realized &&
- REGION_NOTEMPTY( confineTo->drawable.pScreen,
- &confineTo->borderSize))))
-#endif
- rep.status = GrabNotViewable;
- else if (device->sync.frozen &&
- device->sync.other && !SameClient(device->sync.other, client))
- rep.status = GrabFrozen;
- else if ((CompareTimeStamps(time, currentTime) == LATER) ||
- (CompareTimeStamps(time, device->grabTime) == EARLIER))
- rep.status = GrabInvalidTime;
- else
- {
- GrabRec tempGrab;
-
- oldCursor = NullCursor;
- if (grab)
- {
- if (grab->confineTo && !confineTo)
- ConfineCursorToWindow(ROOT, FALSE, FALSE);
- oldCursor = grab->cursor;
- }
- tempGrab.cursor = cursor;
- tempGrab.resource = client->clientAsMask;
- tempGrab.ownerEvents = stuff->ownerEvents;
- tempGrab.eventMask = stuff->eventMask;
- tempGrab.confineTo = confineTo;
- tempGrab.window = pWin;
- tempGrab.keyboardMode = stuff->keyboardMode;
- tempGrab.pointerMode = stuff->pointerMode;
- tempGrab.device = device;
- (*device->ActivateGrab)(device, &tempGrab, time, FALSE);
- if (oldCursor)
- FreeCursor (oldCursor, (Cursor)0);
- rep.status = GrabSuccess;
- }
- WriteReplyToClient(client, sizeof(xGrabPointerReply), &rep);
- return Success;
-}
-
-int
-ProcChangeActivePointerGrab(client)
- ClientPtr client;
-{
- DeviceIntPtr device = inputInfo.pointer;
- register GrabPtr grab = device->grab;
- CursorPtr newCursor, oldCursor;
- REQUEST(xChangeActivePointerGrabReq);
- TimeStamp time;
-
- REQUEST_SIZE_MATCH(xChangeActivePointerGrabReq);
- if ((stuff->eventMask & ~PointerGrabMask) && !permitOldBugs)
- {
- client->errorValue = stuff->eventMask;
- return BadValue;
- }
- if (stuff->cursor == None)
- newCursor = NullCursor;
- else
- {
- newCursor = (CursorPtr)SecurityLookupIDByType(client, stuff->cursor,
- RT_CURSOR, SecurityReadAccess);
- if (!newCursor)
- {
- client->errorValue = stuff->cursor;
- return BadCursor;
- }
- }
- if (!grab)
- return Success;
- if (!SameClient(grab, client))
- return Success;
- time = ClientTimeToServerTime(stuff->time);
- if ((CompareTimeStamps(time, currentTime) == LATER) ||
- (CompareTimeStamps(time, device->grabTime) == EARLIER))
- return Success;
- oldCursor = grab->cursor;
- grab->cursor = newCursor;
- if (newCursor)
- newCursor->refcnt++;
- PostNewCursor();
- if (oldCursor)
- FreeCursor(oldCursor, (Cursor)0);
- grab->eventMask = stuff->eventMask;
- return Success;
-}
-
-int
-ProcUngrabPointer(client)
- ClientPtr client;
-{
- DeviceIntPtr device = inputInfo.pointer;
- GrabPtr grab;
- TimeStamp time;
- REQUEST(xResourceReq);
-
- REQUEST_SIZE_MATCH(xResourceReq);
- UpdateCurrentTime();
- grab = device->grab;
- time = ClientTimeToServerTime(stuff->id);
- if ((CompareTimeStamps(time, currentTime) != LATER) &&
- (CompareTimeStamps(time, device->grabTime) != EARLIER) &&
- (grab) && SameClient(grab, client))
- (*device->DeactivateGrab)(device);
- return Success;
-}
-
-int
-GrabDevice(client, dev, this_mode, other_mode, grabWindow, ownerEvents, ctime,
- mask, status)
- register ClientPtr client;
- register DeviceIntPtr dev;
- unsigned this_mode;
- unsigned other_mode;
- Window grabWindow;
- unsigned ownerEvents;
- Time ctime;
- Mask mask;
- CARD8 *status;
-{
- register WindowPtr pWin;
- register GrabPtr grab;
- TimeStamp time;
-
- UpdateCurrentTime();
- if ((this_mode != GrabModeSync) && (this_mode != GrabModeAsync))
- {
- client->errorValue = this_mode;
- return BadValue;
- }
- if ((other_mode != GrabModeSync) && (other_mode != GrabModeAsync))
- {
- client->errorValue = other_mode;
- return BadValue;
- }
- if ((ownerEvents != xFalse) && (ownerEvents != xTrue))
- {
- client->errorValue = ownerEvents;
- return BadValue;
- }
- pWin = SecurityLookupWindow(grabWindow, client, SecurityReadAccess);
- if (!pWin)
- return BadWindow;
- time = ClientTimeToServerTime(ctime);
- grab = dev->grab;
- if (grab && !SameClient(grab, client))
- *status = AlreadyGrabbed;
- else if (!pWin->realized)
- *status = GrabNotViewable;
- else if ((CompareTimeStamps(time, currentTime) == LATER) ||
- (CompareTimeStamps(time, dev->grabTime) == EARLIER))
- *status = GrabInvalidTime;
- else if (dev->sync.frozen &&
- dev->sync.other && !SameClient(dev->sync.other, client))
- *status = GrabFrozen;
- else
- {
- GrabRec tempGrab;
-
- tempGrab.window = pWin;
- tempGrab.resource = client->clientAsMask;
- tempGrab.ownerEvents = ownerEvents;
- tempGrab.keyboardMode = this_mode;
- tempGrab.pointerMode = other_mode;
- tempGrab.eventMask = mask;
- tempGrab.device = dev;
- (*dev->ActivateGrab)(dev, &tempGrab, time, FALSE);
- *status = GrabSuccess;
- }
- return Success;
-}
-
-int
-ProcGrabKeyboard(client)
- ClientPtr client;
-{
- xGrabKeyboardReply rep;
- REQUEST(xGrabKeyboardReq);
- int result;
-#ifdef PANORAMIX
- int PanoramiXNum;
- Window winID;
- PanoramiXWindow *pPanoramiXWin = PanoramiXWinRoot;
-#endif
-
- REQUEST_SIZE_MATCH(xGrabKeyboardReq);
-#ifdef XCSECURITY
- if (!SecurityCheckDeviceAccess(client, inputInfo.keyboard, TRUE))
- {
- result = Success;
- rep.status = AlreadyGrabbed;
- }
- else
-#endif
-#ifdef PANORAMIX
- if (!noPanoramiXExtension) {
- PanoramiXNum = (sprite.hotPhys.pScreen)->myNum;
- winID = stuff->grabWindow;
- PANORAMIXFIND_ID(pPanoramiXWin, stuff->grabWindow);
- stuff->grabWindow = pPanoramiXWin ? pPanoramiXWin->info[PanoramiXNum].id : winID;
- }
-#endif
- result = GrabDevice(client, inputInfo.keyboard, stuff->keyboardMode,
- stuff->pointerMode, stuff->grabWindow,
- stuff->ownerEvents, stuff->time,
- KeyPressMask | KeyReleaseMask, &rep.status);
- if (result != Success)
- return result;
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.length = 0;
- WriteReplyToClient(client, sizeof(xGrabKeyboardReply), &rep);
- return Success;
-}
-
-int
-ProcUngrabKeyboard(client)
- ClientPtr client;
-{
- DeviceIntPtr device = inputInfo.keyboard;
- GrabPtr grab;
- TimeStamp time;
- REQUEST(xResourceReq);
-
- REQUEST_SIZE_MATCH(xResourceReq);
- UpdateCurrentTime();
- grab = device->grab;
- time = ClientTimeToServerTime(stuff->id);
- if ((CompareTimeStamps(time, currentTime) != LATER) &&
- (CompareTimeStamps(time, device->grabTime) != EARLIER) &&
- (grab) && SameClient(grab, client))
- (*device->DeactivateGrab)(device);
- return Success;
-}
-
-int
-ProcQueryPointer(client)
- ClientPtr client;
-{
- xQueryPointerReply rep;
- WindowPtr pWin, t;
- REQUEST(xResourceReq);
- DeviceIntPtr mouse = inputInfo.pointer;
-#ifdef PANORAMIX
- int PanoramiXNum;
- Window winID;
- PanoramiXWindow *pPanoramiXWin = PanoramiXWinRoot;
-#endif
-
- REQUEST_SIZE_MATCH(xResourceReq);
- pWin = SecurityLookupWindow(stuff->id, client, SecurityReadAccess);
- if (!pWin)
- return BadWindow;
-#ifdef PANORAMIX
- if ( !noPanoramiXExtension ){
- t = sprite.win;
- PanoramiXNum = (sprite.hotPhys.pScreen)->myNum;
- if (t == pWin) {
- /* we probably want pWin of some Fake Window */
- PANORAMIXFIND_ID(pPanoramiXWin, stuff->id);
- winID = pPanoramiXWin ? pPanoramiXWin->info[PanoramiXNum].id : stuff->id;
- pWin = SecurityLookupWindow(winID, client, SecurityReadAccess);
- }
- }
-#endif
- if (mouse->valuator->motionHintWindow)
- MaybeStopHint(mouse, client);
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.mask = mouse->button->state | inputInfo.keyboard->key->state;
- rep.length = 0;
-#ifdef PANORAMIX
- if ( !noPanoramiXExtension ){
- rep.root = PanoramiXWinRoot->info[0].id;
- rep.rootX = sprite.hot.x + panoramiXdataPtr[PanoramiXNum].x;
- rep.rootY = sprite.hot.y + panoramiXdataPtr[PanoramiXNum].y;
- } else {
-#endif
- rep.root = (ROOT)->drawable.id;
- rep.rootX = sprite.hot.x;
- rep.rootY = sprite.hot.y;
-#ifdef PANORAMIX
- }
-#endif
- rep.child = None;
-#ifdef PANORAMIX
- if ( !noPanoramiXExtension ){
- rep.sameScreen = xTrue;
- rep.winX = sprite.hot.x - pWin->drawable.x + panoramiXdataPtr[PanoramiXNum].x;
- rep.winY = sprite.hot.y - pWin->drawable.y + panoramiXdataPtr[PanoramiXNum].y;
- for (; pPanoramiXWin &&
- ((unsigned long)LookupIDByType(pPanoramiXWin->info[PanoramiXNum].id,
- RT_WINDOW) != (unsigned long) t); pPanoramiXWin = pPanoramiXWin->next);
- if (pPanoramiXWin)
- t = (WindowPtr)LookupIDByType(pPanoramiXWin->info[0].id, RT_WINDOW);
- for (; t; t = t->parent) {
- if (t->parent == pWin) {
- rep.child = t->drawable.id;
- break;
- }
- }
- } else {
-#endif
- if (sprite.hot.pScreen == pWin->drawable.pScreen)
- {
- rep.sameScreen = xTrue;
- rep.winX = sprite.hot.x - pWin->drawable.x;
- rep.winY = sprite.hot.y - pWin->drawable.y;
- for (t = sprite.win; t; t = t->parent)
- if (t->parent == pWin)
- {
- rep.child = t->drawable.id;
- break;
- }
- }
- else
- {
- rep.sameScreen = xFalse;
- rep.winX = 0;
- rep.winY = 0;
- }
-#ifdef PANORAMIX
- }
-#endif
-
- WriteReplyToClient(client, sizeof(xQueryPointerReply), &rep);
-
- return(Success);
-}
-
-void
-InitEvents()
-{
- int i;
-
- sprite.hot.pScreen = sprite.hotPhys.pScreen = (ScreenPtr)NULL;
- inputInfo.numDevices = 0;
- inputInfo.devices = (DeviceIntPtr)NULL;
- inputInfo.off_devices = (DeviceIntPtr)NULL;
- inputInfo.keyboard = (DeviceIntPtr)NULL;
- inputInfo.pointer = (DeviceIntPtr)NULL;
- if (spriteTraceSize == 0)
- {
- spriteTraceSize = 32;
- spriteTrace = (WindowPtr *)xalloc(32*sizeof(WindowPtr));
- if (!spriteTrace)
- FatalError("failed to allocate spriteTrace");
- }
- spriteTraceGood = 0;
- lastEventMask = OwnerGrabButtonMask;
- filters[MotionNotify] = PointerMotionMask;
- sprite.win = NullWindow;
- sprite.current = NullCursor;
- sprite.hotLimits.x1 = 0;
- sprite.hotLimits.y1 = 0;
- sprite.hotLimits.x2 = 0;
- sprite.hotLimits.y2 = 0;
- sprite.confined = FALSE;
- syncEvents.replayDev = (DeviceIntPtr)NULL;
- syncEvents.replayWin = NullWindow;
- while (syncEvents.pending)
- {
- QdEventPtr next = syncEvents.pending->next;
- xfree(syncEvents.pending);
- syncEvents.pending = next;
- }
- syncEvents.pendtail = &syncEvents.pending;
- syncEvents.playingEvents = FALSE;
- syncEvents.time.months = 0;
- syncEvents.time.milliseconds = 0; /* hardly matters */
- currentTime.months = 0;
- currentTime.milliseconds = GetTimeInMillis();
- lastDeviceEventTime = currentTime;
- for (i = 0; i < DNPMCOUNT; i++)
- {
- DontPropagateMasks[i] = 0;
- DontPropagateRefCnts[i] = 0;
- }
-}
-
-int
-ProcSendEvent(client)
- ClientPtr client;
-{
- WindowPtr pWin;
- WindowPtr effectiveFocus = NullWindow; /* only set if dest==InputFocus */
- REQUEST(xSendEventReq);
-
- REQUEST_SIZE_MATCH(xSendEventReq);
-
- /* The client's event type must be a core event type or one defined by an
- extension. */
-
- if ( ! ((stuff->event.u.u.type > X_Reply &&
- stuff->event.u.u.type < LASTEvent) ||
- (stuff->event.u.u.type >= EXTENSION_EVENT_BASE &&
- stuff->event.u.u.type < (unsigned)lastEvent)))
- {
- client->errorValue = stuff->event.u.u.type;
- return BadValue;
- }
- if (stuff->event.u.u.type == ClientMessage &&
- stuff->event.u.u.detail != 8 &&
- stuff->event.u.u.detail != 16 &&
- stuff->event.u.u.detail != 32 &&
- !permitOldBugs)
- {
- client->errorValue = stuff->event.u.u.detail;
- return BadValue;
- }
- if ((stuff->eventMask & ~AllEventMasks) && !permitOldBugs)
- {
- client->errorValue = stuff->eventMask;
- return BadValue;
- }
-
- if (stuff->destination == PointerWindow)
- pWin = sprite.win;
- else if (stuff->destination == InputFocus)
- {
- WindowPtr inputFocus = inputInfo.keyboard->focus->win;
-
- if (inputFocus == NoneWin)
- return Success;
-
- /* If the input focus is PointerRootWin, send the event to where
- the pointer is if possible, then perhaps propogate up to root. */
- if (inputFocus == PointerRootWin)
- inputFocus = ROOT;
-
- if (IsParent(inputFocus, sprite.win))
- {
- effectiveFocus = inputFocus;
- pWin = sprite.win;
- }
- else
- effectiveFocus = pWin = inputFocus;
- }
- else
- pWin = SecurityLookupWindow(stuff->destination, client,
- SecurityReadAccess);
- if (!pWin)
- return BadWindow;
- if ((stuff->propagate != xFalse) && (stuff->propagate != xTrue))
- {
- client->errorValue = stuff->propagate;
- return BadValue;
- }
- stuff->event.u.u.type |= 0x80;
- if (stuff->propagate)
- {
-#ifdef PANORAMIX
- if (noPanoramiXExtension){
-#endif
- for (;pWin; pWin = pWin->parent)
- {
- if (DeliverEventsToWindow(pWin, &stuff->event, 1, stuff->eventMask,
- NullGrab, 0))
- return Success;
- if (pWin == effectiveFocus)
- return Success;
- stuff->eventMask &= ~wDontPropagateMask(pWin);
- if (!stuff->eventMask)
- break;
- }
-#ifdef PANORAMIX
- }
-#endif
- }
- else
-#ifdef PANORAMIX
- if (noPanoramiXExtension)
-#endif
- (void)DeliverEventsToWindow(pWin, &stuff->event, 1, stuff->eventMask,
- NullGrab, 0);
- return Success;
-}
-
-int
-ProcUngrabKey(client)
- ClientPtr client;
-{
- REQUEST(xUngrabKeyReq);
- WindowPtr pWin;
- GrabRec tempGrab;
- DeviceIntPtr keybd = inputInfo.keyboard;
-#ifdef PANORAMIX
- int i, PanoramiXNum;
- Window GrabWinID;
- PanoramiXWindow *pPanoramiXWin = PanoramiXWinRoot;
-#endif
-
- REQUEST_SIZE_MATCH(xUngrabKeyReq);
- pWin = SecurityLookupWindow(stuff->grabWindow, client, SecurityReadAccess);
- if (!pWin)
- return BadWindow;
-#ifdef PANORAMIX
- if ( !noPanoramiXExtension ){
- PanoramiXNum = (sprite.hotPhys.pScreen)->myNum;
- PANORAMIXFIND_ID(pPanoramiXWin, stuff->grabWindow);
- GrabWinID = pPanoramiXWin ?
- pPanoramiXWin->info[PanoramiXNum].id : stuff->grabWindow;
- pWin = SecurityLookupWindow(GrabWinID, client, SecurityReadAccess);
- }
-#endif
- if (((stuff->key > keybd->key->curKeySyms.maxKeyCode) ||
- (stuff->key < keybd->key->curKeySyms.minKeyCode))
- && (stuff->key != AnyKey))
- {
- client->errorValue = stuff->key;
- return BadValue;
- }
- if ((stuff->modifiers != AnyModifier) &&
- (stuff->modifiers & ~AllModifiersMask))
- {
- client->errorValue = stuff->modifiers;
- return BadValue;
- }
-
- tempGrab.resource = client->clientAsMask;
- tempGrab.device = keybd;
- tempGrab.window = pWin;
- tempGrab.modifiersDetail.exact = stuff->modifiers;
- tempGrab.modifiersDetail.pMask = NULL;
- tempGrab.modifierDevice = inputInfo.keyboard;
- tempGrab.type = KeyPress;
- tempGrab.detail.exact = stuff->key;
- tempGrab.detail.pMask = NULL;
-
- if (!DeletePassiveGrabFromList(&tempGrab))
- return(BadAlloc);
- return(Success);
-}
-
-int
-ProcGrabKey(client)
- ClientPtr client;
-{
- WindowPtr pWin;
- REQUEST(xGrabKeyReq);
- GrabPtr grab;
- DeviceIntPtr keybd = inputInfo.keyboard;
-#ifdef PANORAMIX
- int i, PanoramiXNum;
- Window GrabWinID;
- PanoramiXWindow *pPanoramiXWin = PanoramiXWinRoot;
-#endif
-
- REQUEST_SIZE_MATCH(xGrabKeyReq);
- if ((stuff->ownerEvents != xTrue) && (stuff->ownerEvents != xFalse))
- {
- client->errorValue = stuff->ownerEvents;
- return(BadValue);
- }
- if ((stuff->pointerMode != GrabModeSync) &&
- (stuff->pointerMode != GrabModeAsync))
- {
- client->errorValue = stuff->pointerMode;
- return BadValue;
- }
- if ((stuff->keyboardMode != GrabModeSync) &&
- (stuff->keyboardMode != GrabModeAsync))
- {
- client->errorValue = stuff->keyboardMode;
- return BadValue;
- }
- if (((stuff->key > keybd->key->curKeySyms.maxKeyCode) ||
- (stuff->key < keybd->key->curKeySyms.minKeyCode))
- && (stuff->key != AnyKey))
- {
- client->errorValue = stuff->key;
- return BadValue;
- }
- if ((stuff->modifiers != AnyModifier) &&
- (stuff->modifiers & ~AllModifiersMask))
- {
- client->errorValue = stuff->modifiers;
- return BadValue;
- }
- pWin = SecurityLookupWindow(stuff->grabWindow, client, SecurityReadAccess);
- if (!pWin)
- return BadWindow;
-#ifdef PANORAMIX
- if ( !noPanoramiXExtension ){
- PanoramiXNum = (sprite.hotPhys.pScreen)->myNum;
- PANORAMIXFIND_ID(pPanoramiXWin, stuff->grabWindow);
- GrabWinID = pPanoramiXWin ?
- pPanoramiXWin->info[PanoramiXNum].id : stuff->grabWindow;
- pWin = SecurityLookupWindow(GrabWinID, client, SecurityReadAccess);
- }
-#endif
- grab = CreateGrab(client->index, keybd, pWin,
- (Mask)(KeyPressMask | KeyReleaseMask), (Bool)stuff->ownerEvents,
- (Bool)stuff->keyboardMode, (Bool)stuff->pointerMode,
- keybd, stuff->modifiers, KeyPress, stuff->key, NullWindow, NullCursor);
- if (!grab)
- return BadAlloc;
- return AddPassiveGrabToList(grab);
-}
-
-int
-ProcGrabButton(client)
- ClientPtr client;
-{
- WindowPtr pWin, confineTo;
- REQUEST(xGrabButtonReq);
- CursorPtr cursor;
- GrabPtr grab;
-#ifdef PANORAMIX
- int i, PanoramiXNum;
- Bool NotViewable, NotRealized;
- Window GrabWinID;
- PanoramiXWindow *pPanoramiXWin = PanoramiXWinRoot;
-#endif
-
- REQUEST_SIZE_MATCH(xGrabButtonReq);
-#ifdef PANORAMIX
- if ( !noPanoramiXExtension ) {
- NotViewable = FALSE;
- }
-#endif
- if ((stuff->pointerMode != GrabModeSync) &&
- (stuff->pointerMode != GrabModeAsync))
- {
- client->errorValue = stuff->pointerMode;
- return BadValue;
- }
- if ((stuff->keyboardMode != GrabModeSync) &&
- (stuff->keyboardMode != GrabModeAsync))
- {
- client->errorValue = stuff->keyboardMode;
- return BadValue;
- }
- if ((stuff->modifiers != AnyModifier) &&
- (stuff->modifiers & ~AllModifiersMask))
- {
- client->errorValue = stuff->modifiers;
- return BadValue;
- }
- if ((stuff->ownerEvents != xFalse) && (stuff->ownerEvents != xTrue))
- {
- client->errorValue = stuff->ownerEvents;
- return BadValue;
- }
- if (stuff->eventMask & ~PointerGrabMask)
- {
- client->errorValue = stuff->eventMask;
- return BadValue;
- }
- pWin = SecurityLookupWindow(stuff->grabWindow, client, SecurityReadAccess);
- if (!pWin)
- return BadWindow;
-#ifdef PANORAMIX
- if ( !noPanoramiXExtension ){
- PanoramiXNum = (sprite.hotPhys.pScreen)->myNum;
- PANORAMIXFIND_ID(pPanoramiXWin, stuff->grabWindow);
- GrabWinID = pPanoramiXWin ?
- pPanoramiXWin->info[PanoramiXNum].id : stuff->grabWindow;
- pWin = SecurityLookupWindow(GrabWinID, client, SecurityReadAccess);
- if (stuff->confineTo == PanoramiXWinRoot->info[0].id)
- stuff->confineTo = None;
- }
-#endif
- if (stuff->confineTo == None)
- confineTo = NullWindow;
-#ifdef PANORAMIX
- else if ( !noPanoramiXExtension ) {
- if (stuff->confineTo) {
- pPanoramiXWin = PanoramiXWinRoot;
- PANORAMIXFIND_ID(pPanoramiXWin, stuff->confineTo);
- if (pPanoramiXWin) {
- for ( i = PanoramiXNumScreens - 1; i >=0 ; i--) {
- stuff->confineTo = pPanoramiXWin->info[i].id;
- confineTo = SecurityLookupWindow(stuff->confineTo, client,
- SecurityReadAccess);
- if (!confineTo)
- return BadWindow;
- /* find where confined windows top-left corner lies
- and based on its coordinates choose the window
- which is truly seen. Then check realized/empty
- and pass this window to activate grab. */
- if ((confineTo->drawable.x >= 0) &&
- (confineTo->drawable.x <= panoramiXdataPtr[i].x))
- break;
- }
- } else
- confineTo = SecurityLookupWindow(stuff->confineTo, client,
- SecurityReadAccess);
- if (!confineTo)
- return BadWindow;
- }
- } else {
-#else
- else {
-#endif
- confineTo = SecurityLookupWindow(stuff->confineTo, client,
- SecurityReadAccess);
- if (!confineTo)
- return BadWindow;
- }
- if (stuff->cursor == None)
- cursor = NullCursor;
- else
- {
- cursor = (CursorPtr)SecurityLookupIDByType(client, stuff->cursor,
- RT_CURSOR, SecurityReadAccess);
- if (!cursor)
- {
- client->errorValue = stuff->cursor;
- return BadCursor;
- }
- }
-
- grab = CreateGrab(client->index, inputInfo.pointer, pWin,
- permitOldBugs ? (Mask)(stuff->eventMask |
- ButtonPressMask | ButtonReleaseMask) :
- (Mask)stuff->eventMask,
- (Bool)stuff->ownerEvents, (Bool) stuff->keyboardMode,
- (Bool)stuff->pointerMode, inputInfo.keyboard, stuff->modifiers,
- ButtonPress, stuff->button, confineTo, cursor);
- if (!grab)
- return BadAlloc;
- return AddPassiveGrabToList(grab);
-}
-
-int
-ProcUngrabButton(client)
- ClientPtr client;
-{
- REQUEST(xUngrabButtonReq);
- WindowPtr pWin;
- GrabRec tempGrab;
-#ifdef PANORAMIX
- int i, PanoramiXNum;
- Window GrabWinID;
- PanoramiXWindow *pPanoramiXWin = PanoramiXWinRoot;
-#endif
-
- REQUEST_SIZE_MATCH(xUngrabButtonReq);
- if ((stuff->modifiers != AnyModifier) &&
- (stuff->modifiers & ~AllModifiersMask))
- {
- client->errorValue = stuff->modifiers;
- return BadValue;
- }
- pWin = SecurityLookupWindow(stuff->grabWindow, client, SecurityReadAccess);
- if (!pWin)
- return BadWindow;
-#ifdef PANORAMIX
- if ( !noPanoramiXExtension ){
- PanoramiXNum = (sprite.hotPhys.pScreen)->myNum;
- PANORAMIXFIND_ID(pPanoramiXWin, stuff->grabWindow);
- GrabWinID = pPanoramiXWin ?
- pPanoramiXWin->info[PanoramiXNum].id : stuff->grabWindow;
- pWin = SecurityLookupWindow(GrabWinID, client, SecurityReadAccess);
- }
-#endif
- tempGrab.resource = client->clientAsMask;
- tempGrab.device = inputInfo.pointer;
- tempGrab.window = pWin;
- tempGrab.modifiersDetail.exact = stuff->modifiers;
- tempGrab.modifiersDetail.pMask = NULL;
- tempGrab.modifierDevice = inputInfo.keyboard;
- tempGrab.type = ButtonPress;
- tempGrab.detail.exact = stuff->button;
- tempGrab.detail.pMask = NULL;
-
- if (!DeletePassiveGrabFromList(&tempGrab))
- return(BadAlloc);
- return(Success);
-}
-
-void
-DeleteWindowFromAnyEvents(pWin, freeResources)
- WindowPtr pWin;
- Bool freeResources;
-{
- WindowPtr parent;
- DeviceIntPtr mouse = inputInfo.pointer;
- DeviceIntPtr keybd = inputInfo.keyboard;
- FocusClassPtr focus = keybd->focus;
- OtherClientsPtr oc;
- GrabPtr passive;
-
-
- /* Deactivate any grabs performed on this window, before making any
- input focus changes. */
-
- if (mouse->grab &&
- ((mouse->grab->window == pWin) || (mouse->grab->confineTo == pWin)))
- (*mouse->DeactivateGrab)(mouse);
-
- /* Deactivating a keyboard grab should cause focus events. */
-
- if (keybd->grab && (keybd->grab->window == pWin))
- (*keybd->DeactivateGrab)(keybd);
-
- /* If the focus window is a root window (ie. has no parent) then don't
- delete the focus from it. */
-
- if ((pWin == focus->win) && (pWin->parent != NullWindow))
- {
- int focusEventMode = NotifyNormal;
-
- /* If a grab is in progress, then alter the mode of focus events. */
-
- if (keybd->grab)
- focusEventMode = NotifyWhileGrabbed;
-
- switch (focus->revert)
- {
- case RevertToNone:
- DoFocusEvents(keybd, pWin, NoneWin, focusEventMode);
- focus->win = NoneWin;
- focus->traceGood = 0;
- break;
- case RevertToParent:
- parent = pWin;
- do
- {
- parent = parent->parent;
- focus->traceGood--;
- } while (!parent->realized
-/* This would be a good protocol change -- windows being reparented
- during SaveSet processing would cause the focus to revert to the
- nearest enclosing window which will survive the death of the exiting
- client, instead of ending up reverting to a dying window and thence
- to None
- */
-#ifdef NOTDEF
- || clients[CLIENT_ID(parent->drawable.id)]->clientGone
-#endif
- );
- DoFocusEvents(keybd, pWin, parent, focusEventMode);
- focus->win = parent;
- focus->revert = RevertToNone;
- break;
- case RevertToPointerRoot:
- DoFocusEvents(keybd, pWin, PointerRootWin, focusEventMode);
- focus->win = PointerRootWin;
- focus->traceGood = 0;
- break;
- }
- }
-
- if (mouse->valuator->motionHintWindow == pWin)
- mouse->valuator->motionHintWindow = NullWindow;
-
- if (freeResources)
- {
- if (pWin->dontPropagate)
- DontPropagateRefCnts[pWin->dontPropagate]--;
- while ( (oc = wOtherClients(pWin)) )
- FreeResource(oc->resource, RT_NONE);
- while ( (passive = wPassiveGrabs(pWin)) )
- FreeResource(passive->resource, RT_NONE);
- }
-#ifdef XINPUT
- DeleteWindowFromAnyExtEvents(pWin, freeResources);
-#endif
-}
-
-/* Call this whenever some window at or below pWin has changed geometry */
-
-/*ARGSUSED*/
-void
-CheckCursorConfinement(pWin)
- WindowPtr pWin;
-{
- GrabPtr grab = inputInfo.pointer->grab;
- WindowPtr confineTo;
-
- if (grab && (confineTo = grab->confineTo))
- {
- if (!REGION_NOTEMPTY( confineTo->drawable.pScreen,
- &confineTo->borderSize))
- (*inputInfo.pointer->DeactivateGrab)(inputInfo.pointer);
- else if ((pWin == confineTo) || IsParent(pWin, confineTo))
- ConfineCursorToWindow(confineTo, TRUE, TRUE);
- }
-}
-
-Mask
-EventMaskForClient(pWin, client)
- WindowPtr pWin;
- ClientPtr client;
-{
- register OtherClientsPtr other;
-
- if (wClient (pWin) == client)
- return pWin->eventMask;
- for (other = wOtherClients(pWin); other; other = other->next)
- {
- if (SameClient(other, client))
- return other->mask;
- }
- return 0;
-}
-
-int
-ProcRecolorCursor(client)
- ClientPtr client;
-{
- CursorPtr pCursor;
- int nscr;
- ScreenPtr pscr;
- REQUEST(xRecolorCursorReq);
-
- REQUEST_SIZE_MATCH(xRecolorCursorReq);
- pCursor = (CursorPtr)SecurityLookupIDByType(client, stuff->cursor,
- RT_CURSOR, SecurityWriteAccess);
- if ( !pCursor)
- {
- client->errorValue = stuff->cursor;
- return (BadCursor);
- }
-
- pCursor->foreRed = stuff->foreRed;
- pCursor->foreGreen = stuff->foreGreen;
- pCursor->foreBlue = stuff->foreBlue;
-
- pCursor->backRed = stuff->backRed;
- pCursor->backGreen = stuff->backGreen;
- pCursor->backBlue = stuff->backBlue;
-
- for (nscr = 0; nscr < screenInfo.numScreens; nscr++)
- {
- pscr = screenInfo.screens[nscr];
- ( *pscr->RecolorCursor)(pscr, pCursor,
- (pCursor == sprite.current) &&
- (pscr == sprite.hotPhys.pScreen));
- }
- return (Success);
-}
-
-void
-WriteEventsToClient(pClient, count, events)
- ClientPtr pClient;
- int count;
- xEvent *events;
-{
- xEvent eventTo, *eventFrom;
- int i;
-#ifdef PANORAMIX
- PanoramiXWindow *pPanoramiXWin = PanoramiXWinRoot;
- int x_off = 0, y_off = 0;
- int j,NewId,OrigId;
-#endif
-
-#ifdef PANORAMIX
- if (!noPanoramiXExtension) {
- switch (events->u.u.type) {
- case ButtonPress : case ButtonRelease :
- case MotionNotify : case KeyPress :
- FORCE_ROOT(events->u.keyButtonPointer, j);
- events->u.keyButtonPointer.sameScreen = xTrue;
- for (i = 0; i < count; i++) {
- FORCE_WIN(events[i].u.keyButtonPointer.event, j);
- if (events[i].u.keyButtonPointer.child) {
- pPanoramiXWin = PanoramiXWinRoot;
- FORCE_WIN(events[i].u.keyButtonPointer.child, j);
- }
- }
- break;
- case EnterNotify : case LeaveNotify :
- FORCE_ROOT(events->u.enterLeave, j);
- for (i = 0; i < count; i++) {
- FORCE_WIN(events[i].u.enterLeave.event, j);
- if (events[i].u.enterLeave.child) {
- pPanoramiXWin = PanoramiXWinRoot;
- FORCE_WIN(events[i].u.enterLeave.child, j);
- }
- }
- break;
- case Expose :
- /* Need to do this count time, ensure no fake
- window ideas are send to client */
- for (i = 0; i < count; i++)
- FORCE_WIN(events[i].u.expose.window, j);
- break;
- case FocusOut :
- FORCE_WIN(events->u.focus.window, j);
- break;
- case FocusIn :
- FORCE_WIN(events->u.focus.window, j);
- break;
- case VisibilityNotify :
- FORCE_WIN(events->u.visibility.window, j);
- break;
- case GraphicsExpose :
- FORCE_WIN(events->u.graphicsExposure.drawable, j);
- break;
- case NoExpose :
- SKIP_FAKE_WINDOW(events->u.noExposure.drawable, j);
- break;
- case CreateNotify :
- FORCE_WIN(events->u.createNotify.parent, j);
- pPanoramiXWin = PanoramiXWinRoot;
- FORCE_WIN(events->u.createNotify.window, j);
- break;
- case ColormapNotify :
- FORCE_WIN(events->u.colormap.window, j);
- pPanoramiXWin = PanoramiXWinRoot;
- FORCE_WIN(events->u.colormap.colormap, j);
- break;
- case MapNotify :
- SKIP_FAKE_WINDOW(events->u.mapNotify.event, j);
- pPanoramiXWin = PanoramiXWinRoot;
- SKIP_FAKE_WINDOW(events->u.mapNotify.window, j);
- break;
- case UnmapNotify :
- SKIP_FAKE_WINDOW(events->u.unmapNotify.event, j);
- pPanoramiXWin = PanoramiXWinRoot;
- SKIP_FAKE_WINDOW(events->u.unmapNotify.window, j);
- break;
- case DestroyNotify :
- SKIP_FAKE_WINDOW(events->u.destroyNotify.event, j);
- pPanoramiXWin = PanoramiXWinRoot;
- SKIP_FAKE_WINDOW(events->u.destroyNotify.window, j);
- break;
- case GravityNotify :
- FORCE_WIN(events->u.gravity.event, j);
- pPanoramiXWin = PanoramiXWinRoot;
- FORCE_WIN(events->u.gravity.window, j);
- break;
- case MapRequest :
- SKIP_FAKE_WINDOW(events->u.mapRequest.parent, j);
- pPanoramiXWin = PanoramiXWinRoot;
- SKIP_FAKE_WINDOW(events->u.mapRequest.window, j);
- break;
- case ConfigureNotify :
- FORCE_WIN(events->u.configureNotify.event, j);
- pPanoramiXWin = PanoramiXWinRoot;
- FORCE_WIN(events->u.configureNotify.window, j);
- pPanoramiXWin = PanoramiXWinRoot;
- FORCE_WIN(events->u.configureNotify.aboveSibling, j);
- break;
- case ConfigureRequest :
- SKIP_FAKE_WINDOW(events->u.configureRequest.parent, j);
- pPanoramiXWin = PanoramiXWinRoot;
- SKIP_FAKE_WINDOW(events->u.configureRequest.window, j);
- pPanoramiXWin = PanoramiXWinRoot;
- SKIP_FAKE_WINDOW(events->u.configureRequest.sibling, j);
- break;
- case ResizeRequest :
- FORCE_WIN(events->u.resizeRequest.window, j);
- break;
- case CirculateNotify : case CirculateRequest :
- case ReparentNotify :
- FORCE_WIN(events->u.circulate.event, j);
- pPanoramiXWin = PanoramiXWinRoot;
- FORCE_WIN(events->u.circulate.window, j);
- pPanoramiXWin = PanoramiXWinRoot;
- FORCE_WIN(events->u.circulate.parent, j);
- break;
- case PropertyNotify :
- SKIP_FAKE_WINDOW(events->u.property.window, j);
- break;
- case ClientMessage :
- SKIP_FAKE_WINDOW(events->u.clientMessage.window, j);
- break;
- default :
- switch (events->u.u.type & ~0x80) {
- case VisibilityNotify :
- FORCE_WIN(events->u.visibility.window, j);
- break;
- case MapNotify :
- SKIP_FAKE_WINDOW(events->u.mapNotify.event, j);
- pPanoramiXWin = PanoramiXWinRoot;
- SKIP_FAKE_WINDOW(events->u.mapNotify.window, j);
- break;
- case UnmapNotify :
- SKIP_FAKE_WINDOW(events->u.unmapNotify.event, j);
- pPanoramiXWin = PanoramiXWinRoot;
- SKIP_FAKE_WINDOW(events->u.unmapNotify.window, j);
- case MapRequest :
- SKIP_FAKE_WINDOW(events->u.mapRequest.parent, j);
- pPanoramiXWin = PanoramiXWinRoot;
- SKIP_FAKE_WINDOW(events->u.mapRequest.window, j);
- break;
- case ConfigureNotify :
- FORCE_WIN(events->u.configureNotify.event, j);
- pPanoramiXWin = PanoramiXWinRoot;
- FORCE_WIN(events->u.configureNotify.window, j);
- pPanoramiXWin = PanoramiXWinRoot;
- FORCE_WIN(events->u.configureNotify.aboveSibling, j);
- break;
- case ConfigureRequest :
- SKIP_FAKE_WINDOW(events->u.configureRequest.parent, j);
- pPanoramiXWin = PanoramiXWinRoot;
- SKIP_FAKE_WINDOW(events->u.configureRequest.window, j);
- pPanoramiXWin = PanoramiXWinRoot;
- SKIP_FAKE_WINDOW(events->u.configureRequest.sibling, j);
- break;
- default :
- break;
- } /* default case */
- break;
- } /* case */
- }
-#endif
-
-#ifdef XKB
- if ((!noXkbExtension)&&(!XkbFilterEvents(pClient, count, events)))
- return;
-#endif
-
- if (EventCallback)
- {
- EventInfoRec eventinfo;
- eventinfo.client = pClient;
- eventinfo.events = events;
- eventinfo.count = count;
- CallCallbacks(&EventCallback, (pointer)&eventinfo);
- }
- if(pClient->swapped)
- {
- for(i = 0; i < count; i++)
- {
- eventFrom = &events[i];
- /* Remember to strip off the leading bit of type in case
- this event was sent with "SendEvent." */
- (*EventSwapVector[eventFrom->u.u.type & 0177])
- (eventFrom, &eventTo);
- (void)WriteToClient(pClient, sizeof(xEvent), (char *)&eventTo);
- }
- }
- else
- {
- (void)WriteToClient(pClient, count * sizeof(xEvent), (char *) events);
- }
-}
diff --git a/programs/Xserver/pandix/main.c b/programs/Xserver/pandix/main.c
deleted file mode 100644
index 5e91f6357..000000000
--- a/programs/Xserver/pandix/main.c
+++ /dev/null
@@ -1,756 +0,0 @@
-
-/****************************************************************
-* *
-* Copyright (c) Digital Equipment Corporation, 1991, 1997 *
-* *
-* All Rights Reserved. Unpublished rights reserved under *
-* the copyright laws of the United States. *
-* *
-* The software contained on this media is proprietary to *
-* and embodies the confidential technology of Digital *
-* Equipment Corporation. Possession, use, duplication or *
-* dissemination of the software and media is authorized only *
-* pursuant to a valid written license from Digital Equipment *
-* Corporation. *
-* *
-* RESTRICTED RIGHTS LEGEND Use, duplication, or disclosure *
-* by the U.S. Government is subject to restrictions as set *
-* forth in Subparagraph (c)(1)(ii) of DFARS 252.227-7013, *
-* or in FAR 52.227-19, as applicable. *
-* *
-*****************************************************************/
-/***********************************************************
-
-Copyright (c) 1987 X Consortium
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-X CONSORTIUM 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 X Consortium 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 X Consortium.
-
-
-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.
-
-******************************************************************/
-/* $TOG: main.c /main/1 1997/10/29 13:27:25 kaleb $ */
-
-#include "X.h"
-#include "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 "font.h"
-#include "opaque.h"
-#include "servermd.h"
-#include "site.h"
-#include "dixfont.h"
-
-extern CARD32 defaultScreenSaverTime;
-extern CARD32 defaultScreenSaverInterval;
-extern int defaultScreenSaverBlanking;
-extern int defaultScreenSaverAllowExposures;
-
-#ifdef DPMSExtension
-#indlude "dpms.h"
-#endif
-
-void ddxGiveUp();
-
-extern int InitClientPrivates(
-#if NeedFunctionPrototypes
- ClientPtr /*client*/
-#endif
-);
-
-extern void Dispatch(
-#if NeedFunctionPrototypes
- void
-#endif
-);
-
-extern char *display;
-char *ConnectionInfo;
-xConnSetupPrefix connSetupPrefix;
-
-extern WindowPtr *WindowTable;
-extern FontPtr defaultFont;
-extern int screenPrivateCount;
-
-extern void InitProcVectors();
-extern void InitEvents();
-extern void DefineInitialRootWindow();
-extern Bool CreateGCperDepthArray();
-
-#ifdef PANORAMIX
-Bool CreateConnectionBlock(
-#else
-static Bool CreateConnectionBlock(
-#endif
-#if NeedFunctionPrototypes
- void
-#endif
-);
-
-static void FreeScreen(
-#if NeedFunctionPrototypes
- ScreenPtr /*pScreen*/
-#endif
-);
-
-#ifdef PANORAMIX
-extern Bool noPanoramiXExtension;
-extern void PanoramiXConsolidate(void);
-extern Bool PanoramiXCreateConnectionBlock(void);
-extern Bool PanoramiXCreateScreenRegion(
-#if NeedFunctionPrototypes
- WindowPtr
-#endif
-);
-#endif
-
-PaddingInfo PixmapWidthPaddingInfo[33];
-
-#ifdef INTERNAL_VS_EXTERNAL_PADDING
-/* add padding info for 32-bit interface. PutImage and GetImage will
- * work on 32-bit padding while the rest of the server will work
- * on 64-bit padding (Alpha).
- */
-PaddingInfo PixmapWidthPaddingInfoProto[33];
-#endif
-
-int connBlockScreenStart;
-
-static int restart = 0;
-
-void
-NotImplemented()
-{
- FatalError("Not implemented");
-}
-
-/*
- * This array encodes the answer to the question "what is the log base 2
- * of the number of pixels that fit in a scanline pad unit?"
- * Note that ~0 is an invalid entry (mostly for the benefit of the reader).
- */
-static int answer[6][4] = {
- /* pad pad pad pad*/
- /* 8 16 32 64 */
-
- { 3, 4, 5 , 6 }, /* 1 bit per pixel */
- { 1, 2, 3 , 4 }, /* 4 bits per pixel */
- { 0, 1, 2 , 3 }, /* 8 bits per pixel */
- { ~0, 0, 1 , 2 }, /* 16 bits per pixel */
- { ~0, ~0, 0 , 1 }, /* 24 bits per pixel */
- { ~0, ~0, 0 , 1 } /* 32 bits per pixel */
-};
-
-/*
- * This array gives the answer to the question "what is the first index for
- * the answer array above given the number of bits per pixel?"
- * Note that ~0 is an invalid entry (mostly for the benefit of the reader).
- */
-static int indexForBitsPerPixel[ 33 ] = {
- ~0, 0, ~0, ~0, /* 1 bit per pixel */
- 1, ~0, ~0, ~0, /* 4 bits per pixel */
- 2, ~0, ~0, ~0, /* 8 bits per pixel */
- ~0,~0, ~0, ~0,
- 3, ~0, ~0, ~0, /* 16 bits per pixel */
- ~0,~0, ~0, ~0,
- 4, ~0, ~0, ~0, /* 24 bits per pixel */
- ~0,~0, ~0, ~0,
- 5 /* 32 bits per pixel */
-};
-
-/*
- * This array gives the answer to the question "what is the second index for
- * the answer array above given the number of bits per scanline pad unit?"
- * Note that ~0 is an invalid entry (mostly for the benefit of the reader).
- */
-static int indexForScanlinePad[ 65 ] = {
- ~0, ~0, ~0, ~0,
- ~0, ~0, ~0, ~0,
- 0, ~0, ~0, ~0, /* 8 bits per scanline pad unit */
- ~0, ~0, ~0, ~0,
- 1, ~0, ~0, ~0, /* 16 bits per scanline pad unit */
- ~0, ~0, ~0, ~0,
- ~0, ~0, ~0, ~0,
- ~0, ~0, ~0, ~0,
- 2, ~0, ~0, ~0, /* 32 bits per scanline pad unit */
- ~0, ~0, ~0, ~0,
- ~0, ~0, ~0, ~0,
- ~0, ~0, ~0, ~0,
- ~0, ~0, ~0, ~0,
- ~0, ~0, ~0, ~0,
- ~0, ~0, ~0, ~0,
- ~0, ~0, ~0, ~0,
- 3 /* 64 bits per scanline pad unit */
-};
-
-#ifndef MIN
-#define MIN(a,b) (((a) < (b)) ? (a) : (b))
-#endif
-
-int
-main(argc, argv)
- int argc;
- char *argv[];
-{
- int i, j, k;
- HWEventQueueType alwaysCheckForInput[2];
-
- /* Notice if we're restart. Probably this is because we jumped through
- * uninitialized pointer */
- if (restart)
- FatalError("server restarted. Jumped through uninitialized pointer?\n");
- else
- restart = 1;
-
-#ifdef COMMANDLINE_CHALLENGED_OPERATING_SYSTEMS
- ExpandCommandLine(&argc, &argv);
-#endif
-
-#ifdef _SC_OPEN_MAX
- /* if sysconf(_SC_OPEN_MAX) is supported, at runtime MaxClients will be
- * reassigned instead of using MAXSOCKS */
- if (MaxClients == 0)
- MaxClients = MIN(MAXCLIENTS, sysconf(_SC_OPEN_MAX));
-#endif
-
- /* 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;
- display = "0";
- 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 *)xalloc(MAXCLIENTS * sizeof(ClientPtr));
- if (!clients)
- FatalError("couldn't create client array");
- for (i=1; i<MAXCLIENTS; i++)
- clients[i] = NullClient;
- serverClient = (ClientPtr)xalloc(sizeof(ClientRec));
- if (!serverClient)
- FatalError("couldn't create server client");
- InitClient(serverClient, 0, (pointer)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;
- screenInfo.numVideoScreens = -1;
- WindowTable = (WindowPtr *)xalloc(MAXSCREENS * sizeof(WindowPtr));
- if (!WindowTable)
- FatalError("couldn't create root window table");
-
- /*
- * Just in case the ddx doesnt supply a format for depth 1 (like qvss).
- */
- j = indexForBitsPerPixel[ 1 ];
- k = indexForScanlinePad[ BITMAP_SCANLINE_PAD ];
- PixmapWidthPaddingInfo[1].padRoundUp = BITMAP_SCANLINE_PAD-1;
- PixmapWidthPaddingInfo[1].padPixelsLog2 = answer[j][k];
- j = indexForBitsPerPixel[8]; /* bits per byte */
- PixmapWidthPaddingInfo[1].padBytesLog2 = answer[j][k];
-
-#ifdef INTERNAL_VS_EXTERNAL_PADDING
- /* Fake out protocol interface to make them believe we support
- * a different padding than the actual internal padding.
- */
- j = indexForBitsPerPixel[ 1 ];
- k = indexForScanlinePad[ BITMAP_SCANLINE_PAD_PROTO ];
- PixmapWidthPaddingInfoProto[1].padRoundUp = BITMAP_SCANLINE_PAD_PROTO-1;
- PixmapWidthPaddingInfoProto[1].padPixelsLog2 = answer[j][k];
- j = indexForBitsPerPixel[8]; /* bits per byte */
- PixmapWidthPaddingInfoProto[1].padBytesLog2 = answer[j][k];
-#endif /* INTERNAL_VS_EXTERNAL_PADDING */
-
- InitAtoms();
- InitEvents();
- InitGlyphCaching();
- ResetClientPrivates();
- ResetScreenPrivates();
- ResetWindowPrivates();
- ResetGCPrivates();
-#ifdef PIXPRIV
- ResetPixmapPrivates();
-#endif
- ResetColormapPrivates();
- ResetFontPrivateIndex();
- InitCallbackManager();
- InitOutput(&screenInfo, argc, argv);
- if (screenInfo.numScreens < 1)
- FatalError("no screens found");
- if (screenInfo.numVideoScreens < 0)
- screenInfo.numVideoScreens = screenInfo.numScreens;
-#ifdef XPRINT
- PrinterInitOutput(&screenInfo, argc, argv);
-#endif
- 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");
-
- InitFonts();
- if (SetDefaultFontPath(defaultFontPath) != Success)
- ErrorF("failed to set default font path '%s'", 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 colormap information for each screen
- */
-
- if (!noPanoramiXExtension)
- PanoramiXConsolidate();
-#endif
-
- for (i = 0; i < screenInfo.numScreens; i++)
- InitRootWindow(WindowTable[i]);
- DefineInitialRootWindow(WindowTable[0]);
-
-#ifdef PANORAMIX
- if (!noPanoramiXExtension) {
- if (!PanoramiXCreateConnectionBlock())
- FatalError("could not create connection block info");
- if (!PanoramiXCreateScreenRegion(WindowTable[0]))
- FatalError("could not create PanoramiX Screen Region");
- } else
-#endif
- {
- if (!CreateConnectionBlock())
- FatalError("could not create connection block info");
- }
-
- Dispatch();
-
- /* Now free up whatever must be freed */
- if (screenIsSaved == SCREEN_SAVER_ON)
- SaveScreens(SCREEN_SAVER_OFF, ScreenSaverReset);
- CloseDownExtensions();
-
-#ifdef PANORAMIX
- {
- Bool remember_it = noPanoramiXExtension;
- noPanoramiXExtension = TRUE;
- FreeAllResources();
- noPanoramiXExtension = remember_it;
- }
-#else
- FreeAllResources();
-#endif
-
- CloseDownDevices();
- for (i = screenInfo.numScreens - 1; i >= 0; i--)
- {
- FreeScratchPixmapsForScreen(i);
- FreeGCperDepth(i);
- FreeDefaultStipple(i);
- (* screenInfo.screens[i]->CloseScreen)(i, screenInfo.screens[i]);
- FreeScreen(screenInfo.screens[i]);
- screenInfo.numScreens = i;
- }
- xfree(WindowTable);
- FreeFonts ();
- xfree(serverClient->devPrivates);
-
- if (dispatchException & DE_TERMINATE)
- {
- ddxGiveUp();
- break;
- }
-
- xfree(ConnectionInfo);
- }
- return(0);
-}
-
-static int padlength[4] = {0, 3, 2, 1};
-
-#ifdef PANORAMIX
-Bool
-#else
-static Bool
-#endif
-CreateConnectionBlock()
-{
- xConnSetup setup;
- xWindowRoot root;
- xDepth depth;
- xVisualType visual;
- xPixmapFormat format;
- unsigned long vid;
- int i, j, k,
- lenofblock,
- sizesofar = 0;
- char *pBuf;
-
-
- /* Leave off the ridBase and ridMask, these must be sent with
- connection */
-
- setup.release = VENDOR_RELEASE;
- /*
- * per-server image and bitmap parameters are defined in Xmd.h
- */
- setup.imageByteOrder = screenInfo.imageByteOrder;
-
-#ifdef INTERNAL_VS_EXTERNAL_PADDING
- if ( screenInfo.bitmapScanlineUnit > 32 )
- setup.bitmapScanlineUnit = 32;
- else
-#endif
- setup.bitmapScanlineUnit = screenInfo.bitmapScanlineUnit;
-#ifdef INTERNAL_VS_EXTERNAL_PADDING
- if ( screenInfo.bitmapScanlinePad > 32 )
- setup.bitmapScanlinePad = 32;
- else
-#endif
- setup.bitmapScanlinePad = screenInfo.bitmapScanlinePad;
-
- setup.bitmapBitOrder = screenInfo.bitmapBitOrder;
- setup.motionBufferSize = NumMotionEvents();
- setup.numRoots = screenInfo.numScreens;
- setup.nbytesVendor = strlen(VENDOR_STRING);
- 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 *) xalloc(lenofblock);
- if (!ConnectionInfo)
- return FALSE;
-
- memmove(ConnectionInfo, (char *)&setup, sizeof(xConnSetup));
- sizesofar = sizeof(xConnSetup);
- pBuf = ConnectionInfo + sizeof(xConnSetup);
-
- memmove(pBuf, VENDOR_STRING, (int)setup.nbytesVendor);
- sizesofar += setup.nbytesVendor;
- pBuf += setup.nbytesVendor;
- i = padlength[setup.nbytesVendor & 3];
- sizesofar += i;
- while (--i >= 0)
- *pBuf++ = 0;
-
- for (i=0; i<screenInfo.numPixmapFormats; i++)
- {
- format.depth = screenInfo.formats[i].depth;
- format.bitsPerPixel = screenInfo.formats[i].bitsPerPixel;
-#ifdef INTERNAL_VS_EXTERNAL_PADDING
- if ( screenInfo.formats[i].scanlinePad > 32 )
- format.scanLinePad = 32;
- else
-#endif
- format.scanLinePad = screenInfo.formats[i].scanlinePad;
- memmove(pBuf, (char *)&format, sizeof(xPixmapFormat));
- pBuf += sizeof(xPixmapFormat);
- sizesofar += sizeof(xPixmapFormat);
- }
-
- connBlockScreenStart = sizesofar;
- for (i=0; i<screenInfo.numScreens; i++)
- {
- ScreenPtr pScreen;
- DepthPtr pDepth;
- VisualPtr pVisual;
-
- pScreen = screenInfo.screens[i];
- root.windowId = WindowTable[i]->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 *)xrealloc(ConnectionInfo, lenofblock);
- if (!pBuf)
- {
- xfree(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;
-}
-
-/*
- grow the array of screenRecs if necessary.
- call the device-supplied initialization procedure
-with its screen number, a pointer to its ScreenRec, argc, and argv.
- return the number of successfully installed screens.
-
-*/
-
-int
-AddScreen(pfnInit, argc, argv)
- Bool (* pfnInit)();
- int argc;
- char **argv;
-{
-
- int i;
- int scanlinepad, format, depth, bitsPerPixel, j, k;
- ScreenPtr pScreen;
-#ifdef DEBUG
- void (**jNI) ();
-#endif /* DEBUG */
-
- i = screenInfo.numScreens;
- if (i == MAXSCREENS)
- return -1;
-
- pScreen = (ScreenPtr) xalloc(sizeof(ScreenRec));
- if (!pScreen)
- return -1;
-
- pScreen->devPrivates = (DevUnion *)xalloc(screenPrivateCount *
- sizeof(DevUnion));
- if (!pScreen->devPrivates && screenPrivateCount)
- {
- xfree(pScreen);
- return -1;
- }
- pScreen->myNum = i;
- pScreen->WindowPrivateLen = 0;
- pScreen->WindowPrivateSizes = (unsigned *)NULL;
- pScreen->totalWindowSize = sizeof(WindowRec);
- pScreen->GCPrivateLen = 0;
- pScreen->GCPrivateSizes = (unsigned *)NULL;
- pScreen->totalGCSize = sizeof(GC);
-#ifdef PIXPRIV
- pScreen->PixmapPrivateLen = 0;
- pScreen->PixmapPrivateSizes = (unsigned *)NULL;
- pScreen->totalPixmapSize = sizeof(PixmapRec);
-#endif
- pScreen->ClipNotify = (void (*)())NULL; /* for R4 ddx compatibility */
- pScreen->CreateScreenResources = (Bool (*)())NULL;
-
-#ifdef DEBUG
- for (jNI = &pScreen->QueryBestSize;
- jNI < (void (**) ()) &pScreen->SendGraphicsExpose;
- jNI++)
- *jNI = NotImplemented;
-#endif /* DEBUG */
-
- /*
- * This loop gets run once for every Screen that gets added,
- * but thats ok. If the ddx layer initializes the formats
- * one at a time calling AddScreen() after each, then each
- * iteration will make it a little more accurate. Worst case
- * we do this loop N * numPixmapFormats where N is # of screens.
- * Anyway, this must be called after InitOutput and before the
- * screen init routine is called.
- */
- for (format=0; format<screenInfo.numPixmapFormats; format++)
- {
- depth = screenInfo.formats[format].depth;
- bitsPerPixel = screenInfo.formats[format].bitsPerPixel;
- scanlinepad = screenInfo.formats[format].scanlinePad;
- j = indexForBitsPerPixel[ bitsPerPixel ];
- k = indexForScanlinePad[ scanlinepad ];
- PixmapWidthPaddingInfo[ depth ].padPixelsLog2 = answer[j][k];
- PixmapWidthPaddingInfo[ depth ].padRoundUp =
- (scanlinepad/bitsPerPixel) - 1;
- j = indexForBitsPerPixel[ 8 ]; /* bits per byte */
- PixmapWidthPaddingInfo[ depth ].padBytesLog2 = answer[j][k];
-
-#ifdef INTERNAL_VS_EXTERNAL_PADDING
- /* Fake out protocol interface to make them believe we support
- * a different padding than the actual internal padding.
- */
- j = indexForBitsPerPixel[ bitsPerPixel ];
- k = indexForScanlinePad[ BITMAP_SCANLINE_PAD_PROTO ];
- PixmapWidthPaddingInfoProto[ depth ].padPixelsLog2 = answer[j][k];
- PixmapWidthPaddingInfoProto[ depth ].padRoundUp =
- (BITMAP_SCANLINE_PAD_PROTO/bitsPerPixel) - 1;
- j = indexForBitsPerPixel[ 8 ]; /* bits per byte */
- PixmapWidthPaddingInfoProto[ depth ].padBytesLog2 = answer[j][k];
-#endif /* INTERNAL_VS_EXTERNAL_PADDING */
- }
-
- /* This is where screen specific stuff gets initialized. Load the
- screen structure, call the hardware, whatever.
- This is also where the default colormap should be allocated and
- also pixel values for blackPixel, whitePixel, and the cursor
- Note that InitScreen is NOT allowed to modify argc, argv, or
- any of the strings pointed to by argv. They may be passed to
- multiple screens.
- */
- pScreen->rgf = ~0L; /* there are no scratch GCs yet*/
- WindowTable[i] = NullWindow;
- screenInfo.screens[i] = pScreen;
- screenInfo.numScreens++;
- if (!(*pfnInit)(i, pScreen, argc, argv))
- {
- FreeScreen(pScreen);
- screenInfo.numScreens--;
- return -1;
- }
- return i;
-}
-
-static void
-FreeScreen(pScreen)
- ScreenPtr pScreen;
-{
- xfree(pScreen->WindowPrivateSizes);
- xfree(pScreen->GCPrivateSizes);
-#ifdef PIXPRIV
- xfree(pScreen->PixmapPrivateSizes);
-#endif
- xfree(pScreen->devPrivates);
- xfree(pScreen);
-}
diff --git a/programs/Xserver/pandix/resource.c b/programs/Xserver/pandix/resource.c
deleted file mode 100644
index 920234efe..000000000
--- a/programs/Xserver/pandix/resource.c
+++ /dev/null
@@ -1,981 +0,0 @@
-
-/****************************************************************
-* *
-* Copyright (c) Digital Equipment Corporation, 1991, 1997 *
-* *
-* All Rights Reserved. Unpublished rights reserved under *
-* the copyright laws of the United States. *
-* *
-* The software contained on this media is proprietary to *
-* and embodies the confidential technology of Digital *
-* Equipment Corporation. Possession, use, duplication or *
-* dissemination of the software and media is authorized only *
-* pursuant to a valid written license from Digital Equipment *
-* Corporation. *
-* *
-* RESTRICTED RIGHTS LEGEND Use, duplication, or disclosure *
-* by the U.S. Government is subject to restrictions as set *
-* forth in Subparagraph (c)(1)(ii) of DFARS 252.227-7013, *
-* or in FAR 52.227-19, as applicable. *
-* *
-*****************************************************************/
-/************************************************************
-
-Copyright (c) 1987 X Consortium
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-X CONSORTIUM 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 X Consortium 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 X Consortium.
-
-
-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.
-
-********************************************************/
-
-/* $TOG: resource.c /main/1 1997/10/29 13:27:29 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 3 bits of which are
- * off-limits for client-visible resources. The next 7 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 30th 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.
- */
-
-#include "X.h"
-#include "misc.h"
-#include "os.h"
-#include "resource.h"
-#include "dixstruct.h"
-#include "opaque.h"
-#include "windowstr.h"
-#ifdef PANORAMIX
-#include "panoramiX.h"
-#endif
-extern WindowPtr *WindowTable;
-#include <assert.h>
-
-#ifdef PANORAMIX
-extern PanoramiXWindow *PanoramiXWinRoot;
-extern PanoramiXGC *PanoramiXGCRoot;
-extern PanoramiXCmap *PanoramiXCmapRoot;
-extern PanoramiXPmap *PanoramiXPmapRoot;
-extern Bool noPanoramiXExtension;
-extern int PanoramiXNumScreens;
-#endif /* PANORAMIX */
-
-static void RebuildTable(
-#if NeedFunctionPrototypes
- int /*client*/
-#endif
-);
-
-#define SERVER_MINID 32
-
-#define INITBUCKETS 64
-#define INITHASHSIZE 6
-#define MAXHASHSIZE 11
-
-typedef struct _Resource {
- struct _Resource *next;
- XID id;
- RESTYPE type;
- pointer 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;
-
-static RESTYPE lastResourceType;
-static RESTYPE lastResourceClass;
-static RESTYPE TypeMask;
-
-static DeleteType *DeleteFuncs = (DeleteType *)NULL;
-
-RESTYPE
-CreateNewResourceType(deleteFunc)
- DeleteType deleteFunc;
-{
- RESTYPE next = lastResourceType + 1;
- DeleteType *funcs;
-
- if (next & lastResourceClass)
- return 0;
- funcs = (DeleteType *)xrealloc(DeleteFuncs,
- (next + 1) * sizeof(DeleteType));
- if (!funcs)
- return 0;
- 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(client)
- ClientPtr client;
-{
- register int i, j;
-
- if (client == serverClient)
- {
- extern int DeleteWindow(), dixDestroyPixmap(), FreeGC();
- extern int CloseFont(), FreeCursor();
- extern int FreeColormap(), FreeClientPixels();
- extern int OtherClientGone(), DeletePassiveGrab();
-
- lastResourceType = RT_LASTPREDEF;
- lastResourceClass = RC_LASTPREDEF;
- TypeMask = RC_LASTPREDEF - 1;
- if (DeleteFuncs)
- xfree(DeleteFuncs);
- DeleteFuncs = (DeleteType *)xalloc((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;
- }
- clientTable[i = client->index].resources =
- (ResourcePtr *)xalloc(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(client, id)
- 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(client, id, maxid, goodid)
- register int client;
- register XID id, maxid, 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(client, server, minp, maxp)
- int client;
- Bool server;
- XID *minp, *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(pClient, count, pids)
- ClientPtr pClient;
- unsigned int 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(client)
- 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;
-}
-
-Bool
-AddResource(id, type, value)
- XID id;
- RESTYPE type;
- pointer value;
-{
- int client;
- register ClientResourceRec *rrec;
- register ResourcePtr res, *head;
-
- client = CLIENT_ID(id);
- rrec = &clientTable[client];
- if (!rrec->buckets)
- {
- ErrorF("AddResource(%x, %x, %x), client=%d \n",
- 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)xalloc(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;
-}
-
-static void
-RebuildTable(client)
- 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 **)ALLOCATE_LOCAL(j * sizeof(ResourcePtr *));
- if (!tails)
- return;
- resources = (ResourcePtr *)xalloc(j * sizeof(ResourcePtr));
- if (!resources)
- {
- DEALLOCATE_LOCAL(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;
- }
- }
- DEALLOCATE_LOCAL(tails);
- clientTable[client].buckets *= 2;
- xfree(clientTable[client].resources);
- clientTable[client].resources = resources;
-}
-
-void
-FreeResource(id, skipDeleteFuncType)
- XID id;
- RESTYPE skipDeleteFuncType;
-{
- int cid;
- register ResourcePtr res;
- register ResourcePtr *prev, *head;
- register int *eltptr;
- int elements;
- Bool gotOne = FALSE;
-#ifdef PANORAMIX
- PanoramiXGC *pPanoramiXGC;
- PanoramiXGC *pPanoramiXGCback = NULL;
- PanoramiXWindow *pPanoramiXWin;
- PanoramiXWindow *pPanoramiXWinback = NULL;
- PanoramiXCmap *pPanoramiXCmap;
- PanoramiXCmap *pPanoramiXCmapback = NULL;
- PanoramiXPmap *pPanoramiXPmap;
- PanoramiXPmap *pPanoramiXPmapback = NULL;
- XID FreeID, FoundID ;
- RESTYPE PanoramiXType;
-
-#endif
- 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 & RC_CACHED)
- FlushClientCaches(res->id);
- if (rtype != skipDeleteFuncType)
- (*DeleteFuncs[rtype & TypeMask])(res->value, res->id);
-#ifdef PANORAMIX
- if (!noPanoramiXExtension) {
- FoundID = 0;
- FreeID = res->id;
- PanoramiXType = res->type;
- PANORAMIX_MARKFREE(FreeID,PanoramiXType);
- }
-#endif
- xfree(res);
- if (*eltptr != elements)
- prev = head; /* prev may no longer be valid */
- gotOne = TRUE;
- }
- else
- prev = &res->next;
- }
- if(clients[cid] && (id == clients[cid]->lastDrawableID))
- {
- clients[cid]->lastDrawable = (DrawablePtr)WindowTable[0];
- clients[cid]->lastDrawableID = WindowTable[0]->drawable.id;
- }
- }
- if (!gotOne)
- FatalError("Freeing resource id=%X which isn't there", id);
-}
-
-
-void
-FreeResourceByType(id, type, skipFree)
- XID id;
- RESTYPE type;
- Bool skipFree;
-{
- int cid;
- register ResourcePtr res;
- register ResourcePtr *prev, *head;
-#ifdef PANORAMIX
- PanoramiXGC *pPanoramiXGC;
- PanoramiXGC *pPanoramiXGCback = NULL;
- PanoramiXWindow *pPanoramiXWin;
- PanoramiXWindow *pPanoramiXWinback = NULL;
- PanoramiXCmap *pPanoramiXCmap;
- PanoramiXCmap *pPanoramiXCmapback = NULL;
- PanoramiXPmap *pPanoramiXPmap;
- PanoramiXPmap *pPanoramiXPmapback = NULL;
- XID FreeID, FoundID;
- RESTYPE PanoramiXType;
-
-#endif
- 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 (type & RC_CACHED)
- FlushClientCaches(res->id);
- if (!skipFree)
- (*DeleteFuncs[type & TypeMask])(res->value, res->id);
-#ifdef PANORAMIX
- if (!noPanoramiXExtension) {
- FoundID = 0;
- FreeID = res->id;
- PanoramiXType = res->type;
- PANORAMIX_MARKFREE(FreeID,PanoramiXType);
- }
-#endif
- xfree(res);
- break;
- }
- else
- prev = &res->next;
- }
- if(clients[cid] && (id == clients[cid]->lastDrawableID))
- {
- clients[cid]->lastDrawable = (DrawablePtr)WindowTable[0];
- clients[cid]->lastDrawableID = WindowTable[0]->drawable.id;
- }
- }
-}
-
-/*
- * Change the value associated with a resource id. Caller
- * is responsible for "doing the right thing" with the old
- * data
- */
-
-Bool
-ChangeResourceValue (id, rtype, value)
- XID id;
- RESTYPE rtype;
- pointer 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))
- {
- if (rtype & RC_CACHED)
- FlushClientCaches(res->id);
- 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!
- */
-
-void
-FindClientResourcesByType(client, type, func, cdata)
- ClientPtr client;
- RESTYPE type;
- FindResType func;
- pointer 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
-FreeClientNeverRetainResources(client)
- ClientPtr client;
-{
- ResourcePtr *resources;
- ResourcePtr this;
- ResourcePtr *prev;
- int j;
-
-#ifdef PANORAMIX
- PanoramiXGC *pPanoramiXGC;
- PanoramiXGC *pPanoramiXGCback = NULL;
- PanoramiXWindow *pPanoramiXWin;
- PanoramiXWindow *pPanoramiXWinback = NULL;
- PanoramiXCmap *pPanoramiXCmap;
- PanoramiXCmap *pPanoramiXCmapback = NULL;
- PanoramiXPmap *pPanoramiXPmap;
- PanoramiXPmap *pPanoramiXPmapback = NULL;
- XID FreeID, FoundID;
- RESTYPE PanoramiXType;
-#endif
-
- 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;
- if (rtype & RC_CACHED)
- FlushClientCaches(this->id);
- (*DeleteFuncs[rtype & TypeMask])(this->value, this->id);
-#ifdef PANORAMIX
- if (!noPanoramiXExtension) {
- FoundID = 0;
- FreeID = this->id;
- PanoramiXType = this->type;
- PANORAMIX_MARKFREE(FreeID,PanoramiXType);
- }
-#endif
- xfree(this);
- }
- else
- prev = &this->next;
- }
- }
-}
-
-void
-FreeClientResources(client)
- ClientPtr client;
-{
- register ResourcePtr *resources;
- register ResourcePtr this;
- int j;
-#ifdef PANORAMIX
- PanoramiXGC *pPanoramiXGC;
- PanoramiXGC *pPanoramiXGCback = NULL;
- PanoramiXWindow *pPanoramiXWin;
- PanoramiXWindow *pPanoramiXWinback = NULL;
- PanoramiXCmap *pPanoramiXCmap;
- PanoramiXCmap *pPanoramiXCmapback = NULL;
- PanoramiXPmap *pPanoramiXPmap;
- PanoramiXPmap *pPanoramiXPmapback = NULL;
- XID FreeID, FoundID = 0;
- RESTYPE PanoramiXType;
-#endif
-
- /* 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;
- if (rtype & RC_CACHED)
- FlushClientCaches(this->id);
- (*DeleteFuncs[rtype & TypeMask])(this->value, this->id);
-#ifdef PANORAMIX
- if (!noPanoramiXExtension) {
- FoundID = 0;
- FreeID = this->id;
- PanoramiXType = this->type;
- PANORAMIX_MARKFREE(FreeID,PanoramiXType);
- }
-#endif
- xfree(this);
- }
- }
- xfree(clientTable[client->index].resources);
- clientTable[client->index].buckets = 0;
-}
-
-void
-FreeAllResources()
-{
- int i;
-
- for (i = currentMaxClients; --i >= 0; )
- {
- if (clientTable[i].buckets)
- FreeClientResources(clients[i]);
- }
-}
-
-Bool
-LegalNewID(id, client)
- 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.
- */
-
-pointer
-SecurityLookupIDByType(client, id, rtype, mode)
- ClientPtr client;
- XID id;
- RESTYPE rtype;
- Mask mode;
-{
- int cid;
- register ResourcePtr res;
- pointer 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;
-}
-
-
-pointer
-SecurityLookupIDByClass(client, id, classes, mode)
- ClientPtr client;
- XID id;
- RESTYPE classes;
- Mask mode;
-{
- int cid;
- register ResourcePtr res;
- pointer 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.
- */
-
-pointer
-LookupIDByType(id, rtype)
- XID id;
- RESTYPE rtype;
-{
- return SecurityLookupIDByType(NullClient, id, rtype,
- SecurityUnknownAccess);
-}
-
-pointer
-LookupIDByClass(id, classes)
- XID id;
- RESTYPE classes;
-{
- return SecurityLookupIDByClass(NullClient, id, classes,
- SecurityUnknownAccess);
-}
-
-#else /* not XCSECURITY */
-
-/*
- * LookupIDByType returns the object with the given id and type, else NULL.
- */
-pointer
-LookupIDByType(id, rtype)
- 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 (pointer)NULL;
-}
-
-/*
- * LookupIDByClass returns the object with the given id and any one of the
- * given classes, else NULL.
- */
-pointer
-LookupIDByClass(id, classes)
- 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 (pointer)NULL;
-}
-
-#endif /* XCSECURITY */
diff --git a/programs/Xserver/pandix/window.c b/programs/Xserver/pandix/window.c
deleted file mode 100644
index 8e93f7b9e..000000000
--- a/programs/Xserver/pandix/window.c
+++ /dev/null
@@ -1,3830 +0,0 @@
-
-/****************************************************************
-* *
-* Copyright (c) Digital Equipment Corporation, 1991, 1997 *
-* *
-* All Rights Reserved. Unpublished rights reserved under *
-* the copyright laws of the United States. *
-* *
-* The software contained on this media is proprietary to *
-* and embodies the confidential technology of Digital *
-* Equipment Corporation. Possession, use, duplication or *
-* dissemination of the software and media is authorized only *
-* pursuant to a valid written license from Digital Equipment *
-* Corporation. *
-* *
-* RESTRICTED RIGHTS LEGEND Use, duplication, or disclosure *
-* by the U.S. Government is subject to restrictions as set *
-* forth in Subparagraph (c)(1)(ii) of DFARS 252.227-7013, *
-* or in FAR 52.227-19, as applicable. *
-* *
-*****************************************************************/
-/* $TOG: window.c /main/1 1997/10/29 13:27:33 kaleb $ */
-/*
-
-Copyright (c) 1987 X Consortium
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE X CONSORTIUM 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 X Consortium 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 X Consortium.
-
-
-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.
-
-*/
-
-#include "misc.h"
-#include "scrnintstr.h"
-#include "os.h"
-#include "regionstr.h"
-#include "validate.h"
-#include "windowstr.h"
-#include "input.h"
-#include "resource.h"
-#include "colormapst.h"
-#include "cursorstr.h"
-#include "dixstruct.h"
-#include "gcstruct.h"
-#include "servermd.h"
-#ifdef PANORAMIX
-#include "panoramiX.h"
-#endif
-
-#ifdef PANORAMIX
-extern PanoramiXWindow *PanoramiXWinRoot;
-extern Bool noPanoramiXExtension;
-extern int PanoramiXNumScreens;
-extern PanoramiXData *panoramiXdataPtr;
-extern RegionRec PanoramiXScreenRegion[MAXSCREENS];
-#endif /* PANORAMIX */
-
-#ifdef XAPPGROUP
-#include "extensions/Xagsrv.h"
-#endif
-#ifdef XCSECURITY
-#define _SECURITY_SERVER
-#include "extensions/security.h"
-#endif
-
-extern Bool permitOldBugs;
-
-/******
- * Window stuff for server
- *
- * CreateRootWindow, CreateWindow, ChangeWindowAttributes,
- * GetWindowAttributes, DeleteWindow, DestroySubWindows,
- * HandleSaveSet, ReparentWindow, MapWindow, MapSubWindows,
- * UnmapWindow, UnmapSubWindows, ConfigureWindow, CirculateWindow,
- *
- ******/
-
-static unsigned char _back_lsb[4] = {0x88, 0x22, 0x44, 0x11};
-static unsigned char _back_msb[4] = {0x11, 0x44, 0x22, 0x88};
-
-int screenIsSaved = SCREEN_SAVER_OFF;
-
-ScreenSaverStuffRec savedScreenInfo[MAXSCREENS];
-
-extern WindowPtr *WindowTable;
-
-extern void DeleteWindowFromAnyEvents();
-extern Mask EventMaskForClient();
-extern void WindowHasNewCursor();
-extern void RecalculateDeliverableEvents();
-extern int rand();
-
-static Bool TileScreenSaver(
-#if NeedFunctionPrototypes
- int /*i*/,
- int /*kind*/
-#endif
-);
-
-
-#define INPUTONLY_LEGAL_MASK (CWWinGravity | CWEventMask | \
- CWDontPropagate | CWOverrideRedirect | CWCursor )
-
-#define BOXES_OVERLAP(b1, b2) \
- (!( ((b1)->x2 <= (b2)->x1) || \
- ( ((b1)->x1 >= (b2)->x2)) || \
- ( ((b1)->y2 <= (b2)->y1)) || \
- ( ((b1)->y1 >= (b2)->y2)) ) )
-
-#define RedirectSend(pWin) \
- ((pWin->eventMask|wOtherEventMasks(pWin)) & SubstructureRedirectMask)
-
-#define SubSend(pWin) \
- ((pWin->eventMask|wOtherEventMasks(pWin)) & SubstructureNotifyMask)
-
-#define StrSend(pWin) \
- ((pWin->eventMask|wOtherEventMasks(pWin)) & StructureNotifyMask)
-
-#define SubStrSend(pWin,pParent) (StrSend(pWin) || SubSend(pParent))
-
-
-int numSaveUndersViewable = 0;
-int deltaSaveUndersViewable = 0;
-
-#ifdef DEBUG
-/******
- * PrintWindowTree
- * For debugging only
- ******/
-
-int
-PrintChildren(p1, indent)
- WindowPtr p1;
- int indent;
-{
- WindowPtr p2;
- int i;
-
- while (p1)
- {
- p2 = p1->firstChild;
- for (i=0; i<indent; i++) ErrorF( " ");
- ErrorF( "%x\n", p1->drawable.id);
- miPrintRegion(&p1->clipList);
- PrintChildren(p2, indent+4);
- p1 = p1->nextSib;
- }
-}
-
-PrintWindowTree()
-{
- int i;
- WindowPtr pWin, p1;
-
- for (i=0; i<screenInfo.numScreens; i++)
- {
- ErrorF( "WINDOW %d\n", i);
- pWin = WindowTable[i];
- miPrintRegion(&pWin->clipList);
- p1 = pWin->firstChild;
- PrintChildren(p1, 4);
- }
-}
-#endif
-
-#ifdef PANORAMIX
-Bool
-PanoramiXWindowOffScreen(pWin,w, h)
- register WindowPtr pWin;
- unsigned short w, h;
-{
- register ScreenPtr pScreen = pWin->drawable.pScreen;
- int Scr;
-
- Scr = (pWin->drawable.pScreen)->myNum;
-
- if ((pWin->drawable.x < 0) &&
- ((pWin->drawable.x + w) < 0))
- return TRUE;
- if ((pWin->drawable.x > panoramiXdataPtr[Scr].width) &&
- ((pWin->drawable.x + w) > panoramiXdataPtr[Scr].width))
- return TRUE;
- if ((pWin->drawable.y < 0) &&
- ((pWin->drawable.y + h) < 0))
- return TRUE;
- if ((pWin->drawable.y > panoramiXdataPtr[Scr].height) &&
- ((pWin->drawable.y + h) > panoramiXdataPtr[Scr].height) )
- return TRUE;
-
- return FALSE;
-}
-#endif
-
-int
-TraverseTree(pWin, func, data)
- register WindowPtr pWin;
- VisitWindowProcPtr func;
- pointer data;
-{
- register int result;
- register WindowPtr pChild;
-
- if (!(pChild = pWin))
- return(WT_NOMATCH);
- while (1)
- {
- result = (* func)(pChild, data);
- if (result == WT_STOPWALKING)
- return(WT_STOPWALKING);
- if ((result == WT_WALKCHILDREN) && pChild->firstChild)
- {
- pChild = pChild->firstChild;
- continue;
- }
- while (!pChild->nextSib && (pChild != pWin))
- pChild = pChild->parent;
- if (pChild == pWin)
- break;
- pChild = pChild->nextSib;
- }
- return(WT_NOMATCH);
-}
-
-/*****
- * WalkTree
- * Walk the window tree, for SCREEN, preforming FUNC(pWin, data) on
- * each window. If FUNC returns WT_WALKCHILDREN, traverse the children,
- * if it returns WT_DONTWALKCHILDREN, dont. If it returns WT_STOPWALKING
- * exit WalkTree. Does depth-first traverse.
- *****/
-
-int
-WalkTree(pScreen, func, data)
- ScreenPtr pScreen;
- VisitWindowProcPtr func;
- pointer data;
-{
- return(TraverseTree(WindowTable[pScreen->myNum], func, data));
-}
-
-/* hack for forcing backing store on all windows */
-int defaultBackingStore = NotUseful;
-/* hack to force no backing store */
-Bool disableBackingStore = FALSE;
-/* hack to force no save unders */
-Bool disableSaveUnders = FALSE;
-
-static void
-SetWindowToDefaults(pWin)
- register WindowPtr pWin;
-{
- pWin->prevSib = NullWindow;
- pWin->firstChild = NullWindow;
- pWin->lastChild = NullWindow;
-
- pWin->valdata = (ValidatePtr)NULL;
- pWin->optional = (WindowOptPtr)NULL;
- pWin->cursorIsNone = TRUE;
-
- pWin->backingStore = NotUseful;
- pWin->DIXsaveUnder = FALSE;
- pWin->backStorage = (pointer) NULL;
-
- pWin->mapped = FALSE; /* off */
- pWin->realized = FALSE; /* off */
- pWin->viewable = FALSE;
- pWin->visibility = VisibilityNotViewable;
- pWin->overrideRedirect = FALSE;
- pWin->saveUnder = FALSE;
-
- pWin->bitGravity = ForgetGravity;
- pWin->winGravity = NorthWestGravity;
-
- pWin->eventMask = 0;
- pWin->deliverableEvents = 0;
- pWin->dontPropagate = 0;
- pWin->forcedBS = FALSE;
-#ifdef NEED_DBE_BUF_BITS
- pWin->srcBuffer = DBE_FRONT_BUFFER;
- pWin->dstBuffer = DBE_FRONT_BUFFER;
-#endif
-}
-
-static void
-MakeRootTile(pWin)
- WindowPtr pWin;
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- GCPtr pGC;
- unsigned char back[128];
- int len = BitmapBytePad(sizeof(long));
- register unsigned char *from, *to;
- register int i, j;
-
- pWin->background.pixmap = (*pScreen->CreatePixmap)(pScreen, len, 4,
- pScreen->rootDepth);
-
- pWin->backgroundState = BackgroundPixmap;
- pGC = GetScratchGC(pScreen->rootDepth, pScreen);
- if (!pWin->background.pixmap || !pGC)
- FatalError("cound not create root tile");
-
- {
- CARD32 attributes[2];
-
- attributes[0] = pScreen->whitePixel;
- attributes[1] = pScreen->blackPixel;
-
- (void)ChangeGC(pGC, GCForeground | GCBackground, attributes);
- }
-
- ValidateGC((DrawablePtr)pWin->background.pixmap, pGC);
-
- from = (screenInfo.bitmapBitOrder == LSBFirst) ? _back_lsb : _back_msb;
- to = back;
-
- for (i = 4; i > 0; i--, from++)
- for (j = len; j > 0; j--)
- *to++ = *from;
-
- (*pGC->ops->PutImage)((DrawablePtr)pWin->background.pixmap, pGC, 1,
- 0, 0, len, 4, 0, XYBitmap, (char *)back);
-
- FreeScratchGC(pGC);
-
-}
-
-WindowPtr
-AllocateWindow(pScreen)
- ScreenPtr pScreen;
-{
- WindowPtr pWin;
- register char *ptr;
- register DevUnion *ppriv;
- register unsigned *sizes;
- register unsigned size;
- register int i;
-
- pWin = (WindowPtr)xalloc(pScreen->totalWindowSize);
- if (pWin)
- {
- ppriv = (DevUnion *)(pWin + 1);
- pWin->devPrivates = ppriv;
- sizes = pScreen->WindowPrivateSizes;
- ptr = (char *)(ppriv + pScreen->WindowPrivateLen);
- for (i = pScreen->WindowPrivateLen; --i >= 0; ppriv++, sizes++)
- {
- if ( (size = *sizes) )
- {
- ppriv->ptr = (pointer)ptr;
- ptr += size;
- }
- else
- ppriv->ptr = (pointer)NULL;
- }
- }
- return pWin;
-}
-
-/*****
- * CreateRootWindow
- * Makes a window at initialization time for specified screen
- *****/
-
-Bool
-CreateRootWindow(pScreen)
- ScreenPtr pScreen;
-{
- WindowPtr pWin;
- BoxRec box;
- PixmapFormatRec *format;
-
- pWin = AllocateWindow(pScreen);
- if (!pWin)
- return FALSE;
-
- savedScreenInfo[pScreen->myNum].pWindow = NULL;
- savedScreenInfo[pScreen->myNum].wid = FakeClientID(0);
- savedScreenInfo[pScreen->myNum].ExternalScreenSaver = NULL;
- screenIsSaved = SCREEN_SAVER_OFF;
-
- WindowTable[pScreen->myNum] = pWin;
-
- pWin->drawable.pScreen = pScreen;
- pWin->drawable.type = DRAWABLE_WINDOW;
-
- pWin->drawable.depth = pScreen->rootDepth;
- for (format = screenInfo.formats;
- format->depth != pScreen->rootDepth;
- format++)
- ;
- pWin->drawable.bitsPerPixel = format->bitsPerPixel;
-
- pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER;
-
- pWin->parent = NullWindow;
- SetWindowToDefaults(pWin);
-
- pWin->optional = (WindowOptRec *) xalloc (sizeof (WindowOptRec));
-
- pWin->optional->dontPropagateMask = 0;
- pWin->optional->otherEventMasks = 0;
- pWin->optional->otherClients = NULL;
- pWin->optional->passiveGrabs = NULL;
- pWin->optional->userProps = NULL;
- pWin->optional->backingBitPlanes = ~0L;
- pWin->optional->backingPixel = 0;
-#ifdef SHAPE
- pWin->optional->boundingShape = NULL;
- pWin->optional->clipShape = NULL;
-#endif
-#ifdef XINPUT
- pWin->optional->inputMasks = NULL;
-#endif
- pWin->optional->colormap = pScreen->defColormap;
- pWin->optional->visual = pScreen->rootVisual;
-
- pWin->nextSib = NullWindow;
-
- pWin->drawable.id = FakeClientID(0);
-
- pWin->origin.x = pWin->origin.y = 0;
- pWin->drawable.height = pScreen->height;
- pWin->drawable.width = pScreen->width;
- pWin->drawable.x = pWin->drawable.y = 0;
-
- box.x1 = 0;
- box.y1 = 0;
- box.x2 = pScreen->width;
- box.y2 = pScreen->height;
- REGION_INIT(pScreen, &pWin->clipList, &box, 1);
- REGION_INIT(pScreen, &pWin->winSize, &box, 1);
- REGION_INIT(pScreen, &pWin->borderSize, &box, 1);
- REGION_INIT(pScreen, &pWin->borderClip, &box, 1);
-
- pWin->drawable.class = InputOutput;
- pWin->optional->visual = pScreen->rootVisual;
-
- pWin->backgroundState = BackgroundPixel;
- pWin->background.pixel = pScreen->whitePixel;
-
- pWin->borderIsPixel = TRUE;
- pWin->border.pixel = pScreen->blackPixel;
- pWin->borderWidth = 0;
-
- if (!AddResource(pWin->drawable.id, RT_WINDOW, (pointer)pWin))
- return FALSE;
-
- if (disableBackingStore)
- pScreen->backingStoreSupport = NotUseful;
-
-#ifdef DO_SAVE_UNDERS
- if ((pScreen->backingStoreSupport != NotUseful) &&
- (pScreen->saveUnderSupport == NotUseful))
- {
- /*
- * If the screen has backing-store but no save-unders, let the
- * clients know we can support save-unders using backing-store.
- */
- pScreen->saveUnderSupport = USE_DIX_SAVE_UNDERS;
- }
-#endif /* DO_SAVE_UNDERS */
-
- if (disableSaveUnders)
- pScreen->saveUnderSupport = NotUseful;
-
- return TRUE;
-}
-
-void
-InitRootWindow(pWin)
- WindowPtr pWin;
-{
- ScreenPtr pScreen;
-
- pScreen = pWin->drawable.pScreen;
- if (!(*pScreen->CreateWindow)(pWin))
- return; /* XXX */
- (*pScreen->PositionWindow)(pWin, 0, 0);
-
- pWin->cursorIsNone = FALSE;
- pWin->optional->cursor = rootCursor;
- rootCursor->refcnt++;
- MakeRootTile(pWin);
- pWin->backingStore = defaultBackingStore;
- pWin->forcedBS = (defaultBackingStore != NotUseful);
- /* We SHOULD check for an error value here XXX */
- (*pScreen->ChangeWindowAttributes)(pWin,
- CWBackPixmap|CWBorderPixel|CWCursor|CWBackingStore);
-
- MapWindow(pWin, serverClient);
-}
-
-/* Set the region to the intersection of the rectangle and the
- * window's winSize. The window is typically the parent of the
- * window from which the region came.
- */
-
-void
-ClippedRegionFromBox(pWin, Rgn, x, y, w, h)
- register WindowPtr pWin;
- RegionPtr Rgn;
- register int x, y;
- int w, h;
-{
- register ScreenPtr pScreen = pWin->drawable.pScreen;
- BoxRec box;
-
- box = *(REGION_EXTENTS(pScreen, &pWin->winSize));
- /* we do these calculations to avoid overflows */
- if (x > box.x1)
- box.x1 = x;
- if (y > box.y1)
- box.y1 = y;
- x += w;
- if (x < box.x2)
- box.x2 = x;
- y += h;
- if (y < box.y2)
- box.y2 = y;
- if (box.x1 > box.x2)
- box.x2 = box.x1;
- if (box.y1 > box.y2)
- box.y2 = box.y1;
- REGION_RESET(pScreen, Rgn, &box);
- REGION_INTERSECT(pScreen, Rgn, Rgn, &pWin->winSize);
-}
-
-/* Set the region to the intersection of the rectangle and the
- * PanoramiX window size. The window is typically the parent of the
- * window from which the region came.
- */
-
-#ifdef PANORAMIX
-void
-PanoramiXClippedRegion(pWin, Rgn, x, y, w, h)
- register WindowPtr pWin;
- RegionPtr Rgn;
- register int x, y;
- int w, h;
-{
- register ScreenPtr pScreen = pWin->drawable.pScreen;
- BoxRec box;
-
- box = *(REGION_EXTENTS(pScreen, &PanoramiXScreenRegion[pScreen->myNum]));
-
- /* we do these calculations to avoid overflows */
- if (x > box.x1)
- box.x1 = x;
- if (y > box.y1)
- box.y1 = y;
- x += w;
- if (x < box.x2)
- box.x2 = x;
- y += h;
- if (y < box.y2)
- box.y2 = y;
- if (box.x1 > box.x2)
- box.x2 = box.x1;
- if (box.y1 > box.y2)
- box.y2 = box.y1;
- REGION_RESET(pScreen, Rgn, &box);
- REGION_INTERSECT(pScreen, Rgn, Rgn, &PanoramiXScreenRegion[pScreen->myNum]);
-}
-#endif
-
-WindowPtr
-RealChildHead(pWin)
- register WindowPtr pWin;
-{
- if (!pWin->parent &&
- (screenIsSaved == SCREEN_SAVER_ON) &&
- (HasSaverWindow (pWin->drawable.pScreen->myNum)))
- return (pWin->firstChild);
- else
- return (NullWindow);
-}
-
-/*****
- * CreateWindow
- * Makes a window in response to client request
- *****/
-
-WindowPtr
-CreateWindow(wid, pParent, x, y, w, h, bw, class, vmask, vlist,
- depth, client, visual, error)
- Window wid;
- register WindowPtr pParent;
- int x,y;
- unsigned int w, h, bw;
- unsigned int class;
- register Mask vmask;
- XID *vlist;
- int depth;
- ClientPtr client;
- VisualID visual;
- int *error;
-{
- register WindowPtr pWin;
- WindowPtr pHead;
- register ScreenPtr pScreen;
- xEvent event;
- int idepth, ivisual;
- Bool fOK;
- DepthPtr pDepth;
- PixmapFormatRec *format;
- register WindowOptPtr ancwopt;
-#ifdef PANORAMIX
- PanoramiXWindow *pPanoramiXWin = PanoramiXWinRoot;
- Window parID;
- register ScreenPtr PXpScreen;
- register WindowPtr PXpParent;
- register WindowOptPtr PXancwopt;
- VisualPtr pVisual;
- short VisualClass;
- Bool ClassKnown;
- int i, j, thisVisual, thisDepth;
-#endif
- if (class == CopyFromParent)
- class = pParent->drawable.class;
-
- if ((class != InputOutput) && (class != InputOnly))
- {
- *error = BadValue;
- client->errorValue = class;
- return NullWindow;
- }
-
- if ((class != InputOnly) && (pParent->drawable.class == InputOnly))
- {
- *error = BadMatch;
- return NullWindow;
- }
-
- if ((class == InputOnly) && ((bw != 0) || (depth != 0)))
- {
- *error = BadMatch;
- return NullWindow;
- }
-
- pScreen = pParent->drawable.pScreen;
-#ifdef PANORAMIX
- if (!noPanoramiXExtension) {
- if (depth > pParent->drawable.depth)
- depth = pParent->drawable.depth;
- }
-#endif
- if ((class == InputOutput) && (depth == 0))
- depth = pParent->drawable.depth;
- ancwopt = pParent->optional;
- if (!ancwopt)
- ancwopt = FindWindowWithOptional(pParent)->optional;
- if (visual == CopyFromParent) {
-#ifdef XAPPGROUP
- VisualID ag_visual;
-
- if (client->appgroup && !pParent->parent &&
- (ag_visual = XagRootVisual (client)))
- visual = ag_visual;
- else
-#endif
- visual = ancwopt->visual;
- }
-
- /* Find out if the depth and visual are acceptable for this Screen */
- if ((visual != ancwopt->visual) || (depth != pParent->drawable.depth))
- {
- fOK = FALSE;
- for(idepth = 0; idepth < pScreen->numDepths; idepth++)
- {
- pDepth = (DepthPtr) &pScreen->allowedDepths[idepth];
- if ((depth == pDepth->depth) || (depth == 0))
- {
- for (ivisual = 0; ivisual < pDepth->numVids; ivisual++)
- {
- if (visual == pDepth->vids[ivisual])
- {
- fOK = TRUE;
- break;
- }
- }
- }
- }
- if (fOK == FALSE)
- {
- *error = BadMatch;
- return NullWindow;
- }
- }
-
- if (((vmask & (CWBorderPixmap | CWBorderPixel)) == 0) &&
- (class != InputOnly) &&
- (depth != pParent->drawable.depth))
- {
- *error = BadMatch;
- return NullWindow;
- }
-
- if (((vmask & CWColormap) == 0) &&
- (class != InputOnly) &&
- ((visual != ancwopt->visual) || (ancwopt->colormap == None)))
- {
- *error = BadMatch;
- return NullWindow;
- }
-
- pWin = AllocateWindow(pScreen);
- if (!pWin)
- {
- *error = BadAlloc;
- return NullWindow;
- }
- pWin->drawable = pParent->drawable;
- pWin->drawable.depth = depth;
- if (depth == pParent->drawable.depth)
- pWin->drawable.bitsPerPixel = pParent->drawable.bitsPerPixel;
- else
- {
- for (format = screenInfo.formats; format->depth != depth; format++)
- ;
- pWin->drawable.bitsPerPixel = format->bitsPerPixel;
- }
- if (class == InputOnly)
- pWin->drawable.type = (short) UNDRAWABLE_WINDOW;
- pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER;
-
- pWin->drawable.id = wid;
- pWin->drawable.class = class;
-
- pWin->parent = pParent;
- SetWindowToDefaults(pWin);
-
- if (visual != ancwopt->visual)
- {
- if (!MakeWindowOptional (pWin))
- {
- xfree (pWin);
- *error = BadAlloc;
- return NullWindow;
- }
- pWin->optional->visual = visual;
- pWin->optional->colormap = None;
- }
-
- pWin->borderWidth = bw;
-#ifdef XCSECURITY
- /* can't let untrusted clients have background None windows;
- * they make it too easy to steal window contents
- */
- if (client->trustLevel != XSecurityClientTrusted)
- {
- pWin->backgroundState = BackgroundPixel;
- pWin->background.pixel = 0;
- }
- else
-#endif
- pWin->backgroundState = None;
-
- pWin->borderIsPixel = pParent->borderIsPixel;
- pWin->border = pParent->border;
- if (pWin->borderIsPixel == FALSE)
- pWin->border.pixmap->refcnt++;
-
- pWin->origin.x = x + (int)bw;
- pWin->origin.y = y + (int)bw;
- pWin->drawable.width = w;
- pWin->drawable.height = h;
- pWin->drawable.x = pParent->drawable.x + x + (int)bw;
- pWin->drawable.y = pParent->drawable.y + y + (int)bw;
-
- /* set up clip list correctly for unobscured WindowPtr */
- REGION_INIT(pScreen, &pWin->clipList, NullBox, 1);
- REGION_INIT(pScreen, &pWin->borderClip, NullBox, 1);
- REGION_INIT(pScreen, &pWin->winSize, NullBox, 1);
- REGION_INIT(pScreen, &pWin->borderSize, NullBox, 1);
-
- pHead = RealChildHead(pParent);
- if (pHead)
- {
- pWin->nextSib = pHead->nextSib;
- if (pHead->nextSib)
- pHead->nextSib->prevSib = pWin;
- else
- pParent->lastChild = pWin;
- pHead->nextSib = pWin;
- pWin->prevSib = pHead;
- }
- else
- {
- pWin->nextSib = pParent->firstChild;
- if (pParent->firstChild)
- pParent->firstChild->prevSib = pWin;
- else
- pParent->lastChild = pWin;
- pParent->firstChild = pWin;
- }
-
- SetWinSize (pWin);
- SetBorderSize (pWin);
-
- /* We SHOULD check for an error value here XXX */
- if (!(*pScreen->CreateWindow)(pWin))
- {
- *error = BadAlloc;
- DeleteWindow(pWin, None);
- return NullWindow;
- }
- /* We SHOULD check for an error value here XXX */
- (*pScreen->PositionWindow)(pWin, pWin->drawable.x, pWin->drawable.y);
-
- if (!(vmask & CWEventMask))
- RecalculateDeliverableEvents(pWin);
-
- if (vmask)
- *error = ChangeWindowAttributes(pWin, vmask, vlist, wClient (pWin));
- else
- *error = Success;
-
- if (*error != Success)
- {
- DeleteWindow(pWin, None);
- return NullWindow;
- }
- if (!(vmask & CWBackingStore) && (defaultBackingStore != NotUseful))
- {
- XID value = defaultBackingStore;
- (void)ChangeWindowAttributes(pWin, CWBackingStore, &value, wClient (pWin));
- pWin->forcedBS = TRUE;
- }
-
- if (SubSend(pParent))
- {
- event.u.u.type = CreateNotify;
- event.u.createNotify.window = wid;
- event.u.createNotify.parent = pParent->drawable.id;
- event.u.createNotify.x = x;
- event.u.createNotify.y = y;
- event.u.createNotify.width = w;
- event.u.createNotify.height = h;
- event.u.createNotify.borderWidth = bw;
- event.u.createNotify.override = pWin->overrideRedirect;
- DeliverEvents(pParent, &event, 1, NullWindow);
- }
-
- return pWin;
-}
-
-static void
-FreeWindowResources(pWin)
- register WindowPtr pWin;
-{
- register ScreenPtr pScreen;
-
- pScreen = pWin->drawable.pScreen;
-
- DeleteWindowFromAnySaveSet(pWin);
- DeleteWindowFromAnySelections(pWin);
- DeleteWindowFromAnyEvents(pWin, TRUE);
- REGION_UNINIT(pScreen, &pWin->clipList);
- REGION_UNINIT(pScreen, &pWin->winSize);
- REGION_UNINIT(pScreen, &pWin->borderClip);
- REGION_UNINIT(pScreen, &pWin->borderSize);
-#ifdef SHAPE
- if (wBoundingShape (pWin))
- REGION_DESTROY(pScreen, wBoundingShape (pWin));
- if (wClipShape (pWin))
- REGION_DESTROY(pScreen, wClipShape (pWin));
-#endif
- if (pWin->borderIsPixel == FALSE)
- (*pScreen->DestroyPixmap)(pWin->border.pixmap);
- if (pWin->backgroundState == BackgroundPixmap)
- (*pScreen->DestroyPixmap)(pWin->background.pixmap);
-
- DeleteAllWindowProperties(pWin);
- /* We SHOULD check for an error value here XXX */
- (*pScreen->DestroyWindow)(pWin);
- DisposeWindowOptional (pWin);
-}
-
-static void
-CrushTree(pWin)
- WindowPtr pWin;
-{
- register WindowPtr pChild, pSib, pParent;
- Bool (* UnrealizeWindow)();
- xEvent event;
-
- if (!(pChild = pWin->firstChild))
- return;
- UnrealizeWindow = pWin->drawable.pScreen->UnrealizeWindow;
- while (1)
- {
- if (pChild->firstChild)
- {
- pChild = pChild->firstChild;
- continue;
- }
- while (1)
- {
- pParent = pChild->parent;
- if (SubStrSend(pChild, pParent))
- {
- event.u.u.type = DestroyNotify;
- event.u.destroyNotify.window = pChild->drawable.id;
- DeliverEvents(pChild, &event, 1, NullWindow);
- }
- FreeResource(pChild->drawable.id, RT_WINDOW);
- pSib = pChild->nextSib;
-#ifdef DO_SAVE_UNDERS
- if (pChild->saveUnder && pChild->viewable)
- deltaSaveUndersViewable--;
-#endif
- pChild->viewable = FALSE;
- if (pChild->realized)
- {
- pChild->realized = FALSE;
- (*UnrealizeWindow)(pChild);
- }
- FreeWindowResources(pChild);
- xfree(pChild);
- if ( (pChild = pSib) )
- break;
- pChild = pParent;
- pChild->firstChild = NullWindow;
- pChild->lastChild = NullWindow;
- if (pChild == pWin)
- return;
- }
- }
-}
-
-/*****
- * DeleteWindow
- * Deletes child of window then window itself
- * If wid is None, don't send any events
- *****/
-
-/*ARGSUSED*/
-int
-DeleteWindow(value, wid)
- pointer value;
- XID wid;
- {
- register WindowPtr pParent;
- register WindowPtr pWin = (WindowPtr)value;
- xEvent event;
-
- UnmapWindow(pWin, FALSE);
-
- CrushTree(pWin);
-
- pParent = pWin->parent;
- if (wid && pParent && SubStrSend(pWin, pParent))
- {
- event.u.u.type = DestroyNotify;
- event.u.destroyNotify.window = pWin->drawable.id;
- DeliverEvents(pWin, &event, 1, NullWindow);
- }
-
- FreeWindowResources(pWin);
- if (pParent)
- {
- if (pParent->firstChild == pWin)
- pParent->firstChild = pWin->nextSib;
- if (pParent->lastChild == pWin)
- pParent->lastChild = pWin->prevSib;
- if (pWin->nextSib)
- pWin->nextSib->prevSib = pWin->prevSib;
- if (pWin->prevSib)
- pWin->prevSib->nextSib = pWin->nextSib;
- }
- xfree(pWin);
- return Success;
-}
-
-/*ARGSUSED*/
-void
-DestroySubwindows(pWin, client)
- register WindowPtr pWin;
- ClientPtr client;
-{
- /* XXX
- * The protocol is quite clear that each window should be
- * destroyed in turn, however, unmapping all of the first
- * eliminates most of the calls to ValidateTree. So,
- * this implementation is incorrect in that all of the
- * UnmapNotifies occur before all of the DestroyNotifies.
- * If you care, simply delete the call to UnmapSubwindows.
- */
- UnmapSubwindows(pWin);
- while (pWin->lastChild)
- FreeResource(pWin->lastChild->drawable.id, RT_NONE);
-}
-
-#define DeviceEventMasks (KeyPressMask | KeyReleaseMask | ButtonPressMask | \
- ButtonReleaseMask | PointerMotionMask)
-
-/*****
- * ChangeWindowAttributes
- *
- * The value-mask specifies which attributes are to be changed; the
- * value-list contains one value for each one bit in the mask, from least
- * to most significant bit in the mask.
- *****/
-
-int
-ChangeWindowAttributes(pWin, vmask, vlist, client)
- register WindowPtr pWin;
- Mask vmask;
- XID *vlist;
- ClientPtr client;
-{
- register Mask index;
- register XID *pVlist;
- PixmapPtr pPixmap;
- Pixmap pixID;
- CursorPtr pCursor, pOldCursor;
- Cursor cursorID;
- WindowPtr pChild;
- Colormap cmap;
- ColormapPtr pCmap;
- xEvent xE;
- int result;
- register ScreenPtr pScreen;
- Mask vmaskCopy = 0;
- register Mask tmask;
- unsigned int val;
- int error;
- Bool checkOptional = FALSE;
- Bool borderRelative = FALSE;
- WindowPtr pLayerWin;
-
- if ((pWin->drawable.class == InputOnly) && (vmask & (~INPUTONLY_LEGAL_MASK)))
- return BadMatch;
-
- error = Success;
- pScreen = pWin->drawable.pScreen;
- pVlist = vlist;
- tmask = vmask;
- while (tmask)
- {
- index = (Mask) lowbit (tmask);
- tmask &= ~index;
- switch (index)
- {
- case CWBackPixmap:
- pixID = (Pixmap )*pVlist;
- pVlist++;
- if (pWin->backgroundState == ParentRelative)
- borderRelative = TRUE;
- if (pixID == None)
- {
-#ifdef XCSECURITY
- /* can't let untrusted clients have background None windows */
- if (client->trustLevel == XSecurityClientTrusted)
- {
-#endif
- if (pWin->backgroundState == BackgroundPixmap)
- (*pScreen->DestroyPixmap)(pWin->background.pixmap);
- if (!pWin->parent)
- MakeRootTile(pWin);
- else
- pWin->backgroundState = None;
-#ifdef XCSECURITY
- }
- else
- { /* didn't change the background to None, so don't tell ddx */
- index = 0;
- }
-#endif
- }
- else if (pixID == ParentRelative)
- {
- if (pWin->parent &&
- pWin->drawable.depth != pWin->parent->drawable.depth)
- {
- error = BadMatch;
- goto PatchUp;
- }
- if (pWin->backgroundState == BackgroundPixmap)
- (*pScreen->DestroyPixmap)(pWin->background.pixmap);
- if (!pWin->parent)
- MakeRootTile(pWin);
- else
- pWin->backgroundState = ParentRelative;
- borderRelative = TRUE;
- /* Note that the parent's backgroundTile's refcnt is NOT
- * incremented. */
- }
- else
- {
- pPixmap = (PixmapPtr)SecurityLookupIDByType(client, pixID,
- RT_PIXMAP, SecurityReadAccess);
- if (pPixmap != (PixmapPtr) NULL)
- {
- if ((pPixmap->drawable.depth != pWin->drawable.depth) ||
- (pPixmap->drawable.pScreen != pScreen))
- {
- error = BadMatch;
- goto PatchUp;
- }
- if (pWin->backgroundState == BackgroundPixmap)
- (*pScreen->DestroyPixmap)(pWin->background.pixmap);
- pWin->backgroundState = BackgroundPixmap;
- pWin->background.pixmap = pPixmap;
- pPixmap->refcnt++;
- }
- else
- {
- error = BadPixmap;
- client->errorValue = pixID;
- goto PatchUp;
- }
- }
- break;
- case CWBackPixel:
- if (pWin->backgroundState == ParentRelative)
- borderRelative = TRUE;
- if (pWin->backgroundState == BackgroundPixmap)
- (*pScreen->DestroyPixmap)(pWin->background.pixmap);
- pWin->backgroundState = BackgroundPixel;
- pWin->background.pixel = (CARD32 ) *pVlist;
- /* background pixel overrides background pixmap,
- so don't let the ddx layer see both bits */
- vmaskCopy &= ~CWBackPixmap;
- pVlist++;
- break;
- case CWBorderPixmap:
- pixID = (Pixmap ) *pVlist;
- pVlist++;
- if (pixID == CopyFromParent)
- {
- if (!pWin->parent ||
- (pWin->drawable.depth != pWin->parent->drawable.depth))
- {
- error = BadMatch;
- goto PatchUp;
- }
- if (pWin->borderIsPixel == FALSE)
- (*pScreen->DestroyPixmap)(pWin->border.pixmap);
- pWin->border = pWin->parent->border;
- if ((pWin->borderIsPixel = pWin->parent->borderIsPixel) == TRUE)
- {
- index = CWBorderPixel;
- }
- else
- {
- pWin->parent->border.pixmap->refcnt++;
- }
- }
- else
- {
- pPixmap = (PixmapPtr)SecurityLookupIDByType(client, pixID,
- RT_PIXMAP, SecurityReadAccess);
- if (pPixmap)
- {
- if ((pPixmap->drawable.depth != pWin->drawable.depth) ||
- (pPixmap->drawable.pScreen != pScreen))
- {
- error = BadMatch;
- goto PatchUp;
- }
- if (pWin->borderIsPixel == FALSE)
- (*pScreen->DestroyPixmap)(pWin->border.pixmap);
- pWin->borderIsPixel = FALSE;
- pWin->border.pixmap = pPixmap;
- pPixmap->refcnt++;
- }
- else
- {
- error = BadPixmap;
- client->errorValue = pixID;
- goto PatchUp;
- }
- }
- break;
- case CWBorderPixel:
- if (pWin->borderIsPixel == FALSE)
- (*pScreen->DestroyPixmap)(pWin->border.pixmap);
- pWin->borderIsPixel = TRUE;
- pWin->border.pixel = (CARD32) *pVlist;
- /* border pixel overrides border pixmap,
- so don't let the ddx layer see both bits */
- vmaskCopy &= ~CWBorderPixmap;
- pVlist++;
- break;
- case CWBitGravity:
- val = (CARD8 )*pVlist;
- pVlist++;
- if (val > StaticGravity)
- {
- error = BadValue;
- client->errorValue = val;
- goto PatchUp;
- }
- pWin->bitGravity = val;
- break;
- case CWWinGravity:
- val = (CARD8 )*pVlist;
- pVlist++;
- if (val > StaticGravity)
- {
- error = BadValue;
- client->errorValue = val;
- goto PatchUp;
- }
- pWin->winGravity = val;
- break;
- case CWBackingStore:
- val = (CARD8 )*pVlist;
- pVlist++;
- if ((val != NotUseful) && (val != WhenMapped) && (val != Always))
- {
- error = BadValue;
- client->errorValue = val;
- goto PatchUp;
- }
- pWin->backingStore = val;
- pWin->forcedBS = FALSE;
- break;
- case CWBackingPlanes:
- if (pWin->optional || ((CARD32)*pVlist != ~0L)) {
- if (!pWin->optional && !MakeWindowOptional (pWin))
- {
- error = BadAlloc;
- goto PatchUp;
- }
- pWin->optional->backingBitPlanes = (CARD32) *pVlist;
- if ((CARD32)*pVlist == ~0L)
- checkOptional = TRUE;
- }
- pVlist++;
- break;
- case CWBackingPixel:
- if (pWin->optional || (CARD32) *pVlist) {
- if (!pWin->optional && !MakeWindowOptional (pWin))
- {
- error = BadAlloc;
- goto PatchUp;
- }
- pWin->optional->backingPixel = (CARD32) *pVlist;
- if (!*pVlist)
- checkOptional = TRUE;
- }
- pVlist++;
- break;
- case CWSaveUnder:
- val = (BOOL) *pVlist;
- pVlist++;
- if ((val != xTrue) && (val != xFalse))
- {
- error = BadValue;
- client->errorValue = val;
- goto PatchUp;
- }
-#ifdef DO_SAVE_UNDERS
- if (pWin->parent && (pWin->saveUnder != val) && (pWin->viewable) &&
- DO_SAVE_UNDERS(pWin))
- {
- /*
- * Re-check all siblings and inferiors for obscurity or
- * exposition (hee hee).
- */
- if (pWin->saveUnder)
- deltaSaveUndersViewable--;
- else
- deltaSaveUndersViewable++;
- pWin->saveUnder = val;
-
- if (pWin->firstChild)
- {
- pLayerWin = (*pScreen->GetLayerWindow)(pWin);
- if ((*pScreen->ChangeSaveUnder)(pLayerWin->parent, pWin->nextSib))
- (*pScreen->PostChangeSaveUnder)(pLayerWin->parent,
- pWin->nextSib);
- }
- else
- {
- if ((*pScreen->ChangeSaveUnder)(pWin, pWin->nextSib))
- (*pScreen->PostChangeSaveUnder)(pWin,
- pWin->nextSib);
- }
- }
- else
- {
- /* If we're changing the saveUnder attribute of the root
- * window, all we do is set pWin->saveUnder so that
- * GetWindowAttributes returns the right value. We don't
- * do the "normal" save-under processing (as above).
- * Hope that doesn't cause any problems.
- */
- pWin->saveUnder = val;
- }
-#else
- pWin->saveUnder = val;
-#endif /* DO_SAVE_UNDERS */
- break;
- case CWEventMask:
- result = EventSelectForWindow(pWin, client, (Mask )*pVlist);
- if (result)
- {
- error = result;
- goto PatchUp;
- }
- pVlist++;
- break;
- case CWDontPropagate:
- result = EventSuppressForWindow(pWin, client, (Mask )*pVlist,
- &checkOptional);
- if (result)
- {
- error = result;
- goto PatchUp;
- }
- pVlist++;
- break;
- case CWOverrideRedirect:
- val = (BOOL ) *pVlist;
- pVlist++;
- if ((val != xTrue) && (val != xFalse))
- {
- error = BadValue;
- client->errorValue = val;
- goto PatchUp;
- }
- pWin->overrideRedirect = val;
- break;
- case CWColormap:
- cmap = (Colormap) *pVlist;
- pVlist++;
- if (cmap == CopyFromParent)
- {
-#ifdef XAPPGROUP
- Colormap ag_colormap;
- ClientPtr win_owner;
-
- /*
- * win_owner == client for CreateWindow, other clients
- * can ChangeWindowAttributes
- */
- win_owner = clients[CLIENT_ID(pWin->drawable.id)];
-
- if (win_owner->appgroup && !pWin->parent->parent &&
- (ag_colormap = XagDefaultColormap (win_owner)))
- cmap = ag_colormap;
- else
-#endif
- if (pWin->parent &&
- (!pWin->optional ||
- pWin->optional->visual == wVisual (pWin->parent)))
- {
- cmap = wColormap (pWin->parent);
- }
- else
- cmap = None;
- }
- if (cmap == None)
- {
- error = BadMatch;
- goto PatchUp;
- }
- pCmap = (ColormapPtr)SecurityLookupIDByType(client, cmap,
- RT_COLORMAP, SecurityReadAccess);
- if (!pCmap)
- {
- error = BadColor;
- client->errorValue = cmap;
- goto PatchUp;
- }
- if (pCmap->pVisual->vid != wVisual (pWin) ||
- pCmap->pScreen != pScreen)
- {
- error = BadMatch;
- goto PatchUp;
- }
- if (cmap != wColormap (pWin))
- {
- if (!pWin->optional)
- {
- if (!MakeWindowOptional (pWin))
- {
- error = BadAlloc;
- goto PatchUp;
- }
- }
- else if (pWin->parent && cmap == wColormap (pWin->parent))
- checkOptional = TRUE;
-
- /*
- * propagate the original colormap to any children
- * inheriting it
- */
-
- for (pChild = pWin->firstChild; pChild; pChild=pChild->nextSib)
- {
- if (!pChild->optional && !MakeWindowOptional (pChild))
- {
- error = BadAlloc;
- goto PatchUp;
- }
- }
-
- pWin->optional->colormap = cmap;
-
- /*
- * check on any children now matching the new colormap
- */
-
- for (pChild = pWin->firstChild; pChild; pChild=pChild->nextSib)
- {
- if (pChild->optional->colormap == cmap)
- CheckWindowOptionalNeed (pChild);
- }
-
- xE.u.u.type = ColormapNotify;
- xE.u.colormap.window = pWin->drawable.id;
- xE.u.colormap.colormap = cmap;
- xE.u.colormap.new = xTrue;
- xE.u.colormap.state = IsMapInstalled(cmap, pWin);
- DeliverEvents(pWin, &xE, 1, NullWindow);
- }
- break;
- case CWCursor:
- cursorID = (Cursor ) *pVlist;
- pVlist++;
- /*
- * install the new
- */
- if ( cursorID == None)
- {
- if (pWin == WindowTable[pWin->drawable.pScreen->myNum])
- pCursor = rootCursor;
- else
- pCursor = (CursorPtr) None;
- }
- else
- {
- pCursor = (CursorPtr)SecurityLookupIDByType(client, cursorID,
- RT_CURSOR, SecurityReadAccess);
- if (!pCursor)
- {
- error = BadCursor;
- client->errorValue = cursorID;
- goto PatchUp;
- }
- }
-
- if (pCursor != wCursor (pWin))
- {
- /*
- * patch up child windows so they don't lose cursors.
- */
-
- for (pChild = pWin->firstChild; pChild; pChild=pChild->nextSib)
- {
- if (!pChild->optional && !pChild->cursorIsNone &&
- !MakeWindowOptional (pChild))
- {
- error = BadAlloc;
- goto PatchUp;
- }
- }
-
- pOldCursor = 0;
- if (pCursor == (CursorPtr) None)
- {
- pWin->cursorIsNone = TRUE;
- if (pWin->optional)
- {
- pOldCursor = pWin->optional->cursor;
- pWin->optional->cursor = (CursorPtr) None;
- checkOptional = TRUE;
- }
- } else {
- if (!pWin->optional)
- {
- if (!MakeWindowOptional (pWin))
- {
- error = BadAlloc;
- goto PatchUp;
- }
- }
- else if (pWin->parent && pCursor == wCursor (pWin->parent))
- checkOptional = TRUE;
- pOldCursor = pWin->optional->cursor;
- pWin->optional->cursor = pCursor;
- pCursor->refcnt++;
- pWin->cursorIsNone = FALSE;
- /*
- * check on any children now matching the new cursor
- */
-
- for (pChild=pWin->firstChild; pChild; pChild=pChild->nextSib)
- {
- if (pChild->optional &&
- (pChild->optional->cursor == pCursor))
- CheckWindowOptionalNeed (pChild);
- }
- }
-
- if (pWin->realized)
- WindowHasNewCursor( pWin);
-
- /* Can't free cursor until here - old cursor
- * is needed in WindowHasNewCursor
- */
- if (pOldCursor)
- FreeCursor (pOldCursor, (Cursor)0);
- }
- break;
- default:
- error = BadValue;
- client->errorValue = vmask;
- goto PatchUp;
- }
- vmaskCopy |= index;
- }
-PatchUp:
- if (checkOptional)
- CheckWindowOptionalNeed (pWin);
-
- /* We SHOULD check for an error value here XXX */
- (*pScreen->ChangeWindowAttributes)(pWin, vmaskCopy);
-
- /*
- If the border contents have changed, redraw the border.
- Note that this has to be done AFTER pScreen->ChangeWindowAttributes
- for the tile to be rotated, and the correct function selected.
- */
- if (((vmaskCopy & (CWBorderPixel | CWBorderPixmap)) || borderRelative)
- && pWin->viewable && HasBorder (pWin))
- {
- RegionRec exposed;
-
- REGION_INIT(pScreen, &exposed, NullBox, 0);
- REGION_SUBTRACT(pScreen, &exposed, &pWin->borderClip, &pWin->winSize);
- (*pWin->drawable.pScreen->PaintWindowBorder)(pWin, &exposed, PW_BORDER);
- REGION_UNINIT(pScreen, &exposed);
- }
- return error;
-}
-
-
-/*****
- * GetWindowAttributes
- * Notice that this is different than ChangeWindowAttributes
- *****/
-
-void
-GetWindowAttributes(pWin, client, wa)
- register WindowPtr pWin;
- ClientPtr client;
- xGetWindowAttributesReply *wa;
-{
- wa->type = X_Reply;
- wa->bitGravity = pWin->bitGravity;
- wa->winGravity = pWin->winGravity;
- if (pWin->forcedBS && pWin->backingStore != Always)
- wa->backingStore = NotUseful;
- else
- wa->backingStore = pWin->backingStore;
- wa->length = (sizeof(xGetWindowAttributesReply) -
- sizeof(xGenericReply)) >> 2;
- wa->sequenceNumber = client->sequence;
- wa->backingBitPlanes = wBackingBitPlanes (pWin);
- wa->backingPixel = wBackingPixel (pWin);
- wa->saveUnder = (BOOL)pWin->saveUnder;
- wa->override = pWin->overrideRedirect;
- if (!pWin->mapped)
- wa->mapState = IsUnmapped;
- else if (pWin->realized)
- wa->mapState = IsViewable;
- else
- wa->mapState = IsUnviewable;
-
- wa->colormap = wColormap (pWin);
- wa->mapInstalled = (wa->colormap == None) ? xFalse
- : IsMapInstalled(wa->colormap, pWin);
-
- wa->yourEventMask = EventMaskForClient(pWin, client);
- wa->allEventMasks = pWin->eventMask | wOtherEventMasks (pWin);
- wa->doNotPropagateMask = wDontPropagateMask (pWin);
- wa->class = pWin->drawable.class;
- wa->visualID = wVisual (pWin);
-}
-
-
-WindowPtr
-MoveWindowInStack(pWin, pNextSib)
- register WindowPtr pWin, pNextSib;
-{
- register WindowPtr pParent = pWin->parent;
- WindowPtr pFirstChange = pWin; /* highest window where list changes */
-
- if (pWin->nextSib != pNextSib)
- {
- if (!pNextSib) /* move to bottom */
- {
- if (pParent->firstChild == pWin)
- pParent->firstChild = pWin->nextSib;
- /* if (pWin->nextSib) */ /* is always True: pNextSib == NULL
- * and pWin->nextSib != pNextSib
- * therefore pWin->nextSib != NULL */
- pFirstChange = pWin->nextSib;
- pWin->nextSib->prevSib = pWin->prevSib;
- if (pWin->prevSib)
- pWin->prevSib->nextSib = pWin->nextSib;
- pParent->lastChild->nextSib = pWin;
- pWin->prevSib = pParent->lastChild;
- pWin->nextSib = NullWindow;
- pParent->lastChild = pWin;
- }
- else if (pParent->firstChild == pNextSib) /* move to top */
- {
- pFirstChange = pWin;
- if (pParent->lastChild == pWin)
- pParent->lastChild = pWin->prevSib;
- if (pWin->nextSib)
- pWin->nextSib->prevSib = pWin->prevSib;
- if (pWin->prevSib)
- pWin->prevSib->nextSib = pWin->nextSib;
- pWin->nextSib = pParent->firstChild;
- pWin->prevSib = (WindowPtr ) NULL;
- pNextSib->prevSib = pWin;
- pParent->firstChild = pWin;
- }
- else /* move in middle of list */
- {
- WindowPtr pOldNext = pWin->nextSib;
-
- pFirstChange = NullWindow;
- if (pParent->firstChild == pWin)
- pFirstChange = pParent->firstChild = pWin->nextSib;
- if (pParent->lastChild == pWin) {
- pFirstChange = pWin;
- pParent->lastChild = pWin->prevSib;
- }
- if (pWin->nextSib)
- pWin->nextSib->prevSib = pWin->prevSib;
- if (pWin->prevSib)
- pWin->prevSib->nextSib = pWin->nextSib;
- pWin->nextSib = pNextSib;
- pWin->prevSib = pNextSib->prevSib;
- if (pNextSib->prevSib)
- pNextSib->prevSib->nextSib = pWin;
- pNextSib->prevSib = pWin;
- if (!pFirstChange) { /* do we know it yet? */
- pFirstChange = pParent->firstChild; /* no, search from top */
- while ((pFirstChange != pWin) && (pFirstChange != pOldNext))
- pFirstChange = pFirstChange->nextSib;
- }
- }
- }
-
- return( pFirstChange );
-}
-
-RegionPtr
-CreateUnclippedWinSize (pWin)
- register WindowPtr pWin;
-{
- RegionPtr pRgn;
- BoxRec box;
-
- box.x1 = pWin->drawable.x;
- box.y1 = pWin->drawable.y;
- box.x2 = pWin->drawable.x + (int) pWin->drawable.width;
- box.y2 = pWin->drawable.y + (int) pWin->drawable.height;
- pRgn = REGION_CREATE(pWin->drawable.pScreen, &box, 1);
-#ifdef SHAPE
- if (wBoundingShape (pWin) || wClipShape (pWin)) {
- ScreenPtr pScreen = pWin->drawable.pScreen;
-
- REGION_TRANSLATE(pScreen, pRgn, - pWin->drawable.x,
- - pWin->drawable.y);
- if (wBoundingShape (pWin))
- REGION_INTERSECT(pScreen, pRgn, pRgn, wBoundingShape (pWin));
- if (wClipShape (pWin))
- REGION_INTERSECT(pScreen, pRgn, pRgn, wClipShape (pWin));
- REGION_TRANSLATE(pScreen, pRgn, pWin->drawable.x, pWin->drawable.y);
- }
-#endif
- return pRgn;
-}
-
-void
-SetWinSize (pWin)
- register WindowPtr pWin;
-{
- ClippedRegionFromBox(pWin->parent, &pWin->winSize,
- pWin->drawable.x, pWin->drawable.y,
- (int)pWin->drawable.width,
- (int)pWin->drawable.height);
-#ifdef SHAPE
- if (wBoundingShape (pWin) || wClipShape (pWin)) {
- ScreenPtr pScreen = pWin->drawable.pScreen;
-
- REGION_TRANSLATE(pScreen, &pWin->winSize, - pWin->drawable.x,
- - pWin->drawable.y);
- if (wBoundingShape (pWin))
- REGION_INTERSECT(pScreen, &pWin->winSize, &pWin->winSize,
- wBoundingShape (pWin));
- if (wClipShape (pWin))
- REGION_INTERSECT(pScreen, &pWin->winSize, &pWin->winSize,
- wClipShape (pWin));
- REGION_TRANSLATE(pScreen, &pWin->winSize, pWin->drawable.x,
- pWin->drawable.y);
- }
-#endif
-}
-
-void
-SetBorderSize (pWin)
- register WindowPtr pWin;
-{
- int bw;
-
- if (HasBorder (pWin)) {
- bw = wBorderWidth (pWin);
- ClippedRegionFromBox(pWin->parent, &pWin->borderSize,
- pWin->drawable.x - bw, pWin->drawable.y - bw,
- (int)(pWin->drawable.width + (bw<<1)),
- (int)(pWin->drawable.height + (bw<<1)));
-#ifdef SHAPE
- if (wBoundingShape (pWin)) {
- ScreenPtr pScreen = pWin->drawable.pScreen;
-
- REGION_TRANSLATE(pScreen, &pWin->borderSize, - pWin->drawable.x,
- - pWin->drawable.y);
- REGION_INTERSECT(pScreen, &pWin->borderSize, &pWin->borderSize,
- wBoundingShape (pWin));
- REGION_TRANSLATE(pScreen, &pWin->borderSize, pWin->drawable.x,
- pWin->drawable.y);
- REGION_UNION(pScreen, &pWin->borderSize, &pWin->borderSize,
- &pWin->winSize);
- }
-#endif
- } else {
- REGION_COPY(pWin->drawable.pScreen, &pWin->borderSize,
- &pWin->winSize);
- }
-}
-
-void
-GravityTranslate (x, y, oldx, oldy, dw, dh, gravity, destx, desty)
- register int x, y; /* new window position */
- int oldx, oldy; /* old window position */
- int dw, dh;
- unsigned gravity;
- register int *destx, *desty; /* position relative to gravity */
-{
- switch (gravity) {
- case NorthGravity:
- *destx = x + dw / 2;
- *desty = y;
- break;
- case NorthEastGravity:
- *destx = x + dw;
- *desty = y;
- break;
- case WestGravity:
- *destx = x;
- *desty = y + dh / 2;
- break;
- case CenterGravity:
- *destx = x + dw / 2;
- *desty = y + dh / 2;
- break;
- case EastGravity:
- *destx = x + dw;
- *desty = y + dh / 2;
- break;
- case SouthWestGravity:
- *destx = x;
- *desty = y + dh;
- break;
- case SouthGravity:
- *destx = x + dw / 2;
- *desty = y + dh;
- break;
- case SouthEastGravity:
- *destx = x + dw;
- *desty = y + dh;
- break;
- case StaticGravity:
- *destx = oldx;
- *desty = oldy;
- break;
- default:
- *destx = x;
- *desty = y;
- break;
- }
-}
-
-/* XXX need to retile border on each window with ParentRelative origin */
-void
-ResizeChildrenWinSize(pWin, dx, dy, dw, dh)
- register WindowPtr pWin;
- int dx, dy, dw, dh;
-{
- register ScreenPtr pScreen;
- register WindowPtr pSib, pChild;
- Bool resized = (dw || dh);
-
- pScreen = pWin->drawable.pScreen;
-
- for (pSib = pWin->firstChild; pSib; pSib = pSib->nextSib)
- {
- if (resized && (pSib->winGravity > NorthWestGravity))
- {
- int cwsx, cwsy;
-
- cwsx = pSib->origin.x;
- cwsy = pSib->origin.y;
- GravityTranslate (cwsx, cwsy, cwsx - dx, cwsy - dy, dw, dh,
- pSib->winGravity, &cwsx, &cwsy);
- if (cwsx != pSib->origin.x || cwsy != pSib->origin.y)
- {
- xEvent event;
-
- event.u.u.type = GravityNotify;
- event.u.gravity.window = pSib->drawable.id;
- event.u.gravity.x = cwsx - wBorderWidth (pSib);
- event.u.gravity.y = cwsy - wBorderWidth (pSib);
- DeliverEvents (pSib, &event, 1, NullWindow);
- pSib->origin.x = cwsx;
- pSib->origin.y = cwsy;
- }
- }
- pSib->drawable.x = pWin->drawable.x + pSib->origin.x;
- pSib->drawable.y = pWin->drawable.y + pSib->origin.y;
- SetWinSize (pSib);
- SetBorderSize (pSib);
- (*pScreen->PositionWindow)(pSib, pSib->drawable.x, pSib->drawable.y);
- if ( (pChild = pSib->firstChild) )
- {
- while (1)
- {
- pChild->drawable.x = pChild->parent->drawable.x +
- pChild->origin.x;
- pChild->drawable.y = pChild->parent->drawable.y +
- pChild->origin.y;
- SetWinSize (pChild);
- SetBorderSize (pChild);
- (*pScreen->PositionWindow)(pChild,
- pChild->drawable.x, pChild->drawable.y);
- if (pChild->firstChild)
- {
- pChild = pChild->firstChild;
- continue;
- }
- while (!pChild->nextSib && (pChild != pSib))
- pChild = pChild->parent;
- if (pChild == pSib)
- break;
- pChild = pChild->nextSib;
- }
- }
- }
-}
-
-#define GET_INT16(m, f) \
- if (m & mask) \
- { \
- f = (INT16) *pVlist;\
- pVlist++; \
- }
-#define GET_CARD16(m, f) \
- if (m & mask) \
- { \
- f = (CARD16) *pVlist;\
- pVlist++;\
- }
-
-#define GET_CARD8(m, f) \
- if (m & mask) \
- { \
- f = (CARD8) *pVlist;\
- pVlist++;\
- }
-
-#define ChangeMask ((Mask)(CWX | CWY | CWWidth | CWHeight))
-
-#define IllegalInputOnlyConfigureMask (CWBorderWidth)
-
-/*
- * IsSiblingAboveMe
- * returns Above if pSib above pMe in stack or Below otherwise
- */
-
-static int
-IsSiblingAboveMe(pMe, pSib)
- register WindowPtr pMe, pSib;
-{
- register WindowPtr pWin;
-
- pWin = pMe->parent->firstChild;
- while (pWin)
- {
- if (pWin == pSib)
- return(Above);
- else if (pWin == pMe)
- return(Below);
- pWin = pWin->nextSib;
- }
- return(Below);
-}
-
-static BoxPtr
-WindowExtents(pWin, pBox)
- register WindowPtr pWin;
- register BoxPtr pBox;
-{
- pBox->x1 = pWin->drawable.x - wBorderWidth (pWin);
- pBox->y1 = pWin->drawable.y - wBorderWidth (pWin);
- pBox->x2 = pWin->drawable.x + (int)pWin->drawable.width
- + wBorderWidth (pWin);
- pBox->y2 = pWin->drawable.y + (int)pWin->drawable.height
- + wBorderWidth (pWin);
- return(pBox);
-}
-
-#ifdef SHAPE
-#define IS_SHAPED(pWin) (wBoundingShape (pWin) != (RegionPtr) NULL)
-
-static RegionPtr
-MakeBoundingRegion (pWin, pBox)
- register WindowPtr pWin;
- BoxPtr pBox;
-{
- RegionPtr pRgn;
- register ScreenPtr pScreen = pWin->drawable.pScreen;
-
- pRgn = REGION_CREATE(pScreen, pBox, 1);
- if (wBoundingShape (pWin)) {
- REGION_TRANSLATE(pScreen, pRgn, -pWin->origin.x,
- -pWin->origin.y);
- REGION_INTERSECT(pScreen, pRgn, pRgn, wBoundingShape (pWin));
- REGION_TRANSLATE(pScreen, pRgn, pWin->origin.x,
- pWin->origin.y);
- }
- return pRgn;
-}
-
-static Bool
-ShapeOverlap (pWin, pWinBox, pSib, pSibBox)
- WindowPtr pWin, pSib;
- BoxPtr pWinBox, pSibBox;
-{
- RegionPtr pWinRgn, pSibRgn;
- register ScreenPtr pScreen;
- Bool ret;
-
- if (!IS_SHAPED(pWin) && !IS_SHAPED(pSib))
- return TRUE;
- pScreen = pWin->drawable.pScreen;
- pWinRgn = MakeBoundingRegion (pWin, pWinBox);
- pSibRgn = MakeBoundingRegion (pSib, pSibBox);
- REGION_INTERSECT(pScreen, pWinRgn, pWinRgn, pSibRgn);
- ret = REGION_NOTEMPTY(pScreen, pWinRgn);
- REGION_DESTROY(pScreen, pWinRgn);
- REGION_DESTROY(pScreen, pSibRgn);
- return ret;
-}
-#endif
-
-static Bool
-AnyWindowOverlapsMe(pWin, pHead, box)
- WindowPtr pWin, pHead;
- register BoxPtr box;
-{
- register WindowPtr pSib;
- BoxRec sboxrec;
- register BoxPtr sbox;
-
- for (pSib = pWin->prevSib; pSib != pHead; pSib = pSib->prevSib)
- {
- if (pSib->mapped)
- {
- sbox = WindowExtents(pSib, &sboxrec);
- if (BOXES_OVERLAP(sbox, box)
-#ifdef SHAPE
- && ShapeOverlap (pWin, box, pSib, sbox)
-#endif
- )
- return(TRUE);
- }
- }
- return(FALSE);
-}
-
-static Bool
-IOverlapAnyWindow(pWin, box)
- WindowPtr pWin;
- register BoxPtr box;
-{
- register WindowPtr pSib;
- BoxRec sboxrec;
- register BoxPtr sbox;
-
- for (pSib = pWin->nextSib; pSib; pSib = pSib->nextSib)
- {
- if (pSib->mapped)
- {
- sbox = WindowExtents(pSib, &sboxrec);
- if (BOXES_OVERLAP(sbox, box)
-#ifdef SHAPE
- && ShapeOverlap (pWin, box, pSib, sbox)
-#endif
- )
- return(TRUE);
- }
- }
- return(FALSE);
-}
-
-/*
- * WhereDoIGoInTheStack()
- * Given pWin and pSib and the relationshipe smode, return
- * the window that pWin should go ABOVE.
- * If a pSib is specified:
- * Above: pWin is placed just above pSib
- * Below: pWin is placed just below pSib
- * TopIf: if pSib occludes pWin, then pWin is placed
- * at the top of the stack
- * BottomIf: if pWin occludes pSib, then pWin is
- * placed at the bottom of the stack
- * Opposite: if pSib occludes pWin, then pWin is placed at the
- * top of the stack, else if pWin occludes pSib, then
- * pWin is placed at the bottom of the stack
- *
- * If pSib is NULL:
- * Above: pWin is placed at the top of the stack
- * Below: pWin is placed at the bottom of the stack
- * TopIf: if any sibling occludes pWin, then pWin is placed at
- * the top of the stack
- * BottomIf: if pWin occludes any sibline, then pWin is placed at
- * the bottom of the stack
- * Opposite: if any sibling occludes pWin, then pWin is placed at
- * the top of the stack, else if pWin occludes any
- * sibling, then pWin is placed at the bottom of the stack
- *
- */
-
-static WindowPtr
-WhereDoIGoInTheStack(pWin, pSib, x, y, w, h, smode)
- register WindowPtr pWin, pSib;
- short x, y;
- unsigned short w, h;
- int smode;
-{
- BoxRec box;
- register ScreenPtr pScreen;
- WindowPtr pHead, pFirst;
-
- if ((pWin == pWin->parent->firstChild) &&
- (pWin == pWin->parent->lastChild))
- return((WindowPtr ) NULL);
- pHead = RealChildHead(pWin->parent);
- pFirst = pHead ? pHead->nextSib : pWin->parent->firstChild;
- pScreen = pWin->drawable.pScreen;
- box.x1 = x;
- box.y1 = y;
- box.x2 = x + (int)w;
- box.y2 = y + (int)h;
- switch (smode)
- {
- case Above:
- if (pSib)
- return(pSib);
- else if (pWin == pFirst)
- return(pWin->nextSib);
- else
- return(pFirst);
- case Below:
- if (pSib)
- if (pSib->nextSib != pWin)
- return(pSib->nextSib);
- else
- return(pWin->nextSib);
- else
- return NullWindow;
- case TopIf:
- if ((!pWin->mapped || (pSib && !pSib->mapped)) && !permitOldBugs)
- return(pWin->nextSib);
- else if (pSib)
- {
- if ((IsSiblingAboveMe(pWin, pSib) == Above) &&
- (RECT_IN_REGION(pScreen, &pSib->borderSize, &box) != rgnOUT))
- return(pFirst);
- else
- return(pWin->nextSib);
- }
- else if (AnyWindowOverlapsMe(pWin, pHead, &box))
- return(pFirst);
- else
- return(pWin->nextSib);
- case BottomIf:
- if ((!pWin->mapped || (pSib && !pSib->mapped)) && !permitOldBugs)
- return(pWin->nextSib);
- else if (pSib)
- {
- if ((IsSiblingAboveMe(pWin, pSib) == Below) &&
- (RECT_IN_REGION(pScreen, &pSib->borderSize, &box) != rgnOUT))
- return NullWindow;
- else
- return(pWin->nextSib);
- }
- else if (IOverlapAnyWindow(pWin, &box))
- return NullWindow;
- else
- return(pWin->nextSib);
- case Opposite:
- if ((!pWin->mapped || (pSib && !pSib->mapped)) && !permitOldBugs)
- return(pWin->nextSib);
- else if (pSib)
- {
- if (RECT_IN_REGION(pScreen, &pSib->borderSize, &box) != rgnOUT)
- {
- if (IsSiblingAboveMe(pWin, pSib) == Above)
- return(pFirst);
- else
- return NullWindow;
- }
- else
- return(pWin->nextSib);
- }
- else if (AnyWindowOverlapsMe(pWin, pHead, &box))
- {
- /* If I'm occluded, I can't possibly be the first child
- * if (pWin == pWin->parent->firstChild)
- * return pWin->nextSib;
- */
- return(pFirst);
- }
- else if (IOverlapAnyWindow(pWin, &box))
- return NullWindow;
- else
- return pWin->nextSib;
- default:
- {
- ErrorF("Internal error in ConfigureWindow, smode == %d\n",smode );
- return pWin->nextSib;
- }
- }
-}
-
-static void
-ReflectStackChange(pWin, pSib, kind)
- register WindowPtr pWin, pSib;
- VTKind kind;
-{
-/* Note that pSib might be NULL */
-
- Bool WasViewable = (Bool)pWin->viewable;
- WindowPtr pParent;
- Bool anyMarked;
- WindowPtr pFirstChange;
-#ifdef DO_SAVE_UNDERS
- Bool dosave = FALSE;
-#endif
- WindowPtr pLayerWin;
- ScreenPtr pScreen = pWin->drawable.pScreen;
-
- /* if this is a root window, can't be restacked */
- if (!(pParent = pWin->parent))
- return ;
-
- pFirstChange = MoveWindowInStack(pWin, pSib);
-
- if (WasViewable)
- {
- anyMarked = (*pScreen->MarkOverlappedWindows)(pWin, pFirstChange,
- &pLayerWin);
- if (pLayerWin != pWin) pFirstChange = pLayerWin;
-#ifdef DO_SAVE_UNDERS
- if (DO_SAVE_UNDERS(pWin))
- {
- dosave = (*pScreen->ChangeSaveUnder)(pLayerWin, pFirstChange);
- }
-#endif /* DO_SAVE_UNDERS */
- if (anyMarked)
- {
- (*pScreen->ValidateTree)(pLayerWin->parent, pFirstChange, kind);
- (*pScreen->HandleExposures)(pLayerWin->parent);
- }
-#ifdef DO_SAVE_UNDERS
- if (dosave)
- (*pScreen->PostChangeSaveUnder)(pLayerWin, pFirstChange);
-#endif /* DO_SAVE_UNDERS */
- if (anyMarked && pWin->drawable.pScreen->PostValidateTree)
- (*pScreen->PostValidateTree)(pLayerWin->parent, pFirstChange, kind);
- }
- if (pWin->realized)
- WindowsRestructured ();
-}
-
-/*****
- * ConfigureWindow
- *****/
-
-int
-ConfigureWindow(pWin, mask, vlist, client)
- register WindowPtr pWin;
- register Mask mask;
- XID *vlist;
- ClientPtr client;
-{
-#define RESTACK_WIN 0
-#define MOVE_WIN 1
-#define RESIZE_WIN 2
-#define REBORDER_WIN 3
- register WindowPtr pSib = NullWindow;
- register WindowPtr pParent = pWin->parent;
- Window sibwid;
- Mask index, tmask;
- register XID *pVlist;
- short x, y, beforeX, beforeY;
- unsigned short w = pWin->drawable.width,
- h = pWin->drawable.height,
- bw = pWin->borderWidth;
- int action, smode = Above;
-#ifdef XAPPGROUP
- ClientPtr win_owner;
- ClientPtr ag_leader = NULL;
-#endif
- xEvent event;
-
- if ((pWin->drawable.class == InputOnly) && (mask & IllegalInputOnlyConfigureMask))
- return(BadMatch);
-
- if ((mask & CWSibling) && !(mask & CWStackMode))
- return(BadMatch);
-
- pVlist = vlist;
-
- if (pParent)
- {
- x = pWin->drawable.x - pParent->drawable.x - (int)bw;
- y = pWin->drawable.y - pParent->drawable.y - (int)bw;
- }
- else
- {
- x = pWin->drawable.x;
- y = pWin->drawable.y;
- }
- beforeX = x;
- beforeY = y;
- action = RESTACK_WIN;
- if ((mask & (CWX | CWY)) && (!(mask & (CWHeight | CWWidth))))
- {
- GET_INT16(CWX, x);
- GET_INT16(CWY, y);
- action = MOVE_WIN;
- }
- /* or should be resized */
- else if (mask & (CWX | CWY | CWWidth | CWHeight))
- {
- GET_INT16(CWX, x);
- GET_INT16(CWY, y);
- GET_CARD16(CWWidth, w);
- GET_CARD16 (CWHeight, h);
- if (!w || !h)
- {
- client->errorValue = 0;
- return BadValue;
- }
- action = RESIZE_WIN;
- }
- tmask = mask & ~ChangeMask;
- while (tmask)
- {
- index = (Mask)lowbit (tmask);
- tmask &= ~index;
- switch (index)
- {
- case CWBorderWidth:
- GET_CARD16(CWBorderWidth, bw);
- break;
- case CWSibling:
- sibwid = (Window ) *pVlist;
- pVlist++;
- pSib = (WindowPtr )SecurityLookupIDByType(client, sibwid,
- RT_WINDOW, SecurityReadAccess);
- if (!pSib)
- {
- client->errorValue = sibwid;
- return(BadWindow);
- }
- if (pSib->parent != pParent)
- return(BadMatch);
- if (pSib == pWin)
- return(BadMatch);
- break;
- case CWStackMode:
- GET_CARD8(CWStackMode, smode);
- if ((smode != TopIf) && (smode != BottomIf) &&
- (smode != Opposite) && (smode != Above) && (smode != Below))
- {
- client->errorValue = smode;
- return(BadValue);
- }
- break;
- default:
- client->errorValue = mask;
- return(BadValue);
- }
- }
- /* root really can't be reconfigured, so just return */
- if (!pParent)
- return Success;
-
- /* Figure out if the window should be moved. Doesnt
- make the changes to the window if event sent */
-
- if (mask & CWStackMode)
- pSib = WhereDoIGoInTheStack(pWin, pSib, pParent->drawable.x + x,
- pParent->drawable.y + y,
- w + (bw << 1), h + (bw << 1), smode);
- else
- pSib = pWin->nextSib;
-
-#ifdef XAPPGROUP
- win_owner = clients[CLIENT_ID(pWin->drawable.id)];
- ag_leader = XagLeader (win_owner);
-#endif
-
- if ((!pWin->overrideRedirect) &&
- (RedirectSend(pParent)
-#ifdef XAPPGROUP
- || (win_owner->appgroup && ag_leader &&
- XagIsControlledRoot (client, pParent))
-#endif
- ))
- {
- event.u.u.type = ConfigureRequest;
- event.u.configureRequest.window = pWin->drawable.id;
- if (mask & CWSibling)
- event.u.configureRequest.sibling = sibwid;
- else
- event.u.configureRequest.sibling = None;
- if (mask & CWStackMode)
- event.u.u.detail = smode;
- else
- event.u.u.detail = Above;
- event.u.configureRequest.x = x;
- event.u.configureRequest.y = y;
- event.u.configureRequest.width = w;
- event.u.configureRequest.height = h;
- event.u.configureRequest.borderWidth = bw;
- event.u.configureRequest.valueMask = mask;
-#ifdef XAPPGROUP
- /* make sure if the ag_leader maps the window it goes to the wm */
- if (ag_leader && ag_leader != client &&
- XagIsControlledRoot (client, pParent)) {
- event.u.configureRequest.parent = XagId (win_owner);
- (void) TryClientEvents (ag_leader, &event, 1,
- NoEventMask, NoEventMask, NullGrab);
- return Success;
- }
-#endif
- event.u.configureRequest.parent = pParent->drawable.id;
- if (MaybeDeliverEventsToClient(pParent, &event, 1,
- SubstructureRedirectMask, client) == 1)
- return(Success);
- }
- if (action == RESIZE_WIN)
- {
- Bool size_change = (w != pWin->drawable.width)
- || (h != pWin->drawable.height);
- if (size_change && ((pWin->eventMask|wOtherEventMasks(pWin)) & ResizeRedirectMask))
- {
- xEvent eventT;
- eventT.u.u.type = ResizeRequest;
- eventT.u.resizeRequest.window = pWin->drawable.id;
- eventT.u.resizeRequest.width = w;
- eventT.u.resizeRequest.height = h;
- if (MaybeDeliverEventsToClient(pWin, &eventT, 1,
- ResizeRedirectMask, client) == 1)
- {
- /* if event is delivered, leave the actual size alone. */
- w = pWin->drawable.width;
- h = pWin->drawable.height;
- size_change = FALSE;
- }
- }
- if (!size_change)
- {
- if (mask & (CWX | CWY))
- action = MOVE_WIN;
- else if (mask & (CWStackMode | CWBorderWidth))
- action = RESTACK_WIN;
- else /* really nothing to do */
- return(Success) ;
- }
- }
-
- if (action == RESIZE_WIN)
- /* we've already checked whether there's really a size change */
- goto ActuallyDoSomething;
- if ((mask & CWX) && (x != beforeX))
- goto ActuallyDoSomething;
- if ((mask & CWY) && (y != beforeY))
- goto ActuallyDoSomething;
- if ((mask & CWBorderWidth) && (bw != wBorderWidth (pWin)))
- goto ActuallyDoSomething;
- if (mask & CWStackMode)
- {
- if (pWin->nextSib != pSib)
- goto ActuallyDoSomething;
- }
- return(Success);
-
-ActuallyDoSomething:
- if (SubStrSend(pWin, pParent))
- {
- event.u.u.type = ConfigureNotify;
- event.u.configureNotify.window = pWin->drawable.id;
- if (pSib)
- event.u.configureNotify.aboveSibling = pSib->drawable.id;
- else
- event.u.configureNotify.aboveSibling = None;
- event.u.configureNotify.x = x;
- event.u.configureNotify.y = y;
- event.u.configureNotify.width = w;
- event.u.configureNotify.height = h;
- event.u.configureNotify.borderWidth = bw;
- event.u.configureNotify.override = pWin->overrideRedirect;
-#ifdef PANORAMIX
- /* In the case where a window is split between one
- or more screen, a ConfigureNotify event will be written
- to the client describing the section of the window
- which is changed per screen. This causes a failure
- in the vsw test CH03/mvrszwdw because the test is
- not properly written and expects 1 event and fails
- when it reads more than 1 event when the window is
- split. The server is in fact doing the expected and
- correct behavior. -mad 10/11/96
- */
- if (!noPanoramiXExtension) {
- if (!PanoramiXWindowOffScreen(pWin, w, h))
- DeliverEvents(pWin, &event, 1, NullWindow);
- }else
- DeliverEvents(pWin, &event, 1, NullWindow);
-#else
- DeliverEvents(pWin, &event, 1, NullWindow);
-#endif
- }
- if (mask & CWBorderWidth)
- {
- if (action == RESTACK_WIN)
- {
- action = MOVE_WIN;
- pWin->borderWidth = bw;
- }
- else if ((action == MOVE_WIN) &&
- (beforeX + wBorderWidth (pWin) == x + (int)bw) &&
- (beforeY + wBorderWidth (pWin) == y + (int)bw))
- {
- action = REBORDER_WIN;
- (*pWin->drawable.pScreen->ChangeBorderWidth)(pWin, bw);
- }
- else
- pWin->borderWidth = bw;
- }
- if (action == MOVE_WIN)
- (*pWin->drawable.pScreen->MoveWindow)(pWin, x, y, pSib,
- (mask & CWBorderWidth) ? VTOther : VTMove);
- else if (action == RESIZE_WIN)
- (*pWin->drawable.pScreen->ResizeWindow)(pWin, x, y, w, h, pSib);
- else if (mask & CWStackMode)
- ReflectStackChange(pWin, pSib, VTOther);
-
- if (action != RESTACK_WIN)
- CheckCursorConfinement(pWin);
-
- return(Success);
-#undef RESTACK_WIN
-#undef MOVE_WIN
-#undef RESIZE_WIN
-#undef REBORDER_WIN
-}
-
-
-/******
- *
- * CirculateWindow
- * For RaiseLowest, raises the lowest mapped child (if any) that is
- * obscured by another child to the top of the stack. For LowerHighest,
- * lowers the highest mapped child (if any) that is obscuring another
- * child to the bottom of the stack. Exposure processing is performed
- *
- ******/
-
-int
-CirculateWindow(pParent, direction, client)
- WindowPtr pParent;
- int direction;
- ClientPtr client;
-{
- register WindowPtr pWin, pHead, pFirst;
- xEvent event;
- BoxRec box;
-
- pHead = RealChildHead(pParent);
- pFirst = pHead ? pHead->nextSib : pParent->firstChild;
- if (direction == RaiseLowest)
- {
- for (pWin = pParent->lastChild;
- (pWin != pHead) &&
- !(pWin->mapped &&
- AnyWindowOverlapsMe(pWin, pHead, WindowExtents(pWin, &box)));
- pWin = pWin->prevSib) ;
- if (pWin == pHead)
- return Success;
- }
- else
- {
- for (pWin = pFirst;
- pWin &&
- !(pWin->mapped &&
- IOverlapAnyWindow(pWin, WindowExtents(pWin, &box)));
- pWin = pWin->nextSib) ;
- if (!pWin)
- return Success;
- }
-
- event.u.circulate.window = pWin->drawable.id;
- event.u.circulate.parent = pParent->drawable.id;
- event.u.circulate.event = pParent->drawable.id;
- if (direction == RaiseLowest)
- event.u.circulate.place = PlaceOnTop;
- else
- event.u.circulate.place = PlaceOnBottom;
-
- if (RedirectSend(pParent))
- {
- event.u.u.type = CirculateRequest;
- if (MaybeDeliverEventsToClient(pParent, &event, 1,
- SubstructureRedirectMask, client) == 1)
- return(Success);
- }
-
- event.u.u.type = CirculateNotify;
- DeliverEvents(pWin, &event, 1, NullWindow);
- ReflectStackChange(pWin,
- (direction == RaiseLowest) ? pFirst : NullWindow,
- VTStack);
-
- return(Success);
-}
-
-static int
-CompareWIDs(pWin, value)
- WindowPtr pWin;
- pointer value; /* must conform to VisitWindowProcPtr */
-{
- Window *wid = (Window *)value;
-
- if (pWin->drawable.id == *wid)
- return(WT_STOPWALKING);
- else
- return(WT_WALKCHILDREN);
-}
-
-/*****
- * ReparentWindow
- *****/
-
-int
-ReparentWindow(pWin, pParent, x, y, client)
- register WindowPtr pWin, pParent;
- int x,y;
- ClientPtr client;
-{
- WindowPtr pPrev, pPriorParent;
- Bool WasMapped = (Bool)(pWin->mapped);
- xEvent event;
- int bw = wBorderWidth (pWin);
- register ScreenPtr pScreen;
-
- pScreen = pWin->drawable.pScreen;
- if (TraverseTree(pWin, CompareWIDs, (pointer)&pParent->drawable.id) == WT_STOPWALKING)
- return(BadMatch);
- if (!MakeWindowOptional(pWin))
- return(BadAlloc);
-
- if (WasMapped)
- UnmapWindow(pWin, FALSE);
-
- event.u.u.type = ReparentNotify;
- event.u.reparent.window = pWin->drawable.id;
- event.u.reparent.parent = pParent->drawable.id;
- event.u.reparent.x = x;
- event.u.reparent.y = y;
- event.u.reparent.override = pWin->overrideRedirect;
- DeliverEvents(pWin, &event, 1, pParent);
-
- /* take out of sibling chain */
-
- pPriorParent = pPrev = pWin->parent;
- if (pPrev->firstChild == pWin)
- pPrev->firstChild = pWin->nextSib;
- if (pPrev->lastChild == pWin)
- pPrev->lastChild = pWin->prevSib;
-
- if (pWin->nextSib)
- pWin->nextSib->prevSib = pWin->prevSib;
- if (pWin->prevSib)
- pWin->prevSib->nextSib = pWin->nextSib;
-
- /* insert at begining of pParent */
- pWin->parent = pParent;
- pPrev = RealChildHead(pParent);
- if (pPrev)
- {
- pWin->nextSib = pPrev->nextSib;
- if (pPrev->nextSib)
- pPrev->nextSib->prevSib = pWin;
- else
- pParent->lastChild = pWin;
- pPrev->nextSib = pWin;
- pWin->prevSib = pPrev;
- }
- else
- {
- pWin->nextSib = pParent->firstChild;
- pWin->prevSib = NullWindow;
- if (pParent->firstChild)
- pParent->firstChild->prevSib = pWin;
- else
- pParent->lastChild = pWin;
- pParent->firstChild = pWin;
- }
-
- pWin->origin.x = x + bw;
- pWin->origin.y = y + bw;
- pWin->drawable.x = x + bw + pParent->drawable.x;
- pWin->drawable.y = y + bw + pParent->drawable.y;
-
- /* clip to parent */
- SetWinSize (pWin);
- SetBorderSize (pWin);
-
- if (pScreen->ReparentWindow)
- (*pScreen->ReparentWindow)(pWin, pPriorParent);
- (*pScreen->PositionWindow)(pWin, pWin->drawable.x, pWin->drawable.y);
- ResizeChildrenWinSize(pWin, 0, 0, 0, 0);
-
- CheckWindowOptionalNeed(pWin);
-
- if (WasMapped)
- MapWindow(pWin, client);
- RecalculateDeliverableEvents(pWin);
- return(Success);
-}
-
-static void
-RealizeTree(pWin)
- WindowPtr pWin;
-{
- register WindowPtr pChild;
- Bool (* Realize)();
-
- Realize = pWin->drawable.pScreen->RealizeWindow;
- pChild = pWin;
- while (1)
- {
- if (pChild->mapped)
- {
- pChild->realized = TRUE;
-#ifdef DO_SAVE_UNDERS
- if (pChild->saveUnder)
- deltaSaveUndersViewable++;
-#endif
- pChild->viewable = (pChild->drawable.class == InputOutput);
- (* Realize)(pChild);
- if (pChild->firstChild)
- {
- pChild = pChild->firstChild;
- continue;
- }
- }
- while (!pChild->nextSib && (pChild != pWin))
- pChild = pChild->parent;
- if (pChild == pWin)
- return;
- pChild = pChild->nextSib;
- }
-}
-
-/*****
- * MapWindow
- * If some other client has selected SubStructureReDirect on the parent
- * and override-redirect is xFalse, then a MapRequest event is generated,
- * but the window remains unmapped. Otherwise, the window is mapped and a
- * MapNotify event is generated.
- *****/
-
-int
-MapWindow(pWin, client)
- register WindowPtr pWin;
- ClientPtr client;
-{
- register ScreenPtr pScreen;
-
- register WindowPtr pParent;
-#ifdef DO_SAVE_UNDERS
- Bool dosave = FALSE;
-#endif
- WindowPtr pLayerWin;
-
- if (pWin->mapped)
- return(Success);
-
-#ifdef XCSECURITY
- /* don't let an untrusted client map a child-of-trusted-window, InputOnly
- * window; too easy to steal device input
- */
- if ( (client->trustLevel != XSecurityClientTrusted) &&
- (pWin->drawable.class == InputOnly) &&
- (wClient(pWin->parent)->trustLevel == XSecurityClientTrusted) )
- return Success;
-#endif
-
- pScreen = pWin->drawable.pScreen;
- if ( (pParent = pWin->parent) )
- {
- xEvent event;
- Bool anyMarked;
-#ifdef XAPPGROUP
- ClientPtr win_owner = clients[CLIENT_ID(pWin->drawable.id)];
- ClientPtr ag_leader = XagLeader (win_owner);
-#endif
-
- if ((!pWin->overrideRedirect) &&
- (RedirectSend(pParent)
-#ifdef XAPPGROUP
- || (win_owner->appgroup && ag_leader &&
- XagIsControlledRoot (client, pParent))
-#endif
- ))
- {
- event.u.u.type = MapRequest;
- event.u.mapRequest.window = pWin->drawable.id;
-#ifdef XAPPGROUP
- /* make sure if the ag_leader maps the window it goes to the wm */
- if (ag_leader && ag_leader != client &&
- XagIsControlledRoot (client, pParent)) {
- event.u.mapRequest.parent = XagId (win_owner);
- (void) TryClientEvents (ag_leader, &event, 1,
- NoEventMask, NoEventMask, NullGrab);
- return Success;
- }
-#endif
- event.u.mapRequest.parent = pParent->drawable.id;
-
- if (MaybeDeliverEventsToClient(pParent, &event, 1,
- SubstructureRedirectMask, client) == 1)
- return(Success);
- }
-
- pWin->mapped = TRUE;
- if (SubStrSend(pWin, pParent))
- {
- event.u.u.type = MapNotify;
- event.u.mapNotify.window = pWin->drawable.id;
- event.u.mapNotify.override = pWin->overrideRedirect;
- DeliverEvents(pWin, &event, 1, NullWindow);
- }
-
- if (!pParent->realized)
- return(Success);
- RealizeTree(pWin);
- if (pWin->viewable)
- {
- anyMarked = (*pScreen->MarkOverlappedWindows)(pWin, pWin,
- &pLayerWin);
-#ifdef DO_SAVE_UNDERS
- if (DO_SAVE_UNDERS(pWin))
- {
- dosave = (*pScreen->ChangeSaveUnder)(pLayerWin, pWin->nextSib);
- }
-#endif /* DO_SAVE_UNDERS */
- if (anyMarked)
- {
- (*pScreen->ValidateTree)(pLayerWin->parent, pLayerWin, VTMap);
- (*pScreen->HandleExposures)(pLayerWin->parent);
- }
-#ifdef DO_SAVE_UNDERS
- if (dosave)
- (*pScreen->PostChangeSaveUnder)(pLayerWin, pWin->nextSib);
-#endif /* DO_SAVE_UNDERS */
- if (anyMarked && pScreen->PostValidateTree)
- (*pScreen->PostValidateTree)(pLayerWin->parent, pLayerWin, VTMap);
- }
- WindowsRestructured ();
- }
- else
- {
- RegionRec temp;
-
- pWin->mapped = TRUE;
- pWin->realized = TRUE; /* for roots */
- pWin->viewable = pWin->drawable.class == InputOutput;
- /* We SHOULD check for an error value here XXX */
- (*pScreen->RealizeWindow)(pWin);
- if (pScreen->ClipNotify)
- (*pScreen->ClipNotify) (pWin, 0, 0);
- if (pScreen->PostValidateTree)
- (*pScreen->PostValidateTree)(NullWindow, pWin, VTMap);
- REGION_INIT(pScreen, &temp, NullBox, 0);
- REGION_COPY(pScreen, &temp, &pWin->clipList);
- (*pScreen->WindowExposures) (pWin, &temp, NullRegion);
- REGION_UNINIT(pScreen, &temp);
- }
-
- return(Success);
-}
-
-
-/*****
- * MapSubwindows
- * Performs a MapWindow all unmapped children of the window, in top
- * to bottom stacking order.
- *****/
-
-void
-MapSubwindows(pParent, client)
- register WindowPtr pParent;
- ClientPtr client;
-{
- register WindowPtr pWin;
- WindowPtr pFirstMapped = NullWindow;
-#ifdef DO_SAVE_UNDERS
- WindowPtr pFirstSaveUndered = NullWindow;
-#endif
- register ScreenPtr pScreen;
- register Mask parentRedirect;
- register Mask parentNotify;
- xEvent event;
- Bool anyMarked;
-#ifdef DO_SAVE_UNDERS
- Bool dosave = FALSE;
-#endif
- WindowPtr pLayerWin;
-
- pScreen = pParent->drawable.pScreen;
- parentRedirect = RedirectSend(pParent);
- parentNotify = SubSend(pParent);
- anyMarked = FALSE;
- for (pWin = pParent->firstChild; pWin; pWin = pWin->nextSib)
- {
- if (!pWin->mapped)
- {
- if (parentRedirect && !pWin->overrideRedirect)
- {
- event.u.u.type = MapRequest;
- event.u.mapRequest.window = pWin->drawable.id;
- event.u.mapRequest.parent = pParent->drawable.id;
-
- if (MaybeDeliverEventsToClient(pParent, &event, 1,
- SubstructureRedirectMask, client) == 1)
- continue;
- }
-
- pWin->mapped = TRUE;
- if (parentNotify || StrSend(pWin))
- {
- event.u.u.type = MapNotify;
- event.u.mapNotify.window = pWin->drawable.id;
- event.u.mapNotify.override = pWin->overrideRedirect;
- DeliverEvents(pWin, &event, 1, NullWindow);
- }
-
- if (!pFirstMapped)
- pFirstMapped = pWin;
- if (pParent->realized)
- {
- RealizeTree(pWin);
- if (pWin->viewable)
- {
- anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin, pWin,
- (WindowPtr *)NULL);
-#ifdef DO_SAVE_UNDERS
- if (DO_SAVE_UNDERS(pWin))
- {
- dosave = TRUE;
- }
-#endif /* DO_SAVE_UNDERS */
- }
- }
- }
- }
-
- if (pFirstMapped)
- {
- pLayerWin = (*pScreen->GetLayerWindow)(pParent);
- if (pLayerWin->parent != pParent) {
- anyMarked |= (*pScreen->MarkOverlappedWindows)(pLayerWin,
- pLayerWin,
- (WindowPtr *)NULL);
- pFirstMapped = pLayerWin;
- }
- if (anyMarked)
- {
-#ifdef DO_SAVE_UNDERS
- if (pLayerWin->parent != pParent)
- {
- if (dosave || (DO_SAVE_UNDERS(pLayerWin)))
- {
- dosave = (*pScreen->ChangeSaveUnder)(pLayerWin,
- pLayerWin);
- }
- }
- else if (dosave)
- {
- dosave = FALSE;
- for (pWin = pParent->firstChild; pWin; pWin = pWin->nextSib)
- {
- if (DO_SAVE_UNDERS(pWin))
- {
- dosave |= (*pScreen->ChangeSaveUnder)(pWin,
- pWin->nextSib);
- if (dosave && !pFirstSaveUndered)
- pFirstSaveUndered = pWin;
- }
- }
- }
-#endif /* DO_SAVE_UNDERS */
- (*pScreen->ValidateTree)(pLayerWin->parent, pFirstMapped, VTMap);
- (*pScreen->HandleExposures)(pLayerWin->parent);
- }
-#ifdef DO_SAVE_UNDERS
- if (dosave)
- (*pScreen->PostChangeSaveUnder)(pLayerWin,
- pFirstSaveUndered->nextSib);
-#endif /* DO_SAVE_UNDERS */
- if (anyMarked && pScreen->PostValidateTree)
- (*pScreen->PostValidateTree)(pLayerWin->parent, pFirstMapped,
- VTMap);
- WindowsRestructured ();
- }
-}
-
-static void
-UnrealizeTree(pWin, fromConfigure)
- WindowPtr pWin;
- Bool fromConfigure;
-{
- register WindowPtr pChild;
- UnrealizeWindowProcPtr Unrealize;
- MarkUnrealizedWindowProcPtr MarkUnrealizedWindow;
-
- Unrealize = pWin->drawable.pScreen->UnrealizeWindow;
- MarkUnrealizedWindow = pWin->drawable.pScreen->MarkUnrealizedWindow;
- pChild = pWin;
- while (1)
- {
- if (pChild->realized)
- {
- pChild->realized = FALSE;
- pChild->visibility = VisibilityNotViewable;
- (* Unrealize)(pChild);
- DeleteWindowFromAnyEvents(pChild, FALSE);
- if (pChild->viewable)
- {
-#ifdef DO_SAVE_UNDERS
- if (pChild->saveUnder)
- deltaSaveUndersViewable--;
-#endif
- pChild->viewable = FALSE;
- if (pChild->backStorage)
- (*pChild->drawable.pScreen->SaveDoomedAreas)(
- pChild, &pChild->clipList, 0, 0);
- (* MarkUnrealizedWindow)(pChild, pWin, fromConfigure);
- pChild->drawable.serialNumber = NEXT_SERIAL_NUMBER;
- }
- if (pChild->firstChild)
- {
- pChild = pChild->firstChild;
- continue;
- }
- }
- while (!pChild->nextSib && (pChild != pWin))
- pChild = pChild->parent;
- if (pChild == pWin)
- return;
- pChild = pChild->nextSib;
- }
-}
-
-/*****
- * UnmapWindow
- * If the window is already unmapped, this request has no effect.
- * Otherwise, the window is unmapped and an UnMapNotify event is
- * generated. Cannot unmap a root window.
- *****/
-
-int
-UnmapWindow(pWin, fromConfigure)
- register WindowPtr pWin;
- Bool fromConfigure;
-{
- register WindowPtr pParent;
- xEvent event;
- Bool wasRealized = (Bool)pWin->realized;
- Bool wasViewable = (Bool)pWin->viewable;
- ScreenPtr pScreen = pWin->drawable.pScreen;
- WindowPtr pLayerWin = pWin;
-
- if ((!pWin->mapped) || (!(pParent = pWin->parent)))
- return(Success);
- if (SubStrSend(pWin, pParent))
- {
- event.u.u.type = UnmapNotify;
- event.u.unmapNotify.window = pWin->drawable.id;
- event.u.unmapNotify.fromConfigure = fromConfigure;
- DeliverEvents(pWin, &event, 1, NullWindow);
- }
- if (wasViewable && !fromConfigure)
- {
- pWin->valdata = UnmapValData;
- (*pScreen->MarkOverlappedWindows)(pWin, pWin->nextSib, &pLayerWin);
- (*pScreen->MarkWindow)(pLayerWin->parent);
- }
- pWin->mapped = FALSE;
- if (wasRealized)
- UnrealizeTree(pWin, fromConfigure);
- if (wasViewable)
- {
- if (!fromConfigure)
- {
- (*pScreen->ValidateTree)(pLayerWin->parent, pWin, VTUnmap);
- (*pScreen->HandleExposures)(pLayerWin->parent);
- }
-#ifdef DO_SAVE_UNDERS
- if (DO_SAVE_UNDERS(pWin))
- {
- if ( (*pScreen->ChangeSaveUnder)(pLayerWin, pWin->nextSib) )
- {
- (*pScreen->PostChangeSaveUnder)(pLayerWin, pWin->nextSib);
- }
- }
- pWin->DIXsaveUnder = FALSE;
-#endif /* DO_SAVE_UNDERS */
- if (!fromConfigure && pScreen->PostValidateTree)
- (*pScreen->PostValidateTree)(pLayerWin->parent, pWin, VTUnmap);
- }
- if (wasRealized && !fromConfigure)
- WindowsRestructured ();
- return(Success);
-}
-
-/*****
- * UnmapSubwindows
- * Performs an UnmapWindow request with the specified mode on all mapped
- * children of the window, in bottom to top stacking order.
- *****/
-
-void
-UnmapSubwindows(pWin)
- register WindowPtr pWin;
-{
- register WindowPtr pChild, pHead;
- xEvent event;
- Bool wasRealized = (Bool)pWin->realized;
- Bool wasViewable = (Bool)pWin->viewable;
- Bool anyMarked = FALSE;
- Mask parentNotify;
- WindowPtr pLayerWin;
- ScreenPtr pScreen = pWin->drawable.pScreen;
-
- if (!pWin->firstChild)
- return;
- parentNotify = SubSend(pWin);
- pHead = RealChildHead(pWin);
-
- if (wasViewable)
- pLayerWin = (*pScreen->GetLayerWindow)(pWin);
-
- for (pChild = pWin->lastChild; pChild != pHead; pChild = pChild->prevSib)
- {
- if (pChild->mapped)
- {
- if (parentNotify || StrSend(pChild))
- {
- event.u.u.type = UnmapNotify;
- event.u.unmapNotify.window = pChild->drawable.id;
- event.u.unmapNotify.fromConfigure = xFalse;
- DeliverEvents(pChild, &event, 1, NullWindow);
- }
- if (pChild->viewable)
- {
- pChild->valdata = UnmapValData;
- anyMarked = TRUE;
- }
- pChild->mapped = FALSE;
- if (pChild->realized)
- UnrealizeTree(pChild, FALSE);
- if (wasViewable)
- {
-#ifdef DO_SAVE_UNDERS
- pChild->DIXsaveUnder = FALSE;
-#endif /* DO_SAVE_UNDERS */
- if (pChild->backStorage)
- (*pScreen->SaveDoomedAreas)(
- pChild, &pChild->clipList, 0, 0);
- }
- }
- }
- if (wasViewable)
- {
- if (anyMarked)
- {
- if (pLayerWin->parent == pWin)
- (*pScreen->MarkWindow)(pWin);
- else
- {
- WindowPtr ptmp;
- (*pScreen->MarkOverlappedWindows)(pWin, pLayerWin,
- (WindowPtr *)NULL);
- (*pScreen->MarkWindow)(pLayerWin->parent);
-
- /* Windows between pWin and pLayerWin may not have been marked */
- ptmp = pWin;
-
- while (ptmp != pLayerWin->parent)
- {
- (*pScreen->MarkWindow)(ptmp);
- ptmp = ptmp->parent;
- }
- pHead = pWin->firstChild;
- }
- (*pScreen->ValidateTree)(pLayerWin->parent, pHead, VTUnmap);
- (*pScreen->HandleExposures)(pLayerWin->parent);
- }
-#ifdef DO_SAVE_UNDERS
- if (DO_SAVE_UNDERS(pWin))
- {
- if ( (*pScreen->ChangeSaveUnder)(pLayerWin, pLayerWin))
- (*pScreen->PostChangeSaveUnder)(pLayerWin, pLayerWin);
- }
-#endif /* DO_SAVE_UNDERS */
- if (anyMarked && pScreen->PostValidateTree)
- (*pScreen->PostValidateTree)(pLayerWin->parent, pHead, VTUnmap);
- }
- if (wasRealized)
- WindowsRestructured ();
-}
-
-
-void
-HandleSaveSet(client)
- register ClientPtr client;
-{
- register WindowPtr pParent, pWin;
- register int j;
-
- for (j=0; j<client->numSaved; j++)
- {
- pWin = (WindowPtr)client->saveSet[j];
- pParent = pWin->parent;
- while (pParent && (wClient (pParent) == client))
- pParent = pParent->parent;
- if (pParent)
- {
- if (pParent != pWin->parent)
- {
- ReparentWindow(pWin, pParent,
- pWin->drawable.x - wBorderWidth (pWin) - pParent->drawable.x,
- pWin->drawable.y - wBorderWidth (pWin) - pParent->drawable.y,
- client);
- if(!pWin->realized && pWin->mapped)
- pWin->mapped = FALSE;
- }
- MapWindow(pWin, client);
- }
- }
- xfree(client->saveSet);
- client->numSaved = 0;
- client->saveSet = (pointer *)NULL;
-}
-
-Bool
-VisibleBoundingBoxFromPoint(pWin, x, y, box)
- register WindowPtr pWin;
- int x, y; /* in root */
- BoxPtr box; /* "return" value */
-{
- if (!pWin->realized)
- return (FALSE);
- if (POINT_IN_REGION(pWin->drawable.pScreen, &pWin->clipList, x, y, box))
- return(TRUE);
- return(FALSE);
-}
-
-Bool
-PointInWindowIsVisible(pWin, x, y)
- register WindowPtr pWin;
- int x, y; /* in root */
-{
- BoxRec box;
-
- if (!pWin->realized)
- return (FALSE);
- if (POINT_IN_REGION(pWin->drawable.pScreen, &pWin->borderClip,
- x, y, &box))
- return(TRUE);
- return(FALSE);
-}
-
-
-RegionPtr
-NotClippedByChildren(pWin)
- register WindowPtr pWin;
-{
- register ScreenPtr pScreen;
- RegionPtr pReg;
-
- pScreen = pWin->drawable.pScreen;
- pReg = REGION_CREATE(pScreen, NullBox, 1);
- if (pWin->parent ||
- screenIsSaved != SCREEN_SAVER_ON ||
- !HasSaverWindow (pWin->drawable.pScreen->myNum))
- {
- REGION_INTERSECT(pScreen, pReg, &pWin->borderClip, &pWin->winSize);
- }
- return(pReg);
-}
-
-
-void
-SendVisibilityNotify(pWin)
- WindowPtr pWin;
-{
- xEvent event;
- event.u.u.type = VisibilityNotify;
- event.u.visibility.window = pWin->drawable.id;
- event.u.visibility.state = pWin->visibility;
- DeliverEvents(pWin, &event, 1, NullWindow);
-}
-
-
-#define RANDOM_WIDTH 32
-
-#ifndef NOLOGOHACK
-extern int logoScreenSaver;
-static void DrawLogo(
-#if NeedFunctionPrototypes
- WindowPtr /*pWin*/
-#endif
-);
-#endif
-
-void
-SaveScreens(on, mode)
- int on;
- int mode;
-{
- int i;
- int what;
- int type;
-
- if (on == SCREEN_SAVER_FORCER)
- {
- UpdateCurrentTimeIf();
- lastDeviceEventTime = currentTime;
- if (mode == ScreenSaverReset)
- what = SCREEN_SAVER_OFF;
- else
- what = SCREEN_SAVER_ON;
- type = what;
- }
- else
- {
- what = on;
- type = what;
- if (what == screenIsSaved)
- type = SCREEN_SAVER_CYCLE;
- }
- for (i = 0; i < screenInfo.numScreens; i++)
- {
- if (on == SCREEN_SAVER_FORCER)
- (* screenInfo.screens[i]->SaveScreen) (screenInfo.screens[i], on);
- if (savedScreenInfo[i].ExternalScreenSaver)
- {
- if ((*savedScreenInfo[i].ExternalScreenSaver)
- (screenInfo.screens[i], type, on == SCREEN_SAVER_FORCER))
- continue;
- }
- if (type == screenIsSaved)
- continue;
- switch (type) {
- case SCREEN_SAVER_OFF:
- if (savedScreenInfo[i].blanked == SCREEN_IS_BLANKED)
- {
- (* screenInfo.screens[i]->SaveScreen) (screenInfo.screens[i],
- what);
- }
- else if (HasSaverWindow (i))
- {
- savedScreenInfo[i].pWindow = NullWindow;
- FreeResource(savedScreenInfo[i].wid, RT_NONE);
- }
- break;
- case SCREEN_SAVER_CYCLE:
- if (savedScreenInfo[i].blanked == SCREEN_IS_TILED)
- {
- WindowPtr pWin = savedScreenInfo[i].pWindow;
- /* make it look like screen saver is off, so that
- * NotClippedByChildren will compute a clip list
- * for the root window, so miPaintWindow works
- */
- screenIsSaved = SCREEN_SAVER_OFF;
-#ifndef NOLOGOHACK
- if (logoScreenSaver)
- (*pWin->drawable.pScreen->ClearToBackground)(pWin, 0, 0, 0, 0, FALSE);
-#endif
- (*pWin->drawable.pScreen->MoveWindow)(pWin,
- (short)(-(rand() % RANDOM_WIDTH)),
- (short)(-(rand() % RANDOM_WIDTH)),
- pWin->nextSib, VTMove);
-#ifndef NOLOGOHACK
- if (logoScreenSaver)
- DrawLogo(pWin);
-#endif
- screenIsSaved = SCREEN_SAVER_ON;
- }
- break;
- case SCREEN_SAVER_ON:
- if (ScreenSaverBlanking != DontPreferBlanking)
- {
- if ((* screenInfo.screens[i]->SaveScreen)
- (screenInfo.screens[i], what))
- {
- savedScreenInfo[i].blanked = SCREEN_IS_BLANKED;
- continue;
- }
- if ((ScreenSaverAllowExposures != DontAllowExposures) &&
- TileScreenSaver(i, SCREEN_IS_BLACK))
- {
- savedScreenInfo[i].blanked = SCREEN_IS_BLACK;
- continue;
- }
- }
- if ((ScreenSaverAllowExposures != DontAllowExposures) &&
- TileScreenSaver(i, SCREEN_IS_TILED))
- {
- savedScreenInfo[i].blanked = SCREEN_IS_TILED;
- }
- else
- savedScreenInfo[i].blanked = SCREEN_ISNT_SAVED;
- break;
- }
- }
- screenIsSaved = what;
-}
-
-static Bool
-TileScreenSaver(i, kind)
- int i;
- int kind;
-{
- int j;
- int result;
- XID attributes[3];
- Mask mask;
- WindowPtr pWin;
- CursorMetricRec cm;
- unsigned char *srcbits, *mskbits;
- CursorPtr cursor;
- XID cursorID;
- int attri;
-
- mask = 0;
- attri = 0;
- switch (kind) {
- case SCREEN_IS_TILED:
- switch (WindowTable[i]->backgroundState) {
- case BackgroundPixel:
- attributes[attri++] = WindowTable[i]->background.pixel;
- mask |= CWBackPixel;
- break;
- case BackgroundPixmap:
- attributes[attri++] = None;
- mask |= CWBackPixmap;
- break;
- default:
- break;
- }
- break;
- case SCREEN_IS_BLACK:
- attributes[attri++] = WindowTable[i]->drawable.pScreen->blackPixel;
- mask |= CWBackPixel;
- break;
- }
- mask |= CWOverrideRedirect;
- attributes[attri++] = xTrue;
-
- /*
- * create a blank cursor
- */
-
- cm.width=16;
- cm.height=16;
- cm.xhot=8;
- cm.yhot=8;
- srcbits = (unsigned char *)xalloc( BitmapBytePad(32)*16);
- mskbits = (unsigned char *)xalloc( BitmapBytePad(32)*16);
- if (!srcbits || !mskbits)
- {
- xfree(srcbits);
- xfree(mskbits);
- cursor = 0;
- }
- else
- {
- for (j=0; j<BitmapBytePad(32)*16; j++)
- srcbits[j] = mskbits[j] = 0x0;
- cursor = AllocCursor(srcbits, mskbits, &cm, 0, 0, 0, 0, 0, 0);
- if (cursor)
- {
- cursorID = FakeClientID(0);
- if (AddResource (cursorID, RT_CURSOR, (pointer) cursor))
- {
- attributes[attri] = cursorID;
- mask |= CWCursor;
- }
- else
- cursor = 0;
- }
- else
- {
- xfree (srcbits);
- xfree (mskbits);
- }
- }
-
- pWin = savedScreenInfo[i].pWindow =
- CreateWindow(savedScreenInfo[i].wid,
- WindowTable[i],
- -RANDOM_WIDTH, -RANDOM_WIDTH,
- (unsigned short)screenInfo.screens[i]->width + RANDOM_WIDTH,
- (unsigned short)screenInfo.screens[i]->height + RANDOM_WIDTH,
- 0, InputOutput, mask, attributes, 0, serverClient,
- wVisual (WindowTable[i]), &result);
-
- if (cursor)
- FreeResource (cursorID, RT_NONE);
-
- if (!pWin)
- return FALSE;
-
- if (!AddResource(pWin->drawable.id, RT_WINDOW,
- (pointer)savedScreenInfo[i].pWindow))
- return FALSE;
-
- if (mask & CWBackPixmap)
- {
- MakeRootTile (pWin);
- (*pWin->drawable.pScreen->ChangeWindowAttributes)(pWin, CWBackPixmap);
- }
- MapWindow(pWin, serverClient);
-#ifndef NOLOGOHACK
- if (kind == SCREEN_IS_TILED && logoScreenSaver)
- DrawLogo(pWin);
-#endif
- return TRUE;
-}
-
-/*
- * FindWindowWithOptional
- *
- * search ancestors of the given window for an entry containing
- * a WindowOpt structure. Assumptions: some parent will
- * contain the structure.
- */
-
-WindowPtr
-FindWindowWithOptional (w)
- register WindowPtr w;
-{
- do
- w = w->parent;
- while (!w->optional);
- return w;
-}
-
-/*
- * CheckWindowOptionalNeed
- *
- * check each optional entry in the given window to see if
- * the value is satisfied by the default rules. If so,
- * release the optional record
- */
-
-void
-CheckWindowOptionalNeed (w)
- register WindowPtr w;
-{
- register WindowOptPtr optional;
- register WindowOptPtr parentOptional;
-
- if (!w->parent)
- return;
- optional = w->optional;
- if (optional->dontPropagateMask != DontPropagateMasks[w->dontPropagate])
- return;
- if (optional->otherEventMasks != 0)
- return;
- if (optional->otherClients != NULL)
- return;
- if (optional->passiveGrabs != NULL)
- return;
- if (optional->userProps != NULL)
- return;
- if (optional->backingBitPlanes != ~0L)
- return;
- if (optional->backingPixel != 0)
- return;
-#ifdef SHAPE
- if (optional->boundingShape != NULL)
- return;
- if (optional->clipShape != NULL)
- return;
-#endif
-#ifdef XINPUT
- if (optional->inputMasks != NULL)
- return;
-#endif
- parentOptional = FindWindowWithOptional(w)->optional;
- if (optional->visual != parentOptional->visual)
- return;
- if (optional->cursor != None &&
- (optional->cursor != parentOptional->cursor ||
- w->parent->cursorIsNone))
- return;
- if (optional->colormap != parentOptional->colormap)
- return;
- DisposeWindowOptional (w);
-}
-
-/*
- * MakeWindowOptional
- *
- * create an optional record and initialize it with the default
- * values.
- */
-
-Bool
-MakeWindowOptional (pWin)
- register WindowPtr pWin;
-{
- register WindowOptPtr optional;
- register WindowOptPtr parentOptional;
-
- if (pWin->optional)
- return TRUE;
- optional = (WindowOptPtr) xalloc (sizeof (WindowOptRec));
- if (!optional)
- return FALSE;
- optional->dontPropagateMask = DontPropagateMasks[pWin->dontPropagate];
- optional->otherEventMasks = 0;
- optional->otherClients = NULL;
- optional->passiveGrabs = NULL;
- optional->userProps = NULL;
- optional->backingBitPlanes = ~0L;
- optional->backingPixel = 0;
-#ifdef SHAPE
- optional->boundingShape = NULL;
- optional->clipShape = NULL;
-#endif
-#ifdef XINPUT
- optional->inputMasks = NULL;
-#endif
- parentOptional = FindWindowWithOptional(pWin)->optional;
- optional->visual = parentOptional->visual;
- if (!pWin->cursorIsNone)
- {
- optional->cursor = parentOptional->cursor;
- optional->cursor->refcnt++;
- }
- else
- {
- optional->cursor = None;
- }
- optional->colormap = parentOptional->colormap;
- pWin->optional = optional;
- return TRUE;
-}
-
-void
-DisposeWindowOptional (pWin)
- register WindowPtr pWin;
-{
- if (!pWin->optional)
- return;
- /*
- * everything is peachy. Delete the optional record
- * and clean up
- */
- if (pWin->cursorIsNone == FALSE)
- FreeCursor (pWin->optional->cursor, (Cursor)0);
- pWin->cursorIsNone = TRUE;
- xfree (pWin->optional);
- pWin->optional = NULL;
-}
-
-#ifndef NOLOGOHACK
-static void
-DrawLogo(pWin)
- WindowPtr pWin;
-{
- DrawablePtr pDraw;
- ScreenPtr pScreen;
- int x, y;
- unsigned int width, height, size;
- GC *pGC;
- int thin, gap, d31;
- DDXPointRec poly[4];
- ChangeGCVal fore[2], back[2];
- xrgb rgb[2];
- BITS32 fmask, bmask;
- ColormapPtr cmap;
-
- pDraw = (DrawablePtr)pWin;
- pScreen = pDraw->pScreen;
- x = -pWin->origin.x;
- y = -pWin->origin.y;
- width = pScreen->width;
- height = pScreen->height;
- pGC = GetScratchGC(pScreen->rootDepth, pScreen);
- if (!pGC)
- return;
-
- if ((rand() % 100) <= 17) /* make the probability for white fairly low */
- fore[0].val = pScreen->whitePixel;
- else
- fore[0].val = pScreen->blackPixel;
- if ((pWin->backgroundState == BackgroundPixel) &&
- (cmap = (ColormapPtr)LookupIDByType(wColormap (pWin), RT_COLORMAP))) {
- Pixel querypixels[2];
-
- querypixels[0] = fore[0].val;
- querypixels[1] = pWin->background.pixel;
- QueryColors(cmap, 2, querypixels, rgb);
- if ((rgb[0].red == rgb[1].red) &&
- (rgb[0].green == rgb[1].green) &&
- (rgb[0].blue == rgb[1].blue)) {
- if (fore[0].val == pScreen->blackPixel)
- fore[0].val = pScreen->whitePixel;
- else
- fore[0].val = pScreen->blackPixel;
- }
- }
- fore[1].val = FillSolid;
- fmask = GCForeground|GCFillStyle;
- if (pWin->backgroundState == BackgroundPixel) {
- back[0].val = pWin->background.pixel;
- back[1].val = FillSolid;
- bmask = GCForeground|GCFillStyle;
- } else {
- back[0].val = 0;
- back[1].val = 0;
- dixChangeGC(NullClient, pGC, GCTileStipXOrigin|GCTileStipYOrigin,
- NULL, back);
- back[0].val = FillTiled;
- back[1].ptr = pWin->background.pixmap;
- bmask = GCFillStyle|GCTile;
- }
-
- /* should be the same as the reference function XmuDrawLogo() */
-
- size = width;
- if (height < width)
- size = height;
- size = RANDOM_WIDTH + rand() % (size - RANDOM_WIDTH);
- size &= ~1;
- x += rand() % (width - size);
- y += rand() % (height - size);
-
-/*
- * Draw what will be the thin strokes.
- *
- * -----
- * / /
- * / /
- * / /
- * / /
- * /____/
- * d
- *
- * Point d is 9/44 (~1/5) of the way across.
- */
-
- thin = (size / 11);
- if (thin < 1) thin = 1;
- gap = (thin+3) / 4;
- d31 = thin + thin + gap;
- poly[0].x = x + size; poly[0].y = y;
- poly[1].x = x + size-d31; poly[1].y = y;
- poly[2].x = x + 0; poly[2].y = y + size;
- poly[3].x = x + d31; poly[3].y = y + size;
- dixChangeGC(NullClient, pGC, fmask, NULL, fore);
- ValidateGC(pDraw, pGC);
- (*pGC->ops->FillPolygon)(pDraw, pGC, Convex, CoordModeOrigin, 4, poly);
-
-/*
- * Erase area not needed for lower thin stroke.
- *
- * ------
- * / /
- * / __ /
- * / / /
- * / / /
- * /__/__/
- */
-
- poly[0].x = x + d31/2; poly[0].y = y + size;
- poly[1].x = x + size / 2; poly[1].y = y + size/2;
- poly[2].x = x + (size/2)+(d31-(d31/2)); poly[2].y = y + size/2;
- poly[3].x = x + d31; poly[3].y = y + size;
- dixChangeGC(NullClient, pGC, bmask, NULL, back);
- ValidateGC(pDraw, pGC);
- (*pGC->ops->FillPolygon)(pDraw, pGC, Convex, CoordModeOrigin, 4, poly);
-
-/*
- * Erase area not needed for upper thin stroke.
- *
- * ------
- * / / /
- * /--/ /
- * / /
- * / /
- * /_____/
- */
-
- poly[0].x = x + size - d31/2; poly[0].y = y;
- poly[1].x = x + size / 2; poly[1].y = y + size/2;
- poly[2].x = x + (size/2)-(d31-(d31/2)); poly[2].y = y + size/2;
- poly[3].x = x + size - d31; poly[3].y = y;
- ValidateGC(pDraw, pGC);
- (*pGC->ops->FillPolygon)(pDraw, pGC, Convex, CoordModeOrigin, 4, poly);
-
-/*
- * Draw thick stroke.
- * Point b is 1/4 of the way across.
- *
- * b
- * -----
- * \ \
- * \ \
- * \ \
- * \ \
- * \____\
- */
-
- poly[0].x = x; poly[0].y = y;
- poly[1].x = x + size/4; poly[1].y = y;
- poly[2].x = x + size; poly[2].y = y + size;
- poly[3].x = x + size - size/4; poly[3].y = y + size;
- dixChangeGC(NullClient, pGC, fmask, NULL, fore);
- ValidateGC(pDraw, pGC);
- (*pGC->ops->FillPolygon)(pDraw, pGC, Convex, CoordModeOrigin, 4, poly);
-
-/*
- * Erase to create gap.
- *
- * /
- * /
- * /
- * /
- * /
- */
-
- poly[0].x = x + size- thin; poly[0].y = y;
- poly[1].x = x + size-( thin+gap); poly[1].y = y;
- poly[2].x = x + thin; poly[2].y = y + size;
- poly[3].x = x + thin + gap; poly[3].y = y + size;
- dixChangeGC(NullClient, pGC, bmask, NULL, back);
- ValidateGC(pDraw, pGC);
- (*pGC->ops->FillPolygon)(pDraw, pGC, Convex, CoordModeOrigin, 4, poly);
-
- FreeScratchGC(pGC);
-}
-
-#endif
diff --git a/programs/Xserver/panmi/Imakefile b/programs/Xserver/panmi/Imakefile
deleted file mode 100644
index f58c04a24..000000000
--- a/programs/Xserver/panmi/Imakefile
+++ /dev/null
@@ -1,117 +0,0 @@
-XCOMM $TOG: Imakefile /main/1 1997/10/29 13:27:41 kaleb $
-#include <Server.tmpl>
-
-#if ! HasCbrt
-CBRT_SRC = cbrt.c
-CBRT_OBJ = cbrt.o
-#endif
-
-SRCS = $(CBRT_SRC) mivaltree.c mipolyseg.c mipolyrect.c \
- mipoly.c mipolycon.c mipolygen.c mipolyutil.c \
- mifillrct.c miwideline.c mispans.c \
- miarc.c mizerarc.c mifillarc.c \
- miwindow.c micursor.c miregion.c \
- mipolytext.c mibitblt.c mipolypnt.c mipushpxl.c \
- miexpose.c miglblt.c mizerline.c mifpolycon.c \
- midash.c mibstore.c miinitext.c mieq.c \
- mipointer.c misprite.c midispcur.c miscrinit.c miclipn.c migc.c
-
-OBJS = $(CBRT_OBJ) mivaltree.o mipolyseg.o mipolyrect.o \
- mipoly.o mipolycon.o mipolygen.o mipolyutil.o \
- mifillrct.o miwideline.o mispans.o \
- miarc.o mizerarc.o mifillarc.o \
- miwindow.o micursor.o miregion.o \
- mipolytext.o mibitblt.o mipolypnt.o mipushpxl.o \
- miexpose.o miglblt.o mizerline.o mifpolycon.o \
- midash.o mibstore.o miinitext.o mieq.o \
- mipointer.o misprite.o midispcur.o miscrinit.o miclipn.o migc.o
-
-#ifdef XFree86Version
-/*
- * Make sure XINPUT, XF86VidTune isn't defined for the miinitext.o
- * used by Xnest, Xvfb
- */
-EXT_DEFINES = ExtensionDefines -UXINPUT -UXF86VIDMODE
-#else
-EXT_DEFINES = ExtensionDefines
-#endif
-
-INCLUDES = -I. -I../include -I../../../include/fonts \
- -I$(XINCLUDESRC) -I$(FONTINCSRC)
-LINTLIBS = ../dix/llib-ldix.ln ../os/llib-los.ln
-
-NormalLibraryObjectRule()
-NormalLibraryTarget(mi,$(OBJS))
-LintLibraryTarget(mi,$(SRCS))
-NormalLintTarget($(SRCS))
-
-#ifndef Win32Architecture
-NormalLibraryTarget(cbrt,cbrt.o)
-#endif
-
-SpecialCObjectRule(miinitext,$(ICONFIGFILES),$(EXT_DEFINES))
-SpecialCObjectRule(miscrinit,$(ICONFIGFILES),$(EXT_DEFINES))
-
-InstallLinkKitLibrary(mi,$(LINKKITDIR)/lib)
-InstallLinkKitLibrary(cbrt,$(LINKKITDIR)/lib)
-InstallLinkKitNonExecFile(mi.h,$(LINKKITDIR)/include)
-InstallLinkKitNonExecFile(mibstore.h,$(LINKKITDIR)/include)
-InstallLinkKitNonExecFile(miline.h,$(LINKKITDIR)/include)
-InstallLinkKitNonExecFile(mipointer.h,$(LINKKITDIR)/include)
-InstallLinkKitNonExecFile(misprite.h,$(LINKKITDIR)/include)
-InstallLinkKitNonExecFile(mispritest.h,$(LINKKITDIR)/include)
-InstallLinkKitNonExecFile(mistruct.h,$(LINKKITDIR)/include)
-InstallLinkKitNonExecFile(miinitext.c,$(LINKKITDIR)/include)
-
-LinkSourceFile(cbrt.c,../mi)
-LinkSourceFile(miarc.c,../mi)
-LinkSourceFile(mibitblt.c,../mi)
-LinkSourceFile(mibstorest.h,../mi)
-LinkSourceFile(mibstore.c,../mi)
-LinkSourceFile(mibstore.h,../mi)
-LinkSourceFile(miclipn.c,../mi)
-LinkSourceFile(micursor.c,../mi)
-LinkSourceFile(midash.c,../mi)
-LinkSourceFile(midispcur.c,../mi)
-LinkSourceFile(mieq.c,../mi)
-LinkSourceFile(mifillarc.c,../mi)
-LinkSourceFile(mifillarc.h,../mi)
-LinkSourceFile(mifillrct.c,../mi)
-LinkSourceFile(mifpolycon.c,../mi)
-LinkSourceFile(mifpoly.h,../mi)
-LinkSourceFile(migc.c,../mi)
-LinkSourceFile(migc.h,../mi)
-LinkSourceFile(miglblt.c,../mi)
-LinkSourceFile(miinitext.c,../mi)
-LinkSourceFile(miline.h,../mi)
-LinkSourceFile(mipointer.c,../mi)
-LinkSourceFile(mipointer.h,../mi)
-LinkSourceFile(mipointrst.h,../mi)
-LinkSourceFile(mipolycon.c,../mi)
-LinkSourceFile(mipolygen.c,../mi)
-LinkSourceFile(mipolypnt.c,../mi)
-LinkSourceFile(mipolyrect.c,../mi)
-LinkSourceFile(mipolyseg.c,../mi)
-LinkSourceFile(mipolytext.c,../mi)
-LinkSourceFile(mipolyutil.c,../mi)
-LinkSourceFile(mipoly.c,../mi)
-LinkSourceFile(mipoly.h,../mi)
-LinkSourceFile(mipushpxl.c,../mi)
-LinkSourceFile(miscanfill.h,../mi)
-LinkSourceFile(miscrinit.c,../mi)
-LinkSourceFile(mispans.c,../mi)
-LinkSourceFile(mispans.h,../mi)
-LinkSourceFile(mispritest.h,../mi)
-LinkSourceFile(misprite.c,../mi)
-LinkSourceFile(misprite.h,../mi)
-LinkSourceFile(mistruct.h,../mi)
-LinkSourceFile(mivalidate.h,../mi)
-LinkSourceFile(miwideline.c,../mi)
-LinkSourceFile(miwideline.h,../mi)
-LinkSourceFile(miwindow.c,../mi)
-LinkSourceFile(mizerarc.c,../mi)
-LinkSourceFile(mizerarc.h,../mi)
-LinkSourceFile(mizerline.c,../mi)
-LinkSourceFile(mi.h,../mi)
-
-DependTarget()
diff --git a/programs/Xserver/panmi/miexpose.c b/programs/Xserver/panmi/miexpose.c
deleted file mode 100644
index 74e9fecf6..000000000
--- a/programs/Xserver/panmi/miexpose.c
+++ /dev/null
@@ -1,902 +0,0 @@
-/****************************************************************
-* *
-* Copyright (c) Digital Equipment Corporation, 1991, 1997 *
-* *
-* All Rights Reserved. Unpublished rights reserved under *
-* the copyright laws of the United States. *
-* *
-* The software contained on this media is proprietary to *
-* and embodies the confidential technology of Digital *
-* Equipment Corporation. Possession, use, duplication or *
-* dissemination of the software and media is authorized only *
-* pursuant to a valid written license from Digital Equipment *
-* Corporation. *
-* *
-* RESTRICTED RIGHTS LEGEND Use, duplication, or disclosure *
-* by the U.S. Government is subject to restrictions as set *
-* forth in Subparagraph (c)(1)(ii) of DFARS 252.227-7013, *
-* or in FAR 52.227-19, as applicable. *
-* *
-*****************************************************************/
-/***********************************************************
-
-Copyright (c) 1987 X Consortium
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-X CONSORTIUM 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 X Consortium 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 X Consortium.
-
-
-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.
-
-******************************************************************/
-
-/* $TOG: miexpose.c /main/1 1997/10/29 13:27:45 kaleb $ */
-
-#include "X.h"
-#define NEED_EVENTS
-#include "Xproto.h"
-#include "Xprotostr.h"
-
-#include "misc.h"
-#include "regionstr.h"
-#include "scrnintstr.h"
-#include "gcstruct.h"
-#include "windowstr.h"
-#include "pixmap.h"
-#include "input.h"
-
-#include "dixstruct.h"
-#include "mi.h"
-#include "Xmd.h"
-
-extern WindowPtr *WindowTable;
-
-#ifdef PANORAMIX
-#include "extensions/panoramiX.h"
-#endif
-
-#ifdef PANORAMIX
-extern Bool noPanoramiXExtension;
-extern Bool PanoramiXMapped;
-#endif
-
-/*
- machine-independent graphics exposure code. any device that uses
-the region package can call this.
-*/
-
-#ifndef RECTLIMIT
-#define RECTLIMIT 25 /* pick a number, any number > 8 */
-#endif
-
-/* miHandleExposures
- generate a region for exposures for areas that were copied from obscured or
-non-existent areas to non-obscured areas of the destination. Paint the
-background for the region, if the destination is a window.
-
-NOTE:
- this should generally be called, even if graphicsExposures is false,
-because this is where bits get recovered from backing store.
-
-NOTE:
- added argument 'plane' is used to indicate how exposures from backing
-store should be accomplished. If plane is 0 (i.e. no bit plane), CopyArea
-should be used, else a CopyPlane of the indicated plane will be used. The
-exposing is done by the backing store's GraphicsExpose function, of course.
-
-*/
-
-RegionPtr
-miHandleExposures(pSrcDrawable, pDstDrawable,
- pGC, srcx, srcy, width, height, dstx, dsty, plane)
- register DrawablePtr pSrcDrawable;
- register DrawablePtr pDstDrawable;
- GCPtr pGC;
- int srcx, srcy;
- int width, height;
- int dstx, dsty;
- unsigned long plane;
-{
- register ScreenPtr pscr = pGC->pScreen;
- RegionPtr prgnSrcClip; /* drawable-relative source clip */
- RegionRec rgnSrcRec;
- RegionPtr prgnDstClip; /* drawable-relative dest clip */
- RegionRec rgnDstRec;
- BoxRec srcBox; /* unclipped source */
- RegionRec rgnExposed; /* exposed region, calculated source-
- relative, made dst relative to
- intersect with visible parts of
- dest and send events to client,
- and then screen relative to paint
- the window background
- */
- WindowPtr pSrcWin;
- BoxRec expBox;
- Bool extents;
-
- /* avoid work if we can */
- if (!pGC->graphicsExposures &&
- (pDstDrawable->type == DRAWABLE_PIXMAP) &&
- ((pSrcDrawable->type == DRAWABLE_PIXMAP) ||
- (((WindowPtr)pSrcDrawable)->backStorage == NULL)))
- return NULL;
-
- srcBox.x1 = srcx;
- srcBox.y1 = srcy;
- srcBox.x2 = srcx+width;
- srcBox.y2 = srcy+height;
-
- if (pSrcDrawable->type != DRAWABLE_PIXMAP)
- {
- BoxRec TsrcBox;
-
- TsrcBox.x1 = srcx + pSrcDrawable->x;
- TsrcBox.y1 = srcy + pSrcDrawable->y;
- TsrcBox.x2 = TsrcBox.x1 + width;
- TsrcBox.y2 = TsrcBox.y1 + height;
- pSrcWin = (WindowPtr) pSrcDrawable;
- if (pGC->subWindowMode == IncludeInferiors)
- {
- prgnSrcClip = NotClippedByChildren (pSrcWin);
- if ((RECT_IN_REGION(pscr, prgnSrcClip, &TsrcBox)) == rgnIN)
- {
- REGION_DESTROY(pscr, prgnSrcClip);
- return NULL;
- }
- }
- else
- {
- if ((RECT_IN_REGION(pscr, &pSrcWin->clipList, &TsrcBox)) == rgnIN)
- return NULL;
- prgnSrcClip = &rgnSrcRec;
- REGION_INIT(pscr, prgnSrcClip, NullBox, 0);
- REGION_COPY(pscr, prgnSrcClip, &pSrcWin->clipList);
- }
- REGION_TRANSLATE(pscr, prgnSrcClip,
- -pSrcDrawable->x, -pSrcDrawable->y);
- }
- else
- {
- BoxRec box;
-
- if ((srcBox.x1 >= 0) && (srcBox.y1 >= 0) &&
- (srcBox.x2 <= pSrcDrawable->width) &&
- (srcBox.y2 <= pSrcDrawable->height))
- return NULL;
-
- box.x1 = 0;
- box.y1 = 0;
- box.x2 = pSrcDrawable->width;
- box.y2 = pSrcDrawable->height;
- prgnSrcClip = &rgnSrcRec;
- REGION_INIT(pscr, prgnSrcClip, &box, 1);
- pSrcWin = (WindowPtr)NULL;
- }
-
- if (pDstDrawable == pSrcDrawable)
- {
- prgnDstClip = prgnSrcClip;
- }
- else if (pDstDrawable->type != DRAWABLE_PIXMAP)
- {
- if (pGC->subWindowMode == IncludeInferiors)
- {
- prgnDstClip = NotClippedByChildren((WindowPtr)pDstDrawable);
- }
- else
- {
- prgnDstClip = &rgnDstRec;
- REGION_INIT(pscr, prgnDstClip, NullBox, 0);
- REGION_COPY(pscr, prgnDstClip,
- &((WindowPtr)pDstDrawable)->clipList);
- }
- REGION_TRANSLATE(pscr, prgnDstClip,
- -pDstDrawable->x, -pDstDrawable->y);
- }
- else
- {
- BoxRec box;
-
- box.x1 = 0;
- box.y1 = 0;
- box.x2 = pDstDrawable->width;
- box.y2 = pDstDrawable->height;
- prgnDstClip = &rgnDstRec;
- REGION_INIT(pscr, prgnDstClip, &box, 1);
- }
-
- /* drawable-relative source region */
- REGION_INIT(pscr, &rgnExposed, &srcBox, 1);
-
- /* now get the hidden parts of the source box*/
- REGION_SUBTRACT(pscr, &rgnExposed, &rgnExposed, prgnSrcClip);
-
- if (pSrcWin && pSrcWin->backStorage)
- {
- /*
- * Copy any areas from the source backing store. Modifies
- * rgnExposed.
- */
- (* pSrcWin->drawable.pScreen->ExposeCopy) ((WindowPtr)pSrcDrawable,
- pDstDrawable,
- pGC,
- &rgnExposed,
- srcx, srcy,
- dstx, dsty,
- plane);
- }
-
- /* move them over the destination */
- REGION_TRANSLATE(pscr, &rgnExposed, dstx-srcx, dsty-srcy);
-
- /* intersect with visible areas of dest */
- REGION_INTERSECT(pscr, &rgnExposed, &rgnExposed, prgnDstClip);
-
- /*
- * If we have LOTS of rectangles, we decide to take the extents
- * and force an exposure on that. This should require much less
- * work overall, on both client and server. This is cheating, but
- * isn't prohibited by the protocol ("spontaneous combustion" :-)
- * for windows.
- */
- extents = pGC->graphicsExposures &&
- (REGION_NUM_RECTS(&rgnExposed) > RECTLIMIT) &&
- (pDstDrawable->type != DRAWABLE_PIXMAP);
-#ifdef SHAPE
- if (pSrcWin)
- {
- RegionPtr region;
- if (!(region = wClipShape (pSrcWin)))
- region = wBoundingShape (pSrcWin);
- /*
- * If you try to CopyArea the extents of a shaped window, compacting the
- * exposed region will undo all our work!
- */
- if (extents && pSrcWin && region &&
- (RECT_IN_REGION(pscr, region, &srcBox) != rgnIN))
- extents = FALSE;
- }
-#endif
- if (extents)
- {
- WindowPtr pWin = (WindowPtr)pDstDrawable;
-
- expBox = *REGION_EXTENTS(pscr, &rgnExposed);
- REGION_RESET(pscr, &rgnExposed, &expBox);
- /* need to clear out new areas of backing store */
- if (pWin->backStorage)
- (void) (* pWin->drawable.pScreen->ClearBackingStore)(
- pWin,
- expBox.x1,
- expBox.y1,
- expBox.x2 - expBox.x1,
- expBox.y2 - expBox.y1,
- FALSE);
- }
- if ((pDstDrawable->type != DRAWABLE_PIXMAP) &&
- (((WindowPtr)pDstDrawable)->backgroundState != None))
- {
- WindowPtr pWin = (WindowPtr)pDstDrawable;
-
- /* make the exposed area screen-relative */
- REGION_TRANSLATE(pscr, &rgnExposed,
- pDstDrawable->x, pDstDrawable->y);
-
- if (extents)
- {
- /* PaintWindowBackground doesn't clip, so we have to */
- REGION_INTERSECT(pscr, &rgnExposed, &rgnExposed, &pWin->clipList);
- }
- (*pWin->drawable.pScreen->PaintWindowBackground)(
- (WindowPtr)pDstDrawable, &rgnExposed, PW_BACKGROUND);
-
- if (extents)
- {
- REGION_RESET(pscr, &rgnExposed, &expBox);
- }
- else
- REGION_TRANSLATE(pscr, &rgnExposed,
- -pDstDrawable->x, -pDstDrawable->y);
- }
- if (prgnDstClip == &rgnDstRec)
- {
- REGION_UNINIT(pscr, prgnDstClip);
- }
- else if (prgnDstClip != prgnSrcClip)
- {
- REGION_DESTROY(pscr, prgnDstClip);
- }
-
- if (prgnSrcClip == &rgnSrcRec)
- {
- REGION_UNINIT(pscr, prgnSrcClip);
- }
- else
- {
- REGION_DESTROY(pscr, prgnSrcClip);
- }
-
- if (pGC->graphicsExposures)
- {
- /* don't look */
- RegionPtr exposed = REGION_CREATE(pscr, NullBox, 0);
- *exposed = rgnExposed;
- return exposed;
- }
- else
- {
- REGION_UNINIT(pscr, &rgnExposed);
- return NULL;
- }
-}
-
-/* send GraphicsExpose events, or a NoExpose event, based on the region */
-
-void
-miSendGraphicsExpose (client, pRgn, drawable, major, minor)
- ClientPtr client;
- RegionPtr pRgn;
- XID drawable;
- int major;
- int minor;
-{
- if (pRgn && !REGION_NIL(pRgn))
- {
- xEvent *pEvent;
- register xEvent *pe;
- register BoxPtr pBox;
- register int i;
- int numRects;
-
- numRects = REGION_NUM_RECTS(pRgn);
- pBox = REGION_RECTS(pRgn);
- if(!(pEvent = (xEvent *)ALLOCATE_LOCAL(numRects * sizeof(xEvent))))
- return;
- pe = pEvent;
-
- for (i=1; i<=numRects; i++, pe++, pBox++)
- {
- pe->u.u.type = GraphicsExpose;
- pe->u.graphicsExposure.drawable = drawable;
- pe->u.graphicsExposure.x = pBox->x1;
- pe->u.graphicsExposure.y = pBox->y1;
- pe->u.graphicsExposure.width = pBox->x2 - pBox->x1;
- pe->u.graphicsExposure.height = pBox->y2 - pBox->y1;
- pe->u.graphicsExposure.count = numRects - i;
- pe->u.graphicsExposure.majorEvent = major;
- pe->u.graphicsExposure.minorEvent = minor;
- }
- TryClientEvents(client, pEvent, numRects,
- (Mask)0, NoEventMask, NullGrab);
- DEALLOCATE_LOCAL(pEvent);
- }
- else
- {
- xEvent event;
- event.u.u.type = NoExpose;
- event.u.noExposure.drawable = drawable;
- event.u.noExposure.majorEvent = major;
- event.u.noExposure.minorEvent = minor;
- TryClientEvents(client, &event, 1,
- (Mask)0, NoEventMask, NullGrab);
- }
-}
-#ifdef PANORAMIX
-Bool
-PanoramiXBoxOffScreen(pWin, pBox)
- register WindowPtr pWin;
- RegionPtr pBox;
-{
- register ScreenPtr pScreen = pWin->drawable.pScreen;
- BoxRec box;
-
- box = *(REGION_EXTENTS(pScreen, &pWin->winSize));
-
- if ((pBox->extents.x2 < box.x1) && (pBox->extents.x1 < box.x1))
- return TRUE;
- if ((pBox->extents.x1 > box.x2) && (pBox->extents.x2 > box.x2))
- return TRUE;
- if ((pBox->extents.y2 < box.y1) && (pBox->extents.y1 < box.y1))
- return TRUE;
- if ((pBox->extents.y1 > box.y2) && (pBox->extents.y2 > box.y2))
- return TRUE;
-
- return FALSE;
-}
-#endif
-
-void
-miSendExposures(pWin, pRgn, dx, dy)
- WindowPtr pWin;
- RegionPtr pRgn;
- register int dx, dy;
-{
- register BoxPtr pBox;
- int numRects;
- register xEvent *pEvent, *pe;
- register int i;
-
- pBox = REGION_RECTS(pRgn);
- numRects = REGION_NUM_RECTS(pRgn);
- if(!(pEvent = (xEvent *) ALLOCATE_LOCAL(numRects * sizeof(xEvent))))
- return;
-
- for (i=numRects, pe = pEvent; --i >= 0; pe++, pBox++)
- {
- pe->u.u.type = Expose;
- pe->u.expose.window = pWin->drawable.id;
- pe->u.expose.x = pBox->x1 - dx;
- pe->u.expose.y = pBox->y1 - dy;
- pe->u.expose.width = pBox->x2 - pBox->x1;
- pe->u.expose.height = pBox->y2 - pBox->y1;
- pe->u.expose.count = i;
- }
-#ifdef PANORAMIX
- /* In the case where a window is split between one
- or more screen, an expose event will be written
- to the client describing the section of the window
- which is exposed per screen. This causes a failure
- in the vsw test CH07/grbbtn because the test is
- poorly written and expects 1 expose event and fails
- when it reads more than 1 expose event when the
- window is split. The server is in fact doing the
- expected and correct behavior. -mad 08/29/96
- */
- if (!noPanoramiXExtension){
- if (PanoramiXMapped){
- if (!PanoramiXBoxOffScreen(pWin,pRgn))
- DeliverEvents(pWin, pEvent, numRects, NullWindow);
- }else
- DeliverEvents(pWin, pEvent, numRects, NullWindow);
- } else
- DeliverEvents(pWin, pEvent, numRects, NullWindow);
-#else
- DeliverEvents(pWin, pEvent, numRects, NullWindow);
-#endif
-
- DEALLOCATE_LOCAL(pEvent);
-}
-
-void
-miWindowExposures(pWin, prgn, other_exposed)
- WindowPtr pWin;
- register RegionPtr prgn, other_exposed;
-{
- RegionPtr exposures = prgn;
- if (pWin->backStorage && prgn)
- /*
- * in some cases, backing store will cause a different
- * region to be exposed than needs to be repainted
- * (like when a window is mapped). RestoreAreas is
- * allowed to return a region other than prgn,
- * in which case this routine will free the resultant
- * region. If exposures is null, then no events will
- * be sent to the client; if prgn is empty
- * no areas will be repainted.
- */
- exposures = (*pWin->drawable.pScreen->RestoreAreas)(pWin, prgn);
- if ((prgn && !REGION_NIL(prgn)) ||
- (exposures && !REGION_NIL(exposures)) || other_exposed)
- {
- RegionRec expRec;
- int clientInterested;
-
- /*
- * Restore from backing-store FIRST.
- */
- clientInterested = (pWin->eventMask|wOtherEventMasks(pWin)) & ExposureMask;
- if (other_exposed)
- {
- if (exposures)
- {
- REGION_UNION(pWin->drawable.pScreen, other_exposed,
- exposures,
- other_exposed);
- if (exposures != prgn)
- REGION_DESTROY(pWin->drawable.pScreen, exposures);
- }
- exposures = other_exposed;
- }
- if (clientInterested && exposures && (REGION_NUM_RECTS(exposures) > RECTLIMIT))
- {
- /*
- * If we have LOTS of rectangles, we decide to take the extents
- * and force an exposure on that. This should require much less
- * work overall, on both client and server. This is cheating, but
- * isn't prohibited by the protocol ("spontaneous combustion" :-).
- */
- BoxRec box;
-
- box = *REGION_EXTENTS( pWin->drawable.pScreen, exposures);
- if (exposures == prgn) {
- exposures = &expRec;
- REGION_INIT( pWin->drawable.pScreen, exposures, &box, 1);
- REGION_RESET( pWin->drawable.pScreen, prgn, &box);
- } else {
- REGION_RESET( pWin->drawable.pScreen, exposures, &box);
- REGION_UNION( pWin->drawable.pScreen, prgn, prgn, exposures);
- }
- /* PaintWindowBackground doesn't clip, so we have to */
- REGION_INTERSECT( pWin->drawable.pScreen, prgn, prgn, &pWin->clipList);
- /* need to clear out new areas of backing store, too */
- if (pWin->backStorage)
- (void) (* pWin->drawable.pScreen->ClearBackingStore)(
- pWin,
- box.x1 - pWin->drawable.x,
- box.y1 - pWin->drawable.y,
- box.x2 - box.x1,
- box.y2 - box.y1,
- FALSE);
- }
- if (prgn && !REGION_NIL(prgn))
- (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, prgn, PW_BACKGROUND);
- if (clientInterested && exposures && !REGION_NIL(exposures))
- miSendExposures(pWin, exposures,
- pWin->drawable.x, pWin->drawable.y);
- if (exposures == &expRec)
- {
- REGION_UNINIT( pWin->drawable.pScreen, exposures);
- }
- else if (exposures && exposures != prgn && exposures != other_exposed)
- REGION_DESTROY( pWin->drawable.pScreen, exposures);
- if (prgn)
- REGION_EMPTY( pWin->drawable.pScreen, prgn);
- }
- else if (exposures && exposures != prgn)
- REGION_DESTROY( pWin->drawable.pScreen, exposures);
-}
-
-
-/*
- this code is highly unlikely. it is not haile selassie.
-
- there is some hair here. we can't just use the window's
-clip region as it is, because if we are painting the border,
-the border is not in the client area and so we will be excluded
-when we validate the GC, and if we are painting a parent-relative
-background, the area we want to paint is in some other window.
-since we trust the code calling us to tell us to paint only areas
-that are really ours, we will temporarily give the window a
-clipList the size of the whole screen and an origin at (0,0).
-this more or less assumes that ddX code will do translation
-based on the window's absolute position, and that ValidateGC will
-look at clipList, and that no other fields from the
-window will be used. it's not possible to just draw
-in the root because it may be a different depth.
-
-to get the tile to align correctly we set the GC's tile origin to
-be the (x,y) of the window's upper left corner, after which we
-get the right bits when drawing into the root.
-
-because the clip_mask is being set to None, we may call DoChangeGC with
-fPointer set true, thus we no longer need to install the background or
-border tile in the resource table.
-*/
-
-static RESTYPE ResType = 0;
-static int numGCs = 0;
-static GCPtr screenContext[MAXSCREENS];
-
-/*ARGSUSED*/
-static int
-tossGC (value, id)
-pointer value;
-XID id;
-{
- GCPtr pGC = (GCPtr)value;
- screenContext[pGC->pScreen->myNum] = (GCPtr)NULL;
- FreeGC (pGC, id);
- numGCs--;
- if (!numGCs)
- ResType = 0;
-}
-
-
-void
-miPaintWindow(pWin, prgn, what)
-register WindowPtr pWin;
-RegionPtr prgn;
-int what;
-{
- int status;
-
- Bool usingScratchGC = FALSE;
- WindowPtr pRoot;
-
-#define FUNCTION 0
-#define FOREGROUND 1
-#define TILE 2
-#define FILLSTYLE 3
-#define ABSX 4
-#define ABSY 5
-#define CLIPMASK 6
-#define SUBWINDOW 7
-#define COUNT_BITS 8
-
- ChangeGCVal gcval[7];
- ChangeGCVal newValues [COUNT_BITS];
-
- BITS32 gcmask, index, mask;
- RegionRec prgnWin;
- DDXPointRec oldCorner;
- BoxRec box;
- WindowPtr pBgWin;
- GCPtr pGC;
- register int i;
- register BoxPtr pbox;
- register ScreenPtr pScreen = pWin->drawable.pScreen;
- register xRectangle *prect;
- int numRects;
-
- gcmask = 0;
-
- if (what == PW_BACKGROUND)
- {
- switch (pWin->backgroundState) {
- case None:
- return;
- case ParentRelative:
- (*pWin->parent->drawable.pScreen->PaintWindowBackground)(pWin->parent, prgn, what);
- return;
- case BackgroundPixel:
- newValues[FOREGROUND].val = pWin->background.pixel;
- newValues[FILLSTYLE].val = FillSolid;
- gcmask |= GCForeground | GCFillStyle;
- break;
- case BackgroundPixmap:
- newValues[TILE].ptr = (pointer)pWin->background.pixmap;
- newValues[FILLSTYLE].val = FillTiled;
- gcmask |= GCTile | GCFillStyle | GCTileStipXOrigin | GCTileStipYOrigin;
- break;
- }
- }
- else
- {
- if (pWin->borderIsPixel)
- {
- newValues[FOREGROUND].val = pWin->border.pixel;
- newValues[FILLSTYLE].val = FillSolid;
- gcmask |= GCForeground | GCFillStyle;
- }
- else
- {
- newValues[TILE].ptr = (pointer)pWin->border.pixmap;
- newValues[FILLSTYLE].val = FillTiled;
- gcmask |= GCTile | GCFillStyle | GCTileStipXOrigin | GCTileStipYOrigin;
- }
- }
-
- prect = (xRectangle *)ALLOCATE_LOCAL(REGION_NUM_RECTS(prgn) *
- sizeof(xRectangle));
- if (!prect)
- return;
-
- newValues[FUNCTION].val = GXcopy;
- gcmask |= GCFunction | GCClipMask;
-
- i = pScreen->myNum;
- pRoot = WindowTable[i];
-
- pBgWin = pWin;
- if (what == PW_BORDER)
- {
- while (pBgWin->backgroundState == ParentRelative)
- pBgWin = pBgWin->parent;
- }
-
- if ((pWin->drawable.depth != pRoot->drawable.depth) ||
- (pWin->drawable.bitsPerPixel != pRoot->drawable.bitsPerPixel))
- {
- usingScratchGC = TRUE;
- pGC = GetScratchGC(pWin->drawable.depth, pWin->drawable.pScreen);
- if (!pGC)
- {
- DEALLOCATE_LOCAL(prect);
- return;
- }
- /*
- * mash the clip list so we can paint the border by
- * mangling the window in place, pretending it
- * spans the entire screen
- */
- if (what == PW_BORDER)
- {
- prgnWin = pWin->clipList;
- oldCorner.x = pWin->drawable.x;
- oldCorner.y = pWin->drawable.y;
- pWin->drawable.x = pWin->drawable.y = 0;
- box.x1 = 0;
- box.y1 = 0;
- box.x2 = pScreen->width;
- box.y2 = pScreen->height;
- REGION_INIT(pScreen, &pWin->clipList, &box, 1);
- pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER;
- newValues[ABSX].val = pBgWin->drawable.x;
- newValues[ABSY].val = pBgWin->drawable.y;
- }
- else
- {
- newValues[ABSX].val = 0;
- newValues[ABSY].val = 0;
- }
- } else {
- /*
- * draw the background to the root window
- */
- if (screenContext[i] == (GCPtr)NULL)
- {
- if (!ResType && !(ResType = CreateNewResourceType(tossGC)))
- return;
- screenContext[i] = CreateGC((DrawablePtr)pWin, (BITS32) 0,
- (XID *)NULL, &status);
- if (!screenContext[i])
- return;
- numGCs++;
- if (!AddResource(FakeClientID(0), ResType,
- (pointer)screenContext[i]))
- return;
- }
- pGC = screenContext[i];
- newValues[SUBWINDOW].val = IncludeInferiors;
- newValues[ABSX].val = pBgWin->drawable.x;
- newValues[ABSY].val = pBgWin->drawable.y;
- gcmask |= GCSubwindowMode;
- pWin = pRoot;
- }
-
- if (pWin->backStorage)
- (*pWin->drawable.pScreen->DrawGuarantee) (pWin, pGC, GuaranteeVisBack);
-
- mask = gcmask;
- gcmask = 0;
- i = 0;
- while (mask) {
- index = lowbit (mask);
- mask &= ~index;
- switch (index) {
- case GCFunction:
- if (pGC->alu != newValues[FUNCTION].val) {
- gcmask |= index;
- gcval[i++].val = newValues[FUNCTION].val;
- }
- break;
- case GCTileStipXOrigin:
- if ( pGC->patOrg.x != newValues[ABSX].val) {
- gcmask |= index;
- gcval[i++].val = newValues[ABSX].val;
- }
- break;
- case GCTileStipYOrigin:
- if ( pGC->patOrg.y != newValues[ABSY].val) {
- gcmask |= index;
- gcval[i++].val = newValues[ABSY].val;
- }
- break;
- case GCClipMask:
- if ( pGC->clientClipType != CT_NONE) {
- gcmask |= index;
- gcval[i++].val = CT_NONE;
- }
- break;
- case GCSubwindowMode:
- if ( pGC->subWindowMode != newValues[SUBWINDOW].val) {
- gcmask |= index;
- gcval[i++].val = newValues[SUBWINDOW].val;
- }
- break;
- case GCTile:
- if (pGC->tileIsPixel || pGC->tile.pixmap != newValues[TILE].ptr)
- {
- gcmask |= index;
- gcval[i++].ptr = newValues[TILE].ptr;
- }
- break;
- case GCFillStyle:
- if ( pGC->fillStyle != newValues[FILLSTYLE].val) {
- gcmask |= index;
- gcval[i++].val = newValues[FILLSTYLE].val;
- }
- break;
- case GCForeground:
- if ( pGC->fgPixel != newValues[FOREGROUND].val) {
- gcmask |= index;
- gcval[i++].val = newValues[FOREGROUND].val;
- }
- break;
- }
- }
-
- if (gcmask)
- dixChangeGC(NullClient, pGC, gcmask, NULL, gcval);
-
- if (pWin->drawable.serialNumber != pGC->serialNumber)
- ValidateGC((DrawablePtr)pWin, pGC);
-
- numRects = REGION_NUM_RECTS(prgn);
- pbox = REGION_RECTS(prgn);
- for (i= numRects; --i >= 0; pbox++, prect++)
- {
- prect->x = pbox->x1 - pWin->drawable.x;
- prect->y = pbox->y1 - pWin->drawable.y;
- prect->width = pbox->x2 - pbox->x1;
- prect->height = pbox->y2 - pbox->y1;
- }
- prect -= numRects;
- (*pGC->ops->PolyFillRect)((DrawablePtr)pWin, pGC, numRects, prect);
- DEALLOCATE_LOCAL(prect);
-
- if (pWin->backStorage)
- (*pWin->drawable.pScreen->DrawGuarantee) (pWin, pGC, GuaranteeNothing);
-
- if (usingScratchGC)
- {
- if (what == PW_BORDER)
- {
- REGION_UNINIT(pScreen, &pWin->clipList);
- pWin->clipList = prgnWin;
- pWin->drawable.x = oldCorner.x;
- pWin->drawable.y = oldCorner.y;
- pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER;
- }
- FreeScratchGC(pGC);
- }
-}
-
-
-/* MICLEARDRAWABLE -- sets the entire drawable to the background color of
- * the GC. Useful when we have a scratch drawable and need to initialize
- * it. */
-miClearDrawable(pDraw, pGC)
- DrawablePtr pDraw;
- GCPtr pGC;
-{
- XID fg = pGC->fgPixel;
- XID bg = pGC->bgPixel;
- xRectangle rect;
-
- rect.x = 0;
- rect.y = 0;
- rect.width = pDraw->width;
- rect.height = pDraw->height;
- DoChangeGC(pGC, GCForeground, &bg, 0);
- ValidateGC(pDraw, pGC);
- (*pGC->ops->PolyFillRect)(pDraw, pGC, 1, &rect);
- DoChangeGC(pGC, GCForeground, &fg, 0);
- ValidateGC(pDraw, pGC);
-}
diff --git a/programs/Xserver/panmi/miregion.c b/programs/Xserver/panmi/miregion.c
deleted file mode 100644
index f609cfd91..000000000
--- a/programs/Xserver/panmi/miregion.c
+++ /dev/null
@@ -1,2449 +0,0 @@
-/***********************************************************
-
-Copyright (c) 1987, 1988, 1989 X Consortium
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-X CONSORTIUM 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 X Consortium 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 X Consortium.
-
-
-Copyright 1987, 1988, 1989 by
-Digital Equipment Corporation, Maynard, Massachusetts.
-
- All Rights Reserved
-
-Permission to use, copy, modify, and distribute this software and its
-documentation for any purpose and without fee is hereby granted,
-provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in
-supporting documentation, and that the name of Digital not be
-used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.
-
-DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
-ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-SOFTWARE.
-
-******************************************************************/
-/* $TOG: miregion.c /main/1 1997/10/29 13:27:50 kaleb $ */
-
-#include <stdio.h>
-#include "miscstruct.h"
-#include "regionstr.h"
-#include "Xprotostr.h"
-#include "gc.h"
-
-#if defined (__GNUC__) && !defined (NO_INLINES)
-#define INLINE __inline
-#else
-#define INLINE
-#endif
-
-/*
- * hack until callers of these functions can deal with out-of-memory
- */
-
-extern Bool Must_have_memory;
-
-#ifdef DEBUG
-#define assert(expr) {if (!(expr)) \
- FatalError("Assertion failed file %s, line %d: expr\n", \
- __FILE__, __LINE__); }
-#else
-#define assert(expr)
-#endif
-
-#define good(reg) assert(miValidRegion(reg))
-
-/*
- * The functions in this file implement the Region abstraction used extensively
- * throughout the X11 sample server. A Region is simply a set of disjoint
- * (non-overlapping) rectangles, plus an "extent" rectangle which is the
- * smallest single rectangle that contains all the non-overlapping rectangles.
- *
- * A Region is implemented as a "y-x-banded" array of rectangles. This array
- * imposes two degrees of order. First, all rectangles are sorted by top side
- * y coordinate first (y1), and then by left side x coordinate (x1).
- *
- * Furthermore, the rectangles are grouped into "bands". Each rectangle in a
- * band has the same top y coordinate (y1), and each has the same bottom y
- * coordinate (y2). Thus all rectangles in a band differ only in their left
- * and right side (x1 and x2). Bands are implicit in the array of rectangles:
- * there is no separate list of band start pointers.
- *
- * The y-x band representation does not minimize rectangles. In particular,
- * if a rectangle vertically crosses a band (the rectangle has scanlines in
- * the y1 to y2 area spanned by the band), then the rectangle may be broken
- * down into two or more smaller rectangles stacked one atop the other.
- *
- * ----------- -----------
- * | | | | band 0
- * | | -------- ----------- --------
- * | | | | in y-x banded | | | | band 1
- * | | | | form is | | | |
- * ----------- | | ----------- --------
- * | | | | band 2
- * -------- --------
- *
- * An added constraint on the rectangles is that they must cover as much
- * horizontal area as possible: no two rectangles within a band are allowed
- * to touch.
- *
- * Whenever possible, bands will be merged together to cover a greater vertical
- * distance (and thus reduce the number of rectangles). Two bands can be merged
- * only if the bottom of one touches the top of the other and they have
- * rectangles in the same places (of the same width, of course).
- *
- * Adam de Boor wrote most of the original region code. Joel McCormack
- * substantially modified or rewrote most of the core arithmetic routines,
- * and added miRegionValidate in order to support several speed improvements
- * to miValidateTree. Bob Scheifler changed the representation to be more
- * compact when empty or a single rectangle, and did a bunch of gratuitous
- * reformatting.
- */
-
-/* true iff two Boxes overlap */
-#define EXTENTCHECK(r1,r2) \
- (!( ((r1)->x2 <= (r2)->x1) || \
- ((r1)->x1 >= (r2)->x2) || \
- ((r1)->y2 <= (r2)->y1) || \
- ((r1)->y1 >= (r2)->y2) ) )
-
-/* true iff (x,y) is in Box */
-#define INBOX(r,x,y) \
- ( ((r)->x2 > x) && \
- ((r)->x1 <= x) && \
- ((r)->y2 > y) && \
- ((r)->y1 <= y) )
-
-/* true iff Box r1 contains Box r2 */
-#define SUBSUMES(r1,r2) \
- ( ((r1)->x1 <= (r2)->x1) && \
- ((r1)->x2 >= (r2)->x2) && \
- ((r1)->y1 <= (r2)->y1) && \
- ((r1)->y2 >= (r2)->y2) )
-
-#define xallocData(n) (RegDataPtr)xalloc(REGION_SZOF(n))
-#define xfreeData(reg) if ((reg)->data && (reg)->data->size) xfree((reg)->data)
-
-#define RECTALLOC(pReg,n) \
-if (!(pReg)->data || (((pReg)->data->numRects + (n)) > (pReg)->data->size)) \
- miRectAlloc(pReg, n)
-
-#define ADDRECT(pNextRect,nx1,ny1,nx2,ny2) \
-{ \
- pNextRect->x1 = nx1; \
- pNextRect->y1 = ny1; \
- pNextRect->x2 = nx2; \
- pNextRect->y2 = ny2; \
- pNextRect++; \
-}
-
-#define NEWRECT(pReg,pNextRect,nx1,ny1,nx2,ny2) \
-{ \
- if (!(pReg)->data || ((pReg)->data->numRects == (pReg)->data->size))\
- { \
- miRectAlloc(pReg, 1); \
- pNextRect = REGION_TOP(pReg); \
- } \
- ADDRECT(pNextRect,nx1,ny1,nx2,ny2); \
- pReg->data->numRects++; \
- assert(pReg->data->numRects<=pReg->data->size); \
-}
-
-
-#define DOWNSIZE(reg,numRects) \
-if (((numRects) < ((reg)->data->size >> 1)) && ((reg)->data->size > 50)) \
-{ \
- RegDataPtr NewData; \
- NewData = (RegDataPtr)xrealloc((reg)->data, REGION_SZOF(numRects)); \
- if (NewData) \
- { \
- NewData->size = (numRects); \
- (reg)->data = NewData; \
- } \
-}
-
-
-BoxRec miEmptyBox = {0, 0, 0, 0};
-RegDataRec miEmptyData = {0, 0};
-
-#ifdef DEBUG
-int
-miPrintRegion(rgn)
- RegionPtr rgn;
-{
- int num, size;
- register int i;
- BoxPtr rects;
-
- num = REGION_NUM_RECTS(rgn);
- size = REGION_SIZE(rgn);
- rects = REGION_RECTS(rgn);
- ErrorF("num: %d size: %d\n", num, size);
- ErrorF("extents: %d %d %d %d\n",
- rgn->extents.x1, rgn->extents.y1, rgn->extents.x2, rgn->extents.y2);
- for (i = 0; i < num; i++)
- ErrorF("%d %d %d %d \n",
- rects[i].x1, rects[i].y1, rects[i].x2, rects[i].y2);
- ErrorF("\n");
- return(num);
-}
-
-
-Bool
-miRegionsEqual(reg1, reg2)
- RegionPtr reg1;
- RegionPtr reg2;
-{
- int i;
- BoxPtr rects1, rects2;
-
- if (reg1->extents.x1 != reg2->extents.x1) return FALSE;
- if (reg1->extents.x2 != reg2->extents.x2) return FALSE;
- if (reg1->extents.y1 != reg2->extents.y1) return FALSE;
- if (reg1->extents.y2 != reg2->extents.y2) return FALSE;
- if (REGION_NUM_RECTS(reg1) != REGION_NUM_RECTS(reg2)) return FALSE;
-
- rects1 = REGION_RECTS(reg1);
- rects2 = REGION_RECTS(reg2);
- for (i = 0; i != REGION_NUM_RECTS(reg1); i++) {
- if (rects1[i].x1 != rects2[i].x1) return FALSE;
- if (rects1[i].x2 != rects2[i].x2) return FALSE;
- if (rects1[i].y1 != rects2[i].y1) return FALSE;
- if (rects1[i].y2 != rects2[i].y2) return FALSE;
- }
- return TRUE;
-}
-
-Bool
-miValidRegion(reg)
- RegionPtr reg;
-{
- register int i, numRects;
-
- if ((reg->extents.x1 > reg->extents.x2) ||
- (reg->extents.y1 > reg->extents.y2))
- return FALSE;
- numRects = REGION_NUM_RECTS(reg);
- if (!numRects)
- return ((reg->extents.x1 == reg->extents.x2) &&
- (reg->extents.y1 == reg->extents.y2) &&
- (reg->data->size || (reg->data == &miEmptyData)));
- else if (numRects == 1)
- return (!reg->data);
- else
- {
- register BoxPtr pboxP, pboxN;
- BoxRec box;
-
- pboxP = REGION_RECTS(reg);
- box = *pboxP;
- box.y2 = pboxP[numRects-1].y2;
- pboxN = pboxP + 1;
- for (i = numRects; --i > 0; pboxP++, pboxN++)
- {
- if ((pboxN->x1 >= pboxN->x2) ||
- (pboxN->y1 >= pboxN->y2))
- return FALSE;
- if (pboxN->x1 < box.x1)
- box.x1 = pboxN->x1;
- if (pboxN->x2 > box.x2)
- box.x2 = pboxN->x2;
- if ((pboxN->y1 < pboxP->y1) ||
- ((pboxN->y1 == pboxP->y1) &&
- ((pboxN->x1 < pboxP->x2) || (pboxN->y2 != pboxP->y2))))
- return FALSE;
- }
- return ((box.x1 == reg->extents.x1) &&
- (box.x2 == reg->extents.x2) &&
- (box.y1 == reg->extents.y1) &&
- (box.y2 == reg->extents.y2));
- }
-}
-
-#endif /* DEBUG */
-
-
-/*****************************************************************
- * RegionCreate(rect, size)
- * This routine does a simple malloc to make a structure of
- * REGION of "size" number of rectangles.
- *****************************************************************/
-
-RegionPtr
-miRegionCreate(rect, size)
- BoxPtr rect;
- int size;
-{
- register RegionPtr pReg;
-
- Must_have_memory = TRUE; /* XXX */
- pReg = (RegionPtr)xalloc(sizeof(RegionRec));
- Must_have_memory = FALSE; /* XXX */
- if (rect)
- {
- pReg->extents = *rect;
- pReg->data = (RegDataPtr)NULL;
- }
- else
- {
- pReg->extents = miEmptyBox;
- if ((size > 1) && (pReg->data = xallocData(size)))
- {
- pReg->data->size = size;
- pReg->data->numRects = 0;
- }
- else
- pReg->data = &miEmptyData;
- }
- return(pReg);
-}
-
-/*****************************************************************
- * RegionInit(pReg, rect, size)
- * Outer region rect is statically allocated.
- *****************************************************************/
-
-void
-miRegionInit(pReg, rect, size)
- RegionPtr pReg;
- BoxPtr rect;
- int size;
-{
- if (rect)
- {
- pReg->extents = *rect;
- pReg->data = (RegDataPtr)NULL;
- }
- else
- {
- pReg->extents = miEmptyBox;
- if ((size > 1) && (pReg->data = xallocData(size)))
- {
- pReg->data->size = size;
- pReg->data->numRects = 0;
- }
- else
- pReg->data = &miEmptyData;
- }
-}
-
-void
-miRegionDestroy(pReg)
- RegionPtr pReg;
-{
- good(pReg);
- xfreeData(pReg);
- xfree(pReg);
-}
-
-void
-miRegionUninit(pReg)
- RegionPtr pReg;
-{
- good(pReg);
- xfreeData(pReg);
-}
-
-Bool
-miRectAlloc(pRgn, n)
- register RegionPtr pRgn;
- int n;
-{
- Must_have_memory = TRUE; /* XXX */
- if (!pRgn->data)
- {
- n++;
- pRgn->data = xallocData(n);
- pRgn->data->numRects = 1;
- *REGION_BOXPTR(pRgn) = pRgn->extents;
- }
- else if (!pRgn->data->size)
- {
- pRgn->data = xallocData(n);
- pRgn->data->numRects = 0;
- }
- else
- {
- if (n == 1)
- {
- n = pRgn->data->numRects;
- if (n > 500) /* XXX pick numbers out of a hat */
- n = 250;
- }
- n += pRgn->data->numRects;
- pRgn->data = (RegDataPtr)xrealloc(pRgn->data, REGION_SZOF(n));
- }
- Must_have_memory = FALSE; /* XXX */
- pRgn->data->size = n;
- return TRUE;
-}
-
-Bool
-miRegionCopy(dst, src)
- register RegionPtr dst;
- register RegionPtr src;
-{
- good(dst);
- good(src);
- if (dst == src)
- return TRUE;
- dst->extents = src->extents;
- if (!src->data || !src->data->size)
- {
- xfreeData(dst);
- dst->data = src->data;
- return TRUE;
- }
- if (!dst->data || (dst->data->size < src->data->numRects))
- {
- xfreeData(dst);
- Must_have_memory = TRUE; /* XXX */
- dst->data = xallocData(src->data->numRects);
- Must_have_memory = FALSE; /* XXX */
- dst->data->size = src->data->numRects;
- }
- dst->data->numRects = src->data->numRects;
- memmove((char *)REGION_BOXPTR(dst),(char *)REGION_BOXPTR(src),
- dst->data->numRects * sizeof(BoxRec));
- return TRUE;
-}
-
-
-/*======================================================================
- * Generic Region Operator
- *====================================================================*/
-
-/*-
- *-----------------------------------------------------------------------
- * miCoalesce --
- * Attempt to merge the boxes in the current band with those in the
- * previous one. We are guaranteed that the current band extends to
- * the end of the rects array. Used only by miRegionOp.
- *
- * Results:
- * The new index for the previous band.
- *
- * Side Effects:
- * If coalescing takes place:
- * - rectangles in the previous band will have their y2 fields
- * altered.
- * - pReg->data->numRects will be decreased.
- *
- *-----------------------------------------------------------------------
- */
-INLINE static int
-miCoalesce (pReg, prevStart, curStart)
- register RegionPtr pReg; /* Region to coalesce */
- int prevStart; /* Index of start of previous band */
- int curStart; /* Index of start of current band */
-{
- register BoxPtr pPrevBox; /* Current box in previous band */
- register BoxPtr pCurBox; /* Current box in current band */
- register int numRects; /* Number rectangles in both bands */
- register int y2; /* Bottom of current band */
- /*
- * Figure out how many rectangles are in the band.
- */
- numRects = curStart - prevStart;
- assert(numRects == pReg->data->numRects - curStart);
-
- if (!numRects) return curStart;
-
- /*
- * The bands may only be coalesced if the bottom of the previous
- * matches the top scanline of the current.
- */
- pPrevBox = REGION_BOX(pReg, prevStart);
- pCurBox = REGION_BOX(pReg, curStart);
- if (pPrevBox->y2 != pCurBox->y1) return curStart;
-
- /*
- * Make sure the bands have boxes in the same places. This
- * assumes that boxes have been added in such a way that they
- * cover the most area possible. I.e. two boxes in a band must
- * have some horizontal space between them.
- */
- y2 = pCurBox->y2;
-
- do {
- if ((pPrevBox->x1 != pCurBox->x1) || (pPrevBox->x2 != pCurBox->x2)) {
- return (curStart);
- }
- pPrevBox++;
- pCurBox++;
- numRects--;
- } while (numRects);
-
- /*
- * The bands may be merged, so set the bottom y of each box
- * in the previous band to the bottom y of the current band.
- */
- numRects = curStart - prevStart;
- pReg->data->numRects -= numRects;
- do {
- pPrevBox--;
- pPrevBox->y2 = y2;
- numRects--;
- } while (numRects);
- return prevStart;
-}
-
-
-/* Quicky macro to avoid trivial reject procedure calls to miCoalesce */
-
-#define Coalesce(newReg, prevBand, curBand) \
- if (curBand - prevBand == newReg->data->numRects - curBand) { \
- prevBand = miCoalesce(newReg, prevBand, curBand); \
- } else { \
- prevBand = curBand; \
- }
-
-/*-
- *-----------------------------------------------------------------------
- * miAppendNonO --
- * Handle a non-overlapping band for the union and subtract operations.
- * Just adds the (top/bottom-clipped) rectangles into the region.
- * Doesn't have to check for subsumption or anything.
- *
- * Results:
- * None.
- *
- * Side Effects:
- * pReg->data->numRects is incremented and the rectangles overwritten
- * with the rectangles we're passed.
- *
- *-----------------------------------------------------------------------
- */
-
-INLINE static Bool
-miAppendNonO (pReg, r, rEnd, y1, y2)
- register RegionPtr pReg;
- register BoxPtr r;
- BoxPtr rEnd;
- register int y1;
- register int y2;
-{
- register BoxPtr pNextRect;
- register int newRects;
-
- newRects = rEnd - r;
-
- assert(y1 < y2);
- assert(newRects != 0);
-
- /* Make sure we have enough space for all rectangles to be added */
- RECTALLOC(pReg, newRects);
- pNextRect = REGION_TOP(pReg);
- pReg->data->numRects += newRects;
- do {
- assert(r->x1 < r->x2);
- ADDRECT(pNextRect, r->x1, y1, r->x2, y2);
- r++;
- } while (r != rEnd);
-
- return TRUE;
-}
-
-#define FindBand(r, rBandEnd, rEnd, ry1) \
-{ \
- ry1 = r->y1; \
- rBandEnd = r+1; \
- while ((rBandEnd != rEnd) && (rBandEnd->y1 == ry1)) { \
- rBandEnd++; \
- } \
-}
-
-#define AppendRegions(newReg, r, rEnd) \
-{ \
- int newRects; \
- if (newRects = rEnd - r) { \
- RECTALLOC(newReg, newRects); \
- memmove((char *)REGION_TOP(newReg),(char *)r, \
- newRects * sizeof(BoxRec)); \
- newReg->data->numRects += newRects; \
- } \
-}
-
-/*-
- *-----------------------------------------------------------------------
- * miRegionOp --
- * Apply an operation to two regions. Called by miUnion, miInverse,
- * miSubtract, miIntersect.... Both regions MUST have at least one
- * rectangle, and cannot be the same object.
- *
- * Results:
- * TRUE if successful.
- *
- * Side Effects:
- * The new region is overwritten.
- * pOverlap set to TRUE if overlapFunc ever returns TRUE.
- *
- * Notes:
- * The idea behind this function is to view the two regions as sets.
- * Together they cover a rectangle of area that this function divides
- * into horizontal bands where points are covered only by one region
- * or by both. For the first case, the nonOverlapFunc is called with
- * each the band and the band's upper and lower extents. For the
- * second, the overlapFunc is called to process the entire band. It
- * is responsible for clipping the rectangles in the band, though
- * this function provides the boundaries.
- * At the end of each band, the new region is coalesced, if possible,
- * to reduce the number of rectangles in the region.
- *
- *-----------------------------------------------------------------------
- */
-static Bool
-miRegionOp(newReg, reg1, reg2, overlapFunc, appendNon1, appendNon2, pOverlap)
- RegionPtr newReg; /* Place to store result */
- RegionPtr reg1; /* First region in operation */
- RegionPtr reg2; /* 2d region in operation */
- Bool (*overlapFunc)(); /* Function to call for over-
- * lapping bands */
- Bool appendNon1; /* Append non-overlapping bands */
- /* in region 1 ? */
- Bool appendNon2; /* Append non-overlapping bands */
- /* in region 2 ? */
- Bool *pOverlap;
-{
- register BoxPtr r1; /* Pointer into first region */
- register BoxPtr r2; /* Pointer into 2d region */
- BoxPtr r1End; /* End of 1st region */
- BoxPtr r2End; /* End of 2d region */
- short ybot; /* Bottom of intersection */
- short ytop; /* Top of intersection */
- RegDataPtr oldData; /* Old data for newReg */
- int prevBand; /* Index of start of
- * previous band in newReg */
- int curBand; /* Index of start of current
- * band in newReg */
- register BoxPtr r1BandEnd; /* End of current band in r1 */
- register BoxPtr r2BandEnd; /* End of current band in r2 */
- short top; /* Top of non-overlapping band */
- short bot; /* Bottom of non-overlapping band*/
- register int r1y1; /* Temps for r1->y1 and r2->y1 */
- register int r2y1;
- int newSize;
- int numRects;
-
- /*
- * Initialization:
- * set r1, r2, r1End and r2End appropriately, save the rectangles
- * of the destination region until the end in case it's one of
- * the two source regions, then mark the "new" region empty, allocating
- * another array of rectangles for it to use.
- */
-
- r1 = REGION_RECTS(reg1);
- newSize = REGION_NUM_RECTS(reg1);
- r1End = r1 + newSize;
- numRects = REGION_NUM_RECTS(reg2);
- r2 = REGION_RECTS(reg2);
- r2End = r2 + numRects;
- assert(r1 != r1End);
- assert(r2 != r2End);
-
- oldData = (RegDataPtr)NULL;
- if (((newReg == reg1) && (newSize > 1)) ||
- ((newReg == reg2) && (numRects > 1)))
- {
- oldData = newReg->data;
- newReg->data = &miEmptyData;
- }
- /* guess at new size */
- if (numRects > newSize)
- newSize = numRects;
- newSize <<= 1;
- if (!newReg->data)
- newReg->data = &miEmptyData;
- else if (newReg->data->size)
- newReg->data->numRects = 0;
- if (newSize > newReg->data->size)
- miRectAlloc(newReg, newSize);
-
- /*
- * Initialize ybot.
- * In the upcoming loop, ybot and ytop serve different functions depending
- * on whether the band being handled is an overlapping or non-overlapping
- * band.
- * In the case of a non-overlapping band (only one of the regions
- * has points in the band), ybot is the bottom of the most recent
- * intersection and thus clips the top of the rectangles in that band.
- * ytop is the top of the next intersection between the two regions and
- * serves to clip the bottom of the rectangles in the current band.
- * For an overlapping band (where the two regions intersect), ytop clips
- * the top of the rectangles of both regions and ybot clips the bottoms.
- */
-
- ybot = min(r1->y1, r2->y1);
-
- /*
- * prevBand serves to mark the start of the previous band so rectangles
- * can be coalesced into larger rectangles. qv. miCoalesce, above.
- * In the beginning, there is no previous band, so prevBand == curBand
- * (curBand is set later on, of course, but the first band will always
- * start at index 0). prevBand and curBand must be indices because of
- * the possible expansion, and resultant moving, of the new region's
- * array of rectangles.
- */
- prevBand = 0;
-
- do {
- /*
- * This algorithm proceeds one source-band (as opposed to a
- * destination band, which is determined by where the two regions
- * intersect) at a time. r1BandEnd and r2BandEnd serve to mark the
- * rectangle after the last one in the current band for their
- * respective regions.
- */
- assert(r1 != r1End);
- assert(r2 != r2End);
-
- FindBand(r1, r1BandEnd, r1End, r1y1);
- FindBand(r2, r2BandEnd, r2End, r2y1);
-
- /*
- * First handle the band that doesn't intersect, if any.
- *
- * Note that attention is restricted to one band in the
- * non-intersecting region at once, so if a region has n
- * bands between the current position and the next place it overlaps
- * the other, this entire loop will be passed through n times.
- */
- if (r1y1 < r2y1) {
- if (appendNon1) {
- top = max(r1y1, ybot);
- bot = min(r1->y2, r2y1);
- if (top != bot) {
- curBand = newReg->data->numRects;
- miAppendNonO(newReg, r1, r1BandEnd, top, bot);
- Coalesce(newReg, prevBand, curBand);
- }
- }
- ytop = r2y1;
- } else if (r2y1 < r1y1) {
- if (appendNon2) {
- top = max(r2y1, ybot);
- bot = min(r2->y2, r1y1);
- if (top != bot) {
- curBand = newReg->data->numRects;
- miAppendNonO(newReg, r2, r2BandEnd, top, bot);
- Coalesce(newReg, prevBand, curBand);
- }
- }
- ytop = r1y1;
- } else {
- ytop = r1y1;
- }
-
- /*
- * Now see if we've hit an intersecting band. The two bands only
- * intersect if ybot > ytop
- */
- ybot = min(r1->y2, r2->y2);
- if (ybot > ytop) {
- curBand = newReg->data->numRects;
- (* overlapFunc)(newReg, r1, r1BandEnd, r2, r2BandEnd, ytop, ybot,
- pOverlap);
- Coalesce(newReg, prevBand, curBand);
- }
-
- /*
- * If we've finished with a band (y2 == ybot) we skip forward
- * in the region to the next band.
- */
- if (r1->y2 == ybot) r1 = r1BandEnd;
- if (r2->y2 == ybot) r2 = r2BandEnd;
-
- } while (r1 != r1End && r2 != r2End);
-
- /*
- * Deal with whichever region (if any) still has rectangles left.
- *
- * We only need to worry about banding and coalescing for the very first
- * band left. After that, we can just group all remaining boxes,
- * regardless of how many bands, into one final append to the list.
- */
-
- if ((r1 != r1End) && appendNon1) {
- /* Do first nonOverlap1Func call, which may be able to coalesce */
- FindBand(r1, r1BandEnd, r1End, r1y1);
- curBand = newReg->data->numRects;
- miAppendNonO(newReg, r1, r1BandEnd, max(r1y1, ybot), r1->y2);
- Coalesce(newReg, prevBand, curBand);
- /* Just append the rest of the boxes */
- AppendRegions(newReg, r1BandEnd, r1End);
-
- } else if ((r2 != r2End) && appendNon2) {
- /* Do first nonOverlap2Func call, which may be able to coalesce */
- FindBand(r2, r2BandEnd, r2End, r2y1);
- curBand = newReg->data->numRects;
- miAppendNonO(newReg, r2, r2BandEnd, max(r2y1, ybot), r2->y2);
- Coalesce(newReg, prevBand, curBand);
- /* Append rest of boxes */
- AppendRegions(newReg, r2BandEnd, r2End);
- }
-
- if (oldData)
- xfree(oldData);
-
- if (!(numRects = newReg->data->numRects))
- {
- xfreeData(newReg);
- newReg->data = &miEmptyData;
- }
- else if (numRects == 1)
- {
- newReg->extents = *REGION_BOXPTR(newReg);
- xfreeData(newReg);
- newReg->data = (RegDataPtr)NULL;
- }
- else
- {
- DOWNSIZE(newReg, numRects);
- }
-
- return TRUE;
-}
-
-/*-
- *-----------------------------------------------------------------------
- * miSetExtents --
- * Reset the extents of a region to what they should be. Called by
- * miSubtract and miIntersect as they can't figure it out along the
- * way or do so easily, as miUnion can.
- *
- * Results:
- * None.
- *
- * Side Effects:
- * The region's 'extents' structure is overwritten.
- *
- *-----------------------------------------------------------------------
- */
-void
-miSetExtents (pReg)
- register RegionPtr pReg;
-{
- register BoxPtr pBox, pBoxEnd;
-
- if (!pReg->data)
- return;
- if (!pReg->data->size)
- {
- pReg->extents.x2 = pReg->extents.x1;
- pReg->extents.y2 = pReg->extents.y1;
- return;
- }
-
- pBox = REGION_BOXPTR(pReg);
- pBoxEnd = REGION_END(pReg);
-
- /*
- * Since pBox is the first rectangle in the region, it must have the
- * smallest y1 and since pBoxEnd is the last rectangle in the region,
- * it must have the largest y2, because of banding. Initialize x1 and
- * x2 from pBox and pBoxEnd, resp., as good things to initialize them
- * to...
- */
- pReg->extents.x1 = pBox->x1;
- pReg->extents.y1 = pBox->y1;
- pReg->extents.x2 = pBoxEnd->x2;
- pReg->extents.y2 = pBoxEnd->y2;
-
- assert(pReg->extents.y1 < pReg->extents.y2);
- while (pBox <= pBoxEnd) {
- if (pBox->x1 < pReg->extents.x1)
- pReg->extents.x1 = pBox->x1;
- if (pBox->x2 > pReg->extents.x2)
- pReg->extents.x2 = pBox->x2;
- pBox++;
- };
-
- assert(pReg->extents.x1 < pReg->extents.x2);
-}
-
-/*======================================================================
- * Region Intersection
- *====================================================================*/
-/*-
- *-----------------------------------------------------------------------
- * miIntersectO --
- * Handle an overlapping band for miIntersect.
- *
- * Results:
- * TRUE if successful.
- *
- * Side Effects:
- * Rectangles may be added to the region.
- *
- *-----------------------------------------------------------------------
- */
-/*ARGSUSED*/
-static Bool
-miIntersectO (pReg, r1, r1End, r2, r2End, y1, y2, pOverlap)
- register RegionPtr pReg;
- register BoxPtr r1;
- BoxPtr r1End;
- register BoxPtr r2;
- BoxPtr r2End;
- short y1;
- short y2;
- Bool *pOverlap;
-{
- register int x1;
- register int x2;
- register BoxPtr pNextRect;
-
- pNextRect = REGION_TOP(pReg);
-
- assert(y1 < y2);
- assert(r1 != r1End && r2 != r2End);
-
- do {
- x1 = max(r1->x1, r2->x1);
- x2 = min(r1->x2, r2->x2);
-
- /*
- * If there's any overlap between the two rectangles, add that
- * overlap to the new region.
- */
- if (x1 < x2)
- NEWRECT(pReg, pNextRect, x1, y1, x2, y2);
-
- /*
- * Advance the pointer(s) with the leftmost right side, since the next
- * rectangle on that list may still overlap the other region's
- * current rectangle.
- */
- if (r1->x2 == x2) {
- r1++;
- }
- if (r2->x2 == x2) {
- r2++;
- }
- } while ((r1 != r1End) && (r2 != r2End));
-
- return TRUE;
-}
-
-
-Bool
-miIntersect(newReg, reg1, reg2)
- register RegionPtr newReg; /* destination Region */
- register RegionPtr reg1;
- register RegionPtr reg2; /* source regions */
-{
- good(reg1);
- good(reg2);
- good(newReg);
- /* check for trivial reject */
- if (REGION_NIL(reg1) || REGION_NIL(reg2) ||
- !EXTENTCHECK(&reg1->extents, &reg2->extents))
- {
- /* Covers about 20% of all cases */
- xfreeData(newReg);
- newReg->extents.x2 = newReg->extents.x1;
- newReg->extents.y2 = newReg->extents.y1;
- newReg->data = &miEmptyData;
- }
- else if (!reg1->data && !reg2->data)
- {
- /* Covers about 80% of cases that aren't trivially rejected */
- newReg->extents.x1 = max(reg1->extents.x1, reg2->extents.x1);
- newReg->extents.y1 = max(reg1->extents.y1, reg2->extents.y1);
- newReg->extents.x2 = min(reg1->extents.x2, reg2->extents.x2);
- newReg->extents.y2 = min(reg1->extents.y2, reg2->extents.y2);
- xfreeData(newReg);
- newReg->data = (RegDataPtr)NULL;
- }
- else if (!reg2->data && SUBSUMES(&reg2->extents, &reg1->extents))
- {
- return miRegionCopy(newReg, reg1);
- }
- else if (!reg1->data && SUBSUMES(&reg1->extents, &reg2->extents))
- {
- return miRegionCopy(newReg, reg2);
- }
- else if (reg1 == reg2)
- {
- return miRegionCopy(newReg, reg1);
- }
- else
- {
- /* General purpose intersection */
- Bool overlap; /* result ignored */
- if (!miRegionOp(newReg, reg1, reg2, miIntersectO, FALSE, FALSE,
- &overlap))
- return FALSE;
- miSetExtents(newReg);
- }
-
- good(newReg);
- return(TRUE);
-}
-
-#define MERGERECT(r) \
-{ \
- if (r->x1 <= x2) { \
- /* Merge with current rectangle */ \
- if (r->x1 < x2) *pOverlap = TRUE; \
- if (x2 < r->x2) x2 = r->x2; \
- } else { \
- /* Add current rectangle, start new one */ \
- NEWRECT(pReg, pNextRect, x1, y1, x2, y2); \
- x1 = r->x1; \
- x2 = r->x2; \
- } \
- r++; \
-}
-
-/*======================================================================
- * Region Union
- *====================================================================*/
-
-/*-
- *-----------------------------------------------------------------------
- * miUnionO --
- * Handle an overlapping band for the union operation. Picks the
- * left-most rectangle each time and merges it into the region.
- *
- * Results:
- * TRUE if successful.
- *
- * Side Effects:
- * pReg is overwritten.
- * pOverlap is set to TRUE if any boxes overlap.
- *
- *-----------------------------------------------------------------------
- */
-static Bool
-miUnionO (pReg, r1, r1End, r2, r2End, y1, y2, pOverlap)
- register RegionPtr pReg;
- register BoxPtr r1;
- BoxPtr r1End;
- register BoxPtr r2;
- BoxPtr r2End;
- short y1;
- short y2;
- Bool *pOverlap;
-{
- register BoxPtr pNextRect;
- register int x1; /* left and right side of current union */
- register int x2;
-
- assert (y1 < y2);
- assert(r1 != r1End && r2 != r2End);
-
- pNextRect = REGION_TOP(pReg);
-
- /* Start off current rectangle */
- if (r1->x1 < r2->x1)
- {
- x1 = r1->x1;
- x2 = r1->x2;
- r1++;
- }
- else
- {
- x1 = r2->x1;
- x2 = r2->x2;
- r2++;
- }
- while (r1 != r1End && r2 != r2End)
- {
- if (r1->x1 < r2->x1) MERGERECT(r1) else MERGERECT(r2);
- }
-
- /* Finish off whoever (if any) is left */
- if (r1 != r1End)
- {
- do
- {
- MERGERECT(r1);
- } while (r1 != r1End);
- }
- else if (r2 != r2End)
- {
- do
- {
- MERGERECT(r2);
- } while (r2 != r2End);
- }
-
- /* Add current rectangle */
- NEWRECT(pReg, pNextRect, x1, y1, x2, y2);
-
- return TRUE;
-}
-
-Bool
-miUnion(newReg, reg1, reg2)
- RegionPtr newReg; /* destination Region */
- register RegionPtr reg1;
- register RegionPtr reg2; /* source regions */
-{
- Bool overlap; /* result ignored */
-
- /* Return TRUE if some overlap between reg1, reg2 */
- good(reg1);
- good(reg2);
- good(newReg);
- /* checks all the simple cases */
-
- /*
- * Region 1 and 2 are the same
- */
- if (reg1 == reg2)
- {
- return miRegionCopy(newReg, reg1);
- }
-
- /*
- * Region 1 is empty
- */
- if (REGION_NIL(reg1))
- {
- if (newReg != reg2)
- return miRegionCopy(newReg, reg2);
- return TRUE;
- }
-
- /*
- * Region 2 is empty
- */
- if (REGION_NIL(reg2))
- {
- if (newReg != reg1)
- return miRegionCopy(newReg, reg1);
- return TRUE;
- }
-
- /*
- * Region 1 completely subsumes region 2
- */
- if (!reg1->data && SUBSUMES(&reg1->extents, &reg2->extents))
- {
- if (newReg != reg1)
- return miRegionCopy(newReg, reg1);
- return TRUE;
- }
-
- /*
- * Region 2 completely subsumes region 1
- */
- if (!reg2->data && SUBSUMES(&reg2->extents, &reg1->extents))
- {
- if (newReg != reg2)
- return miRegionCopy(newReg, reg2);
- return TRUE;
- }
-
- if (!miRegionOp(newReg, reg1, reg2, miUnionO, TRUE, TRUE, &overlap))
- return FALSE;
-
- newReg->extents.x1 = min(reg1->extents.x1, reg2->extents.x1);
- newReg->extents.y1 = min(reg1->extents.y1, reg2->extents.y1);
- newReg->extents.x2 = max(reg1->extents.x2, reg2->extents.x2);
- newReg->extents.y2 = max(reg1->extents.y2, reg2->extents.y2);
- good(newReg);
- return TRUE;
-}
-
-
-/*======================================================================
- * Batch Rectangle Union
- *====================================================================*/
-
-/*-
- *-----------------------------------------------------------------------
- * miRegionAppend --
- *
- * "Append" the rgn rectangles onto the end of dstrgn, maintaining
- * knowledge of YX-banding when it's easy. Otherwise, dstrgn just
- * becomes a non-y-x-banded random collection of rectangles, and not
- * yet a true region. After a sequence of appends, the caller must
- * call miRegionValidate to ensure that a valid region is constructed.
- *
- * Results:
- * TRUE if successful.
- *
- * Side Effects:
- * dstrgn is modified if rgn has rectangles.
- *
- */
-Bool
-miRegionAppend(dstrgn, rgn)
- register RegionPtr dstrgn;
- register RegionPtr rgn;
-{
- int numRects, dnumRects, size;
- BoxPtr new, old;
- Bool prepend;
-
- if (!rgn->data && (dstrgn->data == &miEmptyData))
- {
- dstrgn->extents = rgn->extents;
- dstrgn->data = (RegDataPtr)NULL;
- return TRUE;
- }
-
- numRects = REGION_NUM_RECTS(rgn);
- if (!numRects)
- return TRUE;
- prepend = FALSE;
- size = numRects;
- dnumRects = REGION_NUM_RECTS(dstrgn);
- if (!dnumRects && (size < 200))
- size = 200; /* XXX pick numbers out of a hat */
- RECTALLOC(dstrgn, size);
- old = REGION_RECTS(rgn);
- if (!dnumRects)
- dstrgn->extents = rgn->extents;
- else if (dstrgn->extents.x2 > dstrgn->extents.x1)
- {
- register BoxPtr first, last;
-
- first = old;
- last = REGION_BOXPTR(dstrgn) + (dnumRects - 1);
- if ((first->y1 > last->y2) ||
- ((first->y1 == last->y1) && (first->y2 == last->y2) &&
- (first->x1 > last->x2)))
- {
- if (rgn->extents.x1 < dstrgn->extents.x1)
- dstrgn->extents.x1 = rgn->extents.x1;
- if (rgn->extents.x2 > dstrgn->extents.x2)
- dstrgn->extents.x2 = rgn->extents.x2;
- dstrgn->extents.y2 = rgn->extents.y2;
- }
- else
- {
- first = REGION_BOXPTR(dstrgn);
- last = old + (numRects - 1);
- if ((first->y1 > last->y2) ||
- ((first->y1 == last->y1) && (first->y2 == last->y2) &&
- (first->x1 > last->x2)))
- {
- prepend = TRUE;
- if (rgn->extents.x1 < dstrgn->extents.x1)
- dstrgn->extents.x1 = rgn->extents.x1;
- if (rgn->extents.x2 > dstrgn->extents.x2)
- dstrgn->extents.x2 = rgn->extents.x2;
- dstrgn->extents.y1 = rgn->extents.y1;
- }
- else
- dstrgn->extents.x2 = dstrgn->extents.x1;
- }
- }
- if (prepend)
- {
- new = REGION_BOX(dstrgn, numRects);
- if (dnumRects == 1)
- *new = *REGION_BOXPTR(dstrgn);
- else
- memmove((char *)new,(char *)REGION_BOXPTR(dstrgn),
- dnumRects * sizeof(BoxRec));
- new = REGION_BOXPTR(dstrgn);
- }
- else
- new = REGION_BOXPTR(dstrgn) + dnumRects;
- if (numRects == 1)
- *new = *old;
- else
- memmove((char *)new, (char *)old, numRects * sizeof(BoxRec));
- dstrgn->data->numRects += numRects;
- return TRUE;
-}
-
-
-#define ExchangeRects(a, b) \
-{ \
- BoxRec t; \
- t = rects[a]; \
- rects[a] = rects[b]; \
- rects[b] = t; \
-}
-
-static void
-QuickSortRects(rects, numRects)
- register BoxRec rects[];
- register int numRects;
-{
- register int y1;
- register int x1;
- register int i, j;
- register BoxPtr r;
-
- /* Always called with numRects > 1 */
-
- do
- {
- if (numRects == 2)
- {
- if (rects[0].y1 > rects[1].y1 ||
- (rects[0].y1 == rects[1].y1 && rects[0].x1 > rects[1].x1))
- ExchangeRects(0, 1);
- return;
- }
-
- /* Choose partition element, stick in location 0 */
- ExchangeRects(0, numRects >> 1);
- y1 = rects[0].y1;
- x1 = rects[0].x1;
-
- /* Partition array */
- i = 0;
- j = numRects;
- do
- {
- r = &(rects[i]);
- do
- {
- r++;
- i++;
- } while (i != numRects &&
- (r->y1 < y1 || (r->y1 == y1 && r->x1 < x1)));
- r = &(rects[j]);
- do
- {
- r--;
- j--;
- } while (y1 < r->y1 || (y1 == r->y1 && x1 < r->x1));
- if (i < j)
- ExchangeRects(i, j);
- } while (i < j);
-
- /* Move partition element back to middle */
- ExchangeRects(0, j);
-
- /* Recurse */
- if (numRects-j-1 > 1)
- QuickSortRects(&rects[j+1], numRects-j-1);
- numRects = j;
- } while (numRects > 1);
-}
-
-/*-
- *-----------------------------------------------------------------------
- * miRegionValidate --
- *
- * Take a ``region'' which is a non-y-x-banded random collection of
- * rectangles, and compute a nice region which is the union of all the
- * rectangles.
- *
- * Results:
- * TRUE if successful.
- *
- * Side Effects:
- * The passed-in ``region'' may be modified.
- * pOverlap set to TRUE if any retangles overlapped, else FALSE;
- *
- * Strategy:
- * Step 1. Sort the rectangles into ascending order with primary key y1
- * and secondary key x1.
- *
- * Step 2. Split the rectangles into the minimum number of proper y-x
- * banded regions. This may require horizontally merging
- * rectangles, and vertically coalescing bands. With any luck,
- * this step in an identity tranformation (ala the Box widget),
- * or a coalescing into 1 box (ala Menus).
- *
- * Step 3. Merge the separate regions down to a single region by calling
- * miUnion. Maximize the work each miUnion call does by using
- * a binary merge.
- *
- *-----------------------------------------------------------------------
- */
-
-Bool
-miRegionValidate(badreg, pOverlap)
- RegionPtr badreg;
- Bool *pOverlap;
-{
- /* Descriptor for regions under construction in Step 2. */
- typedef struct {
- RegionRec reg;
- int prevBand;
- int curBand;
- } RegionInfo;
-
- int numRects; /* Original numRects for badreg */
- RegionInfo *ri; /* Array of current regions */
- int numRI; /* Number of entries used in ri */
- int sizeRI; /* Number of entries available in ri */
- int i; /* Index into rects */
- register int j; /* Index into ri */
- register RegionInfo *rit; /* &ri[j] */
- register RegionPtr reg; /* ri[j].reg */
- register BoxPtr box; /* Current box in rects */
- register BoxPtr riBox; /* Last box in ri[j].reg */
- register RegionPtr hreg; /* ri[j_half].reg */
-
- *pOverlap = FALSE;
- if (!badreg->data)
- {
- good(badreg);
- return TRUE;
- }
- numRects = badreg->data->numRects;
- if (!numRects)
- {
- good(badreg);
- return TRUE;
- }
- if (badreg->extents.x1 < badreg->extents.x2)
- {
- if ((numRects) == 1)
- {
- xfreeData(badreg);
- badreg->data = (RegDataPtr) NULL;
- }
- else
- {
- DOWNSIZE(badreg, numRects);
- }
- good(badreg);
- return TRUE;
- }
-
- /* Step 1: Sort the rects array into ascending (y1, x1) order */
- QuickSortRects(REGION_BOXPTR(badreg), numRects);
-
- /* Step 2: Scatter the sorted array into the minimum number of regions */
-
- /* Set up the first region to be the first rectangle in badreg */
- /* Note that step 2 code will never overflow the ri[0].reg rects array */
- Must_have_memory = TRUE; /* XXX */
- ri = (RegionInfo *) xalloc(4 * sizeof(RegionInfo));
- Must_have_memory = FALSE; /* XXX */
- sizeRI = 4;
- numRI = 1;
- ri[0].prevBand = 0;
- ri[0].curBand = 0;
- ri[0].reg = *badreg;
- box = REGION_BOXPTR(&ri[0].reg);
- ri[0].reg.extents = *box;
- ri[0].reg.data->numRects = 1;
-
- /* Now scatter rectangles into the minimum set of valid regions. If the
- next rectangle to be added to a region would force an existing rectangle
- in the region to be split up in order to maintain y-x banding, just
- forget it. Try the next region. If it doesn't fit cleanly into any
- region, make a new one. */
-
- for (i = numRects; --i > 0;)
- {
- box++;
- /* Look for a region to append box to */
- for (j = numRI, rit = ri; --j >= 0; rit++)
- {
- reg = &rit->reg;
- riBox = REGION_END(reg);
-
- if (box->y1 == riBox->y1 && box->y2 == riBox->y2)
- {
- /* box is in same band as riBox. Merge or append it */
- if (box->x1 <= riBox->x2)
- {
- /* Merge it with riBox */
- if (box->x1 < riBox->x2) *pOverlap = TRUE;
- if (box->x2 > riBox->x2) riBox->x2 = box->x2;
- }
- else
- {
- RECTALLOC(reg, 1);
- *REGION_TOP(reg) = *box;
- reg->data->numRects++;
- }
- goto NextRect; /* So sue me */
- }
- else if (box->y1 >= riBox->y2)
- {
- /* Put box into new band */
- if (reg->extents.x2 < riBox->x2) reg->extents.x2 = riBox->x2;
- if (reg->extents.x1 > box->x1) reg->extents.x1 = box->x1;
- Coalesce(reg, rit->prevBand, rit->curBand);
- rit->curBand = reg->data->numRects;
- RECTALLOC(reg, 1);
- *REGION_TOP(reg) = *box;
- reg->data->numRects++;
- goto NextRect;
- }
- /* Well, this region was inappropriate. Try the next one. */
- } /* for j */
-
- /* Uh-oh. No regions were appropriate. Create a new one. */
- if (sizeRI == numRI)
- {
- /* Oops, allocate space for new region information */
- sizeRI <<= 1;
- Must_have_memory = TRUE; /* XXX */
- ri = (RegionInfo *) xrealloc(ri, sizeRI * sizeof(RegionInfo));
- Must_have_memory = FALSE; /* XXX */
- rit = &ri[numRI];
- }
- numRI++;
- rit->prevBand = 0;
- rit->curBand = 0;
- rit->reg.extents = *box;
- rit->reg.data = (RegDataPtr)NULL;
- miRectAlloc(&rit->reg, (i+numRI) / numRI); /* MUST force allocation */
-NextRect: ;
- } /* for i */
-
- /* Make a final pass over each region in order to Coalesce and set
- extents.x2 and extents.y2 */
-
- for (j = numRI, rit = ri; --j >= 0; rit++)
- {
- reg = &rit->reg;
- riBox = REGION_END(reg);
- reg->extents.y2 = riBox->y2;
- if (reg->extents.x2 < riBox->x2) reg->extents.x2 = riBox->x2;
- Coalesce(reg, rit->prevBand, rit->curBand);
- if (reg->data->numRects == 1) /* keep unions happy below */
- {
- xfreeData(reg);
- reg->data = (RegDataPtr)NULL;
- }
- }
-
- /* Step 3: Union all regions into a single region */
- while (numRI > 1)
- {
- int half = numRI/2;
- for (j = numRI & 1; j < (half + (numRI & 1)); j++)
- {
- reg = &ri[j].reg;
- hreg = &ri[j+half].reg;
- miRegionOp(reg, reg, hreg, miUnionO, TRUE, TRUE, pOverlap);
- if (hreg->extents.x1 < reg->extents.x1)
- reg->extents.x1 = hreg->extents.x1;
- if (hreg->extents.y1 < reg->extents.y1)
- reg->extents.y1 = hreg->extents.y1;
- if (hreg->extents.x2 > reg->extents.x2)
- reg->extents.x2 = hreg->extents.x2;
- if (hreg->extents.y2 > reg->extents.y2)
- reg->extents.y2 = hreg->extents.y2;
- xfreeData(hreg);
- }
- numRI -= half;
- }
- *badreg = ri[0].reg;
- xfree(ri);
- good(badreg);
- return TRUE;
-}
-
-RegionPtr
-miRectsToRegion(nrects, prect, ctype)
- int nrects;
- register xRectangle *prect;
- int ctype;
-{
- register RegionPtr pRgn;
- register RegDataPtr pData;
- register BoxPtr pBox;
- register int i;
- int x1, y1, x2, y2;
-
- pRgn = miRegionCreate(NullBox, 0);
- if (!nrects)
- return pRgn;
- if (nrects == 1)
- {
- x1 = prect->x;
- y1 = prect->y;
- if ((x2 = x1 + (int) prect->width) > MAXSHORT)
- x2 = MAXSHORT;
- if ((y2 = y1 + (int) prect->height) > MAXSHORT)
- y2 = MAXSHORT;
- if (x1 != x2 && y1 != y2)
- {
- pRgn->extents.x1 = x1;
- pRgn->extents.y1 = y1;
- pRgn->extents.x2 = x2;
- pRgn->extents.y2 = y2;
- pRgn->data = (RegDataPtr)NULL;
- }
- return pRgn;
- }
- Must_have_memory = TRUE; /* XXX */
- pData = xallocData(nrects);
- pBox = (BoxPtr) (pData + 1);
- Must_have_memory = FALSE; /* XXX */
- for (i = nrects; --i >= 0; prect++)
- {
- x1 = prect->x;
- y1 = prect->y;
- if ((x2 = x1 + (int) prect->width) > MAXSHORT)
- x2 = MAXSHORT;
- if ((y2 = y1 + (int) prect->height) > MAXSHORT)
- y2 = MAXSHORT;
- if (x1 != x2 && y1 != y2)
- {
- pBox->x1 = x1;
- pBox->y1 = y1;
- pBox->x2 = x2;
- pBox->y2 = y2;
- pBox++;
- }
- }
- if (pBox != (BoxPtr) (pData + 1))
- {
- pData->size = nrects;
- pData->numRects = pBox - (BoxPtr) (pData + 1);
- pRgn->data = pData;
- if (ctype != CT_YXBANDED)
- {
- Bool overlap; /* result ignored */
- pRgn->extents.x1 = pRgn->extents.x2 = 0;
- miRegionValidate(pRgn, &overlap);
- }
- else
- miSetExtents(pRgn);
- good(pRgn);
- }
- else
- {
- xfree (pData);
- }
- return pRgn;
-}
-
-/*======================================================================
- * Region Subtraction
- *====================================================================*/
-
-
-/*-
- *-----------------------------------------------------------------------
- * miSubtractO --
- * Overlapping band subtraction. x1 is the left-most point not yet
- * checked.
- *
- * Results:
- * TRUE if successful.
- *
- * Side Effects:
- * pReg may have rectangles added to it.
- *
- *-----------------------------------------------------------------------
- */
-/*ARGSUSED*/
-static Bool
-miSubtractO (pReg, r1, r1End, r2, r2End, y1, y2, pOverlap)
- register RegionPtr pReg;
- register BoxPtr r1;
- BoxPtr r1End;
- register BoxPtr r2;
- BoxPtr r2End;
- register int y1;
- int y2;
- Bool *pOverlap;
-{
- register BoxPtr pNextRect;
- register int x1;
-
- x1 = r1->x1;
-
- assert(y1<y2);
- assert(r1 != r1End && r2 != r2End);
-
- pNextRect = REGION_TOP(pReg);
-
- do
- {
- if (r2->x2 <= x1)
- {
- /*
- * Subtrahend entirely to left of minuend: go to next subtrahend.
- */
- r2++;
- }
- else if (r2->x1 <= x1)
- {
- /*
- * Subtrahend preceeds minuend: nuke left edge of minuend.
- */
- x1 = r2->x2;
- if (x1 >= r1->x2)
- {
- /*
- * Minuend completely covered: advance to next minuend and
- * reset left fence to edge of new minuend.
- */
- r1++;
- if (r1 != r1End)
- x1 = r1->x1;
- }
- else
- {
- /*
- * Subtrahend now used up since it doesn't extend beyond
- * minuend
- */
- r2++;
- }
- }
- else if (r2->x1 < r1->x2)
- {
- /*
- * Left part of subtrahend covers part of minuend: add uncovered
- * part of minuend to region and skip to next subtrahend.
- */
- assert(x1<r2->x1);
- NEWRECT(pReg, pNextRect, x1, y1, r2->x1, y2);
-
- x1 = r2->x2;
- if (x1 >= r1->x2)
- {
- /*
- * Minuend used up: advance to new...
- */
- r1++;
- if (r1 != r1End)
- x1 = r1->x1;
- }
- else
- {
- /*
- * Subtrahend used up
- */
- r2++;
- }
- }
- else
- {
- /*
- * Minuend used up: add any remaining piece before advancing.
- */
- if (r1->x2 > x1)
- NEWRECT(pReg, pNextRect, x1, y1, r1->x2, y2);
- r1++;
- if (r1 != r1End)
- x1 = r1->x1;
- }
- } while ((r1 != r1End) && (r2 != r2End));
-
-
- /*
- * Add remaining minuend rectangles to region.
- */
- while (r1 != r1End)
- {
- assert(x1<r1->x2);
- NEWRECT(pReg, pNextRect, x1, y1, r1->x2, y2);
- r1++;
- if (r1 != r1End)
- x1 = r1->x1;
- }
- return TRUE;
-}
-
-/*-
- *-----------------------------------------------------------------------
- * miSubtract --
- * Subtract regS from regM and leave the result in regD.
- * S stands for subtrahend, M for minuend and D for difference.
- *
- * Results:
- * TRUE if successful.
- *
- * Side Effects:
- * regD is overwritten.
- *
- *-----------------------------------------------------------------------
- */
-Bool
-miSubtract(regD, regM, regS)
- register RegionPtr regD;
- register RegionPtr regM;
- register RegionPtr regS;
-{
- Bool overlap; /* result ignored */
-
- good(regM);
- good(regS);
- good(regD);
- /* check for trivial rejects */
- if (REGION_NIL(regM) || REGION_NIL(regS) ||
- !EXTENTCHECK(&regM->extents, &regS->extents))
- {
- return miRegionCopy(regD, regM);
- }
- else if (regM == regS)
- {
- xfreeData(regD);
- regD->extents.x2 = regD->extents.x1;
- regD->extents.y2 = regD->extents.y1;
- regD->data = &miEmptyData;
- return TRUE;
- }
-
- /* Add those rectangles in region 1 that aren't in region 2,
- do yucky substraction for overlaps, and
- just throw away rectangles in region 2 that aren't in region 1 */
- if (!miRegionOp(regD, regM, regS, miSubtractO, TRUE, FALSE, &overlap))
- return FALSE;
-
- /*
- * Can't alter RegD's extents before we call miRegionOp because
- * it might be one of the source regions and miRegionOp depends
- * on the extents of those regions being unaltered. Besides, this
- * way there's no checking against rectangles that will be nuked
- * due to coalescing, so we have to examine fewer rectangles.
- */
- miSetExtents(regD);
- good(regD);
- return TRUE;
-}
-
-/*======================================================================
- * Region Inversion
- *====================================================================*/
-
-/*-
- *-----------------------------------------------------------------------
- * miInverse --
- * Take a region and a box and return a region that is everything
- * in the box but not in the region. The careful reader will note
- * that this is the same as subtracting the region from the box...
- *
- * Results:
- * TRUE.
- *
- * Side Effects:
- * newReg is overwritten.
- *
- *-----------------------------------------------------------------------
- */
-Bool
-miInverse(newReg, reg1, invRect)
- RegionPtr newReg; /* Destination region */
- RegionPtr reg1; /* Region to invert */
- BoxPtr invRect; /* Bounding box for inversion */
-{
- RegionRec invReg; /* Quick and dirty region made from the
- * bounding box */
- Bool overlap; /* result ignored */
-
- good(reg1);
- good(newReg);
- /* check for trivial rejects */
- if (REGION_NIL(reg1) || !EXTENTCHECK(invRect, &reg1->extents))
- {
- newReg->extents = *invRect;
- xfreeData(newReg);
- newReg->data = (RegDataPtr)NULL;
- return TRUE;
- }
-
- /* Add those rectangles in region 1 that aren't in region 2,
- do yucky substraction for overlaps, and
- just throw away rectangles in region 2 that aren't in region 1 */
- invReg.extents = *invRect;
- invReg.data = (RegDataPtr)NULL;
- if (!miRegionOp(newReg, &invReg, reg1, miSubtractO, TRUE, FALSE, &overlap))
- return FALSE;
-
- /*
- * Can't alter newReg's extents before we call miRegionOp because
- * it might be one of the source regions and miRegionOp depends
- * on the extents of those regions being unaltered. Besides, this
- * way there's no checking against rectangles that will be nuked
- * due to coalescing, so we have to examine fewer rectangles.
- */
- miSetExtents(newReg);
- good(newReg);
- return TRUE;
-}
-
-/*
- * RectIn(region, rect)
- * This routine takes a pointer to a region and a pointer to a box
- * and determines if the box is outside/inside/partly inside the region.
- *
- * The idea is to travel through the list of rectangles trying to cover the
- * passed box with them. Anytime a piece of the rectangle isn't covered
- * by a band of rectangles, partOut is set TRUE. Any time a rectangle in
- * the region covers part of the box, partIn is set TRUE. The process ends
- * when either the box has been completely covered (we reached a band that
- * doesn't overlap the box, partIn is TRUE and partOut is false), the
- * box has been partially covered (partIn == partOut == TRUE -- because of
- * the banding, the first time this is true we know the box is only
- * partially in the region) or is outside the region (we reached a band
- * that doesn't overlap the box at all and partIn is false)
- */
-
-int
-miRectIn(region, prect)
- register RegionPtr region;
- register BoxPtr prect;
-{
- register int x;
- register int y;
- register BoxPtr pbox;
- register BoxPtr pboxEnd;
- int partIn, partOut;
- int numRects;
-
- good(region);
- numRects = REGION_NUM_RECTS(region);
- /* useful optimization */
- if (!numRects || !EXTENTCHECK(&region->extents, prect))
- return(rgnOUT);
-
- if (numRects == 1)
- {
- /* We know that it must be rgnIN or rgnPART */
- if (SUBSUMES(&region->extents, prect))
- return(rgnIN);
- else
- return(rgnPART);
- }
-
- partOut = FALSE;
- partIn = FALSE;
-
- /* (x,y) starts at upper left of rect, moving to the right and down */
- x = prect->x1;
- y = prect->y1;
-
- /* can stop when both partOut and partIn are TRUE, or we reach prect->y2 */
- for (pbox = REGION_BOXPTR(region), pboxEnd = pbox + numRects;
- pbox != pboxEnd;
- pbox++)
- {
-
- if (pbox->y2 <= y)
- continue; /* getting up to speed or skipping remainder of band */
-
- if (pbox->y1 > y)
- {
- partOut = TRUE; /* missed part of rectangle above */
- if (partIn || (pbox->y1 >= prect->y2))
- break;
- y = pbox->y1; /* x guaranteed to be == prect->x1 */
- }
-
- if (pbox->x2 <= x)
- continue; /* not far enough over yet */
-
- if (pbox->x1 > x)
- {
- partOut = TRUE; /* missed part of rectangle to left */
- if (partIn)
- break;
- }
-
- if (pbox->x1 < prect->x2)
- {
- partIn = TRUE; /* definitely overlap */
- if (partOut)
- break;
- }
-
- if (pbox->x2 >= prect->x2)
- {
- y = pbox->y2; /* finished with this band */
- if (y >= prect->y2)
- break;
- x = prect->x1; /* reset x out to left again */
- }
- else
- {
- /*
- * Because boxes in a band are maximal width, if the first box
- * to overlap the rectangle doesn't completely cover it in that
- * band, the rectangle must be partially out, since some of it
- * will be uncovered in that band. partIn will have been set true
- * by now...
- */
- partOut = TRUE;
- break;
- }
- }
-
- return(partIn ? ((y < prect->y2) ? rgnPART : rgnIN) : rgnOUT);
-}
-
-/* TranslateRegion(pReg, x, y)
- translates in place
-*/
-
-void
-miTranslateRegion(pReg, x, y)
- register RegionPtr pReg;
- register int x;
- register int y;
-{
- int x1, x2, y1, y2;
- register int nbox;
- register BoxPtr pbox;
-
- good(pReg);
- pReg->extents.x1 = x1 = pReg->extents.x1 + x;
- pReg->extents.y1 = y1 = pReg->extents.y1 + y;
- pReg->extents.x2 = x2 = pReg->extents.x2 + x;
- pReg->extents.y2 = y2 = pReg->extents.y2 + y;
- if (((x1 - MINSHORT)|(y1 - MINSHORT)|(MAXSHORT - x2)|(MAXSHORT - y2)) >= 0)
- {
- if (pReg->data && (nbox = pReg->data->numRects))
- {
- for (pbox = REGION_BOXPTR(pReg); nbox--; pbox++)
- {
- pbox->x1 += x;
- pbox->y1 += y;
- pbox->x2 += x;
- pbox->y2 += y;
- }
- }
- return;
- }
- if (((x2 - MINSHORT)|(y2 - MINSHORT)|(MAXSHORT - x1)|(MAXSHORT - y1)) <= 0)
- {
- pReg->extents.x2 = pReg->extents.x1;
- pReg->extents.y2 = pReg->extents.y1;
- xfreeData(pReg);
- pReg->data = &miEmptyData;
- return;
- }
- if (x1 < MINSHORT)
- pReg->extents.x1 = MINSHORT;
- else if (x2 > MAXSHORT)
- pReg->extents.x2 = MAXSHORT;
- if (y1 < MINSHORT)
- pReg->extents.y1 = MINSHORT;
- else if (y2 > MAXSHORT)
- pReg->extents.y2 = MAXSHORT;
- if (pReg->data && (nbox = pReg->data->numRects))
- {
- register BoxPtr pboxout;
-
- for (pboxout = pbox = REGION_BOXPTR(pReg); nbox--; pbox++)
- {
- pboxout->x1 = x1 = pbox->x1 + x;
- pboxout->y1 = y1 = pbox->y1 + y;
- pboxout->x2 = x2 = pbox->x2 + x;
- pboxout->y2 = y2 = pbox->y2 + y;
- if (((x2 - MINSHORT)|(y2 - MINSHORT)|
- (MAXSHORT - x1)|(MAXSHORT - y1)) <= 0)
- {
- pReg->data->numRects--;
- continue;
- }
- if (x1 < MINSHORT)
- pboxout->x1 = MINSHORT;
- else if (x2 > MAXSHORT)
- pboxout->x2 = MAXSHORT;
- if (y1 < MINSHORT)
- pboxout->y1 = MINSHORT;
- else if (y2 > MAXSHORT)
- pboxout->y2 = MAXSHORT;
- pboxout++;
- }
- if (pboxout != pbox)
- {
- if (pReg->data->numRects == 1)
- {
- pReg->extents = *REGION_BOXPTR(pReg);
- xfreeData(pReg);
- pReg->data = (RegDataPtr)NULL;
- }
- else
- miSetExtents(pReg);
- }
- }
-}
-
-Bool
-miRegionDataCopy(dst, src)
- register RegionPtr dst;
- register RegionPtr src;
-{
- good(dst);
- good(src);
- if (dst->data)
- return TRUE;
- if (dst == src)
- return TRUE;
- if (!src->data || !src->data->size)
- {
- xfreeData(dst);
- dst->data = (RegDataPtr)NULL;
- return TRUE;
- }
- if (!dst->data || (dst->data->size < src->data->numRects))
- {
- xfreeData(dst);
- Must_have_memory = TRUE; /* XXX */
- dst->data = xallocData(src->data->numRects);
- Must_have_memory = FALSE; /* XXX */
- }
- dst->data->size = src->data->size;
- dst->data->numRects = src->data->numRects;
- return TRUE;
-}
-
-void
-miRegionReset(pReg, pBox)
- RegionPtr pReg;
- BoxPtr pBox;
-{
- good(pReg);
- assert(pBox->x1<=pBox->x2);
- assert(pBox->y1<=pBox->y2);
- pReg->extents = *pBox;
- xfreeData(pReg);
- pReg->data = (RegDataPtr)NULL;
-}
-
-Bool
-miPointInRegion(pReg, x, y, box)
- register RegionPtr pReg;
- register int x, y;
- BoxPtr box; /* "return" value */
-{
- register BoxPtr pbox, pboxEnd;
- int numRects;
-
- good(pReg);
- numRects = REGION_NUM_RECTS(pReg);
- if (!numRects || !INBOX(&pReg->extents, x, y))
- return(FALSE);
- if (numRects == 1)
- {
- *box = pReg->extents;
- return(TRUE);
- }
- for (pbox = REGION_BOXPTR(pReg), pboxEnd = pbox + numRects;
- pbox != pboxEnd;
- pbox++)
- {
- if (y >= pbox->y2)
- continue; /* not there yet */
- if ((y < pbox->y1) || (x < pbox->x1))
- break; /* missed it */
- if (x >= pbox->x2)
- continue; /* not there yet */
- *box = *pbox;
- return(TRUE);
- }
- return(FALSE);
-}
-
-Bool
-miRegionNotEmpty(pReg)
- RegionPtr pReg;
-{
- good(pReg);
- return(!REGION_NIL(pReg));
-}
-
-
-void
-miRegionEmpty(pReg)
- RegionPtr pReg;
-{
- good(pReg);
- xfreeData(pReg);
- pReg->extents.x2 = pReg->extents.x1;
- pReg->extents.y2 = pReg->extents.y1;
- pReg->data = &miEmptyData;
-}
-
-BoxPtr
-miRegionExtents(pReg)
- RegionPtr pReg;
-{
- good(pReg);
- return(&pReg->extents);
-}
-
-#define ExchangeSpans(a, b) \
-{ \
- DDXPointRec tpt; \
- register int tw; \
- \
- tpt = spans[a]; spans[a] = spans[b]; spans[b] = tpt; \
- tw = widths[a]; widths[a] = widths[b]; widths[b] = tw; \
-}
-
-/* ||| I should apply the merge sort code to rectangle sorting above, and see
- if mapping time can be improved. But right now I've been at work 12 hours,
- so forget it.
-*/
-
-static void QuickSortSpans(spans, widths, numSpans)
- register DDXPointRec spans[];
- register int widths[];
- register int numSpans;
-{
- register int y;
- register int i, j, m;
- register DDXPointPtr r;
-
- /* Always called with numSpans > 1 */
- /* Sorts only by y, doesn't bother to sort by x */
-
- do
- {
- if (numSpans < 9)
- {
- /* Do insertion sort */
- register int yprev;
-
- yprev = spans[0].y;
- i = 1;
- do
- { /* while i != numSpans */
- y = spans[i].y;
- if (yprev > y)
- {
- /* spans[i] is out of order. Move into proper location. */
- DDXPointRec tpt;
- int tw, k;
-
- for (j = 0; y >= spans[j].y; j++) {}
- tpt = spans[i];
- tw = widths[i];
- for (k = i; k != j; k--)
- {
- spans[k] = spans[k-1];
- widths[k] = widths[k-1];
- }
- spans[j] = tpt;
- widths[j] = tw;
- y = spans[i].y;
- } /* if out of order */
- yprev = y;
- i++;
- } while (i != numSpans);
- return;
- }
-
- /* Choose partition element, stick in location 0 */
- m = numSpans / 2;
- if (spans[m].y > spans[0].y) ExchangeSpans(m, 0);
- if (spans[m].y > spans[numSpans-1].y) ExchangeSpans(m, numSpans-1);
- if (spans[m].y > spans[0].y) ExchangeSpans(m, 0);
- y = spans[0].y;
-
- /* Partition array */
- i = 0;
- j = numSpans;
- do
- {
- r = &(spans[i]);
- do
- {
- r++;
- i++;
- } while (i != numSpans && r->y < y);
- r = &(spans[j]);
- do
- {
- r--;
- j--;
- } while (y < r->y);
- if (i < j)
- ExchangeSpans(i, j);
- } while (i < j);
-
- /* Move partition element back to middle */
- ExchangeSpans(0, j);
-
- /* Recurse */
- if (numSpans-j-1 > 1)
- QuickSortSpans(&spans[j+1], &widths[j+1], numSpans-j-1);
- numSpans = j;
- } while (numSpans > 1);
-}
-
-#define NextBand() \
-{ \
- clipy1 = pboxBandStart->y1; \
- clipy2 = pboxBandStart->y2; \
- pboxBandEnd = pboxBandStart + 1; \
- while (pboxBandEnd != pboxLast && pboxBandEnd->y1 == clipy1) { \
- pboxBandEnd++; \
- } \
- for (; ppt != pptLast && ppt->y < clipy1; ppt++, pwidth++) {} \
-}
-
-/*
- Clip a list of scanlines to a region. The caller has allocated the
- space. FSorted is non-zero if the scanline origins are in ascending
- order.
- returns the number of new, clipped scanlines.
-*/
-
-int
-miClipSpans(prgnDst, ppt, pwidth, nspans, pptNew, pwidthNew, fSorted)
- RegionPtr prgnDst;
- register DDXPointPtr ppt;
- register int *pwidth;
- int nspans;
- register DDXPointPtr pptNew;
- int *pwidthNew;
- int fSorted;
-{
- register DDXPointPtr pptLast;
- int *pwidthNewStart; /* the vengeance of Xerox! */
- register int y, x1, x2;
- register int numRects;
-
- good(prgnDst);
- pptLast = ppt + nspans;
- pwidthNewStart = pwidthNew;
-
- if (!prgnDst->data)
- {
- /* Do special fast code with clip boundaries in registers(?) */
- /* It doesn't pay much to make use of fSorted in this case,
- so we lump everything together. */
-
- register int clipx1, clipx2, clipy1, clipy2;
-
- clipx1 = prgnDst->extents.x1;
- clipy1 = prgnDst->extents.y1;
- clipx2 = prgnDst->extents.x2;
- clipy2 = prgnDst->extents.y2;
-
- for (; ppt != pptLast; ppt++, pwidth++)
- {
- y = ppt->y;
- x1 = ppt->x;
- if (clipy1 <= y && y < clipy2)
- {
- x2 = x1 + *pwidth;
- if (x1 < clipx1) x1 = clipx1;
- if (x2 > clipx2) x2 = clipx2;
- if (x1 < x2)
- {
- /* part of span in clip rectangle */
- pptNew->x = x1;
- pptNew->y = y;
- *pwidthNew = x2 - x1;
- pptNew++;
- pwidthNew++;
- }
- }
- } /* end for */
-
- }
- else if (numRects = prgnDst->data->numRects)
- {
- /* Have to clip against many boxes */
- BoxPtr pboxBandStart, pboxBandEnd;
- register BoxPtr pbox;
- register BoxPtr pboxLast;
- register int clipy1, clipy2;
-
- /* In this case, taking advantage of sorted spans gains more than
- the sorting costs. */
- if ((! fSorted) && (nspans > 1))
- QuickSortSpans(ppt, pwidth, nspans);
-
- pboxBandStart = REGION_BOXPTR(prgnDst);
- pboxLast = pboxBandStart + numRects;
-
- NextBand();
-
- for (; ppt != pptLast; )
- {
- y = ppt->y;
- if (y < clipy2)
- {
- /* span is in the current band */
- pbox = pboxBandStart;
- x1 = ppt->x;
- x2 = x1 + *pwidth;
- do
- { /* For each box in band */
- register int newx1, newx2;
-
- newx1 = x1;
- newx2 = x2;
- if (newx1 < pbox->x1) newx1 = pbox->x1;
- if (newx2 > pbox->x2) newx2 = pbox->x2;
- if (newx1 < newx2)
- {
- /* Part of span in clip rectangle */
- pptNew->x = newx1;
- pptNew->y = y;
- *pwidthNew = newx2 - newx1;
- pptNew++;
- pwidthNew++;
- }
- pbox++;
- } while (pbox != pboxBandEnd);
- ppt++;
- pwidth++;
- }
- else
- {
- /* Move to next band, adjust ppt as needed */
- pboxBandStart = pboxBandEnd;
- if (pboxBandStart == pboxLast)
- break; /* We're completely done */
- NextBand();
- }
- }
- }
- return (pwidthNew - pwidthNewStart);
-}
-
-/* find the band in a region with the most rectangles */
-int
-miFindMaxBand(prgn)
- RegionPtr prgn;
-{
- register int nbox;
- register BoxPtr pbox;
- register int nThisBand;
- register int nMaxBand = 0;
- short yThisBand;
-
- good(prgn);
- nbox = REGION_NUM_RECTS(prgn);
- pbox = REGION_RECTS(prgn);
-
- while(nbox > 0)
- {
- yThisBand = pbox->y1;
- nThisBand = 0;
- while((nbox > 0) && (pbox->y1 == yThisBand))
- {
- nbox--;
- pbox++;
- nThisBand++;
- }
- if (nThisBand > nMaxBand)
- nMaxBand = nThisBand;
- }
- return (nMaxBand);
-}
diff --git a/programs/Xserver/panmi/mivaltree.c b/programs/Xserver/panmi/mivaltree.c
deleted file mode 100644
index ec41da679..000000000
--- a/programs/Xserver/panmi/mivaltree.c
+++ /dev/null
@@ -1,1282 +0,0 @@
-
-/****************************************************************
-* *
-* Copyright (c) Digital Equipment Corporation, 1991, 1997 *
-* *
-* All Rights Reserved. Unpublished rights reserved under *
-* the copyright laws of the United States. *
-* *
-* The software contained on this media is proprietary to *
-* and embodies the confidential technology of Digital *
-* Equipment Corporation. Possession, use, duplication or *
-* dissemination of the software and media is authorized only *
-* pursuant to a valid written license from Digital Equipment *
-* Corporation. *
-* *
-* RESTRICTED RIGHTS LEGEND Use, duplication, or disclosure *
-* by the U.S. Government is subject to restrictions as set *
-* forth in Subparagraph (c)(1)(ii) of DFARS 252.227-7013, *
-* or in FAR 52.227-19, as applicable. *
-* *
-*****************************************************************/
-/* $TOG: mivaltree.c /main/1 1997/10/29 13:27:56 kaleb $ */
-/*
- * mivaltree.c --
- * Functions for recalculating window clip lists. Main function
- * is miValidateTree.
- *
-
-Copyright (c) 1987, 1988, 1989 X Consortium
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-X CONSORTIUM 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 X Consortium 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 X Consortium.
-
- *
- * Copyright 1987, 1988, 1989 by
- * Digital Equipment Corporation, Maynard, Massachusetts,
- *
- * All Rights Reserved
- *
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose and without fee is hereby granted,
- * provided that the above copyright notice appear in all copies and that
- * both that copyright notice and this permission notice appear in
- * supporting documentation, and that the name of Digital not be
- * used in advertising or publicity pertaining to distribution of the
- * software without specific, written prior permission.
- *
- * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
- * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
- * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
- * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
- * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- *
- ******************************************************************/
-
- /*
- * Aug '86: Susan Angebranndt -- original code
- * July '87: Adam de Boor -- substantially modified and commented
- * Summer '89: Joel McCormack -- so fast you wouldn't believe it possible.
- * In particular, much improved code for window mapping and
- * circulating.
- * Bob Scheifler -- avoid miComputeClips for unmapped windows,
- * valdata changes
- */
-#include <stdio.h>
-#include "X.h"
-#include "scrnintstr.h"
-#include "validate.h"
-#include "windowstr.h"
-#include "mi.h"
-#include "regionstr.h"
-#include "mivalidate.h"
-#ifdef PANORAMIX
-#include "extensions/panoramiX.h"
-#endif
-
-#ifdef PANORAMIX
-extern Bool noPanoramiXExtension;
-extern Bool PanoramiXVisibilityNotifySent;
-extern int PanoramiXNumScreens;
-extern PanoramiXWindow *PanoramiXWinRoot;
-#endif
-
-#ifdef SHAPE
-/*
- * Compute the visibility of a shaped window
- */
-miShapedWindowIn (pScreen, universe, bounding, rect, x, y)
- ScreenPtr pScreen;
- RegionPtr universe, bounding;
- BoxPtr rect;
- register int x, y;
-{
- BoxRec box;
- register BoxPtr boundBox;
- int nbox;
- Bool someIn, someOut;
- register int t, x1, y1, x2, y2;
-
- nbox = REGION_NUM_RECTS (bounding);
- boundBox = REGION_RECTS (bounding);
- someIn = someOut = FALSE;
- x1 = rect->x1;
- y1 = rect->y1;
- x2 = rect->x2;
- y2 = rect->y2;
- while (nbox--)
- {
- if ((t = boundBox->x1 + x) < x1)
- t = x1;
- box.x1 = t;
- if ((t = boundBox->y1 + y) < y1)
- t = y1;
- box.y1 = t;
- if ((t = boundBox->x2 + x) > x2)
- t = x2;
- box.x2 = t;
- if ((t = boundBox->y2 + y) > y2)
- t = y2;
- box.y2 = t;
- if (box.x1 > box.x2)
- box.x2 = box.x1;
- if (box.y1 > box.y2)
- box.y2 = box.y1;
- switch (RECT_IN_REGION(pScreen, universe, &box))
- {
- case rgnIN:
- if (someOut)
- return rgnPART;
- someIn = TRUE;
- break;
- case rgnOUT:
- if (someIn)
- return rgnPART;
- someOut = TRUE;
- break;
- default:
- return rgnPART;
- }
- boundBox++;
- }
- if (someIn)
- return rgnIN;
- return rgnOUT;
-}
-#endif
-
-#define HasParentRelativeBorder(w) (!(w)->borderIsPixel && \
- HasBorder(w) && \
- (w)->backgroundState == ParentRelative)
-
-
-/*
- *-----------------------------------------------------------------------
- * miComputeClips --
- * Recompute the clipList, borderClip, exposed and borderExposed
- * regions for pParent and its children. Only viewable windows are
- * taken into account.
- *
- * Results:
- * None.
- *
- * Side Effects:
- * clipList, borderClip, exposed and borderExposed are altered.
- * A VisibilityNotify event may be generated on the parent window.
- *
- *-----------------------------------------------------------------------
- */
-static void
-miComputeClips (pParent, pScreen, universe, kind, exposed)
- register WindowPtr pParent;
- register ScreenPtr pScreen;
- register RegionPtr universe;
- VTKind kind;
- RegionPtr exposed; /* for intermediate calculations */
-{
- int dx,
- dy;
- RegionRec childUniverse;
- register WindowPtr pChild;
- int oldVis, newVis;
- BoxRec borderSize;
- RegionRec childUnion;
- Bool overlap;
- RegionPtr borderVisible;
- Bool resized;
- /*
- * Figure out the new visibility of this window.
- * The extent of the universe should be the same as the extent of
- * the borderSize region. If the window is unobscured, this rectangle
- * will be completely inside the universe (the universe will cover it
- * completely). If the window is completely obscured, none of the
- * universe will cover the rectangle.
- */
- borderSize.x1 = pParent->drawable.x - wBorderWidth(pParent);
- borderSize.y1 = pParent->drawable.y - wBorderWidth(pParent);
- dx = (int) pParent->drawable.x + (int) pParent->drawable.width + wBorderWidth(pParent);
- if (dx > 32767)
- dx = 32767;
- borderSize.x2 = dx;
- dy = (int) pParent->drawable.y + (int) pParent->drawable.height + wBorderWidth(pParent);
- if (dy > 32767)
- dy = 32767;
- borderSize.y2 = dy;
-
- oldVis = pParent->visibility;
- switch (RECT_IN_REGION( pScreen, universe, &borderSize))
- {
- case rgnIN:
- newVis = VisibilityUnobscured;
- break;
- case rgnPART:
- newVis = VisibilityPartiallyObscured;
-#ifdef SHAPE
- {
- RegionPtr pBounding;
-
- if ((pBounding = wBoundingShape (pParent)))
- {
- switch (miShapedWindowIn (pScreen, universe, pBounding,
- &borderSize,
- pParent->drawable.x,
- pParent->drawable.y))
- {
- case rgnIN:
- newVis = VisibilityUnobscured;
- break;
- case rgnOUT:
- newVis = VisibilityFullyObscured;
- break;
- }
- }
- }
-#endif
- break;
- default:
- newVis = VisibilityFullyObscured;
- break;
- }
- pParent->visibility = newVis;
- if (oldVis != newVis &&
- ((pParent->eventMask | wOtherEventMasks(pParent)) & VisibilityChangeMask))
- SendVisibilityNotify(pParent);
-
- dx = pParent->drawable.x - pParent->valdata->before.oldAbsCorner.x;
- dy = pParent->drawable.y - pParent->valdata->before.oldAbsCorner.y;
-
- /*
- * avoid computations when dealing with simple operations
- */
-
- switch (kind) {
- case VTMap:
- case VTStack:
- case VTUnmap:
- break;
- case VTMove:
- if ((oldVis == newVis) &&
- ((oldVis == VisibilityFullyObscured) ||
- (oldVis == VisibilityUnobscured)))
- {
- pChild = pParent;
- while (1)
- {
- if (pChild->viewable)
- {
- if (pChild->visibility != VisibilityFullyObscured)
- {
- REGION_TRANSLATE( pScreen, &pChild->borderClip,
- dx, dy);
- REGION_TRANSLATE( pScreen, &pChild->clipList,
- dx, dy);
- pChild->drawable.serialNumber = NEXT_SERIAL_NUMBER;
- if (pScreen->ClipNotify)
- (* pScreen->ClipNotify) (pChild, dx, dy);
-
- }
- if (pChild->valdata)
- {
- REGION_INIT(pScreen,
- &pChild->valdata->after.borderExposed,
- NullBox, 0);
- if (HasParentRelativeBorder(pChild))
- {
- REGION_SUBTRACT(pScreen,
- &pChild->valdata->after.borderExposed,
- &pChild->borderClip,
- &pChild->winSize);
- }
- REGION_INIT( pScreen, &pChild->valdata->after.exposed,
- NullBox, 0);
- }
- if (pChild->firstChild)
- {
- pChild = pChild->firstChild;
- continue;
- }
- }
- while (!pChild->nextSib && (pChild != pParent))
- pChild = pChild->parent;
- if (pChild == pParent)
- break;
- pChild = pChild->nextSib;
- }
- return;
- }
- /* fall through */
- default:
- /*
- * To calculate exposures correctly, we have to translate the old
- * borderClip and clipList regions to the window's new location so there
- * is a correspondence between pieces of the new and old clipping regions.
- */
- if (dx || dy)
- {
- /*
- * We translate the old clipList because that will be exposed or copied
- * if gravity is right.
- */
- REGION_TRANSLATE( pScreen, &pParent->borderClip, dx, dy);
- REGION_TRANSLATE( pScreen, &pParent->clipList, dx, dy);
- }
- break;
- }
-
- borderVisible = pParent->valdata->before.borderVisible;
- resized = pParent->valdata->before.resized;
- REGION_INIT( pScreen, &pParent->valdata->after.borderExposed, NullBox, 0);
- REGION_INIT( pScreen, &pParent->valdata->after.exposed, NullBox, 0);
-
- /*
- * Since the borderClip must not be clipped by the children, we do
- * the border exposure first...
- *
- * 'universe' is the window's borderClip. To figure the exposures, remove
- * the area that used to be exposed from the new.
- * This leaves a region of pieces that weren't exposed before.
- */
-
- if (HasBorder (pParent))
- {
- if (borderVisible)
- {
- /*
- * when the border changes shape, the old visible portions
- * of the border will be saved by DIX in borderVisible --
- * use that region and destroy it
- */
- REGION_SUBTRACT( pScreen, exposed, universe, borderVisible);
- REGION_DESTROY( pScreen, borderVisible);
- }
- else
- {
- REGION_SUBTRACT( pScreen, exposed, universe, &pParent->borderClip);
- }
- if (HasParentRelativeBorder(pParent) && (dx || dy))
- REGION_SUBTRACT( pScreen, &pParent->valdata->after.borderExposed,
- universe,
- &pParent->winSize);
- else
- REGION_SUBTRACT( pScreen, &pParent->valdata->after.borderExposed,
- exposed, &pParent->winSize);
-
- REGION_COPY( pScreen, &pParent->borderClip, universe);
-
- /*
- * To get the right clipList for the parent, and to make doubly sure
- * that no child overlaps the parent's border, we remove the parent's
- * border from the universe before proceeding.
- */
-
- REGION_INTERSECT( pScreen, universe, universe, &pParent->winSize);
- }
- else
- REGION_COPY( pScreen, &pParent->borderClip, universe);
-
- if ((pChild = pParent->firstChild) && pParent->mapped)
- {
- REGION_INIT(pScreen, &childUniverse, NullBox, 0);
- REGION_INIT(pScreen, &childUnion, NullBox, 0);
- if ((pChild->drawable.y < pParent->lastChild->drawable.y) ||
- ((pChild->drawable.y == pParent->lastChild->drawable.y) &&
- (pChild->drawable.x < pParent->lastChild->drawable.x)))
- {
- for (; pChild; pChild = pChild->nextSib)
- {
- if (pChild->viewable)
- REGION_APPEND( pScreen, &childUnion, &pChild->borderSize);
- }
- }
- else
- {
- for (pChild = pParent->lastChild; pChild; pChild = pChild->prevSib)
- {
- if (pChild->viewable)
- REGION_APPEND( pScreen, &childUnion, &pChild->borderSize);
- }
- }
- REGION_VALIDATE( pScreen, &childUnion, &overlap);
-
- for (pChild = pParent->firstChild;
- pChild;
- pChild = pChild->nextSib)
- {
- if (pChild->viewable) {
- /*
- * If the child is viewable, we want to remove its extents
- * from the current universe, but we only re-clip it if
- * it's been marked.
- */
- if (pChild->valdata) {
- /*
- * Figure out the new universe from the child's
- * perspective and recurse.
- */
- REGION_INTERSECT( pScreen, &childUniverse,
- universe,
- &pChild->borderSize);
- miComputeClips (pChild, pScreen, &childUniverse, kind,
- exposed);
- }
- /*
- * Once the child has been processed, we remove its extents
- * from the current universe, thus denying its space to any
- * other sibling.
- */
- if (overlap)
- REGION_SUBTRACT( pScreen, universe, universe,
- &pChild->borderSize);
- }
- }
- if (!overlap)
- REGION_SUBTRACT( pScreen, universe, universe, &childUnion);
- REGION_UNINIT( pScreen, &childUnion);
- REGION_UNINIT( pScreen, &childUniverse);
- } /* if any children */
-
- /*
- * 'universe' now contains the new clipList for the parent window.
- *
- * To figure the exposure of the window we subtract the old clip from the
- * new, just as for the border.
- */
-
- if (oldVis == VisibilityFullyObscured ||
- oldVis == VisibilityNotViewable)
- {
- REGION_COPY( pScreen, &pParent->valdata->after.exposed, universe);
- }
- else if (newVis != VisibilityFullyObscured &&
- newVis != VisibilityNotViewable)
- {
- REGION_SUBTRACT( pScreen, &pParent->valdata->after.exposed,
- universe, &pParent->clipList);
- }
-
- /*
- * One last thing: backing storage. We have to try to save what parts of
- * the window are about to be obscured. We can just subtract the universe
- * from the old clipList and get the areas that were in the old but aren't
- * in the new and, hence, are about to be obscured.
- */
- if (pParent->backStorage && !resized)
- {
- REGION_SUBTRACT( pScreen, exposed, &pParent->clipList, universe);
- (* pScreen->SaveDoomedAreas)(pParent, exposed, dx, dy);
- }
-
- /* HACK ALERT - copying contents of regions, instead of regions */
- {
- RegionRec tmp;
-
- tmp = pParent->clipList;
- pParent->clipList = *universe;
- *universe = tmp;
- }
-
-#ifdef NOTDEF
- REGION_COPY( pScreen, &pParent->clipList, universe);
-#endif
-
- pParent->drawable.serialNumber = NEXT_SERIAL_NUMBER;
-
- if (pScreen->ClipNotify)
- (* pScreen->ClipNotify) (pParent, dx, dy);
-}
-
-#ifdef PANORAMIX
-static void
-PanoramiXComputeClips (pParent, pScreen, universe, panoramiXuniverse, kind, exposed)
- register WindowPtr pParent;
- register ScreenPtr pScreen;
- register RegionPtr universe;
- register RegionPtr panoramiXuniverse;
- VTKind kind;
- RegionPtr exposed; /* for intermediate calculations */
-{
- int dx,
- dy;
- RegionRec childUniverse;
- register WindowPtr pChild;
- int oldVis, newVis, PanoramiXoldVis, PanoramiXnewVis;
- BoxRec borderSize;
- RegionRec childUnion;
- Bool overlap;
- RegionPtr borderVisible;
- Bool resized;
- RegionRec PanoramiXchildUniverse;
- int j, this_dx, this_dy;
- PanoramiXWindow *pPanoramiXWin = PanoramiXWinRoot;
- RegionRec PanoramiXborderSize;
- register WindowPtr pWin;
- RegionRec totalClip;
- RegionRec childClip;
-
- /*
- * Figure out the new visibility of this window.
- * The extent of the universe should be the same as the extent of
- * the borderSize region. If the window is unobscured, this rectangle
- * will be completely inside the universe (the universe will cover it
- * completely). If the window is completely obscured, none of the
- * universe will cover the rectangle.
- */
- borderSize.x1 = pParent->drawable.x - wBorderWidth(pParent);
- borderSize.y1 = pParent->drawable.y - wBorderWidth(pParent);
- dx = (int) pParent->drawable.x + (int) pParent->drawable.width + wBorderWidth(pParent);
- if (dx > 32767)
- dx = 32767;
- borderSize.x2 = dx;
- dy = (int) pParent->drawable.y + (int) pParent->drawable.height + wBorderWidth(pParent);
- if (dy > 32767)
- dy = 32767;
- borderSize.y2 = dy;
-
- /* Use the panoramiX values to determine visibility */
-
- oldVis = pParent->visibility;
- /* Get the visibility save in the PanoramiX data structure */
- j = pScreen->myNum;
- PANORAMIXFIND_ID_BY_SCRNUM(pPanoramiXWin, pParent->drawable.id, j);
- if ( pPanoramiXWin )
- PanoramiXoldVis = pPanoramiXWin->visibility;
- else
- PanoramiXoldVis = pParent->visibility;
- switch (RECT_IN_REGION( pScreen, panoramiXuniverse, &borderSize))
- {
- case rgnIN:
- PanoramiXnewVis = VisibilityUnobscured;
- break;
- case rgnPART:
- PanoramiXnewVis = VisibilityPartiallyObscured;
-#ifdef SHAPE
- {
- RegionPtr pBounding;
-
- if ((pBounding = wBoundingShape (pParent)))
- {
- switch (miShapedWindowIn (pScreen, panoramiXuniverse, pBounding,
- &borderSize,
- pParent->drawable.x,
- pParent->drawable.y))
- {
- case rgnIN:
- PanoramiXnewVis = VisibilityUnobscured;
- break;
- case rgnOUT:
- PanoramiXnewVis = VisibilityFullyObscured;
- break;
- }
- }
- }
-#endif
- break;
- default:
- PanoramiXnewVis = VisibilityFullyObscured;
- break;
- }
- if (pPanoramiXWin)
- pPanoramiXWin->visibility = PanoramiXnewVis;
-
- if (PanoramiXoldVis != PanoramiXnewVis && (!PanoramiXVisibilityNotifySent) &&
- ((pParent->eventMask | wOtherEventMasks(pParent)) & VisibilityChangeMask)) {
- pParent->visibility = PanoramiXnewVis;
- SendVisibilityNotify(pParent);
- PanoramiXVisibilityNotifySent = TRUE;
- pParent->visibility = oldVis;
- }
-
- switch (RECT_IN_REGION( pScreen, universe, &borderSize))
- {
- case rgnIN:
- newVis = VisibilityUnobscured;
- break;
- case rgnPART:
- newVis = VisibilityPartiallyObscured;
-#ifdef SHAPE
- {
- RegionPtr pBounding;
-
- if ((pBounding = wBoundingShape (pParent)))
- {
- switch (miShapedWindowIn (pScreen, universe, pBounding,
- &borderSize,
- pParent->drawable.x,
- pParent->drawable.y))
- {
- case rgnIN:
- newVis = VisibilityUnobscured;
- break;
- case rgnOUT:
- newVis = VisibilityFullyObscured;
- break;
- }
- }
- }
-#endif
- break;
- default:
- newVis = VisibilityFullyObscured;
- break;
- }
- pParent->visibility = newVis;
- /*
- if (oldVis != newVis &&
- ((pParent->eventMask | wOtherEventMasks(pParent)) & VisibilityChangeMask))
- SendVisibilityNotify(pParent);
- */
- dx = pParent->drawable.x - pParent->valdata->before.oldAbsCorner.x;
- dy = pParent->drawable.y - pParent->valdata->before.oldAbsCorner.y;
-
- /*
- * avoid computations when dealing with simple operations
- */
-
- switch (kind) {
- case VTMap:
- case VTStack:
- case VTUnmap:
- break;
- case VTMove:
- if ((oldVis == newVis) &&
- ((oldVis == VisibilityFullyObscured) ||
- (oldVis == VisibilityUnobscured)))
- {
- pChild = pParent;
- while (1)
- {
- if (pChild->viewable)
- {
- if (pChild->visibility != VisibilityFullyObscured)
- {
- REGION_TRANSLATE( pScreen, &pChild->borderClip,
- dx, dy);
- REGION_TRANSLATE( pScreen, &pChild->clipList,
- dx, dy);
- pChild->drawable.serialNumber = NEXT_SERIAL_NUMBER;
- if (pScreen->ClipNotify)
- (* pScreen->ClipNotify) (pChild, dx, dy);
-
- }
- if (pChild->valdata)
- {
- REGION_INIT(pScreen,
- &pChild->valdata->after.borderExposed,
- NullBox, 0);
- if (HasParentRelativeBorder(pChild))
- {
- REGION_SUBTRACT(pScreen,
- &pChild->valdata->after.borderExposed,
- &pChild->borderClip,
- &pChild->winSize);
- }
- REGION_INIT( pScreen, &pChild->valdata->after.exposed,
- NullBox, 0);
- }
- if (pChild->firstChild)
- {
- pChild = pChild->firstChild;
- continue;
- }
- }
- while (!pChild->nextSib && (pChild != pParent))
- pChild = pChild->parent;
- if (pChild == pParent)
- break;
- pChild = pChild->nextSib;
- }
- return;
- }
- /* fall through */
- default:
- /*
- * To calculate exposures correctly, we have to translate the old
- * borderClip and clipList regions to the window's new location so there
- * is a correspondence between pieces of the new and old clipping regions.
- */
- if (dx || dy)
- {
- /*
- * We translate the old clipList because that will be exposed or copied
- * if gravity is right.
- */
- REGION_TRANSLATE( pScreen, &pParent->borderClip, dx, dy);
- REGION_TRANSLATE( pScreen, &pParent->clipList, dx, dy);
- }
- break;
- }
-
- borderVisible = pParent->valdata->before.borderVisible;
- resized = pParent->valdata->before.resized;
- REGION_INIT( pScreen, &pParent->valdata->after.borderExposed, NullBox, 0);
- REGION_INIT( pScreen, &pParent->valdata->after.exposed, NullBox, 0);
-
- /*
- * Since the borderClip must not be clipped by the children, we do
- * the border exposure first...
- *
- * 'universe' is the window's borderClip. To figure the exposures, remove
- * the area that used to be exposed from the new.
- * This leaves a region of pieces that weren't exposed before.
- */
-
- if (HasBorder (pParent))
- {
- if (borderVisible)
- {
- /*
- * when the border changes shape, the old visible portions
- * of the border will be saved by DIX in borderVisible --
- * use that region and destroy it
- */
- REGION_SUBTRACT( pScreen, exposed, universe, borderVisible);
- REGION_DESTROY( pScreen, borderVisible);
- }
- else
- {
- REGION_SUBTRACT( pScreen, exposed, universe, &pParent->borderClip);
- }
- if (HasParentRelativeBorder(pParent) && (dx || dy))
- REGION_SUBTRACT( pScreen, &pParent->valdata->after.borderExposed,
- universe,
- &pParent->winSize);
- else
- REGION_SUBTRACT( pScreen, &pParent->valdata->after.borderExposed,
- exposed, &pParent->winSize);
-
- REGION_COPY( pScreen, &pParent->borderClip, universe);
-
- /*
- * To get the right clipList for the parent, and to make doubly sure
- * that no child overlaps the parent's border, we remove the parent's
- * border from the universe before proceeding.
- */
-
- REGION_INTERSECT( pScreen, universe, universe, &pParent->winSize);
- }
- else
- REGION_COPY( pScreen, &pParent->borderClip, universe);
-
- if ((pChild = pParent->firstChild) && pParent->mapped)
- {
- REGION_INIT(pScreen, &childUniverse, NullBox, 0);
- REGION_INIT(pScreen, &PanoramiXchildUniverse, NullBox, 0);
- REGION_INIT(pScreen, &childUnion, NullBox, 0);
- if ((pChild->drawable.y < pParent->lastChild->drawable.y) ||
- ((pChild->drawable.y == pParent->lastChild->drawable.y) &&
- (pChild->drawable.x < pParent->lastChild->drawable.x)))
- {
- for (; pChild; pChild = pChild->nextSib)
- {
- if (pChild->viewable)
- REGION_APPEND( pScreen, &childUnion, &pChild->borderSize);
- }
- }
- else
- {
- for (pChild = pParent->lastChild; pChild; pChild = pChild->prevSib)
- {
- if (pChild->viewable)
- REGION_APPEND( pScreen, &childUnion, &pChild->borderSize);
- }
- }
- REGION_VALIDATE( pScreen, &childUnion, &overlap);
-
- for (pChild = pParent->firstChild;
- pChild;
- pChild = pChild->nextSib)
- {
- if (pChild->viewable) {
- /*
- * If the child is viewable, we want to remove its extents
- * from the current universe, but we only re-clip it if
- * it's been marked.
- */
- if (pChild->valdata) {
- /*
- * Figure out the new universe from the child's
- * perspective and recurse.
- */
- REGION_INTERSECT( pScreen, &childUniverse, universe,
- &pChild->borderSize);
- REGION_INIT(pScreen, &PanoramiXborderSize, NullBox, 0);
- if ( kind == VTMove )
- PanoramiXClippedRegion(pChild, &PanoramiXborderSize,
- (pChild->borderSize.extents.x2 - pChild->drawable.width),
- (pChild->borderSize.extents.y2 - pChild->drawable.height),
- (pChild->drawable.width + wBorderWidth(pChild)),
- (pChild->drawable.height + wBorderWidth(pChild)));
- else
- PanoramiXClippedRegion(pChild, &PanoramiXborderSize,
- (pChild->drawable.x - wBorderWidth(pChild)),
- (pChild->drawable.y - wBorderWidth(pChild)),
- (pChild->drawable.width + (2*wBorderWidth(pChild))),
- (pChild->drawable.height + (2*wBorderWidth(pChild))));
- REGION_INTERSECT(pScreen, &PanoramiXchildUniverse, panoramiXuniverse,
- &PanoramiXborderSize);
- PanoramiXComputeClips (pChild, pScreen, &childUniverse, &PanoramiXchildUniverse, kind, exposed);
- }
- /*
- * Once the child has been processed, we remove its extents
- * from the current universe, thus denying its space to any
- * other sibling.
- */
- if (overlap)
- REGION_SUBTRACT( pScreen, universe, universe,
- &pChild->borderSize);
- }
- }
- if (!overlap)
- REGION_SUBTRACT( pScreen, universe, universe, &childUnion);
- REGION_UNINIT( pScreen, &childUnion);
- REGION_UNINIT( pScreen, &childUniverse);
- } /* if any children */
-
- /*
- * 'universe' now contains the new clipList for the parent window.
- *
- * To figure the exposure of the window we subtract the old clip from the
- * new, just as for the border.
- */
-
- if (oldVis == VisibilityFullyObscured ||
- oldVis == VisibilityNotViewable)
- {
- REGION_COPY( pScreen, &pParent->valdata->after.exposed, universe);
- }
- else if (newVis != VisibilityFullyObscured &&
- newVis != VisibilityNotViewable)
- {
- REGION_SUBTRACT( pScreen, &pParent->valdata->after.exposed,
- universe, &pParent->clipList);
- }
-
- /*
- * One last thing: backing storage. We have to try to save what parts of
- * the window are about to be obscured. We can just subtract the universe
- * from the old clipList and get the areas that were in the old but aren't
- * in the new and, hence, are about to be obscured.
- */
- if (pParent->backStorage && !resized)
- {
- REGION_SUBTRACT( pScreen, exposed, &pParent->clipList, universe);
- (* pScreen->SaveDoomedAreas)(pParent, exposed, dx, dy);
- }
-
- /* HACK ALERT - copying contents of regions, instead of regions */
- {
- RegionRec tmp;
-
- tmp = pParent->clipList;
- pParent->clipList = *universe;
- *universe = tmp;
- }
-
-#ifdef NOTDEF
- REGION_COPY( pScreen, &pParent->clipList, universe);
-#endif
-
- pParent->drawable.serialNumber = NEXT_SERIAL_NUMBER;
-
- if (pScreen->ClipNotify)
- (* pScreen->ClipNotify) (pParent, dx, dy);
-}
-#endif
-
-static void
-miTreeObscured(pParent)
- register WindowPtr pParent;
-{
- register WindowPtr pChild;
- register int oldVis;
-
- pChild = pParent;
- while (1)
- {
- if (pChild->viewable)
- {
- oldVis = pChild->visibility;
- if (oldVis != (pChild->visibility = VisibilityFullyObscured) &&
- ((pChild->eventMask | wOtherEventMasks(pChild)) & VisibilityChangeMask))
- SendVisibilityNotify(pChild);
- if (pChild->firstChild)
- {
- pChild = pChild->firstChild;
- continue;
- }
- }
- while (!pChild->nextSib && (pChild != pParent))
- pChild = pChild->parent;
- if (pChild == pParent)
- break;
- pChild = pChild->nextSib;
- }
-}
-
-/*-
- *-----------------------------------------------------------------------
- * miValidateTree --
- * Recomputes the clip list for pParent and all its inferiors.
- *
- * Results:
- * Always returns 1.
- *
- * Side Effects:
- * The clipList, borderClip, exposed, and borderExposed regions for
- * each marked window are altered.
- *
- * Notes:
- * This routine assumes that all affected windows have been marked
- * (valdata created) and their winSize and borderSize regions
- * adjusted to correspond to their new positions. The borderClip and
- * clipList regions should not have been touched.
- *
- * The top-most level is treated differently from all lower levels
- * because pParent is unchanged. For the top level, we merge the
- * regions taken up by the marked children back into the clipList
- * for pParent, thus forming a region from which the marked children
- * can claim their areas. For lower levels, where the old clipList
- * and borderClip are invalid, we can't do this and have to do the
- * extra operations done in miComputeClips, but this is much faster
- * e.g. when only one child has moved...
- *
- *-----------------------------------------------------------------------
- */
-/*ARGSUSED*/
-int
-miValidateTree (pParent, pChild, kind)
- WindowPtr pParent; /* Parent to validate */
- WindowPtr pChild; /* First child of pParent that was
- * affected */
- VTKind kind; /* What kind of configuration caused call */
-{
- RegionRec totalClip; /* Total clipping region available to
- * the marked children. pParent's clipList
- * merged with the borderClips of all
- * the marked children. */
- RegionRec childClip; /* The new borderClip for the current
- * child */
- RegionRec childUnion; /* the space covered by borderSize for
- * all marked children */
- RegionRec exposed; /* For intermediate calculations */
- register ScreenPtr pScreen;
- register WindowPtr pWin;
- Bool overlap;
- int viewvals;
- Bool forward;
-#ifdef PANORAMIX
- Bool OnScreen;
- RegionRec PanoramiXtotalClip; /* Total PanoramiX clipping region
- * available to the marked children. */
- RegionRec PanoramiXborderSize;
- RegionRec PanoramiXborderClip;
- RegionRec PanoramiXclipList;
- RegionRec PanoramiXchildClip;
-#endif
-
- pScreen = pParent->drawable.pScreen;
- if (pChild == NullWindow)
- pChild = pParent->firstChild;
-
- REGION_INIT(pScreen, &childClip, NullBox, 0);
- REGION_INIT(pScreen, &exposed, NullBox, 0);
-
- /*
- * compute the area of the parent window occupied
- * by the marked children + the parent itself. This
- * is the area which can be divied up among the marked
- * children in their new configuration.
- */
- REGION_INIT(pScreen, &totalClip, NullBox, 0);
-#ifdef PANORAMIX
- REGION_INIT(pScreen, &PanoramiXtotalClip, NullBox, 0);
- REGION_INIT(pScreen, &PanoramiXborderSize, NullBox, 0);
- REGION_INIT(pScreen, &PanoramiXborderClip, NullBox, 0);
- REGION_INIT(pScreen, &PanoramiXclipList, NullBox, 0);
- REGION_INIT(pScreen, &PanoramiXchildClip, NullBox, 0);
-#endif
- viewvals = 0;
- if ((pChild->drawable.y < pParent->lastChild->drawable.y) ||
- ((pChild->drawable.y == pParent->lastChild->drawable.y) &&
- (pChild->drawable.x < pParent->lastChild->drawable.x)))
- {
- forward = TRUE;
- for (pWin = pChild; pWin; pWin = pWin->nextSib)
- {
- if (pWin->valdata)
- {
- REGION_APPEND( pScreen, &totalClip, &pWin->borderClip);
-#ifdef PANORAMIX
- if (!noPanoramiXExtension) {
- REGION_INIT(pScreen, &PanoramiXborderClip, NullBox, 0);
- if ( kind == VTMove )
- PanoramiXClippedRegion(pWin, &PanoramiXborderClip,
- (pWin->borderClip.extents.x2 - pWin->drawable.width),
- (pWin->borderClip.extents.y2 - pWin->drawable.height ),
- (pWin->drawable.width + wBorderWidth(pWin)),
- (pWin->drawable.height + wBorderWidth(pWin)));
- else
- PanoramiXClippedRegion(pWin, &PanoramiXborderClip,
- (pWin->drawable.x - wBorderWidth(pWin)),
- (pWin->drawable.y - wBorderWidth(pWin)),
- (pWin->drawable.width + (2*wBorderWidth(pWin))),
- (pWin->drawable.height + (2*wBorderWidth(pWin))));
-
- REGION_APPEND( pScreen, &PanoramiXtotalClip, &PanoramiXborderClip);
- }
-#endif
- if (pWin->viewable)
- viewvals++;
- }
- }
- }
- else
- {
- forward = FALSE;
- pWin = pParent->lastChild;
- while (1)
- {
- if (pWin->valdata)
- {
- REGION_APPEND( pScreen, &totalClip, &pWin->borderClip);
-#ifdef PANORAMIX
- if (!noPanoramiXExtension) {
- REGION_INIT(pScreen, &PanoramiXborderClip, NullBox, 0);
- if ( kind == VTMove )
- PanoramiXClippedRegion(pWin, &PanoramiXborderClip,
- (pWin->borderClip.extents.x2 - pWin->drawable.width),
- (pWin->borderClip.extents.y2 - pWin->drawable.height),
- (pWin->drawable.width + wBorderWidth(pWin)),
- (pWin->drawable.height + wBorderWidth(pWin)));
- else
- PanoramiXClippedRegion(pWin, &PanoramiXborderClip,
- (pWin->drawable.x - wBorderWidth(pWin)),
- (pWin->drawable.y - wBorderWidth(pWin)),
- (pWin->drawable.width + (2*wBorderWidth(pWin))),
- (pWin->drawable.height + (2*wBorderWidth(pWin))));
- REGION_APPEND( pScreen, &PanoramiXtotalClip, &PanoramiXborderClip);
- }
-#endif
- if (pWin->viewable)
- viewvals++;
- }
- if (pWin == pChild)
- break;
- pWin = pWin->prevSib;
- }
- }
-#ifdef PANORAMIX
- if (!noPanoramiXExtension) {
- REGION_VALIDATE( pScreen, &PanoramiXtotalClip, &overlap);
- }
-#endif
- REGION_VALIDATE( pScreen, &totalClip, &overlap);
-
- /*
- * Now go through the children of the root and figure their new
- * borderClips from the totalClip, passing that off to miComputeClips
- * to handle recursively. Once that's done, we remove the child
- * from the totalClip to clip any siblings below it.
- */
-
- overlap = TRUE;
- if (kind != VTStack)
- {
-#ifdef PANORAMIX
- if (!noPanoramiXExtension) {
- REGION_INIT(pScreen, &PanoramiXclipList, NullBox, 0);
- /* This should be the Root window, use clipList if its a Move
- otherwise use the drawable x,y and widths, the areas might
- have been clipped away, assign clipList to get data section */
- if ( kind == VTMove )
- PanoramiXClippedRegion(pParent, &PanoramiXclipList,
- (pParent->clipList.extents.x2 - pParent->drawable.width),
- (pParent->clipList.extents.y2 - pParent->drawable.height),
- (pParent->drawable.width + wBorderWidth(pParent)),
- (pParent->drawable.height + wBorderWidth(pParent)));
- else
- PanoramiXClippedRegion(pParent, &PanoramiXclipList,
- (pParent->drawable.x - wBorderWidth(pParent)),
- (pParent->drawable.y - wBorderWidth(pParent)),
- (pParent->drawable.width + (2*wBorderWidth(pParent))),
- (pParent->drawable.height + (2*wBorderWidth(pParent))));
- REGION_UNION( pScreen, &PanoramiXtotalClip, &PanoramiXtotalClip, &PanoramiXclipList);
- }
-#endif
- REGION_UNION( pScreen, &totalClip, &totalClip, &pParent->clipList);
- if (viewvals > 1)
- {
- /*
- * precompute childUnion to discover whether any of them
- * overlap. This seems redundant, but performance studies
- * have demonstrated that the cost of this loop is
- * lower than the cost of multiple Subtracts in the
- * loop below.
- */
- REGION_INIT(pScreen, &childUnion, NullBox, 0);
- if (forward)
- {
- for (pWin = pChild; pWin; pWin = pWin->nextSib)
- if (pWin->valdata && pWin->viewable)
- REGION_APPEND( pScreen, &childUnion,
- &pWin->borderSize);
- }
- else
- {
- pWin = pParent->lastChild;
- while (1)
- {
- if (pWin->valdata && pWin->viewable)
- REGION_APPEND( pScreen, &childUnion,
- &pWin->borderSize);
- if (pWin == pChild)
- break;
- pWin = pWin->prevSib;
- }
- }
- REGION_VALIDATE(pScreen, &childUnion, &overlap);
- if (overlap)
- REGION_UNINIT(pScreen, &childUnion);
- }
- }
-
- for (pWin = pChild;
- pWin != NullWindow;
- pWin = pWin->nextSib)
- {
- if (pWin->viewable) {
- if (pWin->valdata) {
- REGION_INTERSECT( pScreen, &childClip,
- &totalClip,
- &pWin->borderSize);
-#ifdef PANORAMIX
- if (!noPanoramiXExtension) {
- REGION_INIT(pScreen, &PanoramiXborderSize, NullBox, 0);
- if ( kind == VTMove )
- PanoramiXClippedRegion(pWin, &PanoramiXborderSize,
- (pWin->borderSize.extents.x2 - pWin->drawable.width),
- (pWin->borderSize.extents.y2 - pWin->drawable.height),
- (pWin->drawable.width + wBorderWidth(pWin)),
- (pWin->drawable.height + wBorderWidth(pWin)));
- else
- PanoramiXClippedRegion(pWin, &PanoramiXborderSize,
- (pWin->drawable.x - wBorderWidth(pWin)),
- (pWin->drawable.y - wBorderWidth(pWin)),
- (pWin->drawable.width + (2*wBorderWidth(pWin))),
- (pWin->drawable.height + (2*wBorderWidth(pWin))));
- if (miRegionDataCopy(&PanoramiXtotalClip, &totalClip)) {
- /* somehow the data portion of childClip needs to get tacked
- onto PanoramiXchildClip, when data is lost this results in
- incorrect determination of the windows visibility */
-
- REGION_INTERSECT( pScreen, &PanoramiXchildClip, &PanoramiXtotalClip, &PanoramiXborderSize);
-
- PanoramiXComputeClips (pWin, pScreen, &childClip, &PanoramiXchildClip, kind, &exposed);
- }else
- miComputeClips (pWin, pScreen, &childClip, kind, &exposed);
- }else
- miComputeClips (pWin, pScreen, &childClip, kind, &exposed);
-
-#else
- miComputeClips (pWin, pScreen, &childClip, kind, &exposed);
-#endif
- if (overlap)
- {
- REGION_SUBTRACT( pScreen, &totalClip,
- &totalClip,
- &pWin->borderSize);
-#ifdef PANORAMIX
- if (!noPanoramiXExtension){
- REGION_SUBTRACT( pScreen, &PanoramiXtotalClip,
- &PanoramiXtotalClip,
- &PanoramiXborderSize);
- }
-#endif
- }
- } else if (pWin->visibility == VisibilityNotViewable) {
- miTreeObscured(pWin);
- }
- } else {
- if (pWin->valdata) {
- REGION_EMPTY( pScreen, &pWin->clipList);
- if (pScreen->ClipNotify)
- (* pScreen->ClipNotify) (pWin, 0, 0);
- REGION_EMPTY( pScreen, &pWin->borderClip);
- pWin->valdata = (ValidatePtr)NULL;
- }
- }
- }
-
- REGION_UNINIT( pScreen, &childClip);
-#ifdef PANORAMIX
- REGION_UNINIT(pScreen, &PanoramiXchildClip);
-#endif
- if (!overlap)
- {
- REGION_SUBTRACT(pScreen, &totalClip, &totalClip, &childUnion);
- REGION_UNINIT(pScreen, &childUnion);
- }
-
- REGION_INIT( pScreen, &pParent->valdata->after.exposed, NullBox, 0);
- REGION_INIT( pScreen, &pParent->valdata->after.borderExposed, NullBox, 0);
-
- /*
- * each case below is responsible for updating the
- * clipList and serial number for the parent window
- */
-
- switch (kind) {
- case VTStack:
- break;
- default:
- /*
- * totalClip contains the new clipList for the parent. Figure out
- * exposures and obscures as per miComputeClips and reset the parent's
- * clipList.
- */
- REGION_SUBTRACT( pScreen, &pParent->valdata->after.exposed,
- &totalClip, &pParent->clipList);
- /* fall through */
- case VTMap:
- if (pParent->backStorage) {
- REGION_SUBTRACT( pScreen, &exposed, &pParent->clipList, &totalClip);
- (* pScreen->SaveDoomedAreas)(pParent, &exposed, 0, 0);
- }
-
- REGION_COPY( pScreen, &pParent->clipList, &totalClip);
- pParent->drawable.serialNumber = NEXT_SERIAL_NUMBER;
- break;
- }
-
- REGION_UNINIT( pScreen, &totalClip);
- REGION_UNINIT( pScreen, &exposed);
-#ifdef PANORAMIX
- REGION_UNINIT(pScreen, &PanoramiXtotalClip);
- REGION_UNINIT(pScreen, &PanoramiXborderSize);
- REGION_UNINIT(pScreen, &PanoramiXborderClip);
- REGION_UNINIT(pScreen, &PanoramiXclipList);
-#endif
- if (pScreen->ClipNotify)
- (*pScreen->ClipNotify) (pParent, 0, 0);
- return (1);
-}
diff --git a/programs/appres/appres.man b/programs/appres/appres.man
index 0970fba0c..a4dab42f4 100644
--- a/programs/appres/appres.man
+++ b/programs/appres/appres.man
@@ -1,4 +1,4 @@
-.\" $TOG: appres.man /main/15 1997/11/04 20:54:46 kaleb $
+.\" $XConsortium: appres.man /main/14 1996/12/09 17:06:25 kaleb $
.\" Copyright (c) 1993, 1994 X Consortium
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
@@ -24,7 +24,7 @@
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
-.TH APPRES 1 "Release 6.4" "X Version 11"
+.TH APPRES 1 "Release 6.3" "X Version 11"
.SH NAME
appres \- list X application resource database
.SH SYNOPSIS
diff --git a/programs/bdftopcf/bdftopcf.man b/programs/bdftopcf/bdftopcf.man
index f0e8b7d46..1e54947f1 100644
--- a/programs/bdftopcf/bdftopcf.man
+++ b/programs/bdftopcf/bdftopcf.man
@@ -1,4 +1,4 @@
-.\" $TOG: bdftopcf.man /main/9 1997/11/04 20:54:51 kaleb $
+.\" $XConsortium: bdftopcf.man /main/8 1996/12/09 17:06:31 kaleb $
.\" Copyright (c) 1993, 1994 X Consortium
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
@@ -24,7 +24,7 @@
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
-.TH BDFTOPCF 1 "Release 6.4" "X Version 11"
+.TH BDFTOPCF 1 "Release 6.3" "X Version 11"
.SH NAME
bdftopcf \- convert X font from Bitmap Distribution Format to Portable
Compiled Format
diff --git a/programs/bitmap/bitmap.man b/programs/bitmap/bitmap.man
index 0f5d37d23..6dff1b49f 100644
--- a/programs/bitmap/bitmap.man
+++ b/programs/bitmap/bitmap.man
@@ -1,4 +1,4 @@
-.\" $TOG: bitmap.man /main/19 1997/11/04 20:54:56 kaleb $
+.\" $XConsortium: bitmap.man /main/18 1996/12/09 17:06:36 kaleb $
.\" Copyright (c) 1993 X Consortium
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
@@ -24,7 +24,7 @@
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
-.TH BITMAP 1 "Release 6.4" "X Version 11"
+.TH BITMAP 1 "Release 6.3" "X Version 11"
.SH NAME
bitmap, bmtoa, atobm \- bitmap editor and converter utilities for the X Window System
.SH SYNOPSIS
diff --git a/programs/editres/editres.man b/programs/editres/editres.man
index 58984d39e..a15ebaa18 100644
--- a/programs/editres/editres.man
+++ b/programs/editres/editres.man
@@ -1,4 +1,4 @@
-.\" $TOG: editres.man /main/15 1997/11/04 20:55:00 kaleb $
+.\" $XConsortium: editres.man /main/14 1996/12/09 17:06:42 kaleb $
.\" Copyright (c) 1993,1994 X Consortium
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
@@ -24,7 +24,7 @@
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
-.TH EDITRES 1 "Release 6.4" "X Version 11"
+.TH EDITRES 1 "Release 6.3" "X Version 11"
.SH NAME
editres \- a dynamic resource editor for X Toolkit applications
.SH SYNTAX
diff --git a/programs/fsinfo/fsinfo.man b/programs/fsinfo/fsinfo.man
index d026202da..e5ec324ff 100644
--- a/programs/fsinfo/fsinfo.man
+++ b/programs/fsinfo/fsinfo.man
@@ -1,4 +1,4 @@
-.\" $TOG: fsinfo.man /main/9 1997/11/04 20:55:04 kaleb $
+.\" $XConsortium: fsinfo.man /main/8 1996/12/09 17:06:47 kaleb $
.\" Copyright 1991, Network Computing Devices, Inc
.\" Copyright (c) 1993 X Consortium
.\"
@@ -25,7 +25,7 @@
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
-.TH FSINFO 1 "Release 6.4" "X Version 11"
+.TH FSINFO 1 "Release 6.3" "X Version 11"
.SH NAME
fsinfo \- X font server information utility
.SH SYNOPSIS
diff --git a/programs/fslsfonts/fslsfonts.man b/programs/fslsfonts/fslsfonts.man
index db4c5b570..a2a392022 100644
--- a/programs/fslsfonts/fslsfonts.man
+++ b/programs/fslsfonts/fslsfonts.man
@@ -1,4 +1,4 @@
-.\" $TOG: fslsfonts.man /main/9 1997/11/04 20:55:08 kaleb $
+.\" $XConsortium: fslsfonts.man /main/8 1996/12/09 17:06:51 kaleb $
.\" Copyright 1991, Network Computing Devices, Inc
.\" Copyright (c) 1993, 1994 X Consortium
.\"
@@ -25,7 +25,7 @@
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
-.TH FSLSFONTS 1 "Release 6.4" "X Version 11"
+.TH FSLSFONTS 1 "Release 6.3" "X Version 11"
.SH NAME
fslsfonts \- list fonts served by X font server
.SH SYNOPSIS
diff --git a/programs/fstobdf/fstobdf.man b/programs/fstobdf/fstobdf.man
index cee7a54fe..3c94e0a2a 100644
--- a/programs/fstobdf/fstobdf.man
+++ b/programs/fstobdf/fstobdf.man
@@ -1,4 +1,4 @@
-.\" $TOG: fstobdf.man /main/9 1997/11/04 20:55:11 kaleb $
+.\" $XConsortium: fstobdf.man /main/8 1996/12/09 17:06:55 kaleb $
.\" Copyright 1990, Network Computing Devices
.\" Copyright (c) 1990 X Consortium
.\"
@@ -25,7 +25,7 @@
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
-.TH FSTOBDF 1 "Release 6.4" "X Version 11"
+.TH FSTOBDF 1 "Release 6.3" "X Version 11"
.SH NAME
fstobdf \- generate BDF font from X font server
.SH SYNOPSIS
diff --git a/programs/iceauth/iceauth.man b/programs/iceauth/iceauth.man
index f9d30e45d..e25d52a72 100644
--- a/programs/iceauth/iceauth.man
+++ b/programs/iceauth/iceauth.man
@@ -1,4 +1,4 @@
-.\" $TOG: iceauth.man /main/7 1997/11/04 20:55:15 kaleb $
+.\" $XConsortium: iceauth.man /main/6 1996/12/09 17:07:00 kaleb $
.\" Copyright (c) 1994 X Consortium
.\"
@@ -24,7 +24,7 @@
.\" be used in advertising or otherwise to promote the sale, use or other
.\" dealing in this Software without prior written authorization from the
.\" X Consortium.
-.TH ICEAUTH 1 "Release 6.4" "X Version 11"
+.TH ICEAUTH 1 "Release 6.3" "X Version 11"
.SH NAME
iceauth \- ICE authority file utility
.SH SYNOPSIS
diff --git a/programs/lbxproxy/lbxproxy.man b/programs/lbxproxy/lbxproxy.man
index b0ac38f5a..ea6cd39b3 100644
--- a/programs/lbxproxy/lbxproxy.man
+++ b/programs/lbxproxy/lbxproxy.man
@@ -1,4 +1,4 @@
-.\" $TOG: lbxproxy.man /main/13 1997/11/04 20:55:18 kaleb $
+.\" $TOG: lbxproxy.man /main/12 1997/10/10 14:04:20 barstow $
.\" Copyright (c) 1996 X Consortium
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
@@ -25,7 +25,7 @@
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
.\"
-.TH LBXPROXY 1 "Release 6.4" "X Version 11"
+.TH LBXPROXY 1 "Release 6.3" "X Version 11"
.SH NAME
lbxproxy - Low BandWidth X proxy
.SH SYNOPSIS
diff --git a/programs/mkfontdir/mkfontdir.man b/programs/mkfontdir/mkfontdir.man
index 26c040459..c75957416 100644
--- a/programs/mkfontdir/mkfontdir.man
+++ b/programs/mkfontdir/mkfontdir.man
@@ -1,4 +1,4 @@
-.\" $TOG: mkfontdir.man /main/14 1997/11/04 20:55:22 kaleb $
+.\" $XConsortium: mkfontdir.man /main/13 1996/12/09 17:07:06 kaleb $
.\" Copyright (c) 1993, 1994 X Consortium
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
@@ -24,7 +24,7 @@
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
-.TH MKFONTDIR 1 "Release 6.4" "X Version 11"
+.TH MKFONTDIR 1 "Release 6.3" "X Version 11"
.SH NAME
mkfontdir, fonts.dir, fonts.scale, fonts.alias \- create an index of X font files in a directory
.SH SYNOPSIS
diff --git a/programs/oclock/oclock.man b/programs/oclock/oclock.man
index 4e9d96587..09d4528b6 100644
--- a/programs/oclock/oclock.man
+++ b/programs/oclock/oclock.man
@@ -1,4 +1,4 @@
-.\" $TOG: oclock.man /main/18 1997/11/04 20:55:27 kaleb $
+.\" $XConsortium: oclock.man /main/17 1996/12/09 17:07:12 kaleb $
.\" Copyright (c) 1989 X Consortium
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
@@ -24,7 +24,7 @@
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
-.TH OCLOCK 1 "Release 6.4" "X Version 11"
+.TH OCLOCK 1 "Release 6.3" "X Version 11"
.SH NAME
oclock \- round X clock
.SH SYNOPSIS
diff --git a/programs/proxymngr/proxymngr.man b/programs/proxymngr/proxymngr.man
index 96b3ea5c6..a2b738bf5 100644
--- a/programs/proxymngr/proxymngr.man
+++ b/programs/proxymngr/proxymngr.man
@@ -1,4 +1,4 @@
-.\" $TOG: proxymngr.man /main/4 1997/11/04 20:55:30 kaleb $
+.\" $XConsortium: proxymngr.man /main/3 1996/12/20 14:20:39 swick $
.\" Copyright (c) 1996 X Consortium
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
@@ -25,7 +25,7 @@
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
.\"
-.TH PROXYMNGR 1 "Release 6.4" "X Version 11"
+.TH PROXYMNGR 1 "Release 6.3" "X Version 11"
.SH NAME
proxymngr - proxy manager service
.SH SYNOPSIS
@@ -75,7 +75,7 @@ requests are received and proxies are started.
.PP
The proxy manager maintains a local configuration file describing the proxy
services available. This configuration file is installed
-in /usr/X11R6.4/lib/X11/proxymngr/pmconfig during the installation
+in /usr/X11R6.3/lib/X11/proxymngr/pmconfig during the installation
of proxymngr. The location of the configuration file can be overwritten using
the \fB\-config\fP command line option.
.PP
@@ -127,7 +127,7 @@ Here is a sample configuration file:
! or
! <serviceName> unmanaged <proxyAddress>
!
-lbx managed /usr/X11R6.4/bin/lbxproxy
+lbx managed /usr/X11R6.3/bin/lbxproxy
!
! substitute site-specific info
xfwp unmanaged firewall:4444
diff --git a/programs/rgb/showrgb.man b/programs/rgb/showrgb.man
index a61fe55b2..cf89903c0 100644
--- a/programs/rgb/showrgb.man
+++ b/programs/rgb/showrgb.man
@@ -1,4 +1,4 @@
-.\" $TOG: showrgb.man /main/8 1997/11/04 20:55:34 kaleb $
+.\" $XConsortium: showrgb.man /main/7 1996/12/09 17:07:18 kaleb $
.\" Copyright (c) 1993 X Consortium
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
@@ -24,7 +24,7 @@
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
-.TH SHOWRGB 1 "Release 6.4" "X Version 11"
+.TH SHOWRGB 1 "Release 6.3" "X Version 11"
.SH NAME
showrgb \- uncompile an rgb color-name database
.SH SYNOPSIS
diff --git a/programs/rstart/rstart.man b/programs/rstart/rstart.man
index 841b26140..f64c7d955 100644
--- a/programs/rstart/rstart.man
+++ b/programs/rstart/rstart.man
@@ -1,4 +1,4 @@
-.\" $TOG: rstart.man /main/7 1997/11/04 20:55:41 kaleb $
+.\" $XConsortium: rstart.man /main/6 1996/12/09 17:07:24 kaleb $
.\" Copyright (c) 1993 Quarterdeck Office Systems
.\"
.\" Permission to use, copy, modify, distribute, and sell this software and
@@ -33,7 +33,7 @@
.if t .sp .5
..
.ta .3i .6i .9i 1.2i 1.5i 1.8i
-.TH RSTART 1 "Release 6.4" "X Version 11"
+.TH RSTART 1 "Release 6.3" "X Version 11"
.SH NAME
rstart - a sample implementation of a Remote Start client
.SH SYNOPSIS
diff --git a/programs/rstart/rstartd.man b/programs/rstart/rstartd.man
index 6131a02c9..a83228de9 100644
--- a/programs/rstart/rstartd.man
+++ b/programs/rstart/rstartd.man
@@ -1,4 +1,4 @@
-.\" $TOG: rstartd.man /main/6 1997/11/04 20:55:38 kaleb $
+.\" $XConsortium: rstartd.man /main/5 1996/12/09 17:07:28 kaleb $
.\" Copyright (c) 1993 Quarterdeck Office Systems
.\"
.\" Permission to use, copy, modify, distribute, and sell this software and
@@ -33,7 +33,7 @@
.if t .sp .5
..
.ta .3i .6i .9i 1.2i 1.5i 1.8i
-.TH RSTARTD 1 "Release 6.4" "X Version 11"
+.TH RSTARTD 1 "Release 6.3" "X Version 11"
.SH NAME
rstartd - a sample implementation of a Remote Start rsh helper
.SH SYNOPSIS
diff --git a/programs/scripts/xon.man b/programs/scripts/xon.man
index be1ff2edd..c8ae818ed 100644
--- a/programs/scripts/xon.man
+++ b/programs/scripts/xon.man
@@ -1,4 +1,4 @@
-.\" $TOG: xon.man /main/9 1997/11/04 20:55:45 kaleb $
+.\" $XConsortium: xon.man /main/8 1996/12/09 17:07:34 kaleb $
.\" Copyright (c) 1994 X Consortium
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining a
@@ -23,7 +23,7 @@
.\" be used in advertising or otherwise to promote the sale, use or other
.\" dealing in this Software without prior written authorization from the
.\" X Consortium.
-.TH XON 1 "Release 6.4" "X Version 11"
+.TH XON 1 "Release 6.3" "X Version 11"
.SH NAME
xon \- start an X program on a remote machine
.SH SYNOPSIS
diff --git a/programs/smproxy/smproxy.man b/programs/smproxy/smproxy.man
index c8883a1e5..9577c8c35 100644
--- a/programs/smproxy/smproxy.man
+++ b/programs/smproxy/smproxy.man
@@ -1,4 +1,4 @@
-.\" $TOG: smproxy.man /main/4 1997/11/04 20:55:48 kaleb $
+.\" $XConsortium: smproxy.man /main/3 1996/12/09 17:07:39 kaleb $
.\" Copyright (c) 1994 X Consortium
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
@@ -24,7 +24,7 @@
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
-.TH XSM 1 "Release 6.4" "X Version 11"
+.TH XSM 1 "Release 6.3" "X Version 11"
.SH NAME
smproxy \- Session Manager Proxy
.SH SYNOPSIS
diff --git a/programs/twm/twm.man b/programs/twm/twm.man
index faab54a34..5aa064750 100644
--- a/programs/twm/twm.man
+++ b/programs/twm/twm.man
@@ -1,4 +1,4 @@
-.\" $TOG: twm.man /main/66 1997/11/04 20:55:52 kaleb $
+.\" $XConsortium: twm.man /main/65 1996/12/09 17:07:44 kaleb $
.\" Copyright (c) 1993, 1994 X Consortium
.\" Portions copyright 1988 Evans & Sutherland Computer Corporation.
.\" Portions copyright 1989 Hewlett-Packard Company
@@ -40,7 +40,7 @@
.if t .sp .5
..
.ta .3i .6i .9i 1.2i 1.5i 1.8i
-.TH TWM 1 "Release 6.4" "X Version 11"
+.TH TWM 1 "Release 6.3" "X Version 11"
.SH NAME
twm \- Tab Window Manager for the X Window System
.SH SYNTAX
diff --git a/programs/x11perf/x11pcomp.man b/programs/x11perf/x11pcomp.man
index a5b91ba4f..4fabc42b7 100644
--- a/programs/x11perf/x11pcomp.man
+++ b/programs/x11perf/x11pcomp.man
@@ -1,4 +1,4 @@
-.\" $TOG: x11pcomp.man /main/9 1997/11/04 20:55:58 kaleb $
+.\" $XConsortium: x11pcomp.man /main/8 1996/12/09 17:07:51 kaleb $
.\" Copyright (c) 1993, 1994 X Consortium
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
@@ -24,7 +24,7 @@
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
-.TH X11PERFCOMP 1 "Release 6.4" "X Version 11"
+.TH X11PERFCOMP 1 "Release 6.3" "X Version 11"
.SH NAME
x11perfcomp \- X11 server performance comparison program
.SH SYNTAX
diff --git a/programs/x11perf/x11perf.man b/programs/x11perf/x11perf.man
index 8dfc28420..33dbaefea 100644
--- a/programs/x11perf/x11perf.man
+++ b/programs/x11perf/x11perf.man
@@ -1,4 +1,4 @@
-.\" $TOG: x11perf.man /main/27 1997/11/04 20:56:02 kaleb $
+.\" $XConsortium: x11perf.man /main/26 1996/12/09 17:07:55 kaleb $
.\" Copyright 1988, 1989 Digital Equipment Corporation.
.\" Copyright (c) 1989, 1994 X Consortium
.\"
@@ -25,7 +25,7 @@
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
-.TH X11PERF 1 "Release 6.4" "X Version 11"
+.TH X11PERF 1 "Release 6.3" "X Version 11"
.SH NAME
x11perf \- X11 server performance test program
.SH SYNTAX
diff --git a/programs/xauth/xauth.man b/programs/xauth/xauth.man
index 75f68b4a2..2e7e9bb2b 100644
--- a/programs/xauth/xauth.man
+++ b/programs/xauth/xauth.man
@@ -1,4 +1,4 @@
-.\" $TOG: xauth.man /main/16 1997/11/04 20:56:07 kaleb $
+.\" $XConsortium: xauth.man /main/15 1996/12/09 17:08:01 kaleb $
.\" Copyright (c) 1993 X Consortium
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
@@ -24,7 +24,7 @@
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
-.TH XAUTH 1 "Release 6.4" "X Version 11"
+.TH XAUTH 1 "Release 6.3" "X Version 11"
.SH NAME
xauth \- X authority file utility
.SH SYNOPSIS
diff --git a/programs/xclipboard/xclipboard.man b/programs/xclipboard/xclipboard.man
index 3081aafe4..c3bde3617 100644
--- a/programs/xclipboard/xclipboard.man
+++ b/programs/xclipboard/xclipboard.man
@@ -1,4 +1,4 @@
-.\" $TOG: xclipboard.man /main/16 1997/11/04 20:56:11 kaleb $
+.\" $XConsortium: xclipboard.man /main/15 1996/12/09 17:08:06 kaleb $
.\" Copyright (c) 1988, 1994 X Consortium
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
@@ -24,7 +24,7 @@
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
-.TH XCLIPBOARD 1 "Release 6.4" "X Version 11"
+.TH XCLIPBOARD 1 "Release 6.3" "X Version 11"
.SH NAME
xclipboard \- X clipboard client
.SH SYNOPSIS
diff --git a/programs/xclipboard/xcutsel.man b/programs/xclipboard/xcutsel.man
index 2830664db..4d5c4c7e1 100644
--- a/programs/xclipboard/xcutsel.man
+++ b/programs/xclipboard/xcutsel.man
@@ -1,4 +1,4 @@
-.\" $TOG: xcutsel.man /main/15 1997/11/04 20:56:15 kaleb $
+.\" $XConsortium: xcutsel.man /main/14 1996/12/09 17:08:18 kaleb $
.\" Copyright (c) 1994 X Consortium
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
@@ -24,7 +24,7 @@
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
-.TH XCUTSEL 1 "Release 6.4" "X Version 11"
+.TH XCUTSEL 1 "Release 6.3" "X Version 11"
.SH NAME
xcutsel - interchange between cut buffer and selection
.SH SYNOPSIS
diff --git a/programs/xclock/xclock.man b/programs/xclock/xclock.man
index 84f607294..70c85337a 100644
--- a/programs/xclock/xclock.man
+++ b/programs/xclock/xclock.man
@@ -1,4 +1,4 @@
-.\" $TOG: xclock.man /main/28 1997/11/04 20:56:18 kaleb $
+.\" $XConsortium: xclock.man /main/27 1996/12/09 17:08:23 kaleb $
.\" Copyright (c) 1988, 1994 X Consortium
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
@@ -24,7 +24,7 @@
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
-.TH XCLOCK 1 "Release 6.4" "X Version 11"
+.TH XCLOCK 1 "Release 6.3" "X Version 11"
.SH NAME
xclock \- analog / digital clock for X
.SH SYNOPSIS
diff --git a/programs/xcmsdb/xcmsdb.man b/programs/xcmsdb/xcmsdb.man
index 1e0640ce3..26d98c97d 100644
--- a/programs/xcmsdb/xcmsdb.man
+++ b/programs/xcmsdb/xcmsdb.man
@@ -1,4 +1,4 @@
-.\" $TOG: xcmsdb.man /main/12 1997/11/04 20:56:22 kaleb $
+.\" $XConsortium: xcmsdb.man /main/11 1996/12/09 17:08:29 kaleb $
.\" Copyright 1990, Tektronix Inc.
.\" Copyright (c) 1993 X Consortium
.\"
@@ -24,7 +24,7 @@
.\" be used in advertising or otherwise to promote the sale, use or other
.\" dealing in this Software without prior written authorization from the
.\" X Consortium.
-.TH XCMSDB 1 "Release 6.4" "X Version 11"
+.TH XCMSDB 1 "Release 6.3" "X Version 11"
.SH NAME
xcmsdb \- Device Color Characterization utility for X Color Management System
.SH SYNOPSIS
diff --git a/programs/xconsole/xconsole.man b/programs/xconsole/xconsole.man
index c28a1f55d..17e1d05f5 100644
--- a/programs/xconsole/xconsole.man
+++ b/programs/xconsole/xconsole.man
@@ -1,4 +1,4 @@
-.\" $TOG: xconsole.man /main/11 1997/11/04 20:56:27 kaleb $
+.\" $XConsortium: xconsole.man /main/10 1996/12/09 17:08:33 kaleb $
.\" Copyright (c) 1994 X Consortium
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining a
@@ -23,7 +23,7 @@
.\" be used in advertising or otherwise to promote the sale, use or other
.\" dealing in this Software without prior written authorization from the
.\" X Consortium.
-.TH XCONSOLE 1 "Release 6.4" "X Version 11"
+.TH XCONSOLE 1 "Release 6.3" "X Version 11"
.SH NAME
xconsole \- monitor system console messages with X
.SH SYNOPSIS
diff --git a/programs/xdm/sessreg.man b/programs/xdm/sessreg.man
index 8c1f6b7a7..ad167452a 100644
--- a/programs/xdm/sessreg.man
+++ b/programs/xdm/sessreg.man
@@ -1,4 +1,4 @@
-.\" $TOG: sessreg.man /main/16 1997/11/04 20:56:30 kaleb $
+.\" $XConsortium: sessreg.man /main/15 1996/12/09 17:08:38 kaleb $
.\" Copyright (c) 1994 X Consortium
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
@@ -24,7 +24,7 @@
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
-.TH SESSREG 1 "Release 6.4" "X Version 11"
+.TH SESSREG 1 "Release 6.3" "X Version 11"
.SH NAME
sessreg \- manage utmp/wtmp entries for non-init clients
.SH SYNOPSIS
diff --git a/programs/xdm/xdm.man b/programs/xdm/xdm.man
index fe67d0e3b..78159c165 100644
--- a/programs/xdm/xdm.man
+++ b/programs/xdm/xdm.man
@@ -1,5 +1,4 @@
-.\" $TOG: xdm.man /main/45 1997/11/04 20:56:34 kaleb $
-.\" $XFree86: xc/programs/xdm/xdm.man,v 3.8 1997/02/16 10:27:37 hohndel Exp $
+.\" $XConsortium: xdm.man /main/44 1996/12/09 17:08:44 kaleb $
.\" Copyright (c) 1988, 1994 X Consortium
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
@@ -25,7 +24,8 @@
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
-.TH XDM 1 "Release 6.4" "X Version 11"
+.\" $XFree86: xc/programs/xdm/xdm.man,v 3.9 1997/11/16 06:42:47 dawes Exp $
+.TH XDM 1 "Release 6.3" "X Version 11"
.SH NAME
xdm \- X Display Manager with support for XDMCP, host chooser
.SH SYNOPSIS
diff --git a/programs/xdpyinfo/xdpyinfo.man b/programs/xdpyinfo/xdpyinfo.man
index 274addce0..eb0d7c791 100644
--- a/programs/xdpyinfo/xdpyinfo.man
+++ b/programs/xdpyinfo/xdpyinfo.man
@@ -1,5 +1,4 @@
-.\" $TOG: xdpyinfo.man /main/21 1997/11/04 20:56:39 kaleb $
-.\" $XFree86: xc/programs/xdpyinfo/xdpyinfo.man,v 3.1 1996/12/23 07:11:08 dawes Exp $
+.\" $XConsortium: xdpyinfo.man /main/20 1996/12/09 17:08:50 kaleb $
.\" Copyright (c) 1988, 1989, 1994 X Consortium
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
@@ -25,7 +24,8 @@
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
-.TH XDPYINFO 1 "Release 6.4" "X Version 11"
+.\" $XFree86: xc/programs/xdpyinfo/xdpyinfo.man,v 3.2 1997/11/16 06:42:48 dawes Exp $
+.TH XDPYINFO 1 "Release 6.3" "X Version 11"
.SH NAME
xdpyinfo \- display information utility for X
.SH SYNOPSIS
diff --git a/programs/xfd/xfd.man b/programs/xfd/xfd.man
index fc061b02e..56ac4cf16 100644
--- a/programs/xfd/xfd.man
+++ b/programs/xfd/xfd.man
@@ -1,4 +1,4 @@
-.\" $TOG: xfd.man /main/29 1997/11/04 20:56:43 kaleb $
+.\" $XConsortium: xfd.man /main/28 1996/12/09 17:08:55 kaleb $
.\" Copyright (c) 1989, 1994 X Consortium
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
@@ -24,7 +24,7 @@
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
-.TH XFD 1 "Release 6.4" "X Version 11"
+.TH XFD 1 "Release 6.3" "X Version 11"
.SH NAME
xfd \- display all the characters in an X font
.SH SYNOPSIS
diff --git a/programs/xfindproxy/xfindproxy.man b/programs/xfindproxy/xfindproxy.man
index 41f6c3246..fa20ee328 100644
--- a/programs/xfindproxy/xfindproxy.man
+++ b/programs/xfindproxy/xfindproxy.man
@@ -1,4 +1,4 @@
-.\" $TOG: xfindproxy.man /main/2 1997/11/04 20:56:47 kaleb $
+.\" $XConsortium: xfindproxy.man /main/1 1996/10/14 12:44:59 mor $
.\" Copyright (c) 1996 X Consortium
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
@@ -25,7 +25,7 @@
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
.\"
-.TH XFINDPROXY 1 "Release 6.4" "X Version 11"
+.TH XFINDPROXY 1 "Release 6.3" "X Version 11"
.SH NAME
xfindproxy - locate proxy services
.SH SYNOPSIS
diff --git a/programs/xfs/xfs.man b/programs/xfs/xfs.man
index f62034fa9..3bb90e093 100644
--- a/programs/xfs/xfs.man
+++ b/programs/xfs/xfs.man
@@ -36,8 +36,8 @@
.\" suitability of this software for any purpose. It is provided "as is"
.\" without express or implied warranty.
.\" $TOG: xfs.man /main/15 1997/11/04 20:56:51 kaleb $
-.\" $XFree86: xc/programs/xfs/xfs.man,v 3.5 1997/11/16 06:42:50 dawes Exp $
-.TH XFS 1 "Release 6.4" "X Version 11"
+.\" $XFree86: xc/programs/xfs/xfs.man,v 3.6 1998/03/20 19:08:15 hohndel Exp $
+.TH XFS 1 "Release 6.3" "X Version 11"
.SH NAME
xfs \- X font server
.SH SYNOPSIS
diff --git a/programs/xfwp/xfwp.man b/programs/xfwp/xfwp.man
index f65e35607..adb305e6d 100644
--- a/programs/xfwp/xfwp.man
+++ b/programs/xfwp/xfwp.man
@@ -1,4 +1,4 @@
-.\" $TOG: xfwp.man /main/11 1997/11/12 08:16:03 barstow $
+
.\" Copyright (c) 1996 X Consortium
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
@@ -26,7 +26,7 @@
.\" from the X Consortium.
.\"
.nh
-.TH XFWP 1 "Release 6.4" "X Version 11"
+.TH XFWP 1 "Release 6.3" "X Version 11"
.SH NAME
xfwp - X firewall proxy
.SH SYNOPSIS
diff --git a/programs/xhost/xhost.man b/programs/xhost/xhost.man
index 3a7d0a3ad..532934392 100644
--- a/programs/xhost/xhost.man
+++ b/programs/xhost/xhost.man
@@ -1,4 +1,4 @@
-.\" $TOG: xhost.man /main/21 1997/11/04 20:56:58 kaleb $
+.\" $XConsortium: xhost.man /main/20 1996/12/09 17:09:04 kaleb $
.\" Copyright (c) 1988 X Consortium
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
@@ -24,7 +24,7 @@
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
-.TH XHOST 1 "Release 6.4" "X Version 11"
+.TH XHOST 1 "Release 6.3" "X Version 11"
.SH NAME
xhost \- server access control program for X
.SH SYNOPSIS
diff --git a/programs/xieperf/xieperf.man b/programs/xieperf/xieperf.man
index 6c5c5548e..819599b68 100644
--- a/programs/xieperf/xieperf.man
+++ b/programs/xieperf/xieperf.man
@@ -1,4 +1,4 @@
-.\" $TOG: xieperf.man /main/9 1997/11/04 20:57:02 kaleb $
+.\" $XConsortium: xieperf.man /main/8 1996/12/09 17:09:09 kaleb $
.\" Copyright (c) 1993, 1994 X Consortium
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
@@ -64,7 +64,7 @@
.\"
.\" Title to this software shall at all times remain with AGE
.\" Logic, Inc.
-.TH xieperf 1 "Release 6.4" "X Version 11"
+.TH xieperf 1 "Release 6.3" "X Version 11"
.SH NAME
xieperf - XIE server extension test and demo program
.SH SYNTAX
diff --git a/programs/xinit/startx.man b/programs/xinit/startx.man
index 7d663e2f6..2d8182d76 100644
--- a/programs/xinit/startx.man
+++ b/programs/xinit/startx.man
@@ -1,4 +1,4 @@
-.\" $TOG: startx.man /main/9 1997/11/04 20:57:07 kaleb $
+.\" $XConsortium: startx.man /main/8 1996/12/09 17:09:15 kaleb $
.\" Copyright (c) 1993 X Consortium
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
@@ -24,7 +24,7 @@
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
-.TH STARTX 1 "Release 6.4" "X Version 11"
+.TH STARTX 1 "Release 6.3" "X Version 11"
.SH NAME
startx \- initialize an X session
.SH SYNOPSIS
diff --git a/programs/xinit/xinit.man b/programs/xinit/xinit.man
index 824cb1c59..8f17b9324 100644
--- a/programs/xinit/xinit.man
+++ b/programs/xinit/xinit.man
@@ -1,5 +1,4 @@
-.\" $TOG: xinit.man /main/25 1997/11/04 20:57:10 kaleb $
-.\" $XFree86: xc/programs/xinit/xinit.man,v 3.2 1996/12/23 07:11:25 dawes Exp $
+.\" $XConsortium: xinit.man /main/24 1996/12/09 17:09:20 kaleb $
.\" Copyright (c) 1988 X Consortium
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
@@ -25,7 +24,8 @@
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
-.TH XINIT 1 "Release 6.4" "X Version 11"
+.\" $XFree86: xc/programs/xinit/xinit.man,v 3.3 1997/11/16 06:42:55 dawes Exp $
+.TH XINIT 1 "Release 6.3" "X Version 11"
.SH NAME
xinit \- X Window System initializer
.SH SYNOPSIS
diff --git a/programs/xkbcomp/xkbcomp.man b/programs/xkbcomp/xkbcomp.man
index 6b8ad2fcb..494778a9f 100644
--- a/programs/xkbcomp/xkbcomp.man
+++ b/programs/xkbcomp/xkbcomp.man
@@ -1,5 +1,5 @@
-.\" $TOG: xkbcomp.man /main/5 1997/11/04 20:57:14 kaleb $
-.TH XKBCOMP 1 "Release 6.4" "X Version 11"
+.\" $XConsortium: xkbcomp.man /main/4 1996/12/09 17:09:27 kaleb $
+.TH XKBCOMP 1 "Release 6.3" "X Version 11"
.SH NAME
xkbcomp \- compile XKB keyboard description
.SH SYNOPSIS
diff --git a/programs/xkbevd/xkbevd.man b/programs/xkbevd/xkbevd.man
index d92b4e910..1d2a08e09 100644
--- a/programs/xkbevd/xkbevd.man
+++ b/programs/xkbevd/xkbevd.man
@@ -1,5 +1,5 @@
-.\" $TOG: xkbevd.man /main/4 1997/11/04 20:57:18 kaleb $
-.TH XKBCOMP 1 "Release 6.4" "X Version 11"
+.\" $XConsortium: xkbevd.man /main/3 1996/12/09 17:12:41 kaleb $
+.TH XKBCOMP 1 "Release 6.3" "X Version 11"
.SH NAME
xkbevd \- XKB event daemon
.SH SYNOPSIS
diff --git a/programs/xkbprint/xkbprint.man b/programs/xkbprint/xkbprint.man
index 0dd0043ee..0366bc721 100644
--- a/programs/xkbprint/xkbprint.man
+++ b/programs/xkbprint/xkbprint.man
@@ -1,5 +1,5 @@
-.\" $TOG: xkbprint.man /main/5 1997/11/04 20:57:21 kaleb $
-.TH XKBPRINT 1 "Release 6.4" "X Version 11"
+.\" $XConsortium: xkbprint.man /main/4 1996/12/09 17:09:34 kaleb $
+.TH XKBPRINT 1 "Release 6.3" "X Version 11"
.SH NAME
xkbprint \- print an XKB keyboard description
.SH SYNOPSIS
diff --git a/programs/xkill/xkill.man b/programs/xkill/xkill.man
index 33b1b5e3b..0d6be00bc 100644
--- a/programs/xkill/xkill.man
+++ b/programs/xkill/xkill.man
@@ -1,4 +1,4 @@
-.\" $TOG: xkill.man /main/18 1997/11/04 20:57:26 kaleb $
+.\" $XConsortium: xkill.man /main/17 1996/12/09 17:09:39 kaleb $
.\" Copyright (c) 1988 X Consortium
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
@@ -24,7 +24,7 @@
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
-.TH XKILL 1 "Release 6.4" "X Version 11"
+.TH XKILL 1 "Release 6.3" "X Version 11"
.SH NAME
xkill - kill a client by its X resource
.SH SYNOPSIS
diff --git a/programs/xlogo/xlogo.man b/programs/xlogo/xlogo.man
index 6e090106f..edf9ca6b0 100644
--- a/programs/xlogo/xlogo.man
+++ b/programs/xlogo/xlogo.man
@@ -1,4 +1,4 @@
-.\" $TOG: xlogo.man /main/27 1997/11/04 20:57:30 kaleb $
+.\" $XConsortium: xlogo.man /main/26 1996/12/09 17:09:44 kaleb $
.\" Copyright (c) 1988, 1994 X Consortium
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
@@ -24,7 +24,7 @@
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
-.TH XLOGO 1 "Release 6.4" "X Version 11"
+.TH XLOGO 1 "Release 6.3" "X Version 11"
.SH NAME
xlogo - X Window System logo
.SH SYNOPSIS
diff --git a/programs/xlsatoms/xlsatoms.man b/programs/xlsatoms/xlsatoms.man
index 5a40c434b..b0fdd2164 100644
--- a/programs/xlsatoms/xlsatoms.man
+++ b/programs/xlsatoms/xlsatoms.man
@@ -1,4 +1,4 @@
-.\" $TOG: xlsatoms.man /main/13 1997/11/04 20:57:33 kaleb $
+.\" $XConsortium: xlsatoms.man /main/12 1996/12/09 17:09:48 kaleb $
.\" Copyright (c) 1989, 1994 X Consortium
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
@@ -24,7 +24,7 @@
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
-.TH XLSATOMS 1 "Release 6.4" "X Version 11"
+.TH XLSATOMS 1 "Release 6.3" "X Version 11"
.SH NAME
xlsatoms - list interned atoms defined on server
.SH SYNOPSIS
diff --git a/programs/xlsclients/xlscli.man b/programs/xlsclients/xlscli.man
index 9a80ac8d7..ec86a1fe9 100644
--- a/programs/xlsclients/xlscli.man
+++ b/programs/xlsclients/xlscli.man
@@ -1,4 +1,4 @@
-.\" $TOG: xlscli.man /main/11 1997/11/04 20:57:37 kaleb $
+.\" $XConsortium: xlscli.man /main/10 1996/12/09 17:09:52 kaleb $
.\" Copyright (c) 1991, 1994 X Consortium
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
@@ -24,7 +24,7 @@
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
-.TH XLSCLIENTS 1 "Release 6.4" "X Version 11"
+.TH XLSCLIENTS 1 "Release 6.3" "X Version 11"
.SH NAME
xlsclients - list client applications running on a display
.SH SYNOPSIS
diff --git a/programs/xlsfonts/xlsfonts.man b/programs/xlsfonts/xlsfonts.man
index d2647c75b..b75d69003 100644
--- a/programs/xlsfonts/xlsfonts.man
+++ b/programs/xlsfonts/xlsfonts.man
@@ -1,4 +1,4 @@
-.\" $TOG: xlsfonts.man /main/22 1997/11/04 20:57:40 kaleb $
+.\" $XConsortium: xlsfonts.man /main/21 1996/12/09 17:09:56 kaleb $
.\" Copyright (c) 1988 X Consortium
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
@@ -24,7 +24,7 @@
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
-.TH XLSFONTS 1 "Release 6.4" "X Version 11"
+.TH XLSFONTS 1 "Release 6.3" "X Version 11"
.SH NAME
xlsfonts \- server font list displayer for X
.SH SYNOPSIS
diff --git a/programs/xmag/xmag.man b/programs/xmag/xmag.man
index 06e10e77c..5a19f4618 100644
--- a/programs/xmag/xmag.man
+++ b/programs/xmag/xmag.man
@@ -1,4 +1,4 @@
-.\" $TOG: xmag.man /main/12 1997/11/04 20:57:44 kaleb $
+.\" $XConsortium: xmag.man /main/11 1996/12/09 17:10:01 kaleb $
.\" Copyright (c) 1991, 1994 X Consortium
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
@@ -24,7 +24,7 @@
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
-.TH XMAG 1 "Release 6.4" "X Version 11"
+.TH XMAG 1 "Release 6.3" "X Version 11"
.SH NAME
xmag \- magnify parts of the screen
.SH SYNOPSIS
diff --git a/programs/xmodmap/xmodmap.man b/programs/xmodmap/xmodmap.man
index 346f22615..8acbf1e2e 100644
--- a/programs/xmodmap/xmodmap.man
+++ b/programs/xmodmap/xmodmap.man
@@ -1,4 +1,4 @@
-.\" $TOG: xmodmap.man /main/28 1997/11/04 20:57:48 kaleb $
+.\" $TOG: xmodmap.man /main/27 1997/04/02 09:22:54 kaleb $
.\" Copyright (c) 1988, 1989, 1990 X Consortium
.\" Copyright 1987 Sun Microsystems, Inc.
.\"
@@ -25,7 +25,7 @@
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
-.\" $XFree86: xc/programs/xmodmap/xmodmap.man,v 1.3 1997/07/05 15:17:14 dawes Exp $
+.\" $XFree86: xc/programs/xmodmap/xmodmap.man,v 1.4 1997/11/16 06:43:03 dawes Exp $
.de EX \"Begin example
.ne 5
.if n .sp 1
@@ -39,7 +39,7 @@
.if n .sp 1
.if t .sp .5
..
-.TH XMODMAP 1 "Release 6.4" "X Version 11"
+.TH XMODMAP 1 "Release 6.3" "X Version 11"
.SH NAME
xmodmap - utility for modifying keymaps and pointer button mappings in X
.SH SYNOPSIS
diff --git a/programs/xprop/xprop.man b/programs/xprop/xprop.man
index e06dec1e9..82b03007c 100644
--- a/programs/xprop/xprop.man
+++ b/programs/xprop/xprop.man
@@ -1,4 +1,4 @@
-.\" $TOG: xprop.man /main/21 1997/11/04 20:57:52 kaleb $
+.\" $XConsortium: xprop.man /main/20 1996/12/09 17:10:17 kaleb $
.\" Copyright (c) 1988 X Consortium
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
@@ -24,7 +24,7 @@
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
-.TH XPROP 1 "Release 6.4" "X Version 11"
+.TH XPROP 1 "Release 6.3" "X Version 11"
.SH NAME
xprop - property displayer for X
.SH SYNOPSIS
diff --git a/programs/xrdb/xrdb.man b/programs/xrdb/xrdb.man
index fcb10648e..6641000c2 100644
--- a/programs/xrdb/xrdb.man
+++ b/programs/xrdb/xrdb.man
@@ -1,4 +1,4 @@
-.\" $TOG: xrdb.man /main/41 1997/11/04 20:57:56 kaleb $
+.\" $XConsortium: xrdb.man /main/40 1996/12/09 17:10:22 kaleb $
.\" Copyright 1991, Digital Equipment Corporation.
.\" Copyright (c) 1991, 1994 X Consortium
.\"
@@ -25,7 +25,7 @@
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
-.TH XRDB 1 "Release 6.4" "X Version 11"
+.TH XRDB 1 "Release 6.3" "X Version 11"
.SH NAME
xrdb - X server resource database utility
.SH SYNOPSIS
diff --git a/programs/xrefresh/xrefresh.man b/programs/xrefresh/xrefresh.man
index 2c96273f0..f2239ce3a 100644
--- a/programs/xrefresh/xrefresh.man
+++ b/programs/xrefresh/xrefresh.man
@@ -1,4 +1,4 @@
-.\" $TOG: xrefresh.man /main/18 1997/11/04 20:58:01 kaleb $
+.\" $XConsortium: xrefresh.man /main/17 1996/12/09 17:10:26 kaleb $
.\" Copyright (c) 1988 X Consortium
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
@@ -24,7 +24,7 @@
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
-.TH XREFRESH 1 "Release 6.4" "X Version 11"
+.TH XREFRESH 1 "Release 6.3" "X Version 11"
.SH NAME
xrefresh - refresh all or part of an X screen
.SH SYNOPSIS
diff --git a/programs/xrx/helper/xrx.man b/programs/xrx/helper/xrx.man
index 5b1e44f8c..27db81d34 100644
--- a/programs/xrx/helper/xrx.man
+++ b/programs/xrx/helper/xrx.man
@@ -1,4 +1,4 @@
-.\" $TOG: xrx.man /main/5 1997/11/04 21:01:26 kaleb $
+.\" $XConsortium: xrx.man /main/4 1996/12/26 14:04:41 lehors $
.\" Copyright (c) 1996 X Consortium
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
@@ -25,7 +25,7 @@
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
.\"
-.TH XRX 1 "Release 6.4" "X Version 11"
+.TH XRX 1 "Release 6.3" "X Version 11"
.SH NAME
xrx - RX helper program
.SH SYNOPSIS
diff --git a/programs/xrx/plugin/libxrx.man b/programs/xrx/plugin/libxrx.man
index d0734f8e9..23a5fc7b5 100644
--- a/programs/xrx/plugin/libxrx.man
+++ b/programs/xrx/plugin/libxrx.man
@@ -1,4 +1,4 @@
-.\" $TOG: libxrx.man /main/6 1997/11/24 16:53:15 barstow $
+.\" $XConsortium: libxrx.man /main/4 1996/12/26 14:04:47 lehors $
.\" Copyright (c) 1996 X Consortium
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
@@ -25,7 +25,7 @@
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
.\"
-.TH LIBXRX 1 "Release 6.4" "X Version 11"
+.TH LIBXRX 1 "Release 6.3" "X Version 11"
.SH NAME
libxrx - RX Netscape Navigator Plug-in
.SH DESCRIPTION
@@ -49,7 +49,7 @@ embedded within the browser page from which it was launched.
.SH INSTALLATION
To install the \fBRX Plug-in\fP so that Netscape Navigator can use it, find
the file named libxrx.so.6.3 or libxrx.sl.6.3 (or similar, depending on
-your platform) in <ProjectRoot>/lib (e.g. /usr/X11R6.4/lib) and copy it to
+your platform) in <ProjectRoot>/lib (e.g. /usr/X11R6.3/lib) and copy it to
either /usr/local/lib/netscape/plugins or $HOME/.netscape/plugins. Do
not install the symlinks libxrx.so or libxrx.sl; they would confuse
Netscape.
diff --git a/programs/xrx/testplugin/testplugin.man b/programs/xrx/testplugin/testplugin.man
index bda5a12ec..fe4fe73b3 100644
--- a/programs/xrx/testplugin/testplugin.man
+++ b/programs/xrx/testplugin/testplugin.man
@@ -1,4 +1,4 @@
-.\" $TOG: testplugin.man /main/5 1997/11/04 21:01:35 kaleb $
+.\" $XConsortium: testplugin.man /main/4 1996/12/17 16:54:52 lehors $
.\" Copyright (c) 1996 X Consortium
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
@@ -24,7 +24,7 @@
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
-.TH TESTPLUGIN 1 "Release 6.4" "X Version 11"
+.TH TESTPLUGIN 1 "Release 6.3" "X Version 11"
.SH NAME
testplugin - a Netscape Plug-in test bed utility
.SH SYNOPSIS
diff --git a/programs/xset/xset.man b/programs/xset/xset.man
index 5bfb12a3d..48126385b 100644
--- a/programs/xset/xset.man
+++ b/programs/xset/xset.man
@@ -1,5 +1,4 @@
-.\" $TOG: xset.man /main/30 1997/11/04 20:58:12 kaleb $
-.\" $XFree86: xc/programs/xset/xset.man,v 3.5 1997/01/22 11:18:54 dawes Exp $
+.\" $XConsortium: xsetroot.man /main/18 1996/12/09 17:10:34 kaleb $
.\" Copyright (c) 1988 X Consortium
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
@@ -25,7 +24,8 @@
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
-.TH XSET 1 "Release 6.4" "X Version 11"
+.\" $XFree86: xc/programs/xset/xset.man,v 3.6 1997/11/16 06:43:07 dawes Exp $
+.TH XSET 1 "Release 6.3" "X Version 11"
.SH NAME
xset - user preference utility for X
.SH SYNOPSIS
diff --git a/programs/xsetroot/xsetroot.man b/programs/xsetroot/xsetroot.man
index 27a2ac93e..bf31706ab 100644
--- a/programs/xsetroot/xsetroot.man
+++ b/programs/xsetroot/xsetroot.man
@@ -1,4 +1,4 @@
-.\" $TOG: xsetroot.man /main/19 1997/11/04 20:58:09 kaleb $
+.\" $XConsortium: xsetroot.man /main/18 1996/12/09 17:10:34 kaleb $
.\" Copyright (c) 1988 X Consortium
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
@@ -24,7 +24,7 @@
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
-.TH XSETROOT 1 "Release 6.4" "X Version 11"
+.TH XSETROOT 1 "Release 6.3" "X Version 11"
.SH NAME
xsetroot \- root window parameter setting utility for X
.SH SYNOPSIS
diff --git a/programs/xsm/xsm.man b/programs/xsm/xsm.man
index 0cc660a2d..451f3884f 100644
--- a/programs/xsm/xsm.man
+++ b/programs/xsm/xsm.man
@@ -1,4 +1,4 @@
-.\" $TOG: xsm.man /main/15 1997/11/04 20:58:16 kaleb $
+.\" $XConsortium: xsm.man /main/14 1996/12/09 17:10:38 kaleb $
.\" Copyright (c) 1994 X Consortium
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
@@ -24,7 +24,7 @@
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
-.TH XSM 1 "Release 6.4" "X Version 11"
+.TH XSM 1 "Release 6.3" "X Version 11"
.SH NAME
xsm \- X Session Manager
.SH SYNOPSIS
diff --git a/programs/xstdcmap/xstdcmap.man b/programs/xstdcmap/xstdcmap.man
index a5f8986f1..cac389d55 100644
--- a/programs/xstdcmap/xstdcmap.man
+++ b/programs/xstdcmap/xstdcmap.man
@@ -1,4 +1,4 @@
-.\" $TOG: xstdcmap.man /main/15 1997/11/04 20:58:20 kaleb $
+.\" $XConsortium: xstdcmap.man /main/14 1996/12/09 17:10:44 kaleb $
.\" Copyright (c) 1989, 1994 X Consortium
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
@@ -37,7 +37,7 @@
.if n .sp 1
.if t .sp .5
..
-.TH XSTDCMAP 1 "Release 6.4" "X Version 11"
+.TH XSTDCMAP 1 "Release 6.3" "X Version 11"
.SH NAME
xstdcmap - X standard colormap utility
.SH SYNOPSIS
diff --git a/programs/xterm/resize.man b/programs/xterm/resize.man
index 7897d1696..d6f14571b 100644
--- a/programs/xterm/resize.man
+++ b/programs/xterm/resize.man
@@ -1,7 +1,7 @@
-.\" $TOG: resize.man /main/13 1997/11/04 20:58:24 kaleb $
-.\" $XFree86$
+.\" $XConsortium: resize.man /main/12 1996/12/09 17:10:48 kaleb $
+.\" $XFree86: xc/programs/xterm/resize.man,v 1.3 1998/03/20 21:08:38 hohndel Exp $
.\" updated by Thomas Dickey <dickey@clark.net> for XFree86, Februrary 1998.
-.TH RESIZE 1 "Release 6.4" "X Version 11"
+.TH RESIZE 1 "Release 6.3" "X Version 11"
.SH NAME
resize \- set TERMCAP and terminal settings to current xterm window size
.SH SYNOPSIS
diff --git a/programs/xterm/xterm.man b/programs/xterm/xterm.man
index 823c061b0..864567544 100644
--- a/programs/xterm/xterm.man
+++ b/programs/xterm/xterm.man
@@ -1,5 +1,4 @@
-.\" $TOG: xterm.man /main/86 1997/11/04 20:58:28 kaleb $
-.\" $XFree86: xc/programs/xterm/xterm.man,v 3.23 1998/01/24 01:53:44 hohndel Exp $
+.\" $XConsortium: xterm.man /main/85 1996/12/09 17:10:53 kaleb $
.\" Copyright (c) 1989 X Consortium
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
@@ -26,8 +25,10 @@
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
.\"
+.\" $XFree86: xc/programs/xterm/xterm.man,v 3.24 1998/03/27 23:24:03 hohndel Exp $
+.\"
.\" updated by Thomas Dickey <dickey@clark.net> for XFree86, July 1996.
-.TH XTERM 1 "Release 6.4" "X Version 11"
+.TH XTERM 1 "Release 6.3" "X Version 11"
.SH NAME
xterm \- terminal emulator for X
.SH SYNOPSIS
diff --git a/programs/xwd/xwd.man b/programs/xwd/xwd.man
index 29b2b6abf..119672fc5 100644
--- a/programs/xwd/xwd.man
+++ b/programs/xwd/xwd.man
@@ -1,4 +1,4 @@
-.\" $TOG: xwd.man /main/22 1997/11/04 20:58:34 kaleb $
+.\" $XConsortium: xwd.man /main/21 1996/12/09 17:11:08 kaleb $
.\" Copyright (c) 1988, 1994 X Consortium
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
@@ -24,7 +24,7 @@
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
-.TH XWD 1 "Release 6.4" "X Version 11"
+.TH XWD 1 "Release 6.3" "X Version 11"
.SH NAME
xwd - dump an image of an X window
.SH SYNOPSIS
diff --git a/programs/xwininfo/xwininfo.man b/programs/xwininfo/xwininfo.man
index 84686a45f..c1de5ef4c 100644
--- a/programs/xwininfo/xwininfo.man
+++ b/programs/xwininfo/xwininfo.man
@@ -1,4 +1,4 @@
-.\" $TOG: xwininfo.man /main/25 1997/11/04 20:58:38 kaleb $
+.\" $XConsortium: xwininfo.man /main/24 1996/12/09 17:11:13 kaleb $
.\" Copyright (c) 1988 X Consortium
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
@@ -24,7 +24,7 @@
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
-.TH XWININFO 1 "Release 6.4" "X Version 11"
+.TH XWININFO 1 "Release 6.3" "X Version 11"
.SH NAME
xwininfo \- window information utility for X
.SH SYNOPSIS
@@ -178,7 +178,7 @@ xwininfo: Window id: 0x60000f "xterm"
Save Under State: no
Map State: IsViewable
Override Redirect State: no
- Corners: +2+85 -699+85 -699-6.4 +2-623
+ Corners: +2+85 -699+85 -699-623 +2-623
-geometry 80x24+0+58
.SH ENVIRONMENT
diff --git a/programs/xwud/xwud.man b/programs/xwud/xwud.man
index 807af70e6..05a9e7bfd 100644
--- a/programs/xwud/xwud.man
+++ b/programs/xwud/xwud.man
@@ -1,4 +1,4 @@
-.\" $TOG: xwud.man /main/21 1997/11/04 20:58:42 kaleb $
+.\" $XConsortium: xwud.man /main/20 1996/12/09 17:11:17 kaleb $
.\" Copyright (c) 1988 X Consortium
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
@@ -24,7 +24,7 @@
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
-.TH XWUD 1 "Release 6.4" "X Version 11"
+.TH XWUD 1 "Release 6.3" "X Version 11"
.SH NAME
xwud - image displayer for X
.SH SYNOPSIS