Manage.c revision a3bd7f05
1444c061aSmrg/*********************************************************** 2249c3046SmrgCopyright (c) 1993, Oracle and/or its affiliates. All rights reserved. 31477040fSmrg 41477040fSmrgPermission is hereby granted, free of charge, to any person obtaining a 51477040fSmrgcopy of this software and associated documentation files (the "Software"), 61477040fSmrgto deal in the Software without restriction, including without limitation 71477040fSmrgthe rights to use, copy, modify, merge, publish, distribute, sublicense, 81477040fSmrgand/or sell copies of the Software, and to permit persons to whom the 91477040fSmrgSoftware is furnished to do so, subject to the following conditions: 101477040fSmrg 111477040fSmrgThe above copyright notice and this permission notice (including the next 121477040fSmrgparagraph) shall be included in all copies or substantial portions of the 131477040fSmrgSoftware. 141477040fSmrg 151477040fSmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 161477040fSmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 171477040fSmrgFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 181477040fSmrgTHE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 191477040fSmrgLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 201477040fSmrgFROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 211477040fSmrgDEALINGS IN THE SOFTWARE. 221477040fSmrg 231477040fSmrgCopyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts. 24444c061aSmrg 25444c061aSmrg All Rights Reserved 26444c061aSmrg 27444c061aSmrgPermission to use, copy, modify, and distribute this software and its 28444c061aSmrgdocumentation for any purpose and without fee is hereby granted, 29444c061aSmrgprovided that the above copyright notice appear in all copies and that 30444c061aSmrgboth that copyright notice and this permission notice appear in 311477040fSmrgsupporting documentation, and that the name of Digital not be 32444c061aSmrgused in advertising or publicity pertaining to distribution of the 33444c061aSmrgsoftware without specific, written prior permission. 34444c061aSmrg 35444c061aSmrgDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING 36444c061aSmrgALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL 37444c061aSmrgDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR 38444c061aSmrgANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 39444c061aSmrgWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 40444c061aSmrgARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 41444c061aSmrgSOFTWARE. 42444c061aSmrg 43444c061aSmrg******************************************************************/ 44444c061aSmrg 45444c061aSmrg/* 46444c061aSmrg 47444c061aSmrgCopyright 1987, 1988, 1994, 1998 The Open Group 48444c061aSmrg 49444c061aSmrgPermission to use, copy, modify, distribute, and sell this software and its 50444c061aSmrgdocumentation for any purpose is hereby granted without fee, provided that 51444c061aSmrgthe above copyright notice appear in all copies and that both that 52444c061aSmrgcopyright notice and this permission notice appear in supporting 53444c061aSmrgdocumentation. 54444c061aSmrg 55444c061aSmrgThe above copyright notice and this permission notice shall be included in 56444c061aSmrgall copies or substantial portions of the Software. 57444c061aSmrg 58444c061aSmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 59444c061aSmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 60444c061aSmrgFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 61444c061aSmrgOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 62444c061aSmrgAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 63444c061aSmrgCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 64444c061aSmrg 65444c061aSmrgExcept as contained in this notice, the name of The Open Group shall not be 66444c061aSmrgused in advertising or otherwise to promote the sale, use or other dealings 67444c061aSmrgin this Software without prior written authorization from The Open Group. 68444c061aSmrg 69444c061aSmrg*/ 70444c061aSmrg 71444c061aSmrg#ifdef HAVE_CONFIG_H 72444c061aSmrg#include <config.h> 73444c061aSmrg#endif 74444c061aSmrg#include "IntrinsicI.h" 75444c061aSmrg 760568f49bSmrgstatic _Xconst _XtString XtNinvalidChild = "invalidChild"; 770568f49bSmrgstatic _Xconst _XtString XtNxtUnmanageChildren = "xtUnmanageChildren"; 780568f49bSmrgstatic _Xconst _XtString XtNxtManageChildren = "xtManageChildren"; 790568f49bSmrgstatic _Xconst _XtString XtNxtChangeManagedSet = "xtChangeManagedSet"; 80444c061aSmrg 81a3bd7f05Smrgstatic void 82a3bd7f05SmrgUnmanageChildren(WidgetList children, 83a3bd7f05Smrg Cardinal num_children, 84a3bd7f05Smrg Widget parent, 85a3bd7f05Smrg Cardinal *num_unique_children, 86a3bd7f05Smrg Boolean call_change_managed, 87a3bd7f05Smrg _Xconst _XtString caller_func) 88444c061aSmrg{ 89a3bd7f05Smrg Widget child; 90a3bd7f05Smrg Cardinal i; 91a3bd7f05Smrg XtWidgetProc change_managed = NULL; 92a3bd7f05Smrg Bool parent_realized = False; 93444c061aSmrg 94444c061aSmrg *num_unique_children = 0; 95444c061aSmrg 96444c061aSmrg if (XtIsComposite((Widget) parent)) { 97a3bd7f05Smrg LOCK_PROCESS; 98444c061aSmrg change_managed = ((CompositeWidgetClass) parent->core.widget_class) 99a3bd7f05Smrg ->composite_class.change_managed; 100a3bd7f05Smrg UNLOCK_PROCESS; 101a3bd7f05Smrg parent_realized = XtIsRealized((Widget) parent); 102a3bd7f05Smrg } 103a3bd7f05Smrg else { 104a3bd7f05Smrg XtAppErrorMsg(XtWidgetToApplicationContext((Widget) parent), 105a3bd7f05Smrg "invalidParent", caller_func, XtCXtToolkitError, 106a3bd7f05Smrg "Attempt to unmanage a child when parent is not Composite", 107a3bd7f05Smrg NULL, NULL); 108444c061aSmrg } 109444c061aSmrg 110444c061aSmrg for (i = 0; i < num_children; i++) { 111a3bd7f05Smrg child = children[i]; 112a3bd7f05Smrg if (child == NULL) { 113a3bd7f05Smrg XtAppWarningMsg(XtWidgetToApplicationContext(parent), 114a3bd7f05Smrg XtNinvalidChild, caller_func, XtCXtToolkitError, 115a3bd7f05Smrg "Null child passed to XtUnmanageChildren", 116a3bd7f05Smrg NULL, NULL); 117a3bd7f05Smrg return; 118a3bd7f05Smrg } 119444c061aSmrg if (child->core.parent != parent) { 120a3bd7f05Smrg XtAppWarningMsg(XtWidgetToApplicationContext(parent), 121a3bd7f05Smrg "ambiguousParent", caller_func, XtCXtToolkitError, 122a3bd7f05Smrg "Not all children have same parent in UnmanageChildren", 123a3bd7f05Smrg NULL, NULL); 124a3bd7f05Smrg } 125a3bd7f05Smrg else if (child->core.managed) { 126444c061aSmrg (*num_unique_children)++; 127a3bd7f05Smrg CALLGEOTAT(_XtGeoTrace(child, "Child \"%s\" is marked unmanaged\n", 128a3bd7f05Smrg XtName(child))); 129a3bd7f05Smrg child->core.managed = FALSE; 130444c061aSmrg if (XtIsWidget(child) 131a3bd7f05Smrg && XtIsRealized(child) 132a3bd7f05Smrg && child->core.mapped_when_managed) 133a3bd7f05Smrg XtUnmapWidget(child); 134a3bd7f05Smrg else { /* RectObj child */ 135a3bd7f05Smrg Widget pw = child->core.parent; 136a3bd7f05Smrg RectObj r = (RectObj) child; 137a3bd7f05Smrg 138a3bd7f05Smrg while ((pw != NULL) && (!XtIsWidget(pw))) 139a3bd7f05Smrg pw = pw->core.parent; 140a3bd7f05Smrg if ((pw != NULL) && XtIsRealized(pw)) 141a3bd7f05Smrg XClearArea(XtDisplay(pw), XtWindow(pw), 142a3bd7f05Smrg r->rectangle.x, r->rectangle.y, 143a3bd7f05Smrg (unsigned) (r->rectangle.width + 144a3bd7f05Smrg (r->rectangle.border_width << 1)), 145a3bd7f05Smrg (unsigned) (r->rectangle.height + 146a3bd7f05Smrg (r->rectangle.border_width << 1)), 147a3bd7f05Smrg TRUE); 148a3bd7f05Smrg } 149444c061aSmrg 150444c061aSmrg } 151444c061aSmrg } 152444c061aSmrg if (call_change_managed && *num_unique_children != 0 && 153a3bd7f05Smrg change_managed != NULL && parent_realized) { 154a3bd7f05Smrg CALLGEOTAT(_XtGeoTrace((Widget) parent, 155a3bd7f05Smrg "Call parent: \"%s\"[%d,%d]'s changemanaged proc\n", 156a3bd7f05Smrg XtName((Widget) parent), 157a3bd7f05Smrg parent->core.width, parent->core.height)); 158a3bd7f05Smrg (*change_managed) (parent); 159444c061aSmrg } 160a3bd7f05Smrg} /* UnmanageChildren */ 161444c061aSmrg 162a3bd7f05Smrgvoid 163a3bd7f05SmrgXtUnmanageChildren(WidgetList children, Cardinal num_children) 164444c061aSmrg{ 165444c061aSmrg Widget parent, hookobj; 166444c061aSmrg Cardinal ii; 167a3bd7f05Smrg 168444c061aSmrg#ifdef XTHREADS 169444c061aSmrg XtAppContext app; 170444c061aSmrg#endif 171444c061aSmrg 172a3bd7f05Smrg if (num_children == 0) 173a3bd7f05Smrg return; 174444c061aSmrg if (children[0] == NULL) { 175a3bd7f05Smrg XtWarningMsg(XtNinvalidChild, XtNxtUnmanageChildren, XtCXtToolkitError, 176a3bd7f05Smrg "Null child found in argument list to unmanage", 177a3bd7f05Smrg NULL, NULL); 178a3bd7f05Smrg return; 179444c061aSmrg } 180444c061aSmrg#ifdef XTHREADS 181444c061aSmrg app = XtWidgetToApplicationContext(children[0]); 182444c061aSmrg#endif 183444c061aSmrg LOCK_APP(app); 184444c061aSmrg parent = children[0]->core.parent; 185444c061aSmrg if (parent->core.being_destroyed) { 186a3bd7f05Smrg UNLOCK_APP(app); 187a3bd7f05Smrg return; 188444c061aSmrg } 189444c061aSmrg UnmanageChildren(children, num_children, parent, &ii, 190a3bd7f05Smrg (Boolean) True, XtNxtUnmanageChildren); 191444c061aSmrg hookobj = XtHooksOfDisplay(XtDisplayOfObject(children[0])); 192444c061aSmrg if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) { 193a3bd7f05Smrg XtChangeHookDataRec call_data; 194a3bd7f05Smrg 195a3bd7f05Smrg call_data.type = XtHunmanageChildren; 196a3bd7f05Smrg call_data.widget = parent; 197a3bd7f05Smrg call_data.event_data = (XtPointer) children; 198a3bd7f05Smrg call_data.num_event_data = num_children; 199a3bd7f05Smrg XtCallCallbackList(hookobj, 200a3bd7f05Smrg ((HookObject) hookobj)->hooks.changehook_callbacks, 201a3bd7f05Smrg (XtPointer) &call_data); 202444c061aSmrg } 203444c061aSmrg UNLOCK_APP(app); 204a3bd7f05Smrg} /* XtUnmanageChildren */ 205444c061aSmrg 206a3bd7f05Smrgvoid 207a3bd7f05SmrgXtUnmanageChild(Widget child) 208444c061aSmrg{ 209a3bd7f05Smrg XtUnmanageChildren(&child, (Cardinal) 1); 210a3bd7f05Smrg} /* XtUnmanageChild */ 211a3bd7f05Smrg 212a3bd7f05Smrgstatic void 213a3bd7f05SmrgManageChildren(WidgetList children, 214a3bd7f05Smrg Cardinal num_children, 215a3bd7f05Smrg Widget parent, 216a3bd7f05Smrg Boolean call_change_managed, 217a3bd7f05Smrg _Xconst _XtString caller_func) 218444c061aSmrg{ 219444c061aSmrg#define MAXCHILDREN 100 220a3bd7f05Smrg Widget child; 221a3bd7f05Smrg Cardinal num_unique_children, i; 222a3bd7f05Smrg XtWidgetProc change_managed = NULL; 223a3bd7f05Smrg WidgetList unique_children; 224a3bd7f05Smrg Widget cache[MAXCHILDREN]; 225a3bd7f05Smrg Bool parent_realized = False; 226444c061aSmrg 227444c061aSmrg if (XtIsComposite((Widget) parent)) { 228a3bd7f05Smrg LOCK_PROCESS; 229444c061aSmrg change_managed = ((CompositeWidgetClass) parent->core.widget_class) 230a3bd7f05Smrg ->composite_class.change_managed; 231a3bd7f05Smrg UNLOCK_PROCESS; 232a3bd7f05Smrg parent_realized = XtIsRealized((Widget) parent); 233a3bd7f05Smrg } 234a3bd7f05Smrg else { 235a3bd7f05Smrg XtAppErrorMsg(XtWidgetToApplicationContext((Widget) parent), 236a3bd7f05Smrg "invalidParent", caller_func, XtCXtToolkitError, 237a3bd7f05Smrg "Attempt to manage a child when parent is not Composite", 238a3bd7f05Smrg NULL, NULL); 239444c061aSmrg } 240444c061aSmrg 241444c061aSmrg /* Construct new list of children that really need to be operated upon. */ 242444c061aSmrg if (num_children <= MAXCHILDREN) { 243a3bd7f05Smrg unique_children = cache; 244a3bd7f05Smrg } 245a3bd7f05Smrg else { 246a3bd7f05Smrg unique_children = (WidgetList) 247a3bd7f05Smrg __XtMalloc((Cardinal) ((size_t) num_children * sizeof(Widget))); 248444c061aSmrg } 249444c061aSmrg num_unique_children = 0; 250444c061aSmrg for (i = 0; i < num_children; i++) { 251a3bd7f05Smrg child = children[i]; 252a3bd7f05Smrg if (child == NULL) { 253a3bd7f05Smrg XtAppWarningMsg(XtWidgetToApplicationContext((Widget) parent), 254a3bd7f05Smrg XtNinvalidChild, caller_func, XtCXtToolkitError, 255a3bd7f05Smrg "null child passed to ManageChildren", NULL, NULL); 256a3bd7f05Smrg if (unique_children != cache) 257a3bd7f05Smrg XtFree((char *) unique_children); 258a3bd7f05Smrg return; 259a3bd7f05Smrg } 260444c061aSmrg#ifdef DEBUG 261a3bd7f05Smrg if (!XtIsRectObj(child)) { 262a3bd7f05Smrg String params[2]; 263a3bd7f05Smrg Cardinal num_params = 2; 264a3bd7f05Smrg 265a3bd7f05Smrg params[0] = XtName(child); 266a3bd7f05Smrg params[1] = child->core.widget_class->core_class.class_name; 267a3bd7f05Smrg XtAppWarningMsg(XtWidgetToApplicationContext((Widget) parent), 268a3bd7f05Smrg "notRectObj", caller_func, XtCXtToolkitError, 269a3bd7f05Smrg "child \"%s\", class %s is not a RectObj", 270a3bd7f05Smrg params, &num_params); 271a3bd7f05Smrg continue; 272a3bd7f05Smrg } 273a3bd7f05Smrg#endif /*DEBUG*/ 274a3bd7f05Smrg if (child->core.parent != parent) { 275a3bd7f05Smrg XtAppWarningMsg(XtWidgetToApplicationContext((Widget) parent), 276a3bd7f05Smrg "ambiguousParent", caller_func, XtCXtToolkitError, 277a3bd7f05Smrg "Not all children have same parent in XtManageChildren", 278a3bd7f05Smrg NULL, NULL); 279a3bd7f05Smrg } 280a3bd7f05Smrg else if (!child->core.managed && !child->core.being_destroyed) { 281a3bd7f05Smrg unique_children[num_unique_children++] = child; 282a3bd7f05Smrg CALLGEOTAT(_XtGeoTrace(child, 283a3bd7f05Smrg "Child \"%s\"[%d,%d] is marked managed\n", 284a3bd7f05Smrg XtName(child), 285a3bd7f05Smrg child->core.width, child->core.height)); 286a3bd7f05Smrg child->core.managed = TRUE; 287a3bd7f05Smrg } 288444c061aSmrg } 289444c061aSmrg 290444c061aSmrg if ((call_change_managed || num_unique_children != 0) && parent_realized) { 291a3bd7f05Smrg /* Compute geometry of new managed set of children. */ 292a3bd7f05Smrg if (change_managed != NULL) { 293a3bd7f05Smrg CALLGEOTAT(_XtGeoTrace((Widget) parent, 294a3bd7f05Smrg "Call parent: \"%s\"[%d,%d]'s changemanaged\n", 295a3bd7f05Smrg XtName((Widget) parent), 296a3bd7f05Smrg parent->core.width, parent->core.height)); 297a3bd7f05Smrg (*change_managed) ((Widget) parent); 298a3bd7f05Smrg } 299a3bd7f05Smrg 300a3bd7f05Smrg /* Realize each child if necessary, then map if necessary */ 301a3bd7f05Smrg for (i = 0; i < num_unique_children; i++) { 302a3bd7f05Smrg child = unique_children[i]; 303a3bd7f05Smrg if (XtIsWidget(child)) { 304a3bd7f05Smrg if (!XtIsRealized(child)) 305a3bd7f05Smrg XtRealizeWidget(child); 306a3bd7f05Smrg if (child->core.mapped_when_managed) 307a3bd7f05Smrg XtMapWidget(child); 308a3bd7f05Smrg } 309a3bd7f05Smrg else { /* RectObj child */ 310a3bd7f05Smrg Widget pw = child->core.parent; 311a3bd7f05Smrg RectObj r = (RectObj) child; 312a3bd7f05Smrg 313a3bd7f05Smrg while ((pw != NULL) && (!XtIsWidget(pw))) 314a3bd7f05Smrg pw = pw->core.parent; 315a3bd7f05Smrg if (pw != NULL) 316a3bd7f05Smrg XClearArea(XtDisplay(pw), XtWindow(pw), 317a3bd7f05Smrg r->rectangle.x, r->rectangle.y, 318a3bd7f05Smrg (unsigned) (r->rectangle.width + 319a3bd7f05Smrg (r->rectangle.border_width << 1)), 320a3bd7f05Smrg (unsigned) (r->rectangle.height + 321a3bd7f05Smrg (r->rectangle.border_width << 1)), 322a3bd7f05Smrg TRUE); 323444c061aSmrg } 324444c061aSmrg } 325444c061aSmrg } 326444c061aSmrg 327a3bd7f05Smrg if (unique_children != cache) 328a3bd7f05Smrg XtFree((char *) unique_children); 329a3bd7f05Smrg} /* ManageChildren */ 330444c061aSmrg 331a3bd7f05Smrgvoid 332a3bd7f05SmrgXtManageChildren(WidgetList children, Cardinal num_children) 333444c061aSmrg{ 334444c061aSmrg Widget parent, hookobj; 335a3bd7f05Smrg 336444c061aSmrg#ifdef XTHREADS 337444c061aSmrg XtAppContext app; 338444c061aSmrg#endif 339444c061aSmrg 340a3bd7f05Smrg if (num_children == 0) 341a3bd7f05Smrg return; 342444c061aSmrg if (children[0] == NULL) { 343a3bd7f05Smrg XtWarningMsg(XtNinvalidChild, XtNxtManageChildren, XtCXtToolkitError, 344a3bd7f05Smrg "null child passed to XtManageChildren", NULL, NULL); 345a3bd7f05Smrg return; 346444c061aSmrg } 347444c061aSmrg#ifdef XTHREADS 348444c061aSmrg app = XtWidgetToApplicationContext(children[0]); 349444c061aSmrg#endif 350444c061aSmrg LOCK_APP(app); 351444c061aSmrg parent = children[0]->core.parent; 352444c061aSmrg if (parent->core.being_destroyed) { 353a3bd7f05Smrg UNLOCK_APP(app); 354a3bd7f05Smrg return; 355444c061aSmrg } 356a3bd7f05Smrg ManageChildren(children, num_children, parent, (Boolean) False, 357a3bd7f05Smrg XtNxtManageChildren); 358444c061aSmrg hookobj = XtHooksOfDisplay(XtDisplayOfObject(children[0])); 359444c061aSmrg if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) { 360a3bd7f05Smrg XtChangeHookDataRec call_data; 361a3bd7f05Smrg 362a3bd7f05Smrg call_data.type = XtHmanageChildren; 363a3bd7f05Smrg call_data.widget = parent; 364a3bd7f05Smrg call_data.event_data = (XtPointer) children; 365a3bd7f05Smrg call_data.num_event_data = num_children; 366a3bd7f05Smrg XtCallCallbackList(hookobj, 367a3bd7f05Smrg ((HookObject) hookobj)->hooks.changehook_callbacks, 368a3bd7f05Smrg (XtPointer) &call_data); 369444c061aSmrg } 370444c061aSmrg UNLOCK_APP(app); 371a3bd7f05Smrg} /* XtManageChildren */ 372444c061aSmrg 373a3bd7f05Smrgvoid 374a3bd7f05SmrgXtManageChild(Widget child) 375444c061aSmrg{ 376444c061aSmrg XtManageChildren(&child, (Cardinal) 1); 377a3bd7f05Smrg} /* XtManageChild */ 378444c061aSmrg 379a3bd7f05Smrgvoid 380a3bd7f05SmrgXtSetMappedWhenManaged(Widget widget, _XtBoolean mapped_when_managed) 381444c061aSmrg{ 382444c061aSmrg Widget hookobj; 383a3bd7f05Smrg 384444c061aSmrg WIDGET_TO_APPCON(widget); 385444c061aSmrg 386444c061aSmrg LOCK_APP(app); 387444c061aSmrg if (widget->core.mapped_when_managed == mapped_when_managed) { 388a3bd7f05Smrg UNLOCK_APP(app); 389a3bd7f05Smrg return; 390444c061aSmrg } 3910568f49bSmrg widget->core.mapped_when_managed = (Boolean) mapped_when_managed; 392444c061aSmrg 393444c061aSmrg hookobj = XtHooksOfDisplay(XtDisplay(widget)); 394444c061aSmrg if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) { 395a3bd7f05Smrg XtChangeHookDataRec call_data; 396a3bd7f05Smrg 397a3bd7f05Smrg call_data.type = XtHsetMappedWhenManaged; 398a3bd7f05Smrg call_data.widget = widget; 399a3bd7f05Smrg call_data.event_data = (XtPointer) (unsigned long) mapped_when_managed; 400a3bd7f05Smrg XtCallCallbackList(hookobj, 401a3bd7f05Smrg ((HookObject) hookobj)->hooks.changehook_callbacks, 402a3bd7f05Smrg (XtPointer) &call_data); 403444c061aSmrg } 404444c061aSmrg 405a3bd7f05Smrg if (!XtIsManaged(widget)) { 406a3bd7f05Smrg UNLOCK_APP(app); 407a3bd7f05Smrg return; 408444c061aSmrg } 409444c061aSmrg 410444c061aSmrg if (mapped_when_managed) { 411a3bd7f05Smrg /* Didn't used to be mapped when managed. */ 412a3bd7f05Smrg if (XtIsRealized(widget)) 413a3bd7f05Smrg XtMapWidget(widget); 414a3bd7f05Smrg } 415a3bd7f05Smrg else { 416a3bd7f05Smrg /* Used to be mapped when managed. */ 417a3bd7f05Smrg if (XtIsRealized(widget)) 418a3bd7f05Smrg XtUnmapWidget(widget); 419444c061aSmrg } 420444c061aSmrg UNLOCK_APP(app); 421a3bd7f05Smrg} /* XtSetMappedWhenManaged */ 422a3bd7f05Smrg 423a3bd7f05Smrgvoid 424a3bd7f05SmrgXtChangeManagedSet(WidgetList unmanage_children, 425a3bd7f05Smrg Cardinal num_unmanage, 426a3bd7f05Smrg XtDoChangeProc do_change_proc, 427a3bd7f05Smrg XtPointer client_data, 428a3bd7f05Smrg WidgetList manage_children, 429a3bd7f05Smrg Cardinal num_manage) 430444c061aSmrg{ 431444c061aSmrg WidgetList childp; 432444c061aSmrg Widget parent; 433444c061aSmrg int i; 434444c061aSmrg Cardinal some_unmanaged; 435444c061aSmrg Boolean call_out; 436444c061aSmrg XtAppContext app; 437444c061aSmrg Widget hookobj; 438444c061aSmrg XtChangeHookDataRec call_data; 439444c061aSmrg 440444c061aSmrg if (num_unmanage == 0 && num_manage == 0) 441a3bd7f05Smrg return; 442444c061aSmrg 443444c061aSmrg /* specification doesn't state that library will check for NULL in list */ 444444c061aSmrg 445444c061aSmrg childp = num_unmanage ? unmanage_children : manage_children; 446444c061aSmrg app = XtWidgetToApplicationContext(*childp); 447444c061aSmrg LOCK_APP(app); 448444c061aSmrg 449444c061aSmrg parent = XtParent(*childp); 450444c061aSmrg childp = unmanage_children; 451a3bd7f05Smrg for (i = (int) num_unmanage; --i >= 0 && XtParent(*childp) == parent; 452a3bd7f05Smrg childp++); 453444c061aSmrg call_out = (i >= 0); 454444c061aSmrg childp = manage_children; 455a3bd7f05Smrg for (i = (int) num_manage; --i >= 0 && XtParent(*childp) == parent; 456a3bd7f05Smrg childp++); 457444c061aSmrg if (call_out || i >= 0) { 458a3bd7f05Smrg XtAppWarningMsg(app, "ambiguousParent", XtNxtChangeManagedSet, 459a3bd7f05Smrg XtCXtToolkitError, "Not all children have same parent", 460a3bd7f05Smrg NULL, NULL); 461444c061aSmrg } 462a3bd7f05Smrg if (!XtIsComposite(parent)) { 463a3bd7f05Smrg UNLOCK_APP(app); 464a3bd7f05Smrg XtAppErrorMsg(app, "invalidParent", XtNxtChangeManagedSet, 465a3bd7f05Smrg XtCXtToolkitError, 466a3bd7f05Smrg "Attempt to manage a child when parent is not Composite", 467a3bd7f05Smrg NULL, NULL); 468444c061aSmrg } 469444c061aSmrg if (parent->core.being_destroyed) { 470a3bd7f05Smrg UNLOCK_APP(app); 471a3bd7f05Smrg return; 472444c061aSmrg } 473444c061aSmrg 474444c061aSmrg call_out = False; 475444c061aSmrg if (do_change_proc) { 476a3bd7f05Smrg CompositeClassExtension ext = (CompositeClassExtension) 477a3bd7f05Smrg XtGetClassExtension(parent->core.widget_class, 478a3bd7f05Smrg XtOffsetOf(CompositeClassRec, 479a3bd7f05Smrg composite_class.extension), 480a3bd7f05Smrg NULLQUARK, XtCompositeExtensionVersion, 481a3bd7f05Smrg sizeof(CompositeClassExtensionRec)); 482a3bd7f05Smrg 483a3bd7f05Smrg if (!ext || !ext->allows_change_managed_set) 484a3bd7f05Smrg call_out = True; 485444c061aSmrg } 486444c061aSmrg 487444c061aSmrg UnmanageChildren(unmanage_children, num_unmanage, parent, 488a3bd7f05Smrg &some_unmanaged, call_out, XtNxtChangeManagedSet); 489444c061aSmrg 490444c061aSmrg hookobj = XtHooksOfDisplay(XtDisplay(parent)); 491444c061aSmrg if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) { 492a3bd7f05Smrg call_data.type = XtHunmanageSet; 493a3bd7f05Smrg call_data.widget = parent; 494a3bd7f05Smrg call_data.event_data = (XtPointer) unmanage_children; 495a3bd7f05Smrg call_data.num_event_data = num_unmanage; 496a3bd7f05Smrg XtCallCallbackList(hookobj, 497a3bd7f05Smrg ((HookObject) hookobj)->hooks.changehook_callbacks, 498a3bd7f05Smrg (XtPointer) &call_data); 499444c061aSmrg } 500444c061aSmrg 501444c061aSmrg if (do_change_proc) 502a3bd7f05Smrg (*do_change_proc) (parent, unmanage_children, &num_unmanage, 503a3bd7f05Smrg manage_children, &num_manage, client_data); 504444c061aSmrg 505444c061aSmrg call_out = (some_unmanaged && !call_out); 506444c061aSmrg ManageChildren(manage_children, num_manage, parent, call_out, 507a3bd7f05Smrg XtNxtChangeManagedSet); 508444c061aSmrg 509444c061aSmrg if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) { 510a3bd7f05Smrg call_data.type = XtHmanageSet; 511a3bd7f05Smrg call_data.event_data = (XtPointer) manage_children; 512a3bd7f05Smrg call_data.num_event_data = num_manage; 513a3bd7f05Smrg XtCallCallbackList(hookobj, 514a3bd7f05Smrg ((HookObject) hookobj)->hooks.changehook_callbacks, 515a3bd7f05Smrg (XtPointer) &call_data); 516444c061aSmrg } 517444c061aSmrg UNLOCK_APP(app); 518a3bd7f05Smrg} /* XtChangeManagedSet */ 519