1 /*
2 * tkGeometry.c --
3 *
4 * This file contains generic Tk code for geometry management (stuff
5 * that's used by all geometry managers).
6 *
7 * Copyright © 1990-1994 The Regents of the University of California.
8 * Copyright © 1994-1995 Sun Microsystems, Inc.
9 *
10 * See the file "license.terms" for information on usage and redistribution of
11 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
12 */
13
14 #include "tkInt.h"
15
16 /*
17 * Data structures of the following type are used by Tk_MaintainGeometry. For
18 * each content managed by Tk_MaintainGeometry, there is one of these structures
19 * associated with its container.
20 */
21
22 typedef struct MaintainContent {
23 Tk_Window content; /* The content window being positioned. */
24 Tk_Window container; /* The container that determines content's
25 * position; it must be a descendant of
26 * content's parent. */
27 int x, y; /* Desired position of content relative to
28 * container. */
29 int width, height; /* Desired dimensions of content. */
30 struct MaintainContent *nextPtr;
31 /* Next in list of Maintains associated with
32 * container. */
33 } MaintainContent;
34
35 /*
36 * For each window that has been specified as a content to Tk_MaintainGeometry,
37 * there is a structure of the following type:
38 */
39
40 typedef struct MaintainContainer {
41 Tk_Window ancestor; /* The lowest ancestor of this window for
42 * which we have *not* created a
43 * StructureNotify handler. May be the same as
44 * the window itself. */
45 int checkScheduled; /* Non-zero means that there is already a call
46 * to MaintainCheckProc scheduled as an idle
47 * handler. */
48 MaintainContent *contentPtr; /* First in list of all content associated with
49 * this container. */
50 } MaintainContainer;
51
52 /*
53 * Prototypes for static procedures in this file:
54 */
55
56 static void MaintainCheckProc(ClientData clientData);
57 static void MaintainContainerProc(ClientData clientData,
58 XEvent *eventPtr);
59 static void MaintainContentProc(ClientData clientData,
60 XEvent *eventPtr);
61
62 /*
63 *--------------------------------------------------------------
64 *
65 * Tk_ManageGeometry --
66 *
67 * Arrange for a particular procedure to manage the geometry of a given
68 * content window.
69 *
70 * Results:
71 * None.
72 *
73 * Side effects:
74 * Proc becomes the new geometry manager for tkwin, replacing any
75 * previous geometry manager. The geometry manager will be notified (by
76 * calling procedures in *mgrPtr) when interesting things happen in the
77 * future. If there was an existing geometry manager for tkwin different
78 * from the new one, it is notified by calling its lostContentProc.
79 *
80 *--------------------------------------------------------------
81 */
82
83 void
Tk_ManageGeometry(Tk_Window tkwin,const Tk_GeomMgr * mgrPtr,ClientData clientData)84 Tk_ManageGeometry(
85 Tk_Window tkwin, /* Window whose geometry is to be managed by
86 * proc. */
87 const Tk_GeomMgr *mgrPtr, /* Static structure describing the geometry
88 * manager. This structure must never go
89 * away. */
90 ClientData clientData) /* Arbitrary one-word argument to pass to
91 * geometry manager procedures. */
92 {
93 TkWindow *winPtr = (TkWindow *) tkwin;
94
95 if ((winPtr->geomMgrPtr != NULL) && (mgrPtr != NULL)
96 && ((winPtr->geomMgrPtr != mgrPtr)
97 || (winPtr->geomData != clientData))
98 && (winPtr->geomMgrPtr->lostContentProc != NULL)) {
99 winPtr->geomMgrPtr->lostContentProc(winPtr->geomData, tkwin);
100 }
101
102 winPtr->geomMgrPtr = mgrPtr;
103 winPtr->geomData = clientData;
104 }
105
106 /*
107 *--------------------------------------------------------------
108 *
109 * Tk_GeometryRequest --
110 *
111 * This procedure is invoked by widget code to indicate its preferences
112 * about the size of a window it manages. In general, widget code should
113 * call this procedure rather than Tk_ResizeWindow.
114 *
115 * Results:
116 * None.
117 *
118 * Side effects:
119 * The geometry manager for tkwin (if any) is invoked to handle the
120 * request. If possible, it will reconfigure tkwin and/or other windows
121 * to satisfy the request. The caller gets no indication of success or
122 * failure, but it will get X events if the window size was actually
123 * changed.
124 *
125 *--------------------------------------------------------------
126 */
127
128 void
Tk_GeometryRequest(Tk_Window tkwin,int reqWidth,int reqHeight)129 Tk_GeometryRequest(
130 Tk_Window tkwin, /* Window that geometry information pertains
131 * to. */
132 int reqWidth, int reqHeight)/* Minimum desired dimensions for window, in
133 * pixels. */
134 {
135 TkWindow *winPtr = (TkWindow *) tkwin;
136
137 /*
138 * X gets very upset if a window requests a width or height of zero, so
139 * rounds requested sizes up to at least 1.
140 */
141
142 if (reqWidth <= 0) {
143 reqWidth = 1;
144 }
145 if (reqHeight <= 0) {
146 reqHeight = 1;
147 }
148 if ((reqWidth == winPtr->reqWidth) && (reqHeight == winPtr->reqHeight)) {
149 return;
150 }
151 winPtr->reqWidth = reqWidth;
152 winPtr->reqHeight = reqHeight;
153 if ((winPtr->geomMgrPtr != NULL)
154 && (winPtr->geomMgrPtr->requestProc != NULL)) {
155 winPtr->geomMgrPtr->requestProc(winPtr->geomData, tkwin);
156 }
157 }
158
159 /*
160 *----------------------------------------------------------------------
161 *
162 * Tk_SetInternalBorderEx --
163 *
164 * Notify relevant geometry managers that a window has an internal border
165 * of a given width and that child windows should not be placed on that
166 * border.
167 *
168 * Results:
169 * None.
170 *
171 * Side effects:
172 * The border widths are recorded for the window, and all geometry
173 * managers of all children are notified so that can re-layout, if
174 * necessary.
175 *
176 *----------------------------------------------------------------------
177 */
178
179 void
Tk_SetInternalBorderEx(Tk_Window tkwin,int left,int right,int top,int bottom)180 Tk_SetInternalBorderEx(
181 Tk_Window tkwin, /* Window that will have internal border. */
182 int left, int right, /* Width of internal border, in pixels. */
183 int top, int bottom)
184 {
185 TkWindow *winPtr = (TkWindow *) tkwin;
186 int changed = 0;
187
188 if (left < 0) {
189 left = 0;
190 }
191 if (left != winPtr->internalBorderLeft) {
192 winPtr->internalBorderLeft = left;
193 changed = 1;
194 }
195
196 if (right < 0) {
197 right = 0;
198 }
199 if (right != winPtr->internalBorderRight) {
200 winPtr->internalBorderRight = right;
201 changed = 1;
202 }
203
204 if (top < 0) {
205 top = 0;
206 }
207 if (top != winPtr->internalBorderTop) {
208 winPtr->internalBorderTop = top;
209 changed = 1;
210 }
211
212 if (bottom < 0) {
213 bottom = 0;
214 }
215 if (bottom != winPtr->internalBorderBottom) {
216 winPtr->internalBorderBottom = bottom;
217 changed = 1;
218 }
219
220 /*
221 * All the content for which this is the container window must now be
222 * repositioned to take account of the new internal border width. To
223 * signal all the geometry managers to do this, trigger a ConfigureNotify
224 * event. This will cause geometry managers to recompute everything.
225 */
226
227 if (changed) {
228 TkDoConfigureNotify(winPtr);
229 }
230 }
231
232 /*
233 *----------------------------------------------------------------------
234 *
235 * Tk_SetInternalBorder --
236 *
237 * Notify relevant geometry managers that a window has an internal border
238 * of a given width and that child windows should not be placed on that
239 * border.
240 *
241 * Results:
242 * None.
243 *
244 * Side effects:
245 * The border width is recorded for the window, and all geometry managers
246 * of all children are notified so that can re-layout, if necessary.
247 *
248 *----------------------------------------------------------------------
249 */
250
251 void
Tk_SetInternalBorder(Tk_Window tkwin,int width)252 Tk_SetInternalBorder(
253 Tk_Window tkwin, /* Window that will have internal border. */
254 int width) /* Width of internal border, in pixels. */
255 {
256 Tk_SetInternalBorderEx(tkwin, width, width, width, width);
257 }
258
259 /*
260 *----------------------------------------------------------------------
261 *
262 * Tk_SetMinimumRequestSize --
263 *
264 * Notify relevant geometry managers that a window has a minimum request
265 * size.
266 *
267 * Results:
268 * None.
269 *
270 * Side effects:
271 * The minimum request size is recorded for the window, and a new size is
272 * requested for the window, if necessary.
273 *
274 *----------------------------------------------------------------------
275 */
276
277 void
Tk_SetMinimumRequestSize(Tk_Window tkwin,int minWidth,int minHeight)278 Tk_SetMinimumRequestSize(
279 Tk_Window tkwin, /* Window that will have internal border. */
280 int minWidth, int minHeight)/* Minimum requested size, in pixels. */
281 {
282 TkWindow *winPtr = (TkWindow *) tkwin;
283
284 if ((winPtr->minReqWidth == minWidth) &&
285 (winPtr->minReqHeight == minHeight)) {
286 return;
287 }
288
289 winPtr->minReqWidth = minWidth;
290 winPtr->minReqHeight = minHeight;
291
292 /*
293 * The changed min size may cause geometry managers to get a different
294 * result, so make them recompute. To signal all the geometry managers to
295 * do this, just resize the window to its current size. The
296 * ConfigureNotify event will cause geometry managers to recompute
297 * everything.
298 */
299
300 Tk_ResizeWindow(tkwin, Tk_Width(tkwin), Tk_Height(tkwin));
301 }
302
303 /*
304 *----------------------------------------------------------------------
305 *
306 * TkSetGeometryContainer --
307 *
308 * Set a geometry container for this window. Only one container may own
309 * a window at any time.
310 *
311 * Results:
312 * A standard Tcl result.
313 *
314 * Side effects:
315 * The geometry container is recorded for the window.
316 *
317 *----------------------------------------------------------------------
318 */
319
320 int
TkSetGeometryContainer(Tcl_Interp * interp,Tk_Window tkwin,const char * name)321 TkSetGeometryContainer(
322 Tcl_Interp *interp, /* Current interpreter, for error. */
323 Tk_Window tkwin, /* Window that will have geometry container
324 * set. */
325 const char *name) /* The name of the geometry manager. */
326 {
327 TkWindow *winPtr = (TkWindow *) tkwin;
328
329 if (winPtr->geomMgrName != NULL &&
330 strcmp(winPtr->geomMgrName, name) == 0) {
331 return TCL_OK;
332 }
333 if (winPtr->geomMgrName != NULL) {
334 if (interp != NULL) {
335 Tcl_SetObjResult(interp, Tcl_ObjPrintf(
336 "cannot use geometry manager %s inside %s because"
337 " %s is already managing it's content windows",
338 name, Tk_PathName(tkwin), winPtr->geomMgrName));
339 Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "FIGHT", NULL);
340 }
341 return TCL_ERROR;
342 }
343
344 winPtr->geomMgrName = (char *)ckalloc(strlen(name) + 1);
345 strcpy(winPtr->geomMgrName, name);
346 return TCL_OK;
347 }
348
349 /*
350 *----------------------------------------------------------------------
351 *
352 * TkFreeGeometryContainer --
353 *
354 * Remove a geometry container for this window. Only one container may own
355 * a window at any time.
356 *
357 * Results:
358 * None.
359 *
360 * Side effects:
361 * The geometry container is cleared for the window.
362 *
363 *----------------------------------------------------------------------
364 */
365
366 void
TkFreeGeometryContainer(Tk_Window tkwin,const char * name)367 TkFreeGeometryContainer(
368 Tk_Window tkwin, /* Window that will have geometry container
369 * cleared. */
370 const char *name) /* The name of the geometry manager. */
371 {
372 TkWindow *winPtr = (TkWindow *) tkwin;
373
374 if (winPtr->geomMgrName != NULL &&
375 strcmp(winPtr->geomMgrName, name) != 0) {
376 Tcl_Panic("Trying to free %s from geometry manager %s",
377 winPtr->geomMgrName, name);
378 }
379 if (winPtr->geomMgrName != NULL) {
380 ckfree(winPtr->geomMgrName);
381 winPtr->geomMgrName = NULL;
382 }
383 }
384
385 /*
386 *----------------------------------------------------------------------
387 *
388 * Tk_MaintainGeometry --
389 *
390 * This procedure is invoked by geometry managers to handle content whose
391 * container's are not their parents. It translates the desired geometry for
392 * the content into the coordinate system of the parent and respositions
393 * the content if it isn't already at the right place. Furthermore, it sets
394 * up event handlers so that if the container (or any of its ancestors up to
395 * the content's parent) is mapped, unmapped, or moved, then the content will
396 * be adjusted to match.
397 *
398 * Results:
399 * None.
400 *
401 * Side effects:
402 * Event handlers are created and state is allocated to keep track of
403 * content. Note: if content was already managed for container by
404 * Tk_MaintainGeometry, then the previous information is replaced with
405 * the new information. The caller must eventually call
406 * Tk_UnmaintainGeometry to eliminate the correspondence (or, the state
407 * is automatically freed when either window is destroyed).
408 *
409 *----------------------------------------------------------------------
410 */
411
412 void
Tk_MaintainGeometry(Tk_Window window,Tk_Window container,int x,int y,int width,int height)413 Tk_MaintainGeometry(
414 Tk_Window window, /* Window for geometry management. */
415 Tk_Window container, /* Container for window; must be a descendant of
416 * window's parent. */
417 int x, int y, /* Desired position of window within container. */
418 int width, int height) /* Desired dimensions for window. */
419 {
420 Tcl_HashEntry *hPtr;
421 MaintainContainer *containerPtr;
422 MaintainContent *contentPtr;
423 int isNew, map;
424 Tk_Window ancestor, parent;
425 TkDisplay *dispPtr = ((TkWindow *) container)->dispPtr;
426
427 ((TkWindow *)window)->maintainerPtr = (TkWindow *)container;
428
429 if (container == Tk_Parent(window)) {
430 /*
431 * If the window is a direct descendant of the container, don't bother
432 * setting up the extra infrastructure for management, just make a
433 * call to Tk_MoveResizeWindow; the parent/child relationship will
434 * take care of the rest.
435 */
436
437 Tk_MoveResizeWindow(window, x, y, width, height);
438
439 /*
440 * Map the window if the container is already mapped; otherwise, wait
441 * until the container is mapped later (in which case mapping the window
442 * is taken care of elsewhere).
443 */
444
445 if (Tk_IsMapped(container)) {
446 Tk_MapWindow(window);
447 }
448 return;
449 }
450
451 if (!dispPtr->geomInit) {
452 dispPtr->geomInit = 1;
453 Tcl_InitHashTable(&dispPtr->maintainHashTable, TCL_ONE_WORD_KEYS);
454 }
455
456 /*
457 * See if there is already a MaintainContainer structure for the container; if
458 * not, then create one.
459 */
460
461 parent = Tk_Parent(window);
462 hPtr = Tcl_CreateHashEntry(&dispPtr->maintainHashTable,
463 (char *) container, &isNew);
464 if (!isNew) {
465 containerPtr = (MaintainContainer *)Tcl_GetHashValue(hPtr);
466 } else {
467 containerPtr = (MaintainContainer *)ckalloc(sizeof(MaintainContainer));
468 containerPtr->ancestor = container;
469 containerPtr->checkScheduled = 0;
470 containerPtr->contentPtr = NULL;
471 Tcl_SetHashValue(hPtr, containerPtr);
472 }
473
474 /*
475 * Create a MaintainContent structure for the window if there isn't already
476 * one.
477 */
478
479 for (contentPtr = containerPtr->contentPtr; contentPtr != NULL;
480 contentPtr = contentPtr->nextPtr) {
481 if (contentPtr->content == window) {
482 goto gotContent;
483 }
484 }
485 contentPtr = (MaintainContent *)ckalloc(sizeof(MaintainContent));
486 contentPtr->content = window;
487 contentPtr->container = container;
488 contentPtr->nextPtr = containerPtr->contentPtr;
489 containerPtr->contentPtr = contentPtr;
490 Tk_CreateEventHandler(window, StructureNotifyMask, MaintainContentProc,
491 contentPtr);
492
493 /*
494 * Make sure that there are event handlers registered for all the windows
495 * between container and windows's parent (including container but not window's
496 * parent). There may already be handlers for container and some of its
497 * ancestors (containerPtr->ancestor tells how many).
498 */
499
500 for (ancestor = container; ancestor != parent;
501 ancestor = Tk_Parent(ancestor)) {
502 if (ancestor == containerPtr->ancestor) {
503 Tk_CreateEventHandler(ancestor, StructureNotifyMask,
504 MaintainContainerProc, containerPtr);
505 containerPtr->ancestor = Tk_Parent(ancestor);
506 }
507 }
508
509 /*
510 * Fill in up-to-date information in the structure, then update the window
511 * if it's not currently in the right place or state.
512 */
513
514 gotContent:
515 contentPtr->x = x;
516 contentPtr->y = y;
517 contentPtr->width = width;
518 contentPtr->height = height;
519 map = 1;
520 for (ancestor = contentPtr->container; ; ancestor = Tk_Parent(ancestor)) {
521 if (!Tk_IsMapped(ancestor) && (ancestor != parent)) {
522 map = 0;
523 }
524 if (ancestor == parent) {
525 if ((x != Tk_X(contentPtr->content))
526 || (y != Tk_Y(contentPtr->content))
527 || (width != Tk_Width(contentPtr->content))
528 || (height != Tk_Height(contentPtr->content))) {
529 Tk_MoveResizeWindow(contentPtr->content, x, y, width, height);
530 }
531 if (map) {
532 Tk_MapWindow(contentPtr->content);
533 } else {
534 Tk_UnmapWindow(contentPtr->content);
535 }
536 break;
537 }
538 x += Tk_X(ancestor) + Tk_Changes(ancestor)->border_width;
539 y += Tk_Y(ancestor) + Tk_Changes(ancestor)->border_width;
540 }
541 }
542
543 /*
544 *----------------------------------------------------------------------
545 *
546 * Tk_UnmaintainGeometry --
547 *
548 * This procedure cancels a previous Tk_MaintainGeometry call, so that
549 * the relationship between window and container is no longer maintained.
550 *
551 * Results:
552 * None.
553 *
554 * Side effects:
555 * The window is unmapped and state is released, so that window won't track
556 * container any more. If we weren't previously managing window relative to
557 * container, then this procedure has no effect.
558 *
559 *----------------------------------------------------------------------
560 */
561
562 void
Tk_UnmaintainGeometry(Tk_Window window,Tk_Window container)563 Tk_UnmaintainGeometry(
564 Tk_Window window, /* WIndow for geometry management. */
565 Tk_Window container) /* Container for window; must be a descendant of
566 * window's parent. */
567 {
568 Tcl_HashEntry *hPtr;
569 MaintainContainer *containerPtr;
570 MaintainContent *contentPtr, *prevPtr;
571 Tk_Window ancestor;
572 TkDisplay *dispPtr = ((TkWindow *) window)->dispPtr;
573
574 ((TkWindow *)window)->maintainerPtr = NULL;
575
576 if (container == Tk_Parent(window)) {
577 /*
578 * If the window is a direct descendant of the container,
579 * Tk_MaintainGeometry will not have set up any of the extra
580 * infrastructure. Don't even bother to look for it, just return.
581 */
582 return;
583 }
584
585 if (!dispPtr->geomInit) {
586 dispPtr->geomInit = 1;
587 Tcl_InitHashTable(&dispPtr->maintainHashTable, TCL_ONE_WORD_KEYS);
588 }
589
590 if (!(((TkWindow *) window)->flags & TK_ALREADY_DEAD)) {
591 Tk_UnmapWindow(window);
592 }
593 hPtr = Tcl_FindHashEntry(&dispPtr->maintainHashTable, container);
594 if (hPtr == NULL) {
595 return;
596 }
597 containerPtr = (MaintainContainer *)Tcl_GetHashValue(hPtr);
598 contentPtr = containerPtr->contentPtr;
599 if (contentPtr->content == window) {
600 containerPtr->contentPtr = contentPtr->nextPtr;
601 } else {
602 for (prevPtr = contentPtr, contentPtr = contentPtr->nextPtr; ;
603 prevPtr = contentPtr, contentPtr = contentPtr->nextPtr) {
604 if (contentPtr == NULL) {
605 return;
606 }
607 if (contentPtr->content == window) {
608 prevPtr->nextPtr = contentPtr->nextPtr;
609 break;
610 }
611 }
612 }
613 Tk_DeleteEventHandler(contentPtr->content, StructureNotifyMask,
614 MaintainContentProc, contentPtr);
615 ckfree(contentPtr);
616 if (containerPtr->contentPtr == NULL) {
617 if (containerPtr->ancestor != NULL) {
618 for (ancestor = container; ; ancestor = Tk_Parent(ancestor)) {
619 Tk_DeleteEventHandler(ancestor, StructureNotifyMask,
620 MaintainContainerProc, containerPtr);
621 if (ancestor == containerPtr->ancestor) {
622 break;
623 }
624 }
625 }
626 if (containerPtr->checkScheduled) {
627 Tcl_CancelIdleCall(MaintainCheckProc, containerPtr);
628 }
629 Tcl_DeleteHashEntry(hPtr);
630 ckfree(containerPtr);
631 }
632 }
633
634 /*
635 *----------------------------------------------------------------------
636 *
637 * MaintainContainerProc --
638 *
639 * This procedure is invoked by the Tk event dispatcher in response to
640 * StructureNotify events on the container or one of its ancestors, on
641 * behalf of Tk_MaintainGeometry.
642 *
643 * Results:
644 * None.
645 *
646 * Side effects:
647 * It schedules a call to MaintainCheckProc, which will eventually caused
648 * the postions and mapped states to be recalculated for all the
649 * maintained windows of the container. Or, if the container window is being
650 * deleted then state is cleaned up.
651 *
652 *----------------------------------------------------------------------
653 */
654
655 static void
MaintainContainerProc(ClientData clientData,XEvent * eventPtr)656 MaintainContainerProc(
657 ClientData clientData, /* Pointer to MaintainContainer structure for the
658 * container window. */
659 XEvent *eventPtr) /* Describes what just happened. */
660 {
661 MaintainContainer *containerPtr = (MaintainContainer *)clientData;
662 MaintainContent *contentPtr;
663 int done;
664
665 if ((eventPtr->type == ConfigureNotify)
666 || (eventPtr->type == MapNotify)
667 || (eventPtr->type == UnmapNotify)) {
668 if (!containerPtr->checkScheduled) {
669 containerPtr->checkScheduled = 1;
670 Tcl_DoWhenIdle(MaintainCheckProc, containerPtr);
671 }
672 } else if (eventPtr->type == DestroyNotify) {
673 /*
674 * Delete all of the state associated with this container, but be careful
675 * not to use containerPtr after the last window is deleted, since its
676 * memory will have been freed.
677 */
678
679 done = 0;
680 do {
681 contentPtr = containerPtr->contentPtr;
682 if (contentPtr->nextPtr == NULL) {
683 done = 1;
684 }
685 Tk_UnmaintainGeometry(contentPtr->content, contentPtr->container);
686 } while (!done);
687 }
688 }
689
690 /*
691 *----------------------------------------------------------------------
692 *
693 * MaintainContentProc --
694 *
695 * This procedure is invoked by the Tk event dispatcher in response to
696 * StructureNotify events on a window being managed by
697 * Tk_MaintainGeometry.
698 *
699 * Results:
700 * None.
701 *
702 * Side effects:
703 * If the event is a DestroyNotify event then the Maintain state and
704 * event handlers for this window are deleted.
705 *
706 *----------------------------------------------------------------------
707 */
708
709 static void
MaintainContentProc(ClientData clientData,XEvent * eventPtr)710 MaintainContentProc(
711 ClientData clientData, /* Pointer to MaintainContent structure for
712 * container-window pair. */
713 XEvent *eventPtr) /* Describes what just happened. */
714 {
715 MaintainContent *contentPtr = (MaintainContent *)clientData;
716
717 if (eventPtr->type == DestroyNotify) {
718 Tk_UnmaintainGeometry(contentPtr->content, contentPtr->container);
719 }
720 }
721
722 /*
723 *----------------------------------------------------------------------
724 *
725 * MaintainCheckProc --
726 *
727 * This procedure is invoked by the Tk event dispatcher as an idle
728 * handler, when a container or one of its ancestors has been reconfigured,
729 * mapped, or unmapped. Its job is to scan all of the windows for the
730 * container and reposition them, map them, or unmap them as needed to
731 * maintain their geometry relative to the container.
732 *
733 * Results:
734 * None.
735 *
736 * Side effects:
737 * Windows can get repositioned, mapped, or unmapped.
738 *
739 *----------------------------------------------------------------------
740 */
741
742 static void
MaintainCheckProc(ClientData clientData)743 MaintainCheckProc(
744 ClientData clientData) /* Pointer to MaintainContainer structure for the
745 * container window. */
746 {
747 MaintainContainer *containerPtr = (MaintainContainer *)clientData;
748 MaintainContent *contentPtr;
749 Tk_Window ancestor, parent;
750 int x, y, map;
751
752 containerPtr->checkScheduled = 0;
753 for (contentPtr = containerPtr->contentPtr; contentPtr != NULL;
754 contentPtr = contentPtr->nextPtr) {
755 parent = Tk_Parent(contentPtr->content);
756 x = contentPtr->x;
757 y = contentPtr->y;
758 map = 1;
759 for (ancestor = contentPtr->container; ; ancestor = Tk_Parent(ancestor)) {
760 if (!Tk_IsMapped(ancestor) && (ancestor != parent)) {
761 map = 0;
762 }
763 if (ancestor == parent) {
764 if ((x != Tk_X(contentPtr->content))
765 || (y != Tk_Y(contentPtr->content))) {
766 Tk_MoveWindow(contentPtr->content, x, y);
767 }
768 if (map) {
769 Tk_MapWindow(contentPtr->content);
770 } else {
771 Tk_UnmapWindow(contentPtr->content);
772 }
773 break;
774 }
775 x += Tk_X(ancestor) + Tk_Changes(ancestor)->border_width;
776 y += Tk_Y(ancestor) + Tk_Changes(ancestor)->border_width;
777 }
778 }
779 }
780
781 /*
782 * Local Variables:
783 * mode: c
784 * c-basic-offset: 4
785 * fill-column: 78
786 * End:
787 */
788