summaryrefslogtreecommitdiffstats
path: root/generic
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
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')
-rw-r--r--generic/tkFocus.c129
-rw-r--r--generic/tkFrame.c34
-rw-r--r--generic/tkInt.h5
3 files changed, 163 insertions, 5 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
diff --git a/generic/tkFrame.c b/generic/tkFrame.c
index 0ea4111..7343b6a 100644
--- a/generic/tkFrame.c
+++ b/generic/tkFrame.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: tkFrame.c,v 1.29 2007/09/07 00:34:52 dgp Exp $
+ * RCS: @(#) $Id: tkFrame.c,v 1.30 2007/10/15 20:52:47 hobbs Exp $
*/
#include "default.h"
@@ -943,10 +943,11 @@ ConfigureFrame(
* A few of the options require additional processing.
*/
- if (((oldMenuName == NULL) && (framePtr->menuName != NULL))
+ if ((((oldMenuName == NULL) && (framePtr->menuName != NULL))
|| ((oldMenuName != NULL) && (framePtr->menuName == NULL))
|| ((oldMenuName != NULL) && (framePtr->menuName != NULL)
- && strcmp(oldMenuName, framePtr->menuName) != 0)) {
+ && strcmp(oldMenuName, framePtr->menuName) != 0))
+ && framePtr->type == TYPE_TOPLEVEL) {
TkSetWindowMenuBar(interp, framePtr->tkwin, oldMenuName,
framePtr->menuName);
}
@@ -1910,6 +1911,33 @@ FrameLostSlaveProc(
FrameWorldChanged((ClientData) framePtr);
}
+void
+TkMapTopFrame (tkwin)
+ Tk_Window tkwin;
+{
+ Frame *framePtr = ((TkWindow*)tkwin)->instanceData;
+ Tk_OptionTable optionTable;
+ if (Tk_IsTopLevel(tkwin) && framePtr->type == TYPE_FRAME) {
+ framePtr->type = TYPE_TOPLEVEL;
+ Tcl_DoWhenIdle(MapFrame, (ClientData)framePtr);
+ if (framePtr->menuName != NULL) {
+ TkSetWindowMenuBar(framePtr->interp, framePtr->tkwin, NULL,
+ framePtr->menuName);
+ }
+ } else if (!Tk_IsTopLevel(tkwin) && framePtr->type == TYPE_TOPLEVEL) {
+ framePtr->type = TYPE_FRAME;
+ } else {
+ /* Not a frame or toplevel, skip it */
+ return;
+ }
+ /*
+ * The option table has already been created so
+ * the cached pointer will be returned.
+ */
+ optionTable = Tk_CreateOptionTable(framePtr->interp, optionSpecs[framePtr->type]);
+ framePtr->optionTable = optionTable;
+}
+
/*
*--------------------------------------------------------------
*
diff --git a/generic/tkInt.h b/generic/tkInt.h
index da5b746..752c5eb 100644
--- a/generic/tkInt.h
+++ b/generic/tkInt.h
@@ -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: tkInt.h,v 1.79 2007/10/15 07:24:48 das Exp $
+ * RCS: $Id: tkInt.h,v 1.80 2007/10/15 20:52:47 hobbs Exp $
*/
#ifndef _TKINT
@@ -1180,6 +1180,7 @@ MODULE_SCOPE int TkTileParseProc(ClientData clientData,
MODULE_SCOPE char * TkTilePrintProc(ClientData clientData, Tk_Window tkwin,
char *widgRec, int offset,
Tcl_FreeProc **freeProcPtr);
+MODULE_SCOPE void TkMapTopFrame(Tk_Window tkwin);
MODULE_SCOPE XEvent * TkpGetBindingXEvent(Tcl_Interp *interp);
MODULE_SCOPE void TkCreateExitHandler(Tcl_ExitProc *proc,
ClientData clientData);
@@ -1196,6 +1197,8 @@ MODULE_SCOPE void TkPrintPadAmount(Tcl_Interp *interp,
MODULE_SCOPE int TkParsePadAmount(Tcl_Interp *interp,
Tk_Window tkwin, Tcl_Obj *objPtr,
int *pad1Ptr, int *pad2Ptr);
+MODULE_SCOPE void TkFocusSplit(TkWindow *winPtr);
+MODULE_SCOPE void TkFocusJoin(TkWindow *winPtr);
MODULE_SCOPE int TkpAlwaysShowSelection(Tk_Window tkwin);
MODULE_SCOPE void TkpDrawCharsInContext(Display * display,
Drawable drawable, GC gc, Tk_Font tkfont,