diff options
-rw-r--r-- | ChangeLog | 30 | ||||
-rw-r--r-- | macosx/Wish.xcodeproj/project.pbxproj | 6 | ||||
-rw-r--r-- | macosx/tkMacOSXColor.c | 62 | ||||
-rw-r--r-- | macosx/tkMacOSXDraw.c | 157 | ||||
-rw-r--r-- | macosx/tkMacOSXEntry.c | 51 | ||||
-rw-r--r-- | macosx/tkMacOSXEvent.c | 15 | ||||
-rw-r--r-- | macosx/tkMacOSXInit.c | 12 | ||||
-rw-r--r-- | macosx/tkMacOSXInt.h | 66 | ||||
-rw-r--r-- | macosx/tkMacOSXMouseEvent.c | 19 | ||||
-rw-r--r-- | macosx/tkMacOSXScale.c | 8 | ||||
-rw-r--r-- | macosx/tkMacOSXScrlbr.c | 11 | ||||
-rw-r--r-- | macosx/tkMacOSXWm.c | 81 |
12 files changed, 254 insertions, 264 deletions
@@ -1,3 +1,31 @@ +2007-06-06 Daniel Steffen <das@users.sourceforge.net> + + * 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. + + * macosx/Wish.xcodeproj/project.pbxproj: add settings for Fix&Continue. + + * unix/configure.in (Darwin): link the Tk and Wish plists into their + binaries in all cases; fix 64bit arch removal in fat 32&64bit builds. + + * unix/tcl.m4 (Darwin): fix CF checks in fat 32&64bit builds. + * unix/configure: autoconf-2.59 + 2007-06-05 Donal K. Fellows <donal.k.fellows@man.ac.uk> * doc/photo.n: Clarified the fact that base64 support for the -data @@ -51,7 +79,7 @@ to native button drawing calls. * macosx/tkMacOSXWm.c (TkMacOSXIsWindowZoomed, TkMacOSXZoomToplevel): - correct handle gridded windows in max size calculations. + correct handling of gridded windows in max size calculations. * macosx/tkMacOSXEvent.c (TkMacOSXFlushWindows): use HIWindowFlush API when available. diff --git a/macosx/Wish.xcodeproj/project.pbxproj b/macosx/Wish.xcodeproj/project.pbxproj index 947e17c..dacd1a7 100644 --- a/macosx/Wish.xcodeproj/project.pbxproj +++ b/macosx/Wish.xcodeproj/project.pbxproj @@ -1779,7 +1779,7 @@ F966C06F08F281DC005CB29B /* Frameworks */, 1AB674ADFE9D54B511CA2CBB /* Products */, ); - comments = "Copyright (c) 2004-2007 Daniel A. Steffen <das@users.sourceforge.net>\n\nSee the file \"license.terms\" for information on usage and redistribution of\nthis file, and for a DISCLAIMER OF ALL WARRANTIES.\n\nRCS: @(#) $Id: project.pbxproj,v 1.22 2007/05/27 01:24:54 das Exp $\n"; + comments = "Copyright (c) 2004-2007 Daniel A. Steffen <das@users.sourceforge.net>\n\nSee the file \"license.terms\" for information on usage and redistribution of\nthis file, and for a DISCLAIMER OF ALL WARRANTIES.\n\nRCS: @(#) $Id: project.pbxproj,v 1.23 2007/06/06 09:55:53 das Exp $\n"; name = Wish; path = .; sourceTree = SOURCE_ROOT; @@ -3570,7 +3570,7 @@ hasScannedForEncodings = 1; mainGroup = 08FB7794FE84155DC02AAC07 /* Wish */; projectDirPath = ""; - projectRoot = ""; + projectRoot = ..; targets = ( F9E61D16090A3E94002B3151 /* Tk */, 8DD76FA90486AB0100D96B5E /* tktest */, @@ -4045,11 +4045,13 @@ isa = XCBuildConfiguration; buildSettings = { CONFIGURE_ARGS = "tcl_cv_cc_visibility_hidden=no $(CONFIGURE_ARGS)"; + GCC_DYNAMIC_NO_PIC = NO; GCC_ENABLE_FIX_AND_CONTINUE = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "__private_extern__=extern", "$(GCC_PREPROCESSOR_DEFINITIONS)", ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; PRODUCT_NAME = tktest; ZERO_LINK = YES; }; diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c index c8944e4..7355356 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.9 2007/05/31 13:38:13 das Exp $ + * RCS: @(#) $Id: tkMacOSXColor.c,v 1.10 2007/06/06 09:55:52 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 42792b1..0ea1b1a 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.24 2007/06/03 13:44:39 das Exp $ + * RCS: @(#) $Id: tkMacOSXDraw.c,v 1.25 2007/06/06 09:55:52 das Exp $ */ #include "tkMacOSXInt.h" @@ -39,7 +39,7 @@ RgnHandle tkMacOSXtmpRgn1 = NULL; RgnHandle tkMacOSXtmpRgn2 = NULL; -static PixPatHandle gPenPat = NULL; +static PixPatHandle penPat = NULL; static int useCGDrawing = 1; static int tkMacOSXCGAntiAliasLimit = 0; @@ -52,6 +52,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); /* @@ -205,13 +206,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) { @@ -235,9 +233,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); @@ -300,13 +298,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; @@ -414,13 +409,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; @@ -1009,17 +1001,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)); @@ -1034,7 +1019,7 @@ XDrawArc( CGContextAddPath(dc.context, p); CGPathRelease(p); CGContextStrokePath(dc.context); - } + ) TK_ENDIF_MAC_OS_X } else { Rect theRect; short start, extent; @@ -1104,16 +1089,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), @@ -1132,7 +1111,7 @@ XDrawArcs( CGContextAddPath(dc.context, p); CGPathRelease(p); CGContextStrokePath(dc.context); - } + ) TK_ENDIF_MAC_OS_X } } else { Rect theRect; @@ -1202,16 +1181,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)); @@ -1230,7 +1203,7 @@ XFillArc( CGContextAddPath(dc.context, p); CGPathRelease(p); CGContextFillPath(dc.context); - } + ) TK_ENDIF_MAC_OS_X } else { Rect theRect; short start, extent; @@ -1326,17 +1299,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), @@ -1359,7 +1325,7 @@ XFillArcs( CGContextAddPath(dc.context, p); CGPathRelease(p); CGContextFillPath(dc.context); - } + ) TK_ENDIF_MAC_OS_X } } else { Rect theRect; @@ -1477,11 +1443,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 { @@ -1551,11 +1517,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); } @@ -1650,20 +1616,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); @@ -1756,12 +1718,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) @@ -1925,6 +1887,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 5d19ca3..38c35f4 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.9 2007/06/03 13:44:40 das Exp $ + * RCS: @(#) $Id: tkMacOSXEntry.c,v 1.10 2007/06/06 09:55:52 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 77d3cb5..7542975 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.18 2007/05/31 13:38:13 das Exp $ + * RCS: @(#) $Id: tkMacOSXEvent.c,v 1.19 2007/06/06 09:55:52 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 0e9fe8d..f1990bd 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.29 2007/06/04 09:27:33 das Exp $ + * RCS: @(#) $Id: tkMacOSXInit.c,v 1.30 2007/06/06 09:55:52 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 a6e7b86..2b7da1b 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.24 2007/05/09 12:55:15 das Exp $ + * RCS: @(#) $Id: tkMacOSXInt.h,v 1.25 2007/06/06 09:55:52 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 782ca69..1fa8388 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.29 2007/05/09 12:55:15 das Exp $ + * RCS: @(#) $Id: tkMacOSXMouseEvent.c,v 1.30 2007/06/06 09:55:52 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 f0fca13..1efe10e 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.11 2007/04/23 21:24:34 das Exp $ + * RCS: @(#) $Id: tkMacOSXScale.c,v 1.12 2007/06/06 09:55:52 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 8e1148e..6197672 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.22 2007/05/09 12:55:16 das Exp $ + * RCS: @(#) $Id: tkMacOSXScrlbr.c,v 1.23 2007/06/06 09:55:52 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 f4bba1f..96d423a 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.52 2007/06/03 13:44:40 das Exp $ + * RCS: @(#) $Id: tkMacOSXWm.c,v 1.53 2007/06/06 09:55:52 das Exp $ */ #include "tkMacOSXInt.h" @@ -804,17 +804,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); @@ -823,8 +815,7 @@ static int WmSetAttribute( alias); DisposeHandle((Handle) alias); } -#endif - } + ) TK_ENDIF_MAC_OS_X } } else { int len; @@ -871,12 +862,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); @@ -884,8 +870,7 @@ static int WmSetAttribute( ChkErr(HIWindowChangeFeatures, macWindow, 0, kWindowIsOpaque); } - } -#endif + ) TK_ENDIF_MAC_OS_X } else { wmPtr->flags &= ~WM_TRANSPARENT; wmPtr->attributes &= ~kWindowNoShadowAttribute; @@ -944,17 +929,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; @@ -963,8 +940,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); } @@ -5784,8 +5760,7 @@ TkWmStackorderToplevel(parentPtr) goto done; } - frontWindow = (WindowRef) FrontWindow(); - + frontWindow = GetFrontWindowOfClass(kAllWindowClasses, false); if (frontWindow == NULL) { ckfree((char *) windows); windows = NULL; @@ -5794,11 +5769,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 " @@ -5859,16 +5834,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, @@ -6090,20 +6061,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); |