Geometry.c revision 1477040f
1444c061aSmrg/* $Xorg: Geometry.c,v 1.5 2001/02/09 02:03:54 xorgcvs Exp $ */ 2444c061aSmrg 3444c061aSmrg/*********************************************************** 41477040fSmrgCopyright 1993 Sun Microsystems, Inc. All rights reserved. 51477040fSmrg 61477040fSmrgPermission is hereby granted, free of charge, to any person obtaining a 71477040fSmrgcopy of this software and associated documentation files (the "Software"), 81477040fSmrgto deal in the Software without restriction, including without limitation 91477040fSmrgthe rights to use, copy, modify, merge, publish, distribute, sublicense, 101477040fSmrgand/or sell copies of the Software, and to permit persons to whom the 111477040fSmrgSoftware is furnished to do so, subject to the following conditions: 121477040fSmrg 131477040fSmrgThe above copyright notice and this permission notice (including the next 141477040fSmrgparagraph) shall be included in all copies or substantial portions of the 151477040fSmrgSoftware. 161477040fSmrg 171477040fSmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 181477040fSmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 191477040fSmrgFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 201477040fSmrgTHE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 211477040fSmrgLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 221477040fSmrgFROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 231477040fSmrgDEALINGS IN THE SOFTWARE. 241477040fSmrg 251477040fSmrgCopyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts. 26444c061aSmrg 27444c061aSmrg All Rights Reserved 28444c061aSmrg 29444c061aSmrgPermission to use, copy, modify, and distribute this software and its 30444c061aSmrgdocumentation for any purpose and without fee is hereby granted, 31444c061aSmrgprovided that the above copyright notice appear in all copies and that 32444c061aSmrgboth that copyright notice and this permission notice appear in 331477040fSmrgsupporting documentation, and that the name of Digital not be 34444c061aSmrgused in advertising or publicity pertaining to distribution of the 35444c061aSmrgsoftware without specific, written prior permission. 36444c061aSmrg 37444c061aSmrgDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING 38444c061aSmrgALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL 39444c061aSmrgDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR 40444c061aSmrgANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 41444c061aSmrgWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 42444c061aSmrgARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 43444c061aSmrgSOFTWARE. 44444c061aSmrg 45444c061aSmrg******************************************************************/ 46444c061aSmrg 47444c061aSmrg/* 48444c061aSmrg 49444c061aSmrgCopyright 1987, 1988, 1994, 1998 The Open Group 50444c061aSmrg 51444c061aSmrgPermission to use, copy, modify, distribute, and sell this software and its 52444c061aSmrgdocumentation for any purpose is hereby granted without fee, provided that 53444c061aSmrgthe above copyright notice appear in all copies and that both that 54444c061aSmrgcopyright notice and this permission notice appear in supporting 55444c061aSmrgdocumentation. 56444c061aSmrg 57444c061aSmrgThe above copyright notice and this permission notice shall be included in 58444c061aSmrgall copies or substantial portions of the Software. 59444c061aSmrg 60444c061aSmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 61444c061aSmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 62444c061aSmrgFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 63444c061aSmrgOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 64444c061aSmrgAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 65444c061aSmrgCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 66444c061aSmrg 67444c061aSmrgExcept as contained in this notice, the name of The Open Group shall not be 68444c061aSmrgused in advertising or otherwise to promote the sale, use or other dealings 69444c061aSmrgin this Software without prior written authorization from The Open Group. 70444c061aSmrg 71444c061aSmrg*/ 72444c061aSmrg/* $XFree86: xc/lib/Xt/Geometry.c,v 1.12 2001/12/14 19:56:15 dawes Exp $ */ 73444c061aSmrg 74444c061aSmrg#ifdef HAVE_CONFIG_H 75444c061aSmrg#include <config.h> 76444c061aSmrg#endif 77444c061aSmrg#include "IntrinsicI.h" 78444c061aSmrg#include "ShellP.h" 79444c061aSmrg#include "ShellI.h" 80444c061aSmrg 81444c061aSmrgstatic void ClearRectObjAreas( 82444c061aSmrg RectObj r, 83444c061aSmrg XWindowChanges* old) 84444c061aSmrg{ 85444c061aSmrg Widget pw = _XtWindowedAncestor((Widget)r); 86444c061aSmrg int bw2; 87444c061aSmrg 88444c061aSmrg bw2 = old->border_width << 1; 89444c061aSmrg XClearArea( XtDisplay(pw), XtWindow(pw), 90444c061aSmrg old->x, old->y, 91444c061aSmrg old->width + bw2, old->height + bw2, 92444c061aSmrg TRUE ); 93444c061aSmrg 94444c061aSmrg bw2 = r->rectangle.border_width << 1; 95444c061aSmrg XClearArea( XtDisplay(pw), XtWindow(pw), 96444c061aSmrg (int)r->rectangle.x, (int)r->rectangle.y, 97444c061aSmrg (unsigned int)(r->rectangle.width + bw2), 98444c061aSmrg (unsigned int)(r->rectangle.height + bw2), 99444c061aSmrg TRUE ); 100444c061aSmrg} 101444c061aSmrg 102444c061aSmrg/* 103444c061aSmrg * Internal function used by XtMakeGeometryRequest and XtSetValues. 104444c061aSmrg * Returns more data than the public interface. Does not convert 105444c061aSmrg * XtGeometryDone to XtGeometryYes. 106444c061aSmrg * 107444c061aSmrg * clear_rect_obj - *** RETURNED *** 108444c061aSmrg * TRUE if the rect obj has been cleared, false otherwise. 109444c061aSmrg */ 110444c061aSmrg 111444c061aSmrgXtGeometryResult 112444c061aSmrg_XtMakeGeometryRequest ( 113444c061aSmrg Widget widget, 114444c061aSmrg XtWidgetGeometry *request, 115444c061aSmrg XtWidgetGeometry *reply, 116444c061aSmrg Boolean * clear_rect_obj) 117444c061aSmrg{ 118444c061aSmrg XtWidgetGeometry junk; 119444c061aSmrg XtGeometryHandler manager = (XtGeometryHandler) NULL; 120444c061aSmrg XtGeometryResult returnCode; 121444c061aSmrg Widget parent = widget->core.parent; 122444c061aSmrg Boolean managed, parentRealized, rgm = False; 123444c061aSmrg XtConfigureHookDataRec req; 124444c061aSmrg Widget hookobj; 125444c061aSmrg 126444c061aSmrg *clear_rect_obj = FALSE; 127444c061aSmrg 128444c061aSmrg CALLGEOTAT(_XtGeoTrace(widget, 129444c061aSmrg "\"%s\" is making a %sgeometry request to its parent \"%s\".\n", 130444c061aSmrg XtName(widget), 131444c061aSmrg ((request->request_mode & XtCWQueryOnly))? "query only ":"", 132444c061aSmrg (XtParent(widget))?XtName(XtParent(widget)):"Root")); 133444c061aSmrg CALLGEOTAT(_XtGeoTab(1)); 134444c061aSmrg 135444c061aSmrg if (XtIsShell(widget)) { 136444c061aSmrg ShellClassExtension ext; 137444c061aSmrg LOCK_PROCESS; 138444c061aSmrg for (ext = (ShellClassExtension)((ShellWidgetClass)XtClass(widget)) 139444c061aSmrg ->shell_class.extension; 140444c061aSmrg ext != NULL && ext->record_type != NULLQUARK; 141444c061aSmrg ext = (ShellClassExtension)ext->next_extension); 142444c061aSmrg 143444c061aSmrg if (ext != NULL) { 144444c061aSmrg if ( ext->version == XtShellExtensionVersion 145444c061aSmrg && ext->record_size == sizeof(ShellClassExtensionRec)) { 146444c061aSmrg manager = ext->root_geometry_manager; 147444c061aSmrg rgm = True; 148444c061aSmrg } else { 149444c061aSmrg String params[1]; 150444c061aSmrg Cardinal num_params = 1; 151444c061aSmrg params[0] = XtClass(widget)->core_class.class_name; 152444c061aSmrg XtAppErrorMsg(XtWidgetToApplicationContext(widget), 153444c061aSmrg "invalidExtension", "xtMakeGeometryRequest", 154444c061aSmrg XtCXtToolkitError, 155444c061aSmrg "widget class %s has invalid ShellClassExtension record", 156444c061aSmrg params, &num_params); 157444c061aSmrg } 158444c061aSmrg } else { 159444c061aSmrg XtAppErrorMsg(XtWidgetToApplicationContext(widget), 160444c061aSmrg "internalError", "xtMakeGeometryRequest", 161444c061aSmrg XtCXtToolkitError, 162444c061aSmrg "internal error; ShellClassExtension is NULL", 163444c061aSmrg NULL, NULL); 164444c061aSmrg } 165444c061aSmrg managed = True; 166444c061aSmrg parentRealized = TRUE; 167444c061aSmrg UNLOCK_PROCESS; 168444c061aSmrg } else /* not shell */ { 169444c061aSmrg if (parent == NULL) 170444c061aSmrg XtAppErrorMsg(XtWidgetToApplicationContext(widget), 171444c061aSmrg "invalidParent","xtMakeGeometryRequest", 172444c061aSmrg XtCXtToolkitError, 173444c061aSmrg "non-shell has no parent in XtMakeGeometryRequest", 174444c061aSmrg (String *)NULL, (Cardinal *)NULL); 175444c061aSmrg 176444c061aSmrg managed = XtIsManaged(widget); 177444c061aSmrg parentRealized = XtIsRealized(parent); 178444c061aSmrg if (XtIsComposite(parent)) 179444c061aSmrg { 180444c061aSmrg LOCK_PROCESS; 181444c061aSmrg manager = ((CompositeWidgetClass) (parent->core.widget_class)) 182444c061aSmrg ->composite_class.geometry_manager; 183444c061aSmrg UNLOCK_PROCESS; 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", 207444c061aSmrg (String *)NULL, (Cardinal *)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", 215444c061aSmrg (String *)NULL, (Cardinal *)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 436444c061aSmrg req.changeMask &= ~(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 } 462444c061aSmrg 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; 528444c061aSmrg request.width = width; 529444c061aSmrg request.height = 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 552444c061aSmrg *replyWidth = width; 553444c061aSmrg } 554444c061aSmrg if (replyHeight != NULL) { 555444c061aSmrg if (r == XtGeometryAlmost && reply.request_mode & CWHeight) 556444c061aSmrg *replyHeight = reply.height; 557444c061aSmrg else 558444c061aSmrg *replyHeight = 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 hookobj; 569444c061aSmrg WIDGET_TO_APPCON(w); 570444c061aSmrg 571444c061aSmrg LOCK_APP(app); 572444c061aSmrg if (XtIsRealized(w)) { 573444c061aSmrg req.changes.width = w->core.width; 574444c061aSmrg req.changes.height = w->core.height; 575444c061aSmrg req.changes.border_width = w->core.border_width; 576444c061aSmrg req.changeMask = CWWidth | CWHeight | CWBorderWidth; 577444c061aSmrg XConfigureWindow(XtDisplay(w), XtWindow(w), 578444c061aSmrg (unsigned) req.changeMask, &req.changes); 579444c061aSmrg hookobj = XtHooksOfDisplay(XtDisplayOfObject(w));; 580444c061aSmrg if (XtHasCallbacks(hookobj, XtNconfigureHook) == XtCallbackHasSome) { 581444c061aSmrg req.type = XtHconfigure; 582444c061aSmrg req.widget = w; 583444c061aSmrg XtCallCallbackList(hookobj, 584444c061aSmrg ((HookObject)hookobj)->hooks.confighook_callbacks, 585444c061aSmrg (XtPointer)&req); 586444c061aSmrg } 587444c061aSmrg } 588444c061aSmrg UNLOCK_APP(app); 589444c061aSmrg} /* XtResizeWindow */ 590444c061aSmrg 591444c061aSmrgvoid XtResizeWidget( 592444c061aSmrg Widget w, 593444c061aSmrg _XtDimension width, 594444c061aSmrg _XtDimension height, 595444c061aSmrg _XtDimension borderWidth) 596444c061aSmrg{ 597444c061aSmrg XtConfigureWidget(w, w->core.x, w->core.y, width, height, borderWidth); 598444c061aSmrg} /* XtResizeWidget */ 599444c061aSmrg 600444c061aSmrgvoid XtConfigureWidget( 601444c061aSmrg Widget w, 602444c061aSmrg _XtPosition x, 603444c061aSmrg _XtPosition y, 604444c061aSmrg _XtDimension width, 605444c061aSmrg _XtDimension height, 606444c061aSmrg _XtDimension borderWidth) 607444c061aSmrg{ 608444c061aSmrg XtConfigureHookDataRec req; 609444c061aSmrg Widget hookobj; 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)); 623444c061aSmrg req.changes.x = w->core.x = 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)); 629444c061aSmrg req.changes.y = w->core.y = 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)); 636444c061aSmrg req.changes.width = w->core.width = 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)); 643444c061aSmrg req.changes.height = w->core.height = 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 )); 650444c061aSmrg req.changes.border_width = w->core.border_width = borderWidth; 651444c061aSmrg req.changeMask |= CWBorderWidth; 652444c061aSmrg } 653444c061aSmrg 654444c061aSmrg if (req.changeMask != 0) { 655444c061aSmrg if (XtIsRealized(w)) { 656444c061aSmrg if (XtIsWidget(w)) { 657444c061aSmrg CALLGEOTAT(_XtGeoTrace(w, 658444c061aSmrg "XConfigure \"%s\"'s window\n",XtName(w))); 659444c061aSmrg XConfigureWindow(XtDisplay(w), XtWindow(w), 660444c061aSmrg req.changeMask, &req.changes); 661444c061aSmrg } else { 662444c061aSmrg CALLGEOTAT(_XtGeoTrace(w, 663444c061aSmrg "ClearRectObj called on \"%s\"\n",XtName(w))); 664444c061aSmrg ClearRectObjAreas((RectObj)w, &old); 665444c061aSmrg } 666444c061aSmrg } 667444c061aSmrg hookobj = XtHooksOfDisplay(XtDisplayOfObject(w));; 668444c061aSmrg if (XtHasCallbacks(hookobj, XtNconfigureHook) == XtCallbackHasSome) { 669444c061aSmrg req.type = XtHconfigure; 670444c061aSmrg req.widget = w; 671444c061aSmrg XtCallCallbackList(hookobj, 672444c061aSmrg ((HookObject)hookobj)->hooks.confighook_callbacks, 673444c061aSmrg (XtPointer)&req); 674444c061aSmrg } 675444c061aSmrg { 676444c061aSmrg XtWidgetProc resize; 677444c061aSmrg 678444c061aSmrg LOCK_PROCESS; 679444c061aSmrg resize = XtClass(w)->core_class.resize; 680444c061aSmrg UNLOCK_PROCESS; 681444c061aSmrg if ((req.changeMask & (CWWidth | CWHeight)) && 682444c061aSmrg resize != (XtWidgetProc) NULL) { 683444c061aSmrg CALLGEOTAT(_XtGeoTrace(w,"Resize proc is called.\n")); 684444c061aSmrg (*resize)(w); 685444c061aSmrg } 686444c061aSmrg } 687444c061aSmrg } else { 688444c061aSmrg CALLGEOTAT(_XtGeoTrace(w,"No change in configuration\n")); 689444c061aSmrg } 690444c061aSmrg 691444c061aSmrg CALLGEOTAT(_XtGeoTab(-1)); 692444c061aSmrg UNLOCK_APP(app); 693444c061aSmrg} /* XtConfigureWidget */ 694444c061aSmrg 695444c061aSmrgvoid XtMoveWidget( 696444c061aSmrg Widget w, 697444c061aSmrg _XtPosition x, 698444c061aSmrg _XtPosition y) 699444c061aSmrg{ 700444c061aSmrg XtConfigureWidget(w, x, y, w->core.width, w->core.height, 701444c061aSmrg w->core.border_width); 702444c061aSmrg} /* XtMoveWidget */ 703444c061aSmrg 704444c061aSmrgvoid XtTranslateCoords( 705444c061aSmrg register Widget w, 706444c061aSmrg _XtPosition x, 707444c061aSmrg _XtPosition y, 708444c061aSmrg register Position *rootx, /* return */ 709444c061aSmrg register Position *rooty) /* return */ 710444c061aSmrg{ 711444c061aSmrg Position garbagex, garbagey; 712444c061aSmrg XtAppContext app = XtWidgetToApplicationContext(w); 713444c061aSmrg 714444c061aSmrg LOCK_APP(app); 715444c061aSmrg if (rootx == NULL) rootx = &garbagex; 716444c061aSmrg if (rooty == NULL) rooty = &garbagey; 717444c061aSmrg 718444c061aSmrg *rootx = x; 719444c061aSmrg *rooty = y; 720444c061aSmrg 721444c061aSmrg for (; w != NULL && ! XtIsShell(w); w = w->core.parent) { 722444c061aSmrg *rootx += w->core.x + w->core.border_width; 723444c061aSmrg *rooty += w->core.y + w->core.border_width; 724444c061aSmrg } 725444c061aSmrg 726444c061aSmrg if (w == NULL) 727444c061aSmrg XtAppWarningMsg(app, 728444c061aSmrg "invalidShell","xtTranslateCoords",XtCXtToolkitError, 729444c061aSmrg "Widget has no shell ancestor", 730444c061aSmrg (String *)NULL, (Cardinal *)NULL); 731444c061aSmrg else { 732444c061aSmrg Position x, y; 733444c061aSmrg _XtShellGetCoordinates( w, &x, &y ); 734444c061aSmrg *rootx += x + w->core.border_width; 735444c061aSmrg *rooty += y + w->core.border_width; 736444c061aSmrg } 737444c061aSmrg UNLOCK_APP(app); 738444c061aSmrg} 739444c061aSmrg 740444c061aSmrgXtGeometryResult XtQueryGeometry( 741444c061aSmrg Widget widget, 742444c061aSmrg register XtWidgetGeometry *intended, /* parent's changes; may be NULL */ 743444c061aSmrg XtWidgetGeometry *reply) /* child's preferred geometry; never NULL */ 744444c061aSmrg{ 745444c061aSmrg XtWidgetGeometry null_intended; 746444c061aSmrg XtGeometryHandler query; 747444c061aSmrg XtGeometryResult result; 748444c061aSmrg WIDGET_TO_APPCON(widget); 749444c061aSmrg 750444c061aSmrg CALLGEOTAT(_XtGeoTrace(widget, 751444c061aSmrg "\"%s\" is asking its preferred geometry to \"%s\".\n", 752444c061aSmrg (XtParent(widget))?XtName(XtParent(widget)):"Root", 753444c061aSmrg XtName(widget))); 754444c061aSmrg CALLGEOTAT(_XtGeoTab(1)); 755444c061aSmrg 756444c061aSmrg LOCK_APP(app); 757444c061aSmrg LOCK_PROCESS; 758444c061aSmrg query = XtClass(widget)->core_class.query_geometry; 759444c061aSmrg UNLOCK_PROCESS; 760444c061aSmrg reply->request_mode = 0; 761444c061aSmrg if (query != NULL) { 762444c061aSmrg if (intended == NULL) { 763444c061aSmrg null_intended.request_mode = 0; 764444c061aSmrg intended = &null_intended; 765444c061aSmrg#ifdef XT_GEO_TATTLER 766444c061aSmrg CALLGEOTAT(_XtGeoTrace(widget,"without any constraint.\n")); 767444c061aSmrg } else { 768444c061aSmrg CALLGEOTAT(_XtGeoTrace(widget, 769444c061aSmrg "with the following constraints:\n")); 770444c061aSmrg 771444c061aSmrg if (intended->request_mode & CWX) { 772444c061aSmrg CALLGEOTAT(_XtGeoTrace(widget," x = %d\n",intended->x)); 773444c061aSmrg } 774444c061aSmrg if (intended->request_mode & CWY) { 775444c061aSmrg CALLGEOTAT(_XtGeoTrace(widget," y = %d\n",intended->y)); 776444c061aSmrg } 777444c061aSmrg if (intended->request_mode & CWWidth) { 778444c061aSmrg CALLGEOTAT(_XtGeoTrace(widget, 779444c061aSmrg " width = %d\n",intended->width)); 780444c061aSmrg } 781444c061aSmrg if (intended->request_mode & CWHeight) { 782444c061aSmrg CALLGEOTAT(_XtGeoTrace(widget, 783444c061aSmrg " height = %d\n",intended->height)); 784444c061aSmrg } 785444c061aSmrg if (intended->request_mode & CWBorderWidth) { 786444c061aSmrg CALLGEOTAT(_XtGeoTrace(widget, 787444c061aSmrg " border_width = %d\n",intended->border_width)); 788444c061aSmrg } 789444c061aSmrg#endif 790444c061aSmrg } 791444c061aSmrg 792444c061aSmrg result = (*query) (widget, intended, reply); 793444c061aSmrg } 794444c061aSmrg else { 795444c061aSmrg CALLGEOTAT(_XtGeoTrace(widget,"\"%s\" has no QueryGeometry proc, return the current state\n",XtName(widget))); 796444c061aSmrg 797444c061aSmrg result = XtGeometryYes; 798444c061aSmrg } 799444c061aSmrg 800444c061aSmrg#ifdef XT_GEO_TATTLER 801444c061aSmrg#define FillIn(mask, field) \ 802444c061aSmrg if (!(reply->request_mode & mask)) {\ 803444c061aSmrg reply->field = widget->core.field;\ 804444c061aSmrg _XtGeoTrace(widget," using core %s = %d.\n","field",\ 805444c061aSmrg widget->core.field);\ 806444c061aSmrg } else {\ 807444c061aSmrg _XtGeoTrace(widget," replied %s = %d\n","field",\ 808444c061aSmrg reply->field);\ 809444c061aSmrg } 810444c061aSmrg#else 811444c061aSmrg#define FillIn(mask, field) \ 812444c061aSmrg if (!(reply->request_mode & mask)) reply->field = widget->core.field; 813444c061aSmrg#endif 814444c061aSmrg 815444c061aSmrg FillIn(CWX, x); 816444c061aSmrg FillIn(CWY, y); 817444c061aSmrg FillIn(CWWidth, width); 818444c061aSmrg FillIn(CWHeight, height); 819444c061aSmrg FillIn(CWBorderWidth, border_width); 820444c061aSmrg 821444c061aSmrg CALLGEOTAT(_XtGeoTab(-1)); 822444c061aSmrg#undef FillIn 823444c061aSmrg 824444c061aSmrg if (!(reply->request_mode & CWStackMode)) 825444c061aSmrg reply->stack_mode = XtSMDontChange; 826444c061aSmrg UNLOCK_APP(app); 827444c061aSmrg return result; 828444c061aSmrg} 829