From 15879fe51346c8d78ce33c47a6c22755852add70 Mon Sep 17 00:00:00 2001 From: jenglish Date: Fri, 14 Jun 2002 22:25:11 +0000 Subject: TIP #47 "Modifying Tk to Allow Writing X Window managers" (patch from Neil McKay). * Add CirculateRequest, Create, MapRequest, ResizeRequest, and ConfigureRequest event types; * Split TK_TOPLEVEL flag into TK_TOPLEVEL, TK_HAS_WRAPPER, TK_WIN_MANAGED, and TK_TOP_HIERARCHY. --- ChangeLog | 17 +++++++ doc/bind.n | 47 ++++++++++-------- generic/tk.h | 28 +++++++++-- generic/tkBind.c | 105 +++++++++++++++++++++++++++++++++++++--- generic/tkCanvWind.c | 8 ++-- generic/tkCmds.c | 8 ++-- generic/tkEvent.c | 129 ++++++++++++++++++++++++++++++++++++++++++++++---- generic/tkFocus.c | 6 +-- generic/tkGrab.c | 16 +++---- generic/tkGrid.c | 6 +-- generic/tkImage.c | 4 +- generic/tkPack.c | 10 ++-- generic/tkPlace.c | 6 +-- generic/tkPointer.c | 4 +- generic/tkTextWind.c | 10 ++-- generic/tkWindow.c | 34 ++++++------- mac/tkMacSubwindows.c | 12 ++--- mac/tkMacWindowMgr.c | 6 +-- mac/tkMacWm.c | 41 ++++++++++++---- unix/Makefile.in | 13 +++-- unix/tkUnixEmbed.c | 4 +- unix/tkUnixWm.c | 43 +++++++++++++---- win/tkWinScrlbr.c | 4 +- win/tkWinWindow.c | 8 ++-- win/tkWinWm.c | 31 ++++++++---- 25 files changed, 459 insertions(+), 141 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3f078fc..55ad4e7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2002-06-14 Joe English + * doc/bind.n, generic/tk.h, generic/tkBind.c, + generic/tkCanvWind.c, generic/tkCmds.c, generic/tkEvent.c, + generic/tkFocus.c, generic/tkGrab.c, generic/tkGrid.c, + generic/tkImage.c, generic/tkPack.c, generic/tkPlace.c, + generic/tkPointer.c, generic/tkTextWind.c, + generic/tkWindow.c, mac/tkMacSubwindows.c, + mac/tkMacWindowMgr.c, mac/tkMacWm.c, unix/Makefile.in, + unix/tkUnixEmbed.c, unix/tkUnixWm.c, win/tkWinScrlbr.c, + win/tkWinWindow.c, win/tkWinWm.c: Implementation for + TIP #47 "Modifying Tk to Allow Writing X Window managers" + (patch from Neil McKay). + * Add CirculateRequest, Create, MapRequest, ResizeRequest, + and ConfigureRequest event types; + * Split TK_TOPLEVEL flag into TK_TOPLEVEL, TK_HAS_WRAPPER, + TK_WIN_MANAGED, and TK_TOP_HIERARCHY. + 2002-06-14 Andreas Kupries * unix/tkAppInit.c: Removed now unneeded and erroneous reference diff --git a/doc/bind.n b/doc/bind.n index 6417154..991708b 100644 --- a/doc/bind.n +++ b/doc/bind.n @@ -6,7 +6,7 @@ '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" -'\" RCS: @(#) $Id: bind.n,v 1.5 2000/05/23 00:31:36 hobbs Exp $ +'\" RCS: @(#) $Id: bind.n,v 1.6 2002/06/14 22:25:11 jenglish Exp $ '\" .so man.macros .TH bind n 8.0 Tk "Tk Built-In Commands" @@ -162,18 +162,18 @@ few extra abbreviations. The \fItype\fR field will also accept a couple non-standard X event types that were added to better support the Macintosh and Windows platforms. Below is a list of all the valid types; where two names appear together, they are synonyms. -.DS C +.DS .ta 5c 10c -\fBActivate Enter Map -ButtonPress, Button Expose Motion -.VS -ButtonRelease FocusIn MouseWheel -.VE -Circulate FocusOut Property +\fBActivate Destroy Map +ButtonPress, Button Enter MapRequest +ButtonRelease Expose Motion +Circulate FocusIn MouseWheel +CirculateRequest FocusOut Property Colormap Gravity Reparent -Configure KeyPress, Key Unmap -Deactivate KeyRelease Visibility -Destroy Leave\fR +Configure KeyPress, Key ResizeRequest +ConfigureRequest KeyRelease Unmap +Create Leave Visibility +Deactivate\fR .DE .PP .VS @@ -290,6 +290,13 @@ NotifyDetailNone NotifyPointer NotifyInferior NotifyPointerRoot NotifyNonlinear NotifyVirtual\fR .DE +For \fBConfigureRequest\fR events, the string will be one of: +.DS +.ta 6c +\fBAbove Opposite +Below None +BottomIf TopIf\fR +.DE For events other than these, the substituted string is undefined. .RE .IP \fB%f\fR 5 @@ -297,9 +304,13 @@ The \fIfocus\fR field from the event (\fB0\fR or \fB1\fR). Valid only for \fBEnter\fR and \fBLeave\fR events. .IP \fB%h\fR 5 .VS -The \fIheight\fR field from the event. Valid for the \fBConfigure\fR and +The \fIheight\fR field from the event. Valid for the \fBConfigure\fR, +\fBConfigureRequest\fR, \fBCreate\fR, \fBResizeRequest\fR, and \fBExpose\fR events. .VE +.IP \fB%i\fR 5 +The \fIwindow\fR field from the event, represented as a hexadecimal +integer. .IP \fB%k\fR 5 The \fIkeycode\fR field from the event. Valid only for \fBKeyPress\fR and \fBKeyRelease\fR events. @@ -316,7 +327,7 @@ The \fIoverride_redirect\fR field from the event. Valid only for .IP \fB%p\fR 5 The \fIplace\fR field from the event, substituted as one of the strings \fBPlaceOnTop\fR or \fBPlaceOnBottom\fR. Valid only -for \fBCirculate\fR events. +for \fBCirculate\fR and \fBCirculateRequest\fR events. .IP \fB%s\fR 5 The \fIstate\fR field from the event. For \fBButtonPress\fR, \fBButtonRelease\fR, \fBEnter\fR, \fBKeyPress\fR, \fBKeyRelease\fR, @@ -330,7 +341,8 @@ contain a \fItime\fR field. .IP \fB%w\fR 5 The \fIwidth\fR field from the event. Valid only for .VS -\fBConfigure\fR and \fBExpose\fR events. +\fBConfigure\fR, \fBConfigureRequest\fR, \fBCreate\fR, +\fBResizeRequest\fR, and \fBExpose\fR events. .VE .IP \fB%x\fR 5 The \fIx\fR field from the event. Valid only for events containing @@ -346,7 +358,7 @@ work of translating from the event to an ASCII character. Valid only for \fBKeyPress\fR and \fBKeyRelease\fR events. .IP \fB%B\fR 5 The \fIborder_width\fR field from the event. Valid only for -\fBConfigure\fR events. +\fBConfigure\fR, \fBConfigureRequest\fR, and \fBCreate\fR events. .VS .IP \fB%D\fR 5 This reports the \fIdelta\fR value of a \fBMouseWheel\fR event. The @@ -416,7 +428,7 @@ string (open square bracket) as its first argument. If the extra backslash hadn't been added, Tcl would not have been able to parse the script correctly. -.SH MULTIPLE MATCHES +.SH "MULTIPLE MATCHES" .PP It is possible for several bindings to match a given X event. If the bindings are associated with different \fItag\fR's, @@ -436,7 +448,6 @@ associated with other \fItag\fR's. If the \fBbreak\fR command is invoked within a binding script, then that script terminates and no other scripts will be invoked for the event. -.VS .PP If more than one binding matches a particular event and they have the same \fItag\fR, then the most specific binding @@ -450,7 +461,6 @@ of events matched) is more specific than a shorter sequence; (c) if the modifiers specified in one pattern are a subset of the modifiers in another pattern, then the pattern with more modifiers is more specific. -.VS (d) a virtual event whose physical pattern matches the sequence is less specific than the same physical pattern that is not associated with a virtual event. @@ -477,7 +487,6 @@ If the user types Control-y, the \fB<>\fR binding will be invoked, but if the user presses button 2 then one of either the \fB<>\fR or the \fB<>\fR bindings will be invoked, but exactly which one gets invoked is undefined. -.VE .PP If an X event does not match any of the existing bindings, then the event is ignored. diff --git a/generic/tk.h b/generic/tk.h index 81e6e36..babc9bf 100644 --- a/generic/tk.h +++ b/generic/tk.h @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tk.h,v 1.60 2002/06/14 14:07:51 dkf Exp $ + * RCS: @(#) $Id: tk.h,v 1.61 2002/06/14 22:25:11 jenglish Exp $ */ #ifndef _TK @@ -715,6 +715,12 @@ typedef XActivateDeactivateEvent XDeactivateEvent; (((Tk_FakeWin *) (tkwin))->flags & TK_MAPPED) #define Tk_IsTopLevel(tkwin) \ (((Tk_FakeWin *) (tkwin))->flags & TK_TOP_LEVEL) +#define Tk_HasWrapper(tkwin) \ + (((Tk_FakeWin *) (tkwin))->flags & TK_HAS_WRAPPER) +#define Tk_WinManaged(tkwin) \ + (((Tk_FakeWin *) (tkwin))->flags & TK_WIN_MANAGED) +#define Tk_TopWinHierarchy(tkwin) \ + (((Tk_FakeWin *) (tkwin))->flags & TK_TOP_HIERARCHY) #define Tk_ReqWidth(tkwin) (((Tk_FakeWin *) (tkwin))->reqWidth) #define Tk_ReqHeight(tkwin) (((Tk_FakeWin *) (tkwin))->reqHeight) /* Tk_InternalBorderWidth is deprecated */ @@ -792,9 +798,7 @@ typedef struct Tk_FakeWin { * * TK_MAPPED: 1 means window is currently mapped, * 0 means unmapped. - * TK_TOP_LEVEL: 1 means this is a top-level window (it - * was or will be created as a child of - * a root window). + * TK_TOP_LEVEL: 1 means this is a top-level widget. * TK_ALREADY_DEAD: 1 means the window is in the process of * being destroyed already. * TK_NEED_CONFIG_NOTIFY: 1 means that the window has been reconfigured @@ -846,6 +850,18 @@ typedef struct Tk_FakeWin { * special Unix menubar windows. * TK_ANONYMOUS_WINDOW: 1 means that this window has no name, and is * thus not accessible from Tk. + * TK_HAS_WRAPPER 1 means that this window has a wrapper window + * TK_WIN_MANAGED 1 means that this window is a child of the + * root window, and is managed by the window + * manager. + * TK_TOP_HIERARCHY 1 means this window is at the top of a + * physical window hierarchy within this + * process, i.e. the window's parent + * either doesn't exist or is not owned by + * this Tk application. + * TK_PROP_PROPCHANGE 1 means that PropertyNotify events in + * this window's children should propagate + * up to this window. */ @@ -864,6 +880,10 @@ typedef struct Tk_FakeWin { #define TK_WRAPPER 0x1000 #define TK_REPARENTED 0x2000 #define TK_ANONYMOUS_WINDOW 0x4000 +#define TK_HAS_WRAPPER 0x8000 +#define TK_WIN_MANAGED 0x10000 +#define TK_TOP_HIERARCHY 0x20000 +#define TK_PROP_PROPCHANGE 0x40000 /* *-------------------------------------------------------------- diff --git a/generic/tkBind.c b/generic/tkBind.c index fa6a31a..4ca6ca5 100644 --- a/generic/tkBind.c +++ b/generic/tkBind.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkBind.c,v 1.21 2002/01/25 21:09:36 dgp Exp $ + * RCS: @(#) $Id: tkBind.c,v 1.22 2002/06/14 22:25:12 jenglish Exp $ */ #include "tkPort.h" @@ -506,6 +506,11 @@ static EventInfo eventArray[] = { {"Activate", ActivateNotify, ActivateMask}, {"Deactivate", DeactivateNotify, ActivateMask}, {"MouseWheel", MouseWheelEvent, MouseWheelMask}, + {"CirculateRequest", CirculateRequest, SubstructureRedirectMask}, + {"ConfigureRequest", ConfigureRequest, SubstructureRedirectMask}, + {"Create", CreateNotify, SubstructureNotifyMask}, + {"MapRequest", MapRequest, SubstructureRedirectMask}, + {"ResizeRequest", ResizeRequest, ResizeRedirectMask}, {(char *) NULL, 0, 0} }; static Tcl_HashTable eventTable; @@ -537,6 +542,10 @@ static Tcl_HashTable eventTable; #define COLORMAP 0x10000 #define VIRTUAL 0x20000 #define ACTIVATE 0x40000 +#define MAPREQ 0x80000 +#define CONFIGREQ 0x100000 +#define RESIZEREQ 0x200000 +#define CIRCREQ 0x400000 #define KEY_BUTTON_MOTION_VIRTUAL (KEY|BUTTON|MOTION|VIRTUAL) @@ -561,12 +570,12 @@ static int flagArray[TK_LASTEVENT] = { /* DestroyNotify */ DESTROY, /* UnmapNotify */ UNMAP, /* MapNotify */ MAP, - /* MapRequest */ 0, + /* MapRequest */ MAPREQ, /* ReparentNotify */ REPARENT, /* ConfigureNotify */ CONFIG, - /* ConfigureRequest */ 0, + /* ConfigureRequest */ CONFIGREQ, /* GravityNotify */ GRAVITY, - /* ResizeRequest */ 0, + /* ResizeRequest */ RESIZEREQ, /* CirculateNotify */ CIRC, /* CirculateRequest */ 0, /* PropertyNotify */ PROP, @@ -636,6 +645,22 @@ static TkStateMap visNotify[] = { {-1, NULL} }; +static TkStateMap configureRequestDetail[] = { + {None, "None"}, + {Above, "Above"}, + {Below, "Below"}, + {BottomIf, "BottomIf"}, + {TopIf, "TopIf"}, + {Opposite, "Opposite"}, + {-1, NULL} +}; + +static TkStateMap propNotify[] = { + {PropertyNewValue, "NewValue"}, + {PropertyDelete, "Delete"}, + {-1, NULL} +}; + /* * Prototypes for local procedures defined in this file: */ @@ -2032,6 +2057,10 @@ MatchPatterns(dispPtr, bindPtr, psPtr, bestPtr, objectPtr, sourcePtrPtr) } goto nextEvent; } + if (eventPtr->xany.type == CreateNotify + && eventPtr->xcreatewindow.parent != window) { + goto nextSequence; + } else if (eventPtr->xany.window != window) { goto nextSequence; } @@ -2245,6 +2274,7 @@ MatchPatterns(dispPtr, bindPtr, psPtr, bestPtr, objectPtr, sourcePtrPtr) *sourcePtrPtr = bestSourcePtr; return bestPtr; } + /* *-------------------------------------------------------------- @@ -2343,6 +2373,14 @@ ExpandPercents(winPtr, before, eventPtr, keySym, dsPtr) } string = TkFindStateString(notifyDetail, number); } + else if (flags & CONFIGREQ) { + if (eventPtr->xconfigurerequest.value_mask & CWStackMode) { + string = TkFindStateString(configureRequestDetail, + eventPtr->xconfigurerequest.detail); + } else { + string = ""; + } + } goto doString; case 'f': number = eventPtr->xcrossing.focus; @@ -2353,7 +2391,26 @@ ExpandPercents(winPtr, before, eventPtr, keySym, dsPtr) } else if (flags & (CONFIG)) { number = eventPtr->xconfigure.height; } + else if (flags & CREATE) { + number = eventPtr->xcreatewindow.height; + } else if (flags & CONFIGREQ) { + number = eventPtr->xconfigurerequest.height; + } else if (flags & RESIZEREQ) { + number = eventPtr->xresizerequest.height; + } goto doNumber; + case 'i': + if (flags & CREATE) { + TkpPrintWindowId(numStorage, eventPtr->xcreatewindow.window); + } else if (flags & CONFIGREQ) { + TkpPrintWindowId(numStorage, eventPtr->xconfigurerequest.window); + } else if (flags & MAPREQ) { + TkpPrintWindowId(numStorage, eventPtr->xmaprequest.window); + } else { + TkpPrintWindowId(numStorage, eventPtr->xany.window); + } + string = numStorage; + goto doString; case 'k': number = eventPtr->xkey.keycode; goto doNumber; @@ -2377,13 +2434,21 @@ ExpandPercents(winPtr, before, eventPtr, keySym, dsPtr) } goto doNumber; case 'p': - string = TkFindStateString(circPlace, eventPtr->xcirculate.place); + if (flags & CIRC) { + string = TkFindStateString(circPlace, eventPtr->xcirculate.place); + } else if (flags & CIRCREQ) { + string = TkFindStateString(circPlace, eventPtr->xcirculaterequest.place); + } goto doString; case 's': if (flags & (KEY_BUTTON_MOTION_VIRTUAL)) { number = eventPtr->xkey.state; } else if (flags & CROSSING) { number = eventPtr->xcrossing.state; + } else if (flags & PROP) { + string = TkFindStateString(propNotify, + eventPtr->xproperty.state); + goto doString; } else if (flags & VISIBILITY) { string = TkFindStateString(visNotify, eventPtr->xvisibility.state); @@ -2408,6 +2473,13 @@ ExpandPercents(winPtr, before, eventPtr, keySym, dsPtr) } else if (flags & CONFIG) { number = eventPtr->xconfigure.width; } + else if (flags & CREATE) { + number = eventPtr->xcreatewindow.width; + } else if (flags & CONFIGREQ) { + number = eventPtr->xconfigurerequest.width; + } else if (flags & RESIZEREQ) { + number = eventPtr->xresizerequest.width; + } goto doNumber; case 'x': if (flags & (KEY_BUTTON_MOTION_VIRTUAL)) { @@ -2421,6 +2493,11 @@ ExpandPercents(winPtr, before, eventPtr, keySym, dsPtr) } else if (flags & REPARENT) { number = eventPtr->xreparent.x; } + else if (flags & CREATE) { + number = eventPtr->xcreatewindow.x; + } else if (flags & CONFIGREQ) { + number = eventPtr->xconfigurerequest.x; + } goto doNumber; case 'y': if (flags & (KEY_BUTTON_MOTION_VIRTUAL)) { @@ -2435,6 +2512,11 @@ ExpandPercents(winPtr, before, eventPtr, keySym, dsPtr) number = eventPtr->xcrossing.y; } + else if (flags & CREATE) { + number = eventPtr->xcreatewindow.y; + } else if (flags & CONFIGREQ) { + number = eventPtr->xconfigurerequest.y; + } goto doNumber; case 'A': if (flags & KEY) { @@ -2443,7 +2525,13 @@ ExpandPercents(winPtr, before, eventPtr, keySym, dsPtr) } goto doString; case 'B': - number = eventPtr->xcreatewindow.border_width; + if (flags & CREATE) { + number = eventPtr->xcreatewindow.border_width; + } else if (flags & CONFIGREQ) { + number = eventPtr->xconfigurerequest.border_width; + } else { + number = eventPtr->xconfigure.border_width; + } goto doNumber; case 'D': /* @@ -2468,6 +2556,11 @@ ExpandPercents(winPtr, before, eventPtr, keySym, dsPtr) case 'N': number = (int) keySym; goto doNumber; + case 'P': + if (flags & PROP) { + string = Tk_GetAtomName(winPtr, eventPtr->xproperty.atom); + } + goto doString; case 'R': TkpPrintWindowId(numStorage, eventPtr->xkey.root); string = numStorage; diff --git a/generic/tkCanvWind.c b/generic/tkCanvWind.c index ed218b2..65d09bd 100644 --- a/generic/tkCanvWind.c +++ b/generic/tkCanvWind.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkCanvWind.c,v 1.5 2001/07/03 06:03:44 hobbs Exp $ + * RCS: @(#) $Id: tkCanvWind.c,v 1.6 2002/06/14 22:25:12 jenglish Exp $ */ #include @@ -353,7 +353,7 @@ ConfigureWinItem(interp, canvas, itemPtr, objc, objv, flags) /* * Make sure that the canvas is either the parent of the * window associated with the item or a descendant of that - * parent. Also, don't allow a top-level window to be + * parent. Also, don't allow a top-of-hierarchy window to be * managed inside a canvas. */ @@ -363,7 +363,7 @@ ConfigureWinItem(interp, canvas, itemPtr, objc, objv, flags) if (ancestor == parent) { break; } - if (((Tk_FakeWin *) (ancestor))->flags & TK_TOP_LEVEL) { + if (((Tk_FakeWin *) (ancestor))->flags & TK_TOP_HIERARCHY) { badWindow: Tcl_AppendResult(interp, "can't use ", Tk_PathName(winItemPtr->tkwin), @@ -372,7 +372,7 @@ ConfigureWinItem(interp, canvas, itemPtr, objc, objv, flags) return TCL_ERROR; } } - if (((Tk_FakeWin *) (winItemPtr->tkwin))->flags & TK_TOP_LEVEL) { + if (((Tk_FakeWin *) (winItemPtr->tkwin))->flags & TK_TOP_HIERARCHY) { goto badWindow; } if (winItemPtr->tkwin == canvasTkwin) { diff --git a/generic/tkCmds.c b/generic/tkCmds.c index c1b6275..1ef3361 100644 --- a/generic/tkCmds.c +++ b/generic/tkCmds.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkCmds.c,v 1.23 2002/03/20 22:55:16 dgp Exp $ + * RCS: @(#) $Id: tkCmds.c,v 1.24 2002/06/14 22:25:12 jenglish Exp $ */ #include "tkPort.h" @@ -270,7 +270,7 @@ TkBindEventProc(winPtr, eventPtr) objPtr[0] = (ClientData) winPtr->pathName; objPtr[1] = (ClientData) winPtr->classUid; for (topLevPtr = winPtr; - (topLevPtr != NULL) && !(topLevPtr->flags & TK_TOP_LEVEL); + (topLevPtr != NULL) && !(topLevPtr->flags & TK_TOP_HIERARCHY); topLevPtr = topLevPtr->parentPtr) { /* Empty loop body. */ } @@ -337,7 +337,7 @@ Tk_BindtagsObjCmd(clientData, interp, objc, objv) Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewStringObj(winPtr->classUid, -1)); winPtr2 = winPtr; - while ((winPtr2 != NULL) && !(Tk_IsTopLevel(winPtr2))) { + while ((winPtr2 != NULL) && !(Tk_TopWinHierarchy(winPtr2))) { winPtr2 = winPtr2->parentPtr; } if ((winPtr != winPtr2) && (winPtr2 != NULL)) { @@ -1246,7 +1246,7 @@ Tk_WinfoObjCmd(clientData, interp, objc, objv) if ((winPtr == NULL) || !(winPtr->flags & TK_MAPPED)) { break; } - if (winPtr->flags & TK_TOP_LEVEL) { + if (winPtr->flags & TK_TOP_HIERARCHY) { viewable = 1; break; } diff --git a/generic/tkEvent.c b/generic/tkEvent.c index 9ad96d1..4f40873 100644 --- a/generic/tkEvent.c +++ b/generic/tkEvent.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkEvent.c,v 1.9 2002/04/05 08:41:07 hobbs Exp $ + * RCS: @(#) $Id: tkEvent.c,v 1.10 2002/06/14 22:25:12 jenglish Exp $ */ #include "tkPort.h" @@ -519,6 +519,91 @@ TkEventInit _ANSI_ARGS_((void)) /* *-------------------------------------------------------------- * + * TkXErrorHandler -- + * + * TkXErrorHandler is an error handler, to be installed + * via Tk_CreateErrorHandler, that will set a flag if an + * X error occurred. + * + * Results: + * Always returns 0, indicating that the X error was + * handled. + * + * Side effects: + * None. + * + *-------------------------------------------------------------- + */ + +static int +TkXErrorHandler (clientData, errEventPtr) + ClientData clientData; /* Pointer to flag we set */ + XErrorEvent *errEventPtr; /* X error info */ +{ + int *error; + + error = (int *) clientData; + *error = 1; + return 0; +} + +/* + *-------------------------------------------------------------- + * + * ParentXId -- + * + * Returns the parent of the given window, or "None" + * if the window doesn't exist. + * + * Results: + * Returns an X window ID. + * + * Side effects: + * None. + * + *-------------------------------------------------------------- + */ + +static Window +ParentXId(display, w) + Display *display; + Window w; +{ + Tk_ErrorHandler handler; + int gotXError; + Status status; + Window parent; + Window root; + Window *childList; + unsigned int nChildren; + + /* Handle errors ourselves. */ + + gotXError = 0; + handler = Tk_CreateErrorHandler(display, -1, -1, -1, + TkXErrorHandler, (ClientData) (&gotXError)); + + /* Get the parent window. */ + + status = XQueryTree(display, w, &root, &parent, &childList, &nChildren); + + /* Do some cleanup; gotta return "None" if we got an error. */ + + Tk_DeleteErrorHandler(handler); + XSync(display, False); + if (status != 0 && childList != NULL) { + XFree(childList); + } + if (status == 0) { + parent = None; + } + + return parent; +} + +/* + *-------------------------------------------------------------- + * * Tk_HandleEvent -- * * Given an event, invoke all the handlers that have @@ -544,6 +629,7 @@ Tk_HandleEvent(eventPtr) unsigned long mask; InProgress ip; Window handlerWindow; + Window parentXId; TkDisplay *dispPtr; Tcl_Interp *interp = (Tcl_Interp *) NULL; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) @@ -655,18 +741,38 @@ Tk_HandleEvent(eventPtr) } winPtr = (TkWindow *) Tk_IdToWindow(eventPtr->xany.display, handlerWindow); if (winPtr == NULL) { - /* * There isn't a TkWindow structure for this window. * However, if the event is a PropertyNotify event then call * the selection manager (it deals beneath-the-table with - * certain properties). + * certain properties). Also, if the window's parent is a + * Tk window that has the TK_PROP_PROPCHANGE flag set, then + * we must propagate the PropertyNotify event up to the parent. */ - if (eventPtr->type == PropertyNotify) { - TkSelPropProc(eventPtr); + if (eventPtr->type != PropertyNotify) { + return; } - return; + + TkSelPropProc(eventPtr); + + /* Get handlerWindow's parent. */ + + parentXId = ParentXId(eventPtr->xany.display, handlerWindow); + if (parentXId == None) { + return; + } + + winPtr = (TkWindow *) Tk_IdToWindow(eventPtr->xany.display, parentXId); + if (winPtr == NULL) { + return; + } + + if (!(winPtr->flags & TK_PROP_PROPCHANGE)) { + return; + } + + handlerWindow = parentXId; } /* @@ -893,7 +999,14 @@ Tk_HandleEvent(eventPtr) * these events here than in the lower-level procedures. */ - if ((ip.winPtr != None) && (mask != SubstructureNotifyMask)) { + /* + * ...well, except when we use the tkwm patches, in which case + * we DO handle CreateNotify events, so we gotta pass 'em through. + */ + + if ((ip.winPtr != None) + && ((mask != SubstructureNotifyMask) + || (eventPtr->type == CreateNotify))) { TkBindEventProc(winPtr, eventPtr); } } @@ -1172,7 +1285,7 @@ TkQueueEventForAllChildren(winPtr, eventPtr) childPtr = winPtr->childList; while (childPtr != NULL) { - if (!Tk_IsTopLevel(childPtr)) { + if (!Tk_TopWinHierarchy(childPtr)) { TkQueueEventForAllChildren(childPtr, eventPtr); } childPtr = childPtr->nextPtr; diff --git a/generic/tkFocus.c b/generic/tkFocus.c index c50fc3d..b1ba279 100644 --- a/generic/tkFocus.c +++ b/generic/tkFocus.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkFocus.c,v 1.7 2002/04/12 10:03:24 hobbs Exp $ + * RCS: @(#) $Id: tkFocus.c,v 1.8 2002/06/14 22:25:12 jenglish Exp $ */ #include "tkInt.h" @@ -216,7 +216,7 @@ Tk_FocusObjCmd(clientData, interp, objc, objv) } for (topLevelPtr = newPtr; topLevelPtr != NULL; topLevelPtr = topLevelPtr->parentPtr) { - if (topLevelPtr->flags & TK_TOP_LEVEL) { + if (topLevelPtr->flags & TK_TOP_HIERARCHY) { for (tlFocusPtr = newPtr->mainPtr->tlFocusPtr; tlFocusPtr != NULL; tlFocusPtr = tlFocusPtr->nextPtr) { @@ -588,7 +588,7 @@ TkSetFocusWin(winPtr, force) if (!(topLevelPtr->flags & TK_MAPPED)) { allMapped = 0; } - if (topLevelPtr->flags & TK_TOP_LEVEL) { + if (topLevelPtr->flags & TK_TOP_HIERARCHY) { break; } } diff --git a/generic/tkGrab.c b/generic/tkGrab.c index 8c16927..fb32642 100644 --- a/generic/tkGrab.c +++ b/generic/tkGrab.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkGrab.c,v 1.7 2002/01/17 05:13:11 dgp Exp $ + * RCS: @(#) $Id: tkGrab.c,v 1.8 2002/06/14 22:25:12 jenglish Exp $ */ #include "tkPort.h" @@ -742,7 +742,7 @@ TkPointerEvent(eventPtr, winPtr) if (eventPtr->xcrossing.send_event != GENERATED_EVENT_MAGIC) { if ((eventPtr->type == LeaveNotify) && - (winPtr->flags & TK_TOP_LEVEL)) { + (winPtr->flags & TK_TOP_HIERARCHY)) { dispPtr->serverWinPtr = NULL; } else { dispPtr->serverWinPtr = winPtr; @@ -941,7 +941,7 @@ TkChangeEventWindow(eventPtr, winPtr) eventPtr->xmotion.subwindow = None; for (childPtr = winPtr->childList; childPtr != NULL; childPtr = childPtr->nextPtr) { - if (childPtr->flags & TK_TOP_LEVEL) { + if (childPtr->flags & TK_TOP_HIERARCHY) { continue; } x = eventPtr->xmotion.x - childPtr->changes.x; @@ -1226,7 +1226,7 @@ TkGrabDeadWindow(winPtr) ReleaseButtonGrab(dispPtr); } if (dispPtr->serverWinPtr == winPtr) { - if (winPtr->flags & TK_TOP_LEVEL) { + if (winPtr->flags & TK_TOP_HIERARCHY) { dispPtr->serverWinPtr = NULL; } else { dispPtr->serverWinPtr = winPtr->parentPtr; @@ -1451,7 +1451,7 @@ FindCommonAncestor(winPtr1, winPtr2, countPtr1, countPtr2) if (winPtr1 != NULL) { for (winPtr = winPtr1; winPtr != NULL; winPtr = winPtr->parentPtr) { winPtr->flags |= TK_GRAB_FLAG; - if (winPtr->flags & TK_TOP_LEVEL) { + if (winPtr->flags & TK_TOP_HIERARCHY) { break; } } @@ -1471,7 +1471,7 @@ FindCommonAncestor(winPtr1, winPtr2, countPtr1, countPtr2) ancestorPtr = winPtr; break; } - if (winPtr->flags & TK_TOP_LEVEL) { + if (winPtr->flags & TK_TOP_HIERARCHY) { count2++; break; } @@ -1493,7 +1493,7 @@ FindCommonAncestor(winPtr1, winPtr2, countPtr1, countPtr2) if (winPtr == ancestorPtr) { count1 = i; } - if (winPtr->flags & TK_TOP_LEVEL) { + if (winPtr->flags & TK_TOP_HIERARCHY) { if (count1 == -1) { count1 = i+1; } @@ -1543,7 +1543,7 @@ TkPositionInTree(winPtr, treePtr) if (winPtr2 == winPtr) { return TK_GRAB_ANCESTOR; } - if (winPtr2->flags & TK_TOP_LEVEL) { + if (winPtr2->flags & TK_TOP_HIERARCHY) { break; } } diff --git a/generic/tkGrid.c b/generic/tkGrid.c index 3d2fb40..48db44e 100644 --- a/generic/tkGrid.c +++ b/generic/tkGrid.c @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkGrid.c,v 1.20 2002/01/17 05:13:11 dgp Exp $ + * RCS: @(#) $Id: tkGrid.c,v 1.21 2002/06/14 22:25:12 jenglish Exp $ */ #include "tkInt.h" @@ -2642,7 +2642,7 @@ ConfigureSlaves(interp, tkwin, objc, objv) return TCL_ERROR; } - if (Tk_IsTopLevel(slave)) { + if (Tk_TopWinHierarchy(slave)) { Tcl_AppendResult(interp, "can't manage \"", Tcl_GetString(objv[j]), "\": it's a top-level window", (char *) NULL); return TCL_ERROR; @@ -2806,7 +2806,7 @@ ConfigureSlaves(interp, tkwin, objc, objv) if (ancestor == parent) { break; } - if (Tk_IsTopLevel(ancestor)) { + if (Tk_TopWinHierarchy(ancestor)) { Tcl_AppendResult(interp, "can't put ", Tcl_GetString(objv[j]), " inside ", Tk_PathName(masterPtr->tkwin), (char *) NULL); diff --git a/generic/tkImage.c b/generic/tkImage.c index 38275a8..69b1e19 100644 --- a/generic/tkImage.c +++ b/generic/tkImage.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkImage.c,v 1.14 2002/02/03 22:33:07 ericm Exp $ + * RCS: @(#) $Id: tkImage.c,v 1.15 2002/06/14 22:25:12 jenglish Exp $ */ #include "tkInt.h" @@ -1048,7 +1048,7 @@ Tk_SetTSOrigin(tkwin, gc, x, y) GC gc; int x, y; { - while (!Tk_IsTopLevel(tkwin)) { + while (!Tk_TopWinHierarchy(tkwin)) { x -= Tk_X(tkwin) + Tk_Changes(tkwin)->border_width; y -= Tk_Y(tkwin) + Tk_Changes(tkwin)->border_width; tkwin = Tk_Parent(tkwin); diff --git a/generic/tkPack.c b/generic/tkPack.c index 8033b7b..607af25 100644 --- a/generic/tkPack.c +++ b/generic/tkPack.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkPack.c,v 1.15 2002/01/17 05:13:11 dgp Exp $ + * RCS: @(#) $Id: tkPack.c,v 1.16 2002/06/14 22:25:12 jenglish Exp $ */ #include "tkPort.h" @@ -1190,7 +1190,7 @@ PackAfter(interp, prevPtr, masterPtr, objc, objv) if (ancestor == parent) { break; } - if (((Tk_FakeWin *) (ancestor))->flags & TK_TOP_LEVEL) { + if (((Tk_FakeWin *) (ancestor))->flags & TK_TOP_HIERARCHY) { badWindow: Tcl_AppendResult(interp, "can't pack ", Tcl_GetString(objv[0]), " inside ", Tk_PathName(masterPtr->tkwin), @@ -1198,7 +1198,7 @@ PackAfter(interp, prevPtr, masterPtr, objc, objv) return TCL_ERROR; } } - if (((Tk_FakeWin *) (tkwin))->flags & TK_TOP_LEVEL) { + if (((Tk_FakeWin *) (tkwin))->flags & TK_TOP_HIERARCHY) { goto badWindow; } if (tkwin == masterPtr->tkwin) { @@ -1589,7 +1589,7 @@ ConfigureSlaves(interp, tkwin, objc, objv) if (TkGetWindowFromObj(interp, tkwin, objv[j], &slave) != TCL_OK) { return TCL_ERROR; } - if (Tk_IsTopLevel(slave)) { + if (Tk_TopWinHierarchy(slave)) { Tcl_AppendResult(interp, "can't pack \"", Tcl_GetString(objv[j]), "\": it's a top-level window", (char *) NULL); return TCL_ERROR; @@ -1795,7 +1795,7 @@ ConfigureSlaves(interp, tkwin, objc, objv) if (ancestor == parent) { break; } - if (Tk_IsTopLevel(ancestor)) { + if (Tk_TopWinHierarchy(ancestor)) { Tcl_AppendResult(interp, "can't pack ", Tcl_GetString(objv[j]), " inside ", Tk_PathName(masterPtr->tkwin), (char *) NULL); diff --git a/generic/tkPlace.c b/generic/tkPlace.c index 4913b40..9d5e7f5 100644 --- a/generic/tkPlace.c +++ b/generic/tkPlace.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkPlace.c,v 1.11 2002/01/17 05:13:11 dgp Exp $ + * RCS: @(#) $Id: tkPlace.c,v 1.12 2002/06/14 22:25:12 jenglish Exp $ */ #include "tkPort.h" @@ -593,7 +593,7 @@ ConfigureSlave(interp, tkwin, table, objc, objv) int result = TCL_OK; Slave *slavePtr; - if (Tk_IsTopLevel(tkwin)) { + if (Tk_TopWinHierarchy(tkwin)) { Tcl_AppendResult(interp, "can't use placer on top-level window \"", Tk_PathName(tkwin), "\"; use wm command instead", (char *) NULL); @@ -626,7 +626,7 @@ ConfigureSlave(interp, tkwin, table, objc, objv) if (ancestor == Tk_Parent(slavePtr->tkwin)) { break; } - if (Tk_IsTopLevel(ancestor)) { + if (Tk_TopWinHierarchy(ancestor)) { Tcl_AppendResult(interp, "can't place ", Tk_PathName(slavePtr->tkwin), " relative to ", Tk_PathName(tkwin), (char *) NULL); diff --git a/generic/tkPointer.c b/generic/tkPointer.c index c1a971b..0e4edf4 100644 --- a/generic/tkPointer.c +++ b/generic/tkPointer.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkPointer.c,v 1.5 2001/11/23 02:07:02 das Exp $ + * RCS: @(#) $Id: tkPointer.c,v 1.6 2002/06/14 22:25:12 jenglish Exp $ */ #include "tkInt.h" @@ -562,7 +562,7 @@ UpdateCursor(winPtr) if (winPtr->atts.cursor != None) { cursor = winPtr->atts.cursor; break; - } else if (winPtr->flags & TK_TOP_LEVEL) { + } else if (winPtr->flags & TK_TOP_HIERARCHY) { break; } winPtr = winPtr->parentPtr; diff --git a/generic/tkTextWind.c b/generic/tkTextWind.c index c43b8e8..6466f68 100644 --- a/generic/tkTextWind.c +++ b/generic/tkTextWind.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkTextWind.c,v 1.4 1999/12/14 06:52:33 hobbs Exp $ + * RCS: @(#) $Id: tkTextWind.c,v 1.5 2002/06/14 22:25:12 jenglish Exp $ */ #include "tk.h" @@ -370,7 +370,7 @@ EmbWinConfigure(textPtr, ewPtr, argc, argv) if (ancestor == parent) { break; } - if (Tk_IsTopLevel(ancestor)) { + if (Tk_TopWinHierarchy(ancestor)) { badMaster: Tcl_AppendResult(textPtr->interp, "can't embed ", Tk_PathName(ewPtr->body.ew.tkwin), " in ", @@ -379,7 +379,7 @@ EmbWinConfigure(textPtr, ewPtr, argc, argv) return TCL_ERROR; } } - if (Tk_IsTopLevel(ewPtr->body.ew.tkwin) + if (Tk_TopWinHierarchy(ewPtr->body.ew.tkwin) || (ewPtr->body.ew.tkwin == textPtr->tkwin)) { goto badMaster; } @@ -790,7 +790,7 @@ EmbWinLayoutProc(textPtr, indexPtr, ewPtr, offset, maxX, maxChars, if (ancestor == Tk_Parent(ewPtr->body.ew.tkwin)) { break; } - if (Tk_IsTopLevel(ancestor)) { + if (Tk_TopWinHierarchy(ancestor)) { badMaster: Tcl_AppendResult(textPtr->interp, "can't embed ", Tk_PathName(ewPtr->body.ew.tkwin), " relative to ", @@ -800,7 +800,7 @@ EmbWinLayoutProc(textPtr, indexPtr, ewPtr, offset, maxX, maxChars, goto gotWindow; } } - if (Tk_IsTopLevel(ewPtr->body.ew.tkwin) + if (Tk_TopWinHierarchy(ewPtr->body.ew.tkwin) || (textPtr->tkwin == ewPtr->body.ew.tkwin)) { goto badMaster; } diff --git a/generic/tkWindow.c b/generic/tkWindow.c index aa07b2d..5c1fd17 100644 --- a/generic/tkWindow.c +++ b/generic/tkWindow.c @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWindow.c,v 1.45 2002/04/12 10:20:27 hobbs Exp $ + * RCS: @(#) $Id: tkWindow.c,v 1.46 2002/06/14 22:25:12 jenglish Exp $ */ #include "tkPort.h" @@ -364,12 +364,12 @@ CreateTopLevelWindow(interp, parent, name, screenName, flags) winPtr->dirtyAtts |= CWBorderPixel; /* - * (Need to set the TK_TOP_LEVEL flag immediately here; otherwise + * (Need to set the TK_TOP_HIERARCHY flag immediately here; otherwise * Tk_DestroyWindow will core dump if it is called before the flag * has been set.) */ - winPtr->flags |= TK_TOP_LEVEL; + winPtr->flags |= TK_TOP_HIERARCHY|TK_TOP_LEVEL|TK_HAS_WRAPPER|TK_WIN_MANAGED; if (parent != NULL) { if (NameWindow(interp, winPtr, (TkWindow *) parent, name) != TCL_OK) { @@ -1347,7 +1347,7 @@ Tk_DestroyWindow(tkwin) * Cleanup the data structures associated with this window. */ - if (winPtr->flags & TK_TOP_LEVEL) { + if (winPtr->flags & TK_WIN_MANAGED) { TkWmDeadWindow(winPtr); } else if (winPtr->flags & TK_WM_COLORMAP_WINDOW) { TkWmRemoveFromColormapWindows(winPtr); @@ -1356,7 +1356,7 @@ Tk_DestroyWindow(tkwin) #if defined(MAC_TCL) || defined(__WIN32__) XDestroyWindow(winPtr->display, winPtr->window); #else - if ((winPtr->flags & TK_TOP_LEVEL) + if ((winPtr->flags & TK_TOP_HIERARCHY) || !(winPtr->flags & TK_DONT_DESTROY_WINDOW)) { /* * The parent has already been destroyed and this isn't @@ -1538,7 +1538,7 @@ Tk_MapWindow(tkwin) if (winPtr->window == None) { Tk_MakeWindowExist(tkwin); } - if (winPtr->flags & TK_TOP_LEVEL) { + if (winPtr->flags & TK_WIN_MANAGED) { /* * Lots of special processing has to be done for top-level * windows. Let tkWm.c handle everything itself. @@ -1595,7 +1595,7 @@ Tk_MakeWindowExist(tkwin) return; } - if ((winPtr->parentPtr == NULL) || (winPtr->flags & TK_TOP_LEVEL)) { + if ((winPtr->parentPtr == NULL) || (winPtr->flags & TK_TOP_HIERARCHY)) { parent = XRootWindow(winPtr->display, winPtr->screenNum); } else { if (winPtr->parentPtr->window == None) { @@ -1617,7 +1617,7 @@ Tk_MakeWindowExist(tkwin) winPtr->dirtyAtts = 0; winPtr->dirtyChanges = 0; - if (!(winPtr->flags & TK_TOP_LEVEL)) { + if (!(winPtr->flags & TK_TOP_HIERARCHY)) { /* * If any siblings higher up in the stacking order have already * been created then move this window to its rightful position @@ -1632,7 +1632,7 @@ Tk_MakeWindowExist(tkwin) for (winPtr2 = winPtr->nextPtr; winPtr2 != NULL; winPtr2 = winPtr2->nextPtr) { if ((winPtr2->window != None) - && !(winPtr2->flags & (TK_TOP_LEVEL|TK_REPARENTED))) { + && !(winPtr2->flags & (TK_TOP_HIERARCHY|TK_REPARENTED))) { XWindowChanges changes; changes.sibling = winPtr2->window; changes.stack_mode = Below; @@ -1698,7 +1698,7 @@ Tk_UnmapWindow(tkwin) if (!(winPtr->flags & TK_MAPPED) || (winPtr->flags & TK_ALREADY_DEAD)) { return; } - if (winPtr->flags & TK_TOP_LEVEL) { + if (winPtr->flags & TK_WIN_MANAGED) { /* * Special processing has to be done for top-level windows. Let * tkWm.c handle everything itself. @@ -1709,7 +1709,7 @@ Tk_UnmapWindow(tkwin) } winPtr->flags &= ~TK_MAPPED; XUnmapWindow(winPtr->display, winPtr->window); - if (!(winPtr->flags & TK_TOP_LEVEL)) { + if (!(winPtr->flags & TK_TOP_HIERARCHY)) { XEvent event; event.type = UnmapNotify; @@ -2018,7 +2018,7 @@ Tk_SetWindowColormap(tkwin, colormap) if (winPtr->window != None) { XSetWindowColormap(winPtr->display, winPtr->window, colormap); - if (!(winPtr->flags & TK_TOP_LEVEL)) { + if (!(winPtr->flags & TK_WIN_MANAGED)) { TkWmAddToColormapWindows(winPtr); winPtr->flags |= TK_WM_COLORMAP_WINDOW; } @@ -2147,7 +2147,7 @@ Tk_SetClass(tkwin, className) register TkWindow *winPtr = (TkWindow *) tkwin; winPtr->classUid = Tk_GetUid(className); - if (winPtr->flags & TK_TOP_LEVEL) { + if (winPtr->flags & TK_WIN_MANAGED) { TkWmSetClass(winPtr); } TkOptionClassChanged(winPtr); @@ -2383,8 +2383,8 @@ Tk_RestackWindow(tkwin, aboveBelow, other) * otherPtr without changing any of Tk's childLists. */ - if (winPtr->flags & TK_TOP_LEVEL) { - while ((otherPtr != NULL) && !(otherPtr->flags & TK_TOP_LEVEL)) { + if (winPtr->flags & TK_WIN_MANAGED) { + while ((otherPtr != NULL) && !(otherPtr->flags & TK_TOP_HIERARCHY)) { otherPtr = otherPtr->parentPtr; } TkWmRestackToplevel(winPtr, aboveBelow, otherPtr); @@ -2410,7 +2410,7 @@ Tk_RestackWindow(tkwin, aboveBelow, other) } } else { while (winPtr->parentPtr != otherPtr->parentPtr) { - if ((otherPtr == NULL) || (otherPtr->flags & TK_TOP_LEVEL)) { + if ((otherPtr == NULL) || (otherPtr->flags & TK_TOP_HIERARCHY)) { return TCL_ERROR; } otherPtr = otherPtr->parentPtr; @@ -2462,7 +2462,7 @@ Tk_RestackWindow(tkwin, aboveBelow, other) for (otherPtr = winPtr->nextPtr; otherPtr != NULL; otherPtr = otherPtr->nextPtr) { if ((otherPtr->window != None) - && !(otherPtr->flags & (TK_TOP_LEVEL|TK_REPARENTED))){ + && !(otherPtr->flags & (TK_TOP_HIERARCHY|TK_REPARENTED))){ changes.sibling = otherPtr->window; changes.stack_mode = Below; mask = CWStackMode|CWSibling; diff --git a/mac/tkMacSubwindows.c b/mac/tkMacSubwindows.c index 23942f9..a60e901 100644 --- a/mac/tkMacSubwindows.c +++ b/mac/tkMacSubwindows.c @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacSubwindows.c,v 1.6 2000/02/10 08:56:24 jingham Exp $ + * RCS: @(#) $Id: tkMacSubwindows.c,v 1.7 2002/06/14 22:25:12 jenglish Exp $ */ #include "tkInt.h" @@ -724,14 +724,14 @@ TkMacUpdateClipRgn( * This is not currently enforced, however. */ - if (!Tk_IsTopLevel(winPtr)) { + if (!Tk_TopWinHierarchy(winPtr)) { TkMacUpdateClipRgn(winPtr->parentPtr); SectRgn(rgn, winPtr->parentPtr->privatePtr->aboveClipRgn, rgn); win2Ptr = winPtr->nextPtr; while (win2Ptr != NULL) { - if (Tk_IsTopLevel(win2Ptr) || !Tk_IsMapped(win2Ptr)) { + if (Tk_TopWinHierarchy(win2Ptr) || !Tk_IsMapped(win2Ptr)) { win2Ptr = win2Ptr->nextPtr; continue; } @@ -776,7 +776,7 @@ TkMacUpdateClipRgn( win2Ptr = winPtr->childList; while (win2Ptr != NULL) { - if (Tk_IsTopLevel(win2Ptr) || !Tk_IsMapped(win2Ptr)) { + if (Tk_TopWinHierarchy(win2Ptr) || !Tk_IsMapped(win2Ptr)) { win2Ptr = win2Ptr->nextPtr; continue; } @@ -1000,7 +1000,7 @@ TkMacInvalClipRgns( */ childPtr = winPtr->childList; while (childPtr != NULL) { - if (!Tk_IsTopLevel(childPtr) && Tk_IsMapped(childPtr)) { + if (!Tk_TopWinHierarchy(childPtr) && Tk_IsMapped(childPtr)) { TkMacInvalClipRgns(childPtr); } childPtr = childPtr->nextPtr; @@ -1133,7 +1133,7 @@ UpdateOffsets( childPtr = winPtr->childList; while (childPtr != NULL) { - if (!Tk_IsTopLevel(childPtr)) { + if (!Tk_TopWinHierarchy(childPtr)) { UpdateOffsets(childPtr, deltaX, deltaY); } childPtr = childPtr->nextPtr; diff --git a/mac/tkMacWindowMgr.c b/mac/tkMacWindowMgr.c index 894a7d0..abe0c35 100644 --- a/mac/tkMacWindowMgr.c +++ b/mac/tkMacWindowMgr.c @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacWindowMgr.c,v 1.9 2001/11/23 02:06:32 das Exp $ + * RCS: @(#) $Id: tkMacWindowMgr.c,v 1.10 2002/06/14 22:25:12 jenglish Exp $ */ #include @@ -426,7 +426,7 @@ GenerateUpdates( for (childPtr = winPtr->childList; childPtr != NULL; childPtr = childPtr->nextPtr) { - if (!Tk_IsMapped(childPtr) || Tk_IsTopLevel(childPtr)) { + if (!Tk_IsMapped(childPtr) || Tk_TopWinHierarchy(childPtr)) { continue; } @@ -1546,7 +1546,7 @@ void TkpSetCapture( TkWindow *winPtr) /* Capture window, or NULL. */ { - while ((winPtr != NULL) && !Tk_IsTopLevel(winPtr)) { + while ((winPtr != NULL) && !Tk_TopWinHierarchy(winPtr)) { winPtr = winPtr->parentPtr; } gGrabWinPtr = (Tk_Window) winPtr; diff --git a/mac/tkMacWm.c b/mac/tkMacWm.c index ae2cfc5..18170be 100644 --- a/mac/tkMacWm.c +++ b/mac/tkMacWm.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacWm.c,v 1.17 2002/05/24 09:50:11 mdejong Exp $ + * RCS: @(#) $Id: tkMacWm.c,v 1.18 2002/06/14 22:25:12 jenglish Exp $ */ #include @@ -1870,10 +1870,13 @@ Tk_SetGrid( * information. */ - while (!(winPtr->flags & TK_TOP_LEVEL)) { + while (!(winPtr->flags & TK_TOP_HIERARCHY)) { winPtr = winPtr->parentPtr; } wmPtr = winPtr->wmInfoPtr; + if (wmPtr == NULL) { + return; + } if ((wmPtr->gridWin != NULL) && (wmPtr->gridWin != tkwin)) { return; @@ -1955,10 +1958,14 @@ Tk_UnsetGrid( * information. */ - while (!(winPtr->flags & TK_TOP_LEVEL)) { + while (!(winPtr->flags & TK_TOP_HIERARCHY)) { winPtr = winPtr->parentPtr; } wmPtr = winPtr->wmInfoPtr; + if (wmPtr == NULL) { + return; + } + if (tkwin != wmPtr->gridWin) { return; } @@ -2511,7 +2518,7 @@ Tk_GetRootCoords( while (1) { x += winPtr->changes.x + winPtr->changes.border_width; y += winPtr->changes.y + winPtr->changes.border_width; - if (winPtr->flags & TK_TOP_LEVEL) { + if (winPtr->flags & TK_TOP_HIERARCHY) { if (!(Tk_IsEmbedded(winPtr))) { x += winPtr->wmInfoPtr->xInParent; y += winPtr->wmInfoPtr->yInParent; @@ -2561,6 +2568,9 @@ Tk_GetRootCoords( } } } + if (winPtr->flags & TK_TOP_HIERARCHY) { + break; /* Punt */ + } winPtr = winPtr->parentPtr; } *xPtr = x; @@ -2668,7 +2678,7 @@ Tk_CoordsToWindow( for (childPtr = winPtr->childList; childPtr != NULL; childPtr = childPtr->nextPtr) { if (!Tk_IsMapped(childPtr) || - (childPtr->flags & TK_TOP_LEVEL)) { + (childPtr->flags & TK_TOP_HIERARCHY)) { continue; } tmpx = x - childPtr->changes.x; @@ -2762,7 +2772,7 @@ Tk_TopCoordsToWindow( for (childPtr = winPtr->childList; childPtr != NULL; childPtr = childPtr->nextPtr) { if (!Tk_IsMapped(childPtr) || - (childPtr->flags & TK_TOP_LEVEL)) { + (childPtr->flags & TK_TOP_HIERARCHY)) { continue; } if (x < childPtr->changes.x || y < childPtr->changes.y) { @@ -2895,10 +2905,13 @@ Tk_GetVRootGeometry( * information for that window. */ - while (!(winPtr->flags & TK_TOP_LEVEL)) { + while (!(winPtr->flags & TK_TOP_HIERARCHY)) { winPtr = winPtr->parentPtr; } wmPtr = winPtr->wmInfoPtr; + if (wmPtr == NULL) { + return; /* Punt */ + } /* * Make sure that the geometry information is up-to-date, then copy @@ -3322,10 +3335,14 @@ TkWmAddToColormapWindows( return; } - if (topPtr->flags & TK_TOP_LEVEL) { + if (topPtr->flags & TK_TOP_HIERARCHY) { break; } } + if (topPtr->wmInfoPtr == NULL) { + return; + } + if (topPtr->wmInfoPtr->flags & WM_COLORMAPS_EXPLICIT) { return; } @@ -3412,7 +3429,7 @@ TkWmRemoveFromColormapWindows( return; } - if (topPtr->flags & TK_TOP_LEVEL) { + if (topPtr->flags & TK_TOP_HIERARCHY) { break; } } @@ -3430,6 +3447,10 @@ TkWmRemoveFromColormapWindows( * it up. */ + if (topPtr->wmInfoPtr == NULL) { + return; + } + count = topPtr->wmInfoPtr->cmapCount; oldPtr = topPtr->wmInfoPtr->cmapList; for (i = 0; i < count; i++) { @@ -4648,7 +4669,7 @@ TkWmFocusToplevel( TkWindow *winPtr) /* Window that received a focus-related * event. */ { - if (!(winPtr->flags & TK_TOP_LEVEL)) { + if (!(winPtr->flags & TK_TOP_HIERARCHY)) { return NULL; } return winPtr; diff --git a/unix/Makefile.in b/unix/Makefile.in index f203023..cb3cdd8 100644 --- a/unix/Makefile.in +++ b/unix/Makefile.in @@ -5,7 +5,7 @@ # "autoconf" program (constructs like "@foo@" will get replaced in the # actual Makefile. # -# RCS: @(#) $Id: Makefile.in,v 1.65 2002/03/06 18:54:16 davygrvy Exp $ +# RCS: @(#) $Id: Makefile.in,v 1.66 2002/06/14 22:25:12 jenglish Exp $ # Current Tk version; used in various names. @@ -138,6 +138,12 @@ PROTO_FLAGS = MEM_DEBUG_FLAGS = #MEM_DEBUG_FLAGS = -DTCL_MEM_DEBUG +# To disable window-manager enablers, reverse the comment characters +# on the following two lines. + +WM_ENABLER_FLAGS = -DWM_ENABLERS +#WM_ENABLER_FLAGS = + # If your X server is X11R4 or earlier, then you may wish to reverse # the comment characters on the following two lines. This will enable # extra code to speed up XStringToKeysym. In X11R5 and later releases @@ -248,7 +254,8 @@ CC_SWITCHES_NO_STUBS = ${CFLAGS} ${CFLAGS_WARNING} ${SHLIB_CFLAGS} \ -I${UNIX_DIR} -I${GENERIC_DIR} \ -I${BMAP_DIR} -I${TCL_GENERIC_DIR} ${X11_INCLUDES} \ ${AC_FLAGS} ${PROTO_FLAGS} \ -${SECURITY_FLAGS} ${MEM_DEBUG_FLAGS} ${KEYSYM_FLAGS} ${NO_DEPRECATED_FLAGS} +${SECURITY_FLAGS} ${MEM_DEBUG_FLAGS} ${KEYSYM_FLAGS} ${NO_DEPRECATED_FLAGS} \ +${WM_ENABLER_FLAGS} CC_SWITCHES = ${CC_SWITCHES_NO_STUBS} ${TCL_STUB_FLAGS} @@ -256,7 +263,7 @@ DEPEND_SWITCHES = ${CFLAGS} -I${UNIX_DIR} -I${GENERIC_DIR} \ -I${BMAP_DIR} \ -I${TCL_GENERIC_DIR} ${X11_INCLUDES} \ ${AC_FLAGS} ${PROTO_FLAGS} ${SECURITY_FLAGS} ${MEM_DEBUG_FLAGS} \ -${KEYSYM_FLAGS} +${WM_ENABLER_FLAGS} ${KEYSYM_FLAGS} WISH_OBJS = tkAppInit.o diff --git a/unix/tkUnixEmbed.c b/unix/tkUnixEmbed.c index 5a64713..6020fc3 100644 --- a/unix/tkUnixEmbed.c +++ b/unix/tkUnixEmbed.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkUnixEmbed.c,v 1.4 2002/05/27 17:33:26 mdejong Exp $ + * RCS: @(#) $Id: tkUnixEmbed.c,v 1.5 2002/06/14 22:25:12 jenglish Exp $ */ #include "tkInt.h" @@ -780,7 +780,7 @@ TkpRedirectKeyEvent(winPtr, eventPtr) return; } - if (winPtr->flags & TK_TOP_LEVEL) { + if (winPtr->flags & TK_TOP_HIERARCHY) { break; } winPtr = winPtr->parentPtr; diff --git a/unix/tkUnixWm.c b/unix/tkUnixWm.c index 8ab742b..ad0b662 100644 --- a/unix/tkUnixWm.c +++ b/unix/tkUnixWm.c @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkUnixWm.c,v 1.21 2002/06/12 19:02:49 mdejong Exp $ + * RCS: @(#) $Id: tkUnixWm.c,v 1.22 2002/06/14 22:25:12 jenglish Exp $ */ #include "tkPort.h" @@ -1299,7 +1299,7 @@ Tk_WmCmd(clientData, interp, argc, argv) if (tkwin2 == NULL) { return TCL_ERROR; } - while (!Tk_IsTopLevel(tkwin2)) { + while (!Tk_TopWinHierarchy(tkwin2)) { /* * Ensure that the group leader is actually a Tk toplevel. */ @@ -2050,7 +2050,7 @@ Tk_WmCmd(clientData, interp, argc, argv) if (masterPtr == NULL) { return TCL_ERROR; } - while (!Tk_IsTopLevel(masterPtr)) { + while (!Tk_TopWinHierarchy(masterPtr)) { /* * Ensure that the master window is actually a Tk toplevel. */ @@ -2226,7 +2226,7 @@ Tk_SetGrid(tkwin, reqWidth, reqHeight, widthInc, heightInc) * information. */ - while (!(winPtr->flags & TK_TOP_LEVEL)) { + while (!(winPtr->flags & TK_TOP_HIERARCHY)) { winPtr = winPtr->parentPtr; if (winPtr == NULL) { /* @@ -2237,6 +2237,9 @@ Tk_SetGrid(tkwin, reqWidth, reqHeight, widthInc, heightInc) } } wmPtr = winPtr->wmInfoPtr; + if(wmPtr == NULL) { + return; + } if ((wmPtr->gridWin != NULL) && (wmPtr->gridWin != tkwin)) { return; @@ -2318,7 +2321,7 @@ Tk_UnsetGrid(tkwin) * information. */ - while (!(winPtr->flags & TK_TOP_LEVEL)) { + while (!(winPtr->flags & TK_TOP_HIERARCHY)) { winPtr = winPtr->parentPtr; if (winPtr == NULL) { /* @@ -2329,6 +2332,10 @@ Tk_UnsetGrid(tkwin) } } wmPtr = winPtr->wmInfoPtr; + if(wmPtr == NULL) { + return; + } + if (tkwin != wmPtr->gridWin) { return; } @@ -3936,7 +3943,7 @@ Tk_CoordsToWindow(rootX, rootY, tkwin) nextPtr = NULL; for (childPtr = winPtr->childList; childPtr != NULL; childPtr = childPtr->nextPtr) { - if (!Tk_IsMapped(childPtr) || (childPtr->flags & TK_TOP_LEVEL)) { + if (!Tk_IsMapped(childPtr) || (childPtr->flags & TK_TOP_HIERARCHY)) { continue; } if (childPtr->flags & TK_REPARENTED) { @@ -4086,10 +4093,18 @@ Tk_GetVRootGeometry(tkwin, xPtr, yPtr, widthPtr, heightPtr) * information for that window. */ - while (!(winPtr->flags & TK_TOP_LEVEL) && (winPtr->parentPtr != NULL)) { + while (!(winPtr->flags & TK_TOP_HIERARCHY) && (winPtr->parentPtr != NULL)) { winPtr = winPtr->parentPtr; } wmPtr = winPtr->wmInfoPtr; + if(wmPtr == NULL) { + /* Punt. */ + *xPtr = 0; + *yPtr = 0; + *widthPtr = 0; + *heightPtr = 0; + } + /* * Make sure that the geometry information is up-to-date, then copy @@ -4676,10 +4691,14 @@ TkWmAddToColormapWindows(winPtr) return; } - if (topPtr->flags & TK_TOP_LEVEL) { + if (topPtr->flags & TK_TOP_HIERARCHY) { break; } } + if(topPtr->wmInfoPtr == NULL) { + return; + } + if (topPtr->wmInfoPtr->flags & WM_COLORMAPS_EXPLICIT) { return; } @@ -4776,7 +4795,7 @@ TkWmRemoveFromColormapWindows(winPtr) return; } - if (topPtr->flags & TK_TOP_LEVEL) { + if (topPtr->flags & TK_TOP_HIERARCHY) { break; } } @@ -4788,6 +4807,10 @@ TkWmRemoveFromColormapWindows(winPtr) return; } + if (topPtr->wmInfoPtr == NULL) { + return; + } + if (topPtr->wmInfoPtr->wrapperPtr == NULL) { CreateWrapper(topPtr->wmInfoPtr); } @@ -4963,7 +4986,7 @@ TkpMakeMenuWindow(tkwin, transient) XSetWindowAttributes atts; TkWindow *wrapperPtr; - if (!Tk_IsTopLevel(tkwin)) { + if (!Tk_HasWrapper(tkwin)) { return; } wmPtr = ((TkWindow *) tkwin)->wmInfoPtr; diff --git a/win/tkWinScrlbr.c b/win/tkWinScrlbr.c index 70fae0e..1eb3b47 100644 --- a/win/tkWinScrlbr.c +++ b/win/tkWinScrlbr.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWinScrlbr.c,v 1.7 2000/11/22 01:49:38 ericm Exp $ + * RCS: @(#) $Id: tkWinScrlbr.c,v 1.8 2002/06/14 22:25:12 jenglish Exp $ */ #include "tkWinInt.h" @@ -242,7 +242,7 @@ CreateProc(tkwin, parentWin, instanceData) for (winPtr = ((TkWindow*)tkwin)->nextPtr; winPtr != NULL; winPtr = winPtr->nextPtr) { - if ((winPtr->window != None) && !(winPtr->flags & TK_TOP_LEVEL)) { + if ((winPtr->window != None) && !(winPtr->flags & TK_TOP_HIERARCHY)) { TkWinSetWindowPos(scrollPtr->hwnd, Tk_GetHWND(winPtr->window), Below); break; diff --git a/win/tkWinWindow.c b/win/tkWinWindow.c index 175f54b..da871c7 100644 --- a/win/tkWinWindow.c +++ b/win/tkWinWindow.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWinWindow.c,v 1.9 2001/10/01 21:22:35 hobbs Exp $ + * RCS: @(#) $Id: tkWinWindow.c,v 1.10 2002/06/14 22:25:12 jenglish Exp $ */ #include "tkWinInt.h" @@ -371,13 +371,13 @@ XMapWindow(display, w) * its mapped children have just become visible. */ - if (!(winPtr->flags & TK_TOP_LEVEL)) { + if (!(winPtr->flags & TK_TOP_HIERARCHY)) { for (parentPtr = winPtr->parentPtr; ; parentPtr = parentPtr->parentPtr) { if ((parentPtr == NULL) || !(parentPtr->flags & TK_MAPPED)) { return; } - if (parentPtr->flags & TK_TOP_LEVEL) { + if (parentPtr->flags & TK_TOP_HIERARCHY) { break; } } @@ -478,7 +478,7 @@ XUnmapWindow(display, w) ShowWindow(Tk_GetHWND(w), SW_HIDE); winPtr->flags &= ~TK_MAPPED; - if (winPtr->flags & TK_TOP_LEVEL) { + if (winPtr->flags & TK_WIN_MANAGED) { event.type = UnmapNotify; event.xunmap.serial = display->request; event.xunmap.send_event = False; diff --git a/win/tkWinWm.c b/win/tkWinWm.c index 1fd42a8..46390da 100644 --- a/win/tkWinWm.c +++ b/win/tkWinWm.c @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWinWm.c,v 1.39 2002/06/12 19:02:50 mdejong Exp $ + * RCS: @(#) $Id: tkWinWm.c,v 1.40 2002/06/14 22:25:12 jenglish Exp $ */ #include "tkWinInt.h" @@ -3308,7 +3308,7 @@ Tk_WmCmd(clientData, interp, argc, argv) if (masterPtr == NULL) { return TCL_ERROR; } - while (!(masterPtr->flags & TK_TOP_LEVEL)) { + while (!(masterPtr->flags & TK_TOP_HIERARCHY)) { /* * Ensure that the master window is actually a Tk toplevel. */ @@ -3476,10 +3476,13 @@ Tk_SetGrid(tkwin, reqWidth, reqHeight, widthInc, heightInc) * information. */ - while (!(winPtr->flags & TK_TOP_LEVEL)) { + while (!(winPtr->flags & TK_TOP_HIERARCHY)) { winPtr = winPtr->parentPtr; } wmPtr = winPtr->wmInfoPtr; + if (wmPtr == NULL) { + return; + } if ((wmPtr->gridWin != NULL) && (wmPtr->gridWin != tkwin)) { return; @@ -3560,10 +3563,14 @@ Tk_UnsetGrid(tkwin) * information. */ - while (!(winPtr->flags & TK_TOP_LEVEL)) { + while (!(winPtr->flags & TK_TOP_HIERARCHY)) { winPtr = winPtr->parentPtr; } wmPtr = winPtr->wmInfoPtr; + if (wmPtr == NULL) { + return; + } + if (tkwin != wmPtr->gridWin) { return; } @@ -4592,10 +4599,14 @@ TkWmAddToColormapWindows(winPtr) return; } - if (topPtr->flags & TK_TOP_LEVEL) { + if (topPtr->flags & TK_TOP_HIERARCHY) { break; } } + if (topPtr->wmInfoPtr == NULL) { + return; + } + if (topPtr->wmInfoPtr->flags & WM_COLORMAPS_EXPLICIT) { return; } @@ -4699,6 +4710,10 @@ TkWmRemoveFromColormapWindows(winPtr) return; } + if (topPtr->wmInfoPtr == NULL) { + return; + } + /* * Find the window and slide the following ones down to cover * it up. @@ -5201,7 +5216,7 @@ InvalidateSubTree(winPtr, colormap) * toplevel window. */ - if (!Tk_IsTopLevel(childPtr) && Tk_IsMapped(childPtr)) { + if (!Tk_TopWinHierarchy(childPtr) && Tk_IsMapped(childPtr)) { InvalidateSubTree(childPtr, colormap); } } @@ -5679,7 +5694,7 @@ TkWmFocusToplevel(winPtr) TkWindow *winPtr; /* Window that received a focus-related * event. */ { - if (!(winPtr->flags & TK_TOP_LEVEL)) { + if (!(winPtr->flags & TK_TOP_HIERARCHY)) { return NULL; } return winPtr; @@ -5709,7 +5724,7 @@ TkpGetWrapperWindow( TkWindow *winPtr) /* Window that received a focus-related * event. */ { - if (!(winPtr->flags & TK_TOP_LEVEL)) { + if (!(winPtr->flags & TK_TOP_HIERARCHY)) { return NULL; } return winPtr; -- cgit v0.12