2 * Copyright 1989 Massachusetts Institute of Technology
4 * Permission to use, copy, modify, and distribute this software and its
5 * documentation for any purpose and without fee is hereby granted, provided
6 * that the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name of M.I.T. not be used in advertising
9 * or publicity pertaining to distribution of the software without specific,
10 * written prior permission. M.I.T. makes no representations about the
11 * suitability of this software for any purpose. It is provided "as is"
12 * without express or implied warranty.
14 * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
16 * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
18 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
19 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 /**********************************************************************
26 * Region related routines
28 * 4/26/99 D. J. Hawkey Jr.
30 **********************************************************************/
43 splitRegionEntry (re, grav1, grav2, w, h)
54 splitRegionEntry (re, grav2, grav1, w, re->h);
56 new = (RegionEntry *)malloc (sizeof (RegionEntry));
58 /* djhjr - 10/20/01 */
59 new->type = LTYPE_EXACT_NAME;
67 if (grav1 == D_SOUTH) {
69 re->y = new->y + new->h;
71 new->y = re->y + re->h;
77 splitRegionEntry (re, grav2, grav1, re->w, h);
79 new = (RegionEntry *)malloc (sizeof (RegionEntry));
81 /* djhjr - 10/20/01 */
82 new->type = LTYPE_EXACT_NAME;
90 if (grav1 == D_EAST) {
92 re->x = new->x + new->w;
94 new->x = re->x + re->w;
101 roundEntryUp (v, multiple)
103 return ((v + multiple - 1) / multiple) * multiple;
107 prevRegionEntry (re, rr)
113 if (re == rr->entries)
115 for (ep = rr->entries; ep->next != re; ep=ep->next)
121 * old is being freed; and is adjacent to re. Merge regions together.
124 mergeRegionEntries (old, re)
125 RegionEntry *old, *re;
127 if (old->y == re->y) {
128 re->w = old->w + re->w;
132 re->h = old->h + re->h;
139 downRegionEntry(rr, re)
143 RegionEntry *ep, *en;
147 ep = prevRegionEntry (re, rr);
150 if (ep && ep->usedby == 0 &&
151 ((ep->x == re->x && ep->w == re->w) ||
152 (ep->y == re->y && ep->h == re->h)))
155 mergeRegionEntries (re, ep);
156 if (re->usedby == USEDBY_NAME)
158 /* djhjr - 10/20/01 */
159 #ifndef NO_REGEX_SUPPORT
160 if (re->type & LTYPE_C_REGEXP)
165 ep = prevRegionEntry (ep, rr);
166 } else if (en && en->usedby == 0 &&
167 ((en->x == re->x && en->w == re->w) ||
168 (en->y == re->y && en->h == re->h)))
171 mergeRegionEntries (en, re);
172 if (en->usedby == USEDBY_NAME)
174 /* djhjr - 10/20/01 */
175 #ifndef NO_REGEX_SUPPORT
176 if (en->type & LTYPE_C_REGEXP)
187 AddRegion(geom, grav1, grav2, stepx, stepy)
189 int grav1, grav2, stepx, stepy;
194 rr = (RootRegion *)malloc(sizeof(RootRegion));
198 rr->stepx = (stepx <= 0) ? 2 : stepx; /* hard-coded value was '1' - djhjr - 9/26/99 */
199 rr->stepy = (stepy <= 0) ? 1 : stepy;
200 rr->x = rr->y = rr->w = rr->h = 0;
202 mask = XParseGeometry(geom, &rr->x, &rr->y, (unsigned int *)&rr->w, (unsigned int *)&rr->h);
203 if (mask & XNegative)
204 rr->x += Scr->MyDisplayWidth - rr->w;
205 if (mask & YNegative)
206 rr->y += Scr->MyDisplayHeight - rr->h;
208 rr->entries = (RegionEntry *)malloc(sizeof(RegionEntry));
209 rr->entries->next = 0;
210 rr->entries->x = rr->x;
211 rr->entries->y = rr->y;
212 rr->entries->w = rr->w;
213 rr->entries->h = rr->h;
214 rr->entries->u.twm_win = 0;
215 /* djhjr - 10/20/01 */
216 rr->entries->type = LTYPE_EXACT_NAME;
217 rr->entries->usedby = 0;
223 FreeRegionEntries (rr)
226 RegionEntry *re, *tmp;
228 for (re = rr->entries; re; re=tmp)
231 if (re->usedby == USEDBY_NAME)
233 /* djhjr - 10/20/01 */
234 #ifndef NO_REGEX_SUPPORT
235 if (re->type & LTYPE_C_REGEXP)
243 FreeRegions (first, last)
244 RootRegion *first, *last;
246 RootRegion *rr, *tmp;
248 for (rr = first; rr != NULL;)
251 FreeRegionEntries (rr);