home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-387-Vol-3of3.iso
/
x
/
x11p-13.zip
/
RCS
/
do_windows.c,v
< prev
next >
Wrap
Text File
|
1989-12-07
|
16KB
|
883 lines
head 2.6;
access ;
symbols pre-merge:2.0;
locks ; strict;
comment @ * @;
2.6
date 89.12.07.16.37.17; author joel; state Exp;
branches ;
next 2.5;
2.5
date 89.10.02.14.48.10; author joel; state Exp;
branches ;
next 2.4;
2.4
date 89.05.16.11.42.56; author joel; state Exp;
branches ;
next 2.3;
2.3
date 89.05.11.16.45.17; author joel; state Exp;
branches ;
next 2.2;
2.2
date 89.05.09.13.01.13; author joel; state Exp;
branches ;
next 2.1;
2.1
date 89.05.03.14.18.25; author joel; state Exp;
branches ;
next 2.0;
2.0
date 89.01.31.17.06.42; author erik; state Exp;
branches ;
next 1.2;
1.2
date 89.01.31.17.06.42; author joel; state Exp;
branches ;
next 1.1;
1.1
date 88.06.20.22.02.33; author joel; state Exp;
branches ;
next ;
desc
@@
2.6
log
@Changed interface to p->reps
@
text
@/*****************************************************************************
Copyright 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.
******************************************************************************/
#include "x11perf.h"
static Window *parents;
static Window *isolates;
static int childrows, childcolumns, childwindows;
static int parentrows, parentcolumns, parentwindows;
static int parentwidth, parentheight;
static Window popup;
void ComputeSizes(xp, p)
XParms xp;
Parms p;
{
childwindows = p->objects;
childrows = (childwindows + MAXCOLS - 1) / MAXCOLS;
childcolumns = (childrows > 1 ? MAXCOLS : childwindows);
parentwidth = (CHILDSIZE+CHILDSPACE) * childcolumns;
parentheight = (CHILDSIZE+CHILDSPACE) * childrows;
}
int CreateParents(xp, p, reps)
XParms xp;
Parms p;
int reps;
{
int i;
ComputeSizes(xp, p);
parentcolumns = WIDTH / parentwidth;
parentrows = HEIGHT / parentheight;
parentwindows = parentcolumns * parentrows; /* Max reps we can fit */
if (parentwindows > reps) {
parentwindows = reps;
}
/* We will do parentwindows sets of childwindows, in order to get better
timing accuracy. Creating 4 windows at a millisecond apiece or so
is a bit faster than the 60 Hz clock. */
isolates = (Window *)malloc(parentwindows * sizeof(Window));
parents = (Window *)malloc(parentwindows * sizeof(Window));
/*
* Create isolation windows for the parents, and then the parents
* themselves. These isolation windows ensure that parent and children
* windows created/mapped in DoWins and DoWin2 all see the same local
* environment...the parent is an only child, and each parent contains
* the number of children we are trying to get benchmarks on.
*/
for (i = 0; i != parentwindows; i++) {
isolates[i] = XCreateSimpleWindow(xp->d, xp->w,
(i/parentrows)*parentwidth, (i%parentrows)*parentheight,
parentwidth, parentheight, 0, xp->background, xp->background);
parents[i] = XCreateSimpleWindow(xp->d, isolates[i],
0, 0, parentwidth, parentheight, 0, xp->background, xp->background);
}
XMapSubwindows(xp->d, xp->w);
return parentwindows;
} /* CreateParents */
void MapParents(xp, p, reps)
XParms xp;
Parms p;
int reps;
{
int i;
for (i = 0; i != parentwindows; i++) {
XMapWindow(xp->d, parents[i]);
}
}
int InitCreate(xp, p, reps)
XParms xp;
Parms p;
int reps;
{
reps = CreateParents(xp, p, reps);
MapParents(xp, p, reps);
return reps;
}
void CreateChildGroup(xp, p, parent)
XParms xp;
Parms p;
Window parent;
{
int j;
for (j = 0; j != childwindows; j++) {
(void) XCreateSimpleWindow (xp->d, parent,
(CHILDSIZE+CHILDSPACE) * (j/childrows) + CHILDSPACE/2,
(CHILDSIZE+CHILDSPACE) * (j%childrows) + CHILDSPACE/2,
CHILDSIZE, CHILDSIZE, 0, xp->background, xp->foreground);
}
if (p->special)
XMapSubwindows (xp->d, parent);
}
void CreateChildren(xp, p, reps)
XParms xp;
Parms p;
int reps;
{
int i;
for (i = 0; i != parentwindows; i++) {
CreateChildGroup(xp, p, parents[i]);
} /* end i */
}
void DestroyChildren(xp, p, reps)
XParms xp;
Parms p;
int reps;
{
int i;
for (i = 0; i != parentwindows; i++) {
XDestroySubwindows(xp->d, parents[i]);
}
}
void EndCreate(xp, p)
XParms xp;
Parms p;
{
XDestroySubwindows(xp->d, xp->w);
free(parents);
free(isolates);
}
int InitMap(xp, p, reps)
XParms xp;
Parms p;
int reps;
{
int i;
reps = CreateParents(xp, p, reps);
CreateChildren(xp, p, reps);
return reps;
}
void UnmapParents(xp, p, reps)
XParms xp;
Parms p;
int reps;
{
int i;
for (i = 0; i != parentwindows; i++) {
XUnmapWindow(xp->d, parents[i]);
}
}
int InitDestroy(xp, p, reps)
XParms xp;
Parms p;
int reps;
{
reps = CreateParents(xp, p, reps);
CreateChildren(xp, p, reps);
MapParents(xp, p, reps);
return reps;
}
void DestroyParents(xp, p, reps)
XParms xp;
Parms p;
int reps;
{
int i;
for (i = 0; i != parentwindows; i++) {
XDestroyWindow(xp->d, parents[i]);
}
}
void RenewParents(xp, p)
XParms xp;
Parms p;
{
int i;
for (i = 0; i != parentwindows; i++) {
parents[i] = XCreateSimpleWindow(xp->d, isolates[i],
0, 0, parentwidth, parentheight, 0, xp->background, xp->background);
}
CreateChildren(xp, p, parentwindows);
MapParents(xp, p, parentwindows);
}
int InitPopups(xp, p, reps)
XParms xp;
Parms p;
int reps;
{
XWindowAttributes xwa;
XSetWindowAttributes xswa;
Window isolate;
#ifdef CHILDROOT
ComputeSizes(xp, p);
CreateChildGroup(xp, p, xp->w);
/* Now create simple window to pop up over children */
(void) XGetWindowAttributes(xp->d, xp->w, &xwa);
xswa.override_redirect = True;
popup = XCreateSimpleWindow (
xp->d, DefaultRootWindow(xp->d),
xwa.x + xwa.border_width, xwa.y + xwa.border_width,
parentwidth, parentheight,
0, xp->foreground, xp->foreground);
#else
isolate = XCreateSimpleWindow(
xp->d, xp->w, 0, 0, WIDTH, HEIGHT,
0, xp->background, xp->background);
ComputeSizes(xp, p);
CreateChildGroup(xp, p, isolate);
XMapWindow(xp->d, isolate);
/* Now create simple window to pop up over children */
xswa.override_redirect = True;
popup = XCreateSimpleWindow (
xp->d, xp->w, 0, 0,
parentwidth, parentheight,
0, xp->foreground, xp->foreground);
#endif
XChangeWindowAttributes (xp->d, popup, CWOverrideRedirect, &xswa);
return reps;
}
void DoPopUps(xp, p, reps)
XParms xp;
Parms p;
int reps;
{
int i;
for (i = 0; i != reps; i++) {
XMapWindow(xp->d, popup);
XUnmapWindow(xp->d, popup);
}
}
void EndPopups(xp, p)
XParms xp;
Parms p;
{
XDestroySubwindows(xp->d, xp->w);
#ifdef CHILDROOT
XDestroyWindow(xp->d, popup);
#endif
}
@
2.5
log
@Isolated popup window from rest of root-level windows.
This caused timings to be much better in some cases....what I really need
to do is figure out a test that causes the much lower numbers I was getting
@
text
@d45 1
a45 1
void CreateParents(xp, p)
d48 1
d58 2
a59 4
if (parentwindows > p->reps) {
parentwindows = p->reps;
} else {
p->reps = parentwindows;
d85 1
d89 1
a89 1
void MapParents(xp, p)
d92 1
d102 1
a102 1
Bool InitCreate(xp, p)
d105 1
d107 3
a109 3
CreateParents(xp, p);
MapParents(xp, p);
return True;
d130 1
a130 1
void CreateChildren(xp, p)
d133 1
d142 1
a142 1
void DestroyChildren(xp, p)
d145 1
d164 1
a164 1
Bool InitMap(xp, p)
d167 1
d171 3
a173 3
CreateParents(xp, p);
CreateChildren(xp, p);
return True;
d176 1
a176 1
void UnmapParents(xp, p)
d179 1
d188 1
a188 1
Bool InitDestroy(xp, p)
d191 1
d193 4
a196 4
CreateParents(xp, p);
CreateChildren(xp, p);
MapParents(xp, p);
return True;
d199 1
a199 1
void DestroyParents(xp, p)
d202 1
d222 2
a223 2
CreateChildren(xp, p);
MapParents(xp, p);
d226 1
a226 1
Bool InitPopups(xp, p)
d229 1
d264 1
a264 1
return True;
d267 1
a267 1
void DoPopUps(xp, p)
d270 1
d273 1
a273 1
for (i = 0; i != p->reps; i++) {
@
2.4
log
@Checked out to find mysterious timing problem. Ended up being a lot of
calls to XYToWindow in a field of a lot of windows.
@
text
@d224 1
d226 1
d234 1
a234 1
xp->d, RootWindow(xp->d, 0),
d237 17
a253 1
0, xp->foreground, xp->background);
d274 1
d276 1
@
2.3
log
@Parameters to all routines now (xp, p)
MAXROWS used in all routines
Junked most global communication variables
@
text
@d56 1
@
2.2
log
@Can do only as many reps as specified in p->reps, rather than always
doing maximum amount.
@
text
@d1 23
d27 1
a30 1
static Window w;
d33 3
a35 3
void ComputeSizes(d, p)
Display *d;
Parms p;
d38 3
a40 7
if (childwindows < 50) {
childcolumns = childwindows;
childrows = 1;
} else {
childcolumns = COLS;
childrows = (childwindows + COLS - 1) / COLS;
}
d45 3
a47 3
void CreateParents(d, p)
Display *d;
Parms p;
d49 1
a49 2
Window isolate;
int i;
d51 1
a51 1
ComputeSizes(d, p);
d65 1
a67 2
CreatePerfStuff(d, 1, WIDTH, HEIGHT, &w, NULL, NULL);
d76 2
a77 2
for (i = 0; i < parentwindows; i++) {
isolate = XCreateSimpleWindow(d, w,
d79 3
a81 3
parentwidth, parentheight, 0, bgPixel, bgPixel);
parents[i] = XCreateSimpleWindow(d, isolate,
0, 0, parentwidth, parentheight, 0, bgPixel, bgPixel);
d84 1
a84 1
XMapSubwindows(d, w);
d88 3
a90 3
void MapParents(d, p)
Display *d;
Parms p;
d94 2
a95 2
for (i = 0; i < parentwindows; i++) {
XMapWindow(d, parents[i]);
d100 3
a102 3
Bool InitCreate(d, p)
Display *d;
Parms p;
d104 2
a105 2
CreateParents(d, p);
MapParents(d, p);
d109 3
a111 3
void CreateChildGroup(d, p, parent)
Display *d;
Parms p;
d116 2
a117 2
for (j = 0; j < childwindows; j++) {
(void) XCreateSimpleWindow (d, parent,
d120 1
a120 1
CHILDSIZE, CHILDSIZE, 0, bgPixel, fgPixel);
d124 1
a124 1
XMapSubwindows (d, parent);
d127 3
a129 3
void CreateChildren(d, p)
Display *d;
Parms p;
d133 2
a134 2
for (i = 0; i < parentwindows; i++) {
CreateChildGroup(d, p, parents[i]);
d138 3
a140 3
void DeleteChildren(d, p)
Display *d;
Parms p;
d144 2
a145 2
for (i = 0; i < parentwindows; i++) {
XDestroySubwindows(d, parents[i]);
d149 3
a151 3
void EndCreate(d, p)
Display *d;
Parms p;
d153 3
a155 1
XDestroyWindow(d, w);
d159 3
a161 3
Bool InitMap(d, p)
Display *d;
Parms p;
d165 2
a166 2
CreateParents(d, p);
CreateChildren(d, p);
d170 3
a172 3
void UnmapParents(d, p)
Display *d;
Parms p;
d176 2
a177 2
for (i = 0; i < parentwindows; i++) {
XUnmapWindow(d, parents[i]);
d181 9
d191 3
a193 3
Bool InitPopups(d, p)
Display *d;
Parms p;
d195 27
a221 1
int i, x, y;
d224 2
a225 3
ComputeSizes(d, p);
CreatePerfStuff(d, 1, WIDTH, HEIGHT, &w, NULL, NULL);
CreateChildGroup(d, p, w);
d228 1
a229 1
/* ||| Make relative to perfwindow */
d231 5
a235 3
d, RootWindow(d, 0), 1, 1, parentwidth, parentheight,
0, fgPixel, bgPixel);
XChangeWindowAttributes (d, popup, CWOverrideRedirect, &xswa);
d239 3
a241 3
void DoPopUps(d, p)
Display *d;
Parms p;
d244 3
a246 3
for (i = 0; i < p->reps; i++) {
XMapWindow(d, popup);
XUnmapWindow(d, popup);
d250 2
a251 2
void EndPopups(d, p)
Display *d;
d254 2
a255 2
XDestroyWindow(d, w);
XDestroyWindow(d, popup);
@
2.1
log
@Massive changes, I'm not going to go into details.
@
text
@d20 1
a20 1
childrows = childwindows/COLS;
d31 1
a31 1
int i, x, y;
d37 6
a42 2
parentwindows = parentcolumns * parentrows;
parents = (Window *)malloc(parentwindows * sizeof(Window));
d47 1
a47 1
p->reps = parentwindows;
d59 6
a64 11
i = 0;
for (x = 0; x < parentcolumns; x++) {
for (y = 0; y < parentrows; y++) {
isolate = XCreateSimpleWindow(d, w,
x*parentwidth, y*parentheight, parentwidth, parentheight,
0, bgPixel, bgPixel);
parents[i] = XCreateSimpleWindow(d, isolate,
0, 0, parentwidth, parentheight,
0, bgPixel, bgPixel);
i++;
}
d66 1
d70 1
d97 1
a97 1
int j, x, y;
d99 4
a102 6
j = 0;
for (x = 0; x < childcolumns; x++) {
for (y = 0; y < childrows; y++) {
(void) XCreateSimpleWindow (d, parent,
(CHILDSIZE+CHILDSPACE) * x + CHILDSPACE/2,
(CHILDSIZE+CHILDSPACE) * y + CHILDSPACE/2,
a103 4
j++;
if (j == childwindows)
goto Enough;
}
d105 1
a105 1
Enough:
d176 1
d178 1
a178 1
d, RootWindow(d, 0), 50, 50, parentwidth, parentheight,
d189 1
a189 2
for (i = 0; i < p->reps; i++)
{
@
2.0
log
@version from /usr/src/pmax
@
text
@d3 4
a8 1
static rows, columns;
d10 1
a10 1
void InitWins(d, p)
d14 17
d33 33
a65 3
if (p->objects < 50) {
rows = 1;
columns = p->objects;
d67 11
a77 3
else {
columns = COLS;
rows = p->objects/COLS;
d79 1
a79 2
p->objects = rows * columns;
CreatePerfStuff(d, 1, WIDTH, HEIGHT, &w, NULL, NULL);
d81 8
d91 1
a91 1
void DoWins(d, p)
d94 1
d96 1
a96 2
int x, y, i;
int child;
d98 9
a106 6
child = 0;
for (x = 0; x < COLS; x++)
for (y = 0; y < rows; y++) {
(void) XCreateSimpleWindow (
d, w, x*20 + 10, y*20 + 10, 10, 10, 0, bgPixel, fgPixel);
if ((++child) == p->objects)
d109 1
d112 1
a112 1
XMapSubwindows (d, w);
d115 1
a115 1
static void CreateSubs(d, p, rows, cols)
a117 1
int rows, cols;
d119 1
a119 2
int x, y, i;
int child;
d121 3
a123 10
child = 0;
for (x = 0; x < cols; x++)
for (y = 0; y < rows; y++) {
(void) XCreateSimpleWindow (
d, w, x*20 + 10, y*20 + 10, 10, 10, 0, bgPixel, fgPixel);
if ((++child) == p->objects)
goto Enough ;
}
Enough:
XMapSubwindows (d, w);
d126 1
a126 1
void InitWins2(d, p)
d130 1
a130 1
int i, x, y;
d132 2
a133 3
if (p->objects < 50) {
rows = 1;
columns = p->objects;
a134 8
else {
columns = COLS;
rows = p->objects/COLS;
}
p->objects = rows * columns;
CreatePerfStuff(d, 1, WIDTH, HEIGHT, &w, NULL, NULL);
XUnmapWindow(d, w);
CreateSubs(d, p, rows, columns);
d137 1
a137 1
void DoWins2(d, p)
d141 1
a141 1
XMapWindow (d, w);
d144 2
a145 1
void UnmapWin(d, p)
d149 5
a153 1
XUnmapWindow(d, w);
d156 1
a156 1
void InitPopups(d, p)
d160 12
a171 1
#define POPUPCOLS 8
d175 1
a175 9
if (p->objects < 10) {
rows = 1;
columns = p->objects;
}
else {
columns = POPUPCOLS;
rows = p->objects/POPUPCOLS;
}
p->objects = rows * columns;
d177 1
a177 1
CreateSubs(d, p, rows, columns);
d179 1
d182 2
a183 1
d, RootWindow(d, 0), 30, 40, 500, 500, 0, fgPixel, bgPixel);
d185 1
a185 1
#undef POPUPCOLS
a205 14
}
void DeleteSubs(d, p)
Display *d;
Parms p;
{
XDestroySubwindows(d, w);
}
void EndWins(d, p)
Display *d;
Parms p;
{
XDestroyWindow(d, w);
@
1.2
log
@Added -fg -bg capabilities
@
text
@@
1.1
log
@Initial revision
@
text
@a31 2
int wp = WhitePixel (d, 0);
int bp = BlackPixel (d, 0);
d37 1
a37 1
d, w, x*20 + 10, y*20 + 10, 10, 10, 0, wp, bp);
a52 2
int wp = WhitePixel (d, 0);
int bp = BlackPixel (d, 0);
d58 1
a58 1
d, w, x*20 + 10, y*20 + 10, 10, 10, 0, wp, bp);
a106 2
int wp = WhitePixel (d, 0);
int bp = BlackPixel (d, 0);
d122 1
a122 1
d, RootWindow(d, 0), 30, 40, 500, 500, 0, bp, wp);
@