summaryrefslogtreecommitdiffstats
path: root/macosx/tkMacOSXSubwindows.c
diff options
context:
space:
mode:
authordas <das>2005-08-09 07:39:48 (GMT)
committerdas <das>2005-08-09 07:39:48 (GMT)
commit96e2365694455afbd0982557be9c82975ed043c6 (patch)
treeb77a27b7d580d802ccbfcb5442bba1206c3ff248 /macosx/tkMacOSXSubwindows.c
parent0a01627407c91c3f03582d7d2e81f125d95f40a2 (diff)
downloadtk-96e2365694455afbd0982557be9c82975ed043c6.zip
tk-96e2365694455afbd0982557be9c82975ed043c6.tar.gz
tk-96e2365694455afbd0982557be9c82975ed043c6.tar.bz2
* macosx/tkMacOSXCarbonEvents.c (new): moved carbon events code into
* macosx/tkMacOSXHLEvents.c: new file like on HEAD, * macosx/tkMacOSXInit.c (TkpInit): initialize carbon event handlers * macosx/tkMacOSXInt.h: in TkpInit(), add new source * unix/Makefile.in: file to Makefile.in. * macosx/tkMacOSXCarbonEvents.c (AppEventHandlerProc): handle carbon events sent directly to application event target via the general TkMacOSXProcessEvent() in the same way as events posted to the event loop. Moved existing app event handlers to tkMacOSXWindowEvent.c. (TkMacOSXInitCarbonEvents): register our application event handler for kEventWindowExpanded events to deal with uncollapsing from the dock. * macosx/tkMacOSXEvent.h: made TkMacOSXProcessEvent() non-static, added * macosx/tkMacOSXEvent.c: new interp field to TkMacOSXEvent struct for use by app event handler. * macosx/tkMacOSXMouseEvent.c (TkMacOSXProcessMouseEvent): retrieve current window, partCode, modifiers and local cursor position from carbon mouse event if possible. Use new static GenerateButtonEvent() taking a MouseEventData struct instead of TkGenerateButtonEvent() to avoid recomputing already known values. Move process activation on MouseDown into BringWindowForward() to allow clicking on window titlebar widgets without activating process. Move code dealing with clicks in window titelbar into separate function HandleWindowTitlebarMouseDown() to avoid code duplication. Avoid repeated calls to TkMacOSXGetXWindow() by storing result in MouseEventData struct. (TkMacOSXButtonKeyState, XQueryPointer): try to get button and modifier state from currently processed carbon event (to avoid unnecessary IPC with the window server), otherwise use modern carbon API to get this info instead of Button() and GetKeys(); only retrieve info caller asks for (via non-NULL ptr passed to XQueryPointer). (ButtonModifiers2State): new static function converting carbon button and modifier state into tk state, allows detection of more than 3 mouse buttons (tk supports up to 5) and of NumLock and Fn modifier keys (NumLock is mapped to Mod3 and Fn to Mod4). * macosx/tkMacOSXWindowEvent.c (TkMacOSXProcessApplicationEvent): handle kEventWindowExpanded event to deal with window uncollapsing from the dock by generating tk Map event, handle kEventAppHidden and kEventAppShown events (moved here from tkMacOSXCarbonEvents.c). * macosx/tkMacOSXSubwindows.c (XUnmapWindow): only hide window when it is not iconified to avoid window flashing on collapse. * macosx/tkMacOSXWm.c: replaced Tk_DoWhenIdle() by Tcl_DoWhenIdle(). (TkMacOSXZoomToplevel): remove call to TrackBox(), now done in HandleWindowTitlebarMouseDown() in tkMacOSXMouseEvent.c. (TkpWmSetState): avoid window flashing on collapse by unmapping after calling CollapseWindow(); only uncollapse window if it is collapsed. * generic/tkInt.decls: changed TkMacOSXZoomToplevel() signature. * generic/tkIntPlatDecls.h: * macosx/tkMacOSXKeyEvent.c (TkMacOSXProcessKeyboardEvent): only call GetMenuItemCommandID() on KeyDown or KeyRepeat events. * macosx/tkMacOSXMenu.c (ReconfigureMacintoshMenu): remove call to obsolete AppendResMenu() API. * macosx/tkMacOSXKeyEvent.c: replaced all direct uses of expensive * macosx/tkMacOSXMenu.c: GetMouse() and TkMacOSXButtonKeyState() * macosx/tkMacOSXMenus.c: APIs by calls to XQueryPointer() * macosx/tkMacOSXMouseEvent.c: * macosx/tkMacOSXScale.c: * macosx/tkMacOSXScrlbr.c: * macosx/tkMacOSXWm.c: * macosx/tkMacOSXDialog.c: replaced use of FrontNonFloatingWindow() * macosx/tkMacOSXKeyEvent.c: by ActiveNonFloatingWindow() as * macosx/tkMacOSXMenu.c: recommended by Carbon docs. * macosx/tkMacOSXMenus.c: * macosx/tkMacOSXSubwindows.c: * macosx/tkMacOSXWm.c: * macosx/tkMacOSXDialog.c: fixed warnings * macosx/tkMacOSXTest.c: * macosx/tkMacOSXCarbonEvents.c: added CVS Id line to file header. * macosx/tkMacOSXDebug.c: * macosx/tkMacOSXDebug.h: * macosx/tkMacOSXEntry.c: * macosx/tkMacOSXEvent.h: * macosx/tkMacOSXKeyEvent.c: * macosx/tkMacOSXMouseEvent.c: * macosx/tkMacOSXWindowEvent.c: * macosx/tkMacOSXWm.h: * macosx/tkMacOSXEmbed.c: replaced all uses of panic() with Tcl_Panic() * macosx/tkMacOSXFont.c: (sync with HEAD). * macosx/tkMacOSXMenus.c: * macosx/tkMacOSXSubwindows.c: * macosx/tkMacOSXWm.c: * macosx/tkMacOSXXStubs.c: * macosx/tkMacOSXInt.h: sync with HEAD changes of 2005-03-14. * macosx/tkMacOSXSubwindows.c: * macosx/tclets.r (removed): sync with HEAD. * macosx/tkMacOSXScale.c: * macosx/tkMacOSXPort.h: * library/demos/menu.tcl: removed errant '}'.
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");
}
/*