diff options
Diffstat (limited to 'macosx')
54 files changed, 666 insertions, 423 deletions
diff --git a/macosx/GNUmakefile b/macosx/GNUmakefile index 1699201..333961c 100644 --- a/macosx/GNUmakefile +++ b/macosx/GNUmakefile @@ -9,8 +9,6 @@ # See the file "license.terms" for information on usage and redistribution of # this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: GNUmakefile,v 1.12 2008/10/23 12:20:16 das Exp $ -# ######################################################################################################## #------------------------------------------------------------------------------------------------------- diff --git a/macosx/README b/macosx/README index 650fcef..f58184c 100644 --- a/macosx/README +++ b/macosx/README @@ -1,11 +1,8 @@ Tcl/Tk Mac OS X README ---------------------- -RCS: @(#) $Id: README,v 1.31 2011/01/04 22:36:58 wordtech Exp $ - This is the README file for the Mac OS X/Darwin version of Tcl/Tk. - 1. Where to go for support -------------------------- @@ -19,16 +16,11 @@ before asking on the list, many questions have already been answered). http://groups.google.com/group/comp.lang.tcl/ - The Tcl'ers Wiki also has many pages dealing with Tcl & Tk on Mac OS X, see - http://wiki.tcl.tk/references/3753! - http://wiki.tcl.tk/references/8361! + http://wiki.tcl.tk/_/ref?N=3753 + http://wiki.tcl.tk/_/ref?N=8361 - Please report bugs with Tcl or Tk on Mac OS X to the sourceforge bug trackers: - Tcl: http://sf.net/tracker/?func=add&group_id=10894&atid=110894 - Tk: http://sf.net/tracker/?func=add&group_id=12997&atid=112997 -please make sure that your report Tk specific bugs to the tktoolkit project bug -tracker rather than the tcl project bug tracker. -Mac OS X specific bugs should in general be assigned to user 'das'. - + http://tcl.sourceforge.net/ 2. Using Tcl/Tk on Mac OS X --------------------------- diff --git a/macosx/Tk-Common.xcconfig b/macosx/Tk-Common.xcconfig index 0589a68..0d6e474 100644 --- a/macosx/Tk-Common.xcconfig +++ b/macosx/Tk-Common.xcconfig @@ -9,9 +9,6 @@ // // See the file "license.terms" for information on usage and redistribution // of this file, and for a DISCLAIMER OF ALL WARRANTIES. -// -// RCS: @(#) $Id: Tk-Common.xcconfig,v 1.1 2009/06/29 14:35:01 das Exp $ -// HEADER_SEARCH_PATHS = $(TK_SRCROOT)/generic $(TK_SRCROOT)/xlib "$(DERIVED_FILE_DIR)/tcl" "$(DERIVED_FILE_DIR)/tk" $(HEADER_SEARCH_PATHS) REZ_SEARCH_PATHS = $(TK_SRCROOT)/generic $(TCL_SRCROOT)/generic $(REZ_SEARCH_PATHS) diff --git a/macosx/Tk-Debug.xcconfig b/macosx/Tk-Debug.xcconfig index 74fa22e..2382661 100644 --- a/macosx/Tk-Debug.xcconfig +++ b/macosx/Tk-Debug.xcconfig @@ -8,9 +8,6 @@ // // See the file "license.terms" for information on usage and redistribution // of this file, and for a DISCLAIMER OF ALL WARRANTIES. -// -// RCS: @(#) $Id: Tk-Debug.xcconfig,v 1.1 2009/06/29 14:35:01 das Exp $ -// #include "Tk-Common.xcconfig" diff --git a/macosx/Tk-Info.plist.in b/macosx/Tk-Info.plist.in index 37a76d4..50b9d24 100644 --- a/macosx/Tk-Info.plist.in +++ b/macosx/Tk-Info.plist.in @@ -6,8 +6,6 @@ See the file "license.terms" for information on usage and redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. - - RCS: @(#) $Id: Tk-Info.plist.in,v 1.4 2009/06/29 14:35:01 das Exp $ --> <plist version="1.0"> <dict> diff --git a/macosx/Tk-Release.xcconfig b/macosx/Tk-Release.xcconfig index fca5f6c..505373c 100644 --- a/macosx/Tk-Release.xcconfig +++ b/macosx/Tk-Release.xcconfig @@ -8,9 +8,6 @@ // // See the file "license.terms" for information on usage and redistribution // of this file, and for a DISCLAIMER OF ALL WARRANTIES. -// -// RCS: @(#) $Id: Tk-Release.xcconfig,v 1.1 2009/06/29 14:35:01 das Exp $ -// #include "Tk-Common.xcconfig" diff --git a/macosx/Tk.xcode/project.pbxproj b/macosx/Tk.xcode/project.pbxproj index f80a204..70c2472 100644 --- a/macosx/Tk.xcode/project.pbxproj +++ b/macosx/Tk.xcode/project.pbxproj @@ -2114,7 +2114,7 @@ F966C06F08F281DC005CB29B /* Frameworks */, 1AB674ADFE9D54B511CA2CBB /* Products */, ); - comments = "Copyright (c) 2004-2009 Daniel A. Steffen <das@users.sourceforge.net>\nCopyright 2008-2009, Apple Inc.\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.2 2009/08/24 00:57:20 das Exp $\n"; + comments = "Copyright (c) 2004-2009 Daniel A. Steffen <das@users.sourceforge.net>\nCopyright 2008-2009, Apple Inc.\n\nSee the file \"license.terms\" for information on usage and redistribution of\nthis file, and for a DISCLAIMER OF ALL WARRANTIES.\n"; name = Tk; path = .; sourceTree = SOURCE_ROOT; diff --git a/macosx/Tk.xcodeproj/project.pbxproj b/macosx/Tk.xcodeproj/project.pbxproj index c9a3212..dcfe9fb 100644 --- a/macosx/Tk.xcodeproj/project.pbxproj +++ b/macosx/Tk.xcodeproj/project.pbxproj @@ -2114,7 +2114,7 @@ F966C06F08F281DC005CB29B /* Frameworks */, 1AB674ADFE9D54B511CA2CBB /* Products */, ); - comments = "Copyright (c) 2004-2009 Daniel A. Steffen <das@users.sourceforge.net>\nCopyright 2008-2009, Apple Inc.\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.3 2009/08/25 23:50:19 das Exp $\n"; + comments = "Copyright (c) 2004-2009 Daniel A. Steffen <das@users.sourceforge.net>\nCopyright 2008-2009, Apple Inc.\n\nSee the file \"license.terms\" for information on usage and redistribution of\nthis file, and for a DISCLAIMER OF ALL WARRANTIES.\n"; name = Tk; path = .; sourceTree = SOURCE_ROOT; diff --git a/macosx/Wish-Info.plist.in b/macosx/Wish-Info.plist.in index 31a4ea2..90e00a4 100644 --- a/macosx/Wish-Info.plist.in +++ b/macosx/Wish-Info.plist.in @@ -6,8 +6,6 @@ See the file "license.terms" for information on usage and redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. - - RCS: @(#) $Id: Wish-Info.plist.in,v 1.6 2009/08/24 00:57:20 das Exp $ --> <plist version="1.0"> <dict> diff --git a/macosx/Wish.sdef b/macosx/Wish.sdef index f388d7d..26d1ee8 100644 --- a/macosx/Wish.sdef +++ b/macosx/Wish.sdef @@ -7,8 +7,6 @@ See the file "license.terms" for information on usage and redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. - - RCS: @(#) $Id: Wish.sdef,v 1.1 2009/08/24 00:57:20 das Exp $ --> <dictionary title="Wish Terminology"> <suite name="Standard Suite" code="reqd" description="Common commands for all applications."> diff --git a/macosx/configure.ac b/macosx/configure.ac index 9054e4a..229af64 100644 --- a/macosx/configure.ac +++ b/macosx/configure.ac @@ -2,8 +2,6 @@ dnl This file is an input file used by the GNU "autoconf" program to dnl generate the file "configure", which is run during Tk installation dnl to configure the system for the local environment. -# -# RCS: @(#) $Id: configure.ac,v 1.1 2005/11/27 02:36:14 das Exp $ dnl Ensure that the config (auto)headers support is used, then just dnl include the configure sources from ../unix: diff --git a/macosx/tkMacOSX.h b/macosx/tkMacOSX.h index 95eafd1..05ea6c2 100644 --- a/macosx/tkMacOSX.h +++ b/macosx/tkMacOSX.h @@ -9,8 +9,6 @@ * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * RCS: @(#) $Id: tkMacOSX.h,v 1.6 2009/06/29 14:35:01 das Exp $ */ #ifndef _TKMAC diff --git a/macosx/tkMacOSXBitmap.c b/macosx/tkMacOSXBitmap.c index ce16da4..0c94712 100644 --- a/macosx/tkMacOSXBitmap.c +++ b/macosx/tkMacOSXBitmap.c @@ -9,8 +9,6 @@ * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * RCS: @(#) $Id: tkMacOSXBitmap.c,v 1.12 2009/07/18 06:55:10 das Exp $ */ #include "tkMacOSXPrivate.h" diff --git a/macosx/tkMacOSXButton.c b/macosx/tkMacOSXButton.c index a033990..036624d 100644 --- a/macosx/tkMacOSXButton.c +++ b/macosx/tkMacOSXButton.c @@ -10,8 +10,6 @@ * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * RCS: @(#) $Id: tkMacOSXButton.c,v 1.37 2010/02/18 22:31:31 nijtmans Exp $ */ #include "tkMacOSXPrivate.h" @@ -578,6 +576,15 @@ ComputeNativeButtonGeometry( [button setImagePosition:pos]; } + // if font is too tall, we can't use the fixed-height rounded bezel + if (!haveImage && haveText && style == NSRoundedBezelStyle) { + Tk_FontMetrics fm; + Tk_GetFontMetrics(butPtr->tkfont, &fm); + if (fm.linespace > 18) { + [button setBezelStyle:(style = NSShadowlessSquareBezelStyle)]; + } + } + bounds.size = [cell cellSize]; if (haveText) { titleRect = [cell titleRectForBounds:bounds]; diff --git a/macosx/tkMacOSXClipboard.c b/macosx/tkMacOSXClipboard.c index 333ed34..92d6590 100644 --- a/macosx/tkMacOSXClipboard.c +++ b/macosx/tkMacOSXClipboard.c @@ -9,8 +9,6 @@ * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * RCS: @(#) $Id: tkMacOSXClipboard.c,v 1.16 2009/07/06 20:29:21 dkf Exp $ */ #include "tkMacOSXPrivate.h" @@ -163,7 +161,7 @@ TkSelGetSelection( *---------------------------------------------------------------------- */ -void +int XSetSelectionOwner( Display *display, /* X Display. */ Atom selection, /* What selection to own. */ @@ -180,6 +178,7 @@ XSetSelectionOwner( changeCount = [pb declareTypes:[NSArray array] owner:NSApp]; } } + return Success; } /* diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c index 5906ced..3380087 100644 --- a/macosx/tkMacOSXColor.c +++ b/macosx/tkMacOSXColor.c @@ -12,8 +12,6 @@ * * 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.17 2009/07/06 20:29:21 dkf Exp $ */ #include "tkMacOSXPrivate.h" @@ -268,13 +266,15 @@ GetThemeColor( break; } - *c = CGColorCreateGenericRGB(rgba[0], rgba[1], rgba[2], rgba[3]); + // this attempts to find something roughly fitting for any display +// *c = CGColorCreateGenericRGB(rgba[0], rgba[1], rgba[2], rgba[3]); - /*static CGColorSpaceRef deviceRGBSpace = NULL; + // may be off for non-main display but in most cases better than prev + static CGColorSpaceRef deviceRGBSpace = NULL; if (!deviceRGBSpace) { deviceRGBSpace = CGDisplayCopyColorSpace(CGMainDisplayID()); } - *c = CGColorCreate(deviceRGBSpace, rgba );*/ + *c = CGColorCreate(deviceRGBSpace, rgba ); } return err; } @@ -608,7 +608,7 @@ TkpGetColor( } } - if (XParseColor(display, colormap, name, &color) == 0) { + if (TkParseColor(display, colormap, name, &color) == 0) { return NULL; } @@ -699,14 +699,15 @@ XCreateColormap( return index++; } -void +int XFreeColormap( Display* display, /* Display. */ Colormap colormap) /* Colormap. */ { + return Success; } -void +int XFreeColors( Display* display, /* Display. */ Colormap colormap, /* Colormap. */ @@ -719,6 +720,7 @@ XFreeColors( * needs to be done to release colors as there really is * no colormap in the Tk sense. */ + return Success; } /* diff --git a/macosx/tkMacOSXConfig.c b/macosx/tkMacOSXConfig.c index 138cec1..bdfcb6e 100644 --- a/macosx/tkMacOSXConfig.c +++ b/macosx/tkMacOSXConfig.c @@ -9,8 +9,6 @@ * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * RCS: @(#) $Id: tkMacOSXConfig.c,v 1.6 2009/06/29 14:35:01 das Exp $ */ #include "tkInt.h" diff --git a/macosx/tkMacOSXCursor.c b/macosx/tkMacOSXCursor.c index 56ac364..a333adf 100644 --- a/macosx/tkMacOSXCursor.c +++ b/macosx/tkMacOSXCursor.c @@ -9,8 +9,6 @@ * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * RCS: @(#) $Id: tkMacOSXCursor.c,v 1.16 2009/07/06 20:29:21 dkf Exp $ */ #include "tkMacOSXPrivate.h" diff --git a/macosx/tkMacOSXCursors.h b/macosx/tkMacOSXCursors.h index 07ec6bd..2cf00fb 100644 --- a/macosx/tkMacOSXCursors.h +++ b/macosx/tkMacOSXCursors.h @@ -10,8 +10,6 @@ * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * RCS: @(#) $Id: tkMacOSXCursors.h,v 1.1 2009/06/29 14:35:01 das Exp $ */ static const unsigned char tkMacOSXCursors[][68] = { diff --git a/macosx/tkMacOSXDebug.c b/macosx/tkMacOSXDebug.c index df08d11..6009f09 100644 --- a/macosx/tkMacOSXDebug.c +++ b/macosx/tkMacOSXDebug.c @@ -9,8 +9,6 @@ * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * RCS: @(#) $Id: tkMacOSXDebug.c,v 1.23 2009/06/29 14:35:01 das Exp $ */ #include "tkMacOSXPrivate.h" diff --git a/macosx/tkMacOSXDebug.h b/macosx/tkMacOSXDebug.h index 8d5688e..ab37187 100644 --- a/macosx/tkMacOSXDebug.h +++ b/macosx/tkMacOSXDebug.h @@ -9,8 +9,6 @@ * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * RCS: @(#) $Id: tkMacOSXDebug.h,v 1.17 2009/06/29 14:35:01 das Exp $ */ #ifndef _TKMACDEBUG diff --git a/macosx/tkMacOSXDefault.h b/macosx/tkMacOSXDefault.h index f6cccdd..8565cdb 100644 --- a/macosx/tkMacOSXDefault.h +++ b/macosx/tkMacOSXDefault.h @@ -11,8 +11,6 @@ * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * RCS: @(#) $Id: tkMacOSXDefault.h,v 1.18 2009/06/29 14:35:01 das Exp $ */ #ifndef _TKMACDEFAULT diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c index e1f0fd8..23b3de5 100644 --- a/macosx/tkMacOSXDialog.c +++ b/macosx/tkMacOSXDialog.c @@ -9,8 +9,6 @@ * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * RCS: @(#) $Id: tkMacOSXDialog.c,v 1.49 2010/06/15 12:40:07 nijtmans Exp $ */ #include "tkMacOSXPrivate.h" @@ -35,11 +33,13 @@ enum openOptions { }; static const char *const saveOptionStrings[] = { "-defaultextension", "-filetypes", "-initialdir", "-initialfile", - "-message", "-parent", "-title", "-typevariable", "-command", NULL + "-message", "-parent", "-title", "-typevariable", "-command", + "-confirmoverwrite", NULL }; enum saveOptions { SAVE_DEFAULT, SAVE_FILETYPES, SAVE_INITDIR, SAVE_INITFILE, SAVE_MESSAGE, SAVE_PARENT, SAVE_TITLE, SAVE_TYPEVARIABLE, SAVE_COMMAND, + SAVE_CONFIRMOW }; static const char *const chooseOptionStrings[] = { "-initialdir", "-message", "-mustexist", "-parent", "-title", "-command", @@ -536,6 +536,7 @@ Tk_GetSaveFileObjCmd( Tk_Window tkwin = clientData; char *str; int i, result = TCL_ERROR, haveParentOption = 0; + int confirmOverwrite = 1; int index, len; FileFilterList fl; Tcl_Obj *cmdObj = NULL; @@ -615,6 +616,12 @@ Tk_GetSaveFileObjCmd( case SAVE_COMMAND: cmdObj = objv[i+1]; break; + case SAVE_CONFIRMOW: + if (Tcl_GetBooleanFromObj(interp, objv[i + 1], + &confirmOverwrite) != TCL_OK) { + goto end; + } + break; } } if (fl.filters || defaultType) { diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index a867bf7..fd73b96 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -11,14 +11,13 @@ * * 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.37 2009/08/24 00:55:31 das Exp $ */ #include "tkMacOSXPrivate.h" #include "tkMacOSXDebug.h" #include "xbytes.h" + /* #ifdef TK_MAC_DEBUG #define TK_MAC_DEBUG_DRAWING @@ -312,7 +311,7 @@ XCopyPlane( *---------------------------------------------------------------------- */ -void +int TkPutImage( unsigned long *colors, /* Unused on Macintosh. */ int ncolors, /* Unused on Macintosh. */ @@ -331,7 +330,7 @@ TkPutImage( display->request++; if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) { - return; + return BadDrawable; } if (dc.context) { CGImageRef img = CreateCGImageWithXImage(image); @@ -349,6 +348,7 @@ TkPutImage( TkMacOSXDbgMsg("Invalid destination drawable"); } TkMacOSXRestoreDrawingContext(&dc); + return Success; } /* @@ -732,7 +732,8 @@ DrawCGImage( dstBounds.size.width, dstBounds.size.height); #else /* TK_MAC_DEBUG_IMAGE_DRAWING */ CGContextSaveGState(context); - CGContextTranslateCTM(context, 0, dstBounds.origin.y + CGRectGetMaxY(dstBounds)); + CGContextTranslateCTM(context, + 0, dstBounds.origin.y + CGRectGetMaxY(dstBounds)); CGContextScaleCTM(context, 1, -1); CGContextDrawImage(context, dstBounds, image); CGContextRestoreGState(context); @@ -764,7 +765,7 @@ DrawCGImage( *---------------------------------------------------------------------- */ -void +int XDrawLines( Display *display, /* Display. */ Drawable d, /* Draw on this. */ @@ -778,16 +779,12 @@ XDrawLines( int i, lw = gc->line_width; if (npoints < 2) { - /* - * TODO: generate BadValue error. - */ - - return; + return BadValue; } display->request++; if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) { - return; + return BadDrawable; } if (dc.context) { double prevx, prevy; @@ -811,6 +808,7 @@ XDrawLines( CGContextStrokePath(dc.context); } TkMacOSXRestoreDrawingContext(&dc); + return Success; } /* @@ -1049,7 +1047,7 @@ XDrawRectangles( *---------------------------------------------------------------------- */ -void +int XFillRectangles( Display* display, /* Display. */ Drawable d, /* Draw on this. */ @@ -1064,7 +1062,7 @@ XFillRectangles( display->request++; if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) { - return; + return BadDrawable; } if (dc.context) { CGRect rect; @@ -1081,6 +1079,7 @@ XFillRectangles( } } TkMacOSXRestoreDrawingContext(&dc); + return Success; } /* diff --git a/macosx/tkMacOSXEmbed.c b/macosx/tkMacOSXEmbed.c index f29d752..354a231 100644 --- a/macosx/tkMacOSXEmbed.c +++ b/macosx/tkMacOSXEmbed.c @@ -13,8 +13,6 @@ * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * RCS: @(#) $Id: tkMacOSXEmbed.c,v 1.20 2009/06/29 14:35:01 das Exp $ */ #include "tkMacOSXPrivate.h" @@ -159,7 +157,7 @@ TkpMakeWindow( macWin->xOff = 0; macWin->yOff = 0; macWin->toplevel = macWin; - } else { + } else if (winPtr->parentPtr) { macWin->xOff = winPtr->parentPtr->privatePtr->xOff + winPtr->parentPtr->changes.border_width + winPtr->changes.x; diff --git a/macosx/tkMacOSXEntry.c b/macosx/tkMacOSXEntry.c index 483f799..c103c6d 100644 --- a/macosx/tkMacOSXEntry.c +++ b/macosx/tkMacOSXEntry.c @@ -9,8 +9,6 @@ * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * RCS: @(#) $Id: tkMacOSXEntry.c,v 1.16 2009/06/29 14:35:01 das Exp $ */ #include "tkMacOSXPrivate.h" diff --git a/macosx/tkMacOSXEvent.c b/macosx/tkMacOSXEvent.c index d8d71d7..ea262ff 100644 --- a/macosx/tkMacOSXEvent.c +++ b/macosx/tkMacOSXEvent.c @@ -9,8 +9,6 @@ * * 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.27 2009/07/06 20:29:21 dkf Exp $ */ #include "tkMacOSXPrivate.h" diff --git a/macosx/tkMacOSXEvent.h b/macosx/tkMacOSXEvent.h index 621db75..46d1585 100644 --- a/macosx/tkMacOSXEvent.h +++ b/macosx/tkMacOSXEvent.h @@ -9,8 +9,6 @@ * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * RCS: @(#) $Id: tkMacOSXEvent.h,v 1.14 2009/06/29 14:35:01 das Exp $ */ #ifndef _TKMACEVENT diff --git a/macosx/tkMacOSXFont.c b/macosx/tkMacOSXFont.c index 5bd9265..e4e4e03 100644 --- a/macosx/tkMacOSXFont.c +++ b/macosx/tkMacOSXFont.c @@ -10,8 +10,6 @@ * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * RCS: @(#) $Id: tkMacOSXFont.c,v 1.48 2011/01/06 00:04:44 wordtech Exp $ */ #include "tkMacOSXPrivate.h" @@ -231,7 +229,7 @@ InitFont( NSRect bounds; CGFloat kern = 0.0; NSFontRenderingMode renderingMode = NSFontDefaultRenderingMode; - int ascent, descent, dontAA; + int ascent, descent/*, dontAA*/; static const UniChar ch[] = {'.', 'W', ' ', 0xc4, 0xc1, 0xc2, 0xc3, 0xc7}; /* ., W, Space, Auml, Aacute, Acirc, Atilde, Ccedilla */ #define nCh (sizeof(ch) / sizeof(UniChar)) @@ -246,9 +244,10 @@ InitFont( TkInitFontAttributes(faPtr); } fontPtr->nsFont = nsFont; - dontAA = [nsFont isFixedPitch] && fontPtr->font.fa.size <= 10; - if (antialiasedTextEnabled >= 0 || dontAA) { - renderingMode = (antialiasedTextEnabled == 0 || dontAA) ? + // some don't like antialiasing on fixed-width even if bigger than limit +// dontAA = [nsFont isFixedPitch] && fontPtr->font.fa.size <= 10; + if (antialiasedTextEnabled >= 0/* || dontAA*/) { + renderingMode = (antialiasedTextEnabled == 0/* || dontAA*/) ? NSFontIntegerAdvancementsRenderingMode : NSFontAntialiasedRenderingMode; } @@ -830,7 +829,7 @@ TkpMeasureCharsInContext( typesetter = CTTypesetterCreateWithAttributedString( (CFAttributedStringRef)attributedString); start = Tcl_NumUtfChars(source, rangeStart); - len = Tcl_NumUtfChars(source, rangeStart + rangeLength); + len = Tcl_NumUtfChars(source + rangeStart, rangeLength); if (start > 0) { range.length = start; line = CTTypesetterCreateLine(typesetter, range); @@ -849,13 +848,13 @@ TkpMeasureCharsInContext( index = start; if (flags & TK_WHOLE_WORDS) { - index = CTTypesetterSuggestLineBreak(typesetter, 0, maxWidth); + index = CTTypesetterSuggestLineBreak(typesetter, start, maxWidth); if (index <= start && (flags & TK_AT_LEAST_ONE)) { flags &= ~TK_WHOLE_WORDS; } } if (index <= start && !(flags & TK_WHOLE_WORDS)) { - index = CTTypesetterSuggestClusterBreak(typesetter, 0, maxWidth); + index = CTTypesetterSuggestClusterBreak(typesetter, start, maxWidth); } cs = (index < len || (flags & TK_WHOLE_WORDS)) ? whitespaceCharacterSet : lineendingCharacterSet; @@ -880,6 +879,17 @@ TkpMeasureCharsInContext( width = CTLineGetTypographicBounds(line, NULL, NULL, NULL); CFRelease(line); } + + /* The call to CTTypesetterSuggestClusterBreak above will always + return at least one character regardless of whether it exceeded + it or not. Clean that up now. */ + while (width > maxWidth && !(flags & TK_PARTIAL_OK) && index > start) { + range.length = --index; + line = CTTypesetterCreateLine(typesetter, range); + width = CTLineGetTypographicBounds(line, NULL, NULL, NULL); + CFRelease(line); + } + } CFRelease(typesetter); [attributedString release]; @@ -896,6 +906,7 @@ done: flags & TK_AT_LEAST_ONE ? "atLeastOne " : "", flags & TK_ISOLATE_END ? "isolateEnd " : "", length, fit); +//if (!(rangeLength==1 && rangeStart == 0)) fprintf(stderr, " measure len=%d (max=%d, w=%.0f) from %d (nb=%d): source=\"%s\": index=%d return %d\n",rangeLength,maxLength,width,rangeStart,numBytes, source+rangeStart, index, fit); #endif *lengthPtr = length; return fit; diff --git a/macosx/tkMacOSXFont.h b/macosx/tkMacOSXFont.h index 6f63f2e..08380c4 100644 --- a/macosx/tkMacOSXFont.h +++ b/macosx/tkMacOSXFont.h @@ -11,8 +11,6 @@ * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * RCS: @(#) $Id: tkMacOSXFont.h,v 1.7 2009/06/29 14:35:01 das Exp $ */ #ifndef TKMACOSXFONT_H diff --git a/macosx/tkMacOSXHLEvents.c b/macosx/tkMacOSXHLEvents.c index 11ac7e6..362f752 100644 --- a/macosx/tkMacOSXHLEvents.c +++ b/macosx/tkMacOSXHLEvents.c @@ -10,8 +10,6 @@ * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * RCS: @(#) $Id: tkMacOSXHLEvents.c,v 1.22 2009/08/24 00:56:00 das Exp $ */ #include "tkMacOSXPrivate.h" diff --git a/macosx/tkMacOSXInit.c b/macosx/tkMacOSXInit.c index e3d78ce..cd9b9e6 100644 --- a/macosx/tkMacOSXInit.c +++ b/macosx/tkMacOSXInit.c @@ -10,8 +10,6 @@ * * 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.41 2009/07/06 20:29:21 dkf Exp $ */ #include "tkMacOSXPrivate.h" diff --git a/macosx/tkMacOSXInt.h b/macosx/tkMacOSXInt.h index 6e289b9..813acce 100644 --- a/macosx/tkMacOSXInt.h +++ b/macosx/tkMacOSXInt.h @@ -9,8 +9,6 @@ * * 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.33 2009/06/29 14:35:01 das Exp $ */ #ifndef _TKMACINT diff --git a/macosx/tkMacOSXKeyEvent.c b/macosx/tkMacOSXKeyEvent.c index 051f291..1d24960 100644 --- a/macosx/tkMacOSXKeyEvent.c +++ b/macosx/tkMacOSXKeyEvent.c @@ -6,11 +6,10 @@ * * Copyright 2001-2009, Apple Inc. * Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net> + * Copyright (c) 2012 Adrian Robert. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * RCS: @(#) $Id: tkMacOSXKeyEvent.c,v 1.31 2011/01/24 15:20:50 wordtech Exp $ */ #include "tkMacOSXPrivate.h" @@ -21,6 +20,8 @@ #define TK_MAC_DEBUG_KEYBOARD #endif */ +#define NS_KEYLOG 0 + static Tk_Window grabWinPtr = NULL; /* Current grab window, NULL if no grab. */ @@ -28,9 +29,19 @@ static Tk_Window keyboardGrabWinPtr = NULL; /* Current keyboard grab window. */ static NSModalSession modalSession = NULL; +static BOOL processingCompose = NO; +static BOOL finishedCompose = NO; + +static int caret_x = 0, caret_y = 0, caret_height = 0; + +static void setupXEvent(XEvent *xEvent, NSWindow *w, unsigned int state); +static unsigned isFunctionKey(unsigned int code); + + #pragma mark TKApplication(TKKeyEvent) @implementation TKApplication(TKKeyEvent) + - (NSEvent *) tkProcessKeyEvent: (NSEvent *) theEvent { #ifdef TK_MAC_DEBUG_EVENTS @@ -38,24 +49,38 @@ static NSModalSession modalSession = NULL; #endif NSWindow* w; NSEventType type = [theEvent type]; - NSUInteger modifiers, len; + NSUInteger modifiers, len = 0; BOOL repeat = NO; unsigned short keyCode; NSString *characters = nil, *charactersIgnoringModifiers = nil; static NSUInteger savedModifiers = 0; + static NSMutableArray *nsEvArray; + + if (nsEvArray == nil) + { + nsEvArray = [[NSMutableArray alloc] initWithCapacity: 1]; + processingCompose = NO; + } switch (type) { case NSKeyUp: + if (finishedCompose) + { + // if we were composing, swallow the last release since we already sent + finishedCompose = NO; + return theEvent; + } case NSKeyDown: repeat = [theEvent isARepeat]; characters = [theEvent characters]; charactersIgnoringModifiers = [theEvent charactersIgnoringModifiers]; + len = [charactersIgnoringModifiers length]; case NSFlagsChanged: modifiers = [theEvent modifierFlags]; keyCode = [theEvent keyCode]; w = [self windowWithWindowNumber:[theEvent windowNumber]]; -#ifdef TK_MAC_DEBUG_EVENTS - TKLog(@"-[%@(%p) %s] %d %u %@ %@ %u %@", [self class], self, _cmd, repeat, modifiers, characters, charactersIgnoringModifiers, keyCode, w); +#if defined(TK_MAC_DEBUG_EVENTS) || NS_KEYLOG == 1 + NSLog(@"-[%@(%p) %s] r=%d mods=%u '%@' '%@' code=%u c=%d %@ %d", [self class], self, _cmd, repeat, modifiers, characters, charactersIgnoringModifiers, keyCode,([charactersIgnoringModifiers length] == 0) ? 0 : [charactersIgnoringModifiers characterAtIndex: 0], w, type); #endif break; @@ -63,122 +88,353 @@ static NSModalSession modalSession = NULL; return theEvent; } - unsigned int state = 0; + if (!processingCompose) { + unsigned int state = 0; - if (modifiers & NSAlphaShiftKeyMask) { - state |= LockMask; - } - if (modifiers & NSShiftKeyMask) { - state |= ShiftMask; - } - if (modifiers & NSControlKeyMask) { - state |= ControlMask; - } - if (modifiers & NSCommandKeyMask) { - state |= Mod1Mask; /* command key */ - } - if (modifiers & NSAlternateKeyMask) { - state |= Mod2Mask; /* option key */ - } - if (modifiers & NSNumericPadKeyMask) { - state |= Mod3Mask; - } - if (modifiers & NSFunctionKeyMask) { - state |= Mod4Mask; - } + if (modifiers & NSAlphaShiftKeyMask) { + state |= LockMask; + } + if (modifiers & NSShiftKeyMask) { + state |= ShiftMask; + } + if (modifiers & NSControlKeyMask) { + state |= ControlMask; + } + if (modifiers & NSCommandKeyMask) { + state |= Mod1Mask; /* command key */ + } + if (modifiers & NSAlternateKeyMask) { + state |= Mod2Mask; /* option key */ + } + if (modifiers & NSNumericPadKeyMask) { + state |= Mod3Mask; + } + if (modifiers & NSFunctionKeyMask) { + state |= Mod4Mask; + } - /* - * The focus must be in the FrontWindow on the Macintosh. We then query Tk - * to determine the exact Tk window that owns the focus. - */ + /* + * The focus must be in the FrontWindow on the Macintosh. We then query Tk + * to determine the exact Tk window that owns the focus. + */ - TkWindow *winPtr = TkMacOSXGetTkWindow(w); - Tk_Window tkwin = (Tk_Window) winPtr; + TkWindow *winPtr = TkMacOSXGetTkWindow(w); + Tk_Window tkwin = (Tk_Window) winPtr; - if (!tkwin) { - TkMacOSXDbgMsg("tkwin == NULL"); - return theEvent; - } - tkwin = (Tk_Window) winPtr->dispPtr->focusPtr; - if (!tkwin) { - TkMacOSXDbgMsg("tkwin == NULL"); - return theEvent; + if (!tkwin) { + TkMacOSXDbgMsg("tkwin == NULL"); + return theEvent; + } + tkwin = (Tk_Window) winPtr->dispPtr->focusPtr; + if (!tkwin) { + TkMacOSXDbgMsg("tkwin == NULL"); + return theEvent; + } + + /* + * If it's a function key, or we have modifiers other than Shift or Alt, + * pass it straight to Tk. Otherwise we'll send for input processing. + */ + int code = (len == 0) ? + 0 : [charactersIgnoringModifiers characterAtIndex: 0]; + if (type != NSKeyDown || isFunctionKey(code) + || (len > 0 && state & (ControlMask | Mod1Mask | Mod3Mask | Mod4Mask))) { + + XEvent xEvent; + setupXEvent(&xEvent, w, state); + + if (type == NSFlagsChanged) { + if (savedModifiers > modifiers) { + xEvent.xany.type = KeyRelease; + } else { + xEvent.xany.type = KeyPress; + } + + /* + * Use special '-1' to signify a special keycode to our platform + * specific code in tkMacOSXKeyboard.c. This is rather like what + * happens on Windows. + */ + + xEvent.xany.send_event = -1; + + /* + * Set keycode (which was zero) to the changed modifier + */ + + xEvent.xkey.keycode = (modifiers ^ savedModifiers); + } else { + if (type == NSKeyUp || repeat) { + xEvent.xany.type = KeyRelease; + } else { + xEvent.xany.type = KeyPress; + } + + /* For command key, take input manager's word so things + like dvorak / qwerty layout work. */ + if ((modifiers & NSCommandKeyMask) == NSCommandKeyMask + && (modifiers & NSAlternateKeyMask) != NSAlternateKeyMask + && len > 0 && !isFunctionKey(code)) { + // head off keycode-based translation in tkMacOSXKeyboard.c + xEvent.xkey.nbytes = [characters length]; //len + } + + if ([characters length] > 0) { + xEvent.xkey.keycode = + (keyCode << 16) | (UInt16) [characters characterAtIndex:0]; + if (![characters getCString:xEvent.xkey.trans_chars + maxLength:XMaxTransChars encoding:NSUTF8StringEncoding]) { + /* prevent SF bug 2907388 (crash on some composite chars) */ + //PENDING: we might not need this anymore + TkMacOSXDbgMsg("characters too long"); + return theEvent; + } + } + + if (repeat) { + Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL); + xEvent.xany.type = KeyPress; + xEvent.xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin)); + } + } + Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL); + savedModifiers = modifiers; + return theEvent; + } /* if send straight to TK */ + + } /* if not processing compose */ + + if (type == NSKeyDown) { + if (NS_KEYLOG) + fprintf (stderr, "keyDown: %s compose sequence.\n", + processingCompose == YES ? "Continue" : "Begin"); + processingCompose = YES; + [nsEvArray addObject: theEvent]; + [[w contentView] interpretKeyEvents: nsEvArray]; + [nsEvArray removeObject: theEvent]; + } + + savedModifiers = modifiers; + + return theEvent; +} +@end + + + +@implementation TKContentView(TKKeyEvent) +/* <NSTextInput> implementation (called through interpretKeyEvents:]). */ + +/* <NSTextInput>: called when done composing; + NOTE: also called when we delete over working text, followed immed. + by doCommandBySelector: deleteBackward: */ +- (void)insertText: (id)aString +{ + int i, len = [(NSString *)aString length]; + XEvent xEvent; + TkWindow *winPtr = TkMacOSXGetTkWindow([self window]); + Tk_Window tkwin = (Tk_Window) winPtr; + + if (NS_KEYLOG) + NSLog (@"insertText '%@'\tlen = %d", aString, len); + processingCompose = NO; + finishedCompose = YES; + + /* first, clear any working text */ + if (_workingText != nil) + [self deleteWorkingText]; + + /* now insert the string as keystrokes */ + setupXEvent(&xEvent, [self window], 0); + xEvent.xany.type = KeyPress; + + for (i =0; i<len; i++) + { + xEvent.xkey.keycode = (UInt16) [aString characterAtIndex: i]; + [[aString substringWithRange: NSMakeRange(i,1)] + getCString: xEvent.xkey.trans_chars + maxLength: XMaxTransChars encoding: NSUTF8StringEncoding]; + xEvent.xkey.nbytes = strlen(xEvent.xkey.trans_chars); + xEvent.xany.type = KeyPress; + Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL); + + xEvent.xany.type = KeyRelease; + xEvent.xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin)); + Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL); + xEvent.xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin)); } +} - XEvent xEvent; - - memset(&xEvent, 0, sizeof(XEvent)); - xEvent.xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin)); - xEvent.xany.send_event = false; - xEvent.xany.display = Tk_Display(tkwin); - xEvent.xany.window = Tk_WindowId(tkwin); - - xEvent.xkey.root = XRootWindow(Tk_Display(tkwin), 0); - xEvent.xkey.subwindow = None; - xEvent.xkey.time = TkpGetMS(); - xEvent.xkey.state = state; - xEvent.xkey.same_screen = true; - xEvent.xkey.trans_chars[0] = 0; - xEvent.xkey.nbytes = 0; - - if (type == NSFlagsChanged) { - if (savedModifiers > modifiers) { - xEvent.xany.type = KeyRelease; - } else { - xEvent.xany.type = KeyPress; - } - /* - * Use special '-1' to signify a special keycode to our platform - * specific code in tkMacOSXKeyboard.c. This is rather like what - * happens on Windows. - */ +/* <NSTextInput>: inserts display of composing characters */ +- (void)setMarkedText: (id)aString selectedRange: (NSRange)selRange +{ + NSString *str = [aString respondsToSelector: @selector (string)] ? + [aString string] : aString; + if (NS_KEYLOG) + NSLog (@"setMarkedText '%@' len =%d range %d from %d", str, [str length], + selRange.length, selRange.location); - xEvent.xany.send_event = -1; + if (_workingText != nil) + [self deleteWorkingText]; + if ([str length] == 0) + return; - /* - * Set keycode (which was zero) to the changed modifier - */ + processingCompose = YES; + _workingText = [str copy]; - xEvent.xkey.keycode = (modifiers ^ savedModifiers); - } else { - if (type == NSKeyUp || repeat) { - xEvent.xany.type = KeyRelease; - } else { - xEvent.xany.type = KeyPress; - } + //PENDING: insert workingText underlined +} -/* prevent SF bug 2907388 here (crash on composite characters) */ -if ([characters length] > 0) { - xEvent.xkey.keycode = (keyCode << 16) | (UInt16) - [characters characterAtIndex:0]; - if (![characters getCString:xEvent.xkey.trans_chars - maxLength:XMaxTransChars encoding:NSUTF8StringEncoding]) { - TkMacOSXDbgMsg("characters too long"); - return theEvent; - } + +/* delete display of composing characters [not in <NSTextInput>] */ +- (void)deleteWorkingText +{ + if (_workingText == nil) + return; + if (NS_KEYLOG) + NSLog(@"deleteWorkingText len = %d\n", [_workingText length]); + [_workingText release]; + _workingText = nil; + processingCompose = NO; + + //PENDING: delete working text } -/* end workaround */ - len = [charactersIgnoringModifiers length]; - if (len) { - xEvent.xkey.nbytes = [charactersIgnoringModifiers characterAtIndex:0]; - if (len > 1) { - TkMacOSXDbgMsg("more than one charactersIgnoringModifiers"); - } - } - if (repeat) { - Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL); - xEvent.xany.type = KeyPress; - xEvent.xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin)); - } + +- (BOOL)hasMarkedText +{ + return _workingText != nil; +} + + +- (NSRange)markedRange +{ + NSRange rng = _workingText != nil + ? NSMakeRange (0, [_workingText length]) : NSMakeRange (NSNotFound, 0); + if (NS_KEYLOG) + NSLog (@"markedRange request"); + return rng; +} + + +- (void)unmarkText +{ + if (NS_KEYLOG) + NSLog (@"unmark (accept) text"); + [self deleteWorkingText]; + processingCompose = NO; +} + + +/* used to position char selection windows, etc. */ +- (NSRect)firstRectForCharacterRange: (NSRange)theRange +{ + NSRect rect; + NSPoint pt; + + pt.x = caret_x; + pt.y = caret_y; + + pt = [self convertPoint: pt toView: nil]; + pt = [[self window] convertBaseToScreen: pt]; + pt.y -= caret_height; + + rect.origin = pt; + rect.size.width = caret_height; + rect.size.height = caret_height; + return rect; +} + + +- (NSInteger)conversationIdentifier +{ + return (NSInteger)self; +} + + +- (void)doCommandBySelector: (SEL)aSelector +{ + if (NS_KEYLOG) + NSLog (@"doCommandBySelector: %@", NSStringFromSelector (aSelector)); + processingCompose = NO; + if (aSelector == @selector (deleteBackward:)) + { + /* happens when user backspaces over an ongoing composition: + throw a 'delete' into the event queue */ + XEvent xEvent; + setupXEvent(&xEvent, [self window], 0); + xEvent.xany.type = KeyPress; + xEvent.xkey.nbytes = 1; + xEvent.xkey.keycode = (0x33 << 16) | 0x7F; + xEvent.xkey.trans_chars[0] = 0x7F; + xEvent.xkey.trans_chars[1] = 0x0; + Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL); } - Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL); - savedModifiers = modifiers; +} - return theEvent; + +- (NSArray *)validAttributesForMarkedText +{ + static NSArray *arr = nil; + if (arr == nil) arr = [NSArray new]; + /* [[NSArray arrayWithObject: NSUnderlineStyleAttributeName] retain]; */ + return arr; } + + +- (NSRange)selectedRange +{ + if (NS_KEYLOG) + NSLog (@"selectedRange request"); + return NSMakeRange (NSNotFound, 0); +} + + +- (NSUInteger)characterIndexForPoint: (NSPoint)thePoint +{ + if (NS_KEYLOG) + NSLog (@"characterIndexForPoint request"); + return 0; +} + + +- (NSAttributedString *)attributedSubstringFromRange: (NSRange)theRange +{ + static NSAttributedString *str = nil; + if (str == nil) str = [NSAttributedString new]; + if (NS_KEYLOG) + NSLog (@"attributedSubstringFromRange request"); + return str; +} +/* End <NSTextInput> impl. */ @end + + + +/* + * Set up basic fields in xevent for keyboard input. + */ +static void +setupXEvent(XEvent *xEvent, NSWindow *w, unsigned int state) +{ + TkWindow *winPtr = TkMacOSXGetTkWindow(w); + Tk_Window tkwin = (Tk_Window) winPtr; + + memset(xEvent, 0, sizeof(XEvent)); + xEvent->xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin)); + xEvent->xany.send_event = false; + xEvent->xany.display = Tk_Display(tkwin); + xEvent->xany.window = Tk_WindowId(tkwin); + + xEvent->xkey.root = XRootWindow(Tk_Display(tkwin), 0); + xEvent->xkey.subwindow = None; + xEvent->xkey.time = TkpGetMS(); + xEvent->xkey.state = state; + xEvent->xkey.same_screen = true; + xEvent->xkey.trans_chars[0] = 0; + xEvent->xkey.nbytes = 0; +} #pragma mark - @@ -345,9 +601,118 @@ Tk_SetCaretPos( int x, int y, int height) -{ + { + TkCaret *caretPtr = &(((TkWindow *) tkwin)->dispPtr->caret); + + /* + * Prevent processing anything if the values haven't changed. Windows only + * has one display, so we can do this with statics. + */ + + if ((caretPtr->winPtr == ((TkWindow *) tkwin)) + && (caretPtr->x == x) && (caretPtr->y == y)) { + return; + } + + caretPtr->winPtr = ((TkWindow *) tkwin); + caretPtr->x = x; + caretPtr->y = y; + caretPtr->height = height; + + /* + * As in Windows, adjust to the toplevel to get the coords right. + */ + + while (!Tk_IsTopLevel(tkwin)) { + x += Tk_X(tkwin); + y += Tk_Y(tkwin); + tkwin = Tk_Parent(tkwin); + if (tkwin == NULL) { + return; + } + } + + /* But adjust for fact that NS uses flipped view. */ + y = Tk_Height(tkwin) - y; + + caret_x = x; + caret_y = y; + caret_height = height; } + +static unsigned convert_ns_to_X_keysym[] = +{ + NSHomeFunctionKey, 0x50, + NSLeftArrowFunctionKey, 0x51, + NSUpArrowFunctionKey, 0x52, + NSRightArrowFunctionKey, 0x53, + NSDownArrowFunctionKey, 0x54, + NSPageUpFunctionKey, 0x55, + NSPageDownFunctionKey, 0x56, + NSEndFunctionKey, 0x57, + NSBeginFunctionKey, 0x58, + NSSelectFunctionKey, 0x60, + NSPrintFunctionKey, 0x61, + NSExecuteFunctionKey, 0x62, + NSInsertFunctionKey, 0x63, + NSUndoFunctionKey, 0x65, + NSRedoFunctionKey, 0x66, + NSMenuFunctionKey, 0x67, + NSFindFunctionKey, 0x68, + NSHelpFunctionKey, 0x6A, + NSBreakFunctionKey, 0x6B, + + NSF1FunctionKey, 0xBE, + NSF2FunctionKey, 0xBF, + NSF3FunctionKey, 0xC0, + NSF4FunctionKey, 0xC1, + NSF5FunctionKey, 0xC2, + NSF6FunctionKey, 0xC3, + NSF7FunctionKey, 0xC4, + NSF8FunctionKey, 0xC5, + NSF9FunctionKey, 0xC6, + NSF10FunctionKey, 0xC7, + NSF11FunctionKey, 0xC8, + NSF12FunctionKey, 0xC9, + NSF13FunctionKey, 0xCA, + NSF14FunctionKey, 0xCB, + NSF15FunctionKey, 0xCC, + NSF16FunctionKey, 0xCD, + NSF17FunctionKey, 0xCE, + NSF18FunctionKey, 0xCF, + NSF19FunctionKey, 0xD0, + NSF20FunctionKey, 0xD1, + NSF21FunctionKey, 0xD2, + NSF22FunctionKey, 0xD3, + NSF23FunctionKey, 0xD4, + NSF24FunctionKey, 0xD5, + + NSBackspaceCharacter, 0x08, /* 8: Not on some KBs. */ + NSDeleteCharacter, 0xFF, /* 127: Big 'delete' key upper right. */ + NSDeleteFunctionKey, 0x9F, /* 63272: Del forw key off main array. */ + + NSTabCharacter, 0x09, + 0x19, 0x09, /* left tab->regular since pass shift */ + NSCarriageReturnCharacter, 0x0D, + NSNewlineCharacter, 0x0D, + NSEnterCharacter, 0x8D, + + 0x1B, 0x1B /* escape */ +}; + + +static unsigned isFunctionKey(unsigned code) +{ + const unsigned last_keysym = (sizeof (convert_ns_to_X_keysym) + / sizeof (convert_ns_to_X_keysym[0])); + unsigned keysym; + for (keysym = 0; keysym < last_keysym; keysym += 2) + if (code == convert_ns_to_X_keysym[keysym]) + return 0xFF00 | convert_ns_to_X_keysym[keysym+1]; + return 0; + } + /* * Local Variables: * mode: objc diff --git a/macosx/tkMacOSXKeyboard.c b/macosx/tkMacOSXKeyboard.c index bd9d008..54f99d3 100644 --- a/macosx/tkMacOSXKeyboard.c +++ b/macosx/tkMacOSXKeyboard.c @@ -9,8 +9,6 @@ * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * RCS: @(#) $Id: tkMacOSXKeyboard.c,v 1.27 2009/12/16 22:00:30 nijtmans Exp $ */ #include "tkMacOSXPrivate.h" @@ -482,7 +480,7 @@ XGetModifierMapping( *---------------------------------------------------------------------- */ -void +int XFreeModifiermap( XModifierKeymap *modmap) { @@ -490,6 +488,7 @@ XFreeModifiermap( ckfree(modmap->modifiermap); } ckfree(modmap); + return Success; } /* @@ -768,11 +767,11 @@ TkpGetKeySym( } } -#if 0 + /* If nbytes has been set, it's not a function key, but a regular key that + has been translated in tkMacOSXKeyEvent.c; just use that. */ if (eventPtr->xkey.nbytes) { - return eventPtr->xkey.nbytes; + return eventPtr->xkey.keycode & 0xFFFF; } -#endif /* * Figure out which of the four slots in the keymap vector to use for this diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c index dcb4a3f..8054c57 100644 --- a/macosx/tkMacOSXMenu.c +++ b/macosx/tkMacOSXMenu.c @@ -6,11 +6,10 @@ * Copyright (c) 1996-1997 by Sun Microsystems, Inc. * Copyright 2001-2009, Apple Inc. * Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net> + * Copyright (c) 2012 Adrian Robert. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * RCS: @(#) $Id: tkMacOSXMenu.c,v 1.56 2011/01/06 08:05:05 wordtech Exp $ */ #include "tkMacOSXPrivate.h" @@ -253,6 +252,8 @@ static int ModifierCharWidth(Tk_Font tkfont); if (menuPtr && mePtr) { Tcl_Interp *interp = menuPtr->interp; + /*Add time for errors to fire if necessary. This is sub-optimal but avoids issues with Tcl/Cocoa event loop integration.*/ + Tcl_Sleep(100); Tcl_Preserve(interp); Tcl_Preserve(menuPtr); @@ -282,7 +283,8 @@ static int ModifierCharWidth(Tk_Font tkfont); - (BOOL) menuHasKeyEquivalent: (NSMenu *) menu forEvent: (NSEvent *) event target: (id *) target action: (SEL *) action { - NSString *key = [event charactersIgnoringModifiers]; + /*Use lowercaseString to keep "shift" from firing twice if bound to different procedure.*/ + NSString *key = [[event charactersIgnoringModifiers] lowercaseString]; NSUInteger modifiers = [event modifierFlags] & NSDeviceIndependentModifierFlagsMask; @@ -291,6 +293,12 @@ static int ModifierCharWidth(Tk_Font tkfont); return NO; } + // For command key, take input manager's word so things + // like dvorak / qwerty layout work. + if (([event modifierFlags] & NSCommandKeyMask) == NSCommandKeyMask) { + key = [event characters]; + } + NSArray *itemArray = [self itemArray]; for (NSMenuItem *item in itemArray) { @@ -344,8 +352,8 @@ static int ModifierCharWidth(Tk_Font tkfont); int result = TkPostCommand(_tkMenu); if (result!=TCL_OK && result!=TCL_CONTINUE && result!=TCL_BREAK) { - Tcl_AddErrorInfo(interp, "\n (menu preprocess)"); - Tcl_BackgroundException(interp, result); + Tcl_AddErrorInfo(interp, "\n (menu preprocess)"); + Tcl_BackgroundException(interp, result); } Tcl_Release(menuPtr); Tcl_Release(interp); @@ -661,20 +669,25 @@ TkpConfigureMenuEntry( submenu = nil; } else { [submenu setTitle:title]; + + if ([menuItem isEnabled]) { + /* This menuItem might have been previously disabled (XXX: + track this), which would have disabled entries; we must + re-enable the entries here. */ + int i = 0; + NSArray *itemArray = [submenu itemArray]; + for (NSMenuItem *item in itemArray) { + TkMenuEntry *submePtr = menuRefPtr->menuPtr->entries[i]; + [item setEnabled: !(submePtr->state == ENTRY_DISABLED)]; + i++; + } + } + } } } [menuItem setSubmenu:submenu]; - /*Disabling parent menu disables entries; we must re-enable the entries here.*/ - NSArray *itemArray = [submenu itemArray]; - - if ([menuItem isEnabled]) { - for (NSMenuItem *item in itemArray) { - [item setEnabled:YES]; - } - } - return TCL_OK; } diff --git a/macosx/tkMacOSXMenubutton.c b/macosx/tkMacOSXMenubutton.c index dafbb25..d6e635a 100644 --- a/macosx/tkMacOSXMenubutton.c +++ b/macosx/tkMacOSXMenubutton.c @@ -10,8 +10,6 @@ * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * RCS: @(#) $Id: tkMacOSXMenubutton.c,v 1.23 2010/01/13 23:08:13 nijtmans Exp $ */ #include "tkMacOSXPrivate.h" diff --git a/macosx/tkMacOSXMenus.c b/macosx/tkMacOSXMenus.c index 0299ce0..3b79169 100644 --- a/macosx/tkMacOSXMenus.c +++ b/macosx/tkMacOSXMenus.c @@ -9,8 +9,6 @@ * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * RCS: @(#) $Id: tkMacOSXMenus.c,v 1.26 2009/07/06 20:29:21 dkf Exp $ */ #include "tkMacOSXPrivate.h" diff --git a/macosx/tkMacOSXMouseEvent.c b/macosx/tkMacOSXMouseEvent.c index b5caf5a..90d2d00 100644 --- a/macosx/tkMacOSXMouseEvent.c +++ b/macosx/tkMacOSXMouseEvent.c @@ -9,8 +9,6 @@ * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * RCS: @(#) $Id: tkMacOSXMouseEvent.c,v 1.38 2010/01/06 14:58:30 dkf Exp $ */ #include "tkMacOSXPrivate.h" diff --git a/macosx/tkMacOSXNotify.c b/macosx/tkMacOSXNotify.c index ddc32df..689f45e 100644 --- a/macosx/tkMacOSXNotify.c +++ b/macosx/tkMacOSXNotify.c @@ -10,8 +10,6 @@ * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * RCS: @(#) $Id: tkMacOSXNotify.c,v 1.23 2009/07/06 20:29:21 dkf Exp $ */ #include "tkMacOSXPrivate.h" diff --git a/macosx/tkMacOSXPort.h b/macosx/tkMacOSXPort.h index f453f51..1576ec7 100644 --- a/macosx/tkMacOSXPort.h +++ b/macosx/tkMacOSXPort.h @@ -11,8 +11,6 @@ * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * RCS: @(#) $Id: tkMacOSXPort.h,v 1.16 2009/06/29 14:35:01 das Exp $ */ #ifndef _TKMACPORT @@ -114,7 +112,7 @@ */ #define XFlush(display) -#define XFree(data) {if ((data) != NULL) ckfree((char *) (data));} +#define XFree(data) {if ((data) != NULL) ckfree(data);} #define XGrabServer(display) #define XNoOp(display) {display->request++;} #define XUngrabServer(display) diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h index 20b79fc..034c450 100644 --- a/macosx/tkMacOSXPrivate.h +++ b/macosx/tkMacOSXPrivate.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: tkMacOSXPrivate.h,v 1.12 2009/07/07 08:08:18 dkf Exp $ + * RCS: @(#) $Id$ */ #ifndef _TKMACPRIV @@ -18,7 +18,7 @@ #if !__OBJC__ #error Objective-C compiler required #endif - + #define TextStyle MacTextStyle #import <ApplicationServices/ApplicationServices.h> #import <Cocoa/Cocoa.h> @@ -34,11 +34,8 @@ #ifndef _TKMACDEFAULT #include "tkMacOSXDefault.h" #endif - -/* - * Macros for Mac OS X API availability checking. - */ +/* Macros for Mac OS X API availability checking */ #define TK_IF_MAC_OS_X_API(vers, symbol, ...) \ tk_if_mac_os_x_10_##vers(symbol != NULL, 1, __VA_ARGS__) #define TK_ELSE_MAC_OS_X(vers, ...) \ @@ -49,11 +46,7 @@ } else { __VA_ARGS__ #define TK_ENDIF \ } - -/* - * Private macros that implement the checking macros above. - */ - +/* Private macros that implement the checking macros above */ #define tk_if_mac_os_x_yes(chk, cond, ...) \ if (cond) { __VA_ARGS__ #define tk_else_mac_os_x_yes(...) \ @@ -66,11 +59,7 @@ if (0) { #define tk_else_mac_os_x_no(...) \ } else { __VA_ARGS__ - -/* - * Private mapping macros defined according to Mac OS X version requirements. - */ - +/* Private mapping macros defined according to Mac OS X version requirements */ /* 10.5 Leopard */ #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 #define tk_if_mac_os_x_min_10_5 tk_if_mac_os_x_yes @@ -91,7 +80,7 @@ #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 /* MAC_OS_X_VERSION_MAX_ALLOWED */ - + /* * Macros for DEBUG_ASSERT_MESSAGE et al from Debugging.h. */ @@ -111,7 +100,6 @@ /* * Macro to do debug message output. */ - #define TkMacOSXDbgMsg(m, ...) \ do { \ TKLog(@"%s:%d: %s(): " m, strrchr(__FILE__, '/')+1, \ @@ -121,7 +109,6 @@ /* * Macro to do debug API failure message output. */ - #define TkMacOSXDbgOSErr(f, err) \ do { \ TkMacOSXDbgMsg("%s failed: %d", #f, (int)(err)); \ @@ -131,7 +118,6 @@ * Macro to do very common check for noErr return from given API and output * debug message in case of failure. */ - #define ChkErr(f, ...) ({ \ OSStatus err = f(__VA_ARGS__); \ if (err != noErr) { \ @@ -158,7 +144,7 @@ } /* - * Macros for GC. + * Macros for GC */ #define TkMacOSXMakeUncollectable(x) ({ id o = (id)(x); \ @@ -173,7 +159,7 @@ #define TkMacOSXMakeCollectableAndAutorelease(x) ({ id o = (id)(x); \ if (o) { x = nil; if (tkMacOSXGCEnabled) CFRelease(o); \ else [o autorelease]; } o; }) - + /* * Structure encapsulating current drawing environment. */ @@ -255,23 +241,23 @@ MODULE_SCOPE int TkMacOSXMakeFullscreen(TkWindow *winPtr, Tcl_Interp *interp); MODULE_SCOPE void TkMacOSXEnterExitFullscreen(TkWindow *winPtr, int active); -MODULE_SCOPE NSWindow * TkMacOSXDrawableWindow(Drawable drawable); -MODULE_SCOPE NSView * TkMacOSXDrawableView(MacDrawable *macWin); +MODULE_SCOPE NSWindow* TkMacOSXDrawableWindow(Drawable drawable); +MODULE_SCOPE NSView* TkMacOSXDrawableView(MacDrawable *macWin); MODULE_SCOPE void TkMacOSXWinCGBounds(TkWindow *winPtr, CGRect *bounds); MODULE_SCOPE HIShapeRef TkMacOSXGetClipRgn(Drawable drawable); MODULE_SCOPE void TkMacOSXInvalidateViewRegion(NSView *view, HIShapeRef rgn); MODULE_SCOPE CGImageRef TkMacOSXCreateCGImageWithDrawable(Drawable drawable); -MODULE_SCOPE NSImage * TkMacOSXGetNSImageWithTkImage(Display *display, +MODULE_SCOPE NSImage* TkMacOSXGetNSImageWithTkImage(Display *display, Tk_Image image, int width, int height); -MODULE_SCOPE NSImage * TkMacOSXGetNSImageWithBitmap(Display *display, +MODULE_SCOPE NSImage* TkMacOSXGetNSImageWithBitmap(Display *display, Pixmap bitmap, GC gc, int width, int height); MODULE_SCOPE CGColorRef TkMacOSXCreateCGColor(GC gc, unsigned long pixel); -MODULE_SCOPE NSColor * TkMacOSXGetNSColor(GC gc, unsigned long pixel); +MODULE_SCOPE NSColor* TkMacOSXGetNSColor(GC gc, unsigned long pixel); MODULE_SCOPE Tcl_Obj * TkMacOSXGetStringObjFromCFString(CFStringRef str); -MODULE_SCOPE TkWindow * TkMacOSXGetTkWindow(NSWindow *w); -MODULE_SCOPE NSFont * TkMacOSXNSFontForFont(Tk_Font tkfont); -MODULE_SCOPE NSDictionary *TkMacOSXNSFontAttributesForFont(Tk_Font tkfont); +MODULE_SCOPE TkWindow* TkMacOSXGetTkWindow(NSWindow *w); +MODULE_SCOPE NSFont* TkMacOSXNSFontForFont(Tk_Font tkfont); +MODULE_SCOPE NSDictionary* TkMacOSXNSFontAttributesForFont(Tk_Font tkfont); MODULE_SCOPE NSModalSession TkMacOSXGetModalSession(void); MODULE_SCOPE void TkMacOSXSelDeadWindow(TkWindow *winPtr); MODULE_SCOPE void TkMacOSXApplyWindowAttributes(TkWindow *winPtr, @@ -282,7 +268,7 @@ MODULE_SCOPE int TkMacOSXStandardAboutPanelObjCmd(ClientData clientData, MODULE_SCOPE int TkMacOSXIconBitmapObjCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); - + #pragma mark Private Objective-C Classes #define VISIBILITY_HIDDEN __attribute__((visibility("hidden"))) @@ -295,8 +281,8 @@ VISIBILITY_HIDDEN void *_tkMenu; NSUInteger _tkOffset, _tkItemCount, _tkSpecial; } -- (void) setSpecial: (NSUInteger) special; -- (BOOL) isSpecial: (NSUInteger) special; +- (void)setSpecial:(NSUInteger)special; +- (BOOL)isSpecial:(NSUInteger)special; @end VISIBILITY_HIDDEN @@ -309,35 +295,39 @@ VISIBILITY_HIDDEN NSArray *_defaultHelpMenuItems; } @end - @interface TKApplication(TKInit) -- (NSString *) tkFrameworkImagePath: (NSString *) image; +- (NSString *)tkFrameworkImagePath:(NSString*)image; @end @interface TKApplication(TKEvent) -- (NSEvent *) tkProcessEvent: (NSEvent *) theEvent; +- (NSEvent *)tkProcessEvent:(NSEvent *)theEvent; @end @interface TKApplication(TKMouseEvent) -- (NSEvent *) tkProcessMouseEvent: (NSEvent *) theEvent; +- (NSEvent *)tkProcessMouseEvent:(NSEvent *)theEvent; @end @interface TKApplication(TKKeyEvent) -- (NSEvent *) tkProcessKeyEvent: (NSEvent *) theEvent; +- (NSEvent *)tkProcessKeyEvent:(NSEvent *)theEvent; @end @interface TKApplication(TKMenu) -- (void) tkSetMainMenu: (TKMenu *) menu; +- (void)tkSetMainMenu:(TKMenu *)menu; @end @interface TKApplication(TKClipboard) -- (void) tkProvidePasteboard: (TkDisplay *) dispPtr; -- (void) tkCheckPasteboard; +- (void)tkProvidePasteboard:(TkDisplay *)dispPtr; +- (void)tkCheckPasteboard; @end VISIBILITY_HIDDEN -@interface TKContentView : NSView { +@interface TKContentView : NSView <NSTextInput> { @private id _savedSubviews; BOOL _subviewsSetAside; + NSString *_workingText; } @end +@interface TKContentView(TKKeyEvent) +- (void) deleteWorkingText; +@end + VISIBILITY_HIDDEN @interface TKWindow : NSWindow @end @@ -345,43 +335,34 @@ VISIBILITY_HIDDEN #pragma mark NSMenu & NSMenuItem Utilities @interface NSMenu(TKUtils) -+ (id) menuWithTitle: (NSString *) title; -+ (id) menuWithTitle: (NSString *) title menuItems: (NSArray *) items; -+ (id) menuWithTitle: (NSString *) title submenus: (NSArray *) submenus; -- (NSMenuItem *) itemWithSubmenu: (NSMenu *) submenu; -- (NSMenuItem *) itemInSupermenu; ++ (id)menuWithTitle:(NSString *)title; ++ (id)menuWithTitle:(NSString *)title menuItems:(NSArray *)items; ++ (id)menuWithTitle:(NSString *)title submenus:(NSArray *)submenus; +- (NSMenuItem *)itemWithSubmenu:(NSMenu *)submenu; +- (NSMenuItem *)itemInSupermenu; @end @interface NSMenuItem(TKUtils) -+ (id) itemWithSubmenu: (NSMenu *) submenu; -+ (id) itemWithTitle: (NSString *) title submenu: (NSMenu *) submenu; -+ (id) itemWithTitle: (NSString *) title action: (SEL) action; -+ (id) itemWithTitle: (NSString *) title action: (SEL) action - target: (id) target; -+ (id) itemWithTitle: (NSString *) title action: (SEL) action - keyEquivalent: (NSString *) keyEquivalent; -+ (id) itemWithTitle: (NSString *) title action: (SEL) action - target: (id) target keyEquivalent: (NSString *) keyEquivalent; -+ (id) itemWithTitle: (NSString *) title action: (SEL) action - keyEquivalent: (NSString *) keyEquivalent - keyEquivalentModifierMask: (NSUInteger) keyEquivalentModifierMask; -+ (id) itemWithTitle: (NSString *) title action: (SEL) action - target: (id) target keyEquivalent: (NSString *) keyEquivalent - keyEquivalentModifierMask: (NSUInteger) keyEquivalentModifierMask; ++ (id)itemWithSubmenu:(NSMenu *)submenu; ++ (id)itemWithTitle:(NSString *)title submenu:(NSMenu *)submenu; ++ (id)itemWithTitle:(NSString *)title action:(SEL)action; ++ (id)itemWithTitle:(NSString *)title action:(SEL)action + target:(id)target; ++ (id)itemWithTitle:(NSString *)title action:(SEL)action + keyEquivalent:(NSString *)keyEquivalent; ++ (id)itemWithTitle:(NSString *)title action:(SEL)action + target:(id)target keyEquivalent:(NSString *)keyEquivalent; ++ (id)itemWithTitle:(NSString *)title action:(SEL)action + keyEquivalent:(NSString *)keyEquivalent + keyEquivalentModifierMask:(NSUInteger)keyEquivalentModifierMask; ++ (id)itemWithTitle:(NSString *)title action:(SEL)action + target:(id)target keyEquivalent:(NSString *)keyEquivalent + keyEquivalentModifierMask:(NSUInteger)keyEquivalentModifierMask; @end /* From WebKit/WebKit/mac/WebCoreSupport/WebChromeClient.mm: */ @interface NSWindow(TKGrowBoxRect) -- (NSRect) _growBoxRect; +- (NSRect)_growBoxRect; @end #endif /* _TKMACPRIV */ - -/* - * Local Variables: - * mode: objc - * c-basic-offset: 4 - * fill-column: 79 - * coding: utf-8 - * End: - */ diff --git a/macosx/tkMacOSXRegion.c b/macosx/tkMacOSXRegion.c index 2a0eda7..ff5944f 100644 --- a/macosx/tkMacOSXRegion.c +++ b/macosx/tkMacOSXRegion.c @@ -9,8 +9,6 @@ * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * RCS: @(#) $Id: tkMacOSXRegion.c,v 1.13 2009/06/29 14:35:01 das Exp $ */ #include "tkMacOSXPrivate.h" diff --git a/macosx/tkMacOSXScale.c b/macosx/tkMacOSXScale.c index 9a4c03e..d69d6a1 100644 --- a/macosx/tkMacOSXScale.c +++ b/macosx/tkMacOSXScale.c @@ -11,8 +11,6 @@ * * 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.17 2009/06/29 14:35:01 das Exp $ */ #include "tkMacOSXPrivate.h" diff --git a/macosx/tkMacOSXScrlbr.c b/macosx/tkMacOSXScrlbr.c index 0d18695..77b89e7 100644 --- a/macosx/tkMacOSXScrlbr.c +++ b/macosx/tkMacOSXScrlbr.c @@ -10,8 +10,6 @@ * * 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.33 2010/02/17 19:21:18 nijtmans Exp $ */ #include "tkMacOSXPrivate.h" diff --git a/macosx/tkMacOSXSend.c b/macosx/tkMacOSXSend.c index 4734faf..b48a8a0 100644 --- a/macosx/tkMacOSXSend.c +++ b/macosx/tkMacOSXSend.c @@ -29,8 +29,6 @@ * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * RCS: @(#) $Id: tkMacOSXSend.c,v 1.13 2009/06/29 14:35:01 das Exp $ */ #include "tkMacOSXInt.h" diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c index 4107450..8cf8d65 100644 --- a/macosx/tkMacOSXSubwindows.c +++ b/macosx/tkMacOSXSubwindows.c @@ -9,8 +9,6 @@ * * 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.31 2009/07/06 20:29:21 dkf Exp $ */ #include "tkMacOSXPrivate.h" @@ -971,6 +969,13 @@ TkMacOSXDrawableWindow( } return result; } + +void * +TkMacOSXDrawable( + Drawable drawable) +{ + return TkMacOSXDrawableWindow(drawable); +} /* *---------------------------------------------------------------------- diff --git a/macosx/tkMacOSXTest.c b/macosx/tkMacOSXTest.c index e75a30c..26885a9 100644 --- a/macosx/tkMacOSXTest.c +++ b/macosx/tkMacOSXTest.c @@ -10,8 +10,6 @@ * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * RCS: @(#) $Id: tkMacOSXTest.c,v 1.8 2009/11/29 22:10:37 nijtmans Exp $ */ #include "tkMacOSXPrivate.h" diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 26bd064..50c6702 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -9,8 +9,6 @@ * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * RCS: @(#) $Id: tkMacOSXWindowEvent.c,v 1.40 2011/01/06 00:15:24 wordtech Exp $ */ #include "tkMacOSXPrivate.h" @@ -274,7 +272,7 @@ extern NSString *opaqueTag; int code = Tcl_EvalEx(_eventInterp, cmd, -1, TCL_EVAL_GLOBAL); if (code != TCL_OK) { - Tcl_BackgroundException(_eventInterp, code); + Tcl_BackgroundError(_eventInterp); } Tcl_ResetResult(_eventInterp); } @@ -419,7 +417,6 @@ GenerateActivateEvents( { TkGenerateActivateEvents(winPtr, activeFlag); TkMacOSXGenerateFocusEvent(winPtr, activeFlag); - TkMacOSXEnterExitFullscreen(winPtr, activeFlag); return true; } @@ -710,7 +707,7 @@ TkWmProtocolEventProc( Tcl_AddErrorInfo(interp, Tk_GetAtomName((Tk_Window) winPtr, protocol)); Tcl_AddErrorInfo(interp, "\" window manager protocol)"); - Tcl_BackgroundException(interp, result); + Tcl_BackgroundError(interp); } Tcl_Release(interp); Tcl_Release(protPtr); diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 4df82fe..9ac0369 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -13,8 +13,6 @@ * * 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.78 2011/01/04 22:36:58 wordtech Exp $ */ #include "tkMacOSXPrivate.h" @@ -563,6 +561,7 @@ TkWmNewWindow( UpdateVRootGeometry(wmPtr); + /* * Tk must monitor structure events for top-level windows, in order to * detect size and position changes caused by window managers. @@ -1637,41 +1636,28 @@ WmForgetCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { -#if 1 - Tcl_AppendResult(interp, "wm forget is not yet supported", NULL); - return TCL_ERROR; -#else + register Tk_Window frameWin = (Tk_Window)winPtr; - char *oldClass = (char*)Tk_Class(frameWin); if (Tk_IsTopLevel(frameWin)) { - MacDrawable *macWin = (MacDrawable *) winPtr->window; - CGrafPtr destPort = TkMacOSXGetDrawablePort(winPtr->window); - - TkFocusJoin(winPtr); - Tk_UnmapWindow(frameWin); - - if (destPort != NULL) { - WindowRef winRef = GetWindowFromPort(destPort); - - TkMacOSXUnregisterMacWindow(winRef); - DisposeWindow(winRef); - } - macWin->grafPtr = NULL; - macWin->toplevel = winPtr->parentPtr->privatePtr->toplevel; - macWin->flags &= ~TK_HOST_EXISTS; + MacDrawable *macWin = (MacDrawable *) winPtr->parentPtr->window; + TkFocusJoin(winPtr); + Tk_UnmapWindow(frameWin); + TkWmDeadWindow(macWin); RemapWindows(winPtr, macWin); - TkWmDeadWindow(winPtr); - winPtr->flags &= - ~(TK_TOP_HIERARCHY|TK_TOP_LEVEL|TK_HAS_WRAPPER|TK_WIN_MANAGED); + + winPtr->flags &=~(TK_TOP_HIERARCHY|TK_TOP_LEVEL|TK_HAS_WRAPPER|TK_WIN_MANAGED); + + /* + * Flags (above) must be cleared before calling TkMapTopFrame (below). + */ TkMapTopFrame(frameWin); } else { - /* Already not managed by wm - ignore it */ + /* Already not managed by wm - ignore it */ } return TCL_OK; -#endif } /* @@ -2393,10 +2379,7 @@ WmManageCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { -#if 1 - Tcl_AppendResult(interp, "wm manage is not yet supported", NULL); - return TCL_ERROR; -#else + register Tk_Window frameWin = (Tk_Window)winPtr; register WmInfo *wmPtr = winPtr->wmInfoPtr; char *oldClass = (char*)Tk_Class(frameWin); @@ -2423,7 +2406,6 @@ WmManageCmd( } wmPtr = winPtr->wmInfoPtr; winPtr->flags &= ~TK_MAPPED; - macWin->grafPtr = NULL; macWin->toplevel = macWin; RemapWindows(winPtr, macWin); winPtr->flags |= @@ -2433,7 +2415,6 @@ WmManageCmd( /* Already managed by wm - ignore it */ } return TCL_OK; -#endif } /* @@ -6287,6 +6268,7 @@ TkMacOSXMakeFullscreen( { WmInfo *wmPtr = winPtr->wmInfoPtr; int result = TCL_OK, wasFullscreen = (wmPtr->flags & WM_FULLSCREEN); + static unsigned long prevMask = 0, prevPres = 0; if (fullscreen) { int screenWidth = WidthOfScreen(Tk_Screen(winPtr)); @@ -6324,10 +6306,20 @@ TkMacOSXMakeFullscreen( } wmPtr->flags |= WM_FULLSCREEN; } + + prevMask = [window styleMask]; + prevPres = [NSApp presentationOptions]; + [window setStyleMask: NSBorderlessWindowMask]; + [NSApp setPresentationOptions: NSApplicationPresentationAutoHideDock + | NSApplicationPresentationAutoHideMenuBar]; + } else { - wmPtr->flags &= ~WM_FULLSCREEN; + wmPtr->flags &= ~WM_FULLSCREEN; + + [NSApp setPresentationOptions: prevPres]; + [window setStyleMask: prevMask]; } - TkMacOSXEnterExitFullscreen(winPtr, [window isKeyWindow]); + if (wasFullscreen && !(wmPtr->flags & WM_FULLSCREEN)) { UInt64 oldAttributes = wmPtr->attributes; NSRect bounds = NSMakeRect(wmPtr->configX, tkMacOSXZeroScreenHeight - @@ -6349,55 +6341,6 @@ TkMacOSXMakeFullscreen( /* *---------------------------------------------------------------------- * - * TkMacOSXEnterExitFullscreen -- - * - * This procedure enters or exits fullscreen mode if required. - * - * Results: - * None. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -void -TkMacOSXEnterExitFullscreen( - TkWindow *winPtr, - int active) -{ - WmInfo *wmPtr = winPtr->wmInfoPtr; - NSWindow *window = TkMacOSXDrawableWindow(winPtr->window); - SystemUIMode mode; - SystemUIOptions options; - - GetSystemUIMode(&mode, &options); - if (window && wmPtr && (wmPtr->flags & WM_FULLSCREEN) && active) { - static SystemUIMode fullscreenMode = 0; - static SystemUIOptions fullscreenOptions = 0; - - if (!fullscreenMode) { - fullscreenMode = kUIModeAllSuppressed; - } - if (mode != fullscreenMode) { - ChkErr(SetSystemUIMode, fullscreenMode, fullscreenOptions); - wmPtr->flags |= WM_SYNC_PENDING; - [window setFrame:[window frameRectForContentRect:NSMakeRect(0, 0, - WidthOfScreen(Tk_Screen(winPtr)), - HeightOfScreen(Tk_Screen(winPtr)))] display:YES]; - wmPtr->flags &= ~WM_SYNC_PENDING; - } - } else { - if (mode != kUIModeNormal) { - ChkErr(SetSystemUIMode, kUIModeNormal, 0); - } - } -} - -/* - *---------------------------------------------------------------------- - * * GetMinSize -- * * This function computes the current minWidth and minHeight values for a diff --git a/macosx/tkMacOSXWm.h b/macosx/tkMacOSXWm.h index a8255c4..bfc7fac 100644 --- a/macosx/tkMacOSXWm.h +++ b/macosx/tkMacOSXWm.h @@ -8,8 +8,6 @@ * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * RCS: @(#) $Id: tkMacOSXWm.h,v 1.9 2009/06/29 14:35:01 das Exp $ */ #ifndef _TKMACWM diff --git a/macosx/tkMacOSXXCursors.h b/macosx/tkMacOSXXCursors.h index d6d555a..1363bee 100644 --- a/macosx/tkMacOSXXCursors.h +++ b/macosx/tkMacOSXXCursors.h @@ -11,8 +11,6 @@ * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * RCS: @(#) $Id: tkMacOSXXCursors.h,v 1.1 2009/06/29 14:35:01 das Exp $ */ static const unsigned char tkMacOSXXCursors[][68] = { diff --git a/macosx/tkMacOSXXStubs.c b/macosx/tkMacOSXXStubs.c index 70f8e39..848b49c 100644 --- a/macosx/tkMacOSXXStubs.c +++ b/macosx/tkMacOSXXStubs.c @@ -12,8 +12,6 @@ * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * RCS: @(#) $Id: tkMacOSXXStubs.c,v 1.33 2009/07/06 20:29:21 dkf Exp $ */ #include "tkMacOSXPrivate.h" @@ -453,12 +451,13 @@ XSelectInput( Debugger(); } -void +int XBell( Display* display, int percent) { NSBeep(); + return Success; } #if 0 @@ -538,7 +537,7 @@ XDrawPoints( } */ -void +int XWarpPointer( Display* display, Window src_w, @@ -550,6 +549,7 @@ XWarpPointer( int dest_x, int dest_y) { + return Success; } void diff --git a/macosx/ttkMacOSXTheme.c b/macosx/ttkMacOSXTheme.c index fd8f6d3..fe873f3 100644 --- a/macosx/ttkMacOSXTheme.c +++ b/macosx/ttkMacOSXTheme.c @@ -28,8 +28,6 @@ * The QuickDraw/Carbon coordinate system is relative to the * top-level window, not to the Tk_Window. BoxToRect() * accounts for this. - * - * RCS: @(#) $Id: ttkMacOSXTheme.c,v 1.29 2009/10/22 08:32:23 dkf Exp $ */ #include "tkMacOSXPrivate.h" |