| File: | src/Manage.c |
| Location: | line 372, column 9 |
| Description: | Dereference of null pointer |
| 1 | /*********************************************************** | |||||
| 2 | Copyright (c) 1993, Oracle and/or its affiliates. All rights reserved. | |||||
| 3 | ||||||
| 4 | Permission is hereby granted, free of charge, to any person obtaining a | |||||
| 5 | copy of this software and associated documentation files (the "Software"), | |||||
| 6 | to deal in the Software without restriction, including without limitation | |||||
| 7 | the rights to use, copy, modify, merge, publish, distribute, sublicense, | |||||
| 8 | and/or sell copies of the Software, and to permit persons to whom the | |||||
| 9 | Software is furnished to do so, subject to the following conditions: | |||||
| 10 | ||||||
| 11 | The above copyright notice and this permission notice (including the next | |||||
| 12 | paragraph) shall be included in all copies or substantial portions of the | |||||
| 13 | Software. | |||||
| 14 | ||||||
| 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |||||
| 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |||||
| 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | |||||
| 18 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |||||
| 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |||||
| 20 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | |||||
| 21 | DEALINGS IN THE SOFTWARE. | |||||
| 22 | ||||||
| 23 | Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts. | |||||
| 24 | ||||||
| 25 | All Rights Reserved | |||||
| 26 | ||||||
| 27 | Permission to use, copy, modify, and distribute this software and its | |||||
| 28 | documentation for any purpose and without fee is hereby granted, | |||||
| 29 | provided that the above copyright notice appear in all copies and that | |||||
| 30 | both that copyright notice and this permission notice appear in | |||||
| 31 | supporting documentation, and that the name of Digital not be | |||||
| 32 | used in advertising or publicity pertaining to distribution of the | |||||
| 33 | software without specific, written prior permission. | |||||
| 34 | ||||||
| 35 | DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING | |||||
| 36 | ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL | |||||
| 37 | DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR | |||||
| 38 | ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, | |||||
| 39 | WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, | |||||
| 40 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS | |||||
| 41 | SOFTWARE. | |||||
| 42 | ||||||
| 43 | ******************************************************************/ | |||||
| 44 | ||||||
| 45 | /* | |||||
| 46 | ||||||
| 47 | Copyright 1987, 1988, 1994, 1998 The Open Group | |||||
| 48 | ||||||
| 49 | Permission to use, copy, modify, distribute, and sell this software and its | |||||
| 50 | documentation for any purpose is hereby granted without fee, provided that | |||||
| 51 | the above copyright notice appear in all copies and that both that | |||||
| 52 | copyright notice and this permission notice appear in supporting | |||||
| 53 | documentation. | |||||
| 54 | ||||||
| 55 | The above copyright notice and this permission notice shall be included in | |||||
| 56 | all copies or substantial portions of the Software. | |||||
| 57 | ||||||
| 58 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |||||
| 59 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |||||
| 60 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |||||
| 61 | OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN | |||||
| 62 | AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | |||||
| 63 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |||||
| 64 | ||||||
| 65 | Except as contained in this notice, the name of The Open Group shall not be | |||||
| 66 | used in advertising or otherwise to promote the sale, use or other dealings | |||||
| 67 | in this Software without prior written authorization from The Open Group. | |||||
| 68 | ||||||
| 69 | */ | |||||
| 70 | ||||||
| 71 | #ifdef HAVE_CONFIG_H1 | |||||
| 72 | #include <config.h> | |||||
| 73 | #endif | |||||
| 74 | #include "IntrinsicI.h" | |||||
| 75 | ||||||
| 76 | static String XtNinvalidChild = "invalidChild"; | |||||
| 77 | static String XtNxtUnmanageChildren = "xtUnmanageChildren"; | |||||
| 78 | static String XtNxtManageChildren = "xtManageChildren"; | |||||
| 79 | static String XtNxtChangeManagedSet = "xtChangeManagedSet"; | |||||
| 80 | ||||||
| 81 | static void UnmanageChildren( | |||||
| 82 | WidgetList children, | |||||
| 83 | Cardinal num_children, | |||||
| 84 | Widget parent, | |||||
| 85 | Cardinal* num_unique_children, | |||||
| 86 | Boolean call_change_managed, | |||||
| 87 | String caller_func) | |||||
| 88 | { | |||||
| 89 | Widget child; | |||||
| 90 | Cardinal i; | |||||
| 91 | XtWidgetProc change_managed = NULL((void*)0); | |||||
| 92 | Boolint parent_realized = False0; | |||||
| 93 | ||||||
| 94 | *num_unique_children = 0; | |||||
| 95 | ||||||
| 96 | if (XtIsComposite((Widget) parent)(((Object)((Widget) parent))->object.widget_class->core_class .class_inited & 0x08)) { | |||||
| 97 | LOCK_PROCESSif(_XtProcessLock)(*_XtProcessLock)(); | |||||
| 98 | change_managed = ((CompositeWidgetClass) parent->core.widget_class) | |||||
| 99 | ->composite_class.change_managed; | |||||
| 100 | UNLOCK_PROCESSif(_XtProcessUnlock)(*_XtProcessUnlock)(); | |||||
| 101 | parent_realized = XtIsRealized((Widget)parent)((((((Object)((Widget)parent))->object.widget_class->core_class .class_inited & 0x04) ? ((Widget)parent) : _XtWindowedAncestor ((Widget)parent)) ->core.window) != 0L); | |||||
| 102 | } else { | |||||
| 103 | XtAppErrorMsg(XtWidgetToApplicationContext((Widget)parent), | |||||
| 104 | "invalidParent",caller_func, XtCXtToolkitError, | |||||
| 105 | "Attempt to unmanage a child when parent is not Composite", | |||||
| 106 | (String *) NULL((void*)0), (Cardinal *) NULL((void*)0)); | |||||
| 107 | } | |||||
| 108 | ||||||
| 109 | for (i = 0; i < num_children; i++) { | |||||
| 110 | child = children[i]; | |||||
| 111 | if (child == NULL((void*)0)) { | |||||
| 112 | XtAppWarningMsg(XtWidgetToApplicationContext(parent), | |||||
| 113 | XtNinvalidChild,caller_func,XtCXtToolkitError, | |||||
| 114 | "Null child passed to XtUnmanageChildren", | |||||
| 115 | (String *)NULL((void*)0), (Cardinal *)NULL((void*)0)); | |||||
| 116 | return; | |||||
| 117 | } | |||||
| 118 | if (child->core.parent != parent) { | |||||
| 119 | XtAppWarningMsg(XtWidgetToApplicationContext(parent), | |||||
| 120 | "ambiguousParent",caller_func,XtCXtToolkitError, | |||||
| 121 | "Not all children have same parent in UnmanageChildren", | |||||
| 122 | (String *)NULL((void*)0), (Cardinal *)NULL((void*)0)); | |||||
| 123 | } else | |||||
| 124 | if (child->core.managed) { | |||||
| 125 | (*num_unique_children)++; | |||||
| 126 | CALLGEOTAT(_XtGeoTrace(child,"Child \"%s\" is marked unmanaged\n", | |||||
| 127 | XtName(child))); | |||||
| 128 | child->core.managed = FALSE0; | |||||
| 129 | if (XtIsWidget(child)(((Object)(child))->object.widget_class->core_class.class_inited & 0x04) | |||||
| 130 | && XtIsRealized(child)((((((Object)(child))->object.widget_class->core_class. class_inited & 0x04) ? (child) : _XtWindowedAncestor(child )) ->core.window) != 0L) | |||||
| 131 | && child->core.mapped_when_managed) | |||||
| 132 | XtUnmapWidget(child)XUnmapWindow((((child)->core.screen)->display), ((child )->core.window)); | |||||
| 133 | else | |||||
| 134 | { /* RectObj child */ | |||||
| 135 | Widget pw = child->core.parent; | |||||
| 136 | RectObj r = (RectObj) child; | |||||
| 137 | while ((pw!=NULL((void*)0)) && (!XtIsWidget(pw)(((Object)(pw))->object.widget_class->core_class.class_inited & 0x04))) pw = pw->core.parent; | |||||
| 138 | if ((pw!=NULL((void*)0)) && XtIsRealized (pw)((((((Object)(pw))->object.widget_class->core_class.class_inited & 0x04) ? (pw) : _XtWindowedAncestor(pw)) ->core.window ) != 0L)) | |||||
| 139 | XClearArea (XtDisplay (pw)(((pw)->core.screen)->display), XtWindow (pw)((pw)->core.window), | |||||
| 140 | r->rectangle.x, r->rectangle.y, | |||||
| 141 | r->rectangle.width + (r->rectangle.border_width << 1), | |||||
| 142 | r->rectangle.height + (r->rectangle.border_width << 1), | |||||
| 143 | TRUE1); | |||||
| 144 | } | |||||
| 145 | ||||||
| 146 | } | |||||
| 147 | } | |||||
| 148 | if (call_change_managed && *num_unique_children != 0 && | |||||
| 149 | change_managed != NULL((void*)0) && parent_realized) { | |||||
| 150 | CALLGEOTAT(_XtGeoTrace((Widget)parent, | |||||
| 151 | "Call parent: \"%s\"[%d,%d]'s changemanaged proc\n", | |||||
| 152 | XtName((Widget)parent), | |||||
| 153 | parent->core.width,parent->core.height)); | |||||
| 154 | (*change_managed) (parent); | |||||
| 155 | } | |||||
| 156 | } /* UnmanageChildren */ | |||||
| 157 | ||||||
| 158 | void XtUnmanageChildren ( | |||||
| 159 | WidgetList children, | |||||
| 160 | Cardinal num_children) | |||||
| 161 | { | |||||
| 162 | Widget parent, hookobj; | |||||
| 163 | Cardinal ii; | |||||
| 164 | #ifdef XTHREADS1 | |||||
| 165 | XtAppContext app; | |||||
| 166 | #endif | |||||
| 167 | ||||||
| 168 | if (num_children == 0) return; | |||||
| 169 | if (children[0] == NULL((void*)0)) { | |||||
| 170 | XtWarningMsg(XtNinvalidChild,XtNxtUnmanageChildren,XtCXtToolkitError, | |||||
| 171 | "Null child found in argument list to unmanage", | |||||
| 172 | (String *)NULL((void*)0), (Cardinal *)NULL((void*)0)); | |||||
| 173 | return; | |||||
| 174 | } | |||||
| 175 | #ifdef XTHREADS1 | |||||
| 176 | app = XtWidgetToApplicationContext(children[0]); | |||||
| 177 | #endif | |||||
| 178 | LOCK_APP(app)if(app && app->lock)(*app->lock)(app); | |||||
| 179 | parent = children[0]->core.parent; | |||||
| 180 | if (parent->core.being_destroyed) { | |||||
| 181 | UNLOCK_APP(app)if(app && app->unlock)(*app->unlock)(app); | |||||
| 182 | return; | |||||
| 183 | } | |||||
| 184 | UnmanageChildren(children, num_children, parent, &ii, | |||||
| 185 | (Boolean)True1, XtNxtUnmanageChildren); | |||||
| 186 | hookobj = XtHooksOfDisplay(XtDisplayOfObject(children[0])((((Object)(children[0]))->object.widget_class->core_class .class_inited & 0x04) ? (children[0])->core.screen-> display : _XtIsHookObject(children[0]) ? ((HookObject)(children [0]))->hooks.screen->display : _XtWindowedAncestor(children [0])->core.screen->display)); | |||||
| 187 | if (XtHasCallbacks(hookobj, XtNchangeHook((char*)&XtStrings[2061])) == XtCallbackHasSome) { | |||||
| 188 | XtChangeHookDataRec call_data; | |||||
| 189 | ||||||
| 190 | call_data.type = XtHunmanageChildren((char*)&XtStrings[2236]); | |||||
| 191 | call_data.widget = parent; | |||||
| 192 | call_data.event_data = (XtPointer) children; | |||||
| 193 | call_data.num_event_data = num_children; | |||||
| 194 | XtCallCallbackList(hookobj, | |||||
| 195 | ((HookObject)hookobj)->hooks.changehook_callbacks, | |||||
| 196 | (XtPointer)&call_data); | |||||
| 197 | } | |||||
| 198 | UNLOCK_APP(app)if(app && app->unlock)(*app->unlock)(app); | |||||
| 199 | } /* XtUnmanageChildren */ | |||||
| 200 | ||||||
| 201 | void XtUnmanageChild( | |||||
| 202 | Widget child) | |||||
| 203 | { | |||||
| 204 | XtUnmanageChildren(&child, (Cardinal)1); | |||||
| 205 | } /* XtUnmanageChild */ | |||||
| 206 | ||||||
| 207 | ||||||
| 208 | static void ManageChildren( | |||||
| 209 | WidgetList children, | |||||
| 210 | Cardinal num_children, | |||||
| 211 | Widget parent, | |||||
| 212 | Boolean call_change_managed, | |||||
| 213 | String caller_func) | |||||
| 214 | { | |||||
| 215 | #define MAXCHILDREN100 100 | |||||
| 216 | Widget child; | |||||
| 217 | Cardinal num_unique_children, i; | |||||
| 218 | XtWidgetProc change_managed = NULL((void*)0); | |||||
| 219 | WidgetList unique_children; | |||||
| 220 | Widget cache[MAXCHILDREN100]; | |||||
| 221 | Boolint parent_realized = False0; | |||||
| 222 | ||||||
| 223 | if (XtIsComposite((Widget) parent)(((Object)((Widget) parent))->object.widget_class->core_class .class_inited & 0x08)) { | |||||
| 224 | LOCK_PROCESSif(_XtProcessLock)(*_XtProcessLock)(); | |||||
| 225 | change_managed = ((CompositeWidgetClass) parent->core.widget_class) | |||||
| 226 | ->composite_class.change_managed; | |||||
| 227 | UNLOCK_PROCESSif(_XtProcessUnlock)(*_XtProcessUnlock)(); | |||||
| 228 | parent_realized = XtIsRealized((Widget)parent)((((((Object)((Widget)parent))->object.widget_class->core_class .class_inited & 0x04) ? ((Widget)parent) : _XtWindowedAncestor ((Widget)parent)) ->core.window) != 0L); | |||||
| 229 | } else { | |||||
| 230 | XtAppErrorMsg(XtWidgetToApplicationContext((Widget)parent), | |||||
| 231 | "invalidParent",caller_func, XtCXtToolkitError, | |||||
| 232 | "Attempt to manage a child when parent is not Composite", | |||||
| 233 | (String *) NULL((void*)0), (Cardinal *) NULL((void*)0)); | |||||
| 234 | } | |||||
| 235 | ||||||
| 236 | /* Construct new list of children that really need to be operated upon. */ | |||||
| 237 | if (num_children <= MAXCHILDREN100) { | |||||
| 238 | unique_children = cache; | |||||
| 239 | } else { | |||||
| 240 | unique_children = (WidgetList) __XtMalloc(num_children * sizeof(Widget)); | |||||
| 241 | } | |||||
| 242 | num_unique_children = 0; | |||||
| 243 | for (i = 0; i < num_children; i++) { | |||||
| 244 | child = children[i]; | |||||
| 245 | if (child == NULL((void*)0)) { | |||||
| 246 | XtAppWarningMsg(XtWidgetToApplicationContext((Widget)parent), | |||||
| 247 | XtNinvalidChild,caller_func,XtCXtToolkitError, | |||||
| 248 | "null child passed to ManageChildren", | |||||
| 249 | (String *)NULL((void*)0), (Cardinal *)NULL((void*)0)); | |||||
| 250 | if (unique_children != cache) XtFree((char *) unique_children); | |||||
| 251 | return; | |||||
| 252 | } | |||||
| 253 | #ifdef DEBUG | |||||
| 254 | if (!XtIsRectObj(child)(((Object)(child))->object.widget_class->core_class.class_inited & 0x02)) { | |||||
| 255 | String params[2]; | |||||
| 256 | Cardinal num_params = 2; | |||||
| 257 | params[0] = XtName(child); | |||||
| 258 | params[1] = child->core.widget_class->core_class.class_name; | |||||
| 259 | XtAppWarningMsg(XtWidgetToApplicationContext((Widget)parent), | |||||
| 260 | "notRectObj",caller_func,XtCXtToolkitError, | |||||
| 261 | "child \"%s\", class %s is not a RectObj", | |||||
| 262 | params, &num_params); | |||||
| 263 | continue; | |||||
| 264 | } | |||||
| 265 | #endif /*DEBUG*/ | |||||
| 266 | if (child->core.parent != parent) { | |||||
| 267 | XtAppWarningMsg(XtWidgetToApplicationContext((Widget)parent), | |||||
| 268 | "ambiguousParent",caller_func,XtCXtToolkitError, | |||||
| 269 | "Not all children have same parent in XtManageChildren", | |||||
| 270 | (String *)NULL((void*)0), (Cardinal *)NULL((void*)0)); | |||||
| 271 | } else if (! child->core.managed && !child->core.being_destroyed) { | |||||
| 272 | unique_children[num_unique_children++] = child; | |||||
| 273 | CALLGEOTAT(_XtGeoTrace(child, | |||||
| 274 | "Child \"%s\"[%d,%d] is marked managed\n", | |||||
| 275 | XtName(child), | |||||
| 276 | child->core.width,child->core.height)); | |||||
| 277 | child->core.managed = TRUE1; | |||||
| 278 | } | |||||
| 279 | } | |||||
| 280 | ||||||
| 281 | if ((call_change_managed || num_unique_children != 0) && parent_realized) { | |||||
| 282 | /* Compute geometry of new managed set of children. */ | |||||
| 283 | if (change_managed != NULL((void*)0)) { | |||||
| 284 | CALLGEOTAT(_XtGeoTrace((Widget)parent, | |||||
| 285 | "Call parent: \"%s\"[%d,%d]'s changemanaged\n", | |||||
| 286 | XtName((Widget)parent), | |||||
| 287 | parent->core.width,parent->core.height)); | |||||
| 288 | (*change_managed) ((Widget)parent); | |||||
| 289 | } | |||||
| 290 | ||||||
| 291 | /* Realize each child if necessary, then map if necessary */ | |||||
| 292 | for (i = 0; i < num_unique_children; i++) { | |||||
| 293 | child = unique_children[i]; | |||||
| 294 | if (XtIsWidget(child)(((Object)(child))->object.widget_class->core_class.class_inited & 0x04)) { | |||||
| 295 | if (! XtIsRealized(child)((((((Object)(child))->object.widget_class->core_class. class_inited & 0x04) ? (child) : _XtWindowedAncestor(child )) ->core.window) != 0L)) XtRealizeWidget(child); | |||||
| 296 | if (child->core.mapped_when_managed) XtMapWidget(child)XMapWindow((((child)->core.screen)->display), ((child)-> core.window)); | |||||
| 297 | } else { /* RectObj child */ | |||||
| 298 | Widget pw = child->core.parent; | |||||
| 299 | RectObj r = (RectObj) child; | |||||
| 300 | while ((pw!=NULL((void*)0)) && (!XtIsWidget(pw)(((Object)(pw))->object.widget_class->core_class.class_inited & 0x04))) | |||||
| 301 | pw = pw->core.parent; | |||||
| 302 | if (pw != NULL((void*)0)) | |||||
| 303 | XClearArea (XtDisplay (pw)(((pw)->core.screen)->display), XtWindow (pw)((pw)->core.window), | |||||
| 304 | r->rectangle.x, r->rectangle.y, | |||||
| 305 | r->rectangle.width + (r->rectangle.border_width << 1), | |||||
| 306 | r->rectangle.height + (r->rectangle.border_width << 1), | |||||
| 307 | TRUE1); | |||||
| 308 | } | |||||
| 309 | } | |||||
| 310 | } | |||||
| 311 | ||||||
| 312 | if (unique_children != cache) XtFree((char *) unique_children); | |||||
| 313 | } /* ManageChildren */ | |||||
| 314 | ||||||
| 315 | void XtManageChildren( | |||||
| 316 | WidgetList children, | |||||
| 317 | Cardinal num_children) | |||||
| 318 | { | |||||
| 319 | Widget parent, hookobj; | |||||
| 320 | #ifdef XTHREADS1 | |||||
| 321 | XtAppContext app; | |||||
| 322 | #endif | |||||
| 323 | ||||||
| 324 | if (num_children == 0) return; | |||||
| 325 | if (children[0] == NULL((void*)0)) { | |||||
| 326 | XtWarningMsg(XtNinvalidChild, XtNxtManageChildren, XtCXtToolkitError, | |||||
| 327 | "null child passed to XtManageChildren", | |||||
| 328 | (String*)NULL((void*)0), (Cardinal*)NULL((void*)0)); | |||||
| 329 | return; | |||||
| 330 | } | |||||
| 331 | #ifdef XTHREADS1 | |||||
| 332 | app = XtWidgetToApplicationContext(children[0]); | |||||
| 333 | #endif | |||||
| 334 | LOCK_APP(app)if(app && app->lock)(*app->lock)(app); | |||||
| 335 | parent = children[0]->core.parent; | |||||
| 336 | if (parent->core.being_destroyed) { | |||||
| 337 | UNLOCK_APP(app)if(app && app->unlock)(*app->unlock)(app); | |||||
| 338 | return; | |||||
| 339 | } | |||||
| 340 | ManageChildren(children, num_children, parent, (Boolean)False0, | |||||
| 341 | XtNxtManageChildren); | |||||
| 342 | hookobj = XtHooksOfDisplay(XtDisplayOfObject(children[0])((((Object)(children[0]))->object.widget_class->core_class .class_inited & 0x04) ? (children[0])->core.screen-> display : _XtIsHookObject(children[0]) ? ((HookObject)(children [0]))->hooks.screen->display : _XtWindowedAncestor(children [0])->core.screen->display)); | |||||
| 343 | if (XtHasCallbacks(hookobj, XtNchangeHook((char*)&XtStrings[2061])) == XtCallbackHasSome) { | |||||
| 344 | XtChangeHookDataRec call_data; | |||||
| 345 | ||||||
| 346 | call_data.type = XtHmanageChildren((char*)&XtStrings[2219]); | |||||
| 347 | call_data.widget = parent; | |||||
| 348 | call_data.event_data = (XtPointer) children; | |||||
| 349 | call_data.num_event_data = num_children; | |||||
| 350 | XtCallCallbackList(hookobj, | |||||
| 351 | ((HookObject)hookobj)->hooks.changehook_callbacks, | |||||
| 352 | (XtPointer)&call_data); | |||||
| 353 | } | |||||
| 354 | UNLOCK_APP(app)if(app && app->unlock)(*app->unlock)(app); | |||||
| 355 | } /* XtManageChildren */ | |||||
| 356 | ||||||
| 357 | void XtManageChild( | |||||
| 358 | Widget child) | |||||
| 359 | { | |||||
| 360 | XtManageChildren(&child, (Cardinal) 1); | |||||
| 361 | } /* XtManageChild */ | |||||
| 362 | ||||||
| 363 | ||||||
| 364 | void XtSetMappedWhenManaged( | |||||
| 365 | Widget widget, | |||||
| 366 | _XtBooleanint mapped_when_managed) | |||||
| 367 | { | |||||
| 368 | Widget hookobj; | |||||
| 369 | WIDGET_TO_APPCON(widget)XtAppContext app = (widget && _XtProcessLock ? XtWidgetToApplicationContext (widget) : ((void*)0)); | |||||
| ||||||
| 370 | ||||||
| 371 | LOCK_APP(app)if(app && app->lock)(*app->lock)(app); | |||||
| 372 | if (widget->core.mapped_when_managed == mapped_when_managed) { | |||||
| ||||||
| 373 | UNLOCK_APP(app)if(app && app->unlock)(*app->unlock)(app); | |||||
| 374 | return; | |||||
| 375 | } | |||||
| 376 | widget->core.mapped_when_managed = mapped_when_managed; | |||||
| 377 | ||||||
| 378 | hookobj = XtHooksOfDisplay(XtDisplay(widget)(((widget)->core.screen)->display)); | |||||
| 379 | if (XtHasCallbacks(hookobj, XtNchangeHook((char*)&XtStrings[2061])) == XtCallbackHasSome) { | |||||
| 380 | XtChangeHookDataRec call_data; | |||||
| 381 | ||||||
| 382 | call_data.type = XtHsetMappedWhenManaged((char*)&XtStrings[2511]); | |||||
| 383 | call_data.widget = widget; | |||||
| 384 | call_data.event_data = (XtPointer) (unsigned long) mapped_when_managed; | |||||
| 385 | XtCallCallbackList(hookobj, | |||||
| 386 | ((HookObject)hookobj)->hooks.changehook_callbacks, | |||||
| 387 | (XtPointer)&call_data); | |||||
| 388 | } | |||||
| 389 | ||||||
| 390 | if (! XtIsManaged(widget)((((Object)(widget))->object.widget_class->core_class.class_inited & 0x02) ? (widget)->core.managed : 0)) { | |||||
| 391 | UNLOCK_APP(app)if(app && app->unlock)(*app->unlock)(app); | |||||
| 392 | return; | |||||
| 393 | } | |||||
| 394 | ||||||
| 395 | if (mapped_when_managed) { | |||||
| 396 | /* Didn't used to be mapped when managed. */ | |||||
| 397 | if (XtIsRealized(widget)((((((Object)(widget))->object.widget_class->core_class .class_inited & 0x04) ? (widget) : _XtWindowedAncestor(widget )) ->core.window) != 0L)) XtMapWidget(widget)XMapWindow((((widget)->core.screen)->display), ((widget )->core.window)); | |||||
| 398 | } else { | |||||
| 399 | /* Used to be mapped when managed. */ | |||||
| 400 | if (XtIsRealized(widget)((((((Object)(widget))->object.widget_class->core_class .class_inited & 0x04) ? (widget) : _XtWindowedAncestor(widget )) ->core.window) != 0L)) XtUnmapWidget(widget)XUnmapWindow((((widget)->core.screen)->display), ((widget )->core.window)); | |||||
| 401 | } | |||||
| 402 | UNLOCK_APP(app)if(app && app->unlock)(*app->unlock)(app); | |||||
| 403 | } /* XtSetMappedWhenManaged */ | |||||
| 404 | ||||||
| 405 | ||||||
| 406 | void XtChangeManagedSet( | |||||
| 407 | WidgetList unmanage_children, | |||||
| 408 | Cardinal num_unmanage, | |||||
| 409 | XtDoChangeProc do_change_proc, | |||||
| 410 | XtPointer client_data, | |||||
| 411 | WidgetList manage_children, | |||||
| 412 | Cardinal num_manage) | |||||
| 413 | { | |||||
| 414 | WidgetList childp; | |||||
| 415 | Widget parent; | |||||
| 416 | int i; | |||||
| 417 | Cardinal some_unmanaged; | |||||
| 418 | Boolean call_out; | |||||
| 419 | CompositeClassExtension ext; | |||||
| 420 | XtAppContext app; | |||||
| 421 | Widget hookobj; | |||||
| 422 | XtChangeHookDataRec call_data; | |||||
| 423 | ||||||
| 424 | if (num_unmanage == 0 && num_manage == 0) | |||||
| 425 | return; | |||||
| 426 | ||||||
| 427 | /* specification doesn't state that library will check for NULL in list */ | |||||
| 428 | ||||||
| 429 | childp = num_unmanage ? unmanage_children : manage_children; | |||||
| 430 | app = XtWidgetToApplicationContext(*childp); | |||||
| 431 | LOCK_APP(app)if(app && app->lock)(*app->lock)(app); | |||||
| 432 | ||||||
| 433 | parent = XtParent(*childp)((*childp)->core.parent); | |||||
| 434 | childp = unmanage_children; | |||||
| 435 | for (i = num_unmanage; --i >= 0 && XtParent(*childp)((*childp)->core.parent) == parent; childp++); | |||||
| 436 | call_out = (i >= 0); | |||||
| 437 | childp = manage_children; | |||||
| 438 | for (i = num_manage; --i >= 0 && XtParent(*childp)((*childp)->core.parent) == parent; childp++); | |||||
| 439 | if (call_out || i >= 0) { | |||||
| 440 | XtAppWarningMsg(app, "ambiguousParent", XtNxtChangeManagedSet, | |||||
| 441 | XtCXtToolkitError, "Not all children have same parent", | |||||
| 442 | (String *)NULL((void*)0), (Cardinal *)NULL((void*)0)); | |||||
| 443 | } | |||||
| 444 | if (! XtIsComposite(parent)(((Object)(parent))->object.widget_class->core_class.class_inited & 0x08)) { | |||||
| 445 | UNLOCK_APP(app)if(app && app->unlock)(*app->unlock)(app); | |||||
| 446 | XtAppErrorMsg(app, "invalidParent", XtNxtChangeManagedSet, | |||||
| 447 | XtCXtToolkitError, | |||||
| 448 | "Attempt to manage a child when parent is not Composite", | |||||
| 449 | (String *) NULL((void*)0), (Cardinal *) NULL((void*)0)); | |||||
| 450 | } | |||||
| 451 | if (parent->core.being_destroyed) { | |||||
| 452 | UNLOCK_APP(app)if(app && app->unlock)(*app->unlock)(app); | |||||
| 453 | return; | |||||
| 454 | } | |||||
| 455 | ||||||
| 456 | call_out = False0; | |||||
| 457 | if (do_change_proc) { | |||||
| 458 | ext = (CompositeClassExtension) | |||||
| 459 | XtGetClassExtension(parent->core.widget_class, | |||||
| 460 | XtOffsetOf(CompositeClassRec,__builtin_offsetof(CompositeClassRec, composite_class.extension ) | |||||
| 461 | composite_class.extension)__builtin_offsetof(CompositeClassRec, composite_class.extension ), | |||||
| 462 | NULLQUARK((XrmQuark) 0), XtCompositeExtensionVersion2L, | |||||
| 463 | sizeof(CompositeClassExtensionRec)); | |||||
| 464 | if (!ext || !ext->allows_change_managed_set) | |||||
| 465 | call_out = True1; | |||||
| 466 | } | |||||
| 467 | ||||||
| 468 | UnmanageChildren(unmanage_children, num_unmanage, parent, | |||||
| 469 | &some_unmanaged, call_out, XtNxtChangeManagedSet); | |||||
| 470 | ||||||
| 471 | hookobj = XtHooksOfDisplay(XtDisplay(parent)(((parent)->core.screen)->display)); | |||||
| 472 | if (XtHasCallbacks(hookobj, XtNchangeHook((char*)&XtStrings[2061])) == XtCallbackHasSome) { | |||||
| 473 | call_data.type = XtHunmanageSet((char*)&XtStrings[2267]); | |||||
| 474 | call_data.widget = parent; | |||||
| 475 | call_data.event_data = (XtPointer) unmanage_children; | |||||
| 476 | call_data.num_event_data = num_unmanage; | |||||
| 477 | XtCallCallbackList(hookobj, | |||||
| 478 | ((HookObject)hookobj)->hooks.changehook_callbacks, | |||||
| 479 | (XtPointer) &call_data); | |||||
| 480 | } | |||||
| 481 | ||||||
| 482 | if (do_change_proc) | |||||
| 483 | (*do_change_proc)(parent, unmanage_children, &num_unmanage, | |||||
| 484 | manage_children, &num_manage, client_data); | |||||
| 485 | ||||||
| 486 | call_out = (some_unmanaged && !call_out); | |||||
| 487 | ManageChildren(manage_children, num_manage, parent, call_out, | |||||
| 488 | XtNxtChangeManagedSet); | |||||
| 489 | ||||||
| 490 | if (XtHasCallbacks(hookobj, XtNchangeHook((char*)&XtStrings[2061])) == XtCallbackHasSome) { | |||||
| 491 | call_data.type = XtHmanageSet((char*)&XtStrings[2255]); | |||||
| 492 | call_data.event_data = (XtPointer) manage_children; | |||||
| 493 | call_data.num_event_data = num_manage; | |||||
| 494 | XtCallCallbackList(hookobj, | |||||
| 495 | ((HookObject)hookobj)->hooks.changehook_callbacks, | |||||
| 496 | (XtPointer) &call_data); | |||||
| 497 | } | |||||
| 498 | UNLOCK_APP(app)if(app && app->unlock)(*app->unlock)(app); | |||||
| 499 | } /* XtChangeManagedSet */ |