diff options
author | donal.k.fellows@manchester.ac.uk <dkf> | 2008-04-27 22:38:54 (GMT) |
---|---|---|
committer | donal.k.fellows@manchester.ac.uk <dkf> | 2008-04-27 22:38:54 (GMT) |
commit | 5eebe7e9f7313b33c8d813348f2e13f47b0e25a5 (patch) | |
tree | 681f7c2354a3726da3ab7da646d316c1275f540d /generic/tkFocus.c | |
parent | 9f60d790c709497bf8881a503d03164907d1cecf (diff) | |
download | tk-5eebe7e9f7313b33c8d813348f2e13f47b0e25a5.zip tk-5eebe7e9f7313b33c8d813348f2e13f47b0e25a5.tar.gz tk-5eebe7e9f7313b33c8d813348f2e13f47b0e25a5.tar.bz2 |
Get rid of pre-C89-isms (esp. CONST vs const).
Diffstat (limited to 'generic/tkFocus.c')
-rw-r--r-- | generic/tkFocus.c | 125 |
1 files changed, 72 insertions, 53 deletions
diff --git a/generic/tkFocus.c b/generic/tkFocus.c index e524c16..980a8e0 100644 --- a/generic/tkFocus.c +++ b/generic/tkFocus.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: tkFocus.c,v 1.16 2007/12/13 15:24:14 dgp Exp $ + * RCS: @(#) $Id: tkFocus.c,v 1.17 2008/04/27 22:38:56 dkf Exp $ */ #include "tkInt.h" @@ -118,13 +118,13 @@ Tk_FocusObjCmd( ClientData clientData, /* Main window associated with interpreter. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ - Tcl_Obj *CONST objv[]) /* Argument objects. */ + Tcl_Obj *const objv[]) /* Argument objects. */ { - static CONST char *focusOptions[] = { + static const char *focusOptions[] = { "-displayof", "-force", "-lastfor", NULL }; - Tk_Window tkwin = (Tk_Window) clientData; - TkWindow *winPtr = (TkWindow *) clientData; + Tk_Window tkwin = clientData; + TkWindow *winPtr = clientData; TkWindow *newPtr, *focusWinPtr, *topLevelPtr; ToplevelFocusInfo *tlFocusPtr; char *windowName; @@ -216,7 +216,7 @@ Tk_FocusObjCmd( return TCL_ERROR; } for (topLevelPtr = newPtr; topLevelPtr != NULL; - topLevelPtr = topLevelPtr->parentPtr) { + topLevelPtr = topLevelPtr->parentPtr) { if (!(topLevelPtr->flags & TK_TOP_HIERARCHY)) { continue; } @@ -393,7 +393,7 @@ TkFocusFilterEvent( * tree, then ignore the event. */ - if (TkGrabState(winPtr) == TK_GRAB_EXCLUDED) { + if (TkGrabState(winPtr) == TK_GRAB_EXCLUDED) { return retValue; } @@ -500,14 +500,14 @@ TkFocusFilterEvent( } else if (eventPtr->type == LeaveNotify) { /* * If the pointer just left a window for which we automatically - * claimed the focus on enter, move the focus back to the root - * window, where it was before we claimed it above. Note: + * claimed the focus on enter, move the focus back to the root window, + * where it was before we claimed it above. Note: * dispPtr->implicitWinPtr may not be the same as - * displayFocusPtr->focusWinPtr (e.g. because the "focus" command - * was used to redirect the focus after it arrived at - * dispPtr->implicitWinPtr)!! In addition, we generate events - * because the window manager won't give us a FocusOut event when - * we focus on the root. + * displayFocusPtr->focusWinPtr (e.g. because the "focus" command was + * used to redirect the focus after it arrived at + * dispPtr->implicitWinPtr)!! In addition, we generate events because + * the window manager won't give us a FocusOut event when we focus on + * the root. */ if ((dispPtr->implicitWinPtr != NULL) @@ -573,7 +573,7 @@ TkSetFocusWin( */ allMapped = 1; - for (topLevelPtr = winPtr; ; topLevelPtr = topLevelPtr->parentPtr) { + for (topLevelPtr = winPtr; ; topLevelPtr = topLevelPtr->parentPtr) { if (topLevelPtr == NULL) { /* * The window is being deleted. No point in worrying about giving @@ -599,16 +599,14 @@ TkSetFocusWin( */ if (displayFocusPtr->focusOnMapPtr != NULL) { - Tk_DeleteEventHandler( - (Tk_Window) displayFocusPtr->focusOnMapPtr, + Tk_DeleteEventHandler((Tk_Window) displayFocusPtr->focusOnMapPtr, StructureNotifyMask, FocusMapProc, - (ClientData) displayFocusPtr->focusOnMapPtr); + displayFocusPtr->focusOnMapPtr); displayFocusPtr->focusOnMapPtr = NULL; } if (!allMapped) { - Tk_CreateEventHandler((Tk_Window) winPtr, - VisibilityChangeMask, FocusMapProc, - (ClientData) winPtr); + Tk_CreateEventHandler((Tk_Window) winPtr, VisibilityChangeMask, + FocusMapProc, winPtr); displayFocusPtr->focusOnMapPtr = winPtr; displayFocusPtr->forceFocus = force; return; @@ -943,7 +941,7 @@ FocusMapProc( ClientData clientData, /* Toplevel window. */ XEvent *eventPtr) /* Information about event. */ { - TkWindow *winPtr = (TkWindow *) clientData; + TkWindow *winPtr = clientData; DisplayFocusInfo *displayFocusPtr; if (eventPtr->type == VisibilityNotify) { @@ -1048,8 +1046,8 @@ TkFocusFree( * * TkFocusSplit -- * - * Adjust focus window for a newly managed toplevel, thus splitting - * the toplevel into two toplevels. + * Adjust focus window for a newly managed toplevel, thus splitting the + * toplevel into two toplevels. * * Results: * None. @@ -1062,29 +1060,29 @@ TkFocusFree( void TkFocusSplit(winPtr) - TkWindow *winPtr; /* Window is the new toplevel - * Any focus point at or below window - * must be moved to this new toplevel */ + TkWindow *winPtr; /* Window is the new toplevel. Any focus point + * at or below window must be moved to this + * new toplevel. */ { ToplevelFocusInfo *tlFocusPtr; DisplayFocusInfo *displayFocusPtr; - TkWindow *topLevelPtr; - TkWindow *subWinPtr; + TkWindow *topLevelPtr, *subWinPtr; displayFocusPtr = FindDisplayFocusInfo(winPtr->mainPtr, winPtr->dispPtr); /* - * Find the top-level window for winPtr, then find (or create) - * a record for the top-level. Also see whether winPtr and all its - * ancestors are mapped. + * Find the top-level window for winPtr, then find (or create) a record + * for the top-level. Also see whether winPtr and all its ancestors are + * mapped. */ - for (topLevelPtr = winPtr; ; topLevelPtr = topLevelPtr->parentPtr) { + for (topLevelPtr = winPtr; ; topLevelPtr = topLevelPtr->parentPtr) { if (topLevelPtr == NULL) { /* - * The window is being deleted. No point in worrying about - * giving it the focus. + * The window is being deleted. No point in worrying about giving + * it the focus. */ + return; } if (topLevelPtr->flags & TK_TOP_HIERARCHY) { @@ -1092,37 +1090,58 @@ TkFocusSplit(winPtr) } } - /* Search all focus records to find child windows of winPtr */ + /* + * Search all focus records to find child windows of winPtr. + */ + for (tlFocusPtr = winPtr->mainPtr->tlFocusPtr; tlFocusPtr != NULL; - tlFocusPtr = tlFocusPtr->nextPtr) { + tlFocusPtr = tlFocusPtr->nextPtr) { if (tlFocusPtr->topLevelPtr == topLevelPtr) { break; } } if (tlFocusPtr == NULL) { - /* No focus record for this toplevel, nothing to do. */ + /* + * No focus record for this toplevel, nothing to do. + */ + return; } - /* See if current focusWin is child of the new toplevel */ + /* + * See if current focusWin is child of the new toplevel. + */ + for (subWinPtr = tlFocusPtr->focusWinPtr; - subWinPtr && subWinPtr != winPtr && subWinPtr != topLevelPtr; - subWinPtr = subWinPtr->parentPtr) {} + subWinPtr && subWinPtr != winPtr && subWinPtr != topLevelPtr; + subWinPtr = subWinPtr->parentPtr) { + /* EMPTY */ + } if (subWinPtr == winPtr) { - /* Move focus to new toplevel */ - ToplevelFocusInfo *newTlFocusPtr; + /* + * Move focus to new toplevel. + */ + + ToplevelFocusInfo *newTlFocusPtr = (ToplevelFocusInfo *) + ckalloc(sizeof(ToplevelFocusInfo)); - newTlFocusPtr = (ToplevelFocusInfo *) ckalloc(sizeof(ToplevelFocusInfo)); newTlFocusPtr->topLevelPtr = winPtr; newTlFocusPtr->focusWinPtr = tlFocusPtr->focusWinPtr; newTlFocusPtr->nextPtr = winPtr->mainPtr->tlFocusPtr; winPtr->mainPtr->tlFocusPtr = newTlFocusPtr; - /* Move old toplevel's focus to the toplevel itself */ + + /* + * Move old toplevel's focus to the toplevel itself. + */ + tlFocusPtr->focusWinPtr = topLevelPtr; } - /* If it's not, then let focus progress naturally */ + + /* + * If it's not, then let focus progress naturally. + */ } /* @@ -1142,25 +1161,25 @@ TkFocusSplit(winPtr) */ void -TkFocusJoin(winPtr) - TkWindow *winPtr; /* Window is no longer a toplevel */ +TkFocusJoin( + TkWindow *winPtr) /* Window is no longer a toplevel. */ { - ToplevelFocusInfo *tlFocusPtr; - ToplevelFocusInfo *tmpPtr; + ToplevelFocusInfo *tlFocusPtr, *tmpPtr; /* * Remove old toplevel record */ + if (winPtr && winPtr->mainPtr && winPtr->mainPtr->tlFocusPtr - && winPtr->mainPtr->tlFocusPtr->topLevelPtr == winPtr) { + && winPtr->mainPtr->tlFocusPtr->topLevelPtr == winPtr) { tmpPtr = winPtr->mainPtr->tlFocusPtr; winPtr->mainPtr->tlFocusPtr = tmpPtr->nextPtr; ckfree((char *)tmpPtr); } else { for (tlFocusPtr = winPtr->mainPtr->tlFocusPtr; tlFocusPtr != NULL; - tlFocusPtr = tlFocusPtr->nextPtr) { + tlFocusPtr = tlFocusPtr->nextPtr) { if (tlFocusPtr->nextPtr && - tlFocusPtr->nextPtr->topLevelPtr == winPtr) { + tlFocusPtr->nextPtr->topLevelPtr == winPtr) { tmpPtr = tlFocusPtr->nextPtr; tlFocusPtr->nextPtr = tmpPtr->nextPtr; ckfree((char *)tmpPtr); |