summaryrefslogtreecommitdiffstats
path: root/macosx/tkMacOSXSubwindows.c
diff options
context:
space:
mode:
Diffstat (limited to 'macosx/tkMacOSXSubwindows.c')
-rw-r--r--macosx/tkMacOSXSubwindows.c171
1 files changed, 125 insertions, 46 deletions
diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c
index c889a38..7e7bfc0 100644
--- a/macosx/tkMacOSXSubwindows.c
+++ b/macosx/tkMacOSXSubwindows.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: tkMacOSXSubwindows.c,v 1.2.2.5 2005/07/28 03:45:03 hobbs Exp $
+ * RCS: @(#) $Id: tkMacOSXSubwindows.c,v 1.2.2.6 2005/08/09 07:40:01 das Exp $
*/
#include "tkInt.h"
@@ -32,8 +32,7 @@ static RgnHandle tmpRgn = NULL;
*/
static void GenerateConfigureNotify (TkWindow *winPtr, int includeWin);
-static void UpdateOffsets _ANSI_ARGS_((TkWindow *winPtr,
- int deltaX, int deltaY));
+static void UpdateOffsets (TkWindow *winPtr, int deltaX, int deltaY);
/*
*----------------------------------------------------------------------
@@ -86,7 +85,7 @@ XDestroyWindow(
if (TkpIsWindowFloating (winRef)) {
Window window;
- window = TkMacOSXGetXWindow(FrontNonFloatingWindow());
+ window = TkMacOSXGetXWindow(ActiveNonFloatingWindow());
if (window != None) {
TkMacOSXGenerateFocusEvent(window, 1);
}
@@ -156,6 +155,57 @@ XDestroyWindow(
ckfree((char *) macWin);
}
}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * FixMappingFlags --
+ *
+ * If on is 0, mark the child windows of the window passed in in winPtr
+ * as unmapped, but remember whether they were originally mapped in their
+ * parent.
+ * If on is 1, set all the child windows of winPtr that WERE mapped in
+ * their parent before the parent was unmapped back to mapped.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * The TkWindow and MacDrawable flags may be adjusted.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void
+FixMappingFlags (TkWindow *winPtr, int on)
+{
+ TkWindow *childPtr;
+ childPtr = winPtr->childList;
+
+ while (childPtr != NULL) {
+ /*
+ * We might get called before the Mac OS X side of the widget
+ * is created yet. If so, wait till later...
+ */
+
+ if (childPtr->privatePtr != NULL) {
+
+ if (((MacDrawable *)childPtr->privatePtr)->flags
+ & TK_MAPPED_IN_PARENT) {
+ if (on) {
+ childPtr->flags |= TK_MAPPED;
+ } else {
+ childPtr->flags &= ~TK_MAPPED;
+ }
+ }
+ if (!Tk_TopWinHierarchy(childPtr)) {
+ FixMappingFlags (childPtr, on);
+ }
+ }
+ childPtr = childPtr->nextPtr;
+ }
+
+}
/*
*----------------------------------------------------------------------
@@ -197,6 +247,8 @@ XMapWindow(
display->request++;
macWin->winPtr->flags |= TK_MAPPED;
+ macWin->flags |= TK_MAPPED_IN_PARENT;
+ FixMappingFlags(macWin->winPtr, 1);
if (Tk_IsTopLevel(macWin->winPtr)) {
if (!Tk_IsEmbedded(macWin->winPtr)) {
/*
@@ -268,8 +320,11 @@ XUnmapWindow(
display->request++;
macWin->winPtr->flags &= ~TK_MAPPED;
+ macWin->flags &= ~TK_MAPPED_IN_PARENT;
+ FixMappingFlags(macWin->winPtr, 0);
if (Tk_IsTopLevel(macWin->winPtr)) {
- if (!Tk_IsEmbedded(macWin->winPtr)) {
+ if (!Tk_IsEmbedded(macWin->winPtr)
+ && macWin->winPtr->wmInfoPtr->hints.initial_state != IconicState) {
/*
* XXX This should be HideSheetWindow for kSheetWindowClass
* XXX windows that have a wmPtr->master parent set.
@@ -332,14 +387,14 @@ XResizeWindow(
{
MacDrawable *macWin = (MacDrawable *) window;
CGrafPtr destPort;
+ int havePort = 1;
destPort = TkMacOSXGetDrawablePort(window);
if (destPort == NULL) {
- return;
+ havePort = 0;
}
display->request++;
- SetPort( destPort);
if (Tk_IsTopLevel(macWin->winPtr)) {
if (!Tk_IsEmbedded(macWin->winPtr)) {
/*
@@ -347,10 +402,13 @@ XResizeWindow(
* region. It is currently assumed that Tk will need
* to completely redraw anway.
*/
- SizeWindow(GetWindowFromPort(destPort),
- (short) width, (short) height, false);
- TkMacOSXInvalidateWindow(macWin, TK_WINDOW_ONLY);
- TkMacOSXInvalClipRgns(macWin->winPtr);
+ if (havePort) {
+ SetPort(destPort);
+ SizeWindow(GetWindowFromPort(destPort),
+ (short) width, (short) height, false);
+ TkMacOSXInvalidateWindow(macWin, TK_WINDOW_ONLY);
+ TkMacOSXInvalClipRgns(macWin->winPtr);
+ }
} else {
int deltaX, deltaY;
@@ -365,9 +423,11 @@ XResizeWindow(
if (contWinPtr != NULL) {
MacDrawable *macParent = contWinPtr->privatePtr;
- TkMacOSXInvalClipRgns(macParent->winPtr);
- TkMacOSXInvalidateWindow(macWin, TK_PARENT_WINDOW);
-
+ if (havePort) {
+ SetPort(destPort);
+ TkMacOSXInvalClipRgns(macParent->winPtr);
+ TkMacOSXInvalidateWindow(macWin, TK_PARENT_WINDOW);
+ }
deltaX = macParent->xOff +
macWin->winPtr->changes.x - macWin->xOff;
deltaY = macParent->yOff +
@@ -397,9 +457,11 @@ XResizeWindow(
return; /* TODO: Probably should be a panic */
}
- TkMacOSXInvalClipRgns(macParent->winPtr);
- TkMacOSXInvalidateWindow(macWin, TK_PARENT_WINDOW);
-
+ if (havePort) {
+ SetPort(destPort);
+ TkMacOSXInvalClipRgns(macParent->winPtr);
+ TkMacOSXInvalidateWindow(macWin, TK_PARENT_WINDOW);
+ }
deltaX = - macWin->xOff;
deltaY = - macWin->yOff;
@@ -479,13 +541,13 @@ XMoveResizeWindow(
{
MacDrawable * macWin = (MacDrawable *) window;
CGrafPtr destPort;
+ int havePort = 1;
destPort = TkMacOSXGetDrawablePort(window);
if (destPort == NULL) {
- return;
+ havePort = 0;
}
- SetPort( destPort);
if (Tk_IsTopLevel(macWin->winPtr) && !Tk_IsEmbedded(macWin->winPtr)) {
/*
* NOTE: we are not adding the new space to the update
@@ -493,13 +555,16 @@ XMoveResizeWindow(
* to completely redraw anway.
*/
- SizeWindow(GetWindowFromPort(destPort),
- (short) width, (short) height, false);
- MoveWindowStructure(GetWindowFromPort(destPort), x, y);
+ if (havePort) {
+ SetPort( destPort);
+ SizeWindow(GetWindowFromPort(destPort),
+ (short) width, (short) height, false);
+ MoveWindowStructure(GetWindowFromPort(destPort), x, y);
- /* TODO: is the following right? */
- TkMacOSXInvalidateWindow(macWin, TK_WINDOW_ONLY);
- TkMacOSXInvalClipRgns(macWin->winPtr);
+ /* TODO: is the following right? */
+ TkMacOSXInvalidateWindow(macWin, TK_WINDOW_ONLY);
+ TkMacOSXInvalClipRgns(macWin->winPtr);
+ }
} else {
int deltaX, deltaY, parentBorderwidth;
Rect bounds;
@@ -515,7 +580,7 @@ XMoveResizeWindow(
contWinPtr = TkpGetOtherWindow(macWin->winPtr);
if (contWinPtr == NULL) {
- panic("XMoveResizeWindow could not find container");
+ Tcl_Panic("XMoveResizeWindow could not find container");
}
macParent = contWinPtr->privatePtr;
@@ -530,9 +595,12 @@ XMoveResizeWindow(
return; /* TODO: Probably should be a panic */
}
}
-
- TkMacOSXInvalClipRgns(macParent->winPtr);
- TkMacOSXInvalidateWindow(macWin, TK_PARENT_WINDOW);
+
+ if (havePort) {
+ SetPort( destPort);
+ TkMacOSXInvalClipRgns(macParent->winPtr);
+ TkMacOSXInvalidateWindow(macWin, TK_PARENT_WINDOW);
+ }
deltaX = - macWin->xOff;
deltaY = - macWin->yOff;
@@ -553,8 +621,10 @@ XMoveResizeWindow(
macWin->winPtr->changes.y;
UpdateOffsets(macWin->winPtr, deltaX, deltaY);
- TkMacOSXWinBounds(macWin->winPtr, &bounds);
- InvalWindowRect(GetWindowFromPort(destPort),&bounds);
+ if (havePort) {
+ TkMacOSXWinBounds(macWin->winPtr, &bounds);
+ InvalWindowRect(GetWindowFromPort(destPort),&bounds);
+ }
GenerateConfigureNotify(macWin->winPtr, 0);
}
}
@@ -585,24 +655,27 @@ XMoveWindow(
{
MacDrawable *macWin = (MacDrawable *) window;
CGrafPtr destPort;
+ int havePort = 1;
destPort = TkMacOSXGetDrawablePort(window);
if (destPort == NULL) {
- return;
+ havePort = 0;
}
- SetPort( destPort);
if (Tk_IsTopLevel(macWin->winPtr) && !Tk_IsEmbedded(macWin->winPtr)) {
/*
* NOTE: we are not adding the new space to the update
* region. It is currently assumed that Tk will need
* to completely redraw anway.
*/
- MoveWindowStructure( GetWindowFromPort(destPort), x, y);
+ if (havePort) {
+ SetPort(destPort);
+ MoveWindowStructure( GetWindowFromPort(destPort), x, y);
- /* TODO: is the following right? */
- TkMacOSXInvalidateWindow(macWin, TK_WINDOW_ONLY);
- TkMacOSXInvalClipRgns(macWin->winPtr);
+ /* TODO: is the following right? */
+ TkMacOSXInvalidateWindow(macWin, TK_WINDOW_ONLY);
+ TkMacOSXInvalClipRgns(macWin->winPtr);
+ }
} else {
int deltaX, deltaY, parentBorderwidth;
Rect bounds;
@@ -618,7 +691,7 @@ XMoveWindow(
contWinPtr = TkpGetOtherWindow(macWin->winPtr);
if (contWinPtr == NULL) {
- panic("XMoveWindow could not find container");
+ Tcl_Panic("XMoveWindow could not find container");
}
macParent = contWinPtr->privatePtr;
@@ -633,9 +706,12 @@ XMoveWindow(
}
}
- TkMacOSXInvalClipRgns(macParent->winPtr);
- TkMacOSXInvalidateWindow(macWin, TK_PARENT_WINDOW);
-
+ if (havePort) {
+ SetPort(destPort);
+ TkMacOSXInvalClipRgns(macParent->winPtr);
+ TkMacOSXInvalidateWindow(macWin, TK_PARENT_WINDOW);
+ }
+
deltaX = - macWin->xOff;
deltaY = - macWin->yOff;
@@ -655,8 +731,10 @@ XMoveWindow(
macWin->winPtr->changes.y;
UpdateOffsets(macWin->winPtr, deltaX, deltaY);
- TkMacOSXWinBounds(macWin->winPtr, &bounds);
- InvalWindowRect(GetWindowFromPort(destPort),&bounds);
+ if (havePort) {
+ TkMacOSXWinBounds(macWin->winPtr, &bounds);
+ InvalWindowRect(GetWindowFromPort(destPort),&bounds);
+ }
GenerateConfigureNotify(macWin->winPtr, 0);
}
}
@@ -817,7 +895,7 @@ TkMacOSXUpdateClipRgn(
if (winPtr == NULL) {
return;
}
-
+
if (winPtr->privatePtr->flags & TK_CLIP_INVALID) {
rgn = winPtr->privatePtr->aboveClipRgn;
if (tmpRgn == NULL) {
@@ -1231,7 +1309,8 @@ TkMacOSXWinBounds(
winPtr->changes.width);
bounds->bottom = (short) (winPtr->privatePtr->yOff +
winPtr->changes.height);
-}
+}
+
/*
*----------------------------------------------------------------------
*
@@ -1351,7 +1430,7 @@ Tk_GetPixmap(
err = NewGWorld(&gWorld, depth, &bounds, NULL, NULL, useTempMem);
}
if (err != noErr) {
- panic("Out of memory: NewGWorld failed in Tk_GetPixmap");
+ Tcl_Panic("Out of memory: NewGWorld failed in Tk_GetPixmap");
}
/*