1444c061aSmrg/*********************************************************** 2fdf6a26fSmrgCopyright (c) 1993, Oracle and/or its affiliates. 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 { 246fdf6a26fSmrg unique_children = XtMallocArray(num_children, (Cardinal) sizeof(Widget)); 247444c061aSmrg } 248444c061aSmrg num_unique_children = 0; 249444c061aSmrg for (i = 0; i < num_children; i++) { 250a3bd7f05Smrg child = children[i]; 251a3bd7f05Smrg if (child == NULL) { 252a3bd7f05Smrg XtAppWarningMsg(XtWidgetToApplicationContext((Widget) parent), 253a3bd7f05Smrg XtNinvalidChild, caller_func, XtCXtToolkitError, 254a3bd7f05Smrg "null child passed to ManageChildren", NULL, NULL); 255a3bd7f05Smrg if (unique_children != cache) 256a3bd7f05Smrg XtFree((char *) unique_children); 257a3bd7f05Smrg return; 258a3bd7f05Smrg } 259444c061aSmrg#ifdef DEBUG 260a3bd7f05Smrg if (!XtIsRectObj(child)) { 261a3bd7f05Smrg String params[2]; 262a3bd7f05Smrg Cardinal num_params = 2; 263a3bd7f05Smrg 264a3bd7f05Smrg params[0] = XtName(child); 265a3bd7f05Smrg params[1] = child->core.widget_class->core_class.class_name; 266a3bd7f05Smrg XtAppWarningMsg(XtWidgetToApplicationContext((Widget) parent), 267a3bd7f05Smrg "notRectObj", caller_func, XtCXtToolkitError, 268a3bd7f05Smrg "child \"%s\", class %s is not a RectObj", 269a3bd7f05Smrg params, &num_params); 270a3bd7f05Smrg continue; 271a3bd7f05Smrg } 272a3bd7f05Smrg#endif /*DEBUG*/ 273a3bd7f05Smrg if (child->core.parent != parent) { 274a3bd7f05Smrg XtAppWarningMsg(XtWidgetToApplicationContext((Widget) parent), 275a3bd7f05Smrg "ambiguousParent", caller_func, XtCXtToolkitError, 276a3bd7f05Smrg "Not all children have same parent in XtManageChildren", 277a3bd7f05Smrg NULL, NULL); 278a3bd7f05Smrg } 279a3bd7f05Smrg else if (!child->core.managed && !child->core.being_destroyed) { 280a3bd7f05Smrg unique_children[num_unique_children++] = child; 281a3bd7f05Smrg CALLGEOTAT(_XtGeoTrace(child, 282a3bd7f05Smrg "Child \"%s\"[%d,%d] is marked managed\n", 283a3bd7f05Smrg XtName(child), 284a3bd7f05Smrg child->core.width, child->core.height)); 285a3bd7f05Smrg child->core.managed = TRUE; 286a3bd7f05Smrg } 287444c061aSmrg } 288444c061aSmrg 289444c061aSmrg if ((call_change_managed || num_unique_children != 0) && parent_realized) { 290a3bd7f05Smrg /* Compute geometry of new managed set of children. */ 291a3bd7f05Smrg if (change_managed != NULL) { 292a3bd7f05Smrg CALLGEOTAT(_XtGeoTrace((Widget) parent, 293a3bd7f05Smrg "Call parent: \"%s\"[%d,%d]'s changemanaged\n", 294a3bd7f05Smrg XtName((Widget) parent), 295a3bd7f05Smrg parent->core.width, parent->core.height)); 296a3bd7f05Smrg (*change_managed) ((Widget) parent); 297a3bd7f05Smrg } 298a3bd7f05Smrg 299a3bd7f05Smrg /* Realize each child if necessary, then map if necessary */ 300a3bd7f05Smrg for (i = 0; i < num_unique_children; i++) { 301a3bd7f05Smrg child = unique_children[i]; 302a3bd7f05Smrg if (XtIsWidget(child)) { 303a3bd7f05Smrg if (!XtIsRealized(child)) 304a3bd7f05Smrg XtRealizeWidget(child); 305a3bd7f05Smrg if (child->core.mapped_when_managed) 306a3bd7f05Smrg XtMapWidget(child); 307a3bd7f05Smrg } 308a3bd7f05Smrg else { /* RectObj child */ 309a3bd7f05Smrg Widget pw = child->core.parent; 310a3bd7f05Smrg RectObj r = (RectObj) child; 311a3bd7f05Smrg 312a3bd7f05Smrg while ((pw != NULL) && (!XtIsWidget(pw))) 313a3bd7f05Smrg pw = pw->core.parent; 314a3bd7f05Smrg if (pw != NULL) 315a3bd7f05Smrg XClearArea(XtDisplay(pw), XtWindow(pw), 316a3bd7f05Smrg r->rectangle.x, r->rectangle.y, 317a3bd7f05Smrg (unsigned) (r->rectangle.width + 318a3bd7f05Smrg (r->rectangle.border_width << 1)), 319a3bd7f05Smrg (unsigned) (r->rectangle.height + 320a3bd7f05Smrg (r->rectangle.border_width << 1)), 321a3bd7f05Smrg TRUE); 322444c061aSmrg } 323444c061aSmrg } 324444c061aSmrg } 325444c061aSmrg 326a3bd7f05Smrg if (unique_children != cache) 327a3bd7f05Smrg XtFree((char *) unique_children); 328a3bd7f05Smrg} /* ManageChildren */ 329444c061aSmrg 330a3bd7f05Smrgvoid 331a3bd7f05SmrgXtManageChildren(WidgetList children, Cardinal num_children) 332444c061aSmrg{ 333444c061aSmrg Widget parent, hookobj; 334a3bd7f05Smrg 335444c061aSmrg#ifdef XTHREADS 336444c061aSmrg XtAppContext app; 337444c061aSmrg#endif 338444c061aSmrg 339a3bd7f05Smrg if (num_children == 0) 340a3bd7f05Smrg return; 341444c061aSmrg if (children[0] == NULL) { 342a3bd7f05Smrg XtWarningMsg(XtNinvalidChild, XtNxtManageChildren, XtCXtToolkitError, 343a3bd7f05Smrg "null child passed to XtManageChildren", NULL, NULL); 344a3bd7f05Smrg return; 345444c061aSmrg } 346444c061aSmrg#ifdef XTHREADS 347444c061aSmrg app = XtWidgetToApplicationContext(children[0]); 348444c061aSmrg#endif 349444c061aSmrg LOCK_APP(app); 350444c061aSmrg parent = children[0]->core.parent; 351444c061aSmrg if (parent->core.being_destroyed) { 352a3bd7f05Smrg UNLOCK_APP(app); 353a3bd7f05Smrg return; 354444c061aSmrg } 355a3bd7f05Smrg ManageChildren(children, num_children, parent, (Boolean) False, 356a3bd7f05Smrg XtNxtManageChildren); 357444c061aSmrg hookobj = XtHooksOfDisplay(XtDisplayOfObject(children[0])); 358444c061aSmrg if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) { 359a3bd7f05Smrg XtChangeHookDataRec call_data; 360a3bd7f05Smrg 361a3bd7f05Smrg call_data.type = XtHmanageChildren; 362a3bd7f05Smrg call_data.widget = parent; 363a3bd7f05Smrg call_data.event_data = (XtPointer) children; 364a3bd7f05Smrg call_data.num_event_data = num_children; 365a3bd7f05Smrg XtCallCallbackList(hookobj, 366a3bd7f05Smrg ((HookObject) hookobj)->hooks.changehook_callbacks, 367a3bd7f05Smrg (XtPointer) &call_data); 368444c061aSmrg } 369444c061aSmrg UNLOCK_APP(app); 370a3bd7f05Smrg} /* XtManageChildren */ 371444c061aSmrg 372a3bd7f05Smrgvoid 373a3bd7f05SmrgXtManageChild(Widget child) 374444c061aSmrg{ 375444c061aSmrg XtManageChildren(&child, (Cardinal) 1); 376a3bd7f05Smrg} /* XtManageChild */ 377444c061aSmrg 378a3bd7f05Smrgvoid 379a3bd7f05SmrgXtSetMappedWhenManaged(Widget widget, _XtBoolean mapped_when_managed) 380444c061aSmrg{ 381444c061aSmrg Widget hookobj; 382a3bd7f05Smrg 383444c061aSmrg WIDGET_TO_APPCON(widget); 384444c061aSmrg 385444c061aSmrg LOCK_APP(app); 386444c061aSmrg if (widget->core.mapped_when_managed == mapped_when_managed) { 387a3bd7f05Smrg UNLOCK_APP(app); 388a3bd7f05Smrg return; 389444c061aSmrg } 3900568f49bSmrg widget->core.mapped_when_managed = (Boolean) mapped_when_managed; 391444c061aSmrg 392444c061aSmrg hookobj = XtHooksOfDisplay(XtDisplay(widget)); 393444c061aSmrg if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) { 394a3bd7f05Smrg XtChangeHookDataRec call_data; 395a3bd7f05Smrg 396a3bd7f05Smrg call_data.type = XtHsetMappedWhenManaged; 397a3bd7f05Smrg call_data.widget = widget; 398fdf6a26fSmrg call_data.event_data = (XtPointer) (XtUIntPtr) mapped_when_managed; 399a3bd7f05Smrg XtCallCallbackList(hookobj, 400a3bd7f05Smrg ((HookObject) hookobj)->hooks.changehook_callbacks, 401a3bd7f05Smrg (XtPointer) &call_data); 402444c061aSmrg } 403444c061aSmrg 404a3bd7f05Smrg if (!XtIsManaged(widget)) { 405a3bd7f05Smrg UNLOCK_APP(app); 406a3bd7f05Smrg return; 407444c061aSmrg } 408444c061aSmrg 409444c061aSmrg if (mapped_when_managed) { 410a3bd7f05Smrg /* Didn't used to be mapped when managed. */ 411a3bd7f05Smrg if (XtIsRealized(widget)) 412a3bd7f05Smrg XtMapWidget(widget); 413a3bd7f05Smrg } 414a3bd7f05Smrg else { 415a3bd7f05Smrg /* Used to be mapped when managed. */ 416a3bd7f05Smrg if (XtIsRealized(widget)) 417a3bd7f05Smrg XtUnmapWidget(widget); 418444c061aSmrg } 419444c061aSmrg UNLOCK_APP(app); 420a3bd7f05Smrg} /* XtSetMappedWhenManaged */ 421a3bd7f05Smrg 422a3bd7f05Smrgvoid 423a3bd7f05SmrgXtChangeManagedSet(WidgetList unmanage_children, 424a3bd7f05Smrg Cardinal num_unmanage, 425a3bd7f05Smrg XtDoChangeProc do_change_proc, 426a3bd7f05Smrg XtPointer client_data, 427a3bd7f05Smrg WidgetList manage_children, 428a3bd7f05Smrg Cardinal num_manage) 429444c061aSmrg{ 430444c061aSmrg WidgetList childp; 431444c061aSmrg Widget parent; 432444c061aSmrg int i; 433444c061aSmrg Cardinal some_unmanaged; 434444c061aSmrg Boolean call_out; 435444c061aSmrg XtAppContext app; 436444c061aSmrg Widget hookobj; 437444c061aSmrg XtChangeHookDataRec call_data; 438444c061aSmrg 439444c061aSmrg if (num_unmanage == 0 && num_manage == 0) 440a3bd7f05Smrg return; 441444c061aSmrg 442444c061aSmrg /* specification doesn't state that library will check for NULL in list */ 443444c061aSmrg 444444c061aSmrg childp = num_unmanage ? unmanage_children : manage_children; 445444c061aSmrg app = XtWidgetToApplicationContext(*childp); 446444c061aSmrg LOCK_APP(app); 447444c061aSmrg 448444c061aSmrg parent = XtParent(*childp); 449444c061aSmrg childp = unmanage_children; 450a3bd7f05Smrg for (i = (int) num_unmanage; --i >= 0 && XtParent(*childp) == parent; 451a3bd7f05Smrg childp++); 452444c061aSmrg call_out = (i >= 0); 453444c061aSmrg childp = manage_children; 454a3bd7f05Smrg for (i = (int) num_manage; --i >= 0 && XtParent(*childp) == parent; 455a3bd7f05Smrg childp++); 456444c061aSmrg if (call_out || i >= 0) { 457a3bd7f05Smrg XtAppWarningMsg(app, "ambiguousParent", XtNxtChangeManagedSet, 458a3bd7f05Smrg XtCXtToolkitError, "Not all children have same parent", 459a3bd7f05Smrg NULL, NULL); 460444c061aSmrg } 461a3bd7f05Smrg if (!XtIsComposite(parent)) { 462a3bd7f05Smrg UNLOCK_APP(app); 463a3bd7f05Smrg XtAppErrorMsg(app, "invalidParent", XtNxtChangeManagedSet, 464a3bd7f05Smrg XtCXtToolkitError, 465a3bd7f05Smrg "Attempt to manage a child when parent is not Composite", 466a3bd7f05Smrg NULL, NULL); 467444c061aSmrg } 468444c061aSmrg if (parent->core.being_destroyed) { 469a3bd7f05Smrg UNLOCK_APP(app); 470a3bd7f05Smrg return; 471444c061aSmrg } 472444c061aSmrg 473444c061aSmrg call_out = False; 474444c061aSmrg if (do_change_proc) { 475a3bd7f05Smrg CompositeClassExtension ext = (CompositeClassExtension) 476a3bd7f05Smrg XtGetClassExtension(parent->core.widget_class, 477a3bd7f05Smrg XtOffsetOf(CompositeClassRec, 478a3bd7f05Smrg composite_class.extension), 479a3bd7f05Smrg NULLQUARK, XtCompositeExtensionVersion, 480a3bd7f05Smrg sizeof(CompositeClassExtensionRec)); 481a3bd7f05Smrg 482a3bd7f05Smrg if (!ext || !ext->allows_change_managed_set) 483a3bd7f05Smrg call_out = True; 484444c061aSmrg } 485444c061aSmrg 486444c061aSmrg UnmanageChildren(unmanage_children, num_unmanage, parent, 487a3bd7f05Smrg &some_unmanaged, call_out, XtNxtChangeManagedSet); 488444c061aSmrg 489444c061aSmrg hookobj = XtHooksOfDisplay(XtDisplay(parent)); 490444c061aSmrg if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) { 491a3bd7f05Smrg call_data.type = XtHunmanageSet; 492a3bd7f05Smrg call_data.widget = parent; 493a3bd7f05Smrg call_data.event_data = (XtPointer) unmanage_children; 494a3bd7f05Smrg call_data.num_event_data = num_unmanage; 495a3bd7f05Smrg XtCallCallbackList(hookobj, 496a3bd7f05Smrg ((HookObject) hookobj)->hooks.changehook_callbacks, 497a3bd7f05Smrg (XtPointer) &call_data); 498444c061aSmrg } 499444c061aSmrg 500444c061aSmrg if (do_change_proc) 501a3bd7f05Smrg (*do_change_proc) (parent, unmanage_children, &num_unmanage, 502a3bd7f05Smrg manage_children, &num_manage, client_data); 503444c061aSmrg 504444c061aSmrg call_out = (some_unmanaged && !call_out); 505444c061aSmrg ManageChildren(manage_children, num_manage, parent, call_out, 506a3bd7f05Smrg XtNxtChangeManagedSet); 507444c061aSmrg 508444c061aSmrg if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) { 509a3bd7f05Smrg call_data.type = XtHmanageSet; 510a3bd7f05Smrg call_data.event_data = (XtPointer) manage_children; 511a3bd7f05Smrg call_data.num_event_data = num_manage; 512a3bd7f05Smrg XtCallCallbackList(hookobj, 513a3bd7f05Smrg ((HookObject) hookobj)->hooks.changehook_callbacks, 514a3bd7f05Smrg (XtPointer) &call_data); 515444c061aSmrg } 516444c061aSmrg UNLOCK_APP(app); 517a3bd7f05Smrg} /* XtChangeManagedSet */ 518