From 1cd7efa2147112cf8ef4194985bfc1c24b622aa5 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 4 Jun 2013 13:24:09 +0000 Subject: Eliminate NO_VIZ macro as current zlib uses HAVE_HIDDEN in stead. One more last-moment fix for FreeBSD by Pietro Cerutti --- ChangeLog | 6 ++++++ unix/configure | 32 ++++++++++++-------------------- unix/tcl.m4 | 12 ++---------- unix/tkConfig.h.in | 6 +++--- 4 files changed, 23 insertions(+), 33 deletions(-) diff --git a/ChangeLog b/ChangeLog index 209287d..e6a74da 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2013-06-04 Jan Nijtmans + + * unix/tcl.m4: Eliminate NO_VIZ macro as current + zlib uses HAVE_HIDDEN in stead. One more last-moment + fix for FreeBSD by Pietro Cerutti + 2013-05-23 Jan Nijtmans * unix/tcl.m4: [Bug 3613668]: XFilterEvent() hangs. diff --git a/unix/configure b/unix/configure index 09eff0b..095165d 100755 --- a/unix/configure +++ b/unix/configure @@ -4463,6 +4463,11 @@ cat >>confdefs.h <<\_ACEOF _ACEOF +cat >>confdefs.h <<\_ACEOF +#define HAVE_HIDDEN 1 +_ACEOF + + fi @@ -5673,20 +5678,12 @@ fi fi - case $system in - FreeBSD-3.*) - # FreeBSD-3 doesn't handle version numbers with dots. - UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.a' - SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so' - TCL_LIB_VERSIONS_OK=nodots - ;; - esac ;; FreeBSD-*) # This configuration from FreeBSD Ports. SHLIB_CFLAGS="-fPIC" SHLIB_LD="${CC} -shared" - TCL_SHLIB_LD_EXTRAS="-Wl,-soname,\$@" + TCL_SHLIB_LD_EXTRAS="-Wl,-soname=\$@" SHLIB_SUFFIX=".so" DL_OBJS="tclLoadDl.o" DL_LIBS="" @@ -6903,11 +6900,6 @@ cat >>confdefs.h <<\_ACEOF _ACEOF -cat >>confdefs.h <<\_ACEOF -#define NO_VIZ -_ACEOF - - fi @@ -9876,7 +9868,7 @@ ac_x_header_dirs=' /usr/openwin/share/include' if test "$ac_x_includes" = no; then - # Guess where to find include files, by looking for Xlib.h. + # Guess where to find include files, by looking for Intrinsic.h. # First, try using that file with no special directory specified. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -9884,7 +9876,7 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include +#include _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 @@ -9911,7 +9903,7 @@ else sed 's/^/| /' conftest.$ac_ext >&5 for ac_dir in $ac_x_header_dirs; do - if test -r "$ac_dir/X11/Xlib.h"; then + if test -r "$ac_dir/X11/Intrinsic.h"; then ac_x_includes=$ac_dir break fi @@ -9925,18 +9917,18 @@ if test "$ac_x_libraries" = no; then # See if we find them without any special options. # Don't add to $LIBS permanently. ac_save_LIBS=$LIBS - LIBS="-lX11 $LIBS" + LIBS="-lXt $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include +#include int main () { -XrmInitialize () +XtMalloc (0) ; return 0; } diff --git a/unix/tcl.m4 b/unix/tcl.m4 index cc7c936..43e2b78 100644 --- a/unix/tcl.m4 +++ b/unix/tcl.m4 @@ -1067,6 +1067,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [ AC_DEFINE(MODULE_SCOPE, [extern __attribute__((__visibility__("hidden")))], [Compiler support for module scope symbols]) + AC_DEFINE(HAVE_HIDDEN, [1], [Compiler support for module scope symbols]) ]) ]) @@ -1537,20 +1538,12 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [ CFLAGS="$CFLAGS -pthread" LDFLAGS="$LDFLAGS -pthread" ]) - case $system in - FreeBSD-3.*) - # FreeBSD-3 doesn't handle version numbers with dots. - UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.a' - SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so' - TCL_LIB_VERSIONS_OK=nodots - ;; - esac ;; FreeBSD-*) # This configuration from FreeBSD Ports. SHLIB_CFLAGS="-fPIC" SHLIB_LD="${CC} -shared" - TCL_SHLIB_LD_EXTRAS="-Wl,-soname,\$[@]" + TCL_SHLIB_LD_EXTRAS="-Wl,-soname=\$[@]" SHLIB_SUFFIX=".so" DL_OBJS="tclLoadDl.o" DL_LIBS="" @@ -2048,7 +2041,6 @@ dnl # preprocessing tests use only CPPFLAGS. AS_IF([test "$tcl_cv_cc_visibility_hidden" != yes], [ AC_DEFINE(MODULE_SCOPE, [extern], [No Compiler support for module scope symbols]) - AC_DEFINE(NO_VIZ, [], [No visibility attribute]) ]) AS_IF([test "$SHARED_LIB_SUFFIX" = ""], [ diff --git a/unix/tkConfig.h.in b/unix/tkConfig.h.in index 2efd164..575f36c 100644 --- a/unix/tkConfig.h.in +++ b/unix/tkConfig.h.in @@ -16,6 +16,9 @@ /* Do we have access to Darwin CoreFoundation.framework? */ #undef HAVE_COREFOUNDATION +/* Compiler support for module scope symbols */ +#undef HAVE_HIDDEN + /* Do we have the intptr_t type? */ #undef HAVE_INTPTR_T @@ -118,9 +121,6 @@ /* Do we have ? */ #undef NO_STDLIB_H -/* No visibility attribute */ -#undef NO_VIZ - /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT -- cgit v0.12 From 2275b2df0bd62cd1b7548b48fc7c40f784fd30cd Mon Sep 17 00:00:00 2001 From: stwo Date: Sun, 7 Jul 2013 00:43:18 +0000 Subject: OpenBSD/m88k is now elf. Remove unneeded elf check. --- unix/configure | 55 ++++++++++--------------------------------------------- unix/tcl.m4 | 15 ++++----------- 2 files changed, 14 insertions(+), 56 deletions(-) diff --git a/unix/configure b/unix/configure index 764c597..d5537f2 100755 --- a/unix/configure +++ b/unix/configure @@ -5572,11 +5572,12 @@ fi OpenBSD-*) arch=`arch -s` case "$arch" in - m88k|vax) + vax) # Equivalent using configure option --disable-load # Step 4 will set the necessary variables DL_OBJS="" SHLIB_LD_LIBS="" + LDFLAGS="" ;; *) SHLIB_CFLAGS="-fPIC" @@ -5591,10 +5592,11 @@ fi LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so.${SHLIB_VERSION}' + LDFLAGS="-Wl,-export-dynamic" ;; esac case "$arch" in - m88k|vax) + vax) CFLAGS_OPTIMIZE="-O1" ;; sh) @@ -5604,43 +5606,6 @@ fi CFLAGS_OPTIMIZE="-O2" ;; esac - echo "$as_me:$LINENO: checking for ELF" >&5 -echo $ECHO_N "checking for ELF... $ECHO_C" >&6 -if test "${tcl_cv_ld_elf+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -#ifdef __ELF__ - yes -#endif - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "yes" >/dev/null 2>&1; then - tcl_cv_ld_elf=yes -else - tcl_cv_ld_elf=no -fi -rm -f conftest* - -fi -echo "$as_me:$LINENO: result: $tcl_cv_ld_elf" >&5 -echo "${ECHO_T}$tcl_cv_ld_elf" >&6 - if test $tcl_cv_ld_elf = yes; then - - LDFLAGS=-Wl,-export-dynamic - -else - LDFLAGS="" -fi - if test "${TCL_THREADS}" = "1"; then # On OpenBSD: Compile with -pthread @@ -9842,7 +9807,7 @@ ac_x_header_dirs=' /usr/openwin/share/include' if test "$ac_x_includes" = no; then - # Guess where to find include files, by looking for Xlib.h. + # Guess where to find include files, by looking for Intrinsic.h. # First, try using that file with no special directory specified. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -9850,7 +9815,7 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include +#include _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 @@ -9877,7 +9842,7 @@ else sed 's/^/| /' conftest.$ac_ext >&5 for ac_dir in $ac_x_header_dirs; do - if test -r "$ac_dir/X11/Xlib.h"; then + if test -r "$ac_dir/X11/Intrinsic.h"; then ac_x_includes=$ac_dir break fi @@ -9891,18 +9856,18 @@ if test "$ac_x_libraries" = no; then # See if we find them without any special options. # Don't add to $LIBS permanently. ac_save_LIBS=$LIBS - LIBS="-lX11 $LIBS" + LIBS="-lXt $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include +#include int main () { -XrmInitialize () +XtMalloc (0) ; return 0; } diff --git a/unix/tcl.m4 b/unix/tcl.m4 index b69d5a6..77f7911 100644 --- a/unix/tcl.m4 +++ b/unix/tcl.m4 @@ -1473,11 +1473,12 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [ OpenBSD-*) arch=`arch -s` case "$arch" in - m88k|vax) + vax) # Equivalent using configure option --disable-load # Step 4 will set the necessary variables DL_OBJS="" SHLIB_LD_LIBS="" + LDFLAGS="" ;; *) SHLIB_CFLAGS="-fPIC" @@ -1489,10 +1490,11 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [ CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}']) LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so.${SHLIB_VERSION}' + LDFLAGS="-Wl,-export-dynamic" ;; esac case "$arch" in - m88k|vax) + vax) CFLAGS_OPTIMIZE="-O1" ;; sh) @@ -1502,15 +1504,6 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [ CFLAGS_OPTIMIZE="-O2" ;; esac - AC_CACHE_CHECK([for ELF], tcl_cv_ld_elf, [ - AC_EGREP_CPP(yes, [ -#ifdef __ELF__ - yes -#endif - ], tcl_cv_ld_elf=yes, tcl_cv_ld_elf=no)]) - AS_IF([test $tcl_cv_ld_elf = yes], [ - LDFLAGS=-Wl,-export-dynamic - ], [LDFLAGS=""]) AS_IF([test "${TCL_THREADS}" = "1"], [ # On OpenBSD: Compile with -pthread # Don't link with -lpthread -- cgit v0.12 From 771103dda69711d0ecde7e072cdfdafdecebf5de Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 26 Jul 2013 14:23:40 +0000 Subject: Don't hardcode "tclWinError.o" for Cygwin. --- unix/configure | 3 ++- unix/tcl.m4 | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/unix/configure b/unix/configure index e1e7dff..3682600 100755 --- a/unix/configure +++ b/unix/configure @@ -4914,7 +4914,8 @@ fi SHLIB_LD='${CC} -shared' SHLIB_SUFFIX=".dll" DL_OBJS="tclLoadDl.o" - PLAT_OBJS="tclWinError.o" + PLAT_OBJS='${CYGWIN_OBJS}' + PLAT_SRCS='${CYGWIN_SRCS}' DL_LIBS="-ldl" CC_SEARCH_FLAGS="" LD_SEARCH_FLAGS="" diff --git a/unix/tcl.m4 b/unix/tcl.m4 index dc5c16a..f12d0a8 100644 --- a/unix/tcl.m4 +++ b/unix/tcl.m4 @@ -1225,7 +1225,8 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [ SHLIB_LD='${CC} -shared' SHLIB_SUFFIX=".dll" DL_OBJS="tclLoadDl.o" - PLAT_OBJS="tclWinError.o" + PLAT_OBJS='${CYGWIN_OBJS}' + PLAT_SRCS='${CYGWIN_SRCS}' DL_LIBS="-ldl" CC_SEARCH_FLAGS="" LD_SEARCH_FLAGS="" -- cgit v0.12 From 6ade212617398e54a7180a5548887dddf00ef119 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 31 Jul 2013 11:47:40 +0000 Subject: Suggested fix for Bug [069c9e43c4] --- generic/tkConfig.c | 121 +++++++++++++++-------------------------------------- generic/tkTest.c | 1 + tests/config.test | 4 +- 3 files changed, 36 insertions(+), 90 deletions(-) diff --git a/generic/tkConfig.c b/generic/tkConfig.c index e06d5d5..1cfe1fb 100644 --- a/generic/tkConfig.c +++ b/generic/tkConfig.c @@ -31,7 +31,12 @@ * the option tables that have been created for an interpreter. */ -#define OPTION_HASH_KEY "TkOptionTable" +typedef struct ThreadSpecificData { + int initialized; /* 0 means table below needs initializing. */ + Tcl_HashTable hashTable; +} ThreadSpecificData; +static Tcl_ThreadDataKey dataKey; + /* * The following two structures are used along with Tk_OptionSpec structures @@ -100,8 +105,6 @@ typedef struct OptionTable { * chain. */ int numOptions; /* The number of items in the options array * below. */ - int refCount2; /* Reference counter for controlling the freeing - * of the memory occupied by this OptionTable */ Option options[1]; /* Information about the individual options in * the table. This must be the last field in * the structure: the actual size of the array @@ -115,8 +118,6 @@ typedef struct OptionTable { static int DoObjConfig(Tcl_Interp *interp, char *recordPtr, Option *optionPtr, Tcl_Obj *valuePtr, Tk_Window tkwin, Tk_SavedOption *savePtr); -static void DestroyOptionHashTable(ClientData clientData, - Tcl_Interp *interp); static void FreeResources(Option *optionPtr, Tcl_Obj *objPtr, char *internalPtr, Tk_Window tkwin); static Tcl_Obj * GetConfigList(char *recordPtr, @@ -170,30 +171,26 @@ Tk_CreateOptionTable( /* Static information about the configuration * options. */ { - Tcl_HashTable *hashTablePtr; Tcl_HashEntry *hashEntryPtr; int newEntry; OptionTable *tablePtr; const Tk_OptionSpec *specPtr, *specPtr2; Option *optionPtr; int numOptions, i; + ThreadSpecificData *tsdPtr = + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); /* - * We use an AssocData value in the interpreter to keep a hash table of - * all the option tables we've created for this application. This is used - * for two purposes. First, it allows us to share the tables (e.g. in - * several chains) and second, we use the deletion callback for the - * AssocData to delete all the option tables when the interpreter is - * deleted. The code below finds the hash table or creates a new one if it + * We use an TSD in the thread to keep a hash table of + * all the option tables we've created for this application. This is + * used for allowing us to share the tables (e.g. in several chains). + * The code below finds the hash table or creates a new one if it * doesn't already exist. */ - hashTablePtr = Tcl_GetAssocData(interp, OPTION_HASH_KEY, NULL); - if (hashTablePtr == NULL) { - hashTablePtr = ckalloc(sizeof(Tcl_HashTable)); - Tcl_InitHashTable(hashTablePtr, TCL_ONE_WORD_KEYS); - Tcl_SetAssocData(interp, OPTION_HASH_KEY, DestroyOptionHashTable, - hashTablePtr); + if (!tsdPtr->initialized) { + Tcl_InitHashTable(&tsdPtr->hashTable, TCL_ONE_WORD_KEYS); + tsdPtr->initialized = 1; } /* @@ -201,7 +198,7 @@ Tk_CreateOptionTable( * reuse the existing table. */ - hashEntryPtr = Tcl_CreateHashEntry(hashTablePtr, (char *) templatePtr, + hashEntryPtr = Tcl_CreateHashEntry(&tsdPtr->hashTable, (char *) templatePtr, &newEntry); if (!newEntry) { tablePtr = Tcl_GetHashValue(hashEntryPtr); @@ -220,7 +217,6 @@ Tk_CreateOptionTable( } tablePtr = ckalloc(sizeof(OptionTable) + (numOptions * sizeof(Option))); tablePtr->refCount = 1; - tablePtr->refCount2 = 1; tablePtr->hashEntryPtr = hashEntryPtr; tablePtr->nextPtr = NULL; tablePtr->numOptions = numOptions; @@ -334,9 +330,16 @@ Tk_DeleteOptionTable( OptionTable *tablePtr = (OptionTable *) optionTable; Option *optionPtr; int count; + ThreadSpecificData *tsdPtr = + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); - tablePtr->refCount--; - if (tablePtr->refCount > 0) { + if (tablePtr->refCount > 1) { + tablePtr->refCount--; + return; + } + + if (!tsdPtr->initialized || !Tcl_FindHashEntry(&tsdPtr->hashTable, + tablePtr->hashEntryPtr)) { return; } @@ -356,62 +359,7 @@ Tk_DeleteOptionTable( } } Tcl_DeleteHashEntry(tablePtr->hashEntryPtr); - tablePtr->refCount2--; - if (tablePtr->refCount2 <= 0) { - ckfree(tablePtr); - } -} - -/* - *---------------------------------------------------------------------- - * - * DestroyOptionHashTable -- - * - * This function is the deletion callback associated with the AssocData - * entry created by Tk_CreateOptionTable. It is invoked when an - * interpreter is deleted, and deletes all of the option tables - * associated with that interpreter. - * - * Results: - * None. - * - * Side effects: - * The option hash table is destroyed along with all of the OptionTable - * structures that it refers to. - * - *---------------------------------------------------------------------- - */ - -static void -DestroyOptionHashTable( - ClientData clientData, /* The hash table we are destroying */ - Tcl_Interp *interp) /* The interpreter we are destroying */ -{ - Tcl_HashTable *hashTablePtr = clientData; - Tcl_HashSearch search; - Tcl_HashEntry *hashEntryPtr; - - for (hashEntryPtr = Tcl_FirstHashEntry(hashTablePtr, &search); - hashEntryPtr != NULL; - hashEntryPtr = Tcl_NextHashEntry(&search)) { - OptionTable *tablePtr = Tcl_GetHashValue(hashEntryPtr); - - /* - * The following statements do two tricky things: - * 1. They ensure that the option table is deleted, even if there are - * outstanding references to it. - * 2. They ensure that Tk_DeleteOptionTable doesn't delete other - * tables chained from this one; we'll do it when we come across - * the hash table entry for the chained table (in fact, the chained - * table may already have been deleted). - */ - - tablePtr->refCount = 1; - tablePtr->nextPtr = NULL; - Tk_DeleteOptionTable((Tk_OptionTable) tablePtr); - } - Tcl_DeleteHashTable(hashTablePtr); - ckfree(hashTablePtr); + ckfree(tablePtr); } /* @@ -1151,7 +1099,7 @@ GetOptionFromObj( objPtr->internalRep.twoPtrValue.ptr1 = (void *) tablePtr; objPtr->internalRep.twoPtrValue.ptr2 = (void *) bestPtr; objPtr->typePtr = &optionObjType; - tablePtr->refCount2++; + tablePtr->refCount++; return bestPtr; error: @@ -1224,12 +1172,9 @@ static void FreeOptionInternalRep( register Tcl_Obj *objPtr) /* Object whose internal rep to free. */ { - register OptionTable *tablePtr = (OptionTable *) objPtr->internalRep.twoPtrValue.ptr1; + register Tk_OptionTable tablePtr = (Tk_OptionTable) objPtr->internalRep.twoPtrValue.ptr1; - tablePtr->refCount2--; - if (tablePtr->refCount2 <= 0) { - ckfree(tablePtr); - } + Tk_DeleteOptionTable(tablePtr); objPtr->typePtr = NULL; objPtr->internalRep.twoPtrValue.ptr1 = NULL; objPtr->internalRep.twoPtrValue.ptr2 = NULL; @@ -2113,14 +2058,14 @@ TkDebugConfig( * interpreter anymore. */ { OptionTable *tablePtr = (OptionTable *) table; - Tcl_HashTable *hashTablePtr; Tcl_HashEntry *hashEntryPtr; Tcl_HashSearch search; Tcl_Obj *objPtr; + ThreadSpecificData *tsdPtr = + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); objPtr = Tcl_NewObj(); - hashTablePtr = Tcl_GetAssocData(interp, OPTION_HASH_KEY, NULL); - if (hashTablePtr == NULL) { + if (!tablePtr || !tsdPtr->initialized) { return objPtr; } @@ -2129,7 +2074,7 @@ TkDebugConfig( * want still is valid. */ - for (hashEntryPtr = Tcl_FirstHashEntry(hashTablePtr, &search); + for (hashEntryPtr = Tcl_FirstHashEntry(&tsdPtr->hashTable, &search); hashEntryPtr != NULL; hashEntryPtr = Tcl_NextHashEntry(&search)) { if (tablePtr == (OptionTable *) Tcl_GetHashValue(hashEntryPtr)) { diff --git a/generic/tkTest.c b/generic/tkTest.c index 03431c9..a951a57 100644 --- a/generic/tkTest.c +++ b/generic/tkTest.c @@ -803,6 +803,7 @@ TestobjconfigObjCmd( } if (tables[index] != NULL) { Tk_DeleteOptionTable(tables[index]); + tables[index] = NULL; } break; diff --git a/tests/config.test b/tests/config.test index 8f7aa9f..a3b4708 100644 --- a/tests/config.test +++ b/tests/config.test @@ -98,7 +98,7 @@ test config-1.7 {Tk_CreateOptionTable - chained tables} -constraints { testobjconfig info chain2 } -cleanup { killTables -} -result {1 4 -three 2 2 -one} +} -result {2 4 -three 2 2 -one} test config-1.8 {Tk_CreateOptionTable - chained tables} -constraints { testobjconfig } -body { @@ -134,7 +134,7 @@ test config-2.1 {Tk_DeleteOptionTable - reference counts} -constraints { lappend x [testobjconfig info chain2] [testobjconfig info chain1] } -cleanup { killTables -} -result {{1 4 -three 2 2 -one} {2 2 -one} {} {1 2 -one}} +} -result {{} {2 2 -one} {} {2 2 -one}} # No tests for DestroyOptionHashTable; couldn't figure out how to test. -- cgit v0.12 From 6c208deebcce1a0d90a5721f7a5f96213c26e147 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 1 Aug 2013 08:47:37 +0000 Subject: Make sure that in test-cases, Tk_DeleteOptionTable() is never called more times than the corresponding Tk_CreateOptionTable(). Although it doesn't crash now, this behavior cannot be depended on. --- generic/tkTest.c | 10 +++++++--- tests/config.test | 8 ++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/generic/tkTest.c b/generic/tkTest.c index 03431c9..8146c69 100644 --- a/generic/tkTest.c +++ b/generic/tkTest.c @@ -497,11 +497,11 @@ TestobjconfigObjCmd( Tcl_Obj *const objv[]) /* Argument objects. */ { static const char *const options[] = { - "alltypes", "chain1", "chain2", "configerror", "delete", "info", + "alltypes", "chain1", "chain2", "chain3", "configerror", "delete", "info", "internal", "new", "notenoughparams", "twowindows", NULL }; enum { - ALL_TYPES, CHAIN1, CHAIN2, CONFIG_ERROR, + ALL_TYPES, CHAIN1, CHAIN2, CHAIN3, CONFIG_ERROR, DEL, /* Can't use DELETE: VC++ compiler barfs. */ INFO, INTERNAL, NEW, NOT_ENOUGH_PARAMS, TWO_WINDOWS }; @@ -720,7 +720,8 @@ TestobjconfigObjCmd( break; } - case CHAIN2: { + case CHAIN2: + case CHAIN3: { ExtensionWidgetRecord *recordPtr; static const Tk_OptionSpec extensionSpecs[] = { {TK_OPTION_STRING, "-three", "three", "Three", "three", @@ -803,6 +804,9 @@ TestobjconfigObjCmd( } if (tables[index] != NULL) { Tk_DeleteOptionTable(tables[index]); + /* Make sure that Tk_DeleteOptionTable() is never done + * twice for the same table. */ + tables[index] = NULL; } break; diff --git a/tests/config.test b/tests/config.test index 8f7aa9f..4430000 100644 --- a/tests/config.test +++ b/tests/config.test @@ -16,8 +16,8 @@ proc killTables {} { # chain2 depends on chain1. If chain1 is deleted first, the # delete of chain2 will crash. deleteWindows - foreach t {alltypes chain2 chain1 configerror internal new notenoughparams - twowindows} { + foreach t {alltypes chain3 chain2 chain1 configerror internal + new notenoughparams twowindows} { while {[testobjconfig info $t] != ""} { testobjconfig delete $t } @@ -126,9 +126,9 @@ test config-2.1 {Tk_DeleteOptionTable - reference counts} -constraints { set x {} testobjconfig chain1 .a testobjconfig chain2 .b - testobjconfig chain2 .c + testobjconfig chain3 .c deleteWindows - testobjconfig delete chain2 + testobjconfig delete chain3 lappend x [testobjconfig info chain2] [testobjconfig info chain1] testobjconfig delete chain2 lappend x [testobjconfig info chain2] [testobjconfig info chain1] -- cgit v0.12 From bbf7667599a82119469e3d393b8e23ae2a257348 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 1 Aug 2013 09:18:07 +0000 Subject: Fix some comments --- generic/tkConfig.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/generic/tkConfig.c b/generic/tkConfig.c index 113b3a1..cfa5003 100644 --- a/generic/tkConfig.c +++ b/generic/tkConfig.c @@ -27,8 +27,8 @@ #include "tkFont.h" /* - * The following definition is an AssocData key used to keep track of all of - * the option tables that have been created for an interpreter. + * The following definition keeps track of all of + * the option tables that have been created for a thread. */ typedef struct ThreadSpecificData { @@ -332,7 +332,7 @@ Tk_DeleteOptionTable( int count; tablePtr->refCount--; - if (tablePtr->refCount!=0) { + if (tablePtr->refCount > 0) { return; } -- cgit v0.12 From 0b93e4ec5c09708ab425185d379949e42edad60b Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sun, 11 Aug 2013 14:51:37 +0000 Subject: Sync with Tcl version of tcl.m4 --- unix/configure | 5 +++++ unix/tcl.m4 | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/unix/configure b/unix/configure index 3682600..2683a29 100755 --- a/unix/configure +++ b/unix/configure @@ -4035,6 +4035,10 @@ echo "$as_me: WARNING: Don't know how to find pthread lib on your system - you m # Does the pthread-implementation provide # 'pthread_attr_setstacksize' ? + ac_saved_libs=$LIBS + LIBS="$LIBS $THREADS_LIBS" + + for ac_func in pthread_attr_setstacksize pthread_atfork do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` @@ -4136,6 +4140,7 @@ _ACEOF fi done + LIBS=$ac_saved_libs else TCL_THREADS=0 fi diff --git a/unix/tcl.m4 b/unix/tcl.m4 index f12d0a8..194cf90 100644 --- a/unix/tcl.m4 +++ b/unix/tcl.m4 @@ -676,7 +676,11 @@ AC_DEFUN([SC_ENABLE_THREADS], [ # Does the pthread-implementation provide # 'pthread_attr_setstacksize' ? + + ac_saved_libs=$LIBS + LIBS="$LIBS $THREADS_LIBS" AC_CHECK_FUNCS(pthread_attr_setstacksize pthread_atfork) + LIBS=$ac_saved_libs else TCL_THREADS=0 fi -- cgit v0.12 From 68419d2d6bedf1ae539fbdd80c50eff66b90e883 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 14 Aug 2013 10:53:39 +0000 Subject: Fix reference counting for "option" objects, when being duplicated. --- generic/tkConfig.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/generic/tkConfig.c b/generic/tkConfig.c index cfa5003..82b2e01 100644 --- a/generic/tkConfig.c +++ b/generic/tkConfig.c @@ -129,6 +129,7 @@ static Option * GetOptionFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, OptionTable *tablePtr); static int ObjectIsEmpty(Tcl_Obj *objPtr); static void FreeOptionInternalRep(Tcl_Obj *objPtr); +static void DupOptionInternalRep(Tcl_Obj *, Tcl_Obj *); /* * The structure below defines an object type that is used to cache the result @@ -140,7 +141,7 @@ static void FreeOptionInternalRep(Tcl_Obj *objPtr); static const Tcl_ObjType optionObjType = { "option", /* name */ FreeOptionInternalRep, /* freeIntRepProc */ - NULL, /* dupIntRepProc */ + DupOptionInternalRep, /* dupIntRepProc */ NULL, /* updateStringProc */ NULL /* setFromAnyProc */ }; @@ -1172,6 +1173,28 @@ FreeOptionInternalRep( objPtr->internalRep.twoPtrValue.ptr1 = NULL; objPtr->internalRep.twoPtrValue.ptr2 = NULL; } + +/* + *--------------------------------------------------------------------------- + * + * DupOptionInternalRep -- + * + * When a cached style object is duplicated, this is called to update the + * internal reps. + * + *--------------------------------------------------------------------------- + */ + +static void +DupOptionInternalRep( + Tcl_Obj *srcObjPtr, /* The object we are copying from. */ + Tcl_Obj *dupObjPtr) /* The object we are copying to. */ +{ + register OptionTable *tablePtr = (OptionTable *) srcObjPtr->internalRep.twoPtrValue.ptr1; + tablePtr->refCount++; + dupObjPtr->typePtr = srcObjPtr->typePtr; + dupObjPtr->internalRep = srcObjPtr->internalRep; +} /* *-------------------------------------------------------------- -- cgit v0.12 From 804d674469dc08e5b32edb2e1f251d2b68711efd Mon Sep 17 00:00:00 2001 From: jenglish Date: Thu, 15 Aug 2013 03:56:11 +0000 Subject: Bug [c597acdab3]: Call [$pb step] in tail position in ttk::progressbar::Autoincrement, so that the widget is in a consistent state when any write traces on the linked -variable are fired. --- library/ttk/progress.tcl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/ttk/progress.tcl b/library/ttk/progress.tcl index b6e2ffb..34dce72 100644 --- a/library/ttk/progress.tcl +++ b/library/ttk/progress.tcl @@ -18,10 +18,10 @@ proc ttk::progressbar::Autoincrement {pb steptime stepsize} { return } - $pb step $stepsize - set Timers($pb) [after $steptime \ [list ttk::progressbar::Autoincrement $pb $steptime $stepsize] ] + + $pb step $stepsize } # ttk::progressbar::start -- -- cgit v0.12 From 74d4360d00d7d7a03fe6527d87e17e9fc64db32b Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Sun, 25 Aug 2013 03:04:43 +0000 Subject: Fix for 3016181, thanks to Tom Goddard for patch --- library/tk.tcl | 29 ++++++++++++++--------------- macosx/tkMacOSXScrlbr.c | 2 ++ 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/library/tk.tcl b/library/tk.tcl index 267a7bb..06902f9 100644 --- a/library/tk.tcl +++ b/library/tk.tcl @@ -379,9 +379,8 @@ switch -exact -- [tk windowingsystem] { event add <> event add <> event add <> - if {[info exists tcl_platform(os)] && $tcl_platform(os) eq "Darwin"} { - event add <> - } + # On Darwin/Aqua, buttons from left to right are 1,3,2. On Darwin/X11 with recent + # XQuartz as the X server, they are 1,2,3; other X servers may differ. event add <> event add <> @@ -457,10 +456,10 @@ switch -exact -- [tk windowingsystem] { event add <> } "aqua" { - event add <> - event add <> - event add <> - event add <> + event add <> + event add <> + event add <> + event add <> event add <> event add <> @@ -468,24 +467,24 @@ switch -exact -- [tk windowingsystem] { # See http://support.apple.com/kb/HT1343 event add <> event add <> - event add <> - event add <> + event add <> + event add <> event add <> - event add <> + event add <> event add <> - event add <> + event add <> event add <> event add <> event add <> event add <> event add <> - event add <> + event add <> event add <> - event add <> + event add <> event add <> - event add <> + event add <> event add <> - event add <> + event add <> # Not official, but logical extensions of above. Also derived from # bindings present in MS Word on OSX. event add <> diff --git a/macosx/tkMacOSXScrlbr.c b/macosx/tkMacOSXScrlbr.c index 77b89e7..ac71d8e 100644 --- a/macosx/tkMacOSXScrlbr.c +++ b/macosx/tkMacOSXScrlbr.c @@ -254,6 +254,8 @@ TkpDestroyScrollbar( TkScrollbar *scrollPtr) { MacScrollbar *macScrollPtr = (MacScrollbar *) scrollPtr; + NSScroller *scroller = macScrollPtr->scroller; + [scroller setTag:(NSInteger)0]; TkMacOSXMakeCollectableAndRelease(macScrollPtr->scroller); } -- cgit v0.12 From 79d5874e6b43f1534e132deab029da4f813c596d Mon Sep 17 00:00:00 2001 From: dgp Date: Fri, 30 Aug 2013 22:09:18 +0000 Subject: Bump to 8.6.1. --- ChangeLog | 12 ++++++++++++ README | 2 +- generic/tk.h | 2 +- library/tk.tcl | 2 +- unix/configure | 2 +- unix/configure.in | 2 +- unix/tk.spec | 2 +- win/configure | 2 +- win/configure.in | 2 +- 9 files changed, 20 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index fd34f0b..11f639a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2013-08-30 Don Porter + + * README: Bump version number to 8.6.1 + * generic/tk.h: + * library/tk.tcl: + * unix/configure.in: + * unix/tk.spec: + * win/configure.in: + + * unix/configure: autoconf-2.59 + * win/configure: + 2013-08-25 Kevin Walzer * macosx/tkMacOSXButton.c: Bug [3016181]: Crash after scrollbar diff --git a/README b/README index c8688cb..a76148f 100644 --- a/README +++ b/README @@ -1,5 +1,5 @@ README: Tk - This is the Tk 8.6.0 source distribution. + This is the Tk 8.6.1 source distribution. http://sourceforge.net/projects/tcl/files/Tcl/ You can get any source release of Tk from the URL above. diff --git a/generic/tk.h b/generic/tk.h index aa9cd22..088f4be 100644 --- a/generic/tk.h +++ b/generic/tk.h @@ -78,7 +78,7 @@ extern "C" { #define TK_RELEASE_SERIAL 0 #define TK_VERSION "8.6" -#define TK_PATCH_LEVEL "8.6.0" +#define TK_PATCH_LEVEL "8.6.1" /* * A special definition used to allow this header file to be included from diff --git a/library/tk.tcl b/library/tk.tcl index 06902f9..c490797 100644 --- a/library/tk.tcl +++ b/library/tk.tcl @@ -13,7 +13,7 @@ # Insist on running with compatible version of Tcl package require Tcl 8.6 # Verify that we have Tk binary and script components from the same release -package require -exact Tk 8.6.0 +package require -exact Tk 8.6.1 # Create a ::tk namespace namespace eval ::tk { diff --git a/unix/configure b/unix/configure index 2683a29..485b70a 100755 --- a/unix/configure +++ b/unix/configure @@ -1338,7 +1338,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu TK_VERSION=8.6 TK_MAJOR_VERSION=8 TK_MINOR_VERSION=6 -TK_PATCH_LEVEL=".0" +TK_PATCH_LEVEL=".1" VERSION=${TK_VERSION} LOCALES="cs da de el en en_gb eo es fr hu it nl pl pt ru sv" diff --git a/unix/configure.in b/unix/configure.in index 98b9e0a..e7bf023 100644 --- a/unix/configure.in +++ b/unix/configure.in @@ -25,7 +25,7 @@ m4_ifdef([SC_USE_CONFIG_HEADERS], [ TK_VERSION=8.6 TK_MAJOR_VERSION=8 TK_MINOR_VERSION=6 -TK_PATCH_LEVEL=".0" +TK_PATCH_LEVEL=".1" VERSION=${TK_VERSION} LOCALES="cs da de el en en_gb eo es fr hu it nl pl pt ru sv" diff --git a/unix/tk.spec b/unix/tk.spec index 823b44b..cafad27 100644 --- a/unix/tk.spec +++ b/unix/tk.spec @@ -4,7 +4,7 @@ Name: tk Summary: Tk graphical toolkit for the Tcl scripting language. -Version: 8.6.0 +Version: 8.6.1 Release: 2 License: BSD Group: Development/Languages diff --git a/win/configure b/win/configure index 9efd2a9..807e1ae 100755 --- a/win/configure +++ b/win/configure @@ -1312,7 +1312,7 @@ SHELL=/bin/sh TK_VERSION=8.6 TK_MAJOR_VERSION=8 TK_MINOR_VERSION=6 -TK_PATCH_LEVEL=".0" +TK_PATCH_LEVEL=".1" VER=$TK_MAJOR_VERSION$TK_MINOR_VERSION #------------------------------------------------------------------------ diff --git a/win/configure.in b/win/configure.in index 709e64e..4f446e0 100644 --- a/win/configure.in +++ b/win/configure.in @@ -14,7 +14,7 @@ SHELL=/bin/sh TK_VERSION=8.6 TK_MAJOR_VERSION=8 TK_MINOR_VERSION=6 -TK_PATCH_LEVEL=".0" +TK_PATCH_LEVEL=".1" VER=$TK_MAJOR_VERSION$TK_MINOR_VERSION #------------------------------------------------------------------------ -- cgit v0.12 From 6789adfa1c7518e43c47257ed8dcb508eaef13a7 Mon Sep 17 00:00:00 2001 From: dgp Date: Tue, 3 Sep 2013 16:48:06 +0000 Subject: Update changes --- changes | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/changes b/changes index b7dc763..77500bc 100644 --- a/changes +++ b/changes @@ -7031,3 +7031,45 @@ Many revisions to better support a Cygwin environment (nijtmans) 2012-12-06 (bug fix)[3592736] stop pink greys from buggy mingw builds (fellows) --- Released 8.6.0, December 20, 2012 --- See ChangeLog for details --- + +2013-01-04 (bug fix) Tk_InitStubs("8.6") rejected in 8.60 interp (nijtmans) + +2013-01-10 (bug fix)[3600251] Mac binding (kjnash,nijtmans) + +2013-01-10 (bug fix)[3600260] <> binding (kjnash,nijtmans) + +2013-01-13 (bug fix)[3600290] restore $tk_strictMotif respect (kjnash,nijtmans) + +2013-01-22 (bug fix)[3601782] Tcl_InitStubs failure message (nijtmans) + +2013-01-31 (bug fix)[3599928] use XKeycodeToKeysym on old systems (cassoff) + +2013-02-04 (bug fix)[3603077] treeview update on tag add/remove (english) + +2013-02-28 (bug fix)[3599312] First Alt key event is lost (mcdonald) + +2013-03-11 (bug fix)[3607326] Crash [listbox .l -listvariable $array] (porter) + +2013-03-13 (enhancement) better build support for Debian arch (shadura) + +2013-03-27 (bug fix)[3608074] button, listbox, menu <> (nijtmans) + +2013-04-01 (bug fix)[3607830] Xkb runtime checks (griffin) + +2013-05-19 (platform support) FreeBSD updates (cerutti) + +2013-06-05 (bug fix)[3613759] [ttk::entry .e; .e xview end] (nijtmans) + +2013-06-05 (bug fix)[2100430] [ttk::entry .e; .e xview insert] (nijtmans) + +2013-06-28 (bug fix)[2501278] reverse ttk::scale key bindings {mcdonald) + +2013-07-02 (bug fix)[32afa6] corrected dirent64 check (griffin) + +2013-08-14 (bug fix)[069c9e] "option" value refcount crash (tim,nijtmans) + +2013-08-15 (bug fix)[c597acd] [$pb step] work with traces (english) + +2013-08-25 (bug fix)[3016181] Cocoa: [destroy $scrollbar] => crash (goddard) + +--- Released 8.6.1, September 18, 2013 --- http://core.tcl.tk/tk/ for details -- cgit v0.12 From f7da5802b7d8fb02aacfbd458bdd0486b68c56db Mon Sep 17 00:00:00 2001 From: dgp Date: Tue, 3 Sep 2013 17:39:02 +0000 Subject: make dist --- unix/tkConfig.h.in | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/unix/tkConfig.h.in b/unix/tkConfig.h.in index 575f36c..392566b 100644 --- a/unix/tkConfig.h.in +++ b/unix/tkConfig.h.in @@ -40,6 +40,9 @@ /* Define to 1 if you have the `open64' function. */ #undef HAVE_OPEN64 +/* Define to 1 if you have the `pthread_atfork' function. */ +#undef HAVE_PTHREAD_ATFORK + /* Define to 1 if you have the `pthread_attr_setstacksize' function. */ #undef HAVE_PTHREAD_ATTR_SETSTACKSIZE @@ -196,6 +199,9 @@ # endif #endif +/* Is XKeycodeToKeysym deprecated? */ +#undef XKEYCODETOKEYSYM_IS_DEPRECATED + /* Are Darwin SUSv3 extensions available? */ #undef _DARWIN_C_SOURCE -- cgit v0.12 From c23066514482f0e8e2b176b7e4d1703f31c66afb Mon Sep 17 00:00:00 2001 From: dkf Date: Mon, 23 Sep 2013 19:51:51 +0000 Subject: Documentation tweaks to make index entries more informative. --- doc/button.n | 2 +- doc/canvas.n | 2 +- doc/checkbutton.n | 2 +- doc/dialog.n | 1 + doc/entry.n | 2 +- doc/frame.n | 2 +- doc/label.n | 2 +- doc/labelframe.n | 2 +- doc/listbox.n | 2 +- doc/menu.n | 5 ++++- doc/menubutton.n | 12 ++++++++++-- doc/message.n | 7 +++++-- doc/panedwindow.n | 2 +- doc/radiobutton.n | 2 +- doc/scale.n | 2 +- doc/scrollbar.n | 2 +- doc/spinbox.n | 2 +- doc/text.n | 2 +- doc/toplevel.n | 2 +- 19 files changed, 35 insertions(+), 20 deletions(-) diff --git a/doc/button.n b/doc/button.n index d4f1af3..f201dc4 100644 --- a/doc/button.n +++ b/doc/button.n @@ -10,7 +10,7 @@ .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME -button \- Create and manipulate button widgets +button \- Create and manipulate 'button' action widgets .SH SYNOPSIS \fBbutton\fR \fIpathName \fR?\fIoptions\fR? .SO diff --git a/doc/canvas.n b/doc/canvas.n index 9eb0ec0..f69a3df 100644 --- a/doc/canvas.n +++ b/doc/canvas.n @@ -11,7 +11,7 @@ .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME -canvas \- Create and manipulate canvas widgets +canvas \- Create and manipulate 'canvas' hypergraphics drawing surface widgets .SH SYNOPSIS \fBcanvas\fR \fIpathName \fR?\fIoptions\fR? .SO diff --git a/doc/checkbutton.n b/doc/checkbutton.n index 4d06c68..eca0b72 100644 --- a/doc/checkbutton.n +++ b/doc/checkbutton.n @@ -10,7 +10,7 @@ .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME -checkbutton \- Create and manipulate checkbutton widgets +checkbutton \- Create and manipulate 'checkbutton' boolean selection widgets .SH SYNOPSIS \fBcheckbutton\fI pathName \fR?\fIoptions\fR? .SO diff --git a/doc/dialog.n b/doc/dialog.n index bd40321..5b760f1 100644 --- a/doc/dialog.n +++ b/doc/dialog.n @@ -17,6 +17,7 @@ tk_dialog \- Create modal dialog and wait for response .SH DESCRIPTION .PP This procedure is part of the Tk script library. +It is largely \fIdeprecated\fR by the \fBtk_messageBox\fR. Its arguments describe a dialog box: .TP \fIwindow\fR diff --git a/doc/entry.n b/doc/entry.n index b115268..868dc1d 100644 --- a/doc/entry.n +++ b/doc/entry.n @@ -11,7 +11,7 @@ .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME -entry \- Create and manipulate entry widgets +entry \- Create and manipulate 'entry' one-line text entry widgets .SH SYNOPSIS \fBentry\fR \fIpathName \fR?\fIoptions\fR? .SO diff --git a/doc/frame.n b/doc/frame.n index 6bf4a1b..d6e2202 100644 --- a/doc/frame.n +++ b/doc/frame.n @@ -10,7 +10,7 @@ .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME -frame \- Create and manipulate frame widgets +frame \- Create and manipulate 'frame' simple container widgets .SH SYNOPSIS \fBframe\fR \fIpathName\fR ?\fIoptions\fR? .SO diff --git a/doc/label.n b/doc/label.n index e445ebb..a0db8c0 100644 --- a/doc/label.n +++ b/doc/label.n @@ -10,7 +10,7 @@ .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME -label \- Create and manipulate label widgets +label \- Create and manipulate 'label' non-interactive text or image widgets .SH SYNOPSIS \fBlabel\fR \fIpathName \fR?\fIoptions\fR? .SO diff --git a/doc/labelframe.n b/doc/labelframe.n index 2bb865d..8f989fe 100644 --- a/doc/labelframe.n +++ b/doc/labelframe.n @@ -10,7 +10,7 @@ .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME -labelframe \- Create and manipulate labelframe widgets +labelframe \- Create and manipulate 'labelframe' labelled container widgets .SH SYNOPSIS \fBlabelframe\fR \fIpathName\fR ?\fIoptions\fR? .SO diff --git a/doc/listbox.n b/doc/listbox.n index 709b702..a7fddfc 100644 --- a/doc/listbox.n +++ b/doc/listbox.n @@ -10,7 +10,7 @@ .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME -listbox \- Create and manipulate listbox widgets +listbox \- Create and manipulate 'listbox' item list widgets .SH SYNOPSIS \fBlistbox\fR \fIpathName \fR?\fIoptions\fR? .SO diff --git a/doc/menu.n b/doc/menu.n index c6f74dc..b026844 100644 --- a/doc/menu.n +++ b/doc/menu.n @@ -10,7 +10,7 @@ .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME -menu, tk_menuSetFocus \- Create and manipulate menu widgets +menu, tk_menuSetFocus \- Create and manipulate 'menu' widgets and menubars .SH SYNOPSIS .nf \fBmenu\fR \fIpathName \fR?\fIoptions\fR? @@ -73,6 +73,9 @@ library. .PP The \fBmenu\fR command creates a new top-level window (given by the \fIpathName\fR argument) and makes it into a menu widget. +That menu widget can either be used as a pop-up window or applied to a +\fBtoplevel\fR (with its \fB\-menu\fR option) to make it into the menubar for +that toplevel. Additional options, described above, may be specified on the command line or in the option database diff --git a/doc/menubutton.n b/doc/menubutton.n index c8b0958..6b723ff 100644 --- a/doc/menubutton.n +++ b/doc/menubutton.n @@ -10,7 +10,7 @@ .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME -menubutton \- Create and manipulate menubutton widgets +menubutton \- Create and manipulate 'menubutton' pop-up menu indicator widgets .SH SYNOPSIS \fBmenubutton\fR \fIpathName \fR?\fIoptions\fR? .SO @@ -93,13 +93,19 @@ the menu before releasing the mouse button, the button release causes the underlying menu entry to be invoked. When the button is released, the menu is unposted. .PP -Menubuttons are typically organized into groups called menu bars +Menubuttons are used to construct a \fBtk_optionMenu\fR, which is the +preferred mechanism for allowing a user to select one item from a list +on Mac OS X. +.PP +Menubuttons were also typically organized into groups called menu bars that allow scanning: if the mouse button is pressed over one menubutton (causing it to post its menu) and the mouse is moved over another menubutton in the same menu bar without releasing the mouse button, then the menu of the first menubutton is unposted and the menu of the new menubutton is posted instead. +\fIThis use is deprecated\fR in favor of setting a \fBmenu\fR directly as a +menubar; see the \fBtoplevel\fR's \fB\-menu\fR option for how to do that. .PP There are several interactions between menubuttons and menus; see the \fBmenu\fR manual entry for information on various menu configurations, @@ -118,12 +124,14 @@ determine the exact behavior of the command. The following commands are possible for menubutton widgets: .TP \fIpathName \fBcget \fIoption\fR +. Returns the current value of the configuration option given by \fIoption\fR. \fIOption\fR may have any of the values accepted by the \fBmenubutton\fR command. .TP \fIpathName \fBconfigure\fR ?\fIoption\fR? ?\fIvalue option value ...\fR? +. Query or modify the configuration options of the widget. If no \fIoption\fR is specified, returns a list describing all of the available options for \fIpathName\fR (see \fBTk_ConfigureInfo\fR for diff --git a/doc/message.n b/doc/message.n index 61be2f0..7fb4d04 100644 --- a/doc/message.n +++ b/doc/message.n @@ -10,7 +10,7 @@ .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME -message \- Create and manipulate message widgets +message \- Create and manipulate 'message' non-interactive text widgets .SH SYNOPSIS \fBmessage\fR \fIpathName \fR?\fIoptions\fR? .SO @@ -74,7 +74,8 @@ there must not exist a window named \fIpathName\fR, but \fIpathName\fR's parent must exist. .PP A message is a widget that displays a textual string. A message -widget has three special features. First, it breaks up +widget has three special features that differentiate it from a +\fBlabel\fR widget. First, it breaks up its string into lines in order to produce a given aspect ratio for the window. The line breaks are chosen at word boundaries wherever possible (if not even a single word would fit on a @@ -112,12 +113,14 @@ determine the exact behavior of the command. The following commands are possible for message widgets: .TP \fIpathName \fBcget \fIoption\fR +. Returns the current value of the configuration option given by \fIoption\fR. \fIOption\fR may have any of the values accepted by the \fBmessage\fR command. .TP \fIpathName \fBconfigure\fR ?\fIoption\fR? ?\fIvalue option value ...\fR? +. Query or modify the configuration options of the widget. If no \fIoption\fR is specified, returns a list describing all of the available options for \fIpathName\fR (see \fBTk_ConfigureInfo\fR for diff --git a/doc/panedwindow.n b/doc/panedwindow.n index 17d5730..6ece441 100644 --- a/doc/panedwindow.n +++ b/doc/panedwindow.n @@ -10,7 +10,7 @@ .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME -panedwindow \- Create and manipulate panedwindow widgets +panedwindow \- Create and manipulate 'panedwindow' split container widgets .SH SYNOPSIS \fBpanedwindow\fR \fIpathName \fR?\fIoptions\fR? .SO diff --git a/doc/radiobutton.n b/doc/radiobutton.n index 983b43e..9334449 100644 --- a/doc/radiobutton.n +++ b/doc/radiobutton.n @@ -10,7 +10,7 @@ .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME -radiobutton \- Create and manipulate radiobutton widgets +radiobutton \- Create and manipulate 'radiobutton' pick-one widgets .SH SYNOPSIS \fBradiobutton\fR \fIpathName \fR?\fIoptions\fR? .SO diff --git a/doc/scale.n b/doc/scale.n index c8e722a..ac58837 100644 --- a/doc/scale.n +++ b/doc/scale.n @@ -10,7 +10,7 @@ .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME -scale \- Create and manipulate scale widgets +scale \- Create and manipulate 'scale' value-controlled slider widgets .SH SYNOPSIS \fBscale\fR \fIpathName \fR?\fIoptions\fR? .SO diff --git a/doc/scrollbar.n b/doc/scrollbar.n index 74fb977..d808f29 100644 --- a/doc/scrollbar.n +++ b/doc/scrollbar.n @@ -10,7 +10,7 @@ .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME -scrollbar \- Create and manipulate scrollbar widgets +scrollbar \- Create and manipulate 'scrollbar' scrolling control and indicator widgets .SH SYNOPSIS \fBscrollbar\fR \fIpathName \fR?\fIoptions\fR? .SO diff --git a/doc/spinbox.n b/doc/spinbox.n index e88aea6..dde234b 100644 --- a/doc/spinbox.n +++ b/doc/spinbox.n @@ -10,7 +10,7 @@ .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME -spinbox \- Create and manipulate spinbox widgets +spinbox \- Create and manipulate 'spinbox' value spinner widgets .SH SYNOPSIS \fBspinbox\fR \fIpathName \fR?\fIoptions\fR? .SO diff --git a/doc/text.n b/doc/text.n index da16f9a..dcf5a75 100644 --- a/doc/text.n +++ b/doc/text.n @@ -10,7 +10,7 @@ .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME -text, tk_textCopy, tk_textCut, tk_textPaste \- Create and manipulate text widgets +text, tk_textCopy, tk_textCut, tk_textPaste \- Create and manipulate 'text' hypertext editing widgets .SH SYNOPSIS .nf \fBtext\fR \fIpathName \fR?\fIoptions\fR? diff --git a/doc/toplevel.n b/doc/toplevel.n index 7d5b53c..6301318 100644 --- a/doc/toplevel.n +++ b/doc/toplevel.n @@ -10,7 +10,7 @@ .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME -toplevel \- Create and manipulate toplevel widgets +toplevel \- Create and manipulate 'toplevel' main and popup window widgets .SH SYNOPSIS \fBtoplevel\fR \fIpathName \fR?\fIoptions\fR? .SO -- cgit v0.12 From ce39c47aa3d8e5767729511d3ab853cf1fe9af41 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 27 Sep 2013 09:42:27 +0000 Subject: Workaround for [http://sourceforge.net/p/mingw/bugs/2065/|MinGW bug #2065]. Both MinGW and MinGW-w64 (32-bit) are affected. Even though Win64 is not affected, adding -static-libgcc doesn't harm there, and we don't want to distrubute additional dll's with MinGW-compiled Tcl anyway. --- win/configure | 3 +-- win/tcl.m4 | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/win/configure b/win/configure index 92ebdfb..14b35ab 100755 --- a/win/configure +++ b/win/configure @@ -3599,7 +3599,7 @@ echo "${ECHO_T}yes" >&6 if test "${GCC}" = "yes" ; then extra_cflags="-pipe" - extra_ldflags="-pipe" + extra_ldflags="-pipe -static-libgcc" echo "$as_me:$LINENO: checking for mingw32 version of gcc" >&5 echo $ECHO_N "checking for mingw32 version of gcc... $ECHO_C" >&6 if test "${ac_cv_win32+set}" = set; then @@ -3728,7 +3728,6 @@ echo "${ECHO_T}$ac_cv_municode" >&6 extra_ldflags="$extra_ldflags -municode" else extra_cflags="$extra_cflags -DTCL_BROKEN_MAINARGS" - extra_ldflags="$extra_ldflags -static-libgcc" fi fi diff --git a/win/tcl.m4 b/win/tcl.m4 index 335494b..7ea7fad 100644 --- a/win/tcl.m4 +++ b/win/tcl.m4 @@ -634,7 +634,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [ if test "${GCC}" = "yes" ; then extra_cflags="-pipe" - extra_ldflags="-pipe" + extra_ldflags="-pipe -static-libgcc" AC_CACHE_CHECK(for mingw32 version of gcc, ac_cv_win32, AC_TRY_COMPILE([ @@ -665,7 +665,6 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [ extra_ldflags="$extra_ldflags -municode" else extra_cflags="$extra_cflags -DTCL_BROKEN_MAINARGS" - extra_ldflags="$extra_ldflags -static-libgcc" fi fi -- cgit v0.12 From 0e85ea7738df8da2aa053411a351db327d04f8e8 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 1 Oct 2013 07:32:49 +0000 Subject: Disable command line globbing on MinGW compiles, just as MSVC and MinGW-w64 don't enable command line globbing either by default. (Accidently cleared execute permission on two files) --- unix/configure | 0 win/configure | 0 win/winMain.c | 4 ++++ 3 files changed, 4 insertions(+) mode change 100755 => 100644 unix/configure mode change 100755 => 100644 win/configure diff --git a/unix/configure b/unix/configure old mode 100755 new mode 100644 diff --git a/win/configure b/win/configure old mode 100755 new mode 100644 diff --git a/win/winMain.c b/win/winMain.c index eea7004..01a5e23 100644 --- a/win/winMain.c +++ b/win/winMain.c @@ -16,6 +16,10 @@ #undef WIN32_LEAN_AND_MEAN #include +#if defined(__GNUC__) +int _CRT_glob = 0; +#endif /* __GNUC__ */ + /* * The following declarations refer to internal Tk routines. These interfaces * are available for use, but are not supported. -- cgit v0.12 From 81e6afdd4e6735140c946e30298285ea8d33fdc8 Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Sun, 27 Oct 2013 20:29:36 +0000 Subject: Fix for drawing lags on OS X Mavericks; thanks to Ned Deily for report and Daniel Steffen for patch --- macosx/tkMacOSXDraw.c | 1 + 1 file changed, 1 insertion(+) diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index fd73b96..0727b26 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -1690,6 +1690,7 @@ TkMacOSXRestoreDrawingContext( { if (dcPtr->context) { CGContextSynchronize(dcPtr->context); + [[dcPtr->view window] setViewsNeedDisplay:YES]; [[dcPtr->view window] enableFlushWindow]; if (dcPtr->focusLocked) { [dcPtr->view unlockFocus]; -- cgit v0.12 From e4f9fece815b8121b9300c83a9697f2b2ea27e9f Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 28 Oct 2013 16:26:04 +0000 Subject: Some refactoring as initial attempt to fix [f214b8ad5b]. Not finished/tested yet. --- generic/tkMenu.c | 74 ++++++++++++++++++++++++++++---------------------------- generic/tkMenu.h | 16 +----------- 2 files changed, 38 insertions(+), 52 deletions(-) diff --git a/generic/tkMenu.c b/generic/tkMenu.c index 8f8a176..484352a 100644 --- a/generic/tkMenu.c +++ b/generic/tkMenu.c @@ -81,6 +81,10 @@ typedef struct ThreadSpecificData { int menusInitialized; /* Flag indicates whether thread-specific * elements of the Windows Menu module have * been initialized. */ + Tk_OptionTable menuOptionTable; + /* The option table for menus. */ + Tk_OptionTable entryOptionTables[6]; + /* The tables for menu entries. */ } ThreadSpecificData; static Tcl_ThreadDataKey dataKey; @@ -394,38 +398,12 @@ static const Tk_ClassProcs menuClass = { *-------------------------------------------------------------- */ -static void -FreeOptionTables( - ClientData clientData, - Tcl_Interp *interp) -{ - ckfree(clientData); -} - int TkCreateMenuCmd( Tcl_Interp *interp) /* Interpreter we are creating the command * in. */ { - TkMenuOptionTables *optionTablesPtr = ckalloc(sizeof(TkMenuOptionTables)); - - optionTablesPtr->menuOptionTable = - Tk_CreateOptionTable(interp, tkMenuConfigSpecs); - optionTablesPtr->entryOptionTables[TEAROFF_ENTRY] = - Tk_CreateOptionTable(interp, specsArray[TEAROFF_ENTRY]); - optionTablesPtr->entryOptionTables[COMMAND_ENTRY] = - Tk_CreateOptionTable(interp, specsArray[COMMAND_ENTRY]); - optionTablesPtr->entryOptionTables[CASCADE_ENTRY] = - Tk_CreateOptionTable(interp, specsArray[CASCADE_ENTRY]); - optionTablesPtr->entryOptionTables[SEPARATOR_ENTRY] = - Tk_CreateOptionTable(interp, specsArray[SEPARATOR_ENTRY]); - optionTablesPtr->entryOptionTables[RADIO_BUTTON_ENTRY] = - Tk_CreateOptionTable(interp, specsArray[RADIO_BUTTON_ENTRY]); - optionTablesPtr->entryOptionTables[CHECK_BUTTON_ENTRY] = - Tk_CreateOptionTable(interp, specsArray[CHECK_BUTTON_ENTRY]); - - Tcl_CreateObjCommand(interp, "menu", MenuCmd, optionTablesPtr, 0); - Tcl_CallWhenDeleted(interp, FreeOptionTables, optionTablesPtr); + Tcl_CreateObjCommand(interp, "menu", MenuCmd, NULL, 0); if (Tcl_IsSafe(interp)) { Tcl_HideCommand(interp, "menu", "menu"); @@ -453,7 +431,7 @@ TkCreateMenuCmd( static int MenuCmd( - ClientData clientData, /* Main window associated with interpreter. */ + ClientData clientData, /* Not used */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument strings. */ @@ -465,7 +443,8 @@ MenuCmd( int i, index, toplevel; const char *windowName; static const char *const typeStringList[] = {"-type", NULL}; - TkMenuOptionTables *optionTablesPtr = clientData; + ThreadSpecificData *tsdPtr = + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (objc < 2) { Tcl_WrongNumArgs(interp, 1, objv, "pathName ?-option value ...?"); @@ -511,7 +490,6 @@ MenuCmd( menuPtr->cursorPtr = None; menuPtr->masterMenuPtr = menuPtr; menuPtr->menuType = UNKNOWN_TYPE; - menuPtr->optionTablesPtr = optionTablesPtr; TkMenuInitializeDrawingFields(menuPtr); Tk_SetClass(menuPtr->tkwin, "Menu"); @@ -520,7 +498,7 @@ MenuCmd( ExposureMask|StructureNotifyMask|ActivateMask, TkMenuEventProc, menuPtr); if (Tk_InitOptions(interp, (char *) menuPtr, - menuPtr->optionTablesPtr->menuOptionTable, menuPtr->tkwin) + tsdPtr->menuOptionTable, menuPtr->tkwin) != TCL_OK) { Tk_DestroyWindow(menuPtr->tkwin); return TCL_ERROR; @@ -675,6 +653,8 @@ MenuWidgetObjCmd( register TkMenuEntry *mePtr; int result = TCL_OK; int option; + ThreadSpecificData *tsdPtr = + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (objc < 2) { Tcl_WrongNumArgs(interp, 1, objv, "option ?arg ...?"); @@ -725,7 +705,7 @@ MenuWidgetObjCmd( goto error; } resultPtr = Tk_GetOptionValue(interp, (char *) menuPtr, - menuPtr->optionTablesPtr->menuOptionTable, objv[2], + tsdPtr->menuOptionTable, objv[2], menuPtr->tkwin); if (resultPtr == NULL) { goto error; @@ -745,7 +725,7 @@ MenuWidgetObjCmd( if (objc == 2) { resultPtr = Tk_GetOptionInfo(interp, (char *) menuPtr, - menuPtr->optionTablesPtr->menuOptionTable, NULL, + tsdPtr->menuOptionTable, NULL, menuPtr->tkwin); if (resultPtr == NULL) { result = TCL_ERROR; @@ -755,7 +735,7 @@ MenuWidgetObjCmd( } } else if (objc == 3) { resultPtr = Tk_GetOptionInfo(interp, (char *) menuPtr, - menuPtr->optionTablesPtr->menuOptionTable, objv[2], + tsdPtr->menuOptionTable, objv[2], menuPtr->tkwin); if (resultPtr == NULL) { result = TCL_ERROR; @@ -1144,6 +1124,8 @@ DestroyMenuInstance( Tcl_Obj *newObjv[2]; TkMenu *parentMasterMenuPtr; TkMenuEntry *parentMasterEntryPtr; + ThreadSpecificData *tsdPtr = + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); /* * If the menu has any cascade menu entries pointing to it, the cascade @@ -1233,7 +1215,7 @@ DestroyMenuInstance( } TkMenuFreeDrawOptions(menuPtr); Tk_FreeConfigOptions((char *) menuPtr, - menuPtr->optionTablesPtr->menuOptionTable, menuPtr->tkwin); + tsdPtr->menuOptionTable, menuPtr->tkwin); if (menuPtr->tkwin != NULL) { Tk_Window tkwin = menuPtr->tkwin; @@ -1566,12 +1548,14 @@ ConfigureMenu( int i; TkMenu *menuListPtr, *cleanupPtr; int result; + ThreadSpecificData *tsdPtr = + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); for (menuListPtr = menuPtr->masterMenuPtr; menuListPtr != NULL; menuListPtr = menuListPtr->nextInstancePtr) { menuListPtr->errorStructPtr = ckalloc(sizeof(Tk_SavedOptions)); result = Tk_SetOptions(interp, (char *) menuListPtr, - menuListPtr->optionTablesPtr->menuOptionTable, objc, objv, + tsdPtr->menuOptionTable, objc, objv, menuListPtr->tkwin, menuListPtr->errorStructPtr, NULL); if (result != TCL_OK) { for (cleanupPtr = menuPtr->masterMenuPtr; @@ -2287,6 +2271,8 @@ MenuNewEntry( TkMenuEntry *mePtr; TkMenuEntry **newEntries; int i; + ThreadSpecificData *tsdPtr = + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); /* * Create a new array of entries with an empty slot for the new entry. @@ -2308,7 +2294,7 @@ MenuNewEntry( mePtr = ckalloc(sizeof(TkMenuEntry)); menuPtr->entries[index] = mePtr; mePtr->type = type; - mePtr->optionTable = menuPtr->optionTablesPtr->entryOptionTables[type]; + mePtr->optionTable = tsdPtr->entryOptionTables[type]; mePtr->menuPtr = menuPtr; mePtr->labelPtr = NULL; mePtr->labelLength = 0; @@ -3625,6 +3611,20 @@ TkMenuInit(void) } if (!tsdPtr->menusInitialized) { TkpMenuThreadInit(); + tsdPtr->menuOptionTable = + Tk_CreateOptionTable(NULL, tkMenuConfigSpecs); + tsdPtr->entryOptionTables[TEAROFF_ENTRY] = + Tk_CreateOptionTable(NULL, specsArray[TEAROFF_ENTRY]); + tsdPtr->entryOptionTables[COMMAND_ENTRY] = + Tk_CreateOptionTable(NULL, specsArray[COMMAND_ENTRY]); + tsdPtr->entryOptionTables[CASCADE_ENTRY] = + Tk_CreateOptionTable(NULL, specsArray[CASCADE_ENTRY]); + tsdPtr->entryOptionTables[SEPARATOR_ENTRY] = + Tk_CreateOptionTable(NULL, specsArray[SEPARATOR_ENTRY]); + tsdPtr->entryOptionTables[RADIO_BUTTON_ENTRY] = + Tk_CreateOptionTable(NULL, specsArray[RADIO_BUTTON_ENTRY]); + tsdPtr->entryOptionTables[CHECK_BUTTON_ENTRY] = + Tk_CreateOptionTable(NULL, specsArray[CHECK_BUTTON_ENTRY]); tsdPtr->menusInitialized = 1; } } diff --git a/generic/tkMenu.h b/generic/tkMenu.h index def7d19..bac51aa 100644 --- a/generic/tkMenu.h +++ b/generic/tkMenu.h @@ -359,10 +359,7 @@ typedef struct TkMenu { /* A pointer to the original menu for this * clone chain. Points back to this structure * if this menu is a master menu. */ - struct TkMenuOptionTables *optionTablesPtr; - /* A pointer to the collection of option - * tables that work with menus and menu - * entries. */ + void *reserved1; /* not used any more. */ Tk_Window parentTopLevelPtr;/* If this menu is a menubar, this is the * toplevel that owns the menu. Only * applicable for menubar clones. */ @@ -431,17 +428,6 @@ typedef struct TkMenuReferences { } TkMenuReferences; /* - * This structure contains all of the option tables that are needed by menus. - */ - -typedef struct TkMenuOptionTables { - Tk_OptionTable menuOptionTable; - /* The option table for menus. */ - Tk_OptionTable entryOptionTables[6]; - /* The tables for menu entries. */ -} TkMenuOptionTables; - -/* * Flag bits for menus: * * REDRAW_PENDING: Non-zero means a DoWhenIdle handler has -- cgit v0.12 From 637ea03ab047c97e3a8e0c5ed58b010e8142874b Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 29 Oct 2013 13:59:18 +0000 Subject: Make "menu" a normal command, initialized like any other Tk command. --- generic/tkInt.h | 4 +++- generic/tkMenu.c | 42 +++++------------------------------------- generic/tkWindow.c | 3 +-- 3 files changed, 9 insertions(+), 40 deletions(-) diff --git a/generic/tkInt.h b/generic/tkInt.h index 933fa5e..b48647d 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -1077,6 +1077,9 @@ MODULE_SCOPE int Tk_ListboxObjCmd(ClientData clientData, MODULE_SCOPE int Tk_LowerObjCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); +MODULE_SCOPE int Tk_MenuObjCmd(ClientData clientData, + Tcl_Interp *interp, int objc, + Tcl_Obj *const objv[]); MODULE_SCOPE int Tk_MenubuttonObjCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); @@ -1148,7 +1151,6 @@ MODULE_SCOPE void TkFreeGeometryMaster(Tk_Window tkwin, MODULE_SCOPE void TkEventInit(void); MODULE_SCOPE void TkRegisterObjTypes(void); -MODULE_SCOPE int TkCreateMenuCmd(Tcl_Interp *interp); MODULE_SCOPE int TkDeadAppCmd(ClientData clientData, Tcl_Interp *interp, int argc, const char **argv); MODULE_SCOPE int TkCanvasGetCoordObj(Tcl_Interp *interp, diff --git a/generic/tkMenu.c b/generic/tkMenu.c index 484352a..cd9ff08 100644 --- a/generic/tkMenu.c +++ b/generic/tkMenu.c @@ -353,8 +353,6 @@ static int MenuDoXPosition(Tcl_Interp *interp, static int MenuAddOrInsert(Tcl_Interp *interp, TkMenu *menuPtr, Tcl_Obj *indexPtr, int objc, Tcl_Obj *const objv[]); -static int MenuCmd(ClientData clientData, Tcl_Interp *interp, - int objc, Tcl_Obj *const objv[]); static void MenuCmdDeletedProc(ClientData clientData); static TkMenuEntry * MenuNewEntry(TkMenu *menuPtr, int index, int type); static char * MenuVarProc(ClientData clientData, @@ -385,37 +383,7 @@ static const Tk_ClassProcs menuClass = { /* *-------------------------------------------------------------- * - * TkCreateMenuCmd -- - * - * Called by Tk at initialization time to create the menu command. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *-------------------------------------------------------------- - */ - -int -TkCreateMenuCmd( - Tcl_Interp *interp) /* Interpreter we are creating the command - * in. */ -{ - Tcl_CreateObjCommand(interp, "menu", MenuCmd, NULL, 0); - - if (Tcl_IsSafe(interp)) { - Tcl_HideCommand(interp, "menu", "menu"); - } - - return TCL_OK; -} - -/* - *-------------------------------------------------------------- - * - * MenuCmd -- + * Tk_MenuObjCmd -- * * This function is invoked to process the "menu" Tcl command. See the * user documentation for details on what it does. @@ -429,14 +397,14 @@ TkCreateMenuCmd( *-------------------------------------------------------------- */ -static int -MenuCmd( - ClientData clientData, /* Not used */ +int +Tk_MenuObjCmd( + ClientData clientData, /* Main window associated with interpreter. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument strings. */ { - Tk_Window tkwin = Tk_MainWindow(interp); + Tk_Window tkwin = clientData; Tk_Window newWin; register TkMenu *menuPtr; TkMenuReferences *menuRefPtr; diff --git a/generic/tkWindow.c b/generic/tkWindow.c index 91806cf..6f5ee95 100644 --- a/generic/tkWindow.c +++ b/generic/tkWindow.c @@ -149,6 +149,7 @@ static const TkCmd commands[] = { {"label", Tk_LabelObjCmd, ISSAFE}, {"labelframe", Tk_LabelframeObjCmd, ISSAFE}, {"listbox", Tk_ListboxObjCmd, ISSAFE}, + {"menu", Tk_MenuObjCmd, PASSMAINWINDOW}, {"menubutton", Tk_MenubuttonObjCmd, ISSAFE}, {"message", Tk_MessageObjCmd, ISSAFE}, {"panedwindow", Tk_PanedWindowObjCmd, ISSAFE}, @@ -987,8 +988,6 @@ TkCreateMainWindow( } } - TkCreateMenuCmd(interp); - /* * Set variables for the intepreter. */ -- cgit v0.12 From cbb12f8e904ca926c14cba9d41e99aa6f48c8e90 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 31 Oct 2013 09:35:23 +0000 Subject: Fix [c0cc9fd153]: PNG parser does not support uppercase format string (using -format) --- generic/tkImgPNG.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/generic/tkImgPNG.c b/generic/tkImgPNG.c index f639694..8a740d2 100644 --- a/generic/tkImgPNG.c +++ b/generic/tkImgPNG.c @@ -2283,10 +2283,10 @@ ParseFormat( Tcl_Obj **objv = NULL; int objc = 0; static const char *const fmtOptions[] = { - "png", "-alpha", NULL + "-alpha", NULL }; enum fmtOptions { - OPT_PNG, OPT_ALPHA + OPT_ALPHA }; /* @@ -2299,33 +2299,30 @@ ParseFormat( } for (; objc>0 ; objc--, objv++) { - int optIndex; - - if (Tcl_GetIndexFromObjStruct(interp, objv[0], fmtOptions, - sizeof(char *), "option", 0, &optIndex) == TCL_ERROR) { - return TCL_ERROR; - } + int optIndex; /* * Ignore the "png" part of the format specification. */ - if (OPT_PNG == optIndex) { + if (!strcasecmp(Tcl_GetString(objv[0]), "png")) { continue; } - if (objc < 2) { + if (Tcl_GetIndexFromObjStruct(interp, objv[0], fmtOptions, + sizeof(char *), "option", 0, &optIndex) == TCL_ERROR) { + return TCL_ERROR; + } + + if (objc < 2) { Tcl_WrongNumArgs(interp, 1, objv, "value"); return TCL_ERROR; - } + } objc--; objv++; switch ((enum fmtOptions) optIndex) { - case OPT_PNG: - break; - case OPT_ALPHA: if (Tcl_GetDoubleFromObj(interp, objv[0], &pngPtr->alpha) == TCL_ERROR) { -- cgit v0.12 From b25cb2a04a6f9760b1704338a1174ff474eed50e Mon Sep 17 00:00:00 2001 From: dgp Date: Tue, 5 Nov 2013 20:58:38 +0000 Subject: First draft patch trying to fix [f214b8ad5b]. --- generic/tkFont.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/generic/tkFont.c b/generic/tkFont.c index ad009b9..27cd4af 100644 --- a/generic/tkFont.c +++ b/generic/tkFont.c @@ -421,7 +421,7 @@ TkFontPkgFree( fontsLeft++; #ifdef DEBUG_FONTS fprintf(stderr, "Font %s still in cache.\n", - Tcl_GetHashKey(&fiPtr->fontCache, searchPtr)); + (char *) Tcl_GetHashKey(&fiPtr->fontCache, searchPtr)); #endif } @@ -1093,7 +1093,8 @@ Tk_AllocFontFromObj( int isNew, descent; NamedFont *nfPtr; - if (objPtr->typePtr != &tkFontObjType) { + if (objPtr->typePtr != &tkFontObjType + || objPtr->internalRep.twoPtrValue.ptr2 != &fiPtr->fontCache) { SetFontFromAny(interp, objPtr); } @@ -1133,6 +1134,7 @@ Tk_AllocFontFromObj( fontPtr->resourceRefCount++; fontPtr->objRefCount++; objPtr->internalRep.twoPtrValue.ptr1 = fontPtr; + objPtr->internalRep.twoPtrValue.ptr2 = &fiPtr->fontCache; return (Tk_Font) fontPtr; } } @@ -1243,6 +1245,7 @@ Tk_AllocFontFromObj( } objPtr->internalRep.twoPtrValue.ptr1 = fontPtr; + objPtr->internalRep.twoPtrValue.ptr2 = &fiPtr->fontCache; return (Tk_Font) fontPtr; } @@ -1275,7 +1278,8 @@ Tk_GetFontFromObj( TkFont *fontPtr; Tcl_HashEntry *hashPtr; - if (objPtr->typePtr != &tkFontObjType) { + if (objPtr->typePtr != &tkFontObjType + || objPtr->internalRep.twoPtrValue.ptr2 != &fiPtr->fontCache) { SetFontFromAny(NULL, objPtr); } @@ -1311,6 +1315,7 @@ Tk_GetFontFromObj( if (Tk_Screen(tkwin) == fontPtr->screen) { fontPtr->objRefCount++; objPtr->internalRep.twoPtrValue.ptr1 = fontPtr; + objPtr->internalRep.twoPtrValue.ptr2 = &fiPtr->fontCache; return (Tk_Font) fontPtr; } } @@ -1356,6 +1361,7 @@ SetFontFromAny( } objPtr->typePtr = &tkFontObjType; objPtr->internalRep.twoPtrValue.ptr1 = NULL; + objPtr->internalRep.twoPtrValue.ptr2 = NULL; return TCL_OK; } @@ -1519,6 +1525,7 @@ FreeFontObj( ckfree(fontPtr); } objPtr->internalRep.twoPtrValue.ptr1 = NULL; + objPtr->internalRep.twoPtrValue.ptr2 = NULL; } } @@ -1549,6 +1556,8 @@ DupFontObjProc( dupObjPtr->typePtr = srcObjPtr->typePtr; dupObjPtr->internalRep.twoPtrValue.ptr1 = fontPtr; + dupObjPtr->internalRep.twoPtrValue.ptr2 + = srcObjPtr->internalRep.twoPtrValue.ptr2; if (fontPtr != NULL) { fontPtr->objRefCount++; -- cgit v0.12 From febf16788baf39f348938e62776f7e3b60edfde6 Mon Sep 17 00:00:00 2001 From: dgp Date: Tue, 5 Nov 2013 21:06:39 +0000 Subject: New test font-47.1 demonstrates effectiveness of the fix. --- tests/font.test | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/font.test b/tests/font.test index 33e411a..a07e391 100644 --- a/tests/font.test +++ b/tests/font.test @@ -2345,6 +2345,16 @@ test font-46.5 {font actual, too many chars} -body { font actual {times 10} 123456789012345678901234567890123456789012345678901 } -returnCodes error -result {expected a single character but got "1234567890123456789012345678901234567..."} +test font-47.1 {Bug f214b8ad5b} -body { + interp create one + interp create two + load {} Tk one + load {} Tk two + one eval menu .menubar + two eval menu .menubar + interp delete one + interp delete two +} -result {} # cleanup cleanupTests -- cgit v0.12 From c8a3f6f325bfd89ded61d6b1c9d88bdb012e90b1 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 8 Nov 2013 09:16:05 +0000 Subject: Since fontCache is the first field of struct TkFontInfo, make the code somewhat better readable. But actually it's no change at all. This is my only review comment! Good work! --- generic/tkFont.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/generic/tkFont.c b/generic/tkFont.c index 27cd4af..cbc4cf4 100644 --- a/generic/tkFont.c +++ b/generic/tkFont.c @@ -1094,7 +1094,7 @@ Tk_AllocFontFromObj( NamedFont *nfPtr; if (objPtr->typePtr != &tkFontObjType - || objPtr->internalRep.twoPtrValue.ptr2 != &fiPtr->fontCache) { + || objPtr->internalRep.twoPtrValue.ptr2 != fiPtr) { SetFontFromAny(interp, objPtr); } @@ -1134,7 +1134,7 @@ Tk_AllocFontFromObj( fontPtr->resourceRefCount++; fontPtr->objRefCount++; objPtr->internalRep.twoPtrValue.ptr1 = fontPtr; - objPtr->internalRep.twoPtrValue.ptr2 = &fiPtr->fontCache; + objPtr->internalRep.twoPtrValue.ptr2 = fiPtr; return (Tk_Font) fontPtr; } } @@ -1245,7 +1245,7 @@ Tk_AllocFontFromObj( } objPtr->internalRep.twoPtrValue.ptr1 = fontPtr; - objPtr->internalRep.twoPtrValue.ptr2 = &fiPtr->fontCache; + objPtr->internalRep.twoPtrValue.ptr2 = fiPtr; return (Tk_Font) fontPtr; } @@ -1279,7 +1279,7 @@ Tk_GetFontFromObj( Tcl_HashEntry *hashPtr; if (objPtr->typePtr != &tkFontObjType - || objPtr->internalRep.twoPtrValue.ptr2 != &fiPtr->fontCache) { + || objPtr->internalRep.twoPtrValue.ptr2 != fiPtr) { SetFontFromAny(NULL, objPtr); } @@ -1315,7 +1315,7 @@ Tk_GetFontFromObj( if (Tk_Screen(tkwin) == fontPtr->screen) { fontPtr->objRefCount++; objPtr->internalRep.twoPtrValue.ptr1 = fontPtr; - objPtr->internalRep.twoPtrValue.ptr2 = &fiPtr->fontCache; + objPtr->internalRep.twoPtrValue.ptr2 = fiPtr; return (Tk_Font) fontPtr; } } -- cgit v0.12 From 2e969c1eebe657e1b57a2e5ee2aa11f300e9fd5f Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 19 Nov 2013 11:53:32 +0000 Subject: Revert [3eaa6c984a] (Enh [http://core.tcl.tk/tcl/info/2959069|2959069]), as it turns out that -fvisibility=hidden only affects definitions and not declarations. Therefore explicitely declaring each MODULE_SCOPE function as __attribute__((__visibility__("hidden")) is much better. Suggested by Stuart Cassoff (Thanks!). --- unix/configure | 89 +++++----------------------------------------------------- unix/tcl.m4 | 52 +++++++++++----------------------- win/tcl.m4 | 2 +- 3 files changed, 24 insertions(+), 119 deletions(-) diff --git a/unix/configure b/unix/configure index a3888e3..d098588 100755 --- a/unix/configure +++ b/unix/configure @@ -1449,9 +1449,9 @@ echo "$as_me: error: ${with_tclconfig} directory doesn't contain tclConfig.sh" > `ls -dr ${srcdir}/../tcl[8-9].[0-9] 2>/dev/null` \ `ls -dr ${srcdir}/../tcl[8-9].[0-9]* 2>/dev/null` ; do if test -f "$i/unix/tclConfig.sh" ; then - ac_cv_c_tclconfig="`(cd $i/unix; pwd)`" - break - fi + ac_cv_c_tclconfig="`(cd $i/unix; pwd)`" + break + fi done fi @@ -4335,80 +4335,6 @@ if test "${tcl_cv_cc_visibility_hidden+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - if test "$SHARED_BUILD" = 1; then - - hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -fvisibility=hidden -Werror" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ -#if !defined(__GNUC__) || __GNUC__ < 4 -#error visibility hidden is not supported for this compiler -#endif - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - tcl_cv_cc_visibility_hidden=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -tcl_cv_cc_visibility_hidden=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$hold_cflags - -else - - tcl_cv_cc_visibility_hidden=no - -fi - - -fi -echo "$as_me:$LINENO: result: $tcl_cv_cc_visibility_hidden" >&5 -echo "${ECHO_T}$tcl_cv_cc_visibility_hidden" >&6 - if test $tcl_cv_cc_visibility_hidden = yes; then - - CFLAGS="$CFLAGS -fvisibility=hidden" - -cat >>confdefs.h <<\_ACEOF -#define MODULE_SCOPE extern -_ACEOF - - -else - hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -Werror" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -4459,7 +4385,10 @@ fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext CFLAGS=$hold_cflags - if test $tcl_cv_cc_visibility_hidden = yes; then +fi +echo "$as_me:$LINENO: result: $tcl_cv_cc_visibility_hidden" >&5 +echo "${ECHO_T}$tcl_cv_cc_visibility_hidden" >&6 + if test $tcl_cv_cc_visibility_hidden = yes; then cat >>confdefs.h <<\_ACEOF @@ -4475,9 +4404,6 @@ _ACEOF fi -fi - - # Step 0.d: Disable -rpath support? echo "$as_me:$LINENO: checking if rpath support is requested" >&5 @@ -5995,7 +5921,6 @@ cat >>confdefs.h <<\_ACEOF #define MODULE_SCOPE __private_extern__ _ACEOF - tcl_cv_cc_visibility_hidden=yes fi diff --git a/unix/tcl.m4 b/unix/tcl.m4 index 070946a..8c29334 100644 --- a/unix/tcl.m4 +++ b/unix/tcl.m4 @@ -111,9 +111,9 @@ AC_DEFUN([SC_PATH_TCLCONFIG], [ `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]] 2>/dev/null` \ `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]]* 2>/dev/null` ; do if test -f "$i/unix/tclConfig.sh" ; then - ac_cv_c_tclconfig="`(cd $i/unix; pwd)`" - break - fi + ac_cv_c_tclconfig="`(cd $i/unix; pwd)`" + break + fi done fi ]) @@ -271,11 +271,10 @@ AC_DEFUN([SC_PATH_TKCONFIG], [ # # Results: # -# Subst the following vars: +# Substitutes the following vars: # TCL_BIN_DIR # TCL_SRC_DIR # TCL_LIB_FILE -# #------------------------------------------------------------------------ AC_DEFUN([SC_LOAD_TCLCONFIG], [ @@ -439,11 +438,11 @@ AC_DEFUN([SC_LOAD_TKCONFIG], [ # extension can't assume that an executable Tcl shell exists at # build time. # -# Arguments +# Arguments: # none # -# Results -# Subst's the following values: +# Results: +# Substitutes the following vars: # TCLSH_PROG #------------------------------------------------------------------------ @@ -484,11 +483,11 @@ AC_DEFUN([SC_PROG_TCLSH], [ # when running tests from an extension build directory. It is not # correct to use the TCLSH_PROG in cases like this. # -# Arguments +# Arguments: # none # -# Results -# Subst's the following values: +# Results: +# Substitutes the following values: # BUILD_TCLSH #------------------------------------------------------------------------ @@ -790,7 +789,6 @@ AC_DEFUN([SC_ENABLE_SYMBOLS], [ # # Defines the following vars: # HAVE_LANGINFO Triggers use of nl_langinfo if defined. -# #------------------------------------------------------------------------ AC_DEFUN([SC_ENABLE_LANGINFO], [ @@ -1045,34 +1043,17 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [ AC_CACHE_CHECK([if compiler supports visibility "hidden"], tcl_cv_cc_visibility_hidden, [ - AS_IF([test "$SHARED_BUILD" = 1], [ - hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -fvisibility=hidden -Werror" - AC_TRY_COMPILE(,[#if !defined(__GNUC__) || __GNUC__ < 4 -#error visibility hidden is not supported for this compiler -#endif - ], tcl_cv_cc_visibility_hidden=yes, - tcl_cv_cc_visibility_hidden=no) - CFLAGS=$hold_cflags - ], [ - tcl_cv_cc_visibility_hidden=no - ]) - ]) - AS_IF([test $tcl_cv_cc_visibility_hidden = yes], [ - CFLAGS="$CFLAGS -fvisibility=hidden" - AC_DEFINE(MODULE_SCOPE, [extern], [No need to mark inidividual symbols as hidden]) - ], [ hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -Werror" AC_TRY_LINK([ extern __attribute__((__visibility__("hidden"))) void f(void); void f(void) {}], [f();], tcl_cv_cc_visibility_hidden=yes, tcl_cv_cc_visibility_hidden=no) - CFLAGS=$hold_cflags - AS_IF([test $tcl_cv_cc_visibility_hidden = yes], [ - AC_DEFINE(MODULE_SCOPE, - [extern __attribute__((__visibility__("hidden")))], - [Compiler support for module scope symbols]) - AC_DEFINE(HAVE_HIDDEN, [1], [Compiler support for module scope symbols]) - ]) + CFLAGS=$hold_cflags]) + AS_IF([test $tcl_cv_cc_visibility_hidden = yes], [ + AC_DEFINE(MODULE_SCOPE, + [extern __attribute__((__visibility__("hidden")))], + [Compiler support for module scope symbols]) + AC_DEFINE(HAVE_HIDDEN, [1], [Compiler support for module scope symbols]) ]) # Step 0.d: Disable -rpath support? @@ -1645,7 +1626,6 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [ AS_IF([test "$tcl_cv_cc_visibility_hidden" != yes], [ AC_DEFINE(MODULE_SCOPE, [__private_extern__], [Compiler support for module scope symbols]) - tcl_cv_cc_visibility_hidden=yes ]) CC_SEARCH_FLAGS="" LD_SEARCH_FLAGS="" diff --git a/win/tcl.m4 b/win/tcl.m4 index 52c001f..625c329 100644 --- a/win/tcl.m4 +++ b/win/tcl.m4 @@ -247,7 +247,7 @@ AC_DEFUN([SC_PATH_TKCONFIG], [ # # Results: # -# Subst the following vars: +# Substitutes the following vars: # TCL_BIN_DIR # TCL_SRC_DIR # TCL_LIB_FILE -- cgit v0.12 From 73cd4c1a39143ee2ad2c2bb4dcb84ef52d196797 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 20 Nov 2013 09:56:25 +0000 Subject: typo --- generic/tkEvent.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tkEvent.c b/generic/tkEvent.c index 463379a..51eca3a 100644 --- a/generic/tkEvent.c +++ b/generic/tkEvent.c @@ -2065,7 +2065,7 @@ TkFinalize( * TkFinalizeThread -- * * Runs our private thread exit handlers and removes itself from Tcl. - * This is benificial should we want to protect from dangling pointers + * This is beneficial should we want to protect from dangling pointers * should the Tk shared library be unloaded prior to Tcl which can happen * on Windows should the process be forcefully exiting from an exception * handler. -- cgit v0.12 From 7799ee3637c5c613326a783eb8b3caf625d0064d Mon Sep 17 00:00:00 2001 From: andreask Date: Mon, 3 Feb 2014 19:01:57 +0000 Subject: Squash problem with native AIX cc not allowing direct macro redefinition. --- generic/ttk/ttkLabel.c | 1 + 1 file changed, 1 insertion(+) diff --git a/generic/ttk/ttkLabel.c b/generic/ttk/ttkLabel.c index 0f71970..d51388b 100644 --- a/generic/ttk/ttkLabel.c +++ b/generic/ttk/ttkLabel.c @@ -486,6 +486,7 @@ static Ttk_ElementOptionSpec LabelElementOptions[] = { * Calculate the text, image, and total width and height. */ +#undef MAX #define MAX(a,b) ((a) > (b) ? a : b); static void LabelSetup( LabelElement *c, Tk_Window tkwin, Ttk_State state) -- cgit v0.12 From 3655db8b8d9c31f3253d97a9ea250b07641c24d9 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 7 Feb 2014 08:37:40 +0000 Subject: [6867cc13a4] "tk fontchooser configure" overwrites global variables --- library/fontchooser.tcl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/library/fontchooser.tcl b/library/fontchooser.tcl index 179476c..8b3f87e 100644 --- a/library/fontchooser.tcl +++ b/library/fontchooser.tcl @@ -29,6 +29,10 @@ namespace eval ::tk::fontchooser { set S(-title) [::msgcat::mc "Font"] set S(-command) "" set S(-font) TkDefaultFont +} + +proc ::tk::fontchooser::Setup {} { + variable S # Canonical versions of font families, styles, etc. for easier searching set S(fonts,lcase) {} @@ -52,6 +56,7 @@ namespace eval ::tk::fontchooser { configure ::tk::fontchooser::Configure } } +::tk::fontchooser::Setup proc ::tk::fontchooser::Show {} { variable S -- cgit v0.12 From d015e4d8b48ad76acce178827f3ab114c330308c Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 10 Feb 2014 11:06:19 +0000 Subject: Eliminate all usage of __WIN32__ macro: Some compilers (e.g. Clang/LLVM) don't define it, and _WIN32 is much more portable anyway. See: [http://nadeausoftware.com/articles/2012/01/c_c_tip_how_use_compiler_predefined_macros_detect_operating_system#WindowsCygwinnonPOSIXandMinGW] --- generic/default.h | 3 +-- generic/tk.h | 2 +- generic/tkBind.c | 4 ++-- generic/tkCmds.c | 4 ++-- generic/tkColor.c | 4 ++-- generic/tkConsole.c | 2 +- generic/tkGrab.c | 4 ++-- generic/tkImgPhInstance.c | 20 ++++++++++---------- generic/tkImgPhoto.h | 2 +- generic/tkInt.h | 4 ++-- generic/tkIntDecls.h | 14 +++++++------- generic/tkIntPlatDecls.h | 12 ++++++------ generic/tkIntXlibDecls.h | 6 +++--- generic/tkMain.c | 8 ++++---- generic/tkPlatDecls.h | 6 +++--- generic/tkPointer.c | 2 +- generic/tkRectOval.c | 4 ++-- generic/tkSelect.c | 2 +- generic/tkStubInit.c | 30 +++++++++++++++--------------- generic/tkStubLib.c | 4 ++-- generic/tkTest.c | 24 ++++++++++++------------ generic/tkTextDisp.c | 2 +- generic/tkWindow.c | 22 +++++++++++----------- generic/ttk/ttkGenStubs.tcl | 9 ++++----- generic/ttk/ttkWidget.h | 2 +- unix/tkUnix3d.c | 2 +- unix/tkUnixDraw.c | 2 +- win/configure | 4 ++-- win/makefile.bc | 2 +- win/tcl.m4 | 4 ++-- 30 files changed, 104 insertions(+), 106 deletions(-) diff --git a/generic/default.h b/generic/default.h index 6156f4d..e6ef132 100644 --- a/generic/default.h +++ b/generic/default.h @@ -14,8 +14,7 @@ #ifndef _DEFAULT #define _DEFAULT -#if defined(__WIN32__) || defined(_WIN32) || \ - defined(__MINGW32__) +#ifdef _WIN32 # include "tkWinDefault.h" #else # if defined(MAC_OSX_TK) diff --git a/generic/tk.h b/generic/tk.h index 088f4be..8f03b54 100644 --- a/generic/tk.h +++ b/generic/tk.h @@ -1496,7 +1496,7 @@ typedef struct Tk_ElementSpec { #define Tk_Release Tcl_Release /* Removed Tk_Main, use macro instead */ -#if defined(__WIN32__) || defined(__CYGWIN__) +#if defined(_WIN32) || defined(__CYGWIN__) #define Tk_Main(argc, argv, proc) Tk_MainEx(argc, argv, proc, \ (Tcl_FindExecutable(0), (Tcl_CreateInterp)())) #else diff --git a/generic/tkBind.c b/generic/tkBind.c index ff308ed..fbac56d 100644 --- a/generic/tkBind.c +++ b/generic/tkBind.c @@ -14,11 +14,11 @@ #include "tkInt.h" -#ifdef __WIN32__ +#ifdef _WIN32 #include "tkWinInt.h" #endif -#if !(defined(__WIN32__) || defined(MAC_OSX_TK)) /* UNIX */ +#if !(defined(_WIN32) || defined(MAC_OSX_TK)) /* UNIX */ #include "tkUnixInt.h" #endif diff --git a/generic/tkCmds.c b/generic/tkCmds.c index 4933d34..23fad0f 100644 --- a/generic/tkCmds.c +++ b/generic/tkCmds.c @@ -49,7 +49,7 @@ static int WindowingsystemCmd(ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj *const *objv); -#if defined(__WIN32__) || defined(MAC_OSX_TK) +#if defined(_WIN32) || defined(MAC_OSX_TK) MODULE_SCOPE const TkEnsemble tkFontchooserEnsemble[]; #else #define tkFontchooserEnsemble NULL @@ -649,7 +649,7 @@ TkInitTkCmd( ClientData clientData) { TkMakeEnsemble(interp, "::", "tk", clientData, tkCmdMap); -#if defined(__WIN32__) || defined(MAC_OSX_TK) +#if defined(_WIN32) || defined(MAC_OSX_TK) TkInitFontchooser(interp, clientData); #endif return TCL_OK; diff --git a/generic/tkColor.c b/generic/tkColor.c index e4fa3f7..9abb448 100644 --- a/generic/tkColor.c +++ b/generic/tkColor.c @@ -829,7 +829,7 @@ TkDebugColor( return resultPtr; } -#ifndef __WIN32__ +#ifndef _WIN32 /* This function is not necessary for Win32, * since XParseColor already does the right thing */ @@ -937,7 +937,7 @@ TkParseColor( done: return XParseColor(display, map, name, color); } -#endif /* __WIN32__ */ +#endif /* _WIN32 */ /* * Local Variables: * mode: c diff --git a/generic/tkConsole.c b/generic/tkConsole.c index 12e9353..8bfbe9b 100644 --- a/generic/tkConsole.c +++ b/generic/tkConsole.c @@ -84,7 +84,7 @@ static const Tcl_ChannelType consoleChannelType = { NULL }; -#ifdef __WIN32__ +#ifdef _WIN32 #include /* diff --git a/generic/tkGrab.c b/generic/tkGrab.c index 2df5552..00d4511 100644 --- a/generic/tkGrab.c +++ b/generic/tkGrab.c @@ -12,9 +12,9 @@ #include "tkInt.h" -#ifdef __WIN32__ +#ifdef _WIN32 #include "tkWinInt.h" -#elif !(defined(__WIN32__) || defined(MAC_OSX_TK)) +#elif !defined(MAC_OSX_TK) #include "tkUnixInt.h" #endif diff --git a/generic/tkImgPhInstance.c b/generic/tkImgPhInstance.c index 01f11bb..666a9b0 100644 --- a/generic/tkImgPhInstance.c +++ b/generic/tkImgPhInstance.c @@ -407,7 +407,7 @@ TkImgPhotoGet( *---------------------------------------------------------------------- */ -#ifndef __WIN32__ +#ifndef _WIN32 #define GetRValue(rgb) (UCHAR(((rgb) & red_mask) >> red_shift)) #define GetGValue(rgb) (UCHAR(((rgb) & green_mask) >> green_shift)) #define GetBValue(rgb) (UCHAR(((rgb) & blue_mask) >> blue_shift)) @@ -419,7 +419,7 @@ TkImgPhotoGet( (((r) * red_mask / 255) & red_mask) | \ (((g) * green_mask / 255) & green_mask) | \ (((b) * blue_mask / 255) & blue_mask) )) -#endif /* !__WIN32__ */ +#endif /* !_WIN32 */ static void BlendComplexAlpha( @@ -453,7 +453,7 @@ BlendComplexAlpha( * might be cached for better performance. */ -#ifndef __WIN32__ +#ifndef _WIN32 unsigned long red_mask, green_mask, blue_mask; unsigned long red_shift, green_shift, blue_shift; Visual *visual = iPtr->visualInfo.visual; @@ -473,7 +473,7 @@ BlendComplexAlpha( while ((0x0001 & (blue_mask >> blue_shift)) == 0) { blue_shift++; } -#endif /* !__WIN32__ */ +#endif /* !_WIN32 */ /* * Only UNIX requires the special case for <24bpp. It varies with 3 extra @@ -481,7 +481,7 @@ BlendComplexAlpha( * optimized. */ -#if !(defined(__WIN32__) || defined(MAC_OSX_TK)) +#if !(defined(_WIN32) || defined(MAC_OSX_TK)) if (bgImg->depth < 24) { unsigned char red_mlen, green_mlen, blue_mlen; @@ -529,7 +529,7 @@ BlendComplexAlpha( } return; } -#endif /* !__WIN32__ && !MAC_OSX_TK */ +#endif /* !_WIN32 && !MAC_OSX_TK */ for (y = 0; y < height; y++) { line = (y + yOffset) * iPtr->masterPtr->width; @@ -1336,12 +1336,12 @@ AllocateColors( * since we will be passing the color table into the TkPutImage call. */ -#ifndef __WIN32__ +#ifndef _WIN32 if ((colorPtr->visualInfo.class != DirectColor) && (colorPtr->visualInfo.class != TrueColor)) { colorPtr->flags |= MAP_COLORS; } -#endif /* __WIN32__ */ +#endif /* _WIN32 */ } colorPtr->numColors = numColors; @@ -1770,7 +1770,7 @@ TkImgDitherInstance( case NBBY: *destBytePtr++ = i; break; -#ifndef __WIN32__ +#ifndef _WIN32 /* * This case is not valid for Windows because the * image format is different from the pixel format in @@ -1832,7 +1832,7 @@ TkImgDitherInstance( case NBBY: *destBytePtr++ = i; break; -#ifndef __WIN32__ +#ifndef _WIN32 /* * This case is not valid for Windows because the * image format is different from the pixel format in diff --git a/generic/tkImgPhoto.h b/generic/tkImgPhoto.h index 7bef76b..36bc6cb 100644 --- a/generic/tkImgPhoto.h +++ b/generic/tkImgPhoto.h @@ -17,7 +17,7 @@ */ #include "tkInt.h" -#ifdef __WIN32__ +#ifdef _WIN32 #include "tkWinInt.h" #elif defined(__CYGWIN__) #include "tkUnixInt.h" diff --git a/generic/tkInt.h b/generic/tkInt.h index b48647d..b71e9b9 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -1216,7 +1216,7 @@ MODULE_SCOPE int TkInitFontchooser(Tcl_Interp *interp, ClientData clientData); MODULE_SCOPE void TkpWarpPointer(TkDisplay *dispPtr); -#ifdef __WIN32__ +#ifdef _WIN32 #define TkParseColor XParseColor #else MODULE_SCOPE Status TkParseColor (Display * display, @@ -1242,7 +1242,7 @@ MODULE_SCOPE int SquareObjCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[]); MODULE_SCOPE int TkOldTestInit(Tcl_Interp *interp); -#if !(defined(__WIN32__) || defined(MAC_OSX_TK)) +#if !(defined(_WIN32) || defined(MAC_OSX_TK)) #define TkplatformtestInit(x) TCL_OK #else MODULE_SCOPE int TkplatformtestInit(Tcl_Interp *interp); diff --git a/generic/tkIntDecls.h b/generic/tkIntDecls.h index 3c37922..67a4f4b 100644 --- a/generic/tkIntDecls.h +++ b/generic/tkIntDecls.h @@ -676,20 +676,20 @@ typedef struct TkIntStubs { void (*tkSetRegion) (Display *display, GC gc, TkRegion rgn); /* 118 */ void (*tkUnionRectWithRegion) (XRectangle *rect, TkRegion src, TkRegion dr_return); /* 119 */ void (*reserved120)(void); -#if !(defined(__WIN32__) || defined(MAC_OSX_TK)) /* X11 */ +#if !(defined(_WIN32) || defined(MAC_OSX_TK)) /* X11 */ void (*reserved121)(void); #endif /* X11 */ -#if defined(__WIN32__) /* WIN */ +#if defined(_WIN32) /* WIN */ void (*reserved121)(void); #endif /* WIN */ #ifdef MAC_OSX_TK /* AQUA */ void (*reserved121)(void); /* Dummy entry for stubs table backwards compatibility */ Pixmap (*tkpCreateNativeBitmap) (Display *display, const void *source); /* 121 */ #endif /* AQUA */ -#if !(defined(__WIN32__) || defined(MAC_OSX_TK)) /* X11 */ +#if !(defined(_WIN32) || defined(MAC_OSX_TK)) /* X11 */ void (*reserved122)(void); #endif /* X11 */ -#if defined(__WIN32__) /* WIN */ +#if defined(_WIN32) /* WIN */ void (*reserved122)(void); #endif /* WIN */ #ifdef MAC_OSX_TK /* AQUA */ @@ -697,10 +697,10 @@ typedef struct TkIntStubs { void (*tkpDefineNativeBitmaps) (void); /* 122 */ #endif /* AQUA */ void (*reserved123)(void); -#if !(defined(__WIN32__) || defined(MAC_OSX_TK)) /* X11 */ +#if !(defined(_WIN32) || defined(MAC_OSX_TK)) /* X11 */ void (*reserved124)(void); #endif /* X11 */ -#if defined(__WIN32__) /* WIN */ +#if defined(_WIN32) /* WIN */ void (*reserved124)(void); #endif /* WIN */ #ifdef MAC_OSX_TK /* AQUA */ @@ -1150,7 +1150,7 @@ extern const TkIntStubs *tkIntStubsPtr; /* * On X11, these macros are just wrappers for the equivalent X Region calls. */ -#if !(defined(__WIN32__) || defined(__CYGWIN__) || defined(MAC_OSX_TK)) /* X11 */ +#if !(defined(_WIN32) || defined(__CYGWIN__) || defined(MAC_OSX_TK)) /* X11 */ #undef TkClipBox #undef TkCreateRegion diff --git a/generic/tkIntPlatDecls.h b/generic/tkIntPlatDecls.h index 141f743..2fd66c6 100644 --- a/generic/tkIntPlatDecls.h +++ b/generic/tkIntPlatDecls.h @@ -34,7 +34,7 @@ extern "C" { * Exported function declarations: */ -#if defined(__WIN32__) || defined(__CYGWIN__) /* WIN */ +#if defined(_WIN32) || defined(__CYGWIN__) /* WIN */ /* 0 */ EXTERN char * TkAlignImageData(XImage *image, int alignment, int bitOrder); @@ -256,7 +256,7 @@ EXTERN unsigned long TkpGetMS(void); /* 54 */ EXTERN void * TkMacOSXDrawable(Drawable drawable); #endif /* AQUA */ -#if !(defined(__WIN32__) || defined(__CYGWIN__) || defined(MAC_OSX_TK)) /* X11 */ +#if !(defined(_WIN32) || defined(__CYGWIN__) || defined(MAC_OSX_TK)) /* X11 */ /* 0 */ EXTERN void TkCreateXEventSource(void); /* Slot 1 is reserved */ @@ -291,7 +291,7 @@ typedef struct TkIntPlatStubs { int magic; void *hooks; -#if defined(__WIN32__) || defined(__CYGWIN__) /* WIN */ +#if defined(_WIN32) || defined(__CYGWIN__) /* WIN */ char * (*tkAlignImageData) (XImage *image, int alignment, int bitOrder); /* 0 */ void (*reserved1)(void); void (*tkGenerateActivateEvents) (TkWindow *winPtr, int active); /* 2 */ @@ -396,7 +396,7 @@ typedef struct TkIntPlatStubs { unsigned long (*tkpGetMS) (void); /* 53 */ void * (*tkMacOSXDrawable) (Drawable drawable); /* 54 */ #endif /* AQUA */ -#if !(defined(__WIN32__) || defined(__CYGWIN__) || defined(MAC_OSX_TK)) /* X11 */ +#if !(defined(_WIN32) || defined(__CYGWIN__) || defined(MAC_OSX_TK)) /* X11 */ void (*tkCreateXEventSource) (void); /* 0 */ void (*reserved1)(void); void (*reserved2)(void); @@ -426,7 +426,7 @@ extern const TkIntPlatStubs *tkIntPlatStubsPtr; * Inline function declarations: */ -#if defined(__WIN32__) || defined(__CYGWIN__) /* WIN */ +#if defined(_WIN32) || defined(__CYGWIN__) /* WIN */ #define TkAlignImageData \ (tkIntPlatStubsPtr->tkAlignImageData) /* 0 */ /* Slot 1 is reserved */ @@ -623,7 +623,7 @@ extern const TkIntPlatStubs *tkIntPlatStubsPtr; #define TkMacOSXDrawable \ (tkIntPlatStubsPtr->tkMacOSXDrawable) /* 54 */ #endif /* AQUA */ -#if !(defined(__WIN32__) || defined(__CYGWIN__) || defined(MAC_OSX_TK)) /* X11 */ +#if !(defined(_WIN32) || defined(__CYGWIN__) || defined(MAC_OSX_TK)) /* X11 */ #define TkCreateXEventSource \ (tkIntPlatStubsPtr->tkCreateXEventSource) /* 0 */ /* Slot 1 is reserved */ diff --git a/generic/tkIntXlibDecls.h b/generic/tkIntXlibDecls.h index 8abda05..6ac7ccb 100644 --- a/generic/tkIntXlibDecls.h +++ b/generic/tkIntXlibDecls.h @@ -44,7 +44,7 @@ extern "C" { * Exported function declarations: */ -#if defined(__WIN32__) || defined(__CYGWIN__) /* WIN */ +#if defined(_WIN32) || defined(__CYGWIN__) /* WIN */ /* 0 */ EXTERN int XSetDashes(Display *display, GC gc, int dash_offset, _Xconst char *dash_list, int n); @@ -626,7 +626,7 @@ typedef struct TkIntXlibStubs { int magic; void *hooks; -#if defined(__WIN32__) || defined(__CYGWIN__) /* WIN */ +#if defined(_WIN32) || defined(__CYGWIN__) /* WIN */ int (*xSetDashes) (Display *display, GC gc, int dash_offset, _Xconst char *dash_list, int n); /* 0 */ XModifierKeymap * (*xGetModifierMapping) (Display *d); /* 1 */ XImage * (*xCreateImage) (Display *d, Visual *v, unsigned int ui1, int i1, int i2, char *cp, unsigned int ui2, unsigned int ui3, int i3, int i4); /* 2 */ @@ -851,7 +851,7 @@ extern const TkIntXlibStubs *tkIntXlibStubsPtr; * Inline function declarations: */ -#if defined(__WIN32__) || defined(__CYGWIN__) /* WIN */ +#if defined(_WIN32) || defined(__CYGWIN__) /* WIN */ #define XSetDashes \ (tkIntXlibStubsPtr->xSetDashes) /* 0 */ #define XGetModifierMapping \ diff --git a/generic/tkMain.c b/generic/tkMain.c index 9d12693..f6f4013 100644 --- a/generic/tkMain.c +++ b/generic/tkMain.c @@ -54,7 +54,7 @@ extern int TkCygwinMainEx(int, char **, Tcl_AppInitProc *, Tcl_Interp *); * platforms which don't have we have to translate that * to strcmp here. */ -#ifdef __WIN32__ +#ifdef _WIN32 # include "tclInt.h" # include "tkWinInt.h" #else @@ -95,7 +95,7 @@ extern int TkCygwinMainEx(int, char **, Tcl_AppInitProc *, Tcl_Interp *); * it will conflict with a declaration elsewhere on some systems. */ -#if defined(__WIN32__) || defined(_WIN32) +#if defined(_WIN32) #define isatty WinIsTty static int WinIsTty(int fd) { HANDLE handle; @@ -195,7 +195,7 @@ Tk_MainEx( } } -#if defined(__WIN32__) && !defined(UNICODE) && !defined(STATIC_BUILD) +#if defined(_WIN32) && !defined(UNICODE) && !defined(STATIC_BUILD) if (tclStubsPtr->reserved9) { /* We are running win32 Tk under Cygwin, so let's check @@ -226,7 +226,7 @@ Tk_MainEx( is.gotPartial = 0; Tcl_Preserve(interp); -#if defined(__WIN32__) && !defined(__CYGWIN__) +#if defined(_WIN32) && !defined(__CYGWIN__) Tk_InitConsoleChannels(interp); #endif diff --git a/generic/tkPlatDecls.h b/generic/tkPlatDecls.h index 88fa918..1e69c88 100644 --- a/generic/tkPlatDecls.h +++ b/generic/tkPlatDecls.h @@ -37,7 +37,7 @@ extern "C" { * Exported function declarations: */ -#if defined(__WIN32__) || defined(__CYGWIN__) /* WIN */ +#if defined(_WIN32) || defined(__CYGWIN__) /* WIN */ /* 0 */ EXTERN Window Tk_AttachHWND(Tk_Window tkwin, HWND hwnd); /* 1 */ @@ -88,7 +88,7 @@ typedef struct TkPlatStubs { int magic; void *hooks; -#if defined(__WIN32__) || defined(__CYGWIN__) /* WIN */ +#if defined(_WIN32) || defined(__CYGWIN__) /* WIN */ Window (*tk_AttachHWND) (Tk_Window tkwin, HWND hwnd); /* 0 */ HINSTANCE (*tk_GetHINSTANCE) (void); /* 1 */ HWND (*tk_GetHWND) (Window window); /* 2 */ @@ -123,7 +123,7 @@ extern const TkPlatStubs *tkPlatStubsPtr; * Inline function declarations: */ -#if defined(__WIN32__) || defined(__CYGWIN__) /* WIN */ +#if defined(_WIN32) || defined(__CYGWIN__) /* WIN */ #define Tk_AttachHWND \ (tkPlatStubsPtr->tk_AttachHWND) /* 0 */ #define Tk_GetHINSTANCE \ diff --git a/generic/tkPointer.c b/generic/tkPointer.c index 451373d..0141b64 100644 --- a/generic/tkPointer.c +++ b/generic/tkPointer.c @@ -14,7 +14,7 @@ #include "tkInt.h" -#ifdef __WIN32__ +#ifdef _WIN32 #include "tkWinInt.h" #endif diff --git a/generic/tkRectOval.c b/generic/tkRectOval.c index a51ca33..50b5f1a 100644 --- a/generic/tkRectOval.c +++ b/generic/tkRectOval.c @@ -671,11 +671,11 @@ ComputeRectOvalBbox( * correct place to solve it, but it works. */ -#ifdef __WIN32__ +#ifdef _WIN32 bloat = 1; #else bloat = 0; -#endif /* __WIN32__ */ +#endif /* _WIN32 */ } else { #ifdef MAC_OSX_TK /* diff --git a/generic/tkSelect.c b/generic/tkSelect.c index 2414b3d..ab9018a 100644 --- a/generic/tkSelect.c +++ b/generic/tkSelect.c @@ -1193,7 +1193,7 @@ TkSelInit( * http://www.cl.cam.ac.uk/~mgk25/unicode.html#x11 */ -#if !defined(__WIN32__) +#if !defined(_WIN32) dispPtr->utf8Atom = Tk_InternAtom(tkwin, "UTF8_STRING"); #else dispPtr->utf8Atom = (Atom) 0; diff --git a/generic/tkStubInit.c b/generic/tkStubInit.c index d141b02..47288c6 100644 --- a/generic/tkStubInit.c +++ b/generic/tkStubInit.c @@ -11,13 +11,13 @@ #include "tkInt.h" -#if !(defined(__WIN32__) || defined(MAC_OSX_TK)) +#if !(defined(_WIN32) || defined(MAC_OSX_TK)) /* UNIX */ #define UNIX_TK #include "tkUnixInt.h" #endif -#ifdef __WIN32__ +#ifdef _WIN32 #include "tkWinInt.h" #endif @@ -38,7 +38,7 @@ static const TkIntStubs tkIntStubs; #undef Tk_MainEx -#ifdef __WIN32__ +#ifdef _WIN32 int TkpCmapStressed(Tk_Window tkwin, Colormap colormap) @@ -65,7 +65,7 @@ TkCreateXEventSource(void) # define TkSendCleanup (void (*)(TkDisplay *)) TkpSync # define TkpTestsendCmd 0 -#else /* !__WIN32__ */ +#else /* !_WIN32 */ /* * Make sure that extensions which call XParseColor through the stub @@ -224,7 +224,7 @@ void TkSubtractRegion (TkRegion a, TkRegion b, TkRegion c) # define TkUnionRectWithRegion (void (*) (XRectangle *, TkRegion, TkRegion)) XUnionRectWithRegion # define TkSubtractRegion (void (*) (TkRegion, TkRegion, TkRegion)) XSubtractRegion # endif -#endif /* !__WIN32__ */ +#endif /* !_WIN32 */ /* * WARNING: The contents of this file is automatically generated by the @@ -358,20 +358,20 @@ static const TkIntStubs tkIntStubs = { TkSetRegion, /* 118 */ TkUnionRectWithRegion, /* 119 */ 0, /* 120 */ -#if !(defined(__WIN32__) || defined(MAC_OSX_TK)) /* X11 */ +#if !(defined(_WIN32) || defined(MAC_OSX_TK)) /* X11 */ 0, /* 121 */ #endif /* X11 */ -#if defined(__WIN32__) /* WIN */ +#if defined(_WIN32) /* WIN */ 0, /* 121 */ #endif /* WIN */ #ifdef MAC_OSX_TK /* AQUA */ 0, /* 121 */ /* Dummy entry for stubs table backwards compatibility */ TkpCreateNativeBitmap, /* 121 */ #endif /* AQUA */ -#if !(defined(__WIN32__) || defined(MAC_OSX_TK)) /* X11 */ +#if !(defined(_WIN32) || defined(MAC_OSX_TK)) /* X11 */ 0, /* 122 */ #endif /* X11 */ -#if defined(__WIN32__) /* WIN */ +#if defined(_WIN32) /* WIN */ 0, /* 122 */ #endif /* WIN */ #ifdef MAC_OSX_TK /* AQUA */ @@ -379,10 +379,10 @@ static const TkIntStubs tkIntStubs = { TkpDefineNativeBitmaps, /* 122 */ #endif /* AQUA */ 0, /* 123 */ -#if !(defined(__WIN32__) || defined(MAC_OSX_TK)) /* X11 */ +#if !(defined(_WIN32) || defined(MAC_OSX_TK)) /* X11 */ 0, /* 124 */ #endif /* X11 */ -#if defined(__WIN32__) /* WIN */ +#if defined(_WIN32) /* WIN */ 0, /* 124 */ #endif /* WIN */ #ifdef MAC_OSX_TK /* AQUA */ @@ -454,7 +454,7 @@ static const TkIntStubs tkIntStubs = { static const TkIntPlatStubs tkIntPlatStubs = { TCL_STUB_MAGIC, 0, -#if defined(__WIN32__) || defined(__CYGWIN__) /* WIN */ +#if defined(_WIN32) || defined(__CYGWIN__) /* WIN */ TkAlignImageData, /* 0 */ 0, /* 1 */ TkGenerateActivateEvents, /* 2 */ @@ -559,7 +559,7 @@ static const TkIntPlatStubs tkIntPlatStubs = { TkpGetMS, /* 53 */ TkMacOSXDrawable, /* 54 */ #endif /* AQUA */ -#if !(defined(__WIN32__) || defined(__CYGWIN__) || defined(MAC_OSX_TK)) /* X11 */ +#if !(defined(_WIN32) || defined(__CYGWIN__) || defined(MAC_OSX_TK)) /* X11 */ TkCreateXEventSource, /* 0 */ 0, /* 1 */ 0, /* 2 */ @@ -580,7 +580,7 @@ static const TkIntPlatStubs tkIntPlatStubs = { static const TkIntXlibStubs tkIntXlibStubs = { TCL_STUB_MAGIC, 0, -#if defined(__WIN32__) || defined(__CYGWIN__) /* WIN */ +#if defined(_WIN32) || defined(__CYGWIN__) /* WIN */ XSetDashes, /* 0 */ XGetModifierMapping, /* 1 */ XCreateImage, /* 2 */ @@ -796,7 +796,7 @@ static const TkIntXlibStubs tkIntXlibStubs = { static const TkPlatStubs tkPlatStubs = { TCL_STUB_MAGIC, 0, -#if defined(__WIN32__) || defined(__CYGWIN__) /* WIN */ +#if defined(_WIN32) || defined(__CYGWIN__) /* WIN */ Tk_AttachHWND, /* 0 */ Tk_GetHINSTANCE, /* 1 */ Tk_GetHWND, /* 2 */ diff --git a/generic/tkStubLib.c b/generic/tkStubLib.c index fe30f26..ea48894 100644 --- a/generic/tkStubLib.c +++ b/generic/tkStubLib.c @@ -13,7 +13,7 @@ #include "tkInt.h" -#ifdef __WIN32__ +#ifdef _WIN32 #include "tkWinInt.h" #endif @@ -21,7 +21,7 @@ #include "tkMacOSXInt.h" #endif -#if !(defined(__WIN32__) || defined(MAC_OSX_TK)) +#if !(defined(_WIN32) || defined(MAC_OSX_TK)) #include "tkUnixInt.h" #endif diff --git a/generic/tkTest.c b/generic/tkTest.c index 8146c69..562b2c8 100644 --- a/generic/tkTest.c +++ b/generic/tkTest.c @@ -24,7 +24,7 @@ #include "tkInt.h" #include "tkText.h" -#ifdef __WIN32__ +#ifdef _WIN32 #include "tkWinInt.h" #endif @@ -160,11 +160,11 @@ static int TestfontObjCmd(ClientData dummy, Tcl_Obj *const objv[]); static int TestmakeexistCmd(ClientData dummy, Tcl_Interp *interp, int argc, const char **argv); -#if !(defined(__WIN32__) || defined(MAC_OSX_TK) || defined(__CYGWIN__)) +#if !(defined(_WIN32) || defined(MAC_OSX_TK) || defined(__CYGWIN__)) static int TestmenubarCmd(ClientData dummy, Tcl_Interp *interp, int argc, const char **argv); #endif -#if defined(__WIN32__) || defined(MAC_OSX_TK) +#if defined(_WIN32) || defined(MAC_OSX_TK) static int TestmetricsCmd(ClientData dummy, Tcl_Interp *interp, int argc, const char **argv); #endif @@ -186,7 +186,7 @@ static void CustomOptionFree(ClientData clientData, Tk_Window tkwin, char *internalPtr); static int TestpropCmd(ClientData dummy, Tcl_Interp *interp, int argc, const char **argv); -#if !(defined(__WIN32__) || defined(MAC_OSX_TK) || defined(__CYGWIN__)) +#if !(defined(_WIN32) || defined(MAC_OSX_TK) || defined(__CYGWIN__)) static int TestwrapperCmd(ClientData dummy, Tcl_Interp *interp, int argc, const char **argv); #endif @@ -259,7 +259,7 @@ Tktest_Init( Tcl_CreateCommand(interp, "testtext", TkpTesttextCmd, (ClientData) Tk_MainWindow(interp), NULL); -#if defined(__WIN32__) || defined(MAC_OSX_TK) +#if defined(_WIN32) || defined(MAC_OSX_TK) Tcl_CreateCommand(interp, "testmetrics", TestmetricsCmd, (ClientData) Tk_MainWindow(interp), NULL); #elif !defined(__CYGWIN__) @@ -269,7 +269,7 @@ Tktest_Init( (ClientData) Tk_MainWindow(interp), NULL); Tcl_CreateCommand(interp, "testwrapper", TestwrapperCmd, (ClientData) Tk_MainWindow(interp), NULL); -#endif /* __WIN32__ || MAC_OSX_TK */ +#endif /* _WIN32 || MAC_OSX_TK */ /* * Create test image type. @@ -1693,7 +1693,7 @@ TestmakeexistCmd( */ /* ARGSUSED */ -#if !(defined(__WIN32__) || defined(MAC_OSX_TK) || defined(__CYGWIN__)) +#if !(defined(_WIN32) || defined(MAC_OSX_TK) || defined(__CYGWIN__)) static int TestmenubarCmd( ClientData clientData, /* Main window for application. */ @@ -1761,7 +1761,7 @@ TestmenubarCmd( *---------------------------------------------------------------------- */ -#if defined(__WIN32__) || defined(MAC_OSX_TK) +#if defined(_WIN32) || defined(MAC_OSX_TK) static int TestmetricsCmd( ClientData clientData, /* Main window for application. */ @@ -1772,7 +1772,7 @@ TestmetricsCmd( char buf[TCL_INTEGER_SPACE]; int val; -#ifdef __WIN32__ +#ifdef _WIN32 if (argc < 2) { Tcl_AppendResult(interp, "wrong # args; must be \"", argv[0], " option ?arg ...?\"", NULL); @@ -1795,13 +1795,13 @@ TestmetricsCmd( #endif if (strcmp(argv[1], "cyvscroll") == 0) { -#ifdef __WIN32__ +#ifdef _WIN32 val = GetSystemMetrics(SM_CYVSCROLL); #else val = ((TkScrollbar *) winPtr->instanceData)->width; #endif } else if (strcmp(argv[1], "cxhscroll") == 0) { -#ifdef __WIN32__ +#ifdef _WIN32 val = GetSystemMetrics(SM_CXHSCROLL); #else val = ((TkScrollbar *) winPtr->instanceData)->width; @@ -1895,7 +1895,7 @@ TestpropCmd( return TCL_OK; } -#if !(defined(__WIN32__) || defined(MAC_OSX_TK) || defined(__CYGWIN__)) +#if !(defined(_WIN32) || defined(MAC_OSX_TK) || defined(__CYGWIN__)) /* *---------------------------------------------------------------------- * diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 5bd69a3..aebdcc6 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -16,7 +16,7 @@ #include "tkInt.h" #include "tkText.h" -#ifdef __WIN32__ +#ifdef _WIN32 #include "tkWinInt.h" #elif defined(__CYGWIN__) #include "tkUnixInt.h" diff --git a/generic/tkWindow.c b/generic/tkWindow.c index 6f5ee95..4a65db7 100644 --- a/generic/tkWindow.c +++ b/generic/tkWindow.c @@ -14,7 +14,7 @@ #include "tkInt.h" -#ifdef __WIN32__ +#ifdef _WIN32 #include "tkWinInt.h" #elif !defined(MAC_OSX_TK) #include "tkUnixInt.h" @@ -189,7 +189,7 @@ static const TkCmd commands[] = { * these commands differently (via the script library). */ -#if defined(__WIN32__) || defined(MAC_OSX_TK) +#if defined(_WIN32) || defined(MAC_OSX_TK) {"tk_chooseColor", Tk_ChooseColorObjCmd, PASSMAINWINDOW}, {"tk_chooseDirectory", Tk_ChooseDirectoryObjCmd,WINMACONLY|PASSMAINWINDOW}, {"tk_getOpenFile", Tk_GetOpenFileObjCmd, WINMACONLY|PASSMAINWINDOW}, @@ -959,7 +959,7 @@ TkCreateMainWindow( Tcl_Panic("TkCreateMainWindow: builtin command with NULL string and object procs"); } -#if defined(__WIN32__) && !defined(STATIC_BUILD) +#if defined(_WIN32) && !defined(STATIC_BUILD) if ((cmdPtr->flags & WINMACONLY) && tclStubsPtr->reserved9) { /* * We are running on Cygwin, so don't use the win32 dialogs. @@ -967,7 +967,7 @@ TkCreateMainWindow( continue; } -#endif /* __WIN32__ && !STATIC_BUILD */ +#endif /* _WIN32 && !STATIC_BUILD */ if (cmdPtr->flags & PASSMAINWINDOW) { clientData = tkwin; @@ -1466,7 +1466,7 @@ Tk_DestroyWindow( TkWmRemoveFromColormapWindows(winPtr); } if (winPtr->window != None) { -#if defined(MAC_OSX_TK) || defined(__WIN32__) +#if defined(MAC_OSX_TK) || defined(_WIN32) XDestroyWindow(winPtr->display, winPtr->window); #else if ((winPtr->flags & TK_TOP_HIERARCHY) @@ -2851,7 +2851,7 @@ DeleteWindowsExitProc( tsdPtr->initialized = 0; } -#if defined(__WIN32__) +#if defined(_WIN32) static HMODULE tkcygwindll = NULL; @@ -2897,7 +2897,7 @@ TkCygwinMainEx( tkmainex(argc, argv, appInitProc, interp); return 1; } -#endif /* __WIN32__ */ +#endif /* _WIN32 */ /* *---------------------------------------------------------------------- @@ -2926,7 +2926,7 @@ int Tk_Init( Tcl_Interp *interp) /* Interpreter to initialize. */ { -#if defined(__WIN32__) +#if defined(_WIN32) if (tkcygwindll) { int (*tkinit)(Tcl_Interp *); @@ -2935,7 +2935,7 @@ Tk_Init( return tkinit(interp); } } -#endif /* __WIN32__ */ +#endif /* _WIN32 */ return Initialize(interp); } @@ -2999,7 +2999,7 @@ Tk_SafeInit( * checked at several places to differentiate the two initialisations. */ -#if defined(__WIN32__) +#if defined(_WIN32) if (tkcygwindll) { int (*tksafeinit)(Tcl_Interp *); @@ -3009,7 +3009,7 @@ Tk_SafeInit( return tksafeinit(interp); } } -#endif /* __WIN32__ */ +#endif /* _WIN32 */ return Initialize(interp); } diff --git a/generic/ttk/ttkGenStubs.tcl b/generic/ttk/ttkGenStubs.tcl index 5e56951..034f405 100644 --- a/generic/ttk/ttkGenStubs.tcl +++ b/generic/ttk/ttkGenStubs.tcl @@ -290,14 +290,14 @@ proc genStubs::addPlatformGuard {plat iftxt {eltxt {}}} { set text "" switch $plat { win { - append text "#ifdef __WIN32__ /* WIN */\n${iftxt}" + append text "#ifdef _WIN32 /* WIN */\n${iftxt}" if {$eltxt ne ""} { append text "#else /* WIN */\n${eltxt}" } append text "#endif /* WIN */\n" } unix { - append text "#if !defined(__WIN32__) && !defined(MAC_OSX_TCL)\ + append text "#if !defined(_WIN32) && !defined(MAC_OSX_TCL)\ /* UNIX */\n${iftxt}" if {$eltxt ne ""} { append text "#else /* UNIX */\n${eltxt}" @@ -319,7 +319,7 @@ proc genStubs::addPlatformGuard {plat iftxt {eltxt {}}} { append text "#endif /* AQUA */\n" } x11 { - append text "#if !(defined(__WIN32__) || defined(MAC_OSX_TK))\ + append text "#if !(defined(_WIN32) || defined(MAC_OSX_TK))\ /* X11 */\n${iftxt}" if {$eltxt ne ""} { append text "#else /* X11 */\n${eltxt}" @@ -822,10 +822,9 @@ proc genStubs::emitInit {name textVar} { variable hooks variable interfaces variable epoch - variable revision upvar $textVar text - set root 1 + set capName [string toupper [string index $name 0]] append capName [string range $name 1 end] diff --git a/generic/ttk/ttkWidget.h b/generic/ttk/ttkWidget.h index 9e9ab69..e4dd712 100644 --- a/generic/ttk/ttkWidget.h +++ b/generic/ttk/ttkWidget.h @@ -260,7 +260,7 @@ MODULE_SCOPE int TtkGetLabelAnchorFromObj( * Platform-specific initialization. */ -#if defined(__WIN32__) +#ifdef _WIN32 #define Ttk_PlatformInit Ttk_WinPlatformInit MODULE_SCOPE int Ttk_PlatformInit(Tcl_Interp *); #elif defined(MAC_OSX_TK) diff --git a/unix/tkUnix3d.c b/unix/tkUnix3d.c index 38ce683..038d4e1 100644 --- a/unix/tkUnix3d.c +++ b/unix/tkUnix3d.c @@ -13,7 +13,7 @@ #include "tkInt.h" #include "tk3d.h" -#if !(defined(__WIN32__) || defined(MAC_OSX_TK)) +#if !(defined(_WIN32) || defined(MAC_OSX_TK)) #include "tkUnixInt.h" #endif diff --git a/unix/tkUnixDraw.c b/unix/tkUnixDraw.c index 55f7464..acc0565 100644 --- a/unix/tkUnixDraw.c +++ b/unix/tkUnixDraw.c @@ -11,7 +11,7 @@ #include "tkInt.h" -#if !defined(__WIN32__) +#ifndef _WIN32 #include "tkUnixInt.h" #endif diff --git a/win/configure b/win/configure index 7ce097f..299be69 100755 --- a/win/configure +++ b/win/configure @@ -3489,7 +3489,7 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ - #ifndef __WIN32__ + #ifndef _WIN32 #error cross-compiler #endif @@ -3612,7 +3612,7 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ - #ifdef __WIN32__ + #ifdef _WIN32 #error win32 #endif diff --git a/win/makefile.bc b/win/makefile.bc index 8738da9..934599c 100644 --- a/win/makefile.bc +++ b/win/makefile.bc @@ -243,7 +243,7 @@ RCDIR = $(WINDIR)\rc TK_INCLUDES = -I$(WINDIR) -I$(GENERICDIR) -I$(BITMAPDIR) -I$(XLIBDIR) \ -I$(TCLDIR)\generic -I$(TCLDIR)\win -TK_DEFINES = -D__WIN32__ $(DEBUGDEFINES) $(THREADDEFINES) SUPPORT_CONFIG_EMBEDDED +TK_DEFINES = -D_WIN32 $(DEBUGDEFINES) $(THREADDEFINES) SUPPORT_CONFIG_EMBEDDED ###################################################################### # Compile flags diff --git a/win/tcl.m4 b/win/tcl.m4 index 625c329..d12ae10 100644 --- a/win/tcl.m4 +++ b/win/tcl.m4 @@ -572,7 +572,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [ AC_CACHE_CHECK(for cross-compile version of gcc, ac_cv_cross, AC_TRY_COMPILE([ - #ifndef __WIN32__ + #ifndef _WIN32 #error cross-compiler #endif ], [], @@ -639,7 +639,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [ AC_CACHE_CHECK(for mingw32 version of gcc, ac_cv_win32, AC_TRY_COMPILE([ - #ifdef __WIN32__ + #ifdef _WIN32 #error win32 #endif ], [], -- cgit v0.12 From 6b8394f347165c180bf1baae9739a68642e09d0e Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 10 Feb 2014 11:35:13 +0000 Subject: Eliminate all usage of WIN32 macro as well: _WIN32 is the portable macro. --- generic/tkCanvPs.c | 12 ++++++------ generic/tkCmds.c | 4 ++-- generic/tkListbox.c | 8 ++++---- generic/tkWindow.c | 4 ++-- generic/ttk/ttkClamTheme.c | 2 +- generic/ttk/ttkDefaultTheme.c | 2 +- generic/ttk/ttkElements.c | 2 +- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/generic/tkCanvPs.c b/generic/tkCanvPs.c index 70fc457..c6470dd 100644 --- a/generic/tkCanvPs.c +++ b/generic/tkCanvPs.c @@ -1168,7 +1168,7 @@ GetPostscriptPoints( *-------------------------------------------------------------- */ -#ifdef WIN32 +#ifdef _WIN32 #include /* @@ -1178,15 +1178,15 @@ GetPostscriptPoints( #define GetBValue(rgb) ((BYTE)((rgb)>>16)) */ -#else /* !WIN32 */ +#else /* !_WIN32 */ #define GetRValue(rgb) ((rgb & cdata->red_mask) >> cdata->red_shift) #define GetGValue(rgb) ((rgb & cdata->green_mask) >> cdata->green_shift) #define GetBValue(rgb) ((rgb & cdata->blue_mask) >> cdata->blue_shift) -#endif /* WIN32 */ +#endif /* _WIN32 */ -#if defined(WIN32) || defined(MAC_OSX_TK) +#if defined(_WIN32) || defined(MAC_OSX_TK) static void TkImageGetColor( TkColormapData *cdata, /* Colormap data */ @@ -1198,7 +1198,7 @@ TkImageGetColor( *green = (double) GetGValue(pixel) / 255.0; *blue = (double) GetBValue(pixel) / 255.0; } -#else /* ! (WIN32 || MAC_OSX_TK) */ +#else /* ! (_WIN32 || MAC_OSX_TK) */ static void TkImageGetColor( TkColormapData *cdata, /* Colormap data */ @@ -1220,7 +1220,7 @@ TkImageGetColor( *blue = cdata->colors[pixel].blue / 65535.0; } } -#endif /* WIN32 || MAC_OSX_TK */ +#endif /* _WIN32 || MAC_OSX_TK */ /* *-------------------------------------------------------------- diff --git a/generic/tkCmds.c b/generic/tkCmds.c index 23fad0f..a4f2ed9 100644 --- a/generic/tkCmds.c +++ b/generic/tkCmds.c @@ -14,7 +14,7 @@ #include "tkInt.h" -#if defined(WIN32) +#if defined(_WIN32) #include "tkWinInt.h" #elif defined(MAC_OSX_TK) #include "tkMacOSXInt.h" @@ -914,7 +914,7 @@ WindowingsystemCmd( Tcl_WrongNumArgs(interp, 1, objv, NULL); return TCL_ERROR; } -#if defined(WIN32) +#if defined(_WIN32) windowingsystem = "win32"; #elif defined(MAC_OSX_TK) windowingsystem = "aqua"; diff --git a/generic/tkListbox.c b/generic/tkListbox.c index d77fc8f..437973a 100644 --- a/generic/tkListbox.c +++ b/generic/tkListbox.c @@ -15,7 +15,7 @@ #include "default.h" #include "tkInt.h" -#ifdef WIN32 +#ifdef _WIN32 #include "tkWinInt.h" #endif @@ -2077,7 +2077,7 @@ DisplayListbox( Tk_UnderlineChars(listPtr->display, pixmap, gc, listPtr->tkfont, stringRep, x, y, 0, stringLen); } else if (listPtr->activeStyle == ACTIVE_STYLE_DOTBOX) { -#ifdef WIN32 +#ifdef _WIN32 /* * This provides for exact default look and feel on Windows. */ @@ -2094,7 +2094,7 @@ DisplayListbox( rect.bottom = rect.top + listPtr->lineHeight; DrawFocusRect(dc, &rect); TkWinReleaseDrawableDC(pixmap, dc, &state); -#else /* !WIN32 */ +#else /* !_WIN32 */ /* * Draw a dotted box around the text. */ @@ -2133,7 +2133,7 @@ DisplayListbox( gcValues.line_style = LineSolid; XChangeGC(listPtr->display, gc, GCLineStyle, &gcValues); } -#endif /* WIN32 */ +#endif /* _WIN32 */ } } diff --git a/generic/tkWindow.c b/generic/tkWindow.c index 4a65db7..53b368c 100644 --- a/generic/tkWindow.c +++ b/generic/tkWindow.c @@ -1578,7 +1578,7 @@ Tk_DestroyWindow( * display now and relinquish its data structures. */ -#if !defined(WIN32) && defined(NOT_YET) +#if !defined(_WIN32) && defined(NOT_YET) if (dispPtr->refCount <= 0) { /* * I have disabled this code because on Windows there are @@ -1626,7 +1626,7 @@ Tk_DestroyWindow( TkCloseDisplay(dispPtr); } -#endif /* !WIN32 && NOT_YET */ +#endif /* !_WIN32 && NOT_YET */ } } Tcl_EventuallyFree(winPtr, TCL_DYNAMIC); diff --git a/generic/ttk/ttkClamTheme.c b/generic/ttk/ttkClamTheme.c index 572f630..15ebcb7 100644 --- a/generic/ttk/ttkClamTheme.c +++ b/generic/ttk/ttkClamTheme.c @@ -12,7 +12,7 @@ * off-by-one error in the end point. This is especially apparent with this * theme. Defining this macro as true handles this case. */ -#if defined(WIN32) && !defined(WIN32_XDRAWLINE_HACK) +#if defined(_WIN32) && !defined(WIN32_XDRAWLINE_HACK) # define WIN32_XDRAWLINE_HACK 1 #else # define WIN32_XDRAWLINE_HACK 0 diff --git a/generic/ttk/ttkDefaultTheme.c b/generic/ttk/ttkDefaultTheme.c index 0c55651..81f8126 100644 --- a/generic/ttk/ttkDefaultTheme.c +++ b/generic/ttk/ttkDefaultTheme.c @@ -12,7 +12,7 @@ #include #include "ttkTheme.h" -#if defined(WIN32) +#if defined(_WIN32) static const int WIN32_XDRAWLINE_HACK = 1; #else static const int WIN32_XDRAWLINE_HACK = 0; diff --git a/generic/ttk/ttkElements.c b/generic/ttk/ttkElements.c index c348834..5c95dba 100644 --- a/generic/ttk/ttkElements.c +++ b/generic/ttk/ttkElements.c @@ -1145,7 +1145,7 @@ static void TabElementDraw( Tk_3DBorderGC(tkwin, border, TK_3D_FLAT_GC), pts, 6, Convex, CoordModeOrigin); -#ifndef WIN32 +#ifndef _WIN32 /* * Account for whether XDrawLines draws endpoints by platform */ -- cgit v0.12 From 8aaaa90ec748d85170eb507c7f563223493c3471 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 11 Feb 2014 11:39:43 +0000 Subject: Fix for [f476e3d654]: Tk trunk fails to build/link --- generic/tkStubInit.c | 1 + 1 file changed, 1 insertion(+) diff --git a/generic/tkStubInit.c b/generic/tkStubInit.c index 47288c6..5a3e1ce 100644 --- a/generic/tkStubInit.c +++ b/generic/tkStubInit.c @@ -31,6 +31,7 @@ #include "tkIntXlibDecls.h" static const TkIntStubs tkIntStubs; +MODULE_SCOPE const TkStubs tkStubs; /* * Remove macro that might interfere with the definition below. -- cgit v0.12 From f7d16318aae20d960e3c9a993cc28a8174359486 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 13 Mar 2014 08:12:18 +0000 Subject: Fix TK_RELEASE_SERIAL value --- generic/tk.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tk.h b/generic/tk.h index 8f03b54..5d8bd0b 100644 --- a/generic/tk.h +++ b/generic/tk.h @@ -75,7 +75,7 @@ extern "C" { #define TK_MAJOR_VERSION 8 #define TK_MINOR_VERSION 6 #define TK_RELEASE_LEVEL TCL_FINAL_RELEASE -#define TK_RELEASE_SERIAL 0 +#define TK_RELEASE_SERIAL 1 #define TK_VERSION "8.6" #define TK_PATCH_LEVEL "8.6.1" -- cgit v0.12 From 7f35489789c22f3ffecf0bb04fee535339e0a771 Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Sun, 16 Mar 2014 21:18:22 +0000 Subject: Update configure files on Aqua to remove garbage collection flag, which is no longer supported with Xcode 5.1; also add key to Wish Info.plist to support high-resolution (Retina) displays. --- macosx/Wish-Info.plist.in | 2 ++ unix/configure | 2 +- unix/configure.in | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/macosx/Wish-Info.plist.in b/macosx/Wish-Info.plist.in index 90e00a4..78170f1 100644 --- a/macosx/Wish-Info.plist.in +++ b/macosx/Wish-Info.plist.in @@ -72,5 +72,7 @@ Copyright © 2001-2002 Jim Ingham & Ian Reid OSAScriptingDefinition Wish.sdef + NSHighResolutionCapable + True diff --git a/unix/configure b/unix/configure index ab4f9f6..ad9b051 100755 --- a/unix/configure +++ b/unix/configure @@ -9631,7 +9631,7 @@ cat >>confdefs.h <<\_ACEOF _ACEOF LIBS="$LIBS -framework Cocoa -framework Carbon -framework IOKit" - EXTRA_CC_SWITCHES='-std=gnu99 -x objective-c -fobjc-gc' + EXTRA_CC_SWITCHES='-std=gnu99 -x objective-c ' TK_WINDOWINGSYSTEM=AQUA if test -n "${enable_symbols}" -a "${enable_symbols}" != no; then diff --git a/unix/configure.in b/unix/configure.in index 948eae2..4527612 100644 --- a/unix/configure.in +++ b/unix/configure.in @@ -369,7 +369,7 @@ fi if test $tk_aqua = yes; then AC_DEFINE(MAC_OSX_TK, 1, [Are we building TkAqua?]) LIBS="$LIBS -framework Cocoa -framework Carbon -framework IOKit" - EXTRA_CC_SWITCHES='-std=gnu99 -x objective-c -fobjc-gc' + EXTRA_CC_SWITCHES='-std=gnu99 -x objective-c' TK_WINDOWINGSYSTEM=AQUA if test -n "${enable_symbols}" -a "${enable_symbols}" != no; then AC_DEFINE(TK_MAC_DEBUG, 1, [Are TkAqua debug messages enabled?]) -- cgit v0.12 From 44f5fc24fed3e8fce2accea8bd57a5998c3829b5 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 19 May 2014 13:43:36 +0000 Subject: Possible fix for [http://core.tcl.tk/tcl/info/4955f5d8a4dce006e063f924bc9709f7850ecb6a|4955f5d8a4] --- library/tk.tcl | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/library/tk.tcl b/library/tk.tcl index c490797..0110fe3 100644 --- a/library/tk.tcl +++ b/library/tk.tcl @@ -24,7 +24,7 @@ namespace eval ::tk { # The msgcat package is not available. Supply our own # minimal replacement. proc mc {src args} { - tailcall format $src {*}$args + return [format $src {*}$args] } proc mcmax {args} { set max 0 @@ -334,35 +334,35 @@ proc ::tk::EventMotifBindings {n1 dummy dummy} { if {![llength [info commands tk_chooseColor]]} { proc ::tk_chooseColor {args} { - tailcall ::tk::dialog::color:: {*}$args + return [::tk::dialog::color:: {*}$args] } } if {![llength [info commands tk_getOpenFile]]} { proc ::tk_getOpenFile {args} { if {$::tk_strictMotif} { - tailcall ::tk::MotifFDialog open {*}$args + return [::tk::MotifFDialog open {*}$args] } else { - tailcall ::tk::dialog::file:: open {*}$args + return [::tk::dialog::file:: open {*}$args] } } } if {![llength [info commands tk_getSaveFile]]} { proc ::tk_getSaveFile {args} { if {$::tk_strictMotif} { - tailcall ::tk::MotifFDialog save {*}$args + return [::tk::MotifFDialog save {*}$args] } else { - tailcall ::tk::dialog::file:: save {*}$args + return [::tk::dialog::file:: save {*}$args] } } } if {![llength [info commands tk_messageBox]]} { proc ::tk_messageBox {args} { - tailcall ::tk::MessageBox {*}$args + return [::tk::MessageBox {*}$args] } } if {![llength [info command tk_chooseDirectory]]} { proc ::tk_chooseDirectory {args} { - tailcall ::tk::dialog::file::chooseDir:: {*}$args + return [::tk::dialog::file::chooseDir:: {*}$args] } } -- cgit v0.12 From 9ad951406b16aac72049cd90ba9f7ad7678ea7d7 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 22 May 2014 14:46:49 +0000 Subject: Make the "scrollbar" a real Tcl_Obj-based command. No change in functionality. --- generic/tkCmds.c | 10 +-- generic/tkInt.h | 9 ++- generic/tkScrollbar.c | 220 +++++++++++++++++++++++++------------------------- generic/tkWindow.c | 22 ++--- tests/scrollbar.test | 2 +- 5 files changed, 129 insertions(+), 134 deletions(-) diff --git a/generic/tkCmds.c b/generic/tkCmds.c index a4f2ed9..6196b17 100644 --- a/generic/tkCmds.c +++ b/generic/tkCmds.c @@ -2094,7 +2094,7 @@ TkGetDisplayOf( /* *---------------------------------------------------------------------- * - * TkDeadAppCmd -- + * TkDeadAppObjCmd -- * * If an application has been deleted then all Tk commands will be * re-bound to this function. @@ -2111,15 +2111,15 @@ TkGetDisplayOf( /* ARGSUSED */ int -TkDeadAppCmd( +TkDeadAppObjCmd( ClientData clientData, /* Dummy. */ Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - const char **argv) /* Argument strings. */ + int objc, /* Number of arguments. */ + Tcl_Obj *const objv[]) /* Argument strings. */ { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't invoke \"%s\" command: application has been destroyed", - argv[0])); + Tcl_GetString(objv[0]))); return TCL_ERROR; } diff --git a/generic/tkInt.h b/generic/tkInt.h index b71e9b9..7279096 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -1110,8 +1110,9 @@ MODULE_SCOPE int Tk_RaiseObjCmd(ClientData clientData, MODULE_SCOPE int Tk_ScaleObjCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); -MODULE_SCOPE int Tk_ScrollbarCmd(ClientData clientData, - Tcl_Interp *interp, int argc, const char **argv); +MODULE_SCOPE int Tk_ScrollbarObjCmd(ClientData clientData, + Tcl_Interp *interp, int objc, + Tcl_Obj *const objv[]); MODULE_SCOPE int Tk_SelectionObjCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); @@ -1151,8 +1152,8 @@ MODULE_SCOPE void TkFreeGeometryMaster(Tk_Window tkwin, MODULE_SCOPE void TkEventInit(void); MODULE_SCOPE void TkRegisterObjTypes(void); -MODULE_SCOPE int TkDeadAppCmd(ClientData clientData, - Tcl_Interp *interp, int argc, const char **argv); +MODULE_SCOPE int TkDeadAppObjCmd(ClientData clientData, + Tcl_Interp *interp, int objc, Tcl_Obj *const argv[]); MODULE_SCOPE int TkCanvasGetCoordObj(Tcl_Interp *interp, Tk_Canvas canvas, Tcl_Obj *obj, double *doublePtr); diff --git a/generic/tkScrollbar.c b/generic/tkScrollbar.c index 2d91db6..7fc4675 100644 --- a/generic/tkScrollbar.c +++ b/generic/tkScrollbar.c @@ -101,16 +101,16 @@ static const Tk_ConfigSpec configSpecs[] = { */ static int ConfigureScrollbar(Tcl_Interp *interp, - TkScrollbar *scrollPtr, int argc, - const char **argv, int flags); + TkScrollbar *scrollPtr, int objc, + Tcl_Obj *const objv[], int flags); static void ScrollbarCmdDeletedProc(ClientData clientData); -static int ScrollbarWidgetCmd(ClientData clientData, - Tcl_Interp *, int argc, const char **argv); +static int ScrollbarWidgetObjCmd(ClientData clientData, + Tcl_Interp *, int objc, Tcl_Obj *const objv[]); /* *-------------------------------------------------------------- * - * Tk_ScrollbarCmd -- + * Tk_ScrollbarObjCmd -- * * This function is invoked to process the "scrollbar" Tcl command. See * the user documentation for details on what it does. @@ -125,25 +125,22 @@ static int ScrollbarWidgetCmd(ClientData clientData, */ int -Tk_ScrollbarCmd( +Tk_ScrollbarObjCmd( ClientData clientData, /* Main window associated with interpreter. */ Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - const char **argv) /* Argument strings. */ + int objc, /* Number of arguments. */ + Tcl_Obj *const objv[]) /* Argument strings. */ { Tk_Window tkwin = clientData; register TkScrollbar *scrollPtr; Tk_Window newWin; - if (argc < 2) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "wrong # args: should be \"%s pathName ?-option value ...?\"", - argv[0])); - Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", NULL); + if (objc < 2) { + Tcl_WrongNumArgs(interp, 1, objv, "pathName ?-option value ...?"); return TCL_ERROR; } - newWin = Tk_CreateWindowFromPath(interp, tkwin, argv[1], NULL); + newWin = Tk_CreateWindowFromPath(interp, tkwin, Tcl_GetString(objv[1]), NULL); if (newWin == NULL) { return TCL_ERROR; } @@ -162,8 +159,8 @@ Tk_ScrollbarCmd( scrollPtr->tkwin = newWin; scrollPtr->display = Tk_Display(newWin); scrollPtr->interp = interp; - scrollPtr->widgetCmd = Tcl_CreateCommand(interp, - Tk_PathName(scrollPtr->tkwin), ScrollbarWidgetCmd, + scrollPtr->widgetCmd = Tcl_CreateObjCommand(interp, + Tk_PathName(scrollPtr->tkwin), ScrollbarWidgetObjCmd, scrollPtr, ScrollbarCmdDeletedProc); scrollPtr->vertical = 0; scrollPtr->width = 0; @@ -196,7 +193,7 @@ Tk_ScrollbarCmd( scrollPtr->takeFocus = NULL; scrollPtr->flags = 0; - if (ConfigureScrollbar(interp, scrollPtr, argc-2, argv+2, 0) != TCL_OK) { + if (ConfigureScrollbar(interp, scrollPtr, objc-2, objv+2, 0) != TCL_OK) { Tk_DestroyWindow(scrollPtr->tkwin); return TCL_ERROR; } @@ -208,7 +205,7 @@ Tk_ScrollbarCmd( /* *-------------------------------------------------------------- * - * ScrollbarWidgetCmd -- + * ScrollbarWidgetObjCmd -- * * This function is invoked to process the Tcl command that corresponds * to a widget managed by this module. See the user documentation for @@ -224,30 +221,44 @@ Tk_ScrollbarCmd( */ static int -ScrollbarWidgetCmd( +ScrollbarWidgetObjCmd( ClientData clientData, /* Information about scrollbar widget. */ Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - const char **argv) /* Argument strings. */ + int objc, /* Number of arguments. */ + Tcl_Obj *const objv[]) /* Argument strings. */ { register TkScrollbar *scrollPtr = clientData; int result = TCL_OK; - size_t length; - int c; - - if (argc < 2) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "wrong # args: should be \"%s option ?arg ...?\"", argv[0])); - Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", NULL); + int length, cmdIndex; + static const char *const commandNames[] = { + "activate", "cget", "configure", "delta", "fraction", + "get", "identify", "set", NULL + }; + enum command { + COMMAND_ACTIVATE, COMMAND_CGET, COMMAND_CONFIGURE, COMMAND_DELTA, + COMMAND_FRACTION, COMMAND_GET, COMMAND_IDENTIFY, COMMAND_SET + }; + + if (objc < 2) { + Tcl_WrongNumArgs(interp, 1, objv, "option ?arg ...?"); return TCL_ERROR; } + /* + * Parse the command by looking up the second argument in the list of + * valid subcommand names + */ + + result = Tcl_GetIndexFromObj(interp, objv[1], commandNames, + "option", 0, &cmdIndex); + if (result != TCL_OK) { + return result; + } Tcl_Preserve(scrollPtr); - c = argv[1][0]; - length = strlen(argv[1]); - if ((c == 'a') && (strncmp(argv[1], "activate", length) == 0)) { - int oldActiveField; + switch (cmdIndex) { + case COMMAND_ACTIVATE: { + int oldActiveField, c; - if (argc == 2) { + if (objc == 2) { const char *zone = ""; switch (scrollPtr->activeField) { @@ -258,21 +269,17 @@ ScrollbarWidgetCmd( Tcl_SetObjResult(interp, Tcl_NewStringObj(zone, -1)); goto done; } - if (argc != 3) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "wrong # args: should be \"%s activate element\"", - argv[0])); - Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", NULL); + if (objc != 3) { + Tcl_WrongNumArgs(interp, 1, objv, "activate element"); goto error; } - c = argv[2][0]; - length = strlen(argv[2]); + c = Tcl_GetStringFromObj(objv[2], &length)[0]; oldActiveField = scrollPtr->activeField; - if ((c == 'a') && (strcmp(argv[2], "arrow1") == 0)) { + if ((c == 'a') && (strcmp(Tcl_GetString(objv[2]), "arrow1") == 0)) { scrollPtr->activeField = TOP_ARROW; - } else if ((c == 'a') && (strcmp(argv[2], "arrow2") == 0)) { + } else if ((c == 'a') && (strcmp(Tcl_GetString(objv[2]), "arrow2") == 0)) { scrollPtr->activeField = BOTTOM_ARROW; - } else if ((c == 's') && (strncmp(argv[2], "slider", length) == 0)) { + } else if ((c == 's') && (strncmp(Tcl_GetString(objv[2]), "slider", length) == 0)) { scrollPtr->activeField = SLIDER; } else { scrollPtr->activeField = OUTSIDE; @@ -280,41 +287,40 @@ ScrollbarWidgetCmd( if (oldActiveField != scrollPtr->activeField) { TkScrollbarEventuallyRedraw(scrollPtr); } - } else if ((c == 'c') && (strncmp(argv[1], "cget", length) == 0) - && (length >= 2)) { - if (argc != 3) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "wrong # args: should be \"%s cget option\"", argv[0])); - Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", NULL); + break; + } + case COMMAND_CGET: { + if (objc != 3) { + Tcl_WrongNumArgs(interp, 1, objv, "cget option"); goto error; } result = Tk_ConfigureValue(interp, scrollPtr->tkwin, - configSpecs, (char *) scrollPtr, argv[2], 0); - } else if ((c == 'c') && (strncmp(argv[1], "configure", length) == 0) - && (length >= 2)) { - if (argc == 2) { + configSpecs, (char *) scrollPtr, Tcl_GetString(objv[2]), 0); + break; + } + case COMMAND_CONFIGURE: { + if (objc == 2) { result = Tk_ConfigureInfo(interp, scrollPtr->tkwin, configSpecs, (char *) scrollPtr, NULL, 0); - } else if (argc == 3) { + } else if (objc == 3) { result = Tk_ConfigureInfo(interp, scrollPtr->tkwin, - configSpecs, (char *) scrollPtr, argv[2], 0); + configSpecs, (char *) scrollPtr, Tcl_GetString(objv[2]), 0); } else { - result = ConfigureScrollbar(interp, scrollPtr, argc-2, argv+2, - TK_CONFIG_ARGV_ONLY); + result = ConfigureScrollbar(interp, scrollPtr, objc-2, + objv+2, TK_CONFIG_ARGV_ONLY); } - } else if ((c == 'd') && (strncmp(argv[1], "delta", length) == 0)) { + break; + } + case COMMAND_DELTA: { int xDelta, yDelta, pixels, length; double fraction; - if (argc != 4) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "wrong # args: should be \"%s delta xDelta yDelta\"", - argv[0])); - Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", NULL); + if (objc != 4) { + Tcl_WrongNumArgs(interp, 1, objv, "delta xDelta yDelta"); goto error; } - if ((Tcl_GetInt(interp, argv[2], &xDelta) != TCL_OK) - || (Tcl_GetInt(interp, argv[3], &yDelta) != TCL_OK)) { + if ((Tcl_GetIntFromObj(interp, objv[2], &xDelta) != TCL_OK) + || (Tcl_GetIntFromObj(interp, objv[3], &yDelta) != TCL_OK)) { goto error; } if (scrollPtr->vertical) { @@ -332,18 +338,18 @@ ScrollbarWidgetCmd( fraction = ((double) pixels / (double) length); } Tcl_SetObjResult(interp, Tcl_NewDoubleObj(fraction)); - } else if ((c == 'f') && (strncmp(argv[1], "fraction", length) == 0)) { + break; + } + case COMMAND_FRACTION: { int x, y, pos, length; double fraction; - if (argc != 4) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "wrong # args: should be \"%s fraction x y\"", argv[0])); - Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", NULL); + if (objc != 4) { + Tcl_WrongNumArgs(interp, 1, objv, "fraction x y"); goto error; } - if ((Tcl_GetInt(interp, argv[2], &x) != TCL_OK) - || (Tcl_GetInt(interp, argv[3], &y) != TCL_OK)) { + if ((Tcl_GetIntFromObj(interp, objv[2], &x) != TCL_OK) + || (Tcl_GetIntFromObj(interp, objv[3], &y) != TCL_OK)) { goto error; } if (scrollPtr->vertical) { @@ -366,13 +372,13 @@ ScrollbarWidgetCmd( fraction = 1.0; } Tcl_SetObjResult(interp, Tcl_NewDoubleObj(fraction)); - } else if ((c == 'g') && (strncmp(argv[1], "get", length) == 0)) { + break; + } + case COMMAND_GET: { Tcl_Obj *resObjs[4]; - if (argc != 2) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "wrong # args: should be \"%s get\"", argv[0])); - Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", NULL); + if (objc != 2) { + Tcl_WrongNumArgs(interp, 1, objv, "get"); goto error; } if (scrollPtr->flags & NEW_STYLE_COMMANDS) { @@ -386,18 +392,18 @@ ScrollbarWidgetCmd( resObjs[3] = Tcl_NewIntObj(scrollPtr->lastUnit); Tcl_SetObjResult(interp, Tcl_NewListObj(4, resObjs)); } - } else if ((c == 'i') && (strncmp(argv[1], "identify", length) == 0)) { + break; + } + case COMMAND_IDENTIFY: { int x, y; const char *zone = ""; - if (argc != 4) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "wrong # args: should be \"%s identify x y\"", argv[0])); - Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", NULL); + if (objc != 4) { + Tcl_WrongNumArgs(interp, 1, objv, "identify x y"); goto error; } - if ((Tcl_GetInt(interp, argv[2], &x) != TCL_OK) - || (Tcl_GetInt(interp, argv[3], &y) != TCL_OK)) { + if ((Tcl_GetIntFromObj(interp, objv[2], &x) != TCL_OK) + || (Tcl_GetIntFromObj(interp, objv[3], &y) != TCL_OK)) { goto error; } switch (TkpScrollbarPosition(scrollPtr, x, y)) { @@ -408,16 +414,18 @@ ScrollbarWidgetCmd( case BOTTOM_ARROW: zone = "arrow2"; break; } Tcl_SetObjResult(interp, Tcl_NewStringObj(zone, -1)); - } else if ((c == 's') && (strncmp(argv[1], "set", length) == 0)) { + break; + } + case COMMAND_SET: { int totalUnits, windowUnits, firstUnit, lastUnit; - if (argc == 4) { + if (objc == 4) { double first, last; - if (Tcl_GetDouble(interp, argv[2], &first) != TCL_OK) { + if (Tcl_GetDoubleFromObj(interp, objv[2], &first) != TCL_OK) { goto error; } - if (Tcl_GetDouble(interp, argv[3], &last) != TCL_OK) { + if (Tcl_GetDoubleFromObj(interp, objv[3], &last) != TCL_OK) { goto error; } if (first < 0) { @@ -435,23 +443,23 @@ ScrollbarWidgetCmd( scrollPtr->lastFraction = last; } scrollPtr->flags |= NEW_STYLE_COMMANDS; - } else if (argc == 6) { - if (Tcl_GetInt(interp, argv[2], &totalUnits) != TCL_OK) { + } else if (objc == 6) { + if (Tcl_GetIntFromObj(interp, objv[2], &totalUnits) != TCL_OK) { goto error; } if (totalUnits < 0) { totalUnits = 0; } - if (Tcl_GetInt(interp, argv[3], &windowUnits) != TCL_OK) { + if (Tcl_GetIntFromObj(interp, objv[3], &windowUnits) != TCL_OK) { goto error; } if (windowUnits < 0) { windowUnits = 0; } - if (Tcl_GetInt(interp, argv[4], &firstUnit) != TCL_OK) { + if (Tcl_GetIntFromObj(interp, objv[4], &firstUnit) != TCL_OK) { goto error; } - if (Tcl_GetInt(interp, argv[5], &lastUnit) != TCL_OK) { + if (Tcl_GetIntFromObj(interp, objv[5], &lastUnit) != TCL_OK) { goto error; } if (totalUnits > 0) { @@ -474,23 +482,15 @@ ScrollbarWidgetCmd( } scrollPtr->flags &= ~NEW_STYLE_COMMANDS; } else { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "wrong # args: should be " - "\"%s set firstFraction lastFraction\" or " - "\"%s set totalUnits windowUnits firstUnit lastUnit\"", - argv[0], argv[0])); - Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", NULL); + Tcl_WrongNumArgs(interp, 1, objv, "set firstFraction lastFraction"); + Tcl_AppendResult(interp, " or \"", Tcl_GetString(objv[0]), + " set totalUnits windowUnits firstUnit lastUnit\"", NULL); goto error; } TkpComputeScrollbarGeometry(scrollPtr); TkScrollbarEventuallyRedraw(scrollPtr); - } else { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "bad option \"%s\": must be activate, cget, configure," - " delta, fraction, get, identify, or set", argv[1])); - Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "INDEX", "option", - argv[1], NULL); - goto error; + break; + } } done: @@ -528,12 +528,12 @@ ConfigureScrollbar( register TkScrollbar *scrollPtr, /* Information about widget; may or may not * already have values for some fields. */ - int argc, /* Number of valid entries in argv. */ - const char **argv, /* Arguments. */ + int objc, /* Number of valid entries in argv. */ + Tcl_Obj *const objv[], /* Arguments. */ int flags) /* Flags to pass to Tk_ConfigureWidget. */ { - if (Tk_ConfigureWidget(interp, scrollPtr->tkwin, configSpecs, - argc, argv, (char *) scrollPtr, flags) != TCL_OK) { + if (Tk_ConfigureWidget(interp, scrollPtr->tkwin, configSpecs, objc, + (const char **)objv, (char *) scrollPtr, flags|TK_CONFIG_OBJS) != TCL_OK) { return TCL_ERROR; } diff --git a/generic/tkWindow.c b/generic/tkWindow.c index 53b368c..b5cbbab 100644 --- a/generic/tkWindow.c +++ b/generic/tkWindow.c @@ -97,9 +97,8 @@ static const XSetWindowAttributes defAtts= { #define ISSAFE 1 #define PASSMAINWINDOW 2 -#define NOOBJPROC 4 -#define WINMACONLY 8 -#define USEINITPROC 16 +#define WINMACONLY 4 +#define USEINITPROC 8 typedef int (TkInitProc)(Tcl_Interp *interp, ClientData clientData); typedef struct { @@ -155,8 +154,7 @@ static const TkCmd commands[] = { {"panedwindow", Tk_PanedWindowObjCmd, ISSAFE}, {"radiobutton", Tk_RadiobuttonObjCmd, ISSAFE}, {"scale", Tk_ScaleObjCmd, ISSAFE}, - {"scrollbar", (Tcl_ObjCmdProc *) Tk_ScrollbarCmd, - NOOBJPROC|PASSMAINWINDOW|ISSAFE}, + {"scrollbar", Tk_ScrollbarObjCmd, PASSMAINWINDOW|ISSAFE}, {"spinbox", Tk_SpinboxObjCmd, ISSAFE}, {"text", Tk_TextObjCmd, PASSMAINWINDOW|ISSAFE}, {"toplevel", Tk_ToplevelObjCmd, 0}, @@ -178,8 +176,7 @@ static const TkCmd commands[] = { {"::tk::panedwindow",Tk_PanedWindowObjCmd, ISSAFE}, {"::tk::radiobutton",Tk_RadiobuttonObjCmd, ISSAFE}, {"::tk::scale", Tk_ScaleObjCmd, ISSAFE}, - {"::tk::scrollbar", (Tcl_ObjCmdProc *) Tk_ScrollbarCmd, - NOOBJPROC|PASSMAINWINDOW|ISSAFE}, + {"::tk::scrollbar", Tk_ScrollbarObjCmd, PASSMAINWINDOW|ISSAFE}, {"::tk::spinbox", Tk_SpinboxObjCmd, ISSAFE}, {"::tk::text", Tk_TextObjCmd, PASSMAINWINDOW|ISSAFE}, {"::tk::toplevel", Tk_ToplevelObjCmd, 0}, @@ -976,9 +973,6 @@ TkCreateMainWindow( } if (cmdPtr->flags & USEINITPROC) { ((TkInitProc *) cmdPtr->objProc)(interp, clientData); - } else if (cmdPtr->flags & NOOBJPROC) { - Tcl_CreateCommand(interp, cmdPtr->name, - (Tcl_CmdProc *) cmdPtr->objProc, clientData, NULL); } else { Tcl_CreateObjCommand(interp, cmdPtr->name, cmdPtr->objProc, clientData, NULL); @@ -1543,11 +1537,11 @@ Tk_DestroyWindow( if ((winPtr->mainPtr->interp != NULL) && !Tcl_InterpDeleted(winPtr->mainPtr->interp)) { for (cmdPtr = commands; cmdPtr->name != NULL; cmdPtr++) { - Tcl_CreateCommand(winPtr->mainPtr->interp, cmdPtr->name, - TkDeadAppCmd, NULL, NULL); + Tcl_CreateObjCommand(winPtr->mainPtr->interp, cmdPtr->name, + TkDeadAppObjCmd, NULL, NULL); } - Tcl_CreateCommand(winPtr->mainPtr->interp, "send", - TkDeadAppCmd, NULL, NULL); + Tcl_CreateObjCommand(winPtr->mainPtr->interp, "send", + TkDeadAppObjCmd, NULL, NULL); Tcl_UnlinkVar(winPtr->mainPtr->interp, "tk_strictMotif"); Tcl_UnlinkVar(winPtr->mainPtr->interp, "::tk::AlwaysShowSelection"); diff --git a/tests/scrollbar.test b/tests/scrollbar.test index 3addd28..c6a5a90 100644 --- a/tests/scrollbar.test +++ b/tests/scrollbar.test @@ -405,7 +405,7 @@ test scrollbar-3.73 {ScrollbarWidgetCmd procedure} { } {1 {bad option "bogus": must be activate, cget, configure, delta, fraction, get, identify, or set}} test scrollbar-3.74 {ScrollbarWidgetCmd procedure} { list [catch {.s c} msg] $msg -} {1 {bad option "c": must be activate, cget, configure, delta, fraction, get, identify, or set}} +} {1 {ambiguous option "c": must be activate, cget, configure, delta, fraction, get, identify, or set}} test scrollbar-4.1 {ScrollbarEventProc procedure} { catch {destroy .s1} -- cgit v0.12 From fb2df9548f0580531d0597a2dd62d93f17104cec Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 22 May 2014 15:45:38 +0000 Subject: Some more places where Tcl_Obj's can be used --- generic/tkText.c | 6 +----- generic/tkTextMark.c | 24 ++++++++++++++++-------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/generic/tkText.c b/generic/tkText.c index 2c7eec3..9c436c6 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -6675,11 +6675,7 @@ TkpTesttextCmd( if (Tcl_GetCommandInfo(interp, argv[1], &info) == 0) { return TCL_ERROR; } - if (info.isNativeObjectProc) { - textPtr = info.objClientData; - } else { - textPtr = info.clientData; - } + textPtr = info.objClientData; len = strlen(argv[2]); if (strncmp(argv[2], "byteindex", len) == 0) { if (argc != 5) { diff --git a/generic/tkTextMark.c b/generic/tkTextMark.c index 56a21f9..4cfa0ea 100644 --- a/generic/tkTextMark.c +++ b/generic/tkTextMark.c @@ -40,9 +40,9 @@ static int MarkLayoutProc(TkText *textPtr, TkTextIndex *indexPtr, int maxChars, int noCharsYet, TkWrapMode wrapMode, TkTextDispChunk *chunkPtr); static int MarkFindNext(Tcl_Interp *interp, - TkText *textPtr, const char *markName); + TkText *textPtr, Tcl_Obj *markName); static int MarkFindPrev(Tcl_Interp *interp, - TkText *textPtr, const char *markName); + TkText *textPtr, Tcl_Obj *markName); /* @@ -205,13 +205,13 @@ TkTextMarkCmd( Tcl_WrongNumArgs(interp, 3, objv, "index"); return TCL_ERROR; } - return MarkFindNext(interp, textPtr, Tcl_GetString(objv[3])); + return MarkFindNext(interp, textPtr, objv[3]); case MARK_PREVIOUS: if (objc != 4) { Tcl_WrongNumArgs(interp, 3, objv, "index"); return TCL_ERROR; } - return MarkFindPrev(interp, textPtr, Tcl_GetString(objv[3])); + return MarkFindPrev(interp, textPtr, objv[3]); case MARK_SET: if (objc != 5) { Tcl_WrongNumArgs(interp, 3, objv, "markName index"); @@ -805,12 +805,13 @@ static int MarkFindNext( Tcl_Interp *interp, /* For error reporting */ TkText *textPtr, /* The widget */ - const char *string) /* The starting index or mark name */ + Tcl_Obj *obj) /* The starting index or mark name */ { TkTextIndex index; Tcl_HashEntry *hPtr; register TkTextSegment *segPtr; int offset; + const char *string = Tcl_GetString(obj); if (!strcmp(string, "insert")) { segPtr = textPtr->insertMarkPtr; @@ -837,10 +838,13 @@ MarkFindNext( * For non-mark name indices we want to return any marks that are * right at the index. */ + const TkTextIndex *indexFromPtr; - if (TkTextGetIndex(interp, textPtr, string, &index) != TCL_OK) { + indexFromPtr = TkTextGetIndexFromObj(interp, textPtr, obj); + if (indexFromPtr == NULL) { return TCL_ERROR; } + memcpy(&index, indexFromPtr, sizeof(TkTextIndex)); for (offset = 0, segPtr = index.linePtr->segPtr; segPtr != NULL && offset < index.byteIndex; offset += segPtr->size, segPtr = segPtr->nextPtr) { @@ -895,12 +899,13 @@ static int MarkFindPrev( Tcl_Interp *interp, /* For error reporting */ TkText *textPtr, /* The widget */ - const char *string) /* The starting index or mark name */ + Tcl_Obj *obj) /* The starting index or mark name */ { TkTextIndex index; Tcl_HashEntry *hPtr; register TkTextSegment *segPtr, *seg2Ptr, *prevPtr; int offset; + const char *string = Tcl_GetString(obj); if (!strcmp(string, "insert")) { segPtr = textPtr->insertMarkPtr; @@ -924,10 +929,13 @@ MarkFindPrev( * For non-mark name indices we do not return any marks that are * right at the index. */ + const TkTextIndex *indexFromPtr; - if (TkTextGetIndex(interp, textPtr, string, &index) != TCL_OK) { + indexFromPtr = TkTextGetIndexFromObj(interp, textPtr, obj); + if (indexFromPtr == NULL) { return TCL_ERROR; } + memcpy(&index, indexFromPtr, sizeof(TkTextIndex)); for (offset = 0, segPtr = index.linePtr->segPtr; segPtr != NULL && offset < index.byteIndex; offset += segPtr->size, segPtr = segPtr->nextPtr) { -- cgit v0.12 From e50bfa3ef78703fbb073cc1fc61327a7f9f5f822 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 22 May 2014 20:49:22 +0000 Subject: remove TODO: scrollbars use Tcl_Obj API now --- generic/tkScrollbar.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/generic/tkScrollbar.c b/generic/tkScrollbar.c index 7fc4675..d453187 100644 --- a/generic/tkScrollbar.c +++ b/generic/tkScrollbar.c @@ -12,10 +12,6 @@ * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ -/* - * TODO: Convert scrollbars to the Tcl_Obj API. - */ - #include "tkInt.h" #include "tkScrollbar.h" #include "default.h" -- cgit v0.12 From 410808031e49d239bceedf4f48d8a52d2350bdcf Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 23 May 2014 13:12:38 +0000 Subject: Make "send" (and "testsend") use the Tcl_Obj API. --- generic/tkInt.decls | 8 +-- generic/tkInt.h | 5 +- generic/tkIntPlatDecls.h | 12 ++--- generic/tkTest.c | 2 +- tests/constraints.tcl | 1 - tests/send.test | 3 +- unix/tkUnixSend.c | 124 +++++++++++++++++++++++------------------------ 7 files changed, 78 insertions(+), 77 deletions(-) diff --git a/generic/tkInt.decls b/generic/tkInt.decls index 2ee9d1c..19d5c29 100644 --- a/generic/tkInt.decls +++ b/generic/tkInt.decls @@ -684,8 +684,8 @@ declare 12 x11 { } # only needed by tktest: declare 13 x11 { - int TkpTestsendCmd(ClientData clientData, Tcl_Interp *interp, int argc, - const char **argv) + int TkpTestsendCmd(ClientData clientData, Tcl_Interp *interp, int objc, + Tcl_Obj *const objv[]) } ################################ @@ -841,8 +841,8 @@ declare 44 win { } # only needed by tktest: declare 45 win { - int TkpTestsendCmd(ClientData clientData, Tcl_Interp *interp, int argc, - const char **argv) + int TkpTestsendCmd(ClientData clientData, Tcl_Interp *interp, int objc, + Tcl_Obj *const objv[]) } ################################ diff --git a/generic/tkInt.h b/generic/tkInt.h index 7279096..b644c5b 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -1116,8 +1116,9 @@ MODULE_SCOPE int Tk_ScrollbarObjCmd(ClientData clientData, MODULE_SCOPE int Tk_SelectionObjCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); -MODULE_SCOPE int Tk_SendCmd(ClientData clientData, - Tcl_Interp *interp, int argc, const char **argv); +MODULE_SCOPE int Tk_SendObjCmd(ClientData clientData, + Tcl_Interp *interp,int objc, + Tcl_Obj *const objv[]); MODULE_SCOPE int Tk_SendObjCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); diff --git a/generic/tkIntPlatDecls.h b/generic/tkIntPlatDecls.h index 2fd66c6..15ed775 100644 --- a/generic/tkIntPlatDecls.h +++ b/generic/tkIntPlatDecls.h @@ -140,8 +140,8 @@ EXTERN void TkWmCleanup(TkDisplay *dispPtr); EXTERN void TkSendCleanup(TkDisplay *dispPtr); /* 45 */ EXTERN int TkpTestsendCmd(ClientData clientData, - Tcl_Interp *interp, int argc, - const char **argv); + Tcl_Interp *interp, int objc, + Tcl_Obj *const objv[]); #endif /* WIN */ #ifdef MAC_OSX_TK /* AQUA */ /* 0 */ @@ -283,8 +283,8 @@ EXTERN void TkSendCleanup(TkDisplay *dispPtr); EXTERN int TkpWmSetState(TkWindow *winPtr, int state); /* 13 */ EXTERN int TkpTestsendCmd(ClientData clientData, - Tcl_Interp *interp, int argc, - const char **argv); + Tcl_Interp *interp, int objc, + Tcl_Obj *const objv[]); #endif /* X11 */ typedef struct TkIntPlatStubs { @@ -337,7 +337,7 @@ typedef struct TkIntPlatStubs { void (*tkUnixSetMenubar) (Tk_Window tkwin, Tk_Window menubar); /* 42 */ void (*tkWmCleanup) (TkDisplay *dispPtr); /* 43 */ void (*tkSendCleanup) (TkDisplay *dispPtr); /* 44 */ - int (*tkpTestsendCmd) (ClientData clientData, Tcl_Interp *interp, int argc, const char **argv); /* 45 */ + int (*tkpTestsendCmd) (ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); /* 45 */ #endif /* WIN */ #ifdef MAC_OSX_TK /* AQUA */ void (*tkGenerateActivateEvents) (TkWindow *winPtr, int active); /* 0 */ @@ -410,7 +410,7 @@ typedef struct TkIntPlatStubs { void (*tkSendCleanup) (TkDisplay *dispPtr); /* 10 */ void (*reserved11)(void); int (*tkpWmSetState) (TkWindow *winPtr, int state); /* 12 */ - int (*tkpTestsendCmd) (ClientData clientData, Tcl_Interp *interp, int argc, const char **argv); /* 13 */ + int (*tkpTestsendCmd) (ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); /* 13 */ #endif /* X11 */ } TkIntPlatStubs; diff --git a/generic/tkTest.c b/generic/tkTest.c index 562b2c8..7a4220c 100644 --- a/generic/tkTest.c +++ b/generic/tkTest.c @@ -265,7 +265,7 @@ Tktest_Init( #elif !defined(__CYGWIN__) Tcl_CreateCommand(interp, "testmenubar", TestmenubarCmd, (ClientData) Tk_MainWindow(interp), NULL); - Tcl_CreateCommand(interp, "testsend", TkpTestsendCmd, + Tcl_CreateObjCommand(interp, "testsend", TkpTestsendCmd, (ClientData) Tk_MainWindow(interp), NULL); Tcl_CreateCommand(interp, "testwrapper", TestwrapperCmd, (ClientData) Tk_MainWindow(interp), NULL); diff --git a/tests/constraints.tcl b/tests/constraints.tcl index e28b159..535d839 100644 --- a/tests/constraints.tcl +++ b/tests/constraints.tcl @@ -207,7 +207,6 @@ testConstraint testembed [llength [info commands testembed]] testConstraint testfont [llength [info commands testfont]] testConstraint testmakeexist [llength [info commands testmakeexist]] testConstraint testmenubar [llength [info commands testmenubar]] -testConstraint testmenubar [llength [info commands testmenubar]] testConstraint testmetrics [llength [info commands testmetrics]] testConstraint testobjconfig [llength [info commands testobjconfig]] testConstraint testsend [llength [info commands testsend]] diff --git a/tests/send.test b/tests/send.test index e3156a1..2a564bd 100644 --- a/tests/send.test +++ b/tests/send.test @@ -14,6 +14,7 @@ package require tcltest 2.1 eval tcltest::configure $argv tcltest::loadTestedCommands +testConstraint secureserver 1 testConstraint xhost [llength [auto_execok xhost]] # Compute a script that will load Tk into a child interpreter. @@ -227,7 +228,7 @@ test send-8.3 {Tk_SendCmd procedure, options} {secureserver} { } {1 {no application named "-async"}} test send-8.4 {Tk_SendCmd procedure, options} {secureserver} { list [catch {send -gorp foo bar baz} msg] $msg -} {1 {bad option "-gorp": must be -async, -displayof, or --}} +} {1 {no application named "-gorp"}} test send-8.5 {Tk_SendCmd procedure, options} {secureserver} { list [catch {send -async foo} msg] $msg } {1 {wrong # args: should be "send ?-option value ...? interpName arg ?arg ...?"}} diff --git a/unix/tkUnixSend.c b/unix/tkUnixSend.c index 53a2196..3f97e91 100644 --- a/unix/tkUnixSend.c +++ b/unix/tkUnixSend.c @@ -823,7 +823,7 @@ Tk_SetAppName( riPtr->nextPtr = tsdPtr->interpListPtr; tsdPtr->interpListPtr = riPtr; riPtr->name = NULL; - Tcl_CreateCommand(interp, "send", Tk_SendCmd, riPtr, DeleteProc); + Tcl_CreateObjCommand(interp, "send", Tk_SendObjCmd, riPtr, DeleteProc); if (Tcl_IsSafe(interp)) { Tcl_HideCommand(interp, "send", "send"); } @@ -914,7 +914,7 @@ Tk_SetAppName( /* *-------------------------------------------------------------- * - * Tk_SendCmd -- + * Tk_SendObjCmd -- * * This function is invoked to process the "send" Tcl command. See the * user documentation for details on what it does. @@ -929,20 +929,25 @@ Tk_SetAppName( */ int -Tk_SendCmd( +Tk_SendObjCmd( ClientData clientData, /* Information about sender (only dispPtr * field is used). */ Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - const char **argv) /* Argument strings. */ + int objc, /* Number of arguments. */ + Tcl_Obj *const objv[]) /* Argument strings. */ { + enum { + SEND_ASYNC, SEND_DISPLAYOF, SEND_LAST + }; + static const char *const sendOptions[] = { + "-async", "-displayof", "--", NULL + }; TkWindow *winPtr; Window commWindow; PendingCommand pending; register RegisteredInterp *riPtr; const char *destName; - int result, c, async, i, firstArg; - size_t length; + int result, index, async, i, firstArg; Tk_RestrictProc *prevProc; ClientData prevArg; TkDisplay *dispPtr; @@ -963,43 +968,31 @@ Tk_SendCmd( if (winPtr == NULL) { return TCL_ERROR; } - for (i = 1; i < (argc-1); ) { - if (argv[i][0] != '-') { + for (i = 1; i < objc; i++) { + if (Tcl_GetIndexFromObjStruct(interp, objv[i], sendOptions, + sizeof(char *), "option", 0, &index) != TCL_OK) { break; } - c = argv[i][1]; - length = strlen(argv[i]); - if ((c == 'a') && (strncmp(argv[i], "-async", length) == 0)) { - async = 1; - i++; - } else if ((c == 'd') && (strncmp(argv[i], "-displayof", - length) == 0)) { - winPtr = (TkWindow *) Tk_NameToWindow(interp, argv[i+1], + if (index == SEND_ASYNC) { + ++async; + } else if (index == SEND_DISPLAYOF) { + winPtr = (TkWindow *) Tk_NameToWindow(interp, Tcl_GetString(objv[++i]), (Tk_Window) winPtr); if (winPtr == NULL) { return TCL_ERROR; } - i += 2; - } else if (strcmp(argv[i], "--") == 0) { + } else if (index == SEND_LAST) { i++; break; - } else { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "bad option \"%s\": must be -async, -displayof, or --", - argv[i])); - Tcl_SetErrorCode(interp, "TK", "SEND", "OPTION", NULL); - return TCL_ERROR; } } - if (argc < (i+2)) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf("wrong # args: should be " - "\"%s ?-option value ...? interpName arg ?arg ...?\"", - argv[0])); - Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", NULL); + if (objc < (i+2)) { + Tcl_WrongNumArgs(interp, 1, objv, + "?-option value ...? interpName arg ?arg ...?"); return TCL_ERROR; } - destName = argv[i]; + destName = Tcl_GetString(objv[i]); firstArg = i+1; dispPtr = winPtr->dispPtr; @@ -1023,14 +1016,14 @@ Tk_SendCmd( Tcl_Preserve(riPtr); localInterp = riPtr->interp; Tcl_Preserve(localInterp); - if (firstArg == (argc-1)) { - result = Tcl_EvalEx(localInterp, argv[firstArg], -1, TCL_EVAL_GLOBAL); + if (firstArg == (objc-1)) { + result = Tcl_EvalObjEx(localInterp, objv[firstArg], TCL_EVAL_GLOBAL); } else { Tcl_DStringInit(&request); - Tcl_DStringAppend(&request, argv[firstArg], -1); - for (i = firstArg+1; i < argc; i++) { + Tcl_DStringAppend(&request, Tcl_GetString(objv[firstArg]), -1); + for (i = firstArg+1; i < objc; i++) { Tcl_DStringAppend(&request, " ", 1); - Tcl_DStringAppend(&request, argv[i], -1); + Tcl_DStringAppend(&request, Tcl_GetString(objv[i]), -1); } result = Tcl_EvalEx(localInterp, Tcl_DStringValue(&request), -1, TCL_EVAL_GLOBAL); Tcl_DStringFree(&request); @@ -1097,10 +1090,10 @@ Tk_SendCmd( Tcl_DStringAppend(&request, buffer, -1); } Tcl_DStringAppend(&request, "\0-s ", 4); - Tcl_DStringAppend(&request, argv[firstArg], -1); - for (i = firstArg+1; i < argc; i++) { + Tcl_DStringAppend(&request, Tcl_GetString(objv[firstArg]), -1); + for (i = firstArg+1; i < objc; i++) { Tcl_DStringAppend(&request, " ", 1); - Tcl_DStringAppend(&request, argv[i], -1); + Tcl_DStringAppend(&request, Tcl_GetString(objv[i]), -1); } (void) AppendPropCarefully(dispPtr->display, commWindow, dispPtr->commProperty, Tcl_DStringValue(&request), @@ -1948,44 +1941,55 @@ int TkpTestsendCmd( ClientData clientData, /* Main window for application. */ Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - const char **argv) /* Argument strings. */ + int objc, /* Number of arguments. */ + Tcl_Obj *const objv[]) /* Argument strings. */ { + enum { + TESTSEND_BOGUS, TESTSEND_PROP, TESTSEND_SERIAL + }; + static const char *const testsendOptions[] = { + "bogus", "prop", "serial", NULL + }; TkWindow *winPtr = clientData; + int index; - if (argc < 2) { - Tcl_AppendResult(interp, "wrong # args; must be \"", argv[0], - " option ?arg ...?\"", NULL); + if (objc < 2) { + Tcl_WrongNumArgs(interp, 1, objv, + "option ?arg ...?"); return TCL_ERROR; } - if (strcmp(argv[1], "bogus") == 0) { + if (Tcl_GetIndexFromObjStruct(interp, objv[1], testsendOptions, + sizeof(char *), "option", 0, &index) != TCL_OK) { + return TCL_ERROR; + } + if (index == TESTSEND_BOGUS) { XChangeProperty(winPtr->dispPtr->display, RootWindow(winPtr->dispPtr->display, 0), winPtr->dispPtr->registryProperty, XA_INTEGER, 32, PropModeReplace, (unsigned char *) "This is bogus information", 6); - } else if (strcmp(argv[1], "prop") == 0) { + } else if (index == TESTSEND_PROP) { int result, actualFormat; unsigned long length, bytesAfter; Atom actualType, propName; char *property, **propertyPtr = &property, *p, *end; Window w; - if ((argc != 4) && (argc != 5)) { - Tcl_AppendResult(interp, "wrong # args; must be \"", argv[0], - " prop window name ?value ?\"", NULL); + if ((objc != 4) && (objc != 5)) { + Tcl_WrongNumArgs(interp, 1, objv, + "prop window name ?value ?"); return TCL_ERROR; } - if (strcmp(argv[2], "root") == 0) { + if (strcmp(Tcl_GetString(objv[2]), "root") == 0) { w = RootWindow(winPtr->dispPtr->display, 0); - } else if (strcmp(argv[2], "comm") == 0) { + } else if (strcmp(Tcl_GetString(objv[2]), "comm") == 0) { w = Tk_WindowId(winPtr->dispPtr->commTkwin); } else { - w = strtoul(argv[2], &end, 0); + w = strtoul(Tcl_GetString(objv[2]), &end, 0); } - propName = Tk_InternAtom((Tk_Window) winPtr, argv[3]); - if (argc == 4) { + propName = Tk_InternAtom((Tk_Window) winPtr, Tcl_GetString(objv[3])); + if (objc == 4) { property = NULL; result = XGetWindowProperty(winPtr->dispPtr->display, w, propName, 0, 100000, False, XA_STRING, &actualType, &actualFormat, @@ -2002,14 +2006,14 @@ TkpTestsendCmd( if (property != NULL) { XFree(property); } - } else if (argv[4][0] == 0) { + } else if (Tcl_GetString(objv[4])[0] == 0) { XDeleteProperty(winPtr->dispPtr->display, w, propName); } else { Tcl_DString tmp; Tcl_DStringInit(&tmp); - for (p = Tcl_DStringAppend(&tmp, argv[4], - (int) strlen(argv[4])); *p != 0; p++) { + for (p = Tcl_DStringAppend(&tmp, Tcl_GetString(objv[4]), + (int) strlen(Tcl_GetString(objv[4]))); *p != 0; p++) { if (*p == '\n') { *p = 0; } @@ -2020,12 +2024,8 @@ TkpTestsendCmd( p-Tcl_DStringValue(&tmp)); Tcl_DStringFree(&tmp); } - } else if (strcmp(argv[1], "serial") == 0) { + } else if (index == TESTSEND_SERIAL) { Tcl_SetObjResult(interp, Tcl_NewIntObj(localData.sendSerial+1)); - } else { - Tcl_AppendResult(interp, "bad option \"", argv[1], - "\": must be bogus, prop, or serial", NULL); - return TCL_ERROR; } return TCL_OK; } -- cgit v0.12 From a8ef8cc3e5d42c9f2c1be32d8cd9de92b0d80012 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sat, 24 May 2014 06:11:50 +0000 Subject: make test-case send-8.15 pass (is this the right way?) --- tests/send.test | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/send.test b/tests/send.test index 2a564bd..0d539da 100644 --- a/tests/send.test +++ b/tests/send.test @@ -292,8 +292,6 @@ test send-8.15 {Tk_SendCmd procedure, local interp, error info} {secureserver te while executing "open bogus_file_name" invoked from within -"if 1 {open bogus_file_name}" - invoked from within "send t_s_1 {if 1 {open bogus_file_name}}"} {POSIX ENOENT {no such file or directory}}} test send-8.16 {Tk_SendCmd procedure, bogusCommWindow} {secureserver testsend} { testsend prop root InterpRegistry "10234 bogus\n" -- cgit v0.12 From ff98b3b125c4a9b171f4e810c4724bd5f80dad26 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 26 May 2014 14:31:03 +0000 Subject: Convert "testwinevent", "testmetrics" and "testdeleteapps" for using the Tcl_Obj API. --- generic/tkTest.c | 48 ++++++++++++++++++++++----------------------- win/tkWinTest.c | 59 ++++++++++++++++++++++++-------------------------------- 2 files changed, 49 insertions(+), 58 deletions(-) diff --git a/generic/tkTest.c b/generic/tkTest.c index 562b2c8..b7621c7 100644 --- a/generic/tkTest.c +++ b/generic/tkTest.c @@ -153,8 +153,9 @@ static int TestcolorObjCmd(ClientData dummy, static int TestcursorObjCmd(ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[]); -static int TestdeleteappsCmd(ClientData dummy, - Tcl_Interp *interp, int argc, const char **argv); +static int TestdeleteappsObjCmd(ClientData dummy, + Tcl_Interp *interp, int objc, + Tcl_Obj * const objv[]); static int TestfontObjCmd(ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); @@ -165,8 +166,9 @@ static int TestmenubarCmd(ClientData dummy, Tcl_Interp *interp, int argc, const char **argv); #endif #if defined(_WIN32) || defined(MAC_OSX_TK) -static int TestmetricsCmd(ClientData dummy, - Tcl_Interp *interp, int argc, const char **argv); +static int TestmetricsObjCmd(ClientData dummy, + Tcl_Interp *interp, int objc, + Tcl_Obj * const objv[]); #endif static int TestobjconfigObjCmd(ClientData dummy, Tcl_Interp *interp, int objc, @@ -244,7 +246,7 @@ Tktest_Init( (ClientData) Tk_MainWindow(interp), NULL); Tcl_CreateObjCommand(interp, "testcursor", TestcursorObjCmd, (ClientData) Tk_MainWindow(interp), NULL); - Tcl_CreateCommand(interp, "testdeleteapps", TestdeleteappsCmd, + Tcl_CreateObjCommand(interp, "testdeleteapps", TestdeleteappsObjCmd, (ClientData) Tk_MainWindow(interp), NULL); Tcl_CreateCommand(interp, "testembed", TkpTestembedCmd, (ClientData) Tk_MainWindow(interp), NULL); @@ -260,7 +262,7 @@ Tktest_Init( (ClientData) Tk_MainWindow(interp), NULL); #if defined(_WIN32) || defined(MAC_OSX_TK) - Tcl_CreateCommand(interp, "testmetrics", TestmetricsCmd, + Tcl_CreateObjCommand(interp, "testmetrics", TestmetricsObjCmd, (ClientData) Tk_MainWindow(interp), NULL); #elif !defined(__CYGWIN__) Tcl_CreateCommand(interp, "testmenubar", TestmenubarCmd, @@ -436,7 +438,7 @@ TestcursorObjCmd( /* *---------------------------------------------------------------------- * - * TestdeleteappsCmd -- + * TestdeleteappsObjCmd -- * * This function implements the "testdeleteapps" command. It cleans up * all the interpreters left behind by the "testnewapp" command. @@ -453,11 +455,11 @@ TestcursorObjCmd( /* ARGSUSED */ static int -TestdeleteappsCmd( +TestdeleteappsObjCmd( ClientData clientData, /* Main window for application. */ Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - const char **argv) /* Argument strings. */ + int objc, /* Number of arguments. */ + Tcl_Obj *const objv[]) /* Argument strings. */ { NewApp *nextPtr; @@ -1747,7 +1749,7 @@ TestmenubarCmd( /* *---------------------------------------------------------------------- * - * TestmetricsCmd -- + * TestmetricsObjCmd -- * * This function implements the testmetrics command. It provides a way to * determine the size of various widget components. @@ -1763,51 +1765,49 @@ TestmenubarCmd( #if defined(_WIN32) || defined(MAC_OSX_TK) static int -TestmetricsCmd( +TestmetricsObjCmd( ClientData clientData, /* Main window for application. */ Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - const char **argv) /* Argument strings. */ + int objc, /* Number of arguments. */ + Tcl_Obj *const objv[]) /* Argument strings. */ { char buf[TCL_INTEGER_SPACE]; int val; #ifdef _WIN32 - if (argc < 2) { - Tcl_AppendResult(interp, "wrong # args; must be \"", argv[0], - " option ?arg ...?\"", NULL); + if (objc < 2) { + Tcl_WrongNumArgs(interp, 1, objv, "option ?arg ...?"); return TCL_ERROR; } #else Tk_Window tkwin = (Tk_Window) clientData; TkWindow *winPtr; - if (argc != 3) { - Tcl_AppendResult(interp, "wrong # args; must be \"", argv[0], - " option window\"", NULL); + if (objc != 3) { + Tcl_WrongNumArgs(interp, 1, objv, "option window"); return TCL_ERROR; } - winPtr = (TkWindow *) Tk_NameToWindow(interp, argv[2], tkwin); + winPtr = (TkWindow *) Tk_NameToWindow(interp, Tcl_GetString(objv[2]), tkwin); if (winPtr == NULL) { return TCL_ERROR; } #endif - if (strcmp(argv[1], "cyvscroll") == 0) { + if (strcmp(Tcl_GetString(objv[1]), "cyvscroll") == 0) { #ifdef _WIN32 val = GetSystemMetrics(SM_CYVSCROLL); #else val = ((TkScrollbar *) winPtr->instanceData)->width; #endif - } else if (strcmp(argv[1], "cxhscroll") == 0) { + } else if (strcmp(Tcl_GetString(objv[1]), "cxhscroll") == 0) { #ifdef _WIN32 val = GetSystemMetrics(SM_CXHSCROLL); #else val = ((TkScrollbar *) winPtr->instanceData)->width; #endif } else { - Tcl_AppendResult(interp, "bad option \"", argv[1], + Tcl_AppendResult(interp, "bad option \"", Tcl_GetString(objv[1]), "\": must be cxhscroll or cyvscroll", NULL); return TCL_ERROR; } diff --git a/win/tkWinTest.c b/win/tkWinTest.c index 6036995..9fa956c 100644 --- a/win/tkWinTest.c +++ b/win/tkWinTest.c @@ -27,8 +27,9 @@ HWND tkWinCurrentDialog; static int TestclipboardObjCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); -static int TestwineventCmd(ClientData clientData, - Tcl_Interp *interp, int argc, const char **argv); +static int TestwineventObjCmd(ClientData clientData, + Tcl_Interp *interp, int objc, + Tcl_Obj *const objv[]); static int TestfindwindowObjCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); @@ -67,7 +68,7 @@ TkplatformtestInit( Tcl_CreateObjCommand(interp, "testclipboard", TestclipboardObjCmd, (ClientData) Tk_MainWindow(interp), NULL); - Tcl_CreateCommand(interp, "testwinevent", TestwineventCmd, + Tcl_CreateObjCommand(interp, "testwinevent", TestwineventObjCmd, (ClientData) Tk_MainWindow(interp), NULL); Tcl_CreateObjCommand(interp, "testfindwindow", TestfindwindowObjCmd, (ClientData) Tk_MainWindow(interp), NULL); @@ -220,7 +221,7 @@ TestclipboardObjCmd( /* *---------------------------------------------------------------------- * - * TestwineventCmd -- + * TestwineventObjCmd -- * * This function implements the testwinevent command. It provides a way * to send messages to windows dialogs. @@ -235,11 +236,11 @@ TestclipboardObjCmd( */ static int -TestwineventCmd( +TestwineventObjCmd( ClientData clientData, /* Main window for application. */ Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - const char **argv) /* Argument strings. */ + int objc, /* Number of arguments. */ + Tcl_Obj *const objv[]) /* Argument strings. */ { HWND hwnd = 0; HWND child = 0; @@ -258,33 +259,23 @@ TestwineventCmd( {-1, NULL} }; - if ((argc == 3) && (strcmp(argv[1], "debug") == 0)) { + if ((objc == 3) && (strcmp(Tcl_GetString(objv[1]), "debug") == 0)) { int b; - if (Tcl_GetBoolean(interp, argv[2], &b) != TCL_OK) { + if (Tcl_GetBoolean(interp, Tcl_GetString(objv[2]), &b) != TCL_OK) { return TCL_ERROR; } TkWinDialogDebug(b); return TCL_OK; } - if (argc < 4) { + if (objc < 4) { return TCL_ERROR; } -#if 0 - TkpScanWindowId(interp, argv[1], &id); - if ( -#ifdef _WIN64 - (sscanf(string, "0x%p", &number) != 1) && -#endif /* _WIN64 */ - Tcl_GetInt(interp, string, (int *)&number) != TCL_OK) { - return TCL_ERROR; - } -#endif - hwnd = INT2PTR(strtol(argv[1], &rest, 0)); - if (rest == argv[1]) { - hwnd = FindWindowA(NULL, argv[1]); + hwnd = INT2PTR(strtol(Tcl_GetString(objv[1]), &rest, 0)); + if (rest == Tcl_GetString(objv[1])) { + hwnd = FindWindowA(NULL, Tcl_GetString(objv[1])); if (hwnd == NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj("no such window", -1)); return TCL_ERROR; @@ -292,14 +283,14 @@ TestwineventCmd( } UpdateWindow(hwnd); - id = strtol(argv[2], &rest, 0); - if (rest == argv[2]) { + id = strtol(Tcl_GetString(objv[2]), &rest, 0); + if (rest == Tcl_GetString(objv[2])) { char buf[256]; child = GetWindow(hwnd, GW_CHILD); while (child != NULL) { SendMessageA(child, WM_GETTEXT, (WPARAM) sizeof(buf), (LPARAM) buf); - if (strcasecmp(buf, argv[2]) == 0) { + if (strcasecmp(buf, Tcl_GetString(objv[2])) == 0) { id = GetDlgCtrlID(child); break; } @@ -307,19 +298,19 @@ TestwineventCmd( } if (child == NULL) { Tcl_AppendResult(interp, "could not find a control matching \"", - argv[2], "\"", NULL); + Tcl_GetString(objv[2]), "\"", NULL); return TCL_ERROR; } } - message = TkFindStateNum(NULL, NULL, messageMap, argv[3]); + message = TkFindStateNum(NULL, NULL, messageMap, Tcl_GetString(objv[3])); wParam = 0; lParam = 0; - if (argc > 4) { - wParam = strtol(argv[4], NULL, 0); + if (objc > 4) { + wParam = strtol(Tcl_GetString(objv[4]), NULL, 0); } - if (argc > 5) { - lParam = strtol(argv[5], NULL, 0); + if (objc > 5) { + lParam = strtol(Tcl_GetString(objv[5]), NULL, 0); } switch (message) { @@ -337,7 +328,7 @@ TestwineventCmd( Tcl_DString ds; BOOL result; - Tcl_UtfToExternalDString(NULL, argv[4], -1, &ds); + Tcl_UtfToExternalDString(NULL, Tcl_GetString(objv[4]), -1, &ds); result = SetDlgItemTextA(hwnd, id, Tcl_DStringValue(&ds)); Tcl_DStringFree(&ds); if (result == 0) { @@ -349,7 +340,7 @@ TestwineventCmd( } case WM_COMMAND: { char buf[TCL_INTEGER_SPACE]; - if (argc < 5) { + if (objc < 5) { wParam = MAKEWPARAM(id, 0); lParam = (LPARAM)child; } -- cgit v0.12 From d962821b84a7745d3cc1a45c6e58e7192d2b764f Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 3 Jun 2014 10:07:22 +0000 Subject: Typo's and unnecessary end-of-line spacing --- win/tkWin.h | 10 +++++----- win/tkWinInt.h | 4 ++-- win/tkWinPort.h | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/win/tkWin.h b/win/tkWin.h index adb943b..4d278d7 100644 --- a/win/tkWin.h +++ b/win/tkWin.h @@ -16,7 +16,7 @@ /* * We must specify the lower version we intend to support. In particular * the SystemParametersInfo API doesn't like to receive structures that - * are larger than it expects which affects the font assignements. + * are larger than it expects which affects the font assignments. * * WINVER = 0x0500 means Windows 2000 and above */ @@ -38,9 +38,9 @@ /* * The following messages are used to communicate between a Tk toplevel - * and its container window. A Tk container may not be able to provide - * service to all of the following requests at the moment. But an embedded - * Tk window will send out these requests to support external Tk container + * and its container window. A Tk container may not be able to provide + * service to all of the following requests at the moment. But an embedded + * Tk window will send out these requests to support external Tk container * application. */ @@ -61,7 +61,7 @@ /* * The following are sub-messages (wParam) for TK_INFO. An embedded window may - * send a TK_INFO message with one of the sub-messages to query a container + * send a TK_INFO message with one of the sub-messages to query a container * for verification and availability */ #define TK_CONTAINER_VERIFY 0x01 diff --git a/win/tkWinInt.h b/win/tkWinInt.h index 580e58f..6a3978f 100644 --- a/win/tkWinInt.h +++ b/win/tkWinInt.h @@ -202,8 +202,8 @@ MODULE_SCOPE int TkpWmGetState(TkWindow *winPtr); /* * The following functions are not present in old versions of Windows - * API headers but are used in the Tk source to ensure 64bit - * compatability. + * API headers but are used in the Tk source to ensure 64bit + * compatibility. */ #ifndef GetClassLongPtr diff --git a/win/tkWinPort.h b/win/tkWinPort.h index 95cad78..9f5fa9c 100644 --- a/win/tkWinPort.h +++ b/win/tkWinPort.h @@ -105,7 +105,7 @@ | ((p)->green & 0xff00) | (((p)->blue << 8) & 0xff0000)) | 0x20000000) /* - * These calls implement native bitmaps which are not currently + * These calls implement native bitmaps which are not currently * supported under Windows. The macros eliminate the calls. */ -- cgit v0.12 From 622180938c63060edf98112f7b99e35b4b2551ad Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 3 Jun 2014 11:08:38 +0000 Subject: Convert TkpTestembedCmd and TkpTesttextCmd to Tcl_Obj-based commands. --- generic/tkInt.decls | 8 ++++---- generic/tkIntDecls.h | 17 +++++++-------- generic/tkTest.c | 49 ++++++++++++++++++++++---------------------- generic/tkText.c | 34 +++++++++++++++--------------- macosx/tkMacOSXEmbed.c | 6 +++--- macosx/tkMacOSXHLEvents.c | 17 +++++++-------- macosx/tkMacOSXMenus.c | 17 ++++++--------- macosx/tkMacOSXTest.c | 14 ++++++------- macosx/tkMacOSXWindowEvent.c | 3 +-- unix/tkUnixEmbed.c | 6 +++--- win/tkWinEmbed.c | 4 ++-- 11 files changed, 84 insertions(+), 91 deletions(-) diff --git a/generic/tkInt.decls b/generic/tkInt.decls index 19d5c29..b9356d2 100644 --- a/generic/tkInt.decls +++ b/generic/tkInt.decls @@ -506,12 +506,12 @@ declare 154 { # entries needed only by tktest: declare 156 { - int TkpTestembedCmd(ClientData clientData, Tcl_Interp *interp, int argc, - const char **argv) + int TkpTestembedCmd(ClientData clientData, Tcl_Interp *interp, int objc, + Tcl_Obj *const objv[]) } declare 157 { - int TkpTesttextCmd(ClientData dummy, Tcl_Interp *interp, int argc, - const char **argv) + int TkpTesttextCmd(ClientData dummy, Tcl_Interp *interp, int objc, + Tcl_Obj *const objv[]) } declare 158 { int TkSelGetSelection(Tcl_Interp *interp, Tk_Window tkwin, diff --git a/generic/tkIntDecls.h b/generic/tkIntDecls.h index 67a4f4b..261d3db 100644 --- a/generic/tkIntDecls.h +++ b/generic/tkIntDecls.h @@ -433,11 +433,12 @@ EXTERN void TkDeleteThreadExitHandler(Tcl_ExitProc *proc, /* Slot 155 is reserved */ /* 156 */ EXTERN int TkpTestembedCmd(ClientData clientData, - Tcl_Interp *interp, int argc, - const char **argv); + Tcl_Interp *interp, int objc, + Tcl_Obj *const objv[]); /* 157 */ -EXTERN int TkpTesttextCmd(ClientData dummy, Tcl_Interp *interp, - int argc, const char **argv); +EXTERN int TkpTesttextCmd(ClientData dummy, + Tcl_Interp *interp, int objc, + Tcl_Obj *const objv[]); /* 158 */ EXTERN int TkSelGetSelection(Tcl_Interp *interp, Tk_Window tkwin, Atom selection, Atom target, @@ -738,8 +739,8 @@ typedef struct TkIntStubs { void (*tkCreateThreadExitHandler) (Tcl_ExitProc *proc, ClientData clientData); /* 153 */ void (*tkDeleteThreadExitHandler) (Tcl_ExitProc *proc, ClientData clientData); /* 154 */ void (*reserved155)(void); - int (*tkpTestembedCmd) (ClientData clientData, Tcl_Interp *interp, int argc, const char **argv); /* 156 */ - int (*tkpTesttextCmd) (ClientData dummy, Tcl_Interp *interp, int argc, const char **argv); /* 157 */ + int (*tkpTestembedObjCmd) (ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); /* 156 */ + int (*tkpTesttextObjCmd) (ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); /* 157 */ int (*tkSelGetSelection) (Tcl_Interp *interp, Tk_Window tkwin, Atom selection, Atom target, Tk_GetSelProc *proc, ClientData clientData); /* 158 */ int (*tkTextGetIndex) (Tcl_Interp *interp, struct TkText *textPtr, const char *string, struct TkTextIndex *indexPtr); /* 159 */ int (*tkTextIndexBackBytes) (const struct TkText *textPtr, const struct TkTextIndex *srcPtr, int count, struct TkTextIndex *dstPtr); /* 160 */ @@ -1082,9 +1083,9 @@ extern const TkIntStubs *tkIntStubsPtr; (tkIntStubsPtr->tkDeleteThreadExitHandler) /* 154 */ /* Slot 155 is reserved */ #define TkpTestembedCmd \ - (tkIntStubsPtr->tkpTestembedCmd) /* 156 */ + (tkIntStubsPtr->tkpTestembedObjCmd) /* 156 */ #define TkpTesttextCmd \ - (tkIntStubsPtr->tkpTesttextCmd) /* 157 */ + (tkIntStubsPtr->tkpTesttextObjCmd) /* 157 */ #define TkSelGetSelection \ (tkIntStubsPtr->tkSelGetSelection) /* 158 */ #define TkTextGetIndex \ diff --git a/generic/tkTest.c b/generic/tkTest.c index db7f470..1514604 100644 --- a/generic/tkTest.c +++ b/generic/tkTest.c @@ -159,8 +159,9 @@ static int TestdeleteappsObjCmd(ClientData dummy, static int TestfontObjCmd(ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); -static int TestmakeexistCmd(ClientData dummy, - Tcl_Interp *interp, int argc, const char **argv); +static int TestmakeexistObjCmd(ClientData dummy, + Tcl_Interp *interp, int objc, + Tcl_Obj *const objv[]); #if !(defined(_WIN32) || defined(MAC_OSX_TK) || defined(__CYGWIN__)) static int TestmenubarCmd(ClientData dummy, Tcl_Interp *interp, int argc, const char **argv); @@ -186,8 +187,9 @@ static void CustomOptionRestore(ClientData clientData, char *saveInternalPtr); static void CustomOptionFree(ClientData clientData, Tk_Window tkwin, char *internalPtr); -static int TestpropCmd(ClientData dummy, - Tcl_Interp *interp, int argc, const char **argv); +static int TestpropObjCmd(ClientData dummy, + Tcl_Interp *interp, int objc, + Tcl_Obj * const objv[]); #if !(defined(_WIN32) || defined(MAC_OSX_TK) || defined(__CYGWIN__)) static int TestwrapperCmd(ClientData dummy, Tcl_Interp *interp, int argc, const char **argv); @@ -233,7 +235,7 @@ Tktest_Init( * Create additional commands for testing Tk. */ - if (Tcl_PkgProvideEx(interp, "Tktest", TK_VERSION, NULL) == TCL_ERROR) { + if (Tcl_PkgProvideEx(interp, "Tktest", TK_PATCH_LEVEL, NULL) == TCL_ERROR) { return TCL_ERROR; } @@ -248,17 +250,17 @@ Tktest_Init( (ClientData) Tk_MainWindow(interp), NULL); Tcl_CreateObjCommand(interp, "testdeleteapps", TestdeleteappsObjCmd, (ClientData) Tk_MainWindow(interp), NULL); - Tcl_CreateCommand(interp, "testembed", TkpTestembedCmd, + Tcl_CreateObjCommand(interp, "testembed", TkpTestembedCmd, (ClientData) Tk_MainWindow(interp), NULL); Tcl_CreateObjCommand(interp, "testobjconfig", TestobjconfigObjCmd, (ClientData) Tk_MainWindow(interp), NULL); Tcl_CreateObjCommand(interp, "testfont", TestfontObjCmd, (ClientData) Tk_MainWindow(interp), NULL); - Tcl_CreateCommand(interp, "testmakeexist", TestmakeexistCmd, + Tcl_CreateObjCommand(interp, "testmakeexist", TestmakeexistObjCmd, (ClientData) Tk_MainWindow(interp), NULL); - Tcl_CreateCommand(interp, "testprop", TestpropCmd, + Tcl_CreateObjCommand(interp, "testprop", TestpropObjCmd, (ClientData) Tk_MainWindow(interp), NULL); - Tcl_CreateCommand(interp, "testtext", TkpTesttextCmd, + Tcl_CreateObjCommand(interp, "testtext", TkpTesttextCmd, (ClientData) Tk_MainWindow(interp), NULL); #if defined(_WIN32) || defined(MAC_OSX_TK) @@ -1638,7 +1640,7 @@ ImageDelete( /* *---------------------------------------------------------------------- * - * TestmakeexistCmd -- + * TestmakeexistObjCmd -- * * This function implements the "testmakeexist" command. It calls * Tk_MakeWindowExist on each of its arguments to force the windows to be @@ -1655,18 +1657,18 @@ ImageDelete( /* ARGSUSED */ static int -TestmakeexistCmd( +TestmakeexistObjCmd( ClientData clientData, /* Main window for application. */ Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - const char **argv) /* Argument strings. */ + int objc, /* Number of arguments. */ + Tcl_Obj *const objv[]) /* Argument strings. */ { Tk_Window mainWin = (Tk_Window) clientData; int i; Tk_Window tkwin; - for (i = 1; i < argc; i++) { - tkwin = Tk_NameToWindow(interp, argv[i], mainWin); + for (i = 1; i < objc; i++) { + tkwin = Tk_NameToWindow(interp, Tcl_GetString(objv[i]), mainWin); if (tkwin == NULL) { return TCL_ERROR; } @@ -1820,7 +1822,7 @@ TestmetricsObjCmd( /* *---------------------------------------------------------------------- * - * TestpropCmd -- + * TestpropObjCmd -- * * This function implements the "testprop" command. It fetches and prints * the value of a property on a window. @@ -1836,11 +1838,11 @@ TestmetricsObjCmd( /* ARGSUSED */ static int -TestpropCmd( +TestpropObjCmd( ClientData clientData, /* Main window for application. */ Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - const char **argv) /* Argument strings. */ + int objc, /* Number of arguments. */ + Tcl_Obj *const objv[]) /* Argument strings. */ { Tk_Window mainWin = (Tk_Window) clientData; int result, actualFormat; @@ -1851,14 +1853,13 @@ TestpropCmd( Window w; char buffer[30]; - if (argc != 3) { - Tcl_AppendResult(interp, "wrong # args; must be \"", argv[0], - " window property\"", NULL); + if (objc != 3) { + Tcl_WrongNumArgs(interp, 1, objv, "window property"); return TCL_ERROR; } - w = strtoul(argv[1], &end, 0); - propName = Tk_InternAtom(mainWin, argv[2]); + w = strtoul(Tcl_GetString(objv[1]), &end, 0); + propName = Tk_InternAtom(mainWin, Tcl_GetString(objv[2])); property = NULL; result = XGetWindowProperty(Tk_Display(mainWin), w, propName, 0, 100000, False, AnyPropertyType, diff --git a/generic/tkText.c b/generic/tkText.c index 9c436c6..386dac5 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -6658,8 +6658,8 @@ int TkpTesttextCmd( ClientData clientData, /* Main window for application. */ Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - const char **argv) /* Argument strings. */ + int objc, /* Number of arguments. */ + Tcl_Obj *const objv[]) /* Argument strings. */ { TkText *textPtr; size_t len; @@ -6668,41 +6668,41 @@ TkpTesttextCmd( char buf[64]; Tcl_CmdInfo info; - if (argc < 3) { + if (objc < 3) { return TCL_ERROR; } - if (Tcl_GetCommandInfo(interp, argv[1], &info) == 0) { + if (Tcl_GetCommandInfo(interp, Tcl_GetString(objv[1]), &info) == 0) { return TCL_ERROR; } textPtr = info.objClientData; - len = strlen(argv[2]); - if (strncmp(argv[2], "byteindex", len) == 0) { - if (argc != 5) { + len = strlen(Tcl_GetString(objv[2])); + if (strncmp(Tcl_GetString(objv[2]), "byteindex", len) == 0) { + if (objc != 5) { return TCL_ERROR; } - lineIndex = atoi(argv[3]) - 1; - byteIndex = atoi(argv[4]); + lineIndex = atoi(Tcl_GetString(objv[3])) - 1; + byteIndex = atoi(Tcl_GetString(objv[4])); TkTextMakeByteIndex(textPtr->sharedTextPtr->tree, textPtr, lineIndex, byteIndex, &index); - } else if (strncmp(argv[2], "forwbytes", len) == 0) { - if (argc != 5) { + } else if (strncmp(Tcl_GetString(objv[2]), "forwbytes", len) == 0) { + if (objc != 5) { return TCL_ERROR; } - if (TkTextGetIndex(interp, textPtr, argv[3], &index) != TCL_OK) { + if (TkTextGetIndex(interp, textPtr, Tcl_GetString(objv[3]), &index) != TCL_OK) { return TCL_ERROR; } - byteOffset = atoi(argv[4]); + byteOffset = atoi(Tcl_GetString(objv[4])); TkTextIndexForwBytes(textPtr, &index, byteOffset, &index); - } else if (strncmp(argv[2], "backbytes", len) == 0) { - if (argc != 5) { + } else if (strncmp(Tcl_GetString(objv[2]), "backbytes", len) == 0) { + if (objc != 5) { return TCL_ERROR; } - if (TkTextGetIndex(interp, textPtr, argv[3], &index) != TCL_OK) { + if (TkTextGetIndex(interp, textPtr, Tcl_GetString(objv[3]), &index) != TCL_OK) { return TCL_ERROR; } - byteOffset = atoi(argv[4]); + byteOffset = atoi(Tcl_GetString(objv[4])); TkTextIndexBackBytes(textPtr, &index, byteOffset, &index); } else { return TCL_ERROR; diff --git a/macosx/tkMacOSXEmbed.c b/macosx/tkMacOSXEmbed.c index e2e05d2..1d66b82 100644 --- a/macosx/tkMacOSXEmbed.c +++ b/macosx/tkMacOSXEmbed.c @@ -563,15 +563,15 @@ int TkpTestembedCmd( ClientData clientData, /* Main window for application. */ Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - const char **argv) /* Argument strings. */ + int objc, /* Number of arguments. */ + Tcl_Obj *const objv[]) /* Argument strings. */ { int all; Container *containerPtr; Tcl_DString dString; char buffer[50]; - if ((argc > 1) && (strcmp(argv[1], "all") == 0)) { + if ((objc > 1) && (strcmp(Tcl_GetString(objv[1]), "all") == 0)) { all = 1; } else { all = 0; diff --git a/macosx/tkMacOSXHLEvents.c b/macosx/tkMacOSXHLEvents.c index ffbb06d..8d51c33 100644 --- a/macosx/tkMacOSXHLEvents.c +++ b/macosx/tkMacOSXHLEvents.c @@ -221,7 +221,7 @@ OappHandler( Tcl_Interp *interp = (Tcl_Interp *) handlerRefcon; if (interp && - Tcl_GetCommandInfo(interp, "::tk::mac::OpenApplication", &dummy)){ + Tcl_FindCommand(interp, "::tk::mac::OpenApplication", NULL, 0)){ int code = Tcl_EvalEx(interp, "::tk::mac::OpenApplication", -1, TCL_EVAL_GLOBAL); if (code != TCL_OK) { Tcl_BackgroundException(interp, code); @@ -252,13 +252,12 @@ RappHandler( AppleEvent *reply, SRefCon handlerRefcon) { - Tcl_CmdInfo dummy; Tcl_Interp *interp = (Tcl_Interp *) handlerRefcon; ProcessSerialNumber thePSN = {0, kCurrentProcess}; OSStatus err = ChkErr(SetFrontProcess, &thePSN); - if (interp && Tcl_GetCommandInfo(interp, - "::tk::mac::ReopenApplication", &dummy)) { + if (interp && Tcl_FindCommand(interp, + "::tk::mac::ReopenApplication", NULL, 0)) { int code = Tcl_EvalEx(interp, "::tk::mac::ReopenApplication", -1, TCL_EVAL_GLOBAL); if (code != TCL_OK){ Tcl_BackgroundException(interp, code); @@ -294,7 +293,7 @@ PrefsHandler( Tcl_Interp *interp = (Tcl_Interp *) handlerRefcon; if (interp && - Tcl_GetCommandInfo(interp, "::tk::mac::ShowPreferences", &dummy)){ + Tcl_FindCommand(interp, "::tk::mac::ShowPreferences", NULL, 0)){ int code = Tcl_EvalEx(interp, "::tk::mac::ShowPreferences", -1, TCL_EVAL_GLOBAL); if (code != TCL_OK) { Tcl_BackgroundException(interp, code); @@ -333,7 +332,6 @@ OdocHandler( long count, index; AEKeyword keyword; Tcl_DString command, pathName; - Tcl_CmdInfo dummy; int code; /* @@ -342,7 +340,7 @@ OdocHandler( */ if (!interp || - !Tcl_GetCommandInfo(interp, "::tk::mac::OpenDocument", &dummy)) { + !Tcl_FindCommand(interp, "::tk::mac::OpenDocument", NULL, 0)) { return noErr; } @@ -433,7 +431,7 @@ PrintHandler( */ if (!interp || - !Tcl_GetCommandInfo(interp, "::tk::mac::PrintDocument", &dummy)) { + !Tcl_FindCommand(interp, "::tk::mac::PrintDocument", NULL, 0)) { return noErr; } @@ -623,8 +621,7 @@ ReallyKillMe( int flags) { Tcl_Interp *interp = ((KillEvent *) eventPtr)->interp; - Tcl_CmdInfo dummy; - int quit = Tcl_GetCommandInfo(interp, "::tk::mac::Quit", &dummy); + int quit = Tcl_FindCommand(interp, "::tk::mac::Quit", NULL, 0)!=NULL; int code = Tcl_EvalEx(interp, quit ? "::tk::mac::Quit" : "exit", -1, TCL_EVAL_GLOBAL); if (code != TCL_OK) { diff --git a/macosx/tkMacOSXMenus.c b/macosx/tkMacOSXMenus.c index 881bf75..68b2c00 100644 --- a/macosx/tkMacOSXMenus.c +++ b/macosx/tkMacOSXMenus.c @@ -145,10 +145,9 @@ static Tcl_Obj * GetWidgetDemoPath(Tcl_Interp *interp); SEL action = [anItem action]; if (sel_isEqual(action, @selector(preferences:))) { - Tcl_CmdInfo dummy; - return (_eventInterp && Tcl_GetCommandInfo(_eventInterp, - "::tk::mac::ShowPreferences", &dummy)); + return (_eventInterp && Tcl_FindCommand(_eventInterp, + "::tk::mac::ShowPreferences", NULL, 0)); } else if (sel_isEqual(action, @selector(tkDemo:))) { BOOL haveDemo = NO; @@ -169,10 +168,8 @@ static Tcl_Obj * GetWidgetDemoPath(Tcl_Interp *interp); - (void) orderFrontStandardAboutPanel: (id) sender { - Tcl_CmdInfo dummy; - - if (!_eventInterp || !Tcl_GetCommandInfo(_eventInterp, "tkAboutDialog", - &dummy) || (GetCurrentEventKeyModifiers() & optionKey)) { + if (!_eventInterp || !Tcl_FindCommand(_eventInterp, "tkAboutDialog", + NULL, 0) || (GetCurrentEventKeyModifiers() & optionKey)) { TkAboutDlg(); } else { int code = Tcl_EvalEx(_eventInterp, "tkAboutDialog", -1, @@ -187,10 +184,8 @@ static Tcl_Obj * GetWidgetDemoPath(Tcl_Interp *interp); - (void) showHelp: (id) sender { - Tcl_CmdInfo dummy; - - if (!_eventInterp || !Tcl_GetCommandInfo(_eventInterp, - "::tk::mac::ShowHelp", &dummy)) { + if (!_eventInterp || !Tcl_FindCommand(_eventInterp, + "::tk::mac::ShowHelp", NULL, 0)) { [super showHelp:sender]; } else { int code = Tcl_EvalEx(_eventInterp, "::tk::mac::ShowHelp", -1, diff --git a/macosx/tkMacOSXTest.c b/macosx/tkMacOSXTest.c index 7d2b24e..1882ce6 100644 --- a/macosx/tkMacOSXTest.c +++ b/macosx/tkMacOSXTest.c @@ -18,8 +18,8 @@ * Forward declarations of procedures defined later in this file: */ -static int DebuggerCmd (ClientData dummy, Tcl_Interp *interp, - int argc, const char **argv); +static int DebuggerObjCmd (ClientData dummy, Tcl_Interp *interp, + int objc, Tcl_Obj *const objv[]); /* *---------------------------------------------------------------------- @@ -46,7 +46,7 @@ TkplatformtestInit( * Add commands for platform specific tests on MacOS here. */ - Tcl_CreateCommand(interp, "debugger", DebuggerCmd, + Tcl_CreateObjCommand(interp, "debugger", DebuggerObjCmd, (ClientData) 0, (Tcl_CmdDeleteProc *) NULL); return TCL_OK; @@ -55,7 +55,7 @@ TkplatformtestInit( /* *---------------------------------------------------------------------- * - * DebuggerCmd -- + * DebuggerObjCmd -- * * This procedure simply calls the low level debugger. * @@ -69,11 +69,11 @@ TkplatformtestInit( */ static int -DebuggerCmd( +DebuggerObjCmd( ClientData clientData, /* Not used. */ Tcl_Interp *interp, /* Not used. */ - int argc, /* Not used. */ - const char **argv) /* Not used. */ + int objc, /* Not used. */ + Tcl_Obj *const objv[]) /* Not used. */ { Debugger(); return TCL_OK; diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 9402cbb..2e4a683 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -266,9 +266,8 @@ extern NSString *opaqueTag; const char *cmd = ([[notification name] isEqualToString: NSApplicationDidUnhideNotification] ? "::tk::mac::OnShow" : "::tk::mac::OnHide"); - Tcl_CmdInfo dummy; - if (_eventInterp && Tcl_GetCommandInfo(_eventInterp, cmd, &dummy)) { + if (_eventInterp && Tcl_FindCommand(_eventInterp, cmd, NULL, 0)) { int code = Tcl_EvalEx(_eventInterp, cmd, -1, TCL_EVAL_GLOBAL); if (code != TCL_OK) { diff --git a/unix/tkUnixEmbed.c b/unix/tkUnixEmbed.c index 8a4c368..7f3f94b 100644 --- a/unix/tkUnixEmbed.c +++ b/unix/tkUnixEmbed.c @@ -867,8 +867,8 @@ int TkpTestembedCmd( ClientData clientData, /* Main window for application. */ Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - const char **argv) /* Argument strings. */ + int objc, /* Number of arguments. */ + Tcl_Obj *const objv[]) /* Argument strings. */ { int all; Container *containerPtr; @@ -877,7 +877,7 @@ TkpTestembedCmd( ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); - if ((argc > 1) && (strcmp(argv[1], "all") == 0)) { + if ((objc > 1) && (strcmp(Tcl_GetString(objv[1]), "all") == 0)) { all = 1; } else { all = 0; diff --git a/win/tkWinEmbed.c b/win/tkWinEmbed.c index a908a1f..42809cc 100644 --- a/win/tkWinEmbed.c +++ b/win/tkWinEmbed.c @@ -101,8 +101,8 @@ int TkpTestembedCmd( ClientData clientData, Tcl_Interp *interp, - int argc, - const char **argv) + int objc, + Tcl_Obj *const objv[]) { return TCL_OK; } -- cgit v0.12 From 01977b9ff82689c9735a9395986a94a85d1552c4 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 3 Jun 2014 11:10:18 +0000 Subject: re-generate tkIntDecls.h --- generic/tkIntDecls.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/generic/tkIntDecls.h b/generic/tkIntDecls.h index 261d3db..b8addbd 100644 --- a/generic/tkIntDecls.h +++ b/generic/tkIntDecls.h @@ -436,9 +436,8 @@ EXTERN int TkpTestembedCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); /* 157 */ -EXTERN int TkpTesttextCmd(ClientData dummy, - Tcl_Interp *interp, int objc, - Tcl_Obj *const objv[]); +EXTERN int TkpTesttextCmd(ClientData dummy, Tcl_Interp *interp, + int objc, Tcl_Obj *const objv[]); /* 158 */ EXTERN int TkSelGetSelection(Tcl_Interp *interp, Tk_Window tkwin, Atom selection, Atom target, @@ -739,8 +738,8 @@ typedef struct TkIntStubs { void (*tkCreateThreadExitHandler) (Tcl_ExitProc *proc, ClientData clientData); /* 153 */ void (*tkDeleteThreadExitHandler) (Tcl_ExitProc *proc, ClientData clientData); /* 154 */ void (*reserved155)(void); - int (*tkpTestembedObjCmd) (ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); /* 156 */ - int (*tkpTesttextObjCmd) (ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); /* 157 */ + int (*tkpTestembedCmd) (ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); /* 156 */ + int (*tkpTesttextCmd) (ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); /* 157 */ int (*tkSelGetSelection) (Tcl_Interp *interp, Tk_Window tkwin, Atom selection, Atom target, Tk_GetSelProc *proc, ClientData clientData); /* 158 */ int (*tkTextGetIndex) (Tcl_Interp *interp, struct TkText *textPtr, const char *string, struct TkTextIndex *indexPtr); /* 159 */ int (*tkTextIndexBackBytes) (const struct TkText *textPtr, const struct TkTextIndex *srcPtr, int count, struct TkTextIndex *dstPtr); /* 160 */ @@ -1083,9 +1082,9 @@ extern const TkIntStubs *tkIntStubsPtr; (tkIntStubsPtr->tkDeleteThreadExitHandler) /* 154 */ /* Slot 155 is reserved */ #define TkpTestembedCmd \ - (tkIntStubsPtr->tkpTestembedObjCmd) /* 156 */ + (tkIntStubsPtr->tkpTestembedCmd) /* 156 */ #define TkpTesttextCmd \ - (tkIntStubsPtr->tkpTesttextObjCmd) /* 157 */ + (tkIntStubsPtr->tkpTesttextCmd) /* 157 */ #define TkSelGetSelection \ (tkIntStubsPtr->tkSelGetSelection) /* 158 */ #define TkTextGetIndex \ -- cgit v0.12 From 07f1821ced9ccf739badabbba75ae09f5bdb7521 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 3 Jun 2014 11:24:11 +0000 Subject: Use Tcl_FindCommand in stead of Tcl_GetCommandInfo where this suffices. --- generic/tkImage.c | 4 +--- generic/tkMenu.c | 3 +-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/generic/tkImage.c b/generic/tkImage.c index e22b735..359d6c6 100644 --- a/generic/tkImage.c +++ b/generic/tkImage.c @@ -283,13 +283,11 @@ Tk_ImageObjCmd( */ if ((objc == 3) || (*(arg = Tcl_GetString(objv[3])) == '-')) { - Tcl_CmdInfo dummy; - do { dispPtr->imageId++; sprintf(idString, "image%d", dispPtr->imageId); name = idString; - } while (Tcl_GetCommandInfo(interp, name, &dummy) != 0); + } while (Tcl_FindCommand(interp, name, NULL, 0) != NULL); firstOption = 3; } else { TkWindow *topWin; diff --git a/generic/tkMenu.c b/generic/tkMenu.c index cd9ff08..1af9b88 100644 --- a/generic/tkMenu.c +++ b/generic/tkMenu.c @@ -3044,7 +3044,6 @@ TkNewMenuName( char *destString; int i; int doDot; - Tcl_CmdInfo cmdInfo; Tcl_HashTable *nameTablePtr = NULL; TkWindow *winPtr = (TkWindow *) menuPtr->tkwin; const char *parentName = Tcl_GetString(parentPtr); @@ -3084,7 +3083,7 @@ TkNewMenuName( Tcl_DecrRefCount(intPtr); } destString = Tcl_GetString(resultPtr); - if ((Tcl_GetCommandInfo(interp, destString, &cmdInfo) == 0) + if ((Tcl_FindCommand(interp, destString, NULL, 0) == NULL) && ((nameTablePtr == NULL) || (Tcl_FindHashEntry(nameTablePtr, destString) == NULL))) { break; -- cgit v0.12 From 68ffa26f8a2faf3690359d69a6b00ec44268b018 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 27 Jun 2014 19:29:26 +0000 Subject: two more (test-)command converted to Tcl_Obj API --- generic/tkTest.c | 57 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/generic/tkTest.c b/generic/tkTest.c index 1514604..28e068d 100644 --- a/generic/tkTest.c +++ b/generic/tkTest.c @@ -163,8 +163,9 @@ static int TestmakeexistObjCmd(ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); #if !(defined(_WIN32) || defined(MAC_OSX_TK) || defined(__CYGWIN__)) -static int TestmenubarCmd(ClientData dummy, - Tcl_Interp *interp, int argc, const char **argv); +static int TestmenubarObjCmd(ClientData dummy, + Tcl_Interp *interp, int objc, + Tcl_Obj *const objv[]); #endif #if defined(_WIN32) || defined(MAC_OSX_TK) static int TestmetricsObjCmd(ClientData dummy, @@ -191,8 +192,9 @@ static int TestpropObjCmd(ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[]); #if !(defined(_WIN32) || defined(MAC_OSX_TK) || defined(__CYGWIN__)) -static int TestwrapperCmd(ClientData dummy, - Tcl_Interp *interp, int argc, const char **argv); +static int TestwrapperObjCmd(ClientData dummy, + Tcl_Interp *interp, int objc, + Tcl_Obj * const objv[]); #endif static void TrivialCmdDeletedProc(ClientData clientData); static int TrivialConfigObjCmd(ClientData dummy, @@ -267,11 +269,11 @@ Tktest_Init( Tcl_CreateObjCommand(interp, "testmetrics", TestmetricsObjCmd, (ClientData) Tk_MainWindow(interp), NULL); #elif !defined(__CYGWIN__) - Tcl_CreateCommand(interp, "testmenubar", TestmenubarCmd, + Tcl_CreateObjCommand(interp, "testmenubar", TestmenubarObjCmd, (ClientData) Tk_MainWindow(interp), NULL); Tcl_CreateObjCommand(interp, "testsend", TkpTestsendCmd, (ClientData) Tk_MainWindow(interp), NULL); - Tcl_CreateCommand(interp, "testwrapper", TestwrapperCmd, + Tcl_CreateObjCommand(interp, "testwrapper", TestwrapperObjCmd, (ClientData) Tk_MainWindow(interp), NULL); #endif /* _WIN32 || MAC_OSX_TK */ @@ -1681,7 +1683,7 @@ TestmakeexistObjCmd( /* *---------------------------------------------------------------------- * - * TestmenubarCmd -- + * TestmenubarObjCmd -- * * This function implements the "testmenubar" command. It is used to test * the Unix facilities for creating space above a toplevel window for a @@ -1699,43 +1701,41 @@ TestmakeexistObjCmd( /* ARGSUSED */ #if !(defined(_WIN32) || defined(MAC_OSX_TK) || defined(__CYGWIN__)) static int -TestmenubarCmd( +TestmenubarObjCmd( ClientData clientData, /* Main window for application. */ Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - const char **argv) /* Argument strings. */ + int objc, /* Number of arguments. */ + Tcl_Obj *const objv[]) /* Argument strings. */ { #ifdef __UNIX__ Tk_Window mainWin = (Tk_Window) clientData; Tk_Window tkwin, menubar; - if (argc < 2) { - Tcl_AppendResult(interp, "wrong # args; must be \"", argv[0], - " option ?arg ...?\"", NULL); + if (objc < 2) { + Tcl_WrongNumArgs(interp, 1, objv, "option ?arg ...?"); return TCL_ERROR; } - if (strcmp(argv[1], "window") == 0) { - if (argc != 4) { - Tcl_AppendResult(interp, "wrong # args; must be \"", argv[0], - "window toplevel menubar\"", NULL); + if (strcmp(Tcl_GetString(objv[1]), "window") == 0) { + if (objc != 4) { + Tcl_WrongNumArgs(interp, 1, objv, "windows toplevel menubar"); return TCL_ERROR; } - tkwin = Tk_NameToWindow(interp, argv[2], mainWin); + tkwin = Tk_NameToWindow(interp, Tcl_GetString(objv[2]), mainWin); if (tkwin == NULL) { return TCL_ERROR; } - if (argv[3][0] == 0) { + if (Tcl_GetString(objv[3])[0] == 0) { TkUnixSetMenubar(tkwin, NULL); } else { - menubar = Tk_NameToWindow(interp, argv[3], mainWin); + menubar = Tk_NameToWindow(interp, Tcl_GetString(objv[3]), mainWin); if (menubar == NULL) { return TCL_ERROR; } TkUnixSetMenubar(tkwin, menubar); } } else { - Tcl_AppendResult(interp, "bad option \"", argv[1], + Tcl_AppendResult(interp, "bad option \"", Tcl_GetString(objv[1]), "\": must be window", NULL); return TCL_ERROR; } @@ -1900,7 +1900,7 @@ TestpropObjCmd( /* *---------------------------------------------------------------------- * - * TestwrapperCmd -- + * TestwrapperObjCmd -- * * This function implements the "testwrapper" command. It provides a way * from Tcl to determine the extra window Tk adds in between the toplevel @@ -1917,23 +1917,22 @@ TestpropObjCmd( /* ARGSUSED */ static int -TestwrapperCmd( +TestwrapperObjCmd( ClientData clientData, /* Main window for application. */ Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - const char **argv) /* Argument strings. */ + int objc, /* Number of arguments. */ + Tcl_Obj *const objv[]) /* Argument strings. */ { TkWindow *winPtr, *wrapperPtr; Tk_Window tkwin; - if (argc != 2) { - Tcl_AppendResult(interp, "wrong # args; must be \"", argv[0], - " window\"", NULL); + if (objc != 2) { + Tcl_WrongNumArgs(interp, 1, objv, "window"); return TCL_ERROR; } tkwin = (Tk_Window) clientData; - winPtr = (TkWindow *) Tk_NameToWindow(interp, argv[1], tkwin); + winPtr = (TkWindow *) Tk_NameToWindow(interp, Tcl_GetString(objv[1]), tkwin); if (winPtr == NULL) { return TCL_ERROR; } -- cgit v0.12 From 1d58f0d143fb94eeaf0dbd0ddc36011423356d88 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 30 Jun 2014 11:28:47 +0000 Subject: Eliminate last two calls to Tcl_CreateCommand(). --- generic/tkOldTest.c | 42 +++++++++++++++++++++--------------------- generic/tkTest.c | 42 +++++++++++++++++++++--------------------- unix/tkAppInit.c | 2 +- win/winMain.c | 2 +- 4 files changed, 44 insertions(+), 44 deletions(-) diff --git a/generic/tkOldTest.c b/generic/tkOldTest.c index 2e931b1..df1bb6c 100644 --- a/generic/tkOldTest.c +++ b/generic/tkOldTest.c @@ -81,8 +81,9 @@ static Tk_ImageType imageType = { * Forward declarations for functions defined later in this file: */ -static int ImageCmd(ClientData dummy, - Tcl_Interp *interp, int argc, const char **argv); +static int ImageObjCmd(ClientData dummy, + Tcl_Interp *interp, int objc, + Tcl_Obj * const objv[]); /* @@ -175,7 +176,7 @@ ImageCreate( strcpy(timPtr->imageName, name); timPtr->varName = ckalloc((unsigned) (strlen(varName) + 1)); strcpy(timPtr->varName, varName); - Tcl_CreateCommand(interp, name, ImageCmd, timPtr, NULL); + Tcl_CreateObjCommand(interp, name, ImageObjCmd, timPtr, NULL); *clientDataPtr = timPtr; Tk_ImageChanged(master, 0, 0, 30, 15, 30, 15); return TCL_OK; @@ -184,7 +185,7 @@ ImageCreate( /* *---------------------------------------------------------------------- * - * ImageCmd -- + * ImageObjCmd -- * * This function implements the commands corresponding to individual * images. @@ -200,38 +201,37 @@ ImageCreate( /* ARGSUSED */ static int -ImageCmd( +ImageObjCmd( ClientData clientData, /* Main window for application. */ Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - const char **argv) /* Argument strings. */ + int objc, /* Number of arguments. */ + Tcl_Obj *const objv[]) /* Argument strings. */ { TImageMaster *timPtr = clientData; int x, y, width, height; - if (argc < 2) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], "option ?arg ...?", NULL); + if (objc < 2) { + Tcl_WrongNumArgs(interp, 1, objv, "option ?arg ...?"); return TCL_ERROR; } - if (strcmp(argv[1], "changed") == 0) { - if (argc != 8) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " changed x y width height imageWidth imageHeight", NULL); + if (strcmp(Tcl_GetString(objv[1]), "changed") == 0) { + if (objc != 8) { + Tcl_WrongNumArgs(interp, 1, objv, "changed x y width height" + " imageWidth imageHeight"); return TCL_ERROR; } - if ((Tcl_GetInt(interp, argv[2], &x) != TCL_OK) - || (Tcl_GetInt(interp, argv[3], &y) != TCL_OK) - || (Tcl_GetInt(interp, argv[4], &width) != TCL_OK) - || (Tcl_GetInt(interp, argv[5], &height) != TCL_OK) - || (Tcl_GetInt(interp, argv[6], &timPtr->width) != TCL_OK) - || (Tcl_GetInt(interp, argv[7], &timPtr->height) != TCL_OK)) { + if ((Tcl_GetIntFromObj(interp, objv[2], &x) != TCL_OK) + || (Tcl_GetIntFromObj(interp, objv[3], &y) != TCL_OK) + || (Tcl_GetIntFromObj(interp, objv[4], &width) != TCL_OK) + || (Tcl_GetIntFromObj(interp, objv[5], &height) != TCL_OK) + || (Tcl_GetIntFromObj(interp, objv[6], &timPtr->width) != TCL_OK) + || (Tcl_GetIntFromObj(interp, objv[7], &timPtr->height) != TCL_OK)) { return TCL_ERROR; } Tk_ImageChanged(timPtr->master, x, y, width, height, timPtr->width, timPtr->height); } else { - Tcl_AppendResult(interp, "bad option \"", argv[1], + Tcl_AppendResult(interp, "bad option \"", Tcl_GetString(objv[1]), "\": must be changed", NULL); return TCL_ERROR; } diff --git a/generic/tkTest.c b/generic/tkTest.c index 28e068d..fa9e073 100644 --- a/generic/tkTest.c +++ b/generic/tkTest.c @@ -139,8 +139,9 @@ typedef struct TrivialCommandHeader { * Forward declarations for functions defined later in this file: */ -static int ImageCmd(ClientData dummy, - Tcl_Interp *interp, int argc, const char **argv); +static int ImageObjCmd(ClientData dummy, + Tcl_Interp *interp, int objc, + Tcl_Obj * const objv[]); static int TestbitmapObjCmd(ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[]); @@ -1413,7 +1414,7 @@ ImageCreate( strcpy(timPtr->imageName, name); timPtr->varName = ckalloc(strlen(varName) + 1); strcpy(timPtr->varName, varName); - Tcl_CreateCommand(interp, name, ImageCmd, timPtr, NULL); + Tcl_CreateObjCommand(interp, name, ImageObjCmd, timPtr, NULL); *clientDataPtr = timPtr; Tk_ImageChanged(master, 0, 0, 30, 15, 30, 15); return TCL_OK; @@ -1422,7 +1423,7 @@ ImageCreate( /* *---------------------------------------------------------------------- * - * ImageCmd -- + * ImageObjCmd -- * * This function implements the commands corresponding to individual * images. @@ -1438,38 +1439,37 @@ ImageCreate( /* ARGSUSED */ static int -ImageCmd( +ImageObjCmd( ClientData clientData, /* Main window for application. */ Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - const char **argv) /* Argument strings. */ + int objc, /* Number of arguments. */ + Tcl_Obj *const objv[]) /* Argument strings. */ { TImageMaster *timPtr = (TImageMaster *) clientData; int x, y, width, height; - if (argc < 2) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], "option ?arg ...?", NULL); + if (objc < 2) { + Tcl_WrongNumArgs(interp, 1, objv, "option ?arg ...?"); return TCL_ERROR; } - if (strcmp(argv[1], "changed") == 0) { - if (argc != 8) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " changed x y width height imageWidth imageHeight", NULL); + if (strcmp(Tcl_GetString(objv[1]), "changed") == 0) { + if (objc != 8) { + Tcl_WrongNumArgs(interp, 1, objv, "changed x y width height" + " imageWidth imageHeight"); return TCL_ERROR; } - if ((Tcl_GetInt(interp, argv[2], &x) != TCL_OK) - || (Tcl_GetInt(interp, argv[3], &y) != TCL_OK) - || (Tcl_GetInt(interp, argv[4], &width) != TCL_OK) - || (Tcl_GetInt(interp, argv[5], &height) != TCL_OK) - || (Tcl_GetInt(interp, argv[6], &timPtr->width) != TCL_OK) - || (Tcl_GetInt(interp, argv[7], &timPtr->height) != TCL_OK)) { + if ((Tcl_GetIntFromObj(interp, objv[2], &x) != TCL_OK) + || (Tcl_GetIntFromObj(interp, objv[3], &y) != TCL_OK) + || (Tcl_GetIntFromObj(interp, objv[4], &width) != TCL_OK) + || (Tcl_GetIntFromObj(interp, objv[5], &height) != TCL_OK) + || (Tcl_GetIntFromObj(interp, objv[6], &timPtr->width) != TCL_OK) + || (Tcl_GetIntFromObj(interp, objv[7], &timPtr->height) != TCL_OK)) { return TCL_ERROR; } Tk_ImageChanged(timPtr->master, x, y, width, height, timPtr->width, timPtr->height); } else { - Tcl_AppendResult(interp, "bad option \"", argv[1], + Tcl_AppendResult(interp, "bad option \"", Tcl_GetString(objv[1]), "\": must be changed", NULL); return TCL_ERROR; } diff --git a/unix/tkAppInit.c b/unix/tkAppInit.c index 9a0b053..13bcdde 100644 --- a/unix/tkAppInit.c +++ b/unix/tkAppInit.c @@ -131,7 +131,7 @@ Tcl_AppInit( */ /* - * Call Tcl_CreateCommand for application-specific commands, if they + * Call Tcl_CreateObjCommand for application-specific commands, if they * weren't already created by the init procedures called above. */ diff --git a/win/winMain.c b/win/winMain.c index 36dbea9..62bcbd8 100644 --- a/win/winMain.c +++ b/win/winMain.c @@ -224,7 +224,7 @@ Tcl_AppInit( */ /* - * Call Tcl_CreateCommand for application-specific commands, if they + * Call Tcl_CreateObjCommand for application-specific commands, if they * weren't already created by the init procedures called above. */ -- cgit v0.12 From df83d667f620123b4aee3c99d8842189de3db737 Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Mon, 7 Jul 2014 01:09:27 +0000 Subject: Fix for alpha channel rendering for images on OS X Mavericks; thanks to Marc Culler for the extensive patch. --- macosx/tkMacOSXDraw.c | 173 +++++++++++++++++++++++++++----------------- macosx/tkMacOSXPrivate.h | 2 + macosx/tkMacOSXSubwindows.c | 4 +- macosx/tkMacOSXXStubs.c | 112 +++++++++++++++------------- 4 files changed, 170 insertions(+), 121 deletions(-) diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index 0727b26..167277f 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -114,10 +114,79 @@ TkMacOSXInitCGDrawing( /* *---------------------------------------------------------------------- * + * BitmapRepFromDrawableRect + * + * Extract bitmap data from a MacOSX drawable as an NSBitmapImageRep. + * + * Results: + * Returns an autoreleased NSBitmapRep representing the image of the given + * rectangle of the given drawable. + * + * NOTE: The x,y coordinates should be relative to a coordinate system with + * origin at the top left, as used by XImage and CGImage, not bottom + * left as used by NSView. + * + * Side effects: + * None + * + *---------------------------------------------------------------------- + */ +NSBitmapImageRep* +BitmapRepFromDrawableRect( + Drawable drawable, + int x, + int y, + unsigned int width, + unsigned int height) +{ + MacDrawable *mac_drawable = (MacDrawable *) drawable; + CGContextRef cg_context=NULL; + CGImageRef cg_image=NULL, sub_cg_image=NULL; + NSBitmapImageRep *bitmap_rep=NULL; + NSView *view=NULL; + if ( mac_drawable->flags & TK_IS_PIXMAP ) { + /* + This means that the MacDrawable is functioning as a Tk Pixmap, so its view + field is NULL. It's context field should point to a CGImage. + */ + cg_context = GetCGContextForDrawable(drawable); + CGRect image_rect = CGRectMake(x, y, width, height); + cg_image = CGBitmapContextCreateImage( (CGContextRef) cg_context); + sub_cg_image = CGImageCreateWithImageInRect(cg_image, image_rect); + if ( sub_cg_image ) { + bitmap_rep = [[NSBitmapImageRep alloc] autorelease]; + [bitmap_rep initWithCGImage:sub_cg_image]; + } + if ( cg_image ) { + CGImageRelease(cg_image); + } + } else if ( (view = TkMacOSXDrawableView(mac_drawable)) ) { + /* convert top-left coordinates to NSView coordinates */ + int view_height = [view bounds].size.height; + NSRect view_rect = NSMakeRect(x + mac_drawable->xOff, + view_height - height - y - mac_drawable->yOff, + width,height); + + if ( [view lockFocusIfCanDraw] ) { + bitmap_rep = [[NSBitmapImageRep alloc] autorelease]; + bitmap_rep = [bitmap_rep initWithFocusedViewRect:view_rect]; + [view unlockFocus]; + } else { + TkMacOSXDbgMsg("Could not lock focus on view."); + } + + } else { + TkMacOSXDbgMsg("Invalid source drawable"); + } + return bitmap_rep; +} + +/* + *---------------------------------------------------------------------- + * * XCopyArea -- * - * Copies data from one drawable to another using block transfer - * routines. + * Copies data from one drawable to another. * * Results: * None. @@ -144,76 +213,52 @@ XCopyArea( { TkMacOSXDrawingContext dc; MacDrawable *srcDraw = (MacDrawable *) src; + NSBitmapImageRep *bitmap_rep = NULL; + CGImageRef img = NULL; display->request++; + + TkMacOSXDbgMsg("XCopyArea"); + if (!width || !height) { - /* TkMacOSXDbgMsg("Drawing of emtpy area requested"); */ + /* This happens all the time. + TkMacOSXDbgMsg("Drawing of empty area requested"); + */ return; } - if (srcDraw->flags & TK_IS_PIXMAP) { - if (!TkMacOSXSetupDrawingContext(dst, gc, 1, &dc)) { - return; - } - if (dc.context) { - CGImageRef img = TkMacOSXCreateCGImageWithDrawable(src); - if (img) { - DrawCGImage(dst, gc, dc.context, img, gc->foreground, - gc->background, CGRectMake(0, 0, - srcDraw->size.width, srcDraw->size.height), - CGRectMake(src_x, src_y, width, height), - CGRectMake(dest_x, dest_y, width, height)); - CFRelease(img); - } else { - TkMacOSXDbgMsg("Invalid source drawable"); + if (!TkMacOSXSetupDrawingContext(dst, gc, 1, &dc)) { + TkMacOSXDbgMsg("Failed to setup drawing context."); + } + + if ( dc.context ) { + if (srcDraw->flags & TK_IS_PIXMAP) { + img = TkMacOSXCreateCGImageWithDrawable(src); + }else if (TkMacOSXDrawableWindow(src)) { + bitmap_rep = BitmapRepFromDrawableRect(src, src_x, src_y, width, height); + if ( bitmap_rep ) { + img = [bitmap_rep CGImage]; } } else { - TkMacOSXDbgMsg("Invalid destination drawable"); - } - TkMacOSXRestoreDrawingContext(&dc); - } else if (TkMacOSXDrawableWindow(src)) { - NSView *view = TkMacOSXDrawableView(srcDraw); - NSWindow *w = [view window]; - NSInteger gs = [w windowNumber] > 0 ? [w gState] : 0; - /* // alternative using per-view gState: - NSInteger gs = [view gState]; - if (!gs) { - [view allocateGState]; - if ([view lockFocusIfCanDraw]) { - [view unlockFocus]; - } - gs = [view gState]; - } - */ - if (!gs || !TkMacOSXSetupDrawingContext(dst, gc, 1, &dc)) { - return; + TkMacOSXDbgMsg("Invalid source drawable"); } - if (dc.context) { - NSGraphicsContext *gc = nil; - CGFloat boundsH = [view bounds].size.height; - NSRect srcRect = NSMakeRect(srcDraw->xOff + src_x, boundsH - - height - (srcDraw->yOff + src_y), width, height); - - if (((MacDrawable *) dst)->flags & TK_IS_PIXMAP) { - gc = [NSGraphicsContext graphicsContextWithGraphicsPort: - dc.context flipped:NO]; - if (gc) { - [NSGraphicsContext saveGraphicsState]; - [NSGraphicsContext setCurrentContext:gc]; - } - } - NSCopyBits(gs, srcRect, NSMakePoint(dest_x, - dc.portBounds.size.height - dest_y)); - if (gc) { - [NSGraphicsContext restoreGraphicsState]; - } + + if (img) { + DrawCGImage(dst, gc, dc.context, img, gc->foreground, gc->background, + CGRectMake(0, 0, srcDraw->size.width, srcDraw->size.height), + CGRectMake(src_x, src_y, width, height), + CGRectMake(dest_x, dest_y, width, height)); + CFRelease(img); } else { - TkMacOSXDbgMsg("Invalid destination drawable"); + TkMacOSXDbgMsg("Invalid source drawable"); } - TkMacOSXRestoreDrawingContext(&dc); + } else { - TkMacOSXDbgMsg("Invalid source drawable"); + TkMacOSXDbgMsg("Invalid destination drawable"); + return; } + + TkMacOSXRestoreDrawingContext(&dc); } /* @@ -254,7 +299,7 @@ XCopyPlane( display->request++; if (!width || !height) { - /* TkMacOSXDbgMsg("Drawing of emtpy area requested"); */ + /* TkMacOSXDbgMsg("Drawing of empty area requested"); */ return; } if (plane != 1) { @@ -384,13 +429,7 @@ CreateCGImageWithXImage( char *data = NULL; CGDataProviderReleaseDataCallback releaseData = ReleaseData; - if (image->obdata) { - /* - * Image from XGetImage - */ - - img = TkMacOSXCreateCGImageWithDrawable((Pixmap) image->obdata); - } else if (image->bits_per_pixel == 1) { + if (image->bits_per_pixel == 1) { /* * BW image */ diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h index 034c450..412d135 100644 --- a/macosx/tkMacOSXPrivate.h +++ b/macosx/tkMacOSXPrivate.h @@ -230,6 +230,8 @@ MODULE_SCOPE WindowClass TkMacOSXWindowClass(TkWindow *winPtr); MODULE_SCOPE int TkMacOSXIsWindowZoomed(TkWindow *winPtr); MODULE_SCOPE int TkGenerateButtonEventForXPointer(Window window); MODULE_SCOPE EventModifiers TkMacOSXModifierState(void); +MODULE_SCOPE NSBitmapImageRep* BitmapRepFromDrawableRect(Drawable drawable, + int x, int y, unsigned int width, unsigned int height); MODULE_SCOPE int TkMacOSXSetupDrawingContext(Drawable d, GC gc, int useCG, TkMacOSXDrawingContext *dcPtr); MODULE_SCOPE void TkMacOSXRestoreDrawingContext( diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c index 18276fb..29bc4a3 100644 --- a/macosx/tkMacOSXSubwindows.c +++ b/macosx/tkMacOSXSubwindows.c @@ -1277,7 +1277,7 @@ UpdateOffsets( * Returns a handle to a new pixmap. * * Side effects: - * Allocates a new Macintosh GWorld. + * Allocates a new CGBitmapContext. * *---------------------------------------------------------------------- */ @@ -1323,7 +1323,7 @@ Tk_GetPixmap( * None. * * Side effects: - * Deletes the Macintosh GWorld created by Tk_GetPixmap. + * Deletes the CGBitmapContext created by Tk_GetPixmap. * *---------------------------------------------------------------------- */ diff --git a/macosx/tkMacOSXXStubs.c b/macosx/tkMacOSXXStubs.c index 848b49c..196344c 100644 --- a/macosx/tkMacOSXXStubs.c +++ b/macosx/tkMacOSXXStubs.c @@ -782,7 +782,6 @@ XCreateImage( int bytes_per_line) { XImage *ximage; - display->request++; ximage = ckalloc(sizeof(XImage)); @@ -792,6 +791,7 @@ XCreateImage( ximage->xoffset = offset; ximage->format = format; ximage->data = data; + ximage->obdata = NULL; if (format == ZPixmap) { ximage->bits_per_pixel = 32; @@ -823,7 +823,6 @@ XCreateImage( ximage->red_mask = 0x00FF0000; ximage->green_mask = 0x0000FF00; ximage->blue_mask = 0x000000FF; - ximage->obdata = NULL; ximage->f.create_image = NULL; ximage->f.destroy_image = DestroyImage; ximage->f.get_pixel = ImageGetPixel; @@ -842,8 +841,9 @@ XCreateImage( * This function copies data from a pixmap or window into an XImage. * * Results: - * Returns a newly allocated image containing the data from the given - * rectangle of the given drawable. + * Returns a newly allocated XImage containing the data from the given + * rectangle of the given drawable, or NULL if the XImage could not be + * constructed. * * Side effects: * None. @@ -862,60 +862,70 @@ XGetImage( unsigned long plane_mask, int format) { - MacDrawable *macDraw = (MacDrawable *) d; - XImage * imagePtr = NULL; - Pixmap pixmap = (Pixmap) NULL; - Tk_Window win = (Tk_Window) macDraw->winPtr; - GC gc; - char * data = NULL; - int depth = 32; - int offset = 0; - int bitmap_pad = 0; - int bytes_per_line = 0; - + NSBitmapImageRep *bitmap_rep; + XImage * imagePtr = NULL; + char * bitmap = NULL; + char * image_data=NULL; + int depth = 32; + int offset = 0; + int bitmap_pad = 0; + int bytes_per_row = 4*width; + int size; + TkMacOSXDbgMsg("XGetImage"); if (format == ZPixmap) { - if (width > 0 && height > 0) { - /* - * Tk_GetPixmap fails for zero width or height. - */ - - pixmap = Tk_GetPixmap(display, d, width, height, depth); + if (width == 0 || height == 0) { + /* This happens all the time. + TkMacOSXDbgMsg("XGetImage: empty image requested"); + */ + return NULL; } - if (win) { - XGCValues values; - gc = Tk_GetGC(win, 0, &values); - } else { - gc = XCreateGC(display, pixmap, 0, NULL); + bitmap_rep = BitmapRepFromDrawableRect(d, x, y,width, height); + + if ( bitmap_rep == Nil || + [bitmap_rep bitmapFormat] != 0 || + [bitmap_rep samplesPerPixel] != 4 || + [bitmap_rep isPlanar] != 0 ) { + TkMacOSXDbgMsg("XGetImage: Failed to construct NSBitmapRep"); + return NULL; } - if (pixmap) { - CGContextRef context; - - XCopyArea(display, d, pixmap, gc, x, y, width, height, 0, 0); - context = ((MacDrawable *) pixmap)->context; - if (context) { - data = CGBitmapContextGetData(context); - bytes_per_line = CGBitmapContextGetBytesPerRow(context); + + NSSize image_size = NSMakeSize(width, height); + NSImage* ns_image = [[NSImage alloc]initWithSize:image_size]; + [ns_image addRepresentation:bitmap_rep]; + + /* Assume premultiplied nonplanar data with 4 bytes per pixel and alpha last.*/ + if ( [bitmap_rep bitmapFormat] == 0 && + [bitmap_rep isPlanar ] == 0 && + [bitmap_rep samplesPerPixel] == 4 ) { + bytes_per_row = [bitmap_rep bytesPerRow]; + size = bytes_per_row*height; + image_data = (char*)[bitmap_rep bitmapData]; + if ( image_data ) { + int row, n, m; + bitmap = ckalloc(size); + /* + Oddly enough, the bitmap has the top row at the beginning, + and the pixels are in BGRA format. + */ + for (row=0, n=0; rowobdata = (XPointer) pixmap; - } else if (pixmap) { - Tk_FreePixmap(display, pixmap); - } - if (!win) { - XFreeGC(display, gc); + (char*)bitmap, width, height, bitmap_pad, bytes_per_row); + [ns_image removeRepresentation:bitmap_rep]; /*releases the rep*/ + [ns_image release]; } } else { - TkMacOSXDbgMsg("Invalid image format"); + TkMacOSXDbgMsg("Could not extract image from drawable."); } return imagePtr; } @@ -941,9 +951,7 @@ DestroyImage( XImage *image) { if (image) { - if (image->obdata) { - Tk_FreePixmap((Display*) gMacDisplay, (Pixmap) image->obdata); - } else if (image->data) { + if (image->data) { ckfree(image->data); } ckfree(image); -- cgit v0.12 From c14530201df3f512c68f49728a3b8fcd2755bfcc Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Thu, 24 Jul 2014 02:30:25 +0000 Subject: Fix for display of images when scrolling a text widget on OS X; thanks to Marc Culler for patch --- macosx/tkMacOSXDraw.c | 116 +++++++++++++++++++++++++++++++++++------------- macosx/tkMacOSXRegion.c | 64 +++++++++++++------------- 2 files changed, 116 insertions(+), 64 deletions(-) diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index 167277f..701112d 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -218,8 +218,6 @@ XCopyArea( display->request++; - TkMacOSXDbgMsg("XCopyArea"); - if (!width || !height) { /* This happens all the time. TkMacOSXDbgMsg("Drawing of empty area requested"); @@ -240,7 +238,7 @@ XCopyArea( img = [bitmap_rep CGImage]; } } else { - TkMacOSXDbgMsg("Invalid source drawable"); + TkMacOSXDbgMsg("Invalid source drawable - neither window nor pixmap."); } if (img) { @@ -250,11 +248,11 @@ XCopyArea( CGRectMake(dest_x, dest_y, width, height)); CFRelease(img); } else { - TkMacOSXDbgMsg("Invalid source drawable"); + TkMacOSXDbgMsg("Failed to construct CGImage."); } } else { - TkMacOSXDbgMsg("Invalid destination drawable"); + TkMacOSXDbgMsg("Invalid destination drawable - no context."); return; } @@ -1480,43 +1478,97 @@ TkScrollWindow( int dx, int dy, /* Distance rectangle should be moved. */ TkRegion damageRgn) /* Region to accumulate damage in. */ { - MacDrawable *macDraw = (MacDrawable *) Tk_WindowId(tkwin); + Drawable drawable = Tk_WindowId(tkwin); + MacDrawable *macDraw = (MacDrawable *) drawable; NSView *view = TkMacOSXDrawableView(macDraw); - CGRect visRect, srcRect, dstRect; - CGFloat boundsH; - HIShapeRef dmgRgn, dstRgn; + CGRect visRect, srcRect, dstRect, scroll_src, scroll_dst; + HIShapeRef dmgRgn = NULL; + NSRect bounds; int result; - if (view && !CGRectIsEmpty(visRect = NSRectToCGRect([view visibleRect]))) { - boundsH = [view bounds].size.height; - srcRect = CGRectMake(macDraw->xOff + x, boundsH - height - - (macDraw->yOff + y), width, height); - dstRect = CGRectIntersection(CGRectOffset(srcRect, dx, -dy), visRect); - srcRect = CGRectIntersection(srcRect, visRect); - if (!CGRectIsEmpty(srcRect) && !CGRectIsEmpty(dstRect)) { + if ( view ) { + /* Get the scroll area in NSView coordinates (origin at bottom left). */ + bounds = [view bounds]; + scroll_src = CGRectMake( + macDraw->xOff + x, + bounds.size.height - height - (macDraw->yOff + y), + width, height); + scroll_dst = CGRectOffset(scroll_src, dx, -dy); + /* Limit scrolling to the window content area. */ + visRect = NSRectToCGRect([view visibleRect]); + scroll_src = CGRectIntersection(scroll_src, visRect); + scroll_dst = CGRectIntersection(scroll_dst, visRect); + + if ( !CGRectIsEmpty(scroll_src) && !CGRectIsEmpty(scroll_dst) ) { + /* - CGRect sRect = CGRectIntersection(CGRectOffset(dstRect, -dx, dy), - srcRect); - NSCopyBits(0, NSRectFromCGRect(sRect), - NSPointFromCGPoint(CGRectOffset(sRect, dx, -dy).origin)); - */ - [view scrollRect:NSRectFromCGRect(srcRect) by:NSMakeSize(dx, -dy)]; + * Mark the difference between source and destination as damaged. + * This region is described in the Tk coordinate system, after shifting by dy. + */ + + srcRect = CGRectMake(x - macDraw->xOff, y - macDraw->yOff, + width, height); + dstRect = CGRectOffset(srcRect, dx, dy); + dmgRgn = HIShapeCreateMutableWithRect(&srcRect); + HIShapeRef dstRgn = HIShapeCreateWithRect(&dstRect); + ChkErr(HIShapeDifference, dmgRgn, dstRgn, (HIMutableShapeRef) dmgRgn); + CFRelease(dstRgn); + + /* Scroll the rectangle. */ + [view scrollRect:NSRectFromCGRect(scroll_src) by:NSMakeSize(dx, -dy)]; + [view displayRect:NSRectFromCGRect(scroll_dst)]; + + /* + * When a Text widget contains embedded images, scrolling generates + * lots of artifacts involving multiple copies of the images + * displayed on top of each other. Extensive experimentation, with + * very little help from the Apple documentation, indicates that + * whenever an image is displayed it gets added as a subview, which + * then gets automatically redisplayed in its original location. + * + * We do two things to combat this. First, each subview that meets + * the scroll area is added as a damage rectangle. Second, we + * redisplay the subviews after the scroll. + */ + + /* + * Step 1: Find any subviews that meet the scroll area and mark + * them as damaged. Use Tk coordinates, shifted to account for the + * future scrolling. + */ + + for (NSView *subview in [view subviews] ) { + NSRect frame = [subview frame]; + CGRect subviewRect = CGRectMake( + frame.origin.x - macDraw->xOff + dx, + (bounds.size.height - frame.origin.y - frame.size.height) - macDraw->yOff + dy, + frame.size.width, frame.size.height); + /* Rectangles with negative coordinates seem to cause trouble. */ + if (subviewRect.origin.y < 0 && subviewRect.origin.y + subviewRect.size.height > 0) { + subviewRect.origin.y = 0; + } + CGRect intersection = CGRectIntersection(srcRect, subviewRect); + if (! CGRectIsEmpty(intersection) ){ + dstRgn = HIShapeCreateWithRect(&subviewRect); + ChkErr(HIShapeUnion, dmgRgn, dstRgn, (HIMutableShapeRef) dmgRgn); + CFRelease(dstRgn); + } + } + + /* Step 2: Redisplay all subviews */ + for (NSView *subview in [view subviews] ) { + [subview display]; + } } - srcRect.origin.y = boundsH - srcRect.size.height - srcRect.origin.y; - dstRect.origin.y = boundsH - dstRect.size.height - dstRect.origin.y; - srcRect = CGRectUnion(srcRect, dstRect); - dmgRgn = HIShapeCreateMutableWithRect(&srcRect); - dstRgn = HIShapeCreateWithRect(&dstRect); - ChkErr(HIShapeDifference, dmgRgn, dstRgn, (HIMutableShapeRef) dmgRgn); - CFRelease(dstRgn); - TkMacOSXInvalidateViewRegion(view, dmgRgn); - } else { + } + + if ( dmgRgn == NULL ) { dmgRgn = HIShapeCreateEmpty(); } + //TkMacOSXInvalidateViewRegion(view, dmgRgn); TkMacOSXSetWithNativeRegion(damageRgn, dmgRgn); result = HIShapeIsEmpty(dmgRgn) ? 0 : 1; CFRelease(dmgRgn); - return result; } diff --git a/macosx/tkMacOSXRegion.c b/macosx/tkMacOSXRegion.c index 8432299..c716ab7 100644 --- a/macosx/tkMacOSXRegion.c +++ b/macosx/tkMacOSXRegion.c @@ -158,6 +158,29 @@ TkUnionRectWithRegion( /* *---------------------------------------------------------------------- * + * TkMacOSXIsEmptyRegion -- + * + * Return native region for given tk region. + * + * Results: + * 1 if empty, 0 otherwise. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +int +TkMacOSXIsEmptyRegion( + TkRegion r) +{ + return HIShapeIsEmpty((HIMutableShapeRef) r) ? 1 : 0; +} + +/* + *---------------------------------------------------------------------- + * * TkRectInRegion -- * * Implements the equivelent of the X window function XRectInRegion. See @@ -181,12 +204,14 @@ TkRectInRegion( unsigned int width, unsigned int height) { - int result; - const CGRect r = CGRectMake(x, y, width, height); - - result = HIShapeIntersectsRect((HIShapeRef) region, &r) ? + if ( TkMacOSXIsEmptyRegion(region) ) { + return RectangleOut; + } + else { + const CGRect r = CGRectMake(x, y, width, height); + return HIShapeIntersectsRect((HIShapeRef) region, &r) ? RectanglePart : RectangleOut; - return result; + } } /* @@ -332,12 +357,11 @@ TkpReleaseRegion( { CFRelease(r); } -#if 0 /* *---------------------------------------------------------------------- * - * TkMacOSXEmtpyRegion -- + * TkMacOSXSetEmptyRegion -- * * Set region to emtpy. * @@ -351,7 +375,7 @@ TkpReleaseRegion( */ void -TkMacOSXEmtpyRegion( +TkMacOSXSetEmptyRegion( TkRegion r) { ChkErr(HIShapeSetEmpty, (HIMutableShapeRef) r); @@ -360,30 +384,6 @@ TkMacOSXEmtpyRegion( /* *---------------------------------------------------------------------- * - * TkMacOSXIsEmptyRegion -- - * - * Return native region for given tk region. - * - * Results: - * 1 if empty, 0 otherwise. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -int -TkMacOSXIsEmptyRegion( - TkRegion r) -{ - return HIShapeIsEmpty((HIMutableShapeRef) r) ? 1 : 0; -} -#endif - -/* - *---------------------------------------------------------------------- - * * TkMacOSXGetNativeRegion -- * * Return native region for given tk region. -- cgit v0.12 From 70e46f4111270421e799c112aa766a9f71a6d18e Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Fri, 25 Jul 2014 17:04:32 +0000 Subject: Add copyright notice to Marc Culler for extensive patch to alpha rendering on Mac/Cocoa; remove private API calls to comply with platform requirements. --- macosx/tkMacOSXDraw.c | 1 + macosx/tkMacOSXKeyEvent.c | 20 +-- macosx/tkMacOSXPrivate.h | 8 +- macosx/tkMacOSXScrlbr.c | 3 + macosx/tkMacOSXSubwindows.c | 11 +- macosx/tkMacOSXWindowEvent.c | 309 ++++++++++++++++++++++--------------------- macosx/tkMacOSXXStubs.c | 1 + 7 files changed, 185 insertions(+), 168 deletions(-) diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index 701112d..5065fa2 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -8,6 +8,7 @@ * Copyright (c) 1995-1997 Sun Microsystems, Inc. * Copyright 2001-2009, Apple Inc. * Copyright (c) 2006-2009 Daniel A. Steffen + * Copyright 2014 Marc Culler. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. diff --git a/macosx/tkMacOSXKeyEvent.c b/macosx/tkMacOSXKeyEvent.c index 1d24960..0cfb663 100644 --- a/macosx/tkMacOSXKeyEvent.c +++ b/macosx/tkMacOSXKeyEvent.c @@ -241,7 +241,7 @@ static unsigned isFunctionKey(unsigned int code); finishedCompose = YES; /* first, clear any working text */ - if (_workingText != nil) + if (privateWorkingText != nil) [self deleteWorkingText]; /* now insert the string as keystrokes */ @@ -275,13 +275,13 @@ static unsigned isFunctionKey(unsigned int code); NSLog (@"setMarkedText '%@' len =%d range %d from %d", str, [str length], selRange.length, selRange.location); - if (_workingText != nil) + if (privateWorkingText != nil) [self deleteWorkingText]; if ([str length] == 0) return; processingCompose = YES; - _workingText = [str copy]; + privateWorkingText = [str copy]; //PENDING: insert workingText underlined } @@ -290,12 +290,12 @@ static unsigned isFunctionKey(unsigned int code); /* delete display of composing characters [not in ] */ - (void)deleteWorkingText { - if (_workingText == nil) + if (privateWorkingText == nil) return; if (NS_KEYLOG) - NSLog(@"deleteWorkingText len = %d\n", [_workingText length]); - [_workingText release]; - _workingText = nil; + NSLog(@"deleteWorkingText len = %d\n", [privateWorkingText length]); + [privateWorkingText release]; + privateWorkingText = nil; processingCompose = NO; //PENDING: delete working text @@ -304,14 +304,14 @@ static unsigned isFunctionKey(unsigned int code); - (BOOL)hasMarkedText { - return _workingText != nil; + return privateWorkingText != nil; } - (NSRange)markedRange { - NSRange rng = _workingText != nil - ? NSMakeRange (0, [_workingText length]) : NSMakeRange (NSNotFound, 0); + NSRange rng = privateWorkingText != nil + ? NSMakeRange (0, [privateWorkingText length]) : NSMakeRange (NSNotFound, 0); if (NS_KEYLOG) NSLog (@"markedRange request"); return rng; diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h index 412d135..fd32c4b 100644 --- a/macosx/tkMacOSXPrivate.h +++ b/macosx/tkMacOSXPrivate.h @@ -320,9 +320,12 @@ VISIBILITY_HIDDEN VISIBILITY_HIDDEN @interface TKContentView : NSView { @private + /*Remove private API calls.*/ + #if 0 id _savedSubviews; BOOL _subviewsSetAside; - NSString *_workingText; + #endif + NSString *privateWorkingText; } @end @@ -362,9 +365,12 @@ VISIBILITY_HIDDEN keyEquivalentModifierMask:(NSUInteger)keyEquivalentModifierMask; @end +//Remove private API calls here: not necessary for systems >= 10.7 +#if 0 /* From WebKit/WebKit/mac/WebCoreSupport/WebChromeClient.mm: */ @interface NSWindow(TKGrowBoxRect) - (NSRect)_growBoxRect; @end +#endif #endif /* _TKMACPRIV */ diff --git a/macosx/tkMacOSXScrlbr.c b/macosx/tkMacOSXScrlbr.c index ac71d8e..67d79c9 100644 --- a/macosx/tkMacOSXScrlbr.c +++ b/macosx/tkMacOSXScrlbr.c @@ -333,6 +333,8 @@ TkpDisplayScrollbar( NSWindow *w = [view window]; + //This uses a private API call that is no longer needed on systems >= 10.7. + #if 0 if ([w showsResizeIndicator]) { NSRect growBox = [view convertRect:[w _growBoxRect] fromView:nil]; @@ -348,6 +350,7 @@ TkpDisplayScrollbar( TkMacOSXSetScrollbarGrow(winPtr, true); } } + #endif if (!NSEqualRects(frame, [scroller frame])) { [scroller setFrame:frame]; } diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c index 29bc4a3..3dfd308 100644 --- a/macosx/tkMacOSXSubwindows.c +++ b/macosx/tkMacOSXSubwindows.c @@ -743,11 +743,12 @@ TkMacOSXUpdateClipRgn( NSWindow *w = TkMacOSXDrawableWindow(winPtr->window); if (w) { - bounds = NSRectToCGRect([w _growBoxRect]); - bounds.origin.y = [w contentRectForFrameRect: - [w frame]].size.height - bounds.size.height - - bounds.origin.y; - ChkErr(TkMacOSHIShapeDifferenceWithRect, rgn, &bounds); + // This call to private API not needed on systems >= 10.7 + // bounds = NSRectToCGRect([w _growBoxRect]); + // bounds.origin.y = [w contentRectForFrameRect: + // [w frame]].size.height - bounds.size.height - + // bounds.origin.y; + // ChkErr(TkMacOSHIShapeDifferenceWithRect, rgn, &bounds); } } macWin->aboveVisRgn = HIShapeCreateCopy(rgn); diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 2e4a683..eff8484 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -806,13 +806,14 @@ ExposeRestrictProc( NSWindow *w = [self window]; - if ([self isOpaque] && [w showsResizeIndicator]) { - NSRect bounds = [self convertRect:[w _growBoxRect] fromView:nil]; + //remove private API calls here: not needed on systems >= 10.7 + // if ([self isOpaque] && [w showsResizeIndicator]) { + // NSRect bounds = [self convertRect:[w _growBoxRect] fromView:nil]; - if ([self needsToDrawRect:bounds]) { - NSEraseRect(bounds); - } - } + // if ([self needsToDrawRect:bounds]) { + // NSEraseRect(bounds); + // } + // } CGFloat height = [self bounds].size.height; HIMutableShapeRef drawShape = HIShapeCreateMutable(); @@ -946,152 +947,156 @@ ExposeRestrictProc( @end -#pragma mark TKContentViewPrivate - -/* - * Technique adapted from WebKit/WebKit/mac/WebView/WebHTMLView.mm to supress - * normal AppKit subview drawing and make all drawing go through us. - * Overrides NSView internals. - */ - -@interface TKContentView(TKContentViewPrivate) -- (id) initWithFrame: (NSRect) frame; -- (void) _setAsideSubviews; -- (void) _restoreSubviews; -@end - -@interface NSView(TKContentViewPrivate) -- (void) _recursiveDisplayRectIfNeededIgnoringOpacity: (NSRect) rect - isVisibleRect: (BOOL) isVisibleRect - rectIsVisibleRectForView: (NSView *) visibleView - topView: (BOOL) topView; -- (void) _recursiveDisplayAllDirtyWithLockFocus: (BOOL) needsLockFocus - visRect: (NSRect) visRect; -- (void) _recursive: (BOOL) recurse - displayRectIgnoringOpacity: (NSRect) displayRect - inContext: (NSGraphicsContext *) context topView: (BOOL) topView; -- (void) _lightWeightRecursiveDisplayInRect: (NSRect) visRect; -- (BOOL) _drawRectIfEmpty; -- (void) _drawRect: (NSRect) inRect clip: (BOOL) clip; -- (void) _setDrawsOwnDescendants: (BOOL) drawsOwnDescendants; -@end - -@implementation TKContentView(TKContentViewPrivate) - -- (id) initWithFrame: (NSRect) frame -{ - self = [super initWithFrame:frame]; - if (self) { - _savedSubviews = nil; - _subviewsSetAside = NO; - [self _setDrawsOwnDescendants:YES]; - } - return self; -} - -- (void) _setAsideSubviews -{ -#ifdef TK_MAC_DEBUG - if (_subviewsSetAside || _savedSubviews) { - Tcl_Panic("TKContentView _setAsideSubviews called incorrectly"); - } -#endif - _savedSubviews = _subviews; - _subviews = nil; - _subviewsSetAside = YES; -} - -- (void) _restoreSubviews -{ -#ifdef TK_MAC_DEBUG - if (!_subviewsSetAside || _subviews) { - Tcl_Panic("TKContentView _restoreSubviews called incorrectly"); - } -#endif - _subviews = _savedSubviews; - _savedSubviews = nil; - _subviewsSetAside = NO; -} - -- (void) _recursiveDisplayRectIfNeededIgnoringOpacity: (NSRect) rect - isVisibleRect: (BOOL) isVisibleRect - rectIsVisibleRectForView: (NSView *) visibleView - topView: (BOOL) topView -{ - [self _setAsideSubviews]; - [super _recursiveDisplayRectIfNeededIgnoringOpacity:rect - isVisibleRect:isVisibleRect rectIsVisibleRectForView:visibleView - topView:topView]; - [self _restoreSubviews]; -} - -- (void) _recursiveDisplayAllDirtyWithLockFocus: (BOOL) needsLockFocus - visRect: (NSRect) visRect -{ - BOOL needToSetAsideSubviews = !_subviewsSetAside; - - if (needToSetAsideSubviews) { - [self _setAsideSubviews]; - } - [super _recursiveDisplayAllDirtyWithLockFocus:needsLockFocus - visRect:visRect]; - if (needToSetAsideSubviews) { - [self _restoreSubviews]; - } -} - -- (void) _recursive: (BOOL) recurse - displayRectIgnoringOpacity: (NSRect) displayRect - inContext: (NSGraphicsContext *) context topView: (BOOL) topView -{ - [self _setAsideSubviews]; - [super _recursive:recurse - displayRectIgnoringOpacity:displayRect inContext:context - topView:topView]; - [self _restoreSubviews]; -} - -- (void) _lightWeightRecursiveDisplayInRect: (NSRect) visRect -{ - BOOL needToSetAsideSubviews = !_subviewsSetAside; - - if (needToSetAsideSubviews) { - [self _setAsideSubviews]; - } - [super _lightWeightRecursiveDisplayInRect:visRect]; - if (needToSetAsideSubviews) { - [self _restoreSubviews]; - } -} - -- (BOOL) _drawRectIfEmpty -{ - /* - * Our -drawRect manages subview drawing directly, so it needs to be called - * even if the area to be redrawn is completely obscured by subviews. - */ - - return YES; -} - -- (void) _drawRect: (NSRect) inRect clip: (BOOL) clip -{ -#ifdef TK_MAC_DEBUG_DRAWING - TKLog(@"-[%@(%p) %s%@]", [self class], self, _cmd, - NSStringFromRect(inRect)); -#endif - BOOL subviewsWereSetAside = _subviewsSetAside; - - if (subviewsWereSetAside) { - [self _restoreSubviews]; - } - [super _drawRect:inRect clip:clip]; - if (subviewsWereSetAside) { - [self _setAsideSubviews]; - } -} - -@end +/*Remove private/non-documented API calls. This is strongly discouraged by Apple and may lead to breakage in the future.*/ + + +// #pragma mark TKContentViewPrivate + +// /* +// * Technique adapted from WebKit/WebKit/mac/WebView/WebHTMLView.mm to supress +// * normal AppKit subview drawing and make all drawing go through us. +// * Overrides NSView internals. +// */ + +// @interface TKContentView(TKContentViewPrivate) +// - (id) initWithFrame: (NSRect) frame; +// - (void) _setAsideSubviews; +// - (void) _restoreSubviews; +// @end + +// @interface NSView(TKContentViewPrivate) +// - (void) _recursiveDisplayRectIfNeededIgnoringOpacity: (NSRect) rect +// isVisibleRect: (BOOL) isVisibleRect +// rectIsVisibleRectForView: (NSView *) visibleView +// topView: (BOOL) topView; +// - (void) _recursiveDisplayAllDirtyWithLockFocus: (BOOL) needsLockFocus +// visRect: (NSRect) visRect; +// - (void) _recursive: (BOOL) recurse +// displayRectIgnoringOpacity: (NSRect) displayRect +// inContext: (NSGraphicsContext *) context topView: (BOOL) topView; +// - (void) _lightWeightRecursiveDisplayInRect: (NSRect) visRect; +// - (BOOL) _drawRectIfEmpty; +// - (void) _drawRect: (NSRect) inRect clip: (BOOL) clip; +// - (void) _setDrawsOwnDescendants: (BOOL) drawsOwnDescendants; +// @end +// #endif + +// @implementation TKContentView(TKContentViewPrivate) + +// - (id) initWithFrame: (NSRect) frame +// { +// self = [super initWithFrame:frame]; +// if (self) { +// _savedSubviews = nil; +// _subviewsSetAside = NO; +// [self _setDrawsOwnDescendants:YES]; +// } +// return self; +// } + +// - (void) _setAsideSubviews +// { +// #ifdef TK_MAC_DEBUG +// if (_subviewsSetAside || _savedSubviews) { +// Tcl_Panic("TKContentView _setAsideSubviews called incorrectly"); +// } +// #endif +// _savedSubviews = _subviews; +// _subviews = nil; +// _subviewsSetAside = YES; +// } + +// - (void) _restoreSubviews +// { +// #ifdef TK_MAC_DEBUG +// if (!_subviewsSetAside || _subviews) { +// Tcl_Panic("TKContentView _restoreSubviews called incorrectly"); +// } +// #endif +// _subviews = _savedSubviews; +// _savedSubviews = nil; +// _subviewsSetAside = NO; +// } + +// - (void) _recursiveDisplayRectIfNeededIgnoringOpacity: (NSRect) rect +// isVisibleRect: (BOOL) isVisibleRect +// rectIsVisibleRectForView: (NSView *) visibleView +// topView: (BOOL) topView +// { +// [self _setAsideSubviews]; +// [super _recursiveDisplayRectIfNeededIgnoringOpacity:rect +// isVisibleRect:isVisibleRect rectIsVisibleRectForView:visibleView +// topView:topView]; +// [self _restoreSubviews]; +// } + +// - (void) _recursiveDisplayAllDirtyWithLockFocus: (BOOL) needsLockFocus +// visRect: (NSRect) visRect +// { +// BOOL needToSetAsideSubviews = !_subviewsSetAside; + +// if (needToSetAsideSubviews) { +// [self _setAsideSubviews]; +// } +// [super _recursiveDisplayAllDirtyWithLockFocus:needsLockFocus +// visRect:visRect]; +// if (needToSetAsideSubviews) { +// [self _restoreSubviews]; +// } +// } + +// - (void) _recursive: (BOOL) recurse +// displayRectIgnoringOpacity: (NSRect) displayRect +// inContext: (NSGraphicsContext *) context topView: (BOOL) topView +// { +// [self _setAsideSubviews]; +// [super _recursive:recurse +// displayRectIgnoringOpacity:displayRect inContext:context +// topView:topView]; +// [self _restoreSubviews]; +// } + +// - (void) _lightWeightRecursiveDisplayInRect: (NSRect) visRect +// { +// BOOL needToSetAsideSubviews = !_subviewsSetAside; + +// if (needToSetAsideSubviews) { +// [self _setAsideSubviews]; +// } +// [super _lightWeightRecursiveDisplayInRect:visRect]; +// if (needToSetAsideSubviews) { +// [self _restoreSubviews]; +// } +// } + +// - (BOOL) _drawRectIfEmpty +// { +// /* +// * Our -drawRect manages subview drawing directly, so it needs to be called +// * even if the area to be redrawn is completely obscured by subviews. +// */ + +// return YES; +// } + +// - (void) _drawRect: (NSRect) inRect clip: (BOOL) clip +// { +// #ifdef TK_MAC_DEBUG_DRAWING +// TKLog(@"-[%@(%p) %s%@]", [self class], self, _cmd, +// NSStringFromRect(inRect)); +// #endif +// BOOL subviewsWereSetAside = _subviewsSetAside; + +// if (subviewsWereSetAside) { +// [self _restoreSubviews]; +// } +// [super _drawRect:inRect clip:clip]; +// if (subviewsWereSetAside) { +// [self _setAsideSubviews]; +// } +// } + +// @end /* * Local Variables: diff --git a/macosx/tkMacOSXXStubs.c b/macosx/tkMacOSXXStubs.c index 196344c..c0f7c7c 100644 --- a/macosx/tkMacOSXXStubs.c +++ b/macosx/tkMacOSXXStubs.c @@ -9,6 +9,7 @@ * Copyright (c) 1995-1997 Sun Microsystems, Inc. * Copyright 2001-2009, Apple Inc. * Copyright (c) 2005-2009 Daniel A. Steffen + * Copyright 2014 Marc Culler. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. -- cgit v0.12 From b2263f97e0a12c9653911aa89f63766e54e9cfdb Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Mon, 28 Jul 2014 02:43:41 +0000 Subject: Fine-tune scrolling, especially of text widgets with embedded windows, after removal of private API calls; performance is now better and within acceptable ranges. --- macosx/tkMacOSXDraw.c | 4 -- macosx/tkMacOSXPrivate.h | 8 --- macosx/tkMacOSXSubwindows.c | 8 --- macosx/tkMacOSXWindowEvent.c | 167 +------------------------------------------ 4 files changed, 1 insertion(+), 186 deletions(-) diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index 5065fa2..6eef09d 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -1556,10 +1556,6 @@ TkScrollWindow( } } - /* Step 2: Redisplay all subviews */ - for (NSView *subview in [view subviews] ) { - [subview display]; - } } } diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h index fd32c4b..adc7106 100644 --- a/macosx/tkMacOSXPrivate.h +++ b/macosx/tkMacOSXPrivate.h @@ -365,12 +365,4 @@ VISIBILITY_HIDDEN keyEquivalentModifierMask:(NSUInteger)keyEquivalentModifierMask; @end -//Remove private API calls here: not necessary for systems >= 10.7 -#if 0 -/* From WebKit/WebKit/mac/WebCoreSupport/WebChromeClient.mm: */ -@interface NSWindow(TKGrowBoxRect) -- (NSRect)_growBoxRect; -@end -#endif - #endif /* _TKMACPRIV */ diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c index 3dfd308..9ba7100 100644 --- a/macosx/tkMacOSXSubwindows.c +++ b/macosx/tkMacOSXSubwindows.c @@ -742,14 +742,6 @@ TkMacOSXUpdateClipRgn( kWindowResizableAttribute) { NSWindow *w = TkMacOSXDrawableWindow(winPtr->window); - if (w) { - // This call to private API not needed on systems >= 10.7 - // bounds = NSRectToCGRect([w _growBoxRect]); - // bounds.origin.y = [w contentRectForFrameRect: - // [w frame]].size.height - bounds.size.height - - // bounds.origin.y; - // ChkErr(TkMacOSHIShapeDifferenceWithRect, rgn, &bounds); - } } macWin->aboveVisRgn = HIShapeCreateCopy(rgn); diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index eff8484..0bd6398 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -762,10 +762,7 @@ Tk_MacOSXIsAppInFront(void) * Custom content view for Tk NSWindows, containing standard NSView subviews. * The goal is to emulate X11-style drawing in response to Expose events: * during the normal AppKit drawing cycle, we supress drawing of all subviews - * (using a technique adapted from WebKit's WebHTMLView) and instead send - * Expose events about the subviews that would be redrawn. Tk Expose event - * handling and drawing handlers then draw the subviews manually via their - * -displayRectIgnoringOpacity: + * and instead send Expose events about the subviews that would be redrawn. */ @interface TKContentView(TKWindowEvent) @@ -804,17 +801,6 @@ ExposeRestrictProc( NSCompositeSourceOver); #endif - NSWindow *w = [self window]; - - //remove private API calls here: not needed on systems >= 10.7 - // if ([self isOpaque] && [w showsResizeIndicator]) { - // NSRect bounds = [self convertRect:[w _growBoxRect] fromView:nil]; - - // if ([self needsToDrawRect:bounds]) { - // NSEraseRect(bounds); - // } - // } - CGFloat height = [self bounds].size.height; HIMutableShapeRef drawShape = HIShapeCreateMutable(); @@ -947,157 +933,6 @@ ExposeRestrictProc( @end -/*Remove private/non-documented API calls. This is strongly discouraged by Apple and may lead to breakage in the future.*/ - - -// #pragma mark TKContentViewPrivate - -// /* -// * Technique adapted from WebKit/WebKit/mac/WebView/WebHTMLView.mm to supress -// * normal AppKit subview drawing and make all drawing go through us. -// * Overrides NSView internals. -// */ - -// @interface TKContentView(TKContentViewPrivate) -// - (id) initWithFrame: (NSRect) frame; -// - (void) _setAsideSubviews; -// - (void) _restoreSubviews; -// @end - -// @interface NSView(TKContentViewPrivate) -// - (void) _recursiveDisplayRectIfNeededIgnoringOpacity: (NSRect) rect -// isVisibleRect: (BOOL) isVisibleRect -// rectIsVisibleRectForView: (NSView *) visibleView -// topView: (BOOL) topView; -// - (void) _recursiveDisplayAllDirtyWithLockFocus: (BOOL) needsLockFocus -// visRect: (NSRect) visRect; -// - (void) _recursive: (BOOL) recurse -// displayRectIgnoringOpacity: (NSRect) displayRect -// inContext: (NSGraphicsContext *) context topView: (BOOL) topView; -// - (void) _lightWeightRecursiveDisplayInRect: (NSRect) visRect; -// - (BOOL) _drawRectIfEmpty; -// - (void) _drawRect: (NSRect) inRect clip: (BOOL) clip; -// - (void) _setDrawsOwnDescendants: (BOOL) drawsOwnDescendants; -// @end -// #endif - -// @implementation TKContentView(TKContentViewPrivate) - -// - (id) initWithFrame: (NSRect) frame -// { -// self = [super initWithFrame:frame]; -// if (self) { -// _savedSubviews = nil; -// _subviewsSetAside = NO; -// [self _setDrawsOwnDescendants:YES]; -// } -// return self; -// } - -// - (void) _setAsideSubviews -// { -// #ifdef TK_MAC_DEBUG -// if (_subviewsSetAside || _savedSubviews) { -// Tcl_Panic("TKContentView _setAsideSubviews called incorrectly"); -// } -// #endif -// _savedSubviews = _subviews; -// _subviews = nil; -// _subviewsSetAside = YES; -// } - -// - (void) _restoreSubviews -// { -// #ifdef TK_MAC_DEBUG -// if (!_subviewsSetAside || _subviews) { -// Tcl_Panic("TKContentView _restoreSubviews called incorrectly"); -// } -// #endif -// _subviews = _savedSubviews; -// _savedSubviews = nil; -// _subviewsSetAside = NO; -// } - -// - (void) _recursiveDisplayRectIfNeededIgnoringOpacity: (NSRect) rect -// isVisibleRect: (BOOL) isVisibleRect -// rectIsVisibleRectForView: (NSView *) visibleView -// topView: (BOOL) topView -// { -// [self _setAsideSubviews]; -// [super _recursiveDisplayRectIfNeededIgnoringOpacity:rect -// isVisibleRect:isVisibleRect rectIsVisibleRectForView:visibleView -// topView:topView]; -// [self _restoreSubviews]; -// } - -// - (void) _recursiveDisplayAllDirtyWithLockFocus: (BOOL) needsLockFocus -// visRect: (NSRect) visRect -// { -// BOOL needToSetAsideSubviews = !_subviewsSetAside; - -// if (needToSetAsideSubviews) { -// [self _setAsideSubviews]; -// } -// [super _recursiveDisplayAllDirtyWithLockFocus:needsLockFocus -// visRect:visRect]; -// if (needToSetAsideSubviews) { -// [self _restoreSubviews]; -// } -// } - -// - (void) _recursive: (BOOL) recurse -// displayRectIgnoringOpacity: (NSRect) displayRect -// inContext: (NSGraphicsContext *) context topView: (BOOL) topView -// { -// [self _setAsideSubviews]; -// [super _recursive:recurse -// displayRectIgnoringOpacity:displayRect inContext:context -// topView:topView]; -// [self _restoreSubviews]; -// } - -// - (void) _lightWeightRecursiveDisplayInRect: (NSRect) visRect -// { -// BOOL needToSetAsideSubviews = !_subviewsSetAside; - -// if (needToSetAsideSubviews) { -// [self _setAsideSubviews]; -// } -// [super _lightWeightRecursiveDisplayInRect:visRect]; -// if (needToSetAsideSubviews) { -// [self _restoreSubviews]; -// } -// } - -// - (BOOL) _drawRectIfEmpty -// { -// /* -// * Our -drawRect manages subview drawing directly, so it needs to be called -// * even if the area to be redrawn is completely obscured by subviews. -// */ - -// return YES; -// } - -// - (void) _drawRect: (NSRect) inRect clip: (BOOL) clip -// { -// #ifdef TK_MAC_DEBUG_DRAWING -// TKLog(@"-[%@(%p) %s%@]", [self class], self, _cmd, -// NSStringFromRect(inRect)); -// #endif -// BOOL subviewsWereSetAside = _subviewsSetAside; - -// if (subviewsWereSetAside) { -// [self _restoreSubviews]; -// } -// [super _drawRect:inRect clip:clip]; -// if (subviewsWereSetAside) { -// [self _setAsideSubviews]; -// } -// } - -// @end - /* * Local Variables: * mode: objc -- cgit v0.12 From b7987c124821dc0e85b656bc216b70d14a9ba57c Mon Sep 17 00:00:00 2001 From: dgp Date: Mon, 28 Jul 2014 14:54:20 +0000 Subject: Bump to 8.6.2 for release. --- README | 2 +- generic/tk.h | 4 ++-- library/tk.tcl | 2 +- unix/configure | 8 ++++---- unix/configure.in | 2 +- unix/tk.spec | 2 +- win/configure | 2 +- win/configure.in | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/README b/README index a76148f..ec84200 100644 --- a/README +++ b/README @@ -1,5 +1,5 @@ README: Tk - This is the Tk 8.6.1 source distribution. + This is the Tk 8.6.2 source distribution. http://sourceforge.net/projects/tcl/files/Tcl/ You can get any source release of Tk from the URL above. diff --git a/generic/tk.h b/generic/tk.h index 5d8bd0b..0e00ca2 100644 --- a/generic/tk.h +++ b/generic/tk.h @@ -75,10 +75,10 @@ extern "C" { #define TK_MAJOR_VERSION 8 #define TK_MINOR_VERSION 6 #define TK_RELEASE_LEVEL TCL_FINAL_RELEASE -#define TK_RELEASE_SERIAL 1 +#define TK_RELEASE_SERIAL 2 #define TK_VERSION "8.6" -#define TK_PATCH_LEVEL "8.6.1" +#define TK_PATCH_LEVEL "8.6.2" /* * A special definition used to allow this header file to be included from diff --git a/library/tk.tcl b/library/tk.tcl index 0110fe3..5f7a74e 100644 --- a/library/tk.tcl +++ b/library/tk.tcl @@ -13,7 +13,7 @@ # Insist on running with compatible version of Tcl package require Tcl 8.6 # Verify that we have Tk binary and script components from the same release -package require -exact Tk 8.6.1 +package require -exact Tk 8.6.2 # Create a ::tk namespace namespace eval ::tk { diff --git a/unix/configure b/unix/configure index f6544c3..b1b5267 100755 --- a/unix/configure +++ b/unix/configure @@ -1338,7 +1338,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu TK_VERSION=8.6 TK_MAJOR_VERSION=8 TK_MINOR_VERSION=6 -TK_PATCH_LEVEL=".1" +TK_PATCH_LEVEL=".2" VERSION=${TK_VERSION} LOCALES="cs da de el en en_gb eo es fr hu it nl pl pt ru sv" @@ -4852,7 +4852,7 @@ fi LD_SEARCH_FLAGS="" TCL_NEEDS_EXP_FILE=1 TCL_EXPORT_FILE_SUFFIX='${VERSION}\$\{DBGX\}.dll.a' - TCL_SHLIB_LD_EXTRAS='-Wl,--out-implib,$@.a' + SHLIB_LD_LIBS="${SHLIB_LD_LIBS} -Wl,--out-implib,$@.a" TK_SHLIB_LD_EXTRAS='-Wl,--out-implib,$@.a' echo "$as_me:$LINENO: checking for Cygwin version of gcc" >&5 echo $ECHO_N "checking for Cygwin version of gcc... $ECHO_C" >&6 @@ -5586,7 +5586,7 @@ fi # This configuration from FreeBSD Ports. SHLIB_CFLAGS="-fPIC" SHLIB_LD="${CC} -shared" - TCL_SHLIB_LD_EXTRAS="-Wl,-soname=\$@" + SHLIB_LD_LIBS="${SHLIB_LD_LIBS} -Wl,-soname=\$@" TK_SHLIB_LD_EXTRAS="-Wl,-soname,\$@" SHLIB_SUFFIX=".so" DL_OBJS="tclLoadDl.o" @@ -9635,7 +9635,7 @@ cat >>confdefs.h <<\_ACEOF _ACEOF LIBS="$LIBS -framework Cocoa -framework Carbon -framework IOKit" - EXTRA_CC_SWITCHES='-std=gnu99 -x objective-c ' + EXTRA_CC_SWITCHES='-std=gnu99 -x objective-c' TK_WINDOWINGSYSTEM=AQUA if test -n "${enable_symbols}" -a "${enable_symbols}" != no; then diff --git a/unix/configure.in b/unix/configure.in index 4527612..9b0180f 100644 --- a/unix/configure.in +++ b/unix/configure.in @@ -25,7 +25,7 @@ m4_ifdef([SC_USE_CONFIG_HEADERS], [ TK_VERSION=8.6 TK_MAJOR_VERSION=8 TK_MINOR_VERSION=6 -TK_PATCH_LEVEL=".1" +TK_PATCH_LEVEL=".2" VERSION=${TK_VERSION} LOCALES="cs da de el en en_gb eo es fr hu it nl pl pt ru sv" diff --git a/unix/tk.spec b/unix/tk.spec index cafad27..d2ca9d9 100644 --- a/unix/tk.spec +++ b/unix/tk.spec @@ -4,7 +4,7 @@ Name: tk Summary: Tk graphical toolkit for the Tcl scripting language. -Version: 8.6.1 +Version: 8.6.2 Release: 2 License: BSD Group: Development/Languages diff --git a/win/configure b/win/configure index 299be69..7eba14e 100755 --- a/win/configure +++ b/win/configure @@ -1312,7 +1312,7 @@ SHELL=/bin/sh TK_VERSION=8.6 TK_MAJOR_VERSION=8 TK_MINOR_VERSION=6 -TK_PATCH_LEVEL=".1" +TK_PATCH_LEVEL=".2" VER=$TK_MAJOR_VERSION$TK_MINOR_VERSION #------------------------------------------------------------------------ diff --git a/win/configure.in b/win/configure.in index 50efa8d..3fedbf6 100644 --- a/win/configure.in +++ b/win/configure.in @@ -14,7 +14,7 @@ SHELL=/bin/sh TK_VERSION=8.6 TK_MAJOR_VERSION=8 TK_MINOR_VERSION=6 -TK_PATCH_LEVEL=".1" +TK_PATCH_LEVEL=".2" VER=$TK_MAJOR_VERSION$TK_MINOR_VERSION #------------------------------------------------------------------------ -- cgit v0.12 From 641b317cbd760a8d3676fff03a903c8c294410d0 Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Fri, 1 Aug 2014 01:00:11 +0000 Subject: Fix for font configure crash on OS X, thanks to rob@bitkeeper.com for the patch --- generic/tkFont.c | 66 +++++++++++++++++++++++++-------------------------- macosx/tkMacOSXFont.c | 2 +- macosx/tkMacOSXMenu.c | 3 +++ 3 files changed, 37 insertions(+), 34 deletions(-) diff --git a/generic/tkFont.c b/generic/tkFont.c index cbc4cf4..a955c35 100644 --- a/generic/tkFont.c +++ b/generic/tkFont.c @@ -600,40 +600,40 @@ Tk_FontObjCmd( return result; } case FONT_CONFIGURE: { - int result; - const char *string; - Tcl_Obj *objPtr; - NamedFont *nfPtr; - Tcl_HashEntry *namedHashPtr; - - if (objc < 3) { - Tcl_WrongNumArgs(interp, 2, objv, "fontname ?-option value ...?"); - return TCL_ERROR; - } - string = Tcl_GetString(objv[2]); - namedHashPtr = Tcl_FindHashEntry(&fiPtr->namedTable, string); + int result; + const char *string; + Tcl_Obj *objPtr; + NamedFont *nfPtr; + Tcl_HashEntry *namedHashPtr; + + if (objc < 3) { + Tcl_WrongNumArgs(interp, 2, objv, "fontname ?-option value ...?"); + return TCL_ERROR; + } + string = Tcl_GetString(objv[2]); + namedHashPtr = Tcl_FindHashEntry(&fiPtr->namedTable, string); nfPtr = NULL; /* lint. */ - if (namedHashPtr != NULL) { - nfPtr = Tcl_GetHashValue(namedHashPtr); - } - if ((namedHashPtr == NULL) || nfPtr->deletePending) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "named font \"%s\" doesn't exist", string)); - Tcl_SetErrorCode(interp, "TK", "LOOKUP", "FONT", string, NULL); - return TCL_ERROR; - } - if (objc == 3) { - objPtr = NULL; - } else if (objc == 4) { - objPtr = objv[3]; - } else { - result = ConfigAttributesObj(interp, tkwin, objc - 3, objv + 3, - &nfPtr->fa); - UpdateDependentFonts(fiPtr, tkwin, namedHashPtr); - return result; - } - return GetAttributeInfoObj(interp, &nfPtr->fa, objPtr); - } + if (namedHashPtr != NULL) { + nfPtr = Tcl_GetHashValue(namedHashPtr); + } + if ((namedHashPtr == NULL) || nfPtr->deletePending) { + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "named font \"%s\" doesn't exist", string)); + Tcl_SetErrorCode(interp, "TK", "LOOKUP", "FONT", string, NULL); + return TCL_ERROR; + } + if (objc == 3) { + objPtr = NULL; + } else if (objc == 4) { + objPtr = objv[3]; + } else { + result = ConfigAttributesObj(interp, tkwin, objc - 3, objv + 3, + &nfPtr->fa); + UpdateDependentFonts(fiPtr, tkwin, namedHashPtr); + return result; + } + return GetAttributeInfoObj(interp, &nfPtr->fa, objPtr); + } case FONT_CREATE: { int skip = 3, i; const char *name; diff --git a/macosx/tkMacOSXFont.c b/macosx/tkMacOSXFont.c index d800ae5..4c8ac30 100644 --- a/macosx/tkMacOSXFont.c +++ b/macosx/tkMacOSXFont.c @@ -293,7 +293,7 @@ InitFont( [NSNumber numberWithInt:fmPtr->fixed ? 0 : 1], NSLigatureAttributeName, [NSNumber numberWithDouble:kern], NSKernAttributeName, nil]; - fontPtr->nsAttributes = TkMacOSXMakeUncollectableAndRetain(nsAttributes); + fontPtr->nsAttributes = TkMacOSXMakeUncollectableAndRetain(nsAttributes); #undef nCh } diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c index 83ad47a..313a5cf 100644 --- a/macosx/tkMacOSXMenu.c +++ b/macosx/tkMacOSXMenu.c @@ -684,6 +684,9 @@ TkpConfigureMenuEntry( NSArray *itemArray = [submenu itemArray]; for (NSMenuItem *item in itemArray) { TkMenuEntry *submePtr = menuRefPtr->menuPtr->entries[i]; + /* Work around an apparent bug where itemArray can have + more items than the menu's entries[] array. */ + if (i >= menuRefPtr->menuPtr->numEntries) break; [item setEnabled: !(submePtr->state == ENTRY_DISABLED)]; i++; } -- cgit v0.12 From fc2388482a673cedc13b2e7a060175259243a33f Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Mon, 4 Aug 2014 21:14:32 +0000 Subject: Further refinement of Mac OS X scrolling; thanks to Marc Culler for an additional patch. --- macosx/tkMacOSXDraw.c | 46 +++++---------------------------------------- macosx/tkMacOSXSubwindows.c | 14 +++++++++----- 2 files changed, 14 insertions(+), 46 deletions(-) diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index 6eef09d..40400c2 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -1460,12 +1460,12 @@ XMaxRequestSize( * a damage region. * * Results: - * Returns 0 if the scroll genereated no additional damage. + * Returns 0 if the scroll generated no additional damage. * Otherwise, sets the region that needs to be repainted after * scrolling and returns 1. * * Side effects: - * Scrolls the bits in the window. + * Scrolls the rectangle in the window. * *---------------------------------------------------------------------- */ @@ -1518,51 +1518,15 @@ TkScrollWindow( /* Scroll the rectangle. */ [view scrollRect:NSRectFromCGRect(scroll_src) by:NSMakeSize(dx, -dy)]; [view displayRect:NSRectFromCGRect(scroll_dst)]; - - /* - * When a Text widget contains embedded images, scrolling generates - * lots of artifacts involving multiple copies of the images - * displayed on top of each other. Extensive experimentation, with - * very little help from the Apple documentation, indicates that - * whenever an image is displayed it gets added as a subview, which - * then gets automatically redisplayed in its original location. - * - * We do two things to combat this. First, each subview that meets - * the scroll area is added as a damage rectangle. Second, we - * redisplay the subviews after the scroll. - */ - - /* - * Step 1: Find any subviews that meet the scroll area and mark - * them as damaged. Use Tk coordinates, shifted to account for the - * future scrolling. - */ - - for (NSView *subview in [view subviews] ) { - NSRect frame = [subview frame]; - CGRect subviewRect = CGRectMake( - frame.origin.x - macDraw->xOff + dx, - (bounds.size.height - frame.origin.y - frame.size.height) - macDraw->yOff + dy, - frame.size.width, frame.size.height); - /* Rectangles with negative coordinates seem to cause trouble. */ - if (subviewRect.origin.y < 0 && subviewRect.origin.y + subviewRect.size.height > 0) { - subviewRect.origin.y = 0; - } - CGRect intersection = CGRectIntersection(srcRect, subviewRect); - if (! CGRectIsEmpty(intersection) ){ - dstRgn = HIShapeCreateWithRect(&subviewRect); - ChkErr(HIShapeUnion, dmgRgn, dstRgn, (HIMutableShapeRef) dmgRgn); - CFRelease(dstRgn); - } - } - } } + + if ( dmgRgn == NULL ) { dmgRgn = HIShapeCreateEmpty(); } - //TkMacOSXInvalidateViewRegion(view, dmgRgn); + TkMacOSXSetWithNativeRegion(damageRgn, dmgRgn); result = HIShapeIsEmpty(dmgRgn) ? 0 : 1; CFRelease(dmgRgn); diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c index 9ba7100..e4af406 100644 --- a/macosx/tkMacOSXSubwindows.c +++ b/macosx/tkMacOSXSubwindows.c @@ -651,7 +651,7 @@ XConfigureWindow( * * TkMacOSXUpdateClipRgn -- * - * This function updates the cliping regions for a given window and all of + * This function updates the clipping regions for a given window and all of * its children. Once updated the TK_CLIP_INVALID flag in the subwindow * data structure is unset. The TK_CLIP_INVALID flag should always be * unset before any drawing is attempted. @@ -677,7 +677,7 @@ TkMacOSXUpdateClipRgn( macWin = winPtr->privatePtr; if (macWin && macWin->flags & TK_CLIP_INVALID) { TkWindow *win2Ptr; - + #ifdef TK_MAC_DEBUG_CLIP_REGIONS TkMacOSXDbgMsg("%s", winPtr->pathName); #endif @@ -818,7 +818,7 @@ TkMacOSXUpdateClipRgn( * * TkMacOSXVisableClipRgn -- * - * This function returns the Macintosh cliping region for the given + * This function returns the Macintosh clipping region for the given * window. The caller is responsible for disposing of the returned * region via TkDestroyRegion(). * @@ -913,7 +913,7 @@ TkMacOSXInvalidateWindow( * TK_PARENT_WINDOW */ { #ifdef TK_MAC_DEBUG_CLIP_REGIONS - TkMacOSXDbgMsg("%s", winPtr->pathName); + TkMacOSXDbgMsg("%s", macWin->winPtr->pathName); #endif if (macWin->flags & TK_CLIP_INVALID) { TkMacOSXUpdateClipRgn(macWin->winPtr); @@ -1071,7 +1071,7 @@ TkMacOSXGetRootControl( * None. * * Side effects: - * The cliping regions for the window and its children are mark invalid. + * The clipping regions for the window and its children are marked invalid. * (Make sure they are valid before drawing.) * *---------------------------------------------------------------------- @@ -1090,6 +1090,10 @@ TkMacOSXInvalClipRgns( * be marked. */ +#ifdef TK_MAC_DEBUG_CLIP_REGIONS + TkMacOSXDbgMsg("%s", winPtr->pathName); +#endif + if (!macWin || macWin->flags & TK_CLIP_INVALID) { return; } -- cgit v0.12 From 57ad1cd7057d0a9bd8ba4ca1465a9bc44e5b20e4 Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Mon, 11 Aug 2014 03:12:28 +0000 Subject: Further refinement of scrolling; addresses artifacts in scrolling complex interfaces on OS X --- macosx/tkMacOSXDraw.c | 43 ++++++++++++++++++++++++++++++++++++++++--- macosx/tkMacOSXSubwindows.c | 14 +++++--------- 2 files changed, 45 insertions(+), 12 deletions(-) diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index 40400c2..6631b4f 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -1460,12 +1460,12 @@ XMaxRequestSize( * a damage region. * * Results: - * Returns 0 if the scroll generated no additional damage. + * Returns 0 if the scroll genereated no additional damage. * Otherwise, sets the region that needs to be repainted after * scrolling and returns 1. * * Side effects: - * Scrolls the rectangle in the window. + * Scrolls the bits in the window. * *---------------------------------------------------------------------- */ @@ -1518,9 +1518,46 @@ TkScrollWindow( /* Scroll the rectangle. */ [view scrollRect:NSRectFromCGRect(scroll_src) by:NSMakeSize(dx, -dy)]; [view displayRect:NSRectFromCGRect(scroll_dst)]; + + /* + * When a Text widget contains embedded images, scrolling generates + * lots of artifacts involving multiple copies of the images + * displayed on top of each other. Extensive experimentation, with + * very little help from the Apple documentation, indicates that + * whenever an image is displayed it gets added as a subview, which + * then gets automatically redisplayed in its original location. + * + * We do two things to combat this. First, each subview that meets + * the scroll area is added as a damage rectangle. Second, we + * redisplay the subviews after the scroll. + */ + + /* + * Step 1: Find any subviews that meet the scroll area and mark + * them as damaged. Use Tk coordinates, shifted to account for the + * future scrolling. + */ + + for (NSView *subview in [view subviews] ) { + NSRect frame = [subview frame]; + CGRect subviewRect = CGRectMake( + frame.origin.x - macDraw->xOff + dx, + (bounds.size.height - frame.origin.y - frame.size.height) - macDraw->yOff + dy, + frame.size.width, frame.size.height); + /* Rectangles with negative coordinates seem to cause trouble. */ + if (subviewRect.origin.y < 0 && subviewRect.origin.y + subviewRect.size.height > 0) { + subviewRect.origin.y = 0; + } + CGRect intersection = CGRectIntersection(srcRect, subviewRect); + if (! CGRectIsEmpty(intersection) ){ + dstRgn = HIShapeCreateWithRect(&subviewRect); + ChkErr(HIShapeUnion, dmgRgn, dstRgn, (HIMutableShapeRef) dmgRgn); + CFRelease(dstRgn); + } + } + } } - if ( dmgRgn == NULL ) { diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c index e4af406..9ba7100 100644 --- a/macosx/tkMacOSXSubwindows.c +++ b/macosx/tkMacOSXSubwindows.c @@ -651,7 +651,7 @@ XConfigureWindow( * * TkMacOSXUpdateClipRgn -- * - * This function updates the clipping regions for a given window and all of + * This function updates the cliping regions for a given window and all of * its children. Once updated the TK_CLIP_INVALID flag in the subwindow * data structure is unset. The TK_CLIP_INVALID flag should always be * unset before any drawing is attempted. @@ -677,7 +677,7 @@ TkMacOSXUpdateClipRgn( macWin = winPtr->privatePtr; if (macWin && macWin->flags & TK_CLIP_INVALID) { TkWindow *win2Ptr; - + #ifdef TK_MAC_DEBUG_CLIP_REGIONS TkMacOSXDbgMsg("%s", winPtr->pathName); #endif @@ -818,7 +818,7 @@ TkMacOSXUpdateClipRgn( * * TkMacOSXVisableClipRgn -- * - * This function returns the Macintosh clipping region for the given + * This function returns the Macintosh cliping region for the given * window. The caller is responsible for disposing of the returned * region via TkDestroyRegion(). * @@ -913,7 +913,7 @@ TkMacOSXInvalidateWindow( * TK_PARENT_WINDOW */ { #ifdef TK_MAC_DEBUG_CLIP_REGIONS - TkMacOSXDbgMsg("%s", macWin->winPtr->pathName); + TkMacOSXDbgMsg("%s", winPtr->pathName); #endif if (macWin->flags & TK_CLIP_INVALID) { TkMacOSXUpdateClipRgn(macWin->winPtr); @@ -1071,7 +1071,7 @@ TkMacOSXGetRootControl( * None. * * Side effects: - * The clipping regions for the window and its children are marked invalid. + * The cliping regions for the window and its children are mark invalid. * (Make sure they are valid before drawing.) * *---------------------------------------------------------------------- @@ -1090,10 +1090,6 @@ TkMacOSXInvalClipRgns( * be marked. */ -#ifdef TK_MAC_DEBUG_CLIP_REGIONS - TkMacOSXDbgMsg("%s", winPtr->pathName); -#endif - if (!macWin || macWin->flags & TK_CLIP_INVALID) { return; } -- cgit v0.12 From ab19054c699a4edb7222aafe4595c79a139d4fe4 Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Thu, 14 Aug 2014 02:41:52 +0000 Subject: Allow Tk to post popup menus when Tk app is not frontmost --- macosx/tkMacOSXMenu.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c index 313a5cf..a8e9f2f 100644 --- a/macosx/tkMacOSXMenu.c +++ b/macosx/tkMacOSXMenu.c @@ -757,10 +757,18 @@ TkpPostMenu( * to be posted. */ int y) /* The global y-coordinate */ { - NSWindow *win = [NSApp keyWindow]; - if (!win) { + + + /* Get the object that holds this Tk Window.*/ + Tk_Window root; + root = Tk_MainWindow(interp); + if (root == NULL) { return TCL_ERROR; } + + Drawable d = Tk_WindowId(root); + NSView *rootview = TkMacOSXGetRootControl(d); + NSWindow *win = [rootview window]; inPostMenu = 1; -- cgit v0.12 From 42f946fb1df90d38c04c7b68cf1fd3aca9377d6f Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Sat, 16 Aug 2014 00:52:12 +0000 Subject: Fix for shimmering of buttons embedded when scrolled in text and canvas widgets; improvements in scrolling smoothness in text widget. Thanks to Marc Culler for patches. --- generic/tkTextDisp.c | 11 +++- macosx/tkMacOSXButton.c | 163 ++++++++++++++++++++++++++++++++++++++++++------ macosx/tkMacOSXDraw.c | 132 +++++++++++++++++---------------------- macosx/tkMacOSXInt.h | 3 +- 4 files changed, 213 insertions(+), 96 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index aebdcc6..8ceb3fa 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -3970,6 +3970,15 @@ DisplayText( UpdateDisplayInfo(textPtr); dInfoPtr->dLinesInvalidated = 0; +#ifdef MAC_OSX_TK + /* + * Make sure that unmapped subwindows really have been unmapped. + * If the unmap request is pending as an idle request, the window + * can get redrawn on top of the widget. + */ + while (Tcl_DoOneEvent(TCL_IDLE_EVENTS|TCL_DONT_WAIT)) {} +#endif + /* * See if it's possible to bring some parts of the screen up-to-date by * scrolling (copying from other parts of the screen). We have to be @@ -4035,7 +4044,7 @@ DisplayText( */ if ((y + height) > dInfoPtr->maxY) { - height = dInfoPtr->maxY -y; + height = dInfoPtr->maxY - y; } oldY = dlPtr->oldY; if (y < dInfoPtr->y) { diff --git a/macosx/tkMacOSXButton.c b/macosx/tkMacOSXButton.c index 036624d..dd4cca7 100644 --- a/macosx/tkMacOSXButton.c +++ b/macosx/tkMacOSXButton.c @@ -7,6 +7,7 @@ * Copyright (c) 1996-1997 by Sun Microsystems, Inc. * Copyright 2001-2009, Apple Inc. * Copyright (c) 2006-2009 Daniel A. Steffen + * Copyright 2014 Marc Culler. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. @@ -23,9 +24,59 @@ #endif */ +static NSRect TkMacOSXGetButtonFrame(TkButton *butPtr); + +/* + * A subclass of NSButton with sanity checking: + * NSButtons created by Tk will have their tag set to a pointer to the TkButton + * which manages the NSButton. This allows a TkNSButton to be aware of the + * state of its Tk parent. This subclass overrides the drawRect method + * so that it will not draw itself unless the NSButton frame matches + * the frame which was installed by DisplayButton, and the TkButton is + * mapped. Also, it will not draw anything if the widget is completely + * outside of its container. + */ + +@interface TkNSButton: NSButton + +@end + +@implementation TkNSButton + + - (void)drawRect:(NSRect)dirtyRect + { + NSInteger tag = [self tag]; + if ( tag != -1) { + TkButton *butPtr = (TkButton *)tag; + MacDrawable* macWin = (MacDrawable *)butPtr; + NSRect Tkframe = TkMacOSXGetButtonFrame(butPtr); + Tk_Window tkwin = butPtr->tkwin; + /* Do not draw if the widget is misplaced or unmapped. */ + if ( NSIsEmptyRect(Tkframe) || + ! macWin->winPtr->flags & TK_MAPPED || + ! NSEqualRects(Tkframe, [self frame]) + ) { + return; + } + /* Do not draw if the widget is completely outside of its parent, or within 20 pixels of the lower border; this prevents buttons from being drawn on peer widgets as scrolling occurs. */ + if (tkwin) { + int parent_height = Tk_Height(Tk_Parent(tkwin)); + int widget_height = Tk_Height(tkwin); + int y = Tk_Y(tkwin); + if ( y > parent_height - 20 || y + widget_height < 0 ) { + return; + } + } + [super drawRect:dirtyRect]; + } + } + +@end + + typedef struct MacButton { TkButton info; - NSButton *button; + TkNSButton *button; NSImage *image, *selectImage, *tristateImage; #if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS int fix; @@ -186,6 +237,45 @@ TkpDisplayButton( /* *---------------------------------------------------------------------- * + * TkpShiftButton -- + * + * Moves the frame of an NSButton (or TkNSButton) and in case the tag is + * set, also adjusts the xOff and yOff of the controlling TkButton's + * MacDrawable. This is used to avoid jitter when scrolling. + * + * Results: + * None + * + * Side effects: + * Moves the NSbutton after adjusting the associated MacDrawable. + * + *---------------------------------------------------------------------- + */ +void +TkpShiftButton( + NSButton *button, + NSPoint delta ) + { + NSPoint origin = [button frame].origin; + NSInteger tag = [button tag]; + if ( tag != -1) { + TkButton* butPtr = (TkButton *)tag; + TkWindow *winPtr = (TkWindow *) (butPtr->tkwin); + if (winPtr) { + MacDrawable *macWin = (MacDrawable *) winPtr->window; + macWin->xOff += delta.x; + macWin->yOff += delta.y; + } + } + origin.x += delta.x; + origin.y -= delta.y; + [button setFrameOrigin:origin]; + } + + +/* + *---------------------------------------------------------------------- + * * TkpComputeButtonGeometry -- * * After changes in a button's text or bitmap, this procedure @@ -218,7 +308,8 @@ TkpComputeButtonGeometry( case TYPE_CHECK_BUTTON: case TYPE_RADIO_BUTTON: if (!macButtonPtr->button) { - NSButton *button = [[NSButton alloc] initWithFrame:NSZeroRect]; + TkNSButton *button = [[TkNSButton alloc] initWithFrame:NSZeroRect]; + [button setTag:(NSInteger)butPtr]; macButtonPtr->button = TkMacOSXMakeUncollectable(button); } ComputeNativeButtonGeometry(butPtr); @@ -266,6 +357,52 @@ TkpButtonSetDefaults() /* *---------------------------------------------------------------------- * + * TkMacOSXGetButtonFrame -- + * + * Computes a frame for an NSButton that will correspond to where + * Tk thinks the button is located. + * + * Results: + * Returns an NSRect describing a frame for an NSButton. + * + * Side effects: + * None + * + *---------------------------------------------------------------------- + */ +NSRect TkMacOSXGetButtonFrame( + TkButton *butPtr) +{ + MacButton *macButtonPtr = (MacButton *) butPtr; + Tk_Window tkwin = butPtr->tkwin; + TkWindow *winPtr = (TkWindow *) tkwin; + if (tkwin) { + MacDrawable *macWin = (MacDrawable *) winPtr->window; + NSView *view = TkMacOSXDrawableView(macWin); + CGFloat viewHeight = [view bounds].size.height; + NSRect frame = NSMakeRect(macWin->xOff, macWin->yOff, + Tk_Width(tkwin), Tk_Height(tkwin)); + +#if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS + if (tkMacOSXUseCompatibilityMetrics) { + BoundsFix boundsFix = boundsFixes[macButtonPtr->fix]; + frame = NSOffsetRect(frame, boundsFix.offsetX, boundsFix.offsetY); + frame.size.height -= boundsFix.shrinkH + NATIVE_BUTTON_EXTRA_H; + frame = NSInsetRect(frame, boundsFix.inset + NATIVE_BUTTON_INSET, + boundsFix.inset + NATIVE_BUTTON_INSET); + } +#endif + + frame.origin.y = viewHeight - (frame.origin.y + frame.size.height); + return frame; + } else { + return NSZeroRect; + } +} + +/* + *---------------------------------------------------------------------- + * * DisplayNativeButton -- * * This procedure is invoked to display a button widget. It is @@ -286,7 +423,7 @@ DisplayNativeButton( TkButton *butPtr) { MacButton *macButtonPtr = (MacButton *) butPtr; - NSButton *button = macButtonPtr->button; + TkNSButton *button = macButtonPtr->button; Tk_Window tkwin = butPtr->tkwin; TkWindow *winPtr = (TkWindow *) tkwin; MacDrawable *macWin = (MacDrawable *) winPtr->window; @@ -349,21 +486,8 @@ DisplayNativeButton( } else { [button setKeyEquivalent:@""]; } - frame = NSMakeRect(macWin->xOff, macWin->yOff, Tk_Width(tkwin), - Tk_Height(tkwin)); -#if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS - if (tkMacOSXUseCompatibilityMetrics) { - BoundsFix boundsFix = boundsFixes[macButtonPtr->fix]; - frame = NSOffsetRect(frame, boundsFix.offsetX, boundsFix.offsetY); - frame.size.height -= boundsFix.shrinkH + NATIVE_BUTTON_EXTRA_H; - frame = NSInsetRect(frame, boundsFix.inset + NATIVE_BUTTON_INSET, - boundsFix.inset + NATIVE_BUTTON_INSET); - } -#endif - frame.origin.y = viewHeight - (frame.origin.y + frame.size.height); - if (!NSEqualRects(frame, [button frame])) { - [button setFrame:frame]; - } + frame = TkMacOSXGetButtonFrame(butPtr); + [button setFrame:frame]; [button displayRectIgnoringOpacity:[button bounds]]; TkMacOSXRestoreDrawingContext(&dc); #ifdef TK_MAC_DEBUG_BUTTON @@ -396,7 +520,7 @@ ComputeNativeButtonGeometry( TkButton *butPtr) /* Button whose geometry may have changed. */ { MacButton *macButtonPtr = (MacButton *) butPtr; - NSButton *button = macButtonPtr->button; + TkNSButton *button = macButtonPtr->button; NSButtonCell *cell = [button cell]; NSButtonType type = -1; NSBezelStyle style = 0; @@ -1169,6 +1293,7 @@ ComputeUnixButtonGeometry( Tk_SetInternalBorder(butPtr->tkwin, butPtr->inset); } + /* * Local Variables: * mode: objc diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index 3a3e288..ce8bf9b 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -17,6 +17,7 @@ #include "tkMacOSXPrivate.h" #include "tkMacOSXDebug.h" #include "xbytes.h" +#include "tkButton.h" /* #ifdef TK_MAC_DEBUG @@ -1479,86 +1480,67 @@ TkScrollWindow( TkRegion damageRgn) /* Region to accumulate damage in. */ { Drawable drawable = Tk_WindowId(tkwin); - MacDrawable *macDraw = (MacDrawable *) drawable; + MacDrawable *macDraw = (MacDrawable *) drawable; NSView *view = TkMacOSXDrawableView(macDraw); - CGRect visRect, srcRect, dstRect, scroll_src, scroll_dst; - HIShapeRef dmgRgn = NULL; - NSRect bounds; + CGRect srcRect, dstRect; + HIShapeRef dmgRgn = NULL, extraRgn; + NSRect bounds, visRect, scrollSrc, scrollDst; + NSPoint delta = NSMakePoint(dx, dy); int result; - + if ( view ) { - /* Get the scroll area in NSView coordinates (origin at bottom left). */ - bounds = [view bounds]; - scroll_src = CGRectMake( - macDraw->xOff + x, - bounds.size.height - height - (macDraw->yOff + y), - width, height); - scroll_dst = CGRectOffset(scroll_src, dx, -dy); - /* Limit scrolling to the window content area. */ - visRect = NSRectToCGRect([view visibleRect]); - scroll_src = CGRectIntersection(scroll_src, visRect); - scroll_dst = CGRectIntersection(scroll_dst, visRect); - - if ( !CGRectIsEmpty(scroll_src) && !CGRectIsEmpty(scroll_dst) ) { - - /* - * Mark the difference between source and destination as damaged. - * This region is described in the Tk coordinate system, after shifting by dy. - */ - - srcRect = CGRectMake(x - macDraw->xOff, y - macDraw->yOff, - width, height); - dstRect = CGRectOffset(srcRect, dx, dy); - dmgRgn = HIShapeCreateMutableWithRect(&srcRect); - HIShapeRef dstRgn = HIShapeCreateWithRect(&dstRect); - ChkErr(HIShapeDifference, dmgRgn, dstRgn, (HIMutableShapeRef) dmgRgn); - CFRelease(dstRgn); - - /* Scroll the rectangle. */ - [view scrollRect:NSRectFromCGRect(scroll_src) by:NSMakeSize(dx, -dy)]; - [view displayRect:NSRectFromCGRect(scroll_dst)]; - - /* - * When a Text widget contains embedded images, scrolling generates - * lots of artifacts involving multiple copies of the images - * displayed on top of each other. Extensive experimentation, with - * very little help from the Apple documentation, indicates that - * whenever an image is displayed it gets added as a subview, which - * then gets automatically redisplayed in its original location. - * - * We do two things to combat this. First, each subview that meets - * the scroll area is added as a damage rectangle. Second, we - * redisplay the subviews after the scroll. - */ - - /* - * Step 1: Find any subviews that meet the scroll area and mark - * them as damaged. Use Tk coordinates, shifted to account for the - * future scrolling. - */ - - for (NSView *subview in [view subviews] ) { - NSRect frame = [subview frame]; - CGRect subviewRect = CGRectMake( - frame.origin.x - macDraw->xOff + dx, - (bounds.size.height - frame.origin.y - frame.size.height) - macDraw->yOff + dy, - frame.size.width, frame.size.height); - /* Rectangles with negative coordinates seem to cause trouble. */ - if (subviewRect.origin.y < 0 && subviewRect.origin.y + subviewRect.size.height > 0) { - subviewRect.origin.y = 0; - } - CGRect intersection = CGRectIntersection(srcRect, subviewRect); - if (! CGRectIsEmpty(intersection) ){ - dstRgn = HIShapeCreateWithRect(&subviewRect); - ChkErr(HIShapeUnion, dmgRgn, dstRgn, (HIMutableShapeRef) dmgRgn); - CFRelease(dstRgn); - } - } - } + /* Get the scroll area in NSView coordinates (origin at bottom left). */ + bounds = [view bounds]; + scrollSrc = NSMakeRect( + macDraw->xOff + x, + bounds.size.height - height - (macDraw->yOff + y), + width, height); + scrollDst = NSOffsetRect(scrollSrc, dx, -dy); + /* Limit scrolling to the window content area. */ + visRect = [view visibleRect]; + scrollSrc = NSIntersectionRect(scrollSrc, visRect); + scrollDst = NSIntersectionRect(scrollDst, visRect); + + if ( !NSIsEmptyRect(scrollSrc) && !NSIsEmptyRect(scrollDst) ) { + + /* + * Mark the difference between source and destination as damaged. + * This region is described in the Tk coordinate system. + */ + + srcRect = CGRectMake(x, y, width, height); + dstRect = CGRectOffset(srcRect, dx, dy); + dmgRgn = HIShapeCreateMutableWithRect(&srcRect); + extraRgn = HIShapeCreateWithRect(&dstRect); + ChkErr(HIShapeDifference, dmgRgn, extraRgn, (HIMutableShapeRef) dmgRgn); + CFRelease(extraRgn); + + /* Scroll the rectangle. */ + [view scrollRect:scrollSrc by:NSMakeSize(dx, -dy)]; + + /* + * Adjust the positions of the button subwindows that meet the scroll + * area. + */ + + for (NSView *subview in [view subviews] ) { + if ( [subview isKindOfClass:[NSButton class]] == YES ) { + NSRect subframe = [subview frame]; + if ( NSIntersectsRect(scrollSrc, subframe) || + NSIntersectsRect(scrollDst, subframe) ) { + TkpShiftButton((NSButton *)subview, delta ); + } + } + } + + /* Redisplay the scrolled area. */ + [view displayRect:scrollDst]; + + } } - + if ( dmgRgn == NULL ) { - dmgRgn = HIShapeCreateEmpty(); + dmgRgn = HIShapeCreateEmpty(); } TkMacOSXSetWithNativeRegion(damageRgn, dmgRgn); result = HIShapeIsEmpty(dmgRgn) ? 0 : 1; diff --git a/macosx/tkMacOSXInt.h b/macosx/tkMacOSXInt.h index 813acce..249d5cf 100644 --- a/macosx/tkMacOSXInt.h +++ b/macosx/tkMacOSXInt.h @@ -24,6 +24,7 @@ #ifndef _TKMAC #include "tkMacOSX.h" +#import #endif /* @@ -196,7 +197,7 @@ MODULE_SCOPE void TkpClipDrawableToRect(Display *display, Drawable d, int x, int y, int width, int height); MODULE_SCOPE void TkpRetainRegion(TkRegion r); MODULE_SCOPE void TkpReleaseRegion(TkRegion r); - +MODULE_SCOPE void TkpShiftButton(NSButton *button, NSPoint delta); /* * Include the stubbed internal platform-specific API. */ -- cgit v0.12 From db14088d3ee4f1d7d20760f3a2baf82d455eeea9 Mon Sep 17 00:00:00 2001 From: dgp Date: Tue, 19 Aug 2014 19:52:56 +0000 Subject: update changes file --- changes | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/changes b/changes index 3ddc4f9..b36125b 100644 --- a/changes +++ b/changes @@ -7073,3 +7073,51 @@ Many revisions to better support a Cygwin environment (nijtmans) 2013-08-25 (bug fix)[3016181] Cocoa: [destroy $scrollbar] => crash (goddard) --- Released 8.6.1, September 19, 2013 --- http://core.tcl.tk/tk/ for details + +2013-10-27 (bug fix) OSX drawing lags (deily,steffen,walzer) + +2013-10-28 (bug fix)[3603436] png wrong component indices (nijtmans) + +2013-10-31 (bug fix) C++ friendly stubs struct declarations (nijtmans) + +2013-10-31 (bug fix)[c0cc9fd] PNG parser accept uppercase -format (nijtmans) + +2013-10-31 (bug fix) double free of a TkFont (nijtmans) + +2013-11-03 (bug fix)[1632447] support PPM maxval up to 65535 (fellows) + +2013-11-05 (bug fix)[426679e] OpenBSD man page rendering (nijtmans) + +2013-11-11 (bug fix)[f214b8a] multi-interp font teardown double free (porter) + +2013-11-11 (bug fix)[0aa5e85] option file \n syntax support (nijtmans) + +2013-11-20 (platforms) Support for Windows 8.1 (nijtmans) + +2014-01-23 (bug fix)[3606644] X: correct fontconfig dependence (venable) + +2014-01-23 (bug fix) FreeBSD build fixes (cerutti) + +2014-02-06 (bug fix)[3279221] [menu] event race (danckaert,kupries) + +2014-02-07 (bug fix)[6867cc1] creative writing in [tk fontchooser] (nijtmans) + +2014-02-11 (bug fix)[52ca3e7] XkbOpenDisplay macro correction (nijtmans) + +2014-03-16 (bug fix) Xcode 5.1 update; Retina displays (walzer) + +2014-03-20 (bug fix)[2f7cbd0] FreeBSD 10.0 build failure (nijtmans) + +2014-04-01 (bug fix)[5bcb502] @TK_LIBS@ in pkgconfig (badshah400,nijtmans) + +2014-05-27 (bug fix)[a80f5d7] autoscroll initiation (crogers,english) + +2014-07-07 (bug fix) OSX alpha channel rendering (culler,walzer) + +2014-07-08 (workaround)[4955f5d] Ocaml trouble with tailcall splice (nijtmans) + +2014-07-24 (bug fix) OSX [text] image display & scrolling (culler,walzer) + +2014-08-01 (bug fix) OSX font config crash (rob@bitkeeper) + +--- Released 8.6.2, August, 2014 --- http://core.tcl.tk/tk/ for details -- cgit v0.12 From aca83c4e1ed14ccd906381e97504366c40f9e8f6 Mon Sep 17 00:00:00 2001 From: dgp Date: Fri, 22 Aug 2014 17:31:58 +0000 Subject: stamp release date --- changes | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changes b/changes index b36125b..d1b40e0 100644 --- a/changes +++ b/changes @@ -7120,4 +7120,4 @@ Many revisions to better support a Cygwin environment (nijtmans) 2014-08-01 (bug fix) OSX font config crash (rob@bitkeeper) ---- Released 8.6.2, August, 2014 --- http://core.tcl.tk/tk/ for details +--- Released 8.6.2, August 27, 2014 --- http://core.tcl.tk/tk/ for details -- cgit v0.12 From 7a83c408ff097f92d2dfbb97041336962322118a Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 26 Aug 2014 09:28:55 +0000 Subject: Fix build problem on Cygwin, caused by a mismatch between tcl.m4 and the generated configure script (configure script was correct) --- unix/tcl.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unix/tcl.m4 b/unix/tcl.m4 index a0f448b..3a59e4d 100644 --- a/unix/tcl.m4 +++ b/unix/tcl.m4 @@ -1217,7 +1217,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [ LD_SEARCH_FLAGS="" TCL_NEEDS_EXP_FILE=1 TCL_EXPORT_FILE_SUFFIX='${VERSION}\$\{DBGX\}.dll.a' - SHLIB_LD_LIBS="${SHLIB_LD_LIBS} -Wl,--out-implib,$[@].a" + TCL_SHLIB_LD_EXTRAS='-Wl,--out-implib,$[@].a' TK_SHLIB_LD_EXTRAS='-Wl,--out-implib,$[@].a' AC_CACHE_CHECK(for Cygwin version of gcc, ac_cv_cygwin, -- cgit v0.12 From a005af2cae512fc901d06236dc97190523de6bb5 Mon Sep 17 00:00:00 2001 From: hypnotoad Date: Wed, 27 Aug 2014 13:07:52 +0000 Subject: Fix for segfaults induced by the following script: button .b pack .b update destroy .b button .c update --- macosx/tkMacOSXButton.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/macosx/tkMacOSXButton.c b/macosx/tkMacOSXButton.c index dd4cca7..9250884 100644 --- a/macosx/tkMacOSXButton.c +++ b/macosx/tkMacOSXButton.c @@ -379,6 +379,9 @@ NSRect TkMacOSXGetButtonFrame( if (tkwin) { MacDrawable *macWin = (MacDrawable *) winPtr->window; NSView *view = TkMacOSXDrawableView(macWin); + if(view==nil) { + return NSZeroRect; + } CGFloat viewHeight = [view bounds].size.height; NSRect frame = NSMakeRect(macWin->xOff, macWin->yOff, Tk_Width(tkwin), Tk_Height(tkwin)); -- cgit v0.12 From 6f94865121c05acf2559f1edbd66914b04d9b189 Mon Sep 17 00:00:00 2001 From: hypnotoad Date: Wed, 27 Aug 2014 14:17:16 +0000 Subject: dgp's constant comparison fix --- macosx/tkMacOSXButton.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/macosx/tkMacOSXButton.c b/macosx/tkMacOSXButton.c index 9250884..bd5cedd 100644 --- a/macosx/tkMacOSXButton.c +++ b/macosx/tkMacOSXButton.c @@ -376,6 +376,9 @@ NSRect TkMacOSXGetButtonFrame( MacButton *macButtonPtr = (MacButton *) butPtr; Tk_Window tkwin = butPtr->tkwin; TkWindow *winPtr = (TkWindow *) tkwin; + if(tkwin==0xffffffff || tkwin==0xffffffff00000000) { + return NSZeroRect; + } if (tkwin) { MacDrawable *macWin = (MacDrawable *) winPtr->window; NSView *view = TkMacOSXDrawableView(macWin); -- cgit v0.12 From f519c380a7f8158faeaa67fc154cef64f4ac9a8e Mon Sep 17 00:00:00 2001 From: hypnotoad Date: Wed, 27 Aug 2014 14:22:55 +0000 Subject: An improvement on before --- macosx/tkMacOSXButton.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/macosx/tkMacOSXButton.c b/macosx/tkMacOSXButton.c index bd5cedd..4e7904c 100644 --- a/macosx/tkMacOSXButton.c +++ b/macosx/tkMacOSXButton.c @@ -375,8 +375,9 @@ NSRect TkMacOSXGetButtonFrame( { MacButton *macButtonPtr = (MacButton *) butPtr; Tk_Window tkwin = butPtr->tkwin; + unsigned short tkwint=(unsigned int)tkwin; TkWindow *winPtr = (TkWindow *) tkwin; - if(tkwin==0xffffffff || tkwin==0xffffffff00000000) { + if(tkwint==0xffffffff || tkwint==0) { return NSZeroRect; } if (tkwin) { -- cgit v0.12 From 94cd41bca17091f9de05687ef4cc17e70316238a Mon Sep 17 00:00:00 2001 From: hypnotoad Date: Wed, 27 Aug 2014 14:52:58 +0000 Subject: Fix from kevin_walzer for buttons in cocoa --- macosx/tkMacOSXButton.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/macosx/tkMacOSXButton.c b/macosx/tkMacOSXButton.c index 4e7904c..9858f88 100644 --- a/macosx/tkMacOSXButton.c +++ b/macosx/tkMacOSXButton.c @@ -186,6 +186,7 @@ TkpDestroyButton( TkButton *butPtr) { MacButton *macButtonPtr = (MacButton *) butPtr; + [macButtonPtr->button setTag:(NSInteger)-1]; TkMacOSXMakeCollectableAndRelease(macButtonPtr->button); TkMacOSXMakeCollectableAndRelease(macButtonPtr->selectImage); @@ -375,17 +376,10 @@ NSRect TkMacOSXGetButtonFrame( { MacButton *macButtonPtr = (MacButton *) butPtr; Tk_Window tkwin = butPtr->tkwin; - unsigned short tkwint=(unsigned int)tkwin; TkWindow *winPtr = (TkWindow *) tkwin; - if(tkwint==0xffffffff || tkwint==0) { - return NSZeroRect; - } if (tkwin) { MacDrawable *macWin = (MacDrawable *) winPtr->window; NSView *view = TkMacOSXDrawableView(macWin); - if(view==nil) { - return NSZeroRect; - } CGFloat viewHeight = [view bounds].size.height; NSRect frame = NSMakeRect(macWin->xOff, macWin->yOff, Tk_Width(tkwin), Tk_Height(tkwin)); -- cgit v0.12 From b5f3290552fc8c5b9c0db94e85bf8aaf4ec6e5ed Mon Sep 17 00:00:00 2001 From: hypnotoad Date: Wed, 27 Aug 2014 15:10:51 +0000 Subject: Apply a similar dealloc fix to menubutton --- macosx/tkMacOSXMenubutton.c | 1 + 1 file changed, 1 insertion(+) diff --git a/macosx/tkMacOSXMenubutton.c b/macosx/tkMacOSXMenubutton.c index d6e635a..df42763 100644 --- a/macosx/tkMacOSXMenubutton.c +++ b/macosx/tkMacOSXMenubutton.c @@ -116,6 +116,7 @@ TkpDestroyMenuButton( TkMenuButton *mbPtr) { MacMenuButton *macButtonPtr = (MacMenuButton *) mbPtr; + [macButtonPtr->button setTag:(NSInteger)-1]; TkMacOSXMakeCollectableAndRelease(macButtonPtr->button); } -- cgit v0.12