summaryrefslogtreecommitdiffstats
path: root/macosx
diff options
context:
space:
mode:
authordas <das>2007-06-06 09:56:53 (GMT)
committerdas <das>2007-06-06 09:56:53 (GMT)
commitce5acb5ed756f94b279f428e363bb885ab971d01 (patch)
tree0f31e25d4ca595727ac6e0b38a271fa4d9ad77bb /macosx
parent14f8f936349132e0f6dc66230d2378d47d0968d7 (diff)
downloadtk-ce5acb5ed756f94b279f428e363bb885ab971d01.zip
tk-ce5acb5ed756f94b279f428e363bb885ab971d01.tar.gz
tk-ce5acb5ed756f94b279f428e363bb885ab971d01.tar.bz2
* macosx/tkMacOSXMouseEvent.c (GenerateMouseWheelEvent): enable
processing of mousewheel events in background windows. * macosx/tkMacOSXScrlbr.c: modernize checks for active/front window. * macosx/tkMacOSXScale.c: * macosx/tkMacOSXWm.c: * macosx/tkMacOSXColor.c: factor out verbose #ifdef checks of * macosx/tkMacOSXDraw.c: MAC_OS_X_VERSION_{MAX_ALLOWED,MIN_REQUIRED} * macosx/tkMacOSXEntry.c: and runtime checks of kHIToolboxVersion into * macosx/tkMacOSXEvent.c: new TK_{IF,ELSE,ENDIF}_MAC_OS_X macros. * macosx/tkMacOSXInit.c: * macosx/tkMacOSXInt.h: * macosx/tkMacOSXWm.c: * macosx/tkMacOSXDraw.c: factor out clip clearing in QD ports; * macosx/tkMacOSXEntry.c: formatting cleanup.
Diffstat (limited to 'macosx')
-rw-r--r--macosx/tkMacOSXColor.c62
-rw-r--r--macosx/tkMacOSXDraw.c157
-rw-r--r--macosx/tkMacOSXEntry.c51
-rw-r--r--macosx/tkMacOSXEvent.c15
-rw-r--r--macosx/tkMacOSXInit.c12
-rw-r--r--macosx/tkMacOSXInt.h66
-rw-r--r--macosx/tkMacOSXMouseEvent.c19
-rw-r--r--macosx/tkMacOSXScale.c8
-rw-r--r--macosx/tkMacOSXScrlbr.c11
-rw-r--r--macosx/tkMacOSXWm.c81
10 files changed, 221 insertions, 261 deletions
diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c
index 5a35086..5d4fb78 100644
--- a/macosx/tkMacOSXColor.c
+++ b/macosx/tkMacOSXColor.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: tkMacOSXColor.c,v 1.2.2.6 2007/05/31 13:42:12 das Exp $
+ * RCS: @(#) $Id: tkMacOSXColor.c,v 1.2.2.7 2007/06/06 09:56:54 das Exp $
*/
#include "tkMacOSXInt.h"
@@ -382,50 +382,34 @@ TkMacOSXSetColorInContext(unsigned long pixel, CGContextRef context)
if (GetThemeFromPixelCode((pixel >> 24) & 0xff, &brush, &textColor,
&background)) {
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040
if (brush) {
- if (1
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 1040
- && HIThemeSetFill != NULL && HIThemeSetStroke != NULL
-#endif
- ) {
+ TK_IF_MAC_OS_X_API (4, HIThemeSetFill,
err = ChkErr(HIThemeSetFill, brush, NULL, context,
kHIThemeOrientationNormal);
- if (err == noErr) {
+ TK_IF_MAC_OS_X_API_COND (4, err == noErr, HIThemeSetFill,
err = ChkErr(HIThemeSetStroke, brush, NULL, context,
kHIThemeOrientationNormal);
- }
- }
+ ) TK_ENDIF_MAC_OS_X
+ ) TK_ENDIF_MAC_OS_X
} else if (textColor) {
- if (1
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 1040
- && HIThemeSetTextFill != NULL
-#endif
- ) {
+ TK_IF_MAC_OS_X_API (4, HIThemeSetTextFill,
err = ChkErr(HIThemeSetTextFill, textColor, NULL, context,
kHIThemeOrientationNormal);
- }
- } else
-#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= 1040 */
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
- if (background) {
- if (1
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 1030
- && CGContextGetClipBoundingBox != NULL
- && HIThemeApplyBackground != NULL
- && &kHIToolboxVersionNumber != NULL /* c.f. QA1377 */
- && kHIToolboxVersionNumber >= kHIToolboxVersionNumber10_3
-#endif
- ) {
+ ) TK_ENDIF_MAC_OS_X
+ } else if (background) {
+ TK_IF_MAC_OS_X_API (3, CGContextGetClipBoundingBox,
CGRect rect = CGContextGetClipBoundingBox(context);
HIThemeBackgroundDrawInfo info = { 0, kThemeStateActive,
background };
- err = ChkErr(HIThemeApplyBackground, &rect, &info, context,
- kHIThemeOrientationNormal);
- }
+ TK_IF_MAC_OS_X_API (3, HIThemeApplyBackground,
+ TK_IF_MAC_OS_X_HI_TOOLBOX (3, /* c.f. QA1377 */
+ err = ChkErr(HIThemeApplyBackground, &rect, &info,
+ context, kHIThemeOrientationNormal);
+ ) TK_ENDIF_MAC_OS_X
+ ) TK_ENDIF_MAC_OS_X
+ ) TK_ENDIF_MAC_OS_X
}
-#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 */
if (err == noErr) {
return;
}
@@ -458,17 +442,9 @@ TkMacOSXSetColorInContext(unsigned long pixel, CGContextRef context)
Tcl_Panic("TkMacOSXSetColorInContext(): "
"pattern initialization failed !");
}
- bitmapInfo =
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040
- (1
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 1040
- && &kHIToolboxVersionNumber != NULL
- && kHIToolboxVersionNumber >=
- kHIToolboxVersionNumber10_4
-#endif
- ) ? kCGBitmapByteOrder32Host :
-#endif
- 0;
+ TK_IF_MAC_OS_X_HI_TOOLBOX (4,
+ bitmapInfo = kCGBitmapByteOrder32Host;
+ ) TK_ENDIF_MAC_OS_X
}
portChanged = QDSwapPort(patGWorld, &savePort);
TkMacOSXSetColorInPort(pixel, 1, pixpat);
diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c
index fb3d0c1..5b2ebbb 100644
--- a/macosx/tkMacOSXDraw.c
+++ b/macosx/tkMacOSXDraw.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: tkMacOSXDraw.c,v 1.2.2.24 2007/06/04 09:28:44 das Exp $
+ * RCS: @(#) $Id: tkMacOSXDraw.c,v 1.2.2.25 2007/06/06 09:56:54 das Exp $
*/
#include "tkMacOSXInt.h"
@@ -41,7 +41,7 @@
RgnHandle tkMacOSXtmpRgn1 = NULL;
RgnHandle tkMacOSXtmpRgn2 = NULL;
-static PixPatHandle gPenPat = NULL;
+static PixPatHandle penPat = NULL;
static int useCGDrawing = 1;
static int tkMacOSXCGAntiAliasLimit = 0;
@@ -54,6 +54,7 @@ static int useThemedFrame = 0;
* Prototypes for functions used only in this file.
*/
static unsigned char InvertByte(unsigned char data);
+static void NoQDClip(CGrafPtr port);
/*
@@ -207,13 +208,10 @@ XCopyArea(
if (tkPictureIsOpen) {
/*
* When rendering into a picture, after a call to "OpenCPicture"
- * the drawable clipping is incorrect, so clip to the whole window.
+ * the drawable clipping is incorrect, so don't clip.
*/
- Rect clpRect;
-
- GetPortBounds(dstPort, &clpRect);
- ClipRect(&clpRect);
+ NoQDClip(dstPort);
}
if (gc->clip_mask && ((TkpClipMask*)gc->clip_mask)->type
== TKP_CLIP_REGION) {
@@ -237,9 +235,9 @@ XCopyArea(
srcBit = GetPortBitMapForCopyBits(srcPort);
dstBit = GetPortBitMapForCopyBits(dstPort);
CopyBits(srcBit, dstBit, srcPtr, dstPtr, srcCopy, NULL);
+ SetClip(tkMacOSXtmpRgn2);
RGBForeColor(&origForeColor);
RGBBackColor(&origBackColor);
- SetClip(tkMacOSXtmpRgn2);
SetEmptyRgn(tkMacOSXtmpRgn2);
if (portChanged) {
QDSwapPort(savePort, NULL);
@@ -302,13 +300,10 @@ XCopyPlane(
if (tkPictureIsOpen) {
/*
* When rendering into a picture, after a call to "OpenCPicture"
- * the drawable clipping is incorrect, so clip to the whole window.
+ * the drawable clipping is incorrect, so don't clip.
*/
- Rect clpRect;
-
- GetPortBounds(dstPort, &clpRect);
- ClipRect(&clpRect);
+ NoQDClip(dstPort);
dstPtr = &srcRect;
} else {
dstPtr = &dstRect;
@@ -416,13 +411,10 @@ TkPutImage(
if (tkPictureIsOpen) {
/*
* When rendering into a picture, after a call to "OpenCPicture"
- * the drawable clipping is incorrect, so clip to the whole window.
+ * the drawable clipping is incorrect, so don't clip.
*/
- Rect clpRect;
-
- GetPortBounds(destPort, &clpRect);
- ClipRect(&clpRect);
+ NoQDClip(destPort);
destPtr = srcPtr;
} else {
destPtr = &destRect;
@@ -1011,17 +1003,10 @@ XDrawArc(
macWin->xOff + x + o,
macWin->yOff + y + o,
width, height);
-
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040
- if (angle1 == 0 && angle2 == 23040
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 1040
- && CGContextStrokeEllipseInRect != NULL
-#endif
- ) {
+ TK_IF_MAC_OS_X_API_COND (4, angle1 == 0 && angle2 == 23040,
+ CGContextStrokeEllipseInRect,
CGContextStrokeEllipseInRect(dc.context, rect);
- } else
-#endif
- {
+ ) TK_ELSE_MAC_OS_X (4,
CGMutablePathRef p = CGPathCreateMutable();
CGAffineTransform t = CGAffineTransformIdentity;
CGPoint c = CGPointMake(CGRectGetMidX(rect), CGRectGetMidY(rect));
@@ -1036,7 +1021,7 @@ XDrawArc(
CGContextAddPath(dc.context, p);
CGPathRelease(p);
CGContextStrokePath(dc.context);
- }
+ ) TK_ENDIF_MAC_OS_X
} else {
Rect theRect;
short start, extent;
@@ -1106,16 +1091,10 @@ XDrawArcs(
macWin->yOff + arcPtr->y + o,
arcPtr->width, arcPtr->height);
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040
- if (arcPtr->angle1 == 0 && arcPtr->angle2 == 23040
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 1040
- && CGContextStrokeEllipseInRect != NULL
-#endif
- ) {
+ TK_IF_MAC_OS_X_API_COND (4, arcPtr->angle1 == 0 &&
+ arcPtr->angle2 == 23040, CGContextStrokeEllipseInRect,
CGContextStrokeEllipseInRect(dc.context, rect);
- } else
-#endif
- {
+ ) TK_ELSE_MAC_OS_X (4,
CGMutablePathRef p = CGPathCreateMutable();
CGAffineTransform t = CGAffineTransformIdentity;
CGPoint c = CGPointMake(CGRectGetMidX(rect),
@@ -1134,7 +1113,7 @@ XDrawArcs(
CGContextAddPath(dc.context, p);
CGPathRelease(p);
CGContextStrokePath(dc.context);
- }
+ ) TK_ENDIF_MAC_OS_X
}
} else {
Rect theRect;
@@ -1204,16 +1183,10 @@ XFillArc(
macWin->yOff + y + o,
width - u, height - u);
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040
- if (angle1 == 0 && angle2 == 23040
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 1040
- && CGContextFillEllipseInRect != NULL
-#endif
- ) {
+ TK_IF_MAC_OS_X_API_COND (4, angle1 == 0 && angle2 == 23040,
+ CGContextFillEllipseInRect,
CGContextFillEllipseInRect(dc.context, rect);
- } else
-#endif
- {
+ ) TK_ELSE_MAC_OS_X (4,
CGMutablePathRef p = CGPathCreateMutable();
CGAffineTransform t = CGAffineTransformIdentity;
CGPoint c = CGPointMake(CGRectGetMidX(rect), CGRectGetMidY(rect));
@@ -1232,7 +1205,7 @@ XFillArc(
CGContextAddPath(dc.context, p);
CGPathRelease(p);
CGContextFillPath(dc.context);
- }
+ ) TK_ENDIF_MAC_OS_X
} else {
Rect theRect;
short start, extent;
@@ -1328,17 +1301,10 @@ XFillArcs(
macWin->xOff + arcPtr->x + o,
macWin->yOff + arcPtr->y + o,
arcPtr->width - u, arcPtr->height - u);
-
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040
- if (arcPtr->angle1 == 0 && arcPtr->angle2 == 23040
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 1040
- && CGContextFillEllipseInRect != NULL
-#endif
- ) {
+ TK_IF_MAC_OS_X_API_COND (4, arcPtr->angle1 == 0 &&
+ arcPtr->angle2 == 23040, CGContextFillEllipseInRect,
CGContextFillEllipseInRect(dc.context, rect);
- } else
-#endif
- {
+ ) TK_ELSE_MAC_OS_X (4,
CGMutablePathRef p = CGPathCreateMutable();
CGAffineTransform t = CGAffineTransformIdentity;
CGPoint c = CGPointMake(CGRectGetMidX(rect),
@@ -1361,7 +1327,7 @@ XFillArcs(
CGContextAddPath(dc.context, p);
CGPathRelease(p);
CGContextFillPath(dc.context);
- }
+ ) TK_ENDIF_MAC_OS_X
}
} else {
Rect theRect;
@@ -1479,11 +1445,11 @@ TkScrollWindow(
* destination rects disjoint and non-aligned.
*/
- SetRect(&srcRect, (short) (destDraw->xOff + x),
+ SetRect(&scrollRect, (short) (destDraw->xOff + x),
(short) (destDraw->yOff + y),
(short) (destDraw->xOff + x + width),
(short) (destDraw->yOff + y + height));
- scrollRect = srcRect;
+ srcRect = scrollRect;
if (dx < 0) {
scrollRect.left += dx;
} else {
@@ -1553,11 +1519,11 @@ TkMacOSXSetUpGraphicsPort(
{
PenNormal();
if (gc) {
- if (gPenPat == NULL) {
- gPenPat = NewPixPat();
+ if (penPat == NULL) {
+ penPat = NewPixPat();
}
- TkMacOSXSetColorInPort(gc->foreground, 1, gPenPat);
- PenPixPat(gPenPat);
+ TkMacOSXSetColorInPort(gc->foreground, 1, penPat);
+ PenPixPat(penPat);
if(gc->function == GXxor) {
PenMode(patXor);
}
@@ -1652,20 +1618,16 @@ TkMacOSXSetupDrawingContext(
}
} else if (context) {
TkMacOSXCheckTmpRgnEmpty(1);
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
- if (!port
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 1030
- && CGContextGetClipBoundingBox != NULL
-#endif
- ) {
- CGRect r = CGContextGetClipBoundingBox(context);
-
- SetRect(&portBounds, r.origin.x + macDraw->xOff,
- r.origin.y + macDraw->yOff,
- r.origin.x + r.size.width + macDraw->xOff,
- r.origin.y + r.size.height + macDraw->yOff);
+ if (!port) {
+ TK_IF_MAC_OS_X_API (3, CGContextGetClipBoundingBox,
+ CGRect r = CGContextGetClipBoundingBox(context);
+
+ SetRect(&portBounds, r.origin.x + macDraw->xOff,
+ r.origin.y + macDraw->yOff,
+ r.origin.x + r.size.width + macDraw->xOff,
+ r.origin.y + r.size.height + macDraw->yOff);
+ ) TK_ENDIF_MAC_OS_X
}
-#endif
RectRgn(tkMacOSXtmpRgn1, &portBounds);
if (port) {
TkMacOSXSetUpClippingRgn(d);
@@ -1758,12 +1720,12 @@ TkMacOSXSetupDrawingContext(
} else {
ChkErr(GetThemeDrawingState, &(dc->saveState));
if (gc) {
- PixPatHandle savePat = gPenPat;
+ PixPatHandle savePat = penPat;
- gPenPat = NULL;
+ penPat = NULL;
TkMacOSXSetUpGraphicsPort(gc, port);
- dc->penPat = gPenPat;
- gPenPat = savePat;
+ dc->penPat = penPat;
+ penPat = savePat;
if (gc->clip_mask && ((TkpClipMask*)gc->clip_mask)->type
== TKP_CLIP_REGION) {
RgnHandle gcClipRgn = (RgnHandle)
@@ -1927,6 +1889,35 @@ TkpClipDrawableToRect(
/*
*----------------------------------------------------------------------
*
+ * NoQDClip --
+ *
+ * Helper function to setup a QD port to not clip anything.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static void
+NoQDClip(
+ CGrafPtr port)
+{
+ static RgnHandle noClipRgn = NULL;
+
+ if (!noClipRgn) {
+ noClipRgn = NewRgn();
+ SetRectRgn(noClipRgn, SHRT_MIN, SHRT_MIN, SHRT_MAX, SHRT_MAX);
+ }
+ SetPortClipRegion(port, noClipRgn);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* TkMacOSXMakeStippleMap --
*
* Given a drawable and a stipple pattern this function draws the
diff --git a/macosx/tkMacOSXEntry.c b/macosx/tkMacOSXEntry.c
index c412f31..8533932 100644
--- a/macosx/tkMacOSXEntry.c
+++ b/macosx/tkMacOSXEntry.c
@@ -53,7 +53,7 @@
* software in accordance with the terms specified in this
* license.
*
- * RCS: @(#) $Id: tkMacOSXEntry.c,v 1.2.2.9 2007/06/04 09:28:44 das Exp $
+ * RCS: @(#) $Id: tkMacOSXEntry.c,v 1.2.2.10 2007/06/06 09:56:54 das Exp $
*/
#include "tkMacOSXInt.h"
@@ -80,40 +80,37 @@ static ThemeButtonKind ComputeIncDecParameters (int height, int *width);
*--------------------------------------------------------------
*/
static ThemeButtonKind
-ComputeIncDecParameters (int height, int *width)
+ComputeIncDecParameters(int height, int *width)
{
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
- if (1
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 1030
- && &kHIToolboxVersionNumber != NULL
- && kHIToolboxVersionNumber >= kHIToolboxVersionNumber10_3
-#endif
- ) {
+ ThemeButtonKind kind;
+
+ TK_IF_MAC_OS_X_HI_TOOLBOX (3,
if (height < 11 || height > 28) {
*width = 0;
- return (ThemeButtonKind) 0;
- }
-
- if (height >= 21) {
- *width = 13;
- return kThemeIncDecButton;
- } else if (height >= 18) {
- *width = 12;
- return kThemeIncDecButtonSmall;
+ kind = (ThemeButtonKind) 0;
} else {
- *width = 11;
- return kThemeIncDecButtonMini;
+ if (height >= 21) {
+ *width = 13;
+ kind = kThemeIncDecButton;
+ } else if (height >= 18) {
+ *width = 12;
+ kind = kThemeIncDecButtonSmall;
+ } else {
+ *width = 11;
+ kind = kThemeIncDecButtonMini;
+ }
}
- } else
-#endif
- {
+ ) TK_ELSE_MAC_OS_X (3,
if (height < 21 || height > 28) {
*width = 0;
- return (ThemeButtonKind) 0;
+ kind = (ThemeButtonKind) 0;
+ } else {
+ *width = 13;
+ kind = kThemeIncDecButton;
}
- *width = 13;
- return kThemeIncDecButton;
- }
+ ) TK_ENDIF_MAC_OS_X
+
+ return kind;
}
/*
diff --git a/macosx/tkMacOSXEvent.c b/macosx/tkMacOSXEvent.c
index ab275ae..807bae5 100644
--- a/macosx/tkMacOSXEvent.c
+++ b/macosx/tkMacOSXEvent.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMacOSXEvent.c,v 1.3.2.12 2007/05/31 13:42:12 das Exp $
+ * RCS: @(#) $Id: tkMacOSXEvent.c,v 1.3.2.13 2007/06/06 09:56:54 das Exp $
*/
#include "tkMacOSXInt.h"
@@ -41,22 +41,15 @@ TkMacOSXFlushWindows(void)
WindowRef wRef = GetWindowList();
while (wRef) {
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
- if (1
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 1030
- && HIWindowFlush != NULL
-#endif
- ) {
+ TK_IF_MAC_OS_X_API (3, HIWindowFlush,
ChkErr(HIWindowFlush, wRef);
- } else
-#endif
- {
+ ) TK_ELSE_MAC_OS_X (3,
CGrafPtr portPtr = GetWindowPort(wRef);
if (QDIsPortBuffered(portPtr)) {
QDFlushPortBuffer(portPtr, NULL);
}
- }
+ ) TK_ENDIF_MAC_OS_X
wRef = GetNextWindow(wRef);
}
}
diff --git a/macosx/tkMacOSXInit.c b/macosx/tkMacOSXInit.c
index 524306e..e523582 100644
--- a/macosx/tkMacOSXInit.c
+++ b/macosx/tkMacOSXInit.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: tkMacOSXInit.c,v 1.3.2.21 2007/04/29 02:26:49 das Exp $
+ * RCS: @(#) $Id: tkMacOSXInit.c,v 1.3.2.22 2007/06/06 09:56:54 das Exp $
*/
#include "tkMacOSXInt.h"
@@ -255,16 +255,10 @@ TkpInit(
OSStatus err = procNotFound;
ProcessSerialNumber psn = { 0, kCurrentProcess };
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
- if (1
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 1030
- && TransformProcessType != NULL
-#endif
- ) {
+ TK_IF_MAC_OS_X_API (3, TransformProcessType,
err = ChkErr(TransformProcessType, &psn,
kProcessTransformToForegroundApplication);
- }
-#endif
+ ) TK_ENDIF_MAC_OS_X
#if MAC_OSX_TK_USE_CPS_SPI
if (err != noErr) {
/*
diff --git a/macosx/tkMacOSXInt.h b/macosx/tkMacOSXInt.h
index ffc7bff..30cb431 100644
--- a/macosx/tkMacOSXInt.h
+++ b/macosx/tkMacOSXInt.h
@@ -10,7 +10,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.17 2007/05/09 12:57:46 das Exp $
+ * RCS: @(#) $Id: tkMacOSXInt.h,v 1.3.2.18 2007/06/06 09:56:54 das Exp $
*/
#ifndef _TKMACINT
@@ -81,7 +81,69 @@
#define kHIToolboxVersionNumber10_4 (219)
#endif
#ifndef kHIToolboxVersionNumber10_5
- #define kHIToolboxVersionNumber10_5 (291)
+ #define kHIToolboxVersionNumber10_5 (303)
+#endif
+/* Macros for Mac OS X API availability checking */
+#define TK_IF_MAC_OS_X_API(vers, symbol, ...) \
+ tk_if_mac_os_x_10_##vers(1, symbol, 1, __VA_ARGS__)
+#define TK_IF_MAC_OS_X_API_COND(vers, cond, symbol,...) \
+ tk_if_mac_os_x_10_##vers(cond, symbol, 1, __VA_ARGS__)
+#define TK_IF_MAC_OS_X_HI_TOOLBOX(vers, ...) \
+ tk_if_mac_os_x_10_##vers(1, &kHIToolboxVersionNumber, \
+ kHIToolboxVersionNumber >= kHIToolboxVersionNumber10_##vers, \
+ __VA_ARGS__)
+#define TK_ELSE_MAC_OS_X(vers, ...) \
+ tk_else_mac_os_x_10_##vers(__VA_ARGS__)
+#define TK_ENDIF_MAC_OS_X \
+ }
+/* Private helper macros to implement the API checking above */
+#define tk_if_mac_os_x_yes(cond, symbol, postcond, ...) \
+ if (cond) { __VA_ARGS__
+#define tk_else_mac_os_x_yes(...) \
+ } else {
+#define tk_if_mac_os_x_chk(cond, symbol, postcond, ...) \
+ if ((cond) && (symbol) != NULL && (postcond)) { __VA_ARGS__
+#define tk_else_mac_os_x_chk(...) \
+ } else { __VA_ARGS__
+#define tk_if_mac_os_x_no(cond, symbol, postcond, ...) \
+ if (0) {
+#define tk_else_mac_os_x_no(...) \
+ } else { __VA_ARGS__
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1030
+#define tk_if_mac_os_x_10_3 tk_if_mac_os_x_yes
+#define tk_else_mac_os_x_10_3 tk_else_mac_os_x_yes
+#else
+#define tk_if_mac_os_x_10_3 tk_if_mac_os_x_chk
+#define tk_else_mac_os_x_10_3 tk_else_mac_os_x_chk
+#endif
+#else
+#define tk_if_mac_os_x_10_3 tk_if_mac_os_x_no
+#define tk_else_mac_os_x_10_3 tk_else_mac_os_x_no
+#endif
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1040
+#define tk_if_mac_os_x_10_4 tk_if_mac_os_x_yes
+#define tk_else_mac_os_x_10_4 tk_else_mac_os_x_yes
+#else
+#define tk_if_mac_os_x_10_4 tk_if_mac_os_x_chk
+#define tk_else_mac_os_x_10_4 tk_else_mac_os_x_chk
+#endif
+#else
+#define tk_if_mac_os_x_10_4 tk_if_mac_os_x_no
+#define tk_else_mac_os_x_10_4 tk_else_mac_os_x_no
+#endif
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
+#define tk_if_mac_os_x_10_5 tk_if_mac_os_x_yes
+#define tk_else_mac_os_x_10_5 tk_else_mac_os_x_yes
+#else
+#define tk_if_mac_os_x_10_5 tk_if_mac_os_x_chk
+#define tk_else_mac_os_x_10_5 tk_else_mac_os_x_chk
+#endif
+#else
+#define tk_if_mac_os_x_10_5 tk_if_mac_os_x_no
+#define tk_else_mac_os_x_10_5 tk_else_mac_os_x_no
#endif
/*
diff --git a/macosx/tkMacOSXMouseEvent.c b/macosx/tkMacOSXMouseEvent.c
index a44118d..d557ffd 100644
--- a/macosx/tkMacOSXMouseEvent.c
+++ b/macosx/tkMacOSXMouseEvent.c
@@ -54,7 +54,7 @@
* software in accordance with the terms specified in this
* license.
*
- * RCS: @(#) $Id: tkMacOSXMouseEvent.c,v 1.6.2.19 2007/05/09 12:57:46 das Exp $
+ * RCS: @(#) $Id: tkMacOSXMouseEvent.c,v 1.6.2.20 2007/06/06 09:56:54 das Exp $
*/
#include "tkMacOSXInt.h"
@@ -600,19 +600,14 @@ GenerateMouseWheelEvent(MouseEventData * medPtr)
TkWindow *winPtr;
XEvent xEvent;
- if ((!TkpIsWindowFloating(medPtr->whichWin)
- && (medPtr->activeNonFloating != medPtr->whichWin))) {
+ dispPtr = TkGetDisplayList();
+ rootwin = Tk_IdToWindow(dispPtr->display, medPtr->window);
+ if (rootwin == NULL) {
tkwin = NULL;
} else {
- dispPtr = TkGetDisplayList();
- rootwin = Tk_IdToWindow(dispPtr->display, medPtr->window);
- if (rootwin == NULL) {
- tkwin = NULL;
- } else {
- tkwin = Tk_TopCoordsToWindow(rootwin,
- medPtr->local.h, medPtr->local.v,
- &xEvent.xbutton.x, &xEvent.xbutton.y);
- }
+ tkwin = Tk_TopCoordsToWindow(rootwin,
+ medPtr->local.h, medPtr->local.v,
+ &xEvent.xbutton.x, &xEvent.xbutton.y);
}
/*
diff --git a/macosx/tkMacOSXScale.c b/macosx/tkMacOSXScale.c
index 283255f..3673c8b 100644
--- a/macosx/tkMacOSXScale.c
+++ b/macosx/tkMacOSXScale.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: tkMacOSXScale.c,v 1.2.2.6 2007/04/29 02:26:50 das Exp $
+ * RCS: @(#) $Id: tkMacOSXScale.c,v 1.2.2.7 2007/06/06 09:56:54 das Exp $
*/
#include "tkMacOSXInt.h"
@@ -267,11 +267,7 @@ TkpDisplayScale(
&(macScalePtr->scaleHandle));
SetControlReference(macScalePtr->scaleHandle, (UInt32) scalePtr);
- /*
- * If we are foremost than make us active.
- */
-
- if (windowRef == FrontWindow()) {
+ if (IsWindowActive(windowRef)) {
macScalePtr->flags |= ACTIVE;
}
} else {
diff --git a/macosx/tkMacOSXScrlbr.c b/macosx/tkMacOSXScrlbr.c
index 4d2cb07..539f9f7 100644
--- a/macosx/tkMacOSXScrlbr.c
+++ b/macosx/tkMacOSXScrlbr.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: tkMacOSXScrlbr.c,v 1.5.2.12 2007/05/09 12:57:46 das Exp $
+ * RCS: @(#) $Id: tkMacOSXScrlbr.c,v 1.5.2.13 2007/06/06 09:56:54 das Exp $
*/
#include "tkMacOSXInt.h"
@@ -274,7 +274,6 @@ TkpDisplayScrollbar(
if (macScrollPtr->sbHandle == NULL) {
Rect r = {0, 0, 1, 1};
- WindowRef frontNonFloating;
windowRef = GetWindowFromPort(destPort);
CreateScrollBarControl(windowRef, &r, MIN_SCROLLBAR_VALUE +
@@ -283,13 +282,7 @@ TkpDisplayScrollbar(
MIN_SCROLLBAR_VALUE, true, NULL, &(macScrollPtr->sbHandle));
SetControlReference(macScrollPtr->sbHandle, (SInt32) scrollPtr);
- /*
- * If we are foremost then make us active.
- */
-
- frontNonFloating = ActiveNonFloatingWindow();
-
- if ((windowRef == FrontWindow()) || TkpIsWindowFloating(windowRef)) {
+ if (IsWindowActive(windowRef)) {
macScrollPtr->macFlags |= ACTIVE;
}
}
diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c
index 17aab68..d039109 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.7.2.39 2007/06/04 09:28:45 das Exp $
+ * RCS: @(#) $Id: tkMacOSXWm.c,v 1.7.2.40 2007/06/06 09:56:54 das Exp $
*/
#include "tkMacOSXInt.h"
@@ -808,17 +808,9 @@ static int WmSetAttribute(
err = ChkErr(FSPathMakeRef, (const unsigned char*) path, &ref,
&d);
if (err == noErr) {
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040
- if (1
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 1040
- && HIWindowSetProxyFSRef != NULL
-#endif
- ) {
+ TK_IF_MAC_OS_X_API (4, HIWindowSetProxyFSRef,
err = ChkErr(HIWindowSetProxyFSRef, macWindow, &ref);
- } else
-#endif
- {
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 1040
+ ) TK_ELSE_MAC_OS_X (4,
AliasHandle alias;
err = ChkErr(FSNewAlias, NULL, &ref, &alias);
@@ -827,8 +819,7 @@ static int WmSetAttribute(
alias);
DisposeHandle((Handle) alias);
}
-#endif
- }
+ ) TK_ENDIF_MAC_OS_X
}
} else {
int len;
@@ -875,12 +866,7 @@ static int WmSetAttribute(
if (boolean) {
wmPtr->flags |= WM_TRANSPARENT;
wmPtr->attributes |= kWindowNoShadowAttribute;
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
- if (1
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 1030
- && HIWindowChangeFeatures != NULL
-#endif
- ) {
+ TK_IF_MAC_OS_X_API (3, HIWindowChangeFeatures,
UInt32 features;
ChkErr(GetWindowFeatures, macWindow, &features);
@@ -888,8 +874,7 @@ static int WmSetAttribute(
ChkErr(HIWindowChangeFeatures, macWindow, 0,
kWindowIsOpaque);
}
- }
-#endif
+ ) TK_ENDIF_MAC_OS_X
} else {
wmPtr->flags &= ~WM_TRANSPARENT;
wmPtr->attributes &= ~kWindowNoShadowAttribute;
@@ -950,17 +935,9 @@ static Tcl_Obj *WmGetAttribute(
UInt8 path[PATH_MAX+1];
OSStatus err;
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040
- if (1
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 1040
- && HIWindowSetProxyFSRef != NULL
-#endif
- ) {
+ TK_IF_MAC_OS_X_API (4, HIWindowSetProxyFSRef,
err = ChkErr(HIWindowGetProxyFSRef, macWindow, &ref);
- } else
-#endif
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 1040
- {
+ ) TK_ELSE_MAC_OS_X (4,
Boolean wasChanged;
AliasHandle alias;
@@ -969,8 +946,7 @@ static Tcl_Obj *WmGetAttribute(
err = ChkErr(FSResolveAlias, NULL, alias, &ref,
&wasChanged);
}
- }
-#endif
+ ) TK_ENDIF_MAC_OS_X
if (err == noErr) {
err = ChkErr(FSRefMakePath, &ref, path, PATH_MAX);
}
@@ -5790,8 +5766,7 @@ TkWmStackorderToplevel(parentPtr)
goto done;
}
- frontWindow = (WindowRef) FrontWindow();
-
+ frontWindow = GetFrontWindowOfClass(kAllWindowClasses, false);
if (frontWindow == NULL) {
ckfree((char *) windows);
windows = NULL;
@@ -5800,11 +5775,11 @@ TkWmStackorderToplevel(parentPtr)
*window_ptr-- = NULL;
while (frontWindow != NULL) {
hPtr = Tcl_FindHashEntry(&table, (char *) frontWindow);
- if (hPtr != NULL) {
- childWinPtr = (TkWindow *) Tcl_GetHashValue(hPtr);
- *window_ptr-- = childWinPtr;
- }
- frontWindow = GetNextWindow(frontWindow);
+ if (hPtr != NULL) {
+ childWinPtr = (TkWindow *) Tcl_GetHashValue(hPtr);
+ *window_ptr-- = childWinPtr;
+ }
+ frontWindow = GetNextWindow(frontWindow);
}
if (window_ptr != (windows-1))
Tcl_Panic("num matched toplevel windows does not equal num "
@@ -5865,16 +5840,12 @@ ApplyWindowClassAttributeChanges(
macWindow = GetWindowFromPort(TkMacOSXGetDrawablePort(
winPtr->window));
}
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
- if (wmPtr->macClass != oldClass
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 1030
- && HIWindowChangeClass != NULL
-#endif
- ) {
- ChkErr(HIWindowChangeClass, macWindow, wmPtr->macClass);
+ if (wmPtr->macClass != oldClass) {
+ TK_IF_MAC_OS_X_API (4, HIWindowChangeClass,
+ ChkErr(HIWindowChangeClass, macWindow, wmPtr->macClass);
+ ) TK_ENDIF_MAC_OS_X
ChkErr(GetWindowClass, macWindow, &(wmPtr->macClass));
}
-#endif
if (newAttributes != oldAttributes) {
newAttributes &= GetAvailableWindowAttributes(wmPtr->macClass);
ChkErr(ChangeWindowAttributes, macWindow,
@@ -6096,20 +6067,12 @@ TkMacOSXEnterExitFullscreen(
static SystemUIOptions fullscreenOptions = 0;
if (!fullscreenMode) {
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
- if (1
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 1030
- && &kHIToolboxVersionNumber != NULL
- && kHIToolboxVersionNumber >= kHIToolboxVersionNumber10_3
-#endif
- ) {
+ TK_IF_MAC_OS_X_HI_TOOLBOX (3,
fullscreenMode = kUIModeAllSuppressed;
- } else
-#endif
- {
+ ) TK_ELSE_MAC_OS_X (3,
fullscreenMode = kUIModeAllHidden;
fullscreenOptions = kUIOptionAutoShowMenuBar;
- }
+ ) TK_ENDIF_MAC_OS_X
}
if (mode != fullscreenMode) {
ChkErr(SetSystemUIMode, fullscreenMode, fullscreenOptions);