Geometry.c revision 0568f49b
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#include "ShellP.h" 76444c061aSmrg#include "ShellI.h" 77444c061aSmrg 78444c061aSmrgstatic void ClearRectObjAreas( 79444c061aSmrg RectObj r, 80444c061aSmrg XWindowChanges* old) 81444c061aSmrg{ 82444c061aSmrg Widget pw = _XtWindowedAncestor((Widget)r); 83444c061aSmrg int bw2; 84444c061aSmrg 85444c061aSmrg bw2 = old->border_width << 1; 86444c061aSmrg XClearArea( XtDisplay(pw), XtWindow(pw), 87444c061aSmrg old->x, old->y, 880568f49bSmrg (unsigned)(old->width + bw2), (unsigned)(old->height + bw2), 89444c061aSmrg TRUE ); 90444c061aSmrg 91444c061aSmrg bw2 = r->rectangle.border_width << 1; 92444c061aSmrg XClearArea( XtDisplay(pw), XtWindow(pw), 93444c061aSmrg (int)r->rectangle.x, (int)r->rectangle.y, 94444c061aSmrg (unsigned int)(r->rectangle.width + bw2), 95444c061aSmrg (unsigned int)(r->rectangle.height + bw2), 96444c061aSmrg TRUE ); 97444c061aSmrg} 98444c061aSmrg 99444c061aSmrg/* 100444c061aSmrg * Internal function used by XtMakeGeometryRequest and XtSetValues. 101444c061aSmrg * Returns more data than the public interface. Does not convert 102444c061aSmrg * XtGeometryDone to XtGeometryYes. 103444c061aSmrg * 104444c061aSmrg * clear_rect_obj - *** RETURNED *** 105444c061aSmrg * TRUE if the rect obj has been cleared, false otherwise. 106444c061aSmrg */ 107444c061aSmrg 108444c061aSmrgXtGeometryResult 109444c061aSmrg_XtMakeGeometryRequest ( 110444c061aSmrg Widget widget, 111444c061aSmrg XtWidgetGeometry *request, 112444c061aSmrg XtWidgetGeometry *reply, 113444c061aSmrg Boolean * clear_rect_obj) 114444c061aSmrg{ 115444c061aSmrg XtWidgetGeometry junk; 116444c061aSmrg XtGeometryHandler manager = (XtGeometryHandler) NULL; 117444c061aSmrg XtGeometryResult returnCode; 118444c061aSmrg Widget parent = widget->core.parent; 1190568f49bSmrg Boolean managed; 1200568f49bSmrg Boolean parentRealized = False; 1210568f49bSmrg Boolean rgm = False; 122444c061aSmrg XtConfigureHookDataRec req; 123444c061aSmrg Widget hookobj; 124444c061aSmrg 125444c061aSmrg *clear_rect_obj = FALSE; 126444c061aSmrg 127444c061aSmrg CALLGEOTAT(_XtGeoTrace(widget, 128444c061aSmrg "\"%s\" is making a %sgeometry request to its parent \"%s\".\n", 129444c061aSmrg XtName(widget), 130444c061aSmrg ((request->request_mode & XtCWQueryOnly))? "query only ":"", 131444c061aSmrg (XtParent(widget))?XtName(XtParent(widget)):"Root")); 132444c061aSmrg CALLGEOTAT(_XtGeoTab(1)); 133444c061aSmrg 134444c061aSmrg if (XtIsShell(widget)) { 135444c061aSmrg ShellClassExtension ext; 136444c061aSmrg LOCK_PROCESS; 137444c061aSmrg for (ext = (ShellClassExtension)((ShellWidgetClass)XtClass(widget)) 138444c061aSmrg ->shell_class.extension; 139444c061aSmrg ext != NULL && ext->record_type != NULLQUARK; 140444c061aSmrg ext = (ShellClassExtension)ext->next_extension); 141444c061aSmrg 142444c061aSmrg if (ext != NULL) { 143444c061aSmrg if ( ext->version == XtShellExtensionVersion 144444c061aSmrg && ext->record_size == sizeof(ShellClassExtensionRec)) { 145444c061aSmrg manager = ext->root_geometry_manager; 146444c061aSmrg rgm = True; 147444c061aSmrg } else { 148444c061aSmrg String params[1]; 149444c061aSmrg Cardinal num_params = 1; 150444c061aSmrg params[0] = XtClass(widget)->core_class.class_name; 151444c061aSmrg XtAppErrorMsg(XtWidgetToApplicationContext(widget), 152444c061aSmrg "invalidExtension", "xtMakeGeometryRequest", 153444c061aSmrg XtCXtToolkitError, 154444c061aSmrg "widget class %s has invalid ShellClassExtension record", 155444c061aSmrg params, &num_params); 156444c061aSmrg } 157444c061aSmrg } else { 158444c061aSmrg XtAppErrorMsg(XtWidgetToApplicationContext(widget), 159444c061aSmrg "internalError", "xtMakeGeometryRequest", 160444c061aSmrg XtCXtToolkitError, 161444c061aSmrg "internal error; ShellClassExtension is NULL", 162444c061aSmrg NULL, NULL); 163444c061aSmrg } 164444c061aSmrg managed = True; 165444c061aSmrg parentRealized = TRUE; 166444c061aSmrg UNLOCK_PROCESS; 167444c061aSmrg } else /* not shell */ { 1680568f49bSmrg if (parent == NULL) { 169444c061aSmrg XtAppErrorMsg(XtWidgetToApplicationContext(widget), 170444c061aSmrg "invalidParent","xtMakeGeometryRequest", 171444c061aSmrg XtCXtToolkitError, 172444c061aSmrg "non-shell has no parent in XtMakeGeometryRequest", 1730568f49bSmrg NULL, NULL); 1740568f49bSmrg } else { 1750568f49bSmrg managed = XtIsManaged(widget); 1760568f49bSmrg parentRealized = XtIsRealized(parent); 1770568f49bSmrg if (XtIsComposite(parent)) 1780568f49bSmrg { 1790568f49bSmrg LOCK_PROCESS; 1800568f49bSmrg manager = ((CompositeWidgetClass) (parent->core.widget_class)) 1810568f49bSmrg ->composite_class.geometry_manager; 1820568f49bSmrg UNLOCK_PROCESS; 1830568f49bSmrg } 184444c061aSmrg } 185444c061aSmrg } 186444c061aSmrg 187444c061aSmrg#if 0 188444c061aSmrg /* 189444c061aSmrg * The Xt spec says that these conditions must generate 190444c061aSmrg * error messages (not warnings), but many Xt applications 191444c061aSmrg * and toolkits (including parts of Xaw, Motif and Netscape) 192444c061aSmrg * depend on the previous Xt behaviour. Thus, these tests 193444c061aSmrg * should probably remain disabled. 194444c061aSmrg */ 195444c061aSmrg if (parentRealized && managed) { 196444c061aSmrg if (parent && !XtIsComposite(parent)) 197444c061aSmrg { 198444c061aSmrg /* 199444c061aSmrg * This shouldn't ever happen, we only test for this to pass 200444c061aSmrg * VSW5. Normally managing the widget will catch this, but VSW5 201444c061aSmrg * does some really screwy stuff to get here. 202444c061aSmrg */ 203444c061aSmrg XtAppErrorMsg(XtWidgetToApplicationContext(widget), 204444c061aSmrg "invalidParent", "xtMakeGeometryRequest", 205444c061aSmrg XtCXtToolkitError, 206444c061aSmrg "XtMakeGeometryRequest - parent not composite", 2070568f49bSmrg NULL, NULL); 208444c061aSmrg } 209444c061aSmrg else if (manager == (XtGeometryHandler) NULL) 210444c061aSmrg { 211444c061aSmrg XtAppErrorMsg(XtWidgetToApplicationContext(widget), 212444c061aSmrg "invalidGeometryManager","xtMakeGeometryRequest", 213444c061aSmrg XtCXtToolkitError, 214444c061aSmrg "XtMakeGeometryRequest - parent has no geometry manager", 2150568f49bSmrg NULL, NULL); 216444c061aSmrg } 217444c061aSmrg } 218444c061aSmrg#else 219444c061aSmrg if (!manager) 220444c061aSmrg managed = False; 221444c061aSmrg#endif 222444c061aSmrg 223444c061aSmrg if (widget->core.being_destroyed) { 224444c061aSmrg CALLGEOTAT(_XtGeoTab(-1)); 225444c061aSmrg CALLGEOTAT(_XtGeoTrace(widget, 226444c061aSmrg "It is being destroyed, just return XtGeometryNo.\n")); 227444c061aSmrg return XtGeometryNo; 228444c061aSmrg } 229444c061aSmrg 230444c061aSmrg /* see if requesting anything to change */ 231444c061aSmrg req.changeMask = 0; 232444c061aSmrg if (request->request_mode & CWStackMode 233444c061aSmrg && request->stack_mode != XtSMDontChange) { 234444c061aSmrg req.changeMask |= CWStackMode; 235444c061aSmrg CALLGEOTAT(_XtGeoTrace(widget, 236444c061aSmrg "Asking for a change in StackMode!\n")); 237444c061aSmrg if (request->request_mode & CWSibling) { 238444c061aSmrg XtCheckSubclass(request->sibling, rectObjClass, 239444c061aSmrg "XtMakeGeometryRequest"); 240444c061aSmrg req.changeMask |= CWSibling; 241444c061aSmrg } 242444c061aSmrg } 243444c061aSmrg if (request->request_mode & CWX 244444c061aSmrg && widget->core.x != request->x) { 245444c061aSmrg CALLGEOTAT(_XtGeoTrace(widget, 246444c061aSmrg "Asking for a change in x: from %d to %d.\n", 247444c061aSmrg widget->core.x, request->x)); 248444c061aSmrg req.changeMask |= CWX; 249444c061aSmrg } 250444c061aSmrg if (request->request_mode & CWY 251444c061aSmrg && widget->core.y != request->y) { 252444c061aSmrg CALLGEOTAT(_XtGeoTrace(widget, 253444c061aSmrg "Asking for a change in y: from %d to %d.\n", 254444c061aSmrg widget->core.y, request->y)); 255444c061aSmrg req.changeMask |= CWY; 256444c061aSmrg } 257444c061aSmrg if (request->request_mode & CWWidth 258444c061aSmrg && widget->core.width != request->width) { 259444c061aSmrg CALLGEOTAT(_XtGeoTrace(widget,"Asking for a change in width: from %d to %d.\n", 260444c061aSmrg widget->core.width, request->width)); 261444c061aSmrg req.changeMask |= CWWidth; 262444c061aSmrg } 263444c061aSmrg if (request->request_mode & CWHeight 264444c061aSmrg && widget->core.height != request->height) { 265444c061aSmrg CALLGEOTAT(_XtGeoTrace(widget, 266444c061aSmrg "Asking for a change in height: from %d to %d.\n", 267444c061aSmrg widget->core.height, request->height)); 268444c061aSmrg req.changeMask |= CWHeight; 269444c061aSmrg } 270444c061aSmrg if (request->request_mode & CWBorderWidth 271444c061aSmrg && widget->core.border_width != request->border_width){ 272444c061aSmrg CALLGEOTAT(_XtGeoTrace(widget, 273444c061aSmrg "Asking for a change in border_width: from %d to %d.\n", 274444c061aSmrg widget->core.border_width, request->border_width)); 275444c061aSmrg req.changeMask |= CWBorderWidth; 276444c061aSmrg } 277444c061aSmrg if (! req.changeMask) { 278444c061aSmrg CALLGEOTAT(_XtGeoTrace(widget, 279444c061aSmrg "Asking for nothing new,\n")); 280444c061aSmrg CALLGEOTAT(_XtGeoTab(-1)); 281444c061aSmrg CALLGEOTAT(_XtGeoTrace(widget, 282444c061aSmrg "just return XtGeometryYes.\n")); 283444c061aSmrg return XtGeometryYes; 284444c061aSmrg } 285444c061aSmrg req.changeMask |= (request->request_mode & XtCWQueryOnly); 286444c061aSmrg 287444c061aSmrg if ( !(req.changeMask & XtCWQueryOnly) && XtIsRealized(widget) ) { 288444c061aSmrg /* keep record of the current geometry so we know what's changed */ 289444c061aSmrg req.changes.x = widget->core.x ; 290444c061aSmrg req.changes.y = widget->core.y ; 291444c061aSmrg req.changes.width = widget->core.width ; 292444c061aSmrg req.changes.height = widget->core.height ; 293444c061aSmrg req.changes.border_width = widget->core.border_width ; 294444c061aSmrg } 295444c061aSmrg 296444c061aSmrg if (!managed || !parentRealized) { 297444c061aSmrg CALLGEOTAT(_XtGeoTrace(widget, 298444c061aSmrg "Not Managed or Parent not realized.\n")); 299444c061aSmrg /* Don't get parent's manager involved--assume the answer is yes */ 300444c061aSmrg if (req.changeMask & XtCWQueryOnly) { 301444c061aSmrg /* He was just asking, don't change anything, just tell him yes */ 302444c061aSmrg CALLGEOTAT(_XtGeoTrace(widget,"QueryOnly request\n")); 303444c061aSmrg CALLGEOTAT(_XtGeoTab(-1)); 304444c061aSmrg CALLGEOTAT(_XtGeoTrace(widget,"just return XtGeometryYes.\n")); 305444c061aSmrg return XtGeometryYes; 306444c061aSmrg } else { 307444c061aSmrg CALLGEOTAT(_XtGeoTrace(widget, 308444c061aSmrg "Copy values from request to widget.\n")); 309444c061aSmrg /* copy values from request to widget */ 310444c061aSmrg if (request->request_mode & CWX) 311444c061aSmrg widget->core.x = request->x; 312444c061aSmrg if (request->request_mode & CWY) 313444c061aSmrg widget->core.y = request->y; 314444c061aSmrg if (request->request_mode & CWWidth) 315444c061aSmrg widget->core.width = request->width; 316444c061aSmrg if (request->request_mode & CWHeight) 317444c061aSmrg widget->core.height = request->height; 318444c061aSmrg if (request->request_mode & CWBorderWidth) 319444c061aSmrg widget->core.border_width = request->border_width; 320444c061aSmrg if (!parentRealized) { 321444c061aSmrg CALLGEOTAT(_XtGeoTab(-1)); 322444c061aSmrg CALLGEOTAT(_XtGeoTrace(widget,"and return XtGeometryYes.\n")); 323444c061aSmrg return XtGeometryYes; 324444c061aSmrg } 325444c061aSmrg else returnCode = XtGeometryYes; 326444c061aSmrg } 327444c061aSmrg } else { 328444c061aSmrg /* go ask the widget's geometry manager */ 329444c061aSmrg CALLGEOTAT(_XtGeoTrace(widget, 330444c061aSmrg "Go ask the parent geometry manager.\n")); 331444c061aSmrg if (reply == (XtWidgetGeometry *) NULL) { 332444c061aSmrg returnCode = (*manager)(widget, request, &junk); 333444c061aSmrg } else { 334444c061aSmrg returnCode = (*manager)(widget, request, reply); 335444c061aSmrg } 336444c061aSmrg } 337444c061aSmrg 338444c061aSmrg /* 339444c061aSmrg * If Unrealized, not a XtGeometryYes, or a query-only then we are done. 340444c061aSmrg */ 341444c061aSmrg 342444c061aSmrg if ((returnCode != XtGeometryYes) || 343444c061aSmrg (req.changeMask & XtCWQueryOnly) || !XtIsRealized(widget)) { 344444c061aSmrg 345444c061aSmrg#ifdef XT_GEO_TATTLER 346444c061aSmrg switch(returnCode){ 347444c061aSmrg case XtGeometryNo: 348444c061aSmrg CALLGEOTAT(_XtGeoTab(-1)); 349444c061aSmrg CALLGEOTAT(_XtGeoTrace(widget,"\"%s\" returns XtGeometryNo.\n", 350444c061aSmrg (XtParent(widget))?XtName(XtParent(widget)):"Root")); 351444c061aSmrg /* check for no change */ 352444c061aSmrg break ; 353444c061aSmrg case XtGeometryDone: 354444c061aSmrg CALLGEOTAT(_XtGeoTab(-1)); 355444c061aSmrg CALLGEOTAT(_XtGeoTrace(widget,"\"%s\" returns XtGeometryDone.\n", 356444c061aSmrg (XtParent(widget))?XtName(XtParent(widget)):"Root")); 357444c061aSmrg /* check for no change in queryonly */ 358444c061aSmrg break ; 359444c061aSmrg case XtGeometryAlmost: 360444c061aSmrg CALLGEOTAT(_XtGeoTab(-1)); 361444c061aSmrg CALLGEOTAT(_XtGeoTrace(widget,"\"%s\" returns XtGeometryAlmost.\n", 362444c061aSmrg (XtParent(widget))?XtName(XtParent(widget)):"Root")); 363444c061aSmrg CALLGEOTAT(_XtGeoTab(1)); 364444c061aSmrg CALLGEOTAT(_XtGeoTrace(widget,"Proposal: width %d height %d.\n", 365444c061aSmrg (reply)?reply->width:junk.width, 366444c061aSmrg (reply)?reply->height:junk.height)); 367444c061aSmrg CALLGEOTAT(_XtGeoTab(-1)); 368444c061aSmrg 369444c061aSmrg /* check for no change */ 370444c061aSmrg break ; 371444c061aSmrg case XtGeometryYes: 372444c061aSmrg if (req.changeMask & XtCWQueryOnly) { 373444c061aSmrg CALLGEOTAT(_XtGeoTrace(widget, 374444c061aSmrg "QueryOnly specified, no configuration.\n")); 375444c061aSmrg } 376444c061aSmrg if (!XtIsRealized(widget)) { 377444c061aSmrg CALLGEOTAT(_XtGeoTrace(widget, 378444c061aSmrg "\"%s\" not realized, no configuration.\n", 379444c061aSmrg XtName(widget))); 380444c061aSmrg } 381444c061aSmrg CALLGEOTAT(_XtGeoTab(-1)); 382444c061aSmrg CALLGEOTAT(_XtGeoTrace(widget,"\"%s\" returns XtGeometryYes.\n", 383444c061aSmrg (XtParent(widget))?XtName(XtParent(widget)):"Root")); 384444c061aSmrg break ; 385444c061aSmrg } 386444c061aSmrg#endif 387444c061aSmrg return returnCode; 388444c061aSmrg } 389444c061aSmrg 390444c061aSmrg CALLGEOTAT(_XtGeoTab(-1)); 391444c061aSmrg CALLGEOTAT(_XtGeoTrace(widget,"\"%s\" returns XtGeometryYes.\n", 392444c061aSmrg (XtParent(widget))?XtName(XtParent(widget)):"Root")); 393444c061aSmrg 394444c061aSmrg if (XtIsWidget(widget)) { /* reconfigure the window (if needed) */ 395444c061aSmrg 396444c061aSmrg if (rgm) return returnCode; 397444c061aSmrg 398444c061aSmrg if (req.changes.x != widget->core.x) { 399444c061aSmrg req.changeMask |= CWX; 400444c061aSmrg req.changes.x = widget->core.x; 401444c061aSmrg CALLGEOTAT(_XtGeoTrace(widget, 402444c061aSmrg "x changing to %d\n",widget->core.x)); 403444c061aSmrg } 404444c061aSmrg if (req.changes.y != widget->core.y) { 405444c061aSmrg req.changeMask |= CWY; 406444c061aSmrg req.changes.y = widget->core.y; 407444c061aSmrg CALLGEOTAT(_XtGeoTrace(widget, 408444c061aSmrg "y changing to %d\n",widget->core.y)); 409444c061aSmrg } 410444c061aSmrg if (req.changes.width != widget->core.width) { 411444c061aSmrg req.changeMask |= CWWidth; 412444c061aSmrg req.changes.width = widget->core.width; 413444c061aSmrg CALLGEOTAT(_XtGeoTrace(widget, 414444c061aSmrg "width changing to %d\n",widget->core.width)); 415444c061aSmrg } 416444c061aSmrg if (req.changes.height != widget->core.height) { 417444c061aSmrg req.changeMask |= CWHeight; 418444c061aSmrg req.changes.height = widget->core.height; 419444c061aSmrg CALLGEOTAT(_XtGeoTrace(widget, 420444c061aSmrg "height changing to %d\n",widget->core.height)); 421444c061aSmrg } 422444c061aSmrg if (req.changes.border_width != widget->core.border_width) { 423444c061aSmrg req.changeMask |= CWBorderWidth; 424444c061aSmrg req.changes.border_width = widget->core.border_width; 425444c061aSmrg CALLGEOTAT(_XtGeoTrace(widget, 426444c061aSmrg "border_width changing to %d\n", 427444c061aSmrg widget->core.border_width)); 428444c061aSmrg } 429444c061aSmrg if (req.changeMask & CWStackMode) { 430444c061aSmrg req.changes.stack_mode = request->stack_mode; 431444c061aSmrg CALLGEOTAT(_XtGeoTrace(widget,"stack_mode changing\n")); 432444c061aSmrg if (req.changeMask & CWSibling) { 433444c061aSmrg if (XtIsWidget(request->sibling)) 434444c061aSmrg req.changes.sibling = XtWindow(request->sibling); 435444c061aSmrg else 4360568f49bSmrg req.changeMask = (XtGeometryMask) (req.changeMask & (unsigned long) (~(CWStackMode | CWSibling))); 437444c061aSmrg } 438444c061aSmrg } 439444c061aSmrg 440444c061aSmrg#ifdef XT_GEO_TATTLER 441444c061aSmrg if (req.changeMask) { 442444c061aSmrg CALLGEOTAT(_XtGeoTrace(widget, 443444c061aSmrg "XConfigure \"%s\"'s window.\n", 444444c061aSmrg XtName(widget))); 445444c061aSmrg } else { 446444c061aSmrg CALLGEOTAT(_XtGeoTrace(widget, 447444c061aSmrg "No window configuration needed for \"%s\".\n", 448444c061aSmrg XtName(widget))); 449444c061aSmrg } 450444c061aSmrg#endif 451444c061aSmrg 452444c061aSmrg XConfigureWindow(XtDisplay(widget), XtWindow(widget), 453444c061aSmrg req.changeMask, &req.changes); 454444c061aSmrg } 455444c061aSmrg else { /* RectObj child of realized Widget */ 456444c061aSmrg *clear_rect_obj = TRUE; 457444c061aSmrg CALLGEOTAT(_XtGeoTrace(widget, 458444c061aSmrg "ClearRectObj on \"%s\".\n",XtName(widget))); 459444c061aSmrg 460444c061aSmrg ClearRectObjAreas((RectObj)widget, &req.changes); 461444c061aSmrg } 4620568f49bSmrg hookobj = XtHooksOfDisplay(XtDisplayOfObject(widget)); 463444c061aSmrg if (XtHasCallbacks(hookobj, XtNconfigureHook) == XtCallbackHasSome) { 464444c061aSmrg req.type = XtHconfigure; 465444c061aSmrg req.widget = widget; 466444c061aSmrg XtCallCallbackList(hookobj, 467444c061aSmrg ((HookObject)hookobj)->hooks.confighook_callbacks, 468444c061aSmrg (XtPointer)&req); 469444c061aSmrg } 470444c061aSmrg 471444c061aSmrg return returnCode; 472444c061aSmrg} /* _XtMakeGeometryRequest */ 473444c061aSmrg 474444c061aSmrg 475444c061aSmrg/* Public routines */ 476444c061aSmrg 477444c061aSmrgXtGeometryResult XtMakeGeometryRequest ( 478444c061aSmrg Widget widget, 479444c061aSmrg XtWidgetGeometry *request, 480444c061aSmrg XtWidgetGeometry *reply) 481444c061aSmrg{ 482444c061aSmrg Boolean junk; 483444c061aSmrg XtGeometryResult r; 484444c061aSmrg XtGeometryHookDataRec call_data; 485444c061aSmrg Widget hookobj = XtHooksOfDisplay(XtDisplayOfObject(widget)); 486444c061aSmrg WIDGET_TO_APPCON(widget); 487444c061aSmrg 488444c061aSmrg LOCK_APP(app); 489444c061aSmrg if (XtHasCallbacks(hookobj, XtNgeometryHook) == XtCallbackHasSome) { 490444c061aSmrg call_data.type = XtHpreGeometry; 491444c061aSmrg call_data.widget = widget; 492444c061aSmrg call_data.request = request; 493444c061aSmrg XtCallCallbackList(hookobj, 494444c061aSmrg ((HookObject)hookobj)->hooks.geometryhook_callbacks, 495444c061aSmrg (XtPointer)&call_data); 496444c061aSmrg call_data.result = r = 497444c061aSmrg _XtMakeGeometryRequest(widget, request, reply, &junk); 498444c061aSmrg call_data.type = XtHpostGeometry; 499444c061aSmrg call_data.reply = reply; 500444c061aSmrg XtCallCallbackList(hookobj, 501444c061aSmrg ((HookObject)hookobj)->hooks.geometryhook_callbacks, 502444c061aSmrg (XtPointer)&call_data); 503444c061aSmrg } else { 504444c061aSmrg r = _XtMakeGeometryRequest(widget, request, reply, &junk); 505444c061aSmrg } 506444c061aSmrg UNLOCK_APP(app); 507444c061aSmrg 508444c061aSmrg return ((r == XtGeometryDone) ? XtGeometryYes : r); 509444c061aSmrg} 510444c061aSmrg 511444c061aSmrgXtGeometryResult 512444c061aSmrgXtMakeResizeRequest( 513444c061aSmrg Widget widget, 514444c061aSmrg _XtDimension width, 515444c061aSmrg _XtDimension height, 516444c061aSmrg Dimension *replyWidth, 517444c061aSmrg Dimension *replyHeight) 518444c061aSmrg{ 519444c061aSmrg XtWidgetGeometry request, reply; 520444c061aSmrg XtGeometryResult r; 521444c061aSmrg XtGeometryHookDataRec call_data; 522444c061aSmrg Boolean junk; 523444c061aSmrg Widget hookobj = XtHooksOfDisplay(XtDisplayOfObject(widget)); 524444c061aSmrg WIDGET_TO_APPCON(widget); 525444c061aSmrg 526444c061aSmrg LOCK_APP(app); 527444c061aSmrg request.request_mode = CWWidth | CWHeight; 5280568f49bSmrg request.width = (Dimension) width; 5290568f49bSmrg request.height = (Dimension) height; 530444c061aSmrg 531444c061aSmrg if (XtHasCallbacks(hookobj, XtNgeometryHook) == XtCallbackHasSome) { 532444c061aSmrg call_data.type = XtHpreGeometry; 533444c061aSmrg call_data.widget = widget; 534444c061aSmrg call_data.request = &request; 535444c061aSmrg XtCallCallbackList(hookobj, 536444c061aSmrg ((HookObject)hookobj)->hooks.geometryhook_callbacks, 537444c061aSmrg (XtPointer)&call_data); 538444c061aSmrg call_data.result = r = 539444c061aSmrg _XtMakeGeometryRequest(widget, &request, &reply, &junk); 540444c061aSmrg call_data.type = XtHpostGeometry; 541444c061aSmrg call_data.reply = &reply; 542444c061aSmrg XtCallCallbackList(hookobj, 543444c061aSmrg ((HookObject)hookobj)->hooks.geometryhook_callbacks, 544444c061aSmrg (XtPointer)&call_data); 545444c061aSmrg } else { 546444c061aSmrg r = _XtMakeGeometryRequest(widget, &request, &reply, &junk); 547444c061aSmrg } 548444c061aSmrg if (replyWidth != NULL) { 549444c061aSmrg if (r == XtGeometryAlmost && reply.request_mode & CWWidth) 550444c061aSmrg *replyWidth = reply.width; 551444c061aSmrg else 5520568f49bSmrg *replyWidth = (Dimension) width; 553444c061aSmrg } 554444c061aSmrg if (replyHeight != NULL) { 555444c061aSmrg if (r == XtGeometryAlmost && reply.request_mode & CWHeight) 556444c061aSmrg *replyHeight = reply.height; 557444c061aSmrg else 5580568f49bSmrg *replyHeight = (Dimension) height; 559444c061aSmrg } 560444c061aSmrg UNLOCK_APP(app); 561444c061aSmrg return ((r == XtGeometryDone) ? XtGeometryYes : r); 562444c061aSmrg} /* XtMakeResizeRequest */ 563444c061aSmrg 564444c061aSmrgvoid XtResizeWindow( 565444c061aSmrg Widget w) 566444c061aSmrg{ 567444c061aSmrg XtConfigureHookDataRec req; 568444c061aSmrg WIDGET_TO_APPCON(w); 569444c061aSmrg 570444c061aSmrg LOCK_APP(app); 571444c061aSmrg if (XtIsRealized(w)) { 5720568f49bSmrg Widget hookobj; 5730568f49bSmrg 574444c061aSmrg req.changes.width = w->core.width; 575444c061aSmrg req.changes.height = w->core.height; 576444c061aSmrg req.changes.border_width = w->core.border_width; 577444c061aSmrg req.changeMask = CWWidth | CWHeight | CWBorderWidth; 578444c061aSmrg XConfigureWindow(XtDisplay(w), XtWindow(w), 579444c061aSmrg (unsigned) req.changeMask, &req.changes); 5800568f49bSmrg hookobj = XtHooksOfDisplay(XtDisplayOfObject(w)); 581444c061aSmrg if (XtHasCallbacks(hookobj, XtNconfigureHook) == XtCallbackHasSome) { 582444c061aSmrg req.type = XtHconfigure; 583444c061aSmrg req.widget = w; 584444c061aSmrg XtCallCallbackList(hookobj, 585444c061aSmrg ((HookObject)hookobj)->hooks.confighook_callbacks, 586444c061aSmrg (XtPointer)&req); 587444c061aSmrg } 588444c061aSmrg } 589444c061aSmrg UNLOCK_APP(app); 590444c061aSmrg} /* XtResizeWindow */ 591444c061aSmrg 592444c061aSmrgvoid XtResizeWidget( 593444c061aSmrg Widget w, 594444c061aSmrg _XtDimension width, 595444c061aSmrg _XtDimension height, 596444c061aSmrg _XtDimension borderWidth) 597444c061aSmrg{ 598444c061aSmrg XtConfigureWidget(w, w->core.x, w->core.y, width, height, borderWidth); 599444c061aSmrg} /* XtResizeWidget */ 600444c061aSmrg 601444c061aSmrgvoid XtConfigureWidget( 602444c061aSmrg Widget w, 603444c061aSmrg _XtPosition x, 604444c061aSmrg _XtPosition y, 605444c061aSmrg _XtDimension width, 606444c061aSmrg _XtDimension height, 607444c061aSmrg _XtDimension borderWidth) 608444c061aSmrg{ 609444c061aSmrg XtConfigureHookDataRec req; 610444c061aSmrg XWindowChanges old; 611444c061aSmrg WIDGET_TO_APPCON(w); 612444c061aSmrg 613444c061aSmrg CALLGEOTAT(_XtGeoTrace(w, 614444c061aSmrg "\"%s\" is being configured by its parent \"%s\"\n", 615444c061aSmrg XtName(w), 616444c061aSmrg (XtParent(w))?XtName(XtParent(w)):"Root")); 617444c061aSmrg CALLGEOTAT(_XtGeoTab(1)); 618444c061aSmrg 619444c061aSmrg LOCK_APP(app); 620444c061aSmrg req.changeMask = 0; 621444c061aSmrg if ((old.x = w->core.x) != x) { 622444c061aSmrg CALLGEOTAT(_XtGeoTrace(w,"x move from %d to %d\n",w->core.x, x)); 6230568f49bSmrg req.changes.x = w->core.x = (Position) x; 624444c061aSmrg req.changeMask |= CWX; 625444c061aSmrg } 626444c061aSmrg 627444c061aSmrg if ((old.y = w->core.y) != y) { 628444c061aSmrg CALLGEOTAT(_XtGeoTrace(w,"y move from %d to %d\n",w->core.y, y)); 6290568f49bSmrg req.changes.y = w->core.y = (Position) y; 630444c061aSmrg req.changeMask |= CWY; 631444c061aSmrg } 632444c061aSmrg 633444c061aSmrg if ((old.width = w->core.width) != width) { 634444c061aSmrg CALLGEOTAT(_XtGeoTrace(w, 635444c061aSmrg "width move from %d to %d\n",w->core.width, width)); 6360568f49bSmrg req.changes.width = w->core.width = (Dimension) width; 637444c061aSmrg req.changeMask |= CWWidth; 638444c061aSmrg } 639444c061aSmrg 640444c061aSmrg if ((old.height = w->core.height) != height) { 641444c061aSmrg CALLGEOTAT(_XtGeoTrace(w, 642444c061aSmrg "height move from %d to %d\n",w->core.height, height)); 6430568f49bSmrg req.changes.height = w->core.height = (Dimension) height; 644444c061aSmrg req.changeMask |= CWHeight; 645444c061aSmrg } 646444c061aSmrg 647444c061aSmrg if ((old.border_width = w->core.border_width) != borderWidth) { 648444c061aSmrg CALLGEOTAT(_XtGeoTrace(w,"border_width move from %d to %d\n", 649444c061aSmrg w->core.border_width,borderWidth )); 6500568f49bSmrg req.changes.border_width = w->core.border_width = (Dimension) borderWidth; 651444c061aSmrg req.changeMask |= CWBorderWidth; 652444c061aSmrg } 653444c061aSmrg 654444c061aSmrg if (req.changeMask != 0) { 6550568f49bSmrg Widget hookobj; 6560568f49bSmrg 657444c061aSmrg if (XtIsRealized(w)) { 658444c061aSmrg if (XtIsWidget(w)) { 659444c061aSmrg CALLGEOTAT(_XtGeoTrace(w, 660444c061aSmrg "XConfigure \"%s\"'s window\n",XtName(w))); 661444c061aSmrg XConfigureWindow(XtDisplay(w), XtWindow(w), 662444c061aSmrg req.changeMask, &req.changes); 663444c061aSmrg } else { 664444c061aSmrg CALLGEOTAT(_XtGeoTrace(w, 665444c061aSmrg "ClearRectObj called on \"%s\"\n",XtName(w))); 666444c061aSmrg ClearRectObjAreas((RectObj)w, &old); 667444c061aSmrg } 668444c061aSmrg } 6690568f49bSmrg hookobj = XtHooksOfDisplay(XtDisplayOfObject(w)); 670444c061aSmrg if (XtHasCallbacks(hookobj, XtNconfigureHook) == XtCallbackHasSome) { 671444c061aSmrg req.type = XtHconfigure; 672444c061aSmrg req.widget = w; 673444c061aSmrg XtCallCallbackList(hookobj, 674444c061aSmrg ((HookObject)hookobj)->hooks.confighook_callbacks, 675444c061aSmrg (XtPointer)&req); 676444c061aSmrg } 677444c061aSmrg { 678444c061aSmrg XtWidgetProc resize; 679444c061aSmrg 680444c061aSmrg LOCK_PROCESS; 681444c061aSmrg resize = XtClass(w)->core_class.resize; 682444c061aSmrg UNLOCK_PROCESS; 683444c061aSmrg if ((req.changeMask & (CWWidth | CWHeight)) && 684444c061aSmrg resize != (XtWidgetProc) NULL) { 685444c061aSmrg CALLGEOTAT(_XtGeoTrace(w,"Resize proc is called.\n")); 686444c061aSmrg (*resize)(w); 687444c061aSmrg } 688444c061aSmrg } 689444c061aSmrg } else { 690444c061aSmrg CALLGEOTAT(_XtGeoTrace(w,"No change in configuration\n")); 691444c061aSmrg } 692444c061aSmrg 693444c061aSmrg CALLGEOTAT(_XtGeoTab(-1)); 694444c061aSmrg UNLOCK_APP(app); 695444c061aSmrg} /* XtConfigureWidget */ 696444c061aSmrg 697444c061aSmrgvoid XtMoveWidget( 698444c061aSmrg Widget w, 699444c061aSmrg _XtPosition x, 700444c061aSmrg _XtPosition y) 701444c061aSmrg{ 702444c061aSmrg XtConfigureWidget(w, x, y, w->core.width, w->core.height, 703444c061aSmrg w->core.border_width); 704444c061aSmrg} /* XtMoveWidget */ 705444c061aSmrg 706444c061aSmrgvoid XtTranslateCoords( 707444c061aSmrg register Widget w, 708444c061aSmrg _XtPosition x, 709444c061aSmrg _XtPosition y, 710444c061aSmrg register Position *rootx, /* return */ 711444c061aSmrg register Position *rooty) /* return */ 712444c061aSmrg{ 713444c061aSmrg Position garbagex, garbagey; 714444c061aSmrg XtAppContext app = XtWidgetToApplicationContext(w); 715444c061aSmrg 716444c061aSmrg LOCK_APP(app); 717444c061aSmrg if (rootx == NULL) rootx = &garbagex; 718444c061aSmrg if (rooty == NULL) rooty = &garbagey; 719444c061aSmrg 7200568f49bSmrg *rootx = (Position) x; 7210568f49bSmrg *rooty = (Position) y; 722444c061aSmrg 723444c061aSmrg for (; w != NULL && ! XtIsShell(w); w = w->core.parent) { 7240568f49bSmrg *rootx = (Position) (*rootx + w->core.x + w->core.border_width); 7250568f49bSmrg *rooty = (Position) (*rooty + w->core.y + w->core.border_width); 726444c061aSmrg } 727444c061aSmrg 728444c061aSmrg if (w == NULL) 729444c061aSmrg XtAppWarningMsg(app, 730444c061aSmrg "invalidShell","xtTranslateCoords",XtCXtToolkitError, 731444c061aSmrg "Widget has no shell ancestor", 7320568f49bSmrg NULL, NULL); 733444c061aSmrg else { 7340568f49bSmrg Position x2, y2; 7350568f49bSmrg _XtShellGetCoordinates( w, &x2, &y2 ); 7360568f49bSmrg *rootx = (Position) (*rootx + x2 + w->core.border_width); 7370568f49bSmrg *rooty = (Position) (*rooty + y2 + w->core.border_width); 738444c061aSmrg } 739444c061aSmrg UNLOCK_APP(app); 740444c061aSmrg} 741444c061aSmrg 742444c061aSmrgXtGeometryResult XtQueryGeometry( 743444c061aSmrg Widget widget, 744444c061aSmrg register XtWidgetGeometry *intended, /* parent's changes; may be NULL */ 745444c061aSmrg XtWidgetGeometry *reply) /* child's preferred geometry; never NULL */ 746444c061aSmrg{ 747444c061aSmrg XtWidgetGeometry null_intended; 748444c061aSmrg XtGeometryHandler query; 749444c061aSmrg XtGeometryResult result; 750444c061aSmrg WIDGET_TO_APPCON(widget); 751444c061aSmrg 752444c061aSmrg CALLGEOTAT(_XtGeoTrace(widget, 753444c061aSmrg "\"%s\" is asking its preferred geometry to \"%s\".\n", 754444c061aSmrg (XtParent(widget))?XtName(XtParent(widget)):"Root", 755444c061aSmrg XtName(widget))); 756444c061aSmrg CALLGEOTAT(_XtGeoTab(1)); 757444c061aSmrg 758444c061aSmrg LOCK_APP(app); 759444c061aSmrg LOCK_PROCESS; 760444c061aSmrg query = XtClass(widget)->core_class.query_geometry; 761444c061aSmrg UNLOCK_PROCESS; 762444c061aSmrg reply->request_mode = 0; 763444c061aSmrg if (query != NULL) { 764444c061aSmrg if (intended == NULL) { 765444c061aSmrg null_intended.request_mode = 0; 766444c061aSmrg intended = &null_intended; 767444c061aSmrg#ifdef XT_GEO_TATTLER 768444c061aSmrg CALLGEOTAT(_XtGeoTrace(widget,"without any constraint.\n")); 769444c061aSmrg } else { 770444c061aSmrg CALLGEOTAT(_XtGeoTrace(widget, 771444c061aSmrg "with the following constraints:\n")); 772444c061aSmrg 773444c061aSmrg if (intended->request_mode & CWX) { 774444c061aSmrg CALLGEOTAT(_XtGeoTrace(widget," x = %d\n",intended->x)); 775444c061aSmrg } 776444c061aSmrg if (intended->request_mode & CWY) { 777444c061aSmrg CALLGEOTAT(_XtGeoTrace(widget," y = %d\n",intended->y)); 778444c061aSmrg } 779444c061aSmrg if (intended->request_mode & CWWidth) { 780444c061aSmrg CALLGEOTAT(_XtGeoTrace(widget, 781444c061aSmrg " width = %d\n",intended->width)); 782444c061aSmrg } 783444c061aSmrg if (intended->request_mode & CWHeight) { 784444c061aSmrg CALLGEOTAT(_XtGeoTrace(widget, 785444c061aSmrg " height = %d\n",intended->height)); 786444c061aSmrg } 787444c061aSmrg if (intended->request_mode & CWBorderWidth) { 788444c061aSmrg CALLGEOTAT(_XtGeoTrace(widget, 789444c061aSmrg " border_width = %d\n",intended->border_width)); 790444c061aSmrg } 791444c061aSmrg#endif 792444c061aSmrg } 793444c061aSmrg 794444c061aSmrg result = (*query) (widget, intended, reply); 795444c061aSmrg } 796444c061aSmrg else { 797444c061aSmrg CALLGEOTAT(_XtGeoTrace(widget,"\"%s\" has no QueryGeometry proc, return the current state\n",XtName(widget))); 798444c061aSmrg 799444c061aSmrg result = XtGeometryYes; 800444c061aSmrg } 801444c061aSmrg 802444c061aSmrg#ifdef XT_GEO_TATTLER 803444c061aSmrg#define FillIn(mask, field) \ 804444c061aSmrg if (!(reply->request_mode & mask)) {\ 805444c061aSmrg reply->field = widget->core.field;\ 806444c061aSmrg _XtGeoTrace(widget," using core %s = %d.\n","field",\ 807444c061aSmrg widget->core.field);\ 808444c061aSmrg } else {\ 809444c061aSmrg _XtGeoTrace(widget," replied %s = %d\n","field",\ 810444c061aSmrg reply->field);\ 811444c061aSmrg } 812444c061aSmrg#else 813444c061aSmrg#define FillIn(mask, field) \ 814444c061aSmrg if (!(reply->request_mode & mask)) reply->field = widget->core.field; 815444c061aSmrg#endif 816444c061aSmrg 817444c061aSmrg FillIn(CWX, x); 818444c061aSmrg FillIn(CWY, y); 819444c061aSmrg FillIn(CWWidth, width); 820444c061aSmrg FillIn(CWHeight, height); 821444c061aSmrg FillIn(CWBorderWidth, border_width); 822444c061aSmrg 823444c061aSmrg CALLGEOTAT(_XtGeoTab(-1)); 824444c061aSmrg#undef FillIn 825444c061aSmrg 826444c061aSmrg if (!(reply->request_mode & CWStackMode)) 827444c061aSmrg reply->stack_mode = XtSMDontChange; 828444c061aSmrg UNLOCK_APP(app); 829444c061aSmrg return result; 830444c061aSmrg} 831