summaryrefslogtreecommitdiffstats
path: root/macosx
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 /macosx
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 'macosx')
-rw-r--r--macosx/tkMacOSXButton.c14
-rw-r--r--macosx/tkMacOSXMenubutton.c10
-rw-r--r--macosx/tkMacOSXWm.c197
3 files changed, 202 insertions, 19 deletions
diff --git a/macosx/tkMacOSXButton.c b/macosx/tkMacOSXButton.c
index 8f05738..6d89667 100644
--- a/macosx/tkMacOSXButton.c
+++ b/macosx/tkMacOSXButton.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: tkMacOSXButton.c,v 1.28 2007/10/12 03:06:37 das Exp $
+ * RCS: @(#) $Id: tkMacOSXButton.c,v 1.29 2007/10/15 20:52:47 hobbs Exp $
*/
#include "tkMacOSXPrivate.h"
@@ -863,6 +863,7 @@ TkMacOSXDrawControl(
TkButton *butPtr = (TkButton *) mbPtr;
TkWindow *winPtr;
Rect paneRect, cntrRect;
+ int rebuild;
winPtr = (TkWindow *) butPtr->tkwin;
@@ -888,12 +889,17 @@ TkMacOSXDrawControl(
* The control has been previously initialised.
* It may need to be re-initialised
*/
-
+#ifdef TK_REBUILD_TOPLEVEL
+ rebuild = (winPtr->flags & TK_REBUILD_TOPLEVEL);
+ winPtr->flags &= ~TK_REBUILD_TOPLEVEL;
+#else
+ rebuild = 0;
+#endif
if (mbPtr->flags) {
MacControlParams params;
TkMacOSXComputeControlParams(butPtr, &params);
- if (bcmp(&params, &mbPtr->params, sizeof(params))) {
+ if (rebuild || bcmp(&params, &mbPtr->params, sizeof(params))) {
/*
* The type of control has changed.
* Clean it up and clear the flag.
@@ -931,7 +937,7 @@ TkMacOSXDrawControl(
len = 0;
controlTitle[0] = 0;
}
- if (bcmp(mbPtr->controlTitle, controlTitle, len+1)) {
+ if (rebuild || bcmp(mbPtr->controlTitle, controlTitle, len+1)) {
CFStringRef cf = CFStringCreateWithCString(NULL,
(char*) controlTitle, kCFStringEncodingUTF8);
diff --git a/macosx/tkMacOSXMenubutton.c b/macosx/tkMacOSXMenubutton.c
index beb8e71..fb18b2e 100644
--- a/macosx/tkMacOSXMenubutton.c
+++ b/macosx/tkMacOSXMenubutton.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: tkMacOSXMenubutton.c,v 1.15 2007/06/29 03:20:02 das Exp $
+ * RCS: @(#) $Id: tkMacOSXMenubutton.c,v 1.16 2007/10/15 20:52:47 hobbs Exp $
*/
#include "tkMacOSXPrivate.h"
@@ -193,8 +193,12 @@ TkpDisplayMenuButton(
if (mbPtr->userPane) {
MenuButtonControlParams params;
bzero(&params, sizeof(params));
- ComputeMenuButtonControlParams(butPtr, &params );
- if (bcmp(&params,&mbPtr->params,sizeof(params))) {
+ ComputeMenuButtonControlParams(butPtr, &params);
+ if (
+#ifdef TK_REBUILD_TOPLEVEL
+ (winPtr->flags & TK_REBUILD_TOPLEVEL) ||
+#endif
+ bcmp(&params,&mbPtr->params,sizeof(params))) {
if (mbPtr->userPane) {
DisposeControl(mbPtr->userPane);
mbPtr->userPane = NULL;
diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c
index c51509c..5166b17 100644
--- a/macosx/tkMacOSXWm.c
+++ b/macosx/tkMacOSXWm.c
@@ -13,7 +13,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMacOSXWm.c,v 1.57 2007/10/12 03:14:48 das Exp $
+ * RCS: @(#) $Id: tkMacOSXWm.c,v 1.58 2007/10/15 20:52:47 hobbs Exp $
*/
#include "tkMacOSXPrivate.h"
@@ -113,6 +113,8 @@ static int WmDeiconifyCmd(Tk_Window tkwin, TkWindow *winPtr,
Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]);
static int WmFocusmodelCmd(Tk_Window tkwin, TkWindow *winPtr,
Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]);
+static int WmForgetCmd(Tk_Window tkwin, TkWindow *winPtr,
+ Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]);
static int WmFrameCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp,
int objc, Tcl_Obj *const objv[]);
static int WmGeometryCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp,
@@ -135,6 +137,8 @@ static int WmIconpositionCmd(Tk_Window tkwin, TkWindow *winPtr,
Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]);
static int WmIconwindowCmd(Tk_Window tkwin, TkWindow *winPtr,
Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]);
+static int WmManageCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp,
+ int objc, Tcl_Obj *const objv[]);
static int WmMaxsizeCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp,
int objc, Tcl_Obj *const objv[]);
static int WmMinsizeCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp,
@@ -168,6 +172,7 @@ static void ApplyWindowClassAttributeChanges(TkWindow *winPtr,
static void ApplyMasterOverrideChanges(TkWindow *winPtr, WindowRef macWindow);
static void GetMinSize(TkWindow *winPtr, int *minWidthPtr, int *minHeightPtr);
static void GetMaxSize(TkWindow *winPtr, int *maxWidthPtr, int *maxHeightPtr);
+static void RemapWindows(TkWindow *winPtr, MacDrawable *parentWin);
/*
@@ -514,21 +519,21 @@ Tk_WmObjCmd(
Tk_Window tkwin = (Tk_Window) clientData;
static const char *optionStrings[] = {
"aspect", "attributes", "client", "colormapwindows",
- "command", "deiconify", "focusmodel", "frame",
- "geometry", "grid", "group", "iconbitmap",
- "iconify", "iconmask", "iconname",
- "iconphoto", "iconposition",
- "iconwindow", "maxsize", "minsize", "overrideredirect",
+ "command", "deiconify", "focusmodel", "forget",
+ "frame", "geometry", "grid", "group",
+ "iconbitmap", "iconify", "iconmask", "iconname",
+ "iconphoto", "iconposition", "iconwindow",
+ "manage", "maxsize", "minsize", "overrideredirect",
"positionfrom", "protocol", "resizable", "sizefrom",
"stackorder", "state", "title", "transient",
"withdraw", NULL };
enum options {
WMOPT_ASPECT, WMOPT_ATTRIBUTES, WMOPT_CLIENT, WMOPT_COLORMAPWINDOWS,
- WMOPT_COMMAND, WMOPT_DEICONIFY, WMOPT_FOCUSMODEL, WMOPT_FRAME,
- WMOPT_GEOMETRY, WMOPT_GRID, WMOPT_GROUP, WMOPT_ICONBITMAP,
- WMOPT_ICONIFY, WMOPT_ICONMASK, WMOPT_ICONNAME,
- WMOPT_ICONPHOTO, WMOPT_ICONPOSITION,
- WMOPT_ICONWINDOW, WMOPT_MAXSIZE, WMOPT_MINSIZE, WMOPT_OVERRIDEREDIRECT,
+ WMOPT_COMMAND, WMOPT_DEICONIFY, WMOPT_FOCUSMODEL, WMOPT_FORGET,
+ WMOPT_FRAME, WMOPT_GEOMETRY, WMOPT_GRID, WMOPT_GROUP,
+ WMOPT_ICONBITMAP, WMOPT_ICONIFY, WMOPT_ICONMASK, WMOPT_ICONNAME,
+ WMOPT_ICONPHOTO, WMOPT_ICONPOSITION, WMOPT_ICONWINDOW,
+ WMOPT_MANAGE, WMOPT_MAXSIZE, WMOPT_MINSIZE, WMOPT_OVERRIDEREDIRECT,
WMOPT_POSITIONFROM, WMOPT_PROTOCOL, WMOPT_RESIZABLE, WMOPT_SIZEFROM,
WMOPT_STACKORDER, WMOPT_STATE, WMOPT_TITLE, WMOPT_TRANSIENT,
WMOPT_WITHDRAW };
@@ -569,7 +574,8 @@ wrongNumArgs:
!= TCL_OK) {
return TCL_ERROR;
}
- if (!Tk_IsTopLevel(winPtr)) {
+ if (!Tk_IsTopLevel(winPtr) &&
+ (index != WMOPT_MANAGE) && (index != WMOPT_FORGET)) {
Tcl_AppendResult(interp, "window \"", winPtr->pathName,
"\" isn't a top-level window", NULL);
return TCL_ERROR;
@@ -590,6 +596,8 @@ wrongNumArgs:
return WmDeiconifyCmd(tkwin, winPtr, interp, objc, objv);
case WMOPT_FOCUSMODEL:
return WmFocusmodelCmd(tkwin, winPtr, interp, objc, objv);
+ case WMOPT_FORGET:
+ return WmForgetCmd(tkwin, winPtr, interp, objc, objv);
case WMOPT_FRAME:
return WmFrameCmd(tkwin, winPtr, interp, objc, objv);
case WMOPT_GEOMETRY:
@@ -612,6 +620,8 @@ wrongNumArgs:
return WmIconpositionCmd(tkwin, winPtr, interp, objc, objv);
case WMOPT_ICONWINDOW:
return WmIconwindowCmd(tkwin, winPtr, interp, objc, objv);
+ case WMOPT_MANAGE:
+ return WmManageCmd(tkwin, winPtr, interp, objc, objv);
case WMOPT_MAXSIZE:
return WmMaxsizeCmd(tkwin, winPtr, interp, objc, objv);
case WMOPT_MINSIZE:
@@ -1345,6 +1355,67 @@ WmFocusmodelCmd(
/*
*----------------------------------------------------------------------
*
+ * WmForgetCmd --
+ *
+ * This procedure is invoked to process the "wm forget" Tcl command.
+ * See the user documentation for details on what it does.
+ *
+ * Results:
+ * A standard Tcl result.
+ *
+ * Side effects:
+ * See the user documentation.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+WmForgetCmd(tkwin, winPtr, interp, objc, objv)
+ Tk_Window tkwin; /* Main window of the application. */
+ TkWindow *winPtr; /* Toplevel or Frame to work with */
+ Tcl_Interp *interp; /* Current interpreter. */
+ int objc; /* Number of arguments. */
+ Tcl_Obj *CONST objv[]; /* Argument objects. */
+{
+ register Tk_Window frameWin = (Tk_Window)winPtr;
+ char *oldClass = (char*)Tk_Class(frameWin);
+
+#if 1
+ Tcl_AppendResult(interp, "wm forget is not yet supported", (char*)NULL);
+ return TCL_ERROR;
+#else
+ if (Tk_IsTopLevel(frameWin)) {
+ MacDrawable *macWin = (MacDrawable *) winPtr->window;
+ CGrafPtr destPort = TkMacOSXGetDrawablePort(winPtr->window);
+
+ TkFocusJoin(winPtr);
+ Tk_UnmapWindow(frameWin);
+
+ if (destPort != NULL) {
+ WindowRef winRef;
+ winRef = GetWindowFromPort(destPort);
+ TkMacOSXUnregisterMacWindow(winRef);
+ DisposeWindow(winRef);
+ }
+ macWin->grafPtr = NULL;
+ macWin->toplevel = winPtr->parentPtr->privatePtr->toplevel;
+ macWin->flags &= ~TK_HOST_EXISTS;
+
+ RemapWindows(winPtr, macWin);
+ TkWmDeadWindow(winPtr);
+ winPtr->flags &= ~(TK_TOP_HIERARCHY|TK_TOP_LEVEL|TK_HAS_WRAPPER|TK_WIN_MANAGED);
+
+ TkMapTopFrame(frameWin);
+ } else {
+ /* Already not managed by wm - ignore it */
+ }
+ return TCL_OK;
+#endif
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* WmFrameCmd --
*
* This procedure is invoked to process the "wm frame" Tcl command.
@@ -2038,6 +2109,67 @@ WmIconwindowCmd(
/*
*----------------------------------------------------------------------
*
+ * WmManageCmd --
+ *
+ * This procedure is invoked to process the "wm manage" Tcl command.
+ * See the user documentation for details on what it does.
+ *
+ * Results:
+ * A standard Tcl result.
+ *
+ * Side effects:
+ * See the user documentation.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+WmManageCmd(
+ Tk_Window tkwin, /* Main window of the application. */
+ TkWindow *winPtr, /* Toplevel or Frame to work with */
+ Tcl_Interp *interp, /* Current interpreter. */
+ int objc, /* Number of arguments. */
+ Tcl_Obj *CONST objv[]) /* Argument objects. */
+{
+ register Tk_Window frameWin = (Tk_Window)winPtr;
+ register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ char *oldClass = (char*)Tk_Class(frameWin);
+
+#if 1
+ Tcl_AppendResult(interp, "wm manage is not yet supported", (char*)NULL);
+ return TCL_ERROR;
+#else
+ if (!Tk_IsTopLevel(frameWin)) {
+ MacDrawable *macWin = (MacDrawable *) winPtr->window;
+
+ TkFocusSplit(winPtr);
+ Tk_UnmapWindow(frameWin);
+ if (wmPtr == NULL) {
+ TkWmNewWindow(winPtr);
+ if (winPtr->window == None) {
+ Tk_MakeWindowExist((Tk_Window) winPtr);
+ macWin = (MacDrawable *) winPtr->window;
+ }
+ TkWmMapWindow(winPtr);
+ Tk_UnmapWindow(frameWin);
+ }
+ wmPtr = winPtr->wmInfoPtr;
+ winPtr->flags &= ~TK_MAPPED;
+ macWin->grafPtr = NULL;
+ macWin->toplevel = macWin;
+ RemapWindows(winPtr, macWin);
+ winPtr->flags |= (TK_TOP_HIERARCHY|TK_TOP_LEVEL|TK_HAS_WRAPPER|TK_WIN_MANAGED);
+ TkMapTopFrame (frameWin);
+ } else if (Tk_IsTopLevel(frameWin)) {
+ /* Already managed by wm - ignore it */
+ }
+ return TCL_OK;
+#endif
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* WmMaxsizeCmd --
*
* This procedure is invoked to process the "wm maxsize" Tcl command.
@@ -6234,3 +6366,44 @@ GetMaxSize(
*maxHeightPtr = maxHeight;
}
}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * RemapWindows
+ *
+ * Adjust parent/child relation ships of
+ * the given window hierarchy.
+ *
+ * Results:
+ * none
+ *
+ * Side effects:
+ * keeps windowing system (X11) happy
+ *
+ *----------------------------------------------------------------------
+ */
+static void
+RemapWindows(TkWindow *winPtr, MacDrawable *parentWin)
+{
+ TkWindow *childPtr;
+
+ /* Remove the OS specific window.
+ * It will get rebuilt when the window gets Mapped.
+ */
+ if (winPtr->window != None) {
+ MacDrawable *macWin = (MacDrawable *) winPtr->window;
+ macWin->grafPtr = NULL;
+ macWin->toplevel = parentWin->toplevel;
+ winPtr->flags &= ~TK_MAPPED;
+#ifdef TK_REBUILD_TOPLEVEL
+ winPtr->flags |= TK_REBUILD_TOPLEVEL;
+#endif
+ }
+
+ /* Repeat for all the children */
+ for (childPtr = winPtr->childList; childPtr != NULL;
+ childPtr = childPtr->nextPtr) {
+ RemapWindows(childPtr, (MacDrawable *) winPtr->window);
+ }
+}