summaryrefslogtreecommitdiffstats
path: root/generic/tkFocus.c
diff options
context:
space:
mode:
authorhobbs <hobbs>2007-10-15 20:52:46 (GMT)
committerhobbs <hobbs>2007-10-15 20:52:46 (GMT)
commitadaeb1b2d2e9f439ab072349dedd7bd0f414394d (patch)
tree0b6519680e9c83fec3e54dacfb130e98d65f0296 /generic/tkFocus.c
parent410da9d556a7306f0b2bea77db33c15a7375c315 (diff)
downloadtk-adaeb1b2d2e9f439ab072349dedd7bd0f414394d.zip
tk-adaeb1b2d2e9f439ab072349dedd7bd0f414394d.tar.gz
tk-adaeb1b2d2e9f439ab072349dedd7bd0f414394d.tar.bz2
* generic/tkFocus.c, generic/tkFrame.c, generic/tkInt.h:
* macosx/tkMacOSXButton.c, macosx/tkMacOSXMenubutton.c: * macosx/tkMacOSXWm.c, unix/tkUnixWm.c, win/tkWinWm.c: * doc/wm.n, tests/wm.test: TIP #125 implementation [Bug 998125] Adds [wm manage|forget] for dockable frames. Finished X11 and Windows code, needs OS X completion.
Diffstat (limited to 'generic/tkFocus.c')
-rw-r--r--generic/tkFocus.c129
1 files changed, 128 insertions, 1 deletions
diff --git a/generic/tkFocus.c b/generic/tkFocus.c
index 4b929c5..37d3795 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.14 2007/09/07 00:34:52 dgp Exp $
+ * RCS: @(#) $Id: tkFocus.c,v 1.15 2007/10/15 20:52:47 hobbs Exp $
*/
#include "tkInt.h"
@@ -1044,6 +1044,133 @@ TkFocusFree(
}
/*
+ *----------------------------------------------------------------------
+ *
+ * TkFocusSplit --
+ *
+ * Adjust focus window for a newly managed toplevel, thus splitting
+ * the toplevel into two toplevels.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * A new record is allocated for the new toplevel window.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void
+TkFocusSplit(winPtr)
+ 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;
+
+ 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.
+ */
+
+ for (topLevelPtr = winPtr; ; topLevelPtr = topLevelPtr->parentPtr) {
+ if (topLevelPtr == NULL) {
+ /*
+ * The window is being deleted. No point in worrying about
+ * giving it the focus.
+ */
+ return;
+ }
+ if (topLevelPtr->flags & TK_TOP_HIERARCHY) {
+ break;
+ }
+ }
+
+ /* Search all focus records to find child windows of winPtr */
+ for (tlFocusPtr = winPtr->mainPtr->tlFocusPtr; tlFocusPtr != NULL;
+ tlFocusPtr = tlFocusPtr->nextPtr) {
+ if (tlFocusPtr->topLevelPtr == topLevelPtr) {
+ break;
+ }
+ }
+
+ if (tlFocusPtr == NULL) {
+ /* No focus record for this toplevel, nothing to do. */
+ return;
+ }
+
+ /* See if current focusWin is child of the new toplevel */
+ for (subWinPtr = tlFocusPtr->focusWinPtr;
+ subWinPtr && subWinPtr != winPtr && subWinPtr != topLevelPtr;
+ subWinPtr = subWinPtr->parentPtr) {}
+
+ if (subWinPtr == winPtr) {
+ /* Move focus to new toplevel */
+ ToplevelFocusInfo *newTlFocusPtr;
+
+ 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 */
+ tlFocusPtr->focusWinPtr = topLevelPtr;
+ }
+ /* If it's not, then let focus progress naturally */
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TkFocusJoin --
+ *
+ * Remove the focus record for this window that is nolonger managed
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * A tlFocusPtr record is removed
+ *
+ *----------------------------------------------------------------------
+ */
+
+void
+TkFocusJoin(winPtr)
+ TkWindow *winPtr; /* Window is no longer a toplevel */
+{
+ ToplevelFocusInfo *tlFocusPtr;
+ ToplevelFocusInfo *tmpPtr;
+
+ /*
+ * Remove old toplevel record
+ */
+ if (winPtr && winPtr->mainPtr && winPtr->mainPtr->tlFocusPtr
+ && 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) {
+ if (tlFocusPtr->nextPtr &&
+ tlFocusPtr->nextPtr->topLevelPtr == winPtr) {
+ tmpPtr = tlFocusPtr->nextPtr;
+ tlFocusPtr->nextPtr = tmpPtr->nextPtr;
+ ckfree((char *)tmpPtr);
+ break;
+ }
+ }
+ }
+}
+
+/*
* Local Variables:
* mode: c
* c-basic-offset: 4