diff options
author | das <das> | 2006-04-11 07:36:40 (GMT) |
---|---|---|
committer | das <das> | 2006-04-11 07:36:40 (GMT) |
commit | 25e939e6af367ad7192df73d73ae0e43e8ba86df (patch) | |
tree | a7850291b1d9e317f9f61721f3b814c992be5196 /macosx | |
parent | 7453482e26a8d90fd90b6d652b5d47679a91390d (diff) | |
download | tk-25e939e6af367ad7192df73d73ae0e43e8ba86df.zip tk-25e939e6af367ad7192df73d73ae0e43e8ba86df.tar.gz tk-25e939e6af367ad7192df73d73ae0e43e8ba86df.tar.bz2 |
* macosx/tkMacOSXInt.h: Implemented 'zoomed' window state
* macosx/tkMacOSXWindowEvent.c: handling for TkAqua, via titlebar
* macosx/tkMacOSXWm.c: widget clicks as well as [wm state].
* doc/wm.n: [Bug 1073456]
Diffstat (limited to 'macosx')
-rw-r--r-- | macosx/tkMacOSXInt.h | 5 | ||||
-rw-r--r-- | macosx/tkMacOSXWindowEvent.c | 5 | ||||
-rw-r--r-- | macosx/tkMacOSXWm.c | 188 |
3 files changed, 124 insertions, 74 deletions
diff --git a/macosx/tkMacOSXInt.h b/macosx/tkMacOSXInt.h index 4118fb7..d9f0ddd 100644 --- a/macosx/tkMacOSXInt.h +++ b/macosx/tkMacOSXInt.h @@ -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: tkMacOSXInt.h,v 1.3.2.9 2006/03/28 02:44:13 das Exp $ + * RCS: @(#) $Id: tkMacOSXInt.h,v 1.3.2.10 2006/04/11 07:36:40 das Exp $ */ #ifndef _TKMACINT @@ -159,8 +159,9 @@ extern int TkMacOSXInitCGDrawing(Tcl_Interp *interp, int enable, int antiAlias); extern void TkMacOSXDefaultStartupScript(void); extern int TkMacOSXGenerateFocusEvent( Window window, int activeFlag); extern WindowClass TkMacOSXWindowClass(TkWindow *winPtr); -extern void* TkMacOSXGetNamedSymbol(const char* module, const char* symbol); +extern int TkMacOSXIsWindowZoomed(TkWindow *winPtr); +extern void* TkMacOSXGetNamedSymbol(const char* module, const char* symbol); /* Macro to abstract common use of TkMacOSXGetNamedSymbol to initialize named symbols */ #define TkMacOSXInitNamedSymbol(module, ret, symbol, ...) \ static ret (* symbol)(__VA_ARGS__) = (void*)(-1L); \ diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 1a18b33..42f1041 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -54,7 +54,7 @@ * software in accordance with the terms specified in this * license. * - * RCS: @(#) $Id: tkMacOSXWindowEvent.c,v 1.3.2.9 2006/03/28 02:44:14 das Exp $ + * RCS: @(#) $Id: tkMacOSXWindowEvent.c,v 1.3.2.10 2006/04/11 07:36:40 das Exp $ */ #include "tkMacOSXInt.h" @@ -238,7 +238,8 @@ TkMacOSXProcessWindowEvent( dispPtr = TkGetDisplayList(); winPtr = (TkWindow *)Tk_IdToWindow(dispPtr->display, window); if (winPtr) { - TkpWmSetState(winPtr, NormalState); + TkpWmSetState(winPtr, TkMacOSXIsWindowZoomed(winPtr) ? + ZoomState : NormalState); } break; } diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index ff4e64e..7c7818b 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.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: tkMacOSXWm.c,v 1.7.2.22 2006/04/10 09:25:42 das Exp $ + * RCS: @(#) $Id: tkMacOSXWm.c,v 1.7.2.23 2006/04/11 07:36:40 das Exp $ */ #include "tkMacOSXInt.h" @@ -791,6 +791,12 @@ Tcl_Obj *CONST objv[]; /* Argument objects. */ return TCL_ERROR; } + if (winPtr->window == None) { + Tk_MakeWindowExist((Tk_Window) winPtr); + } + if (!TkMacOSXHostToplevelExists(winPtr)) { + TkMacOSXMakeRealWindowExist(winPtr); + } macWindow = GetWindowFromPort(TkMacOSXGetDrawablePort(winPtr->window)); if (objc == 3) { @@ -1228,7 +1234,6 @@ int objc; /* Number of arguments. */ Tcl_Obj *CONST objv[]; /* Argument objects. */ { register WmInfo *wmPtr = winPtr->wmInfoPtr; - if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); return TCL_ERROR; @@ -1244,12 +1249,8 @@ Tcl_Obj *CONST objv[]; /* Argument objects. */ ": it is an embedded window", (char *) NULL); return TCL_ERROR; } - - /* - * TODO: may not want to call this function - look at Map events gened. - */ - - TkpWmSetState(winPtr, NormalState); + TkpWmSetState(winPtr, TkMacOSXIsWindowZoomed(winPtr) ? + ZoomState : NormalState); return TCL_OK; } @@ -2696,6 +2697,11 @@ Tcl_Obj *CONST objv[]; /* Argument objects. */ if (wmPtr->iconFor != NULL) { Tcl_SetResult(interp, "icon", TCL_STATIC); } else { + if (wmPtr->hints.initial_state == NormalState || + wmPtr->hints.initial_state == ZoomState) { + wmPtr->hints.initial_state = (TkMacOSXIsWindowZoomed(winPtr) ? + ZoomState : NormalState); + } switch (wmPtr->hints.initial_state) { case NormalState: Tcl_SetResult(interp, "normal", TCL_STATIC); @@ -4408,7 +4414,7 @@ TkMacOSXGrowToplevel( SetPort(GetWindowPort(whichWindow)); GlobalToLocal(&where); - GetPortBounds(GetWindowPort(whichWindow), &portRect ); + GetPortBounds(GetWindowPort(whichWindow), &portRect); if (where.h > (portRect.right - 16) && where.v > (portRect.bottom - 16)) { Window window; @@ -4445,7 +4451,7 @@ TkMacOSXGrowToplevel( if (growResult != 0) { SizeWindow(whichWindow, LoWord(growResult), HiWord(growResult), true); - InvalWindowRect(whichWindow,&portRect); /* TODO: may not be needed */ + InvalWindowRect(whichWindow, &portRect); /* TODO: may not be needed */ TkMacOSXInvalClipRgns((Tk_Window) winPtr); TkGenWMConfigureEvent((Tk_Window) winPtr, -1, -1, (int) LoWord(growResult), (int) HiWord(growResult), @@ -4558,11 +4564,57 @@ TkMacOSXGetXWindow( /* *---------------------------------------------------------------------- * + * TkMacOSXIsWindowZoomed -- + * + * Ask Carbon if the given window is in the zoomed out state. + * Because dragging & growing a window can change the Carbon + * zoom state, we cannot rely on wmInfoPtr->hints.initial_state + * for this information. + * + * Results: + * True if window is zoomed out, false otherwise. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +int +TkMacOSXIsWindowZoomed( + TkWindow *winPtr) +{ + WmInfo *wmPtr = winPtr->wmInfoPtr; + Point idealSize; + + if ((wmPtr->flags & WM_WIDTH_NOT_RESIZABLE) && + (wmPtr->flags & WM_HEIGHT_NOT_RESIZABLE)) { + return false; + } + if (wmPtr->flags & WM_WIDTH_NOT_RESIZABLE) { + idealSize.h = winPtr->changes.width; + } else { + idealSize.h = wmPtr->maxWidth; + } + if (wmPtr->flags & WM_HEIGHT_NOT_RESIZABLE) { + idealSize.v = winPtr->changes.height; + } else { + idealSize.v = wmPtr->maxHeight; + } + + return IsWindowInStandardState( + GetWindowFromPort(TkMacOSXGetDrawablePort(winPtr->window)), + &idealSize, NULL); +} + +/* + *---------------------------------------------------------------------- + * * TkMacOSXZoomToplevel -- * * The function is invoked when the user clicks in the zoom region - * of a Tk window. The function will handle the mouse tracking - * for the interaction. If the window is to be zoomed the window + * of a Tk window or when the window state is set/unset to "zoomed" + * manually. If the window is to be zoomed (in or out), the window * size is changed and events are generated to let Tk know what * happened. * @@ -4581,65 +4633,60 @@ TkMacOSXZoomToplevel( short zoomPart) /* Either inZoomIn or inZoomOut */ { Window window; - Tk_Window tkwin; - Point location = {0, 0}; - int xOffset, yOffset; - WmInfo *wmPtr; TkDisplay *dispPtr; - Rect portRect; - - SetPort(GetWindowPort(whichWindow)); + TkWindow *winPtr; + WmInfo *wmPtr; + Point location = {0, 0}, idealSize; + Rect portRect; + int xOffset, yOffset; + OSStatus status; - /* - * We should now zoom the window (as long as it's one of ours). We - * also need to generate an event to let Tk know that the window size - * has changed. - */ window = TkMacOSXGetXWindow(whichWindow); dispPtr = TkGetDisplayList(); - tkwin = Tk_IdToWindow(dispPtr->display, window); - if (tkwin == NULL) { + winPtr = (TkWindow *) Tk_IdToWindow(dispPtr->display, window); + wmPtr = winPtr->wmInfoPtr; + + if ((wmPtr->flags & WM_WIDTH_NOT_RESIZABLE) && + (wmPtr->flags & WM_HEIGHT_NOT_RESIZABLE)) { return false; } + if (wmPtr->flags & WM_WIDTH_NOT_RESIZABLE) { + idealSize.h = winPtr->changes.width; + } else { + idealSize.h = wmPtr->maxWidth; + } + if (wmPtr->flags & WM_HEIGHT_NOT_RESIZABLE) { + idealSize.v = winPtr->changes.height; + } else { + idealSize.v = wmPtr->maxHeight; + } - /* - * The following block of code works around a bug in the window - * definition for Apple's floating windows. The zoom behavior is - * broken - we must manually set the standard state (by default - * it's something like 1x1) and we must swap the zoomPart manually - * otherwise we always get the same zoomPart and nothing happens. - */ - wmPtr = ((TkWindow *) tkwin)->wmInfoPtr; - if (wmPtr->style >= floatProc && wmPtr->style <= floatSideZoomGrowProc) { - if (zoomPart == inZoomIn) { - BitMap screenBits; - Rect zoomRect; - GetQDGlobalsScreenBits(&screenBits); - zoomRect = screenBits.bounds; - InsetRect(&zoomRect, 60, 60); - SetWindowStandardState(whichWindow, &zoomRect); - zoomPart = inZoomOut; - } else { - zoomPart = inZoomIn; - } + /* Do nothing if already in desired zoom state */ + if (!IsWindowInStandardState(whichWindow, &idealSize, NULL) == + (zoomPart == inZoomIn)) { + return false; + } + + SetPort(GetWindowPort(whichWindow)); + GetPortBounds(GetWindowPort(whichWindow), &portRect); + status = ZoomWindowIdeal(whichWindow, zoomPart, &idealSize); + if (status == noErr) { + wmPtr->hints.initial_state = + (zoomPart == inZoomIn ? NormalState : ZoomState); + InvalWindowRect(whichWindow, &portRect); + TkMacOSXInvalClipRgns((Tk_Window) winPtr); + LocalToGlobal(&location); + TkMacOSXWindowOffset(whichWindow, &xOffset, &yOffset); + location.h -= xOffset; + location.v -= yOffset; + GetPortBounds(GetWindowPort(whichWindow), &portRect); + TkGenWMConfigureEvent((Tk_Window) winPtr, location.h, location.v, + portRect.right - portRect.left, portRect.bottom - portRect.top, + TK_BOTH_CHANGED); + return true; } else { - zoomPart = inZoomIn; + return false; } - - ZoomWindow(whichWindow, zoomPart, false); - InvalWindowRect(whichWindow,&portRect); - TkMacOSXInvalClipRgns(tkwin); - - LocalToGlobal(&location); - TkMacOSXWindowOffset(whichWindow, &xOffset, &yOffset); - location.h -= xOffset; - location.v -= yOffset; - GetPortBounds ( GetWindowPort(whichWindow), &portRect ); - TkGenWMConfigureEvent(tkwin, location.h, location.v, - portRect.right - portRect.left, - portRect.bottom - portRect.top, - TK_BOTH_CHANGED); - return true; } /* @@ -5056,6 +5103,7 @@ TkMacOSXMakeRealWindowExist( SetWindowGroup(newWindow, group); } } + SetWindowModified(newWindow, false); if (!windowHashInit) { Tcl_InitHashTable(&windowTable, TCL_ONE_WORD_KEYS); @@ -5294,10 +5342,15 @@ TkpWmSetState(winPtr, state) } else if (state == NormalState) { Tk_MapWindow((Tk_Window) winPtr); if (IsWindowCollapsable(macWin) && IsWindowCollapsed(macWin)) { - CollapseWindow((WindowPtr) macWin, false); - } + CollapseWindow(macWin, false); + } + TkMacOSXZoomToplevel(macWin, inZoomIn); } else if (state == ZoomState) { - /* TODO: need to support zoomed windows */ + Tk_MapWindow((Tk_Window) winPtr); + if (IsWindowCollapsable(macWin) && IsWindowCollapsed(macWin)) { + CollapseWindow(macWin, false); + } + TkMacOSXZoomToplevel(macWin, inZoomOut); } } @@ -5652,8 +5705,3 @@ TkWmStackorderToplevel(parentPtr) Tcl_DeleteHashTable(&table); return windows; } - - - - - |