do_movewin.c revision 533545b5
1/***************************************************************************** 2Copyright 1988, 1989 by Digital Equipment Corporation, Maynard, Massachusetts. 3 4 All Rights Reserved 5 6Permission to use, copy, modify, and distribute this software and its 7documentation for any purpose and without fee is hereby granted, 8provided that the above copyright notice appear in all copies and that 9both that copyright notice and this permission notice appear in 10supporting documentation, and that the name of Digital not be 11used in advertising or publicity pertaining to distribution of the 12software without specific, written prior permission. 13 14DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING 15ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL 16DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR 17ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 18WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 19ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 20SOFTWARE. 21 22******************************************************************************/ 23 24#include "x11perf.h" 25 26static Window *children; 27static XPoint *positions; 28static Window cover; 29static int rows; 30static int x_offset, y_offset; /* Private global data for DoMoveWindows */ 31static int xmax, ymax; 32static int delta1; /* Private global data for DoResizeWindows */ 33 34#define STACK (4*(HEIGHT-10)/CHILDSIZE) 35 36int 37InitMoveWindows(XParms xp, Parms p, int64_t reps) 38{ 39 int i = 0; 40 41 rows = (p->objects + MAXCOLS - 1) / MAXCOLS; 42 43 x_offset = 0; 44 y_offset = 0; 45 delta1 = 1; 46 47 children = (Window *) malloc (p->objects*sizeof (Window)); 48 positions = (XPoint *) malloc(p->objects*sizeof(XPoint)); 49 50 xmax = (CHILDSIZE+CHILDSPACE) * (rows > 1 ? MAXCOLS : p->objects); 51 ymax = rows * (CHILDSIZE+CHILDSPACE); 52 53 for (i = 0; i != p->objects; i++) { 54 positions[i].x = (CHILDSIZE+CHILDSPACE) * (i/rows) + CHILDSPACE/2; 55 positions[i].y = (CHILDSIZE+CHILDSPACE) * (i%rows) + CHILDSPACE/2; 56 children[i] = XCreateSimpleWindow(xp->d, xp->w, 57 positions[i].x, positions[i].y, 58 CHILDSIZE, CHILDSIZE, 0, xp->foreground, xp->foreground); 59 } 60 if (p->special) 61 XMapSubwindows (xp->d, xp->w); 62 return reps; 63} 64 65void 66DoMoveWindows(XParms xp, Parms p, int64_t reps) 67{ 68 int i, j; 69 70 for (i = 0; i != reps; i++) { 71 x_offset += 1; 72 y_offset += 3; 73 if (y_offset + ymax > HEIGHT) 74 y_offset = 0; 75 if (x_offset + xmax > WIDTH) 76 x_offset = 0; 77 for (j = 0; j != p->objects; j++) { 78 XMoveWindow(xp->d, children[j], 79 positions[j].x + x_offset, positions[j].y + y_offset); 80 } 81 CheckAbort (); 82 } 83} 84 85void 86EndMoveWindows(XParms xp, Parms p) 87{ 88 free(children); 89 free(positions); 90} 91 92void 93DoResizeWindows(XParms xp, Parms p, int64_t reps) 94{ 95 int i, j, delta2; 96 97 for (i = 0; i != reps; i++) { 98 delta1 = -delta1; 99 delta2 = delta1; 100 for (j = 0; j != p->objects; j++) { 101 delta2 = -delta2; 102 XResizeWindow(xp->d, children[j], 103 CHILDSIZE+delta2, CHILDSIZE-delta2); 104 } 105 CheckAbort (); 106 } 107} 108 109int 110InitCircWindows(XParms xp, Parms p, int64_t reps) 111{ 112 int i; 113 int pos; 114 int color; 115 116 children = (Window *) malloc (p->objects * sizeof (Window)); 117 for (i = 0; i != p->objects; i++) { 118 pos = i % STACK; 119 color = (i & 1 ? xp->foreground : xp->background); 120 children[i] = XCreateSimpleWindow (xp->d, xp->w, 121 pos*CHILDSIZE/4 + (i/STACK)*2*CHILDSIZE, pos*CHILDSIZE/4, 122 CHILDSIZE, CHILDSIZE, 0, color, color); 123 } 124 if (p->special) 125 XMapSubwindows (xp->d, xp->w); 126 return reps; 127} 128 129void 130DoCircWindows(XParms xp, Parms p, int64_t reps) 131{ 132 int i, j; 133 134 for (i = 0; i != reps; i++) 135 { 136 for (j = 0; j != p->objects; j++) 137 XCirculateSubwindows (xp->d, xp->w, RaiseLowest); 138 CheckAbort (); 139 } 140} 141 142void 143EndCircWindows(XParms xp, Parms p) 144{ 145 free(children); 146} 147 148 149int 150InitMoveTree(XParms xp, Parms p, int64_t reps) 151{ 152 int i = 0; 153 154 rows = (p->objects + MAXCOLS - 1) / MAXCOLS; 155 156 x_offset = 0; 157 y_offset = 0; 158 delta1 = 1; 159 160 children = (Window *) malloc (p->objects*sizeof (Window)); 161 positions = (XPoint *) malloc(p->objects*sizeof(XPoint)); 162 163 xmax = (CHILDSIZE+CHILDSPACE) * (rows > 1 ? MAXCOLS : p->objects); 164 ymax = rows * (CHILDSIZE+CHILDSPACE); 165 166 cover = XCreateSimpleWindow(xp->d, xp->w, 167 0, 0, xmax, ymax, 0, 168 xp->background, xp->background); 169 170 for (i = 0; i != p->objects; i++) { 171 positions[i].x = (CHILDSIZE+CHILDSPACE) * (i/rows) + CHILDSPACE/2; 172 positions[i].y = (CHILDSIZE+CHILDSPACE) * (i%rows) + CHILDSPACE/2; 173 children[i] = XCreateSimpleWindow(xp->d, cover, 174 positions[i].x, positions[i].y, 175 CHILDSIZE, CHILDSIZE, 0, xp->foreground, xp->foreground); 176 } 177 XMapSubwindows (xp->d, cover); 178 XMapWindow (xp->d, cover); 179 return reps; 180} 181 182void 183DoMoveTree(XParms xp, Parms p, int64_t reps) 184{ 185 int i; 186 187 for (i = 0; i != reps; i++) { 188 x_offset += 1; 189 y_offset += 3; 190 if (y_offset + ymax > HEIGHT) 191 y_offset = 0; 192 if (x_offset + xmax > WIDTH) 193 x_offset = 0; 194 XMoveWindow(xp->d, cover, x_offset, y_offset); 195 CheckAbort (); 196 } 197} 198 199void 200EndMoveTree(XParms xp, Parms p) 201{ 202 XDestroyWindow(xp->d, cover); 203 free(children); 204 free(positions); 205} 206