From 56a8ee93e20171f058b4af04d7a6900af4ff0b33 Mon Sep 17 00:00:00 2001 From: das Date: Thu, 11 Nov 2004 01:26:40 +0000 Subject: * generic/tkMain.c: * macosx/tkMacOSXAppInit.c (removed): * macosx/Wish.pbproj/project.pbxproj: * macosx/tkMacOSXInit.c: * macosx/tkMacOSXInt.h: changes to make TkAqua dynamically loadable, enabling [package require Tk] from tclsh. Startup code from tkMacOSXAppInit.c moved into tkMacOSXInit.c, added code that notifies the window server that an unbundled executable is a full GUI application after loading Tk. [Patch 1035348] * doc/wm.n: documented [wm attributes] on Mac OS X. [Bug 606665] * macosx/tkMacOSXWm.c: implemented TIP 222 [wm attributes -alpha] on Mac OS X. [Patch 892194] WmIconbitmapCmd: adopted FSRef changes from [wm atttrs -titlepath]. * macosx/tkMacOSXButton.c: * macosx/tkMacOSXMenus.c: * macosx/tkMacOSXRegion.c: * macosx/tkMacOSXSubwindows.c: synced spacing/formatting with HEAD. * macosx/tkMacOSXMouseEvent.c: endianness fixes. * macosx/Wish.pbproj/project.pbxproj: corrected path to html help inside framework. * macosx/Makefile: prevent parallel make from building several targets at the same time. Ensure that xcodebuild will use Wish.pbproj project even if a .xcode project is also present. --- ChangeLog | 32 +++++ doc/wm.n | 11 +- generic/tkMain.c | 11 +- macosx/Makefile | 8 +- macosx/Wish.pbproj/project.pbxproj | 27 ++--- macosx/tkMacOSXAppInit.c | 243 ------------------------------------- macosx/tkMacOSXButton.c | 51 ++++---- macosx/tkMacOSXInit.c | 216 ++++++++++++++++++++++++++++----- macosx/tkMacOSXInt.h | 3 +- macosx/tkMacOSXMenus.c | 20 +-- macosx/tkMacOSXMouseEvent.c | 28 +++-- macosx/tkMacOSXRegion.c | 10 +- macosx/tkMacOSXSubwindows.c | 8 +- macosx/tkMacOSXWm.c | 70 +++++++++-- 14 files changed, 367 insertions(+), 371 deletions(-) delete mode 100644 macosx/tkMacOSXAppInit.c diff --git a/ChangeLog b/ChangeLog index d72e571..de5ce11 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,35 @@ +2004-11-11 Daniel Steffen + + * generic/tkMain.c: + * macosx/tkMacOSXAppInit.c (removed): + * macosx/Wish.pbproj/project.pbxproj: + * macosx/tkMacOSXInit.c: + * macosx/tkMacOSXInt.h: changes to make TkAqua dynamically loadable, + enabling [package require Tk] from tclsh. Startup code from + tkMacOSXAppInit.c moved into tkMacOSXInit.c, added code that + notifies the window server that an unbundled executable is a full + GUI application after loading Tk. [Patch 1035348] + + * doc/wm.n: documented [wm attributes] on Mac OS X. [Bug 606665] + * macosx/tkMacOSXWm.c: implemented TIP 222 [wm attributes -alpha] on + Mac OS X. [Patch 892194] + WmIconbitmapCmd: adopted FSRef changes from [wm atttrs -titlepath]. + + * macosx/tkMacOSXButton.c: + * macosx/tkMacOSXMenus.c: + * macosx/tkMacOSXRegion.c: + * macosx/tkMacOSXSubwindows.c: synced spacing/formatting with HEAD. + + * macosx/tkMacOSXMouseEvent.c: endianness fixes. + + * macosx/Wish.pbproj/project.pbxproj: corrected path to html help + inside framework. + + * macosx/Makefile: prevent parallel make from building several + targets at the same time. + Ensure that xcodebuild will use Wish.pbproj project even if a .xcode + project is also present. + 2004-11-10 Jim Ingham From Michael Kirkham (mikek@muonics.com): diff --git a/doc/wm.n b/doc/wm.n index 557fedf..1df11b8 100644 --- a/doc/wm.n +++ b/doc/wm.n @@ -5,7 +5,7 @@ '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" -'\" RCS: @(#) $Id: wm.n,v 1.11.2.2 2004/10/28 22:40:57 mdejong Exp $ +'\" RCS: @(#) $Id: wm.n,v 1.11.2.3 2004/11/11 01:26:42 das Exp $ '\" .so man.macros .TH wm n 8.4 Tk "Tk Built-In Commands" @@ -68,8 +68,13 @@ outside that range will be constrained. This is supported on Windows 2000/XP+. Where not supported, the \fB\-alpha\fR value remains at \fB1.0\fR. .PP -On Macintosh, there are currently two attribute values: -\fB\-modified\fR and \fB\-titlepath\fR. +On Mac OS X, \fB\-modified\fR gets or sets the modification state of the +window (determines whether the window close widget contains the modification +indicator). \fB\-titlepath\fR gets or sets the path of the file referenced as +the window proxy icon (which can be dragged and dropped in lieu of the file's +finder icon). \fB\-alpha\fR sets the alpha transparency level of the window, +it accepts a value from \fB0.0\fR (fully transparent) to \fB1.0\fR (opaque), +values outside that range will be constrained. .PP On Unix, there are currently no special attribute values. .RE diff --git a/generic/tkMain.c b/generic/tkMain.c index d3e3a13..25f0d9d 100644 --- a/generic/tkMain.c +++ b/generic/tkMain.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: tkMain.c,v 1.15 2002/12/13 16:54:35 dgp Exp $ + * RCS: @(#) $Id: tkMain.c,v 1.15.2.1 2004/11/11 01:26:42 das Exp $ */ #include @@ -31,6 +31,9 @@ #ifdef __WIN32__ #include "tkWinInt.h" #endif +#ifdef MAC_OSX_TK +#include "tkMacOSXInt.h" +#endif typedef struct ThreadSpecificData { @@ -128,6 +131,12 @@ Tk_MainEx(argc, argv, appInitProc, interp) #if (defined(__WIN32__) || defined(MAC_TCL)) Tk_InitConsoleChannels(interp); #endif + +#ifdef MAC_OSX_TK + if (TclGetStartupScriptFileName() == NULL) { + TkMacOSXDefaultStartupScript(); + } +#endif #ifdef TCL_MEM_DEBUG Tcl_InitMemory(interp); diff --git a/macosx/Makefile b/macosx/Makefile index 331de81..ad5b4c9 100644 --- a/macosx/Makefile +++ b/macosx/Makefile @@ -3,7 +3,7 @@ # Makefile to build AquaTk on Mac OS X packaged as a Framework # uses Project Builder command line tool 'pbxbuild' # -# RCS: @(#) $Id: Makefile,v 1.7.2.6 2004/07/20 06:05:59 das Exp $ +# RCS: @(#) $Id: Makefile,v 1.7.2.7 2004/11/11 01:26:42 das Exp $ # ################################################################################ @@ -44,8 +44,8 @@ PBXBUILD = /usr/bin/pbxbuild XCODEBUILD = /usr/bin/xcodebuild BUILDCMD = `if [ -f $(XCODEBUILD) ]; then \ - echo "$(XCODEBUILD)"; \ - else echo "$(PBXBUILD)"; fi` + echo "$(XCODEBUILD) -project $$(ls -d *.pbproj)"; \ + else echo "$(PBXBUILD)"; fi` MAKE_VARS := SYMROOT OBJROOT BINDIR APPLICATION_INSTALL_PATH \ TCL_FRAMEWORK_DIR TCLSH_DIR @@ -128,4 +128,6 @@ cleanup-embedded: embedded-develop embedded-deploy install-embedded-develop install-embedded-deploy \ clean-develop clean-deploy cleanup-embedded +.NOTPARALLEL: + ################################################################################ diff --git a/macosx/Wish.pbproj/project.pbxproj b/macosx/Wish.pbproj/project.pbxproj index 40f6666..ff2b7ec 100644 --- a/macosx/Wish.pbproj/project.pbxproj +++ b/macosx/Wish.pbproj/project.pbxproj @@ -134,7 +134,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "if [ \"${BUILD_STYLE}\" = \"Development\" ]; then\n\t# keep copy of debug library around, so that\n\t# Deployment build can be installed on top\n\t# of Development build without overwriting it\n\tcd \"${TARGET_BUILD_DIR}/${PRODUCT_NAME}.${WRAPPER_EXTENSION}/Versions/${FRAMEWORK_VERSION}\"\n\tcp -fp \"${PRODUCT_NAME}\" \"${PRODUCT_NAME}_debug\"\n\tln -fs \"Versions/Current/${PRODUCT_NAME}_debug\" ../..\n\tcp -fp \"libtkstub${FRAMEWORK_VERSION}.a\" \"libtkstub${FRAMEWORK_VERSION}g.a\"\n\n\t# force Deployment build to be relinked next time\n\tif [ -f \"${OBJROOT}/Deployment.build/${PROJECT_NAME}.build/${TARGET_NAME}.build/Objects-normal/LinkFileList\" ]; then\n\t touch -t `date -r \\`expr \\\\\\`date +\"%s\"\\\\\\` + 30\\` +\"%Y%m%d%H%M.%S\"` \"${OBJROOT}/Deployment.build/${PROJECT_NAME}.build/${TARGET_NAME}.build/Objects-normal/LinkFileList\"\n\tfi\nelse\n\t# force Development build to be relinked next time\n\tif [ -f \"${OBJROOT}/Development.build/${PROJECT_NAME}.build/${TARGET_NAME}.build/Objects-normal/LinkFileList\" ]; then\n\t touch -t `date -r \\`expr \\\\\\`date +\"%s\"\\\\\\` + 30\\` +\"%Y%m%d%H%M.%S\"` \"${OBJROOT}/Development.build/${PROJECT_NAME}.build/${TARGET_NAME}.build/Objects-normal/LinkFileList\"\n\tfi\nfi\n\n# fixup Framework structure\ncd \"${TARGET_BUILD_DIR}/${PRODUCT_NAME}.${WRAPPER_EXTENSION}/Versions/${FRAMEWORK_VERSION}\"\nln -fs `ls libtkstub* | sed -e \"s|.*|Versions/${FRAMEWORK_VERSION}/&|\"` ../..\nln -fs \"Versions/Current/tkConfig.sh\" ../..\nranlib libtkstub${FRAMEWORK_VERSION}*.a"; + shellScript = "if [ \"${BUILD_STYLE}\" = \"Development\" ]; then\n\t# keep copy of debug library around, so that\n\t# Deployment build can be installed on top\n\t# of Development build without overwriting it\n\tcd \"${TARGET_BUILD_DIR}/${PRODUCT_NAME}.${WRAPPER_EXTENSION}/Versions/${FRAMEWORK_VERSION}\"\n\tcp -fp \"${PRODUCT_NAME}\" \"${PRODUCT_NAME}_debug\"\n\tln -fs \"Versions/Current/${PRODUCT_NAME}_debug\" ../..\n\tcp -fp \"libtkstub${FRAMEWORK_VERSION}.a\" \"libtkstub${FRAMEWORK_VERSION}g.a\"\n\n\t# force Deployment build to be relinked next time\n\tif [ -f \"${OBJROOT}/Deployment.build/${PROJECT_NAME}.build/${TARGET_NAME}.build/Objects-normal/LinkFileList\" ]; then\n\t touch -t `date -r \\`expr \\\\\\`date +\"%s\"\\\\\\` + 30\\` +\"%Y%m%d%H%M.%S\"` \"${OBJROOT}/Deployment.build/${PROJECT_NAME}.build/${TARGET_NAME}.build/Objects-normal/LinkFileList\"\n\tfi\nelse\n\t# force Development build to be relinked next time\n\tif [ -f \"${OBJROOT}/Development.build/${PROJECT_NAME}.build/${TARGET_NAME}.build/Objects-normal/LinkFileList\" ]; then\n\t touch -t `date -r \\`expr \\\\\\`date +\"%s\"\\\\\\` + 30\\` +\"%Y%m%d%H%M.%S\"` \"${OBJROOT}/Development.build/${PROJECT_NAME}.build/${TARGET_NAME}.build/Objects-normal/LinkFileList\"\n\tfi\nfi\n\n# fixup Framework structure\ncd \"${TARGET_BUILD_DIR}/${PRODUCT_NAME}.${WRAPPER_EXTENSION}/Versions/${FRAMEWORK_VERSION}\"\nln -fs `ls libtkstub* | sed -e \"s|.*|Versions/${FRAMEWORK_VERSION}/&|\"` ../..\nln -fs \"Versions/Current/tkConfig.sh\" ../..\nranlib libtkstub${FRAMEWORK_VERSION}*.a\n\n# create pkgIndex\n( echo \"if {[package vcompare [package provide Tcl] ${FRAMEWORK_VERSION}] != 0} { return }\" && \\\n echo \"package ifneeded Tk ${FRAMEWORK_VERSION} [list load [file join \\$dir .. .. Tk] Tk]\" \\\n) > \"Resources/Scripts/pkgIndex.tcl\""; }; F537552A016C352C01DC9062 = { buildStyles = ( @@ -432,7 +432,6 @@ }; F5375546016C376E01DC9062 = { children = ( - F5375548016C376E01DC9062, F5375549016C376E01DC9062, F537554A016C376E01DC9062, F537554B016C376E01DC9062, @@ -470,8 +469,9 @@ F5375548016C376E01DC9062 = { fileEncoding = 5; isa = PBXFileReference; - path = tkMacOSXAppInit.c; - refType = 4; + name = tkAppInit.c; + path = ../unix/tkAppInit.c; + refType = 2; }; F5375549016C376E01DC9062 = { fileEncoding = 5; @@ -1321,6 +1321,7 @@ }; F53755C9016C389901DC9062 = { children = ( + F5375548016C376E01DC9062, F53755CA016C389901DC9062, F53755CB016C389901DC9062, ); @@ -1509,7 +1510,7 @@ F9A61D2F04C2C861006F5A0B, ); buildSettings = { - DOCDIR = "${INSTALL_PATH}/${PRODUCT_NAME}.${WRAPPER_EXTENSION}/Versions/${FRAMEWORK_VERSION}/Resources/English.lproj/Documentation/Reference"; + DOCDIR = "${INSTALL_PATH}/${PRODUCT_NAME}.${WRAPPER_EXTENSION}/Versions/${FRAMEWORK_VERSION}/Resources/Documentation/Reference"; DYLIB_COMPATIBILITY_VERSION = 8.4; DYLIB_CURRENT_VERSION = "$(FRAMEWORK_VERSION)"; DYLIB_INSTALL_PATH = /Library/Frameworks; @@ -2941,7 +2942,7 @@ MacOS X Port by Jim Ingham <jingham@apple.com> & Ian Reid, Copyright CFBundleExecutable Wish Shell CFBundleGetInfoString - Wish Shell 8.4, Copyright © 2003 Tcl Core Team. + Wish Shell 8.4, Copyright © 2004 Tcl Core Team. MacOS X Port by Jim Ingham <jingham@apple.com> & Ian Reid, Copyright © 2001-2002, Apple Computer, Inc. CFBundleIconFile Wish.icns @@ -2967,8 +2968,6 @@ MacOS X Port by Jim Ingham <jingham@apple.com> & Ian Reid, Copyright buildActionMask = 2147483647; files = ( F53756AC016C4E1D01DC9062, - F53756AD016C4E1D01DC9062, - F53756AE016C4E1D01DC9062, ); isa = PBXHeadersBuildPhase; runOnlyForDeploymentPostprocessing = 0; @@ -3039,18 +3038,6 @@ MacOS X Port by Jim Ingham <jingham@apple.com> & Ian Reid, Copyright settings = { }; }; - F53756AD016C4E1D01DC9062 = { - fileRef = F5375570016C37A601DC9062; - isa = PBXBuildFile; - settings = { - }; - }; - F53756AE016C4E1D01DC9062 = { - fileRef = F537553E016C376E01DC9062; - isa = PBXBuildFile; - settings = { - }; - }; F53756B2016C525F01DC9062 = { isa = PBXTargetDependency; target = F53755DF016C38D201DC9062; diff --git a/macosx/tkMacOSXAppInit.c b/macosx/tkMacOSXAppInit.c deleted file mode 100644 index 151c68e..0000000 --- a/macosx/tkMacOSXAppInit.c +++ /dev/null @@ -1,243 +0,0 @@ -/* - * tkAppInit.c -- - * - * Provides a default version of the Tcl_AppInit procedure for - * use in wish and similar Tk-based applications. - * - * Copyright (c) 1993 The Regents of the University of California. - * Copyright (c) 1994-1997 Sun Microsystems, Inc. - * Copyright 2001, Apple Computer, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * RCS: @(#) $Id: tkMacOSXAppInit.c,v 1.4.2.1 2004/02/16 00:42:34 wolfsuit Exp $ - */ -#include -#include -#include "tk.h" -#include "tclInt.h" -#include "locale.h" - -#include -#include "tkPort.h" -#include "tkMacOSX.h" -#include "tkMacOSXEvent.h" - -/* - * If the App is in an App package, then we want to add the Scripts - * directory to the auto_path. But we have to wait till after the - * Tcl_Init is run, or it gets blown away. This stores what we - * figured out in main. - */ - -char scriptPath[PATH_MAX + 1]; - -extern Tcl_Interp *gStdoutInterp; - -#ifdef TK_TEST -extern int Tktest_Init _ANSI_ARGS_((Tcl_Interp *interp)); -#endif /* TK_TEST */ - -/* - *---------------------------------------------------------------------- - * - * main -- - * - * This is the main program for the application. - * - * Results: - * None: Tk_Main never returns here, so this procedure never - * returns either. - * - * Side effects: - * Whatever the application does. - * - *---------------------------------------------------------------------- - */ - -int -main(argc, argv) - int argc; /* Number of command-line arguments. */ - char **argv; /* Values of command-line arguments. */ -{ - int textEncoding; /* - * Variable used to take care of - * lazy font initialization - */ - CFBundleRef bundleRef; - - /* - * The following #if block allows you to change the AppInit - * function by using a #define of TCL_LOCAL_APPINIT instead - * of rewriting this entire file. The #if checks for that - * #define and uses Tcl_AppInit if it doesn't exist. - */ - -#ifndef TK_LOCAL_APPINIT -#define TK_LOCAL_APPINIT Tcl_AppInit -#endif - extern int TK_LOCAL_APPINIT _ANSI_ARGS_((Tcl_Interp *interp)); - - scriptPath[0] = '\0'; - - /* - * The following #if block allows you to change how Tcl finds the startup - * script, prime the library or encoding paths, fiddle with the argv, - * etc., without needing to rewrite Tk_Main(). Note, if you use this - * hook, then I won't do the CFBundle lookup, since if you are messing - * around at this level, you probably don't want me to do this for you... - */ - -#ifdef TK_LOCAL_MAIN_HOOK - extern int TK_LOCAL_MAIN_HOOK _ANSI_ARGS_((int *argc, char ***argv)); - TK_LOCAL_MAIN_HOOK(&argc, &argv); -#else - - /* - * On MacOS X, we look for a file in the Resources/Scripts directory - * called AppMain.tcl and if found, we set argv[1] to that, so that - * the rest of the code will find it, and add the Scripts folder to - * the auto_path. If we don't find the startup script, we just bag - * it, assuming the user is starting up some other way. - */ - - bundleRef = CFBundleGetMainBundle(); - - if (bundleRef != NULL) { - CFURLRef appMainURL; - appMainURL = CFBundleCopyResourceURL(bundleRef, - CFSTR("AppMain"), - CFSTR("tcl"), - CFSTR("Scripts")); - - if (appMainURL != NULL) { - CFURLRef scriptFldrURL; - char *startupScript = malloc(PATH_MAX + 1); - - if (CFURLGetFileSystemRepresentation (appMainURL, true, - startupScript, PATH_MAX)) { - TclSetStartupScriptFileName(startupScript); - scriptFldrURL = CFBundleCopyResourceURL(bundleRef, - CFSTR("Scripts"), - NULL, - NULL); - CFURLGetFileSystemRepresentation(scriptFldrURL, - true, scriptPath, PATH_MAX); - CFRelease(scriptFldrURL); - } else { - free(startupScript); - } - CFRelease(appMainURL); - } - } - -#endif - textEncoding = GetApplicationTextEncoding(); - - /* - * Now add the scripts folder to the auto_path. - */ - - Tk_Main(argc,argv,TK_LOCAL_APPINIT); - return 0; /* Needed only to prevent compiler warning. */ -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_AppInit -- - * - * This procedure performs application-specific initialization. - * Most applications, especially those that incorporate additional - * packages, will have their own version of this procedure. - * - * Results: - * Returns a standard Tcl completion code, and leaves an error - * message in the interp's result if an error occurs. - * - * Side effects: - * Depends on the startup script. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_AppInit(interp) - Tcl_Interp *interp; /* Interpreter for application. */ -{ - if (Tcl_Init(interp) == TCL_ERROR) { - return TCL_ERROR; - } - if (Tk_Init(interp) == TCL_ERROR) { - return TCL_ERROR; - } - Tcl_StaticPackage(interp, "Tk", Tk_Init, Tk_SafeInit); - - if (scriptPath[0] != '\0') { - Tcl_SetVar(interp, "auto_path", scriptPath, - TCL_GLOBAL_ONLY|TCL_LIST_ELEMENT|TCL_APPEND_VALUE); - } - -#ifdef TK_TEST - if (Tktest_Init(interp) == TCL_ERROR) { - return TCL_ERROR; - } - Tcl_StaticPackage(interp, "Tktest", Tktest_Init, - (Tcl_PackageInitProc *) NULL); -#endif /* TK_TEST */ - - /* - * If we don't have a TTY and stdin is a special character file of length 0, - * (e.g. /dev/null, which is what Finder sets when double clicking Wish) - * then use the Tk based console interpreter. - */ - - if (!isatty(0)) { - struct stat st; - if (fstat(0, &st) || (S_ISCHR(st.st_mode) && st.st_blocks == 0)) { - Tk_InitConsoleChannels(interp); - Tcl_RegisterChannel(interp, Tcl_GetStdChannel(TCL_STDIN)); - Tcl_RegisterChannel(interp, Tcl_GetStdChannel(TCL_STDOUT)); - Tcl_RegisterChannel(interp, Tcl_GetStdChannel(TCL_STDERR)); - if (Tk_CreateConsoleWindow(interp) == TCL_ERROR) { - goto error; - } - /* Only show the console if we don't have a startup script */ - if (TclGetStartupScriptPath() == NULL) { - Tcl_Eval(interp, "console show"); - } - } - } - - /* - * Call the init procedures for included packages. Each call should - * look like this: - * - * if (Mod_Init(interp) == TCL_ERROR) { - * return TCL_ERROR; - * } - * - * where "Mod" is the name of the module. - */ - - /* - * Call Tcl_CreateCommand for application-specific commands, if - * they weren't already created by the init procedures called above. - */ - - - /* - * Specify a user-specific startup file to invoke if the application - * is run interactively. Typically the startup file is "~/.apprc" - * where "app" is the name of the application. If this line is deleted - * then no user-specific startup file will be run under any conditions. - */ - - Tcl_SetVar(interp, "tcl_rcFileName", "~/.wishrc", TCL_GLOBAL_ONLY); - - return TCL_OK; - - error: - return TCL_ERROR; -} diff --git a/macosx/tkMacOSXButton.c b/macosx/tkMacOSXButton.c index b3935a1..0083935 100644 --- a/macosx/tkMacOSXButton.c +++ b/macosx/tkMacOSXButton.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: tkMacOSXButton.c,v 1.2.2.6 2004/11/10 17:29:45 wolfsuit Exp $ + * RCS: @(#) $Id: tkMacOSXButton.c,v 1.2.2.7 2004/11/11 01:26:42 das Exp $ */ #include "tkButton.h" @@ -309,7 +309,7 @@ TkpDisplayButton( fullWidth = 0; fullHeight = 0; - switch ((enum compound) butPtr->compound) + switch ((enum compound) butPtr->compound) { case COMPOUND_TOP: case COMPOUND_BOTTOM: { /* Image is above or below text */ @@ -324,8 +324,9 @@ TkpDisplayButton( textXOffset = (fullWidth - butPtr->textWidth)/2; imageXOffset = (fullWidth - width)/2; break; + } case COMPOUND_LEFT: - case COMPOUND_RIGHT: + case COMPOUND_RIGHT: { /* * Image is left or right of text */ @@ -341,7 +342,8 @@ TkpDisplayButton( textYOffset = (fullHeight - butPtr->textHeight)/2; imageYOffset = (fullHeight - height)/2; break; - case COMPOUND_CENTER: + } + case COMPOUND_CENTER: { /* * Image and text are superimposed */ @@ -355,8 +357,8 @@ TkpDisplayButton( textYOffset = (fullHeight - butPtr->textHeight)/2; imageYOffset = (fullHeight - height)/2; break; - case COMPOUND_NONE: - break; + } + case COMPOUND_NONE: {break;} } TkComputeAnchor(butPtr->anchor, tkwin, butPtr->padX, butPtr->padY, @@ -820,13 +822,12 @@ TkMacOSXInitControl ( */ initiallyVisible = false; - initialValue = kControlSupportsEmbedding| - kControlHasSpecialBackground; - minValue = 0; - maxValue = 1; - procID = kControlUserPaneProc; + initialValue = kControlSupportsEmbedding|kControlHasSpecialBackground; + minValue = 0; + maxValue = 1; + procID = kControlUserPaneProc; controlReference = (SInt32)mbPtr; - mbPtr->userPane = NewControl(mbPtr->windowRef, + mbPtr->userPane = NewControl(mbPtr->windowRef, paneRect, "\p", initiallyVisible, initialValue, @@ -840,7 +841,7 @@ TkMacOSXInitControl ( return 1; } - if ((status=EmbedControl(mbPtr->userPane,rootControl)) != noErr) { + if ((status = EmbedControl(mbPtr->userPane,rootControl)) != noErr) { fprintf(stderr,"Failed to embed user pane control %d\n", status); return 1; } @@ -910,22 +911,22 @@ TkMacOSXDrawControl( winPtr = (TkWindow *)butPtr->tkwin; - paneRect.left = winPtr->privatePtr->xOff; - paneRect.top = winPtr->privatePtr->yOff; - paneRect.right = paneRect.left + Tk_Width(butPtr->tkwin); + paneRect.left = winPtr->privatePtr->xOff; + paneRect.top = winPtr->privatePtr->yOff; + paneRect.right = paneRect.left + Tk_Width(butPtr->tkwin); paneRect.bottom = paneRect.top + Tk_Height(butPtr->tkwin); cntrRect = paneRect; /* - cntrRect.left += butPtr->inset; - cntrRect.top += butPtr->inset; - cntrRect.right -= butPtr->inset; + cntrRect.left += butPtr->inset; + cntrRect.top += butPtr->inset; + cntrRect.right -= butPtr->inset; cntrRect.bottom -= butPtr->inset; */ - cntrRect.left += DEF_INSET_LEFT; - cntrRect.top += DEF_INSET_TOP; - cntrRect.right -= DEF_INSET_RIGHT; + cntrRect.left += DEF_INSET_LEFT; + cntrRect.top += DEF_INSET_TOP; + cntrRect.right -= DEF_INSET_RIGHT; cntrRect.bottom -= DEF_INSET_BOTTOM; /* @@ -1144,7 +1145,7 @@ SetupBevelButton( if ((err = SetControlData(controlHandle, kControlButtonPart, kControlBevelButtonContentTag, sizeof(ControlButtonContentInfo), - (char *) &mbPtr->bevelButtonContent)) != noErr ) { + (char *) &mbPtr->bevelButtonContent)) != noErr) { fprintf(stderr, "SetControlData BevelButtonContent failed, %d\n", err ); } @@ -1172,7 +1173,7 @@ SetupBevelButton( if ((err = SetControlData(controlHandle, kControlButtonPart, kControlBevelButtonGraphicAlignTag, sizeof(ControlButtonGraphicAlignment), - (char *) &theAlignment)) != noErr ) { + (char *) &theAlignment)) != noErr) { fprintf(stderr, "SetControlData BevelButtonGraphicAlign failed, %d\n", err ); } @@ -1192,7 +1193,7 @@ SetupBevelButton( if ((err = SetControlData(controlHandle, kControlButtonPart, kControlBevelButtonTextPlaceTag, sizeof(ControlButtonTextPlacement), - (char *) &thePlacement)) != noErr ) { + (char *) &thePlacement)) != noErr) { fprintf(stderr, "SetControlData BevelButtonTextPlace failed, %d\n", err ); } diff --git a/macosx/tkMacOSXInit.c b/macosx/tkMacOSXInit.c index 5f415c8..f99124b 100644 --- a/macosx/tkMacOSXInit.c +++ b/macosx/tkMacOSXInit.c @@ -1,7 +1,7 @@ /* - * tkUnixInit.c -- + * tkMacOSXInit.c -- * - * This file contains Unix-specific interpreter initialization + * This file contains Mac OS X -specific interpreter initialization * functions. * * Copyright (c) 1995-1997 Sun Microsystems, Inc. @@ -10,11 +10,14 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXInit.c,v 1.3.2.2 2004/07/25 01:57:41 wolfsuit Exp $ + * RCS: @(#) $Id: tkMacOSXInit.c,v 1.3.2.3 2004/11/11 01:26:43 das Exp $ */ #include "tkInt.h" #include "tkMacOSXInt.h" +#include "tclInt.h" +#include +#include /* * The Init script (common to Windows and Unix platforms) is @@ -23,6 +26,15 @@ #include "tkInitScript.h" /* + * Define the following to 0 to not attempt to use an undocumented SPI + * to notify the window server that an unbundled executable is a full + * GUI application after loading Tk. + */ +#ifndef MAC_OSX_TK_USE_CPS_SPI +#define MAC_OSX_TK_USE_CPS_SPI 1 +#endif + +/* * The following structures are used to map the script/language codes of a * font to the name that should be passed to Tcl_GetEncoding() to obtain * the encoding for that font. The set of numeric constants is fixed and @@ -72,6 +84,11 @@ static Map scriptMap[] = { Tcl_Encoding TkMacOSXCarbonEncoding = NULL; +/* + * If the App is in an App package, then we want to add the Scripts + * directory to the auto_path. + */ +static char scriptPath[PATH_MAX + 1] = ""; /* *---------------------------------------------------------------------- @@ -95,30 +112,27 @@ int TkpInit(interp) Tcl_Interp *interp; { - char tkLibPath[1024]; - int result; - static int menusInitialized = false; - static int carbonEncodingInitialized = false; + static char tkLibPath[PATH_MAX + 1]; + static int tkMacOSXInitialized = false; /* * Since it is possible for TkInit to be called multiple times - * and we don't want to do the menu initialization multiple times + * and we don't want to do the initialization multiple times * we protect against doing it more than once. */ - if (menusInitialized == false) { - menusInitialized = true; + if (tkMacOSXInitialized == false) { + CFStringEncoding encoding; + char *encodingStr = NULL; + int i; + + tkMacOSXInitialized = true; + Tk_MacOSXSetupTkNotifier(); TkMacOSXInitAppleEvents(interp); TkMacOSXInitMenus(interp); TkMacOSXUseAntialiasedText(interp, TRUE); TkMacOSXInitCGDrawing(interp, TRUE, 3); - } - - if (carbonEncodingInitialized == false) { - CFStringEncoding encoding; - char *encodingStr = NULL; - int i; encoding = CFStringGetSystemEncoding(); @@ -136,20 +150,112 @@ TkpInit(interp) if (TkMacOSXCarbonEncoding == NULL) { TkMacOSXCarbonEncoding = Tcl_GetEncoding (NULL, NULL); } - } + + /* + * When Tk is in a framework, force tcl_findLibrary to look in the + * framework scripts directory. + * FIXME: Should we come up with a more generic way of doing this? + */ + + Tcl_MacOSXOpenVersionedBundleResources(interp, + "com.tcltk.tklibrary", TK_VERSION, 1, 1024, tkLibPath); + + /* + * If we don't have a TTY and stdin is a special character file of length 0, + * (e.g. /dev/null, which is what Finder sets when double clicking Wish) + * then use the Tk based console interpreter. + */ - /* - * When Tk is in a framework, force tcl_findLibrary to look in the - * framework scripts directory. - * FIXME: Should we come up with a more generic way of doing this? - */ - - result = Tcl_MacOSXOpenVersionedBundleResources(interp, - "com.tcltk.tklibrary", TK_VERSION, 1, 1024, tkLibPath); - - if (result != TCL_ERROR) { + if (!isatty(0)) { + struct stat st; + if (fstat(0, &st) || (S_ISCHR(st.st_mode) && st.st_blocks == 0)) { + Tk_InitConsoleChannels(interp); + Tcl_RegisterChannel(interp, Tcl_GetStdChannel(TCL_STDIN)); + Tcl_RegisterChannel(interp, Tcl_GetStdChannel(TCL_STDOUT)); + Tcl_RegisterChannel(interp, Tcl_GetStdChannel(TCL_STDERR)); + if (Tk_CreateConsoleWindow(interp) == TCL_OK) { + /* Only show the console if we don't have a startup script */ + if (TclGetStartupScriptPath() == NULL) { + Tcl_Eval(interp, "console show"); + } + } + } + } +#if MAC_OSX_TK_USE_CPS_SPI + /* + * If we are loaded into an executable that is not a bundled application, + * the window server does not let us come to the foreground. + * For such an executable, we attempt to use an undocumented SPI to + * notify the window server that we are now a full GUI application. + */ + { + /* Check whether we are a bundled executable: */ + int bundledExecutable = 0; + CFBundleRef bundleRef = CFBundleGetMainBundle(); + CFURLRef bundleUrl = NULL; + if (bundleRef) { + bundleUrl = CFBundleCopyBundleURL(bundleRef); + } + if (bundleUrl) { + /* + * A bundled executable is two levels down from its main bundle + * directory (e.g. Wish.app/Contents/MacOS/Wish), whereas + * an unbundled executable's main bundle directory is just + * the directory containing the executable. + * So to check whether we are bundled, we delete the last three + * path components of the executable's url and compare the + * resulting url with the main bundle url. + */ + int j = 3; + CFURLRef url = CFBundleCopyExecutableURL(bundleRef); + while (url && j--) { + CFURLRef parent = CFURLCreateCopyDeletingLastPathComponent(NULL, url); + CFRelease(url); + url = parent; + } + if (url) { + bundledExecutable = CFEqual(bundleUrl, url); + CFRelease(url); + } + CFRelease(bundleUrl); + } + + /* If we are not a bundled executable, attempt to use the CPS SPI: */ + if (!bundledExecutable) { + /* + * Load the CPS SPI symbol dynamically, so that we don't break + * if it every disappears or changes its name. + */ + OSErr (*cpsEnableForegroundOperation)(ProcessSerialNumberPtr) = NULL; + NSSymbol nsSymbol; + if(NSIsSymbolNameDefinedWithHint( + "_CPSEnableForegroundOperation", "CoreGraphics")) { + nsSymbol = NSLookupAndBindSymbolWithHint( + "_CPSEnableForegroundOperation", "CoreGraphics"); + if(nsSymbol) { + cpsEnableForegroundOperation = NSAddressOfSymbol(nsSymbol); + } + } + if (cpsEnableForegroundOperation) { + ProcessSerialNumber psn = { 0, kCurrentProcess }; + /* + * Let the window server know that we are a foregroundable app + */ + cpsEnableForegroundOperation(&psn); + } + } + } +#endif /* MAC_OSX_TK_USE_CPS_SPI */ + } + + if (tkLibPath[0] != '\0') { Tcl_SetVar(interp, "tk_library", tkLibPath, TCL_GLOBAL_ONLY); } + + if (scriptPath[0] != '\0') { + Tcl_SetVar(interp, "auto_path", scriptPath, + TCL_GLOBAL_ONLY|TCL_LIST_ELEMENT|TCL_APPEND_VALUE); + } return Tcl_Eval(interp, initScript); } @@ -221,3 +327,59 @@ TkpDisplayWarning(msg, title) Tcl_WriteChars(errChannel, "\n", 1); } } + +/* + *---------------------------------------------------------------------- + * + * TkMacOSXDefaultStartupScript -- + * + * + * On MacOS X, we look for a file in the Resources/Scripts + * directory called AppMain.tcl and if found, we set argv[1] to + * that, so that the rest of the code will find it, and add the + * Scripts folder to the auto_path. If we don't find the startup + * script, we just bag it, assuming the user is starting up some + * other way. + * + * Results: + * None. + * + * Side effects: + * TclSetStartupScriptFileName() called when AppMain.tcl found. + * + *---------------------------------------------------------------------- + */ + +void +TkMacOSXDefaultStartupScript(void) +{ + CFBundleRef bundleRef; + + bundleRef = CFBundleGetMainBundle(); + + if (bundleRef != NULL) { + CFURLRef appMainURL; + appMainURL = CFBundleCopyResourceURL(bundleRef, + CFSTR("AppMain"), + CFSTR("tcl"), + CFSTR("Scripts")); + + if (appMainURL != NULL) { + CFURLRef scriptFldrURL; + char startupScript[PATH_MAX + 1]; + + if (CFURLGetFileSystemRepresentation (appMainURL, true, + startupScript, PATH_MAX)) { + TclSetStartupScriptFileName(startupScript); + scriptFldrURL = CFURLCreateCopyDeletingLastPathComponent( + NULL, appMainURL); + if (scriptFldrURL != NULL) { + CFURLGetFileSystemRepresentation(scriptFldrURL, + true, scriptPath, PATH_MAX); + CFRelease(scriptFldrURL); + } + } + CFRelease(appMainURL); + } + } +} diff --git a/macosx/tkMacOSXInt.h b/macosx/tkMacOSXInt.h index 12ac566..b5347f9 100644 --- a/macosx/tkMacOSXInt.h +++ b/macosx/tkMacOSXInt.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: tkMacOSXInt.h,v 1.3.2.1 2004/07/25 01:57:41 wolfsuit Exp $ + * RCS: @(#) $Id: tkMacOSXInt.h,v 1.3.2.2 2004/11/11 01:26:43 das Exp $ */ #ifndef _TKMACINT @@ -152,6 +152,7 @@ extern Tcl_Encoding TkMacOSXCarbonEncoding; extern int TkMacOSXUseAntialiasedText(Tcl_Interp *interp, int enable); extern int TkMacOSXInitCGDrawing(Tcl_Interp *interp, int enable, int antiAlias); +extern void TkMacOSXDefaultStartupScript(void); #include "tkIntPlatDecls.h" diff --git a/macosx/tkMacOSXMenus.c b/macosx/tkMacOSXMenus.c index 892ef8a..b1aebe8 100644 --- a/macosx/tkMacOSXMenus.c +++ b/macosx/tkMacOSXMenus.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: tkMacOSXMenus.c,v 1.2.2.2 2004/03/17 19:01:47 wolfsuit Exp $ + * RCS: @(#) $Id: tkMacOSXMenus.c,v 1.2.2.3 2004/11/11 01:26:43 das Exp $ */ #include "tk.h" @@ -31,7 +31,6 @@ #define kSourceItem 1 #define kCloseItem 2 -#define kQuitItem 4 #define EDIT_CUT 1 #define EDIT_COPY 2 @@ -110,14 +109,6 @@ TkMacOSXHandleMenuSelect( tkwin = Tk_IdToWindow(dispPtr->display, window); TkGenWMDestroyEvent(tkwin); break; - case kQuitItem: - /* Exit */ - if (optionKeyPressed || gInterp == NULL) { - Tcl_Exit(0); - } else { - Tcl_Eval(gInterp, "exit"); - } - break; } break; case kEditMenu: @@ -190,14 +181,7 @@ TkMacOSXInitMenus( AppendMenu(tkFileMenu, "\pSourceÉ"); AppendMenu(tkFileMenu, "\pClose/W"); - /* - * These don't belong in the File menu on Mac OS X. - */ - -#if 0 - AppendMenu(tkFileMenu, "\p(-"); - AppendMenu(tkFileMenu, "\pQuit/Q"); -#endif + if (TkMacOSXUseMenuID(kEditMenu) != TCL_OK) { panic("Menu ID %d is already in use!", kEditMenu); } diff --git a/macosx/tkMacOSXMouseEvent.c b/macosx/tkMacOSXMouseEvent.c index cab8a93..168ef73 100644 --- a/macosx/tkMacOSXMouseEvent.c +++ b/macosx/tkMacOSXMouseEvent.c @@ -117,6 +117,7 @@ TkMacOSXProcessMouseEvent(TkMacOSXEvent *eventPtr, MacEventStatus * statusPtr) int status,err; MouseEventData mouseEventData, * medPtr = &mouseEventData; KeyMap keyMap; + long modif; switch (eventPtr->eKind) { case kEventMouseUp: @@ -140,19 +141,21 @@ TkMacOSXProcessMouseEvent(TkMacOSXEvent *eventPtr, MacEventStatus * statusPtr) } medPtr->state = 0; GetKeys(keyMap); - if (keyMap[1] & 2) { + modif = EndianS32_BtoN(*(long*)(&keyMap[1])); + + if (modif & 2) { medPtr->state |= LockMask; } - if (keyMap[1] & 1) { + if (modif & 1) { medPtr->state |= ShiftMask; } - if (keyMap[1] & 8) { + if (modif & 8) { medPtr->state |= ControlMask; } - if (keyMap[1] & 32768) { + if (modif & 32768) { medPtr->state |= Mod1Mask; /* command key */ } - if (keyMap[1] & 4) { + if (modif & 4) { medPtr->state |= Mod2Mask; /* option key */ } if (eventPtr->eKind == kEventMouseDown @@ -381,7 +384,7 @@ TkMacOSXProcessMouseEvent(TkMacOSXEvent *eventPtr, MacEventStatus * statusPtr) TkMacOSXPreprocessMenu(); TkMacOSXHandleMenuSelect(MenuSelect(where), - theKeys[1] & 4); + EndianS32_BtoN(*(long*)(&theKeys[1])) & 4); Tcl_SetServiceMode(oldMode); return true; /* TODO: may not be on event on queue. */ } @@ -678,30 +681,33 @@ TkMacOSXButtonKeyState() { unsigned int state = 0; KeyMap theKeys; + long modif; if (Button() & !gEatButtonUp) { state |= Button1Mask; } GetKeys(theKeys); + + modif = EndianS32_BtoN(*(long*)(&theKeys[1])); - if (theKeys[1] & 2) { + if (modif & 2) { state |= LockMask; } - if (theKeys[1] & 1) { + if (modif & 1) { state |= ShiftMask; } - if (theKeys[1] & 8) { + if (modif & 8) { state |= ControlMask; } - if (theKeys[1] & 32768) { + if (modif & 32768) { state |= Mod1Mask; /* command key */ } - if (theKeys[1] & 4) { + if (modif & 4) { state |= Mod2Mask; /* option key */ } diff --git a/macosx/tkMacOSXRegion.c b/macosx/tkMacOSXRegion.c index 0fce0c0..12270f5 100644 --- a/macosx/tkMacOSXRegion.c +++ b/macosx/tkMacOSXRegion.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXRegion.c,v 1.2 2002/08/31 06:12:30 das Exp $ + * RCS: @(#) $Id: tkMacOSXRegion.c,v 1.2.2.1 2004/11/11 01:26:43 das Exp $ */ #include "tkInt.h" @@ -139,7 +139,7 @@ TkUnionRectWithRegion( tmpRgn = NewRgn(); } SetRectRgn(tmpRgn, rectangle->x, rectangle->y, - rectangle->x + rectangle->width, rectangle->y + rectangle->height); + rectangle->x + rectangle->width, rectangle->y + rectangle->height); UnionRgn(srcRgn, tmpRgn, destRgn); } @@ -177,11 +177,11 @@ TkRectInRegion( SetRectRgn(rectRgn, x, y, x + width, y + height); SectRgn(rgn, rectRgn, destRgn); if (EmptyRgn(destRgn)) { - result = RectangleOut; + result = RectangleOut; } else if (EqualRgn(rgn, destRgn)) { - result = RectangleIn; + result = RectangleIn; } else { - result = RectanglePart; + result = RectanglePart; } DisposeRgn(rectRgn); DisposeRgn(destRgn); diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c index 3783017..fda9ae5 100644 --- a/macosx/tkMacOSXSubwindows.c +++ b/macosx/tkMacOSXSubwindows.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXSubwindows.c,v 1.2.2.2 2004/03/21 03:54:59 wolfsuit Exp $ + * RCS: @(#) $Id: tkMacOSXSubwindows.c,v 1.2.2.3 2004/11/11 01:26:43 das Exp $ */ #include "tkInt.h" @@ -505,8 +505,8 @@ XMoveResizeWindow( macWin->winPtr->changes.x; deltaY += macParent->yOff + parentBorderwidth + macWin->winPtr->changes.y; - - UpdateOffsets(macWin->winPtr, deltaX, deltaY); + + UpdateOffsets(macWin->winPtr, deltaX, deltaY); TkMacOSXWinBounds(macWin->winPtr, &bounds); InvalWindowRect(GetWindowFromPort(destPort),&bounds); GenerateConfigureNotify(macWin->winPtr, 0); @@ -611,7 +611,7 @@ XMoveWindow( UpdateOffsets(macWin->winPtr, deltaX, deltaY); TkMacOSXWinBounds(macWin->winPtr, &bounds); InvalWindowRect(GetWindowFromPort(destPort),&bounds); - GenerateConfigureNotify(macWin->winPtr, 0); + GenerateConfigureNotify(macWin->winPtr, 0); } } diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index d1477f0..fe8b9a0 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.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: tkMacOSXWm.c,v 1.7.2.5 2004/10/05 22:27:26 hobbs Exp $ + * RCS: @(#) $Id: tkMacOSXWm.c,v 1.7.2.6 2004/11/11 01:26:43 das Exp $ */ #include @@ -90,6 +90,7 @@ static void WmAttrGetModifiedStatus(WindowRef macWindow, Tcl_Obj *result); static void WmAttrGetTitlePath(WindowRef macWindow, Tcl_Obj *result); +static void WmAttrGetAlpha(WindowRef macWindow, Tcl_Obj *result); static int WmClientCmd _ANSI_ARGS_((Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); @@ -773,17 +774,19 @@ Tcl_Obj *CONST objv[]; /* Argument objects. */ const char *optionTable[] = { "-modified", "-titlepath", + "-alpha", (char *)NULL }; enum optionIdx { WmAttrModifiedIdx, - WmAttrTitlePathIdx + WmAttrTitlePathIdx, + WmAttrAlphaIdx, }; /* Must have objc >= 3 at this point. */ if (objc < 3) { - Tcl_WrongNumArgs(interp, 0, objv, - "wm attributes window ?-modified ?bool?? ?-titlepath ?path??"); + Tcl_WrongNumArgs(interp, 1, objv, + "attributes window ?-modified ?bool?? ?-titlepath ?path?? ?-alpha ?double??"); return TCL_ERROR; } @@ -795,6 +798,8 @@ Tcl_Obj *CONST objv[]; /* Argument objects. */ WmAttrGetModifiedStatus(macWindow, result); Tcl_AppendToObj(result, " -titlepath ", -1); WmAttrGetTitlePath(macWindow, result); + Tcl_AppendToObj(result, " -alpha ", -1); + WmAttrGetAlpha(macWindow, result); Tcl_SetObjResult(interp, result); return TCL_OK; } @@ -811,6 +816,9 @@ Tcl_Obj *CONST objv[]; /* Argument objects. */ case WmAttrTitlePathIdx: WmAttrGetTitlePath(macWindow, result); break; + case WmAttrAlphaIdx: + WmAttrGetAlpha(macWindow, result); + break; } Tcl_SetObjResult(interp, result); return TCL_OK; @@ -818,7 +826,7 @@ Tcl_Obj *CONST objv[]; /* Argument objects. */ if ( (objc - 3) % 2 != 0 ) { Tcl_WrongNumArgs(interp, 3, objv, - "?-modified ?bool?? ?-titlepath ?path??"); + "?-modified ?bool?? ?-titlepath ?path?? ?-alpha ?double??"); return TCL_ERROR; } for (i = 3; i < objc; i += 2) { @@ -827,6 +835,7 @@ Tcl_Obj *CONST objv[]; /* Argument objects. */ FSRef ref; AliasHandle alias; Boolean isDirectory; + double dval; if (Tcl_GetIndexFromObj(interp, objv[i], optionTable, "option", 0, &index) != TCL_OK) { @@ -860,6 +869,22 @@ Tcl_Obj *CONST objv[]; /* Argument objects. */ result = objv[i+1]; } break; + case WmAttrAlphaIdx: + if (Tcl_GetDoubleFromObj(interp, objv[i+1], &dval) != + TCL_OK) { + return TCL_ERROR; + } + /* + * The user should give (transparent) 0 .. 1.0 (opaque) + */ + if (dval < 0.0) { + dval = 0.0; + } else if (dval > 1.0) { + dval = 1.0; + } + result = Tcl_NewDoubleObj(dval); + SetWindowAlpha(macWindow, dval); + break; } } Tcl_SetObjResult(interp, result); @@ -928,6 +953,31 @@ static void WmAttrGetTitlePath(WindowRef macWindow, Tcl_Obj *result) /* *---------------------------------------------------------------------- + * WmAttrGetAlpha -- + * + * Helper procedure to retrieve the -alpha option for the wm + * attributes command. + * + * Results: + * Nothing. + * + * Side effects: + * Appends the alpha value of the given window to the Tcl_Obj + * passed in. + * + *---------------------------------------------------------------------- + */ +static void WmAttrGetAlpha(WindowRef macWindow, Tcl_Obj *result) +{ + float fval; + if (GetWindowAlpha(macWindow, &fval) != noErr) { + fval = 1.0; + } + Tcl_AppendObjToObj(result, Tcl_NewDoubleObj(fval)); +} + +/* + *---------------------------------------------------------------------- * * WmClientCmd -- * @@ -1547,16 +1597,16 @@ Tcl_Obj *CONST objv[]; /* Argument objects. */ wmPtr->hints.flags &= ~IconPixmapHint; } else { OSErr err; - FSSpec spec; + AliasHandle alias; FSRef ref; Boolean isDirectory; err = FSPathMakeRef(Tcl_GetStringFromObj(objv[3], NULL), &ref, &isDirectory); if (err == noErr) { - err = FSGetCatalogInfo (&ref, kFSCatInfoNone, NULL, NULL, &spec, NULL); + err = FSNewAlias(NULL, &ref, &alias); if (err == noErr) { WindowRef macWin = GetWindowFromPort(TkMacOSXGetDrawablePort(winPtr->window)); - SetWindowProxyFSSpec(macWin, &spec); + SetWindowProxyAlias(macWin, alias); return TCL_OK; } } @@ -5050,9 +5100,9 @@ TkMacOSXMakeRealWindowExist( return; } else if (gMacEmbedHandler != NULL) { if (gMacEmbedHandler->containerExistProc != NULL) { - if (gMacEmbedHandler->containerExistProc((Tk_Window) winPtr) != TCL_OK) { + if (gMacEmbedHandler->containerExistProc((Tk_Window) winPtr) != TCL_OK) { panic("ContainerExistProc could not make container"); - } + } } return; } else { -- cgit v0.12