summaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
Diffstat (limited to 'unix')
-rw-r--r--unix/Makefile.in186
-rwxr-xr-xunix/configure678
-rw-r--r--unix/configure.in55
-rw-r--r--[-rwxr-xr-x]unix/install-sh0
-rwxr-xr-xunix/installManPage7
-rw-r--r--unix/tcl.m4275
-rw-r--r--unix/tk.spec6
-rw-r--r--unix/tkAppInit.c75
-rw-r--r--unix/tkConfig.h.in29
-rw-r--r--unix/tkUnix.c38
-rw-r--r--unix/tkUnix3d.c15
-rw-r--r--unix/tkUnixButton.c15
-rw-r--r--unix/tkUnixColor.c40
-rw-r--r--unix/tkUnixConfig.c4
-rw-r--r--unix/tkUnixCursor.c116
-rw-r--r--unix/tkUnixDefault.h65
-rw-r--r--unix/tkUnixDialog.c18
-rw-r--r--unix/tkUnixDraw.c11
-rw-r--r--unix/tkUnixEmbed.c243
-rw-r--r--unix/tkUnixEvent.c58
-rw-r--r--unix/tkUnixFont.c502
-rw-r--r--unix/tkUnixInit.c11
-rw-r--r--unix/tkUnixKey.c63
-rw-r--r--unix/tkUnixMenu.c133
-rw-r--r--unix/tkUnixMenubu.c13
-rw-r--r--unix/tkUnixPort.h26
-rw-r--r--unix/tkUnixRFont.c421
-rw-r--r--unix/tkUnixScale.c25
-rw-r--r--unix/tkUnixScrlbr.c29
-rw-r--r--unix/tkUnixSelect.c217
-rw-r--r--unix/tkUnixSend.c188
-rw-r--r--unix/tkUnixWm.c1206
-rw-r--r--unix/tkUnixXId.c473
33 files changed, 2678 insertions, 2563 deletions
diff --git a/unix/Makefile.in b/unix/Makefile.in
index 30ba378..f21fdbb 100644
--- a/unix/Makefile.in
+++ b/unix/Makefile.in
@@ -8,6 +8,7 @@
# Current Tk version; used in various names.
TCLVERSION = @TCL_VERSION@
+TCLPATCHL = @TCL_PATCH_LEVEL@
VERSION = @TK_VERSION@
MAJOR_VERSION = @TK_MAJOR_VERSION@
MINOR_VERSION = @TK_MINOR_VERSION@
@@ -49,7 +50,7 @@ INSTALL_ROOT = $(DESTDIR)
TK_LIBRARY = @TK_LIBRARY@
# Path to use at runtime to refer to LIB_INSTALL_DIR:
-LIB_RUNTIME_DIR = $(libdir)
+LIB_RUNTIME_DIR = @LIB_RUNTIME_DIR@
# Directory in which to install the program wish:
BIN_INSTALL_DIR = $(INSTALL_ROOT)$(bindir)
@@ -186,7 +187,7 @@ KEYSYM_FLAGS =
# Tk does not used deprecated Tcl constructs so it should
# compile fine with -DTCL_NO_DEPRECATED. To remove its own
# set of deprecated code uncomment the second line.
-NO_DEPRECATED_FLAGS =
+NO_DEPRECATED_FLAGS = -DTCL_NO_DEPRECATED
#NO_DEPRECATED_FLAGS = -DTCL_NO_DEPRECATED -DTK_NO_DEPRECATED
# Some versions of make, like SGI's, use the following variable to
@@ -229,7 +230,7 @@ INSTALL_DATA_DIR = ${INSTALL} -d -m 755
# libraries. See configure.in for a description of what it means.
# The value of the symbol is normally set by the configure script.
-SHLIB_CFLAGS = @SHLIB_CFLAGS@
+SHLIB_CFLAGS = @SHLIB_CFLAGS@ -DBUILD_tk
# To enable support for stubs in Tcl.
STUB_LIB_FILE = @TK_STUB_LIB_FILE@
@@ -284,6 +285,12 @@ LD_SEARCH_FLAGS = @LD_SEARCH_FLAGS@
# support for embedded libraries on Darwin / Mac OS X
DYLIB_INSTALL_DIR = ${LIB_RUNTIME_DIR}
+# support for building the Aqua resource file
+TK_RSRC_FILE = @TK_RSRC_FILE@
+WISH_RSRC_FILE = @WISH_RSRC_FILE@
+REZ = @REZ@
+REZ_SWITCHES = @REZ_FLAGS@ -i $(GENERIC_DIR) -i $(TCL_GENERIC_DIR)
+
# support for Xft:
XFT_CFLAGS = @XFT_CFLAGS@
XFT_LIBS = @XFT_LIBS@
@@ -326,7 +333,7 @@ CC_SWITCHES_NO_STUBS = ${CFLAGS} ${CFLAGS_WARNING} ${SHLIB_CFLAGS} \
${PROTO_FLAGS} ${SECURITY_FLAGS} ${MEM_DEBUG_FLAGS} ${KEYSYM_FLAGS} \
${NO_DEPRECATED_FLAGS} @EXTRA_CC_SWITCHES@
-CC_SWITCHES = $(CC_SWITCHES_NO_STUBS) ${TCL_STUB_FLAGS}
+CC_SWITCHES = $(CC_SWITCHES_NO_STUBS) @TCL_STUB_FLAGS@
APP_CC_SWITCHES = $(CC_SWITCHES_NO_STUBS) @EXTRA_APP_CC_SWITCHES@
@@ -348,7 +355,8 @@ CANV_OBJS = tkCanvas.o tkCanvArc.o tkCanvBmap.o tkCanvImg.o \
tkCanvLine.o tkCanvPoly.o tkCanvPs.o tkCanvText.o \
tkCanvUtil.o tkCanvWind.o tkRectOval.o tkTrig.o
-IMAGE_OBJS = tkImage.o tkImgBmap.o tkImgGIF.o tkImgPPM.o tkImgPhoto.o
+IMAGE_OBJS = tkImage.o tkImgBmap.o tkImgGIF.o tkImgPNG.o tkImgPPM.o \
+ tkImgPhoto.o tkImgPhInstance.o
TEXT_OBJS = tkText.o tkTextBTree.o tkTextDisp.o tkTextImage.o tkTextIndex.o \
tkTextMark.o tkTextTag.o tkTextWind.o
@@ -357,7 +365,8 @@ TEXT_OBJS = tkText.o tkTextBTree.o tkTextDisp.o tkTextImage.o tkTextIndex.o \
#
FONT_OBJS = @UNIX_FONT_OBJS@
-GENERIC_OBJS = tk3d.o tkArgv.o tkAtom.o tkBind.o tkBitmap.o tkClipboard.o \
+GENERIC_OBJS = tk3d.o tkArgv.o tkAtom.o tkBind.o tkBitmap.o tkBusy.o \
+ tkClipboard.o \
tkCmds.o tkColor.o tkConfig.o tkConsole.o tkCursor.o tkError.o \
tkEvent.o tkFocus.o tkFont.o tkGet.o tkGC.o tkGeometry.o tkGrab.o \
tkGrid.o tkMain.o tkObj.o tkOldConfig.o tkOption.o tkPack.o tkPlace.o \
@@ -372,7 +381,7 @@ TTK_OBJS = \
ttkTagSet.o ttkTheme.o ttkTrace.o ttkTrack.o ttkTreeview.o \
ttkWidget.o ttkStubInit.o
-STUB_OBJS = tkStubInit.o tkStubLib.o
+STUB_OBJS = tkStubInit.o
STUB_LIB_OBJS = tkStubLib.o ttkStubLib.o
@@ -411,7 +420,8 @@ TTK_DECLS = \
GENERIC_SRCS = \
$(GENERIC_DIR)/tk3d.c $(GENERIC_DIR)/tkArgv.c \
$(GENERIC_DIR)/tkAtom.c $(GENERIC_DIR)/tkBind.c \
- $(GENERIC_DIR)/tkBitmap.c $(GENERIC_DIR)/tkClipboard.c \
+ $(GENERIC_DIR)/tkBitmap.c $(GENERIC_DIR)/tkBusy.c \
+ $(GENERIC_DIR)/tkClipboard.c \
$(GENERIC_DIR)/tkCmds.c $(GENERIC_DIR)/tkColor.c \
$(GENERIC_DIR)/tkConfig.c $(GENERIC_DIR)/tkCursor.c \
$(GENERIC_DIR)/tkError.c $(GENERIC_DIR)/tkEvent.c \
@@ -438,15 +448,16 @@ GENERIC_SRCS = \
$(GENERIC_DIR)/tkCanvWind.c $(GENERIC_DIR)/tkRectOval.c \
$(GENERIC_DIR)/tkTrig.c $(GENERIC_DIR)/tkImage.c \
$(GENERIC_DIR)/tkImgBmap.c $(GENERIC_DIR)/tkImgGIF.c \
- $(GENERIC_DIR)/tkImgPPM.c \
- $(GENERIC_DIR)/tkImgPhoto.c $(GENERIC_DIR)/tkText.c \
+ $(GENERIC_DIR)/tkImgPNG.c $(GENERIC_DIR)/tkImgPPM.c \
+ $(GENERIC_DIR)/tkImgPhoto.c $(GENERIC_DIR)/tkImgPhInstance.c \
+ $(GENERIC_DIR)/tkText.c \
$(GENERIC_DIR)/tkTextBTree.c $(GENERIC_DIR)/tkTextDisp.c \
$(GENERIC_DIR)/tkTextImage.c \
$(GENERIC_DIR)/tkTextIndex.c $(GENERIC_DIR)/tkTextMark.c \
$(GENERIC_DIR)/tkTextTag.c $(GENERIC_DIR)/tkTextWind.c \
$(GENERIC_DIR)/tkOldConfig.c $(GENERIC_DIR)/tkOldTest.c \
$(GENERIC_DIR)/tkSquare.c $(GENERIC_DIR)/tkTest.c \
- $(GENERIC_DIR)/tkStubInit.c $(GENERIC_DIR)/tkStubLib.c
+ $(GENERIC_DIR)/tkStubInit.c
TTK_SRCS = \
$(TTK_DIR)/ttkBlink.c \
@@ -524,6 +535,12 @@ AQUA_SRCS = \
SRCS = $(GENERIC_SRCS) $(@TK_WINDOWINGSYSTEM@_SRCS) @PLAT_SRCS@
+AQUA_RESOURCES = \
+ $(MAC_OSX_DIR)/tkAboutDlg.r $(MAC_OSX_DIR)/tkMacOSXCursors.r \
+ $(MAC_OSX_DIR)/tkMacOSXXCursors.r
+
+AQUA_WISH_RESOURCES = $(MAC_OSX_DIR)/tkMacOSXAETE.r
+
AQUA_HDRS = $(MAC_OSX_DIR)/tkMacOSX.h $(GENERIC_DIR)/tkIntXlibDecls.h
AQUA_XLIB_HDRS = $(XLIB_DIR)/X11/*.h $(XLIB_DIR)/xbytes.h
@@ -576,6 +593,17 @@ ${STUB_LIB_FILE}: ${STUB_LIB_OBJS}
rm -f $@
@MAKE_STUB_LIB@
+# Build Aqua resource files
+${TK_RSRC_FILE}: $(AQUA_RESOURCES)
+ rm -f $@
+ if test "$(REZ)" != ""; then \
+ $(REZ) -o $@ $(REZ_SWITCHES) $(AQUA_RESOURCES); fi
+
+${WISH_RSRC_FILE}: $(AQUA_WISH_RESOURCES)
+ rm -f $@
+ if test "$(REZ)" != ""; then \
+ $(REZ) -o $@ $(REZ_SWITCHES) $(AQUA_WISH_RESOURCES); fi
+
# Make target which outputs the list of the .o contained in the Tk lib
# usefull to build a single big shared library containing Tcl/Tk and other
# extensions. used for the Tcl Plugin. -- dl
@@ -599,18 +627,18 @@ ${WISH_EXE}: $(TK_STUB_LIB_FILE) $(WISH_OBJS) $(TK_LIB_FILE) @APP_RSRC_FILE@
$(TKTEST_EXE): $(TKTEST_OBJS) $(TK_LIB_FILE)
$(MAKE) tktest-real LIB_RUNTIME_DIR="`pwd`:$(TCL_BIN_DIR)"
-tktest-real:
- ${CC} ${CFLAGS} ${LDFLAGS} $(TKTEST_OBJS) @TK_BUILD_LIB_SPEC@ \
+tktest-real: ${TK_STUB_LIB_FILE}
+ ${CC} ${CFLAGS} ${LDFLAGS} $(TKTEST_OBJS) ${TK_STUB_LIB_FILE} ${TCL_STUB_LIB_SPEC} @TK_BUILD_LIB_SPEC@ \
$(WISH_LIBS) $(CC_SEARCH_FLAGS) -o $(TKTEST_EXE)
-# FIXME: This xttest rule seems to be broken in a number of ways.
-# It should use CC_SEARCH_FLAGS, it does not include the shared
-# lib location logic from tktest, and it is not clear where this
-# test.o object file comes from.
-xttest: test.o tkTest.o tkSquare.o $(TK_LIB_FILE)
- ${CC} ${CFLAGS} ${LDFLAGS} test.o tkTest.o tkSquare.o \
- @TK_BUILD_LIB_SPEC@ \
- $(WISH_LIBS) $(LD_SEARCH_FLAGS) -lXt -o xttest
+# # FIXME: This xttest rule seems to be broken in a number of ways. It should
+# # use CC_SEARCH_FLAGS, it does not include the shared lib location logic from
+# # tktest, and it is not clear where this test.o object file comes from.
+#
+# xttest: test.o tkTest.o tkSquare.o $(TK_LIB_FILE) ${TK_STUB_LIB_FILE}
+# ${CC} ${CFLAGS} ${LDFLAGS} test.o tkTest.o tkSquare.o \
+# @TK_BUILD_LIB_SPEC@ ${TK_STUB_LIB_FILE} ${TCL_STUB_LIB_SPEC} \
+# $(WISH_LIBS) $(LD_SEARCH_FLAGS) -lXt -o xttest
# Note, in the target below TCL_LIBRARY needs to be set or else
# "make test" won't work in the case where the compilation directory
@@ -699,7 +727,7 @@ install-binaries: $(TK_STUB_LIB_FILE) $(TK_LIB_FILE) ${WISH_EXE}
echo "Creating package index $(PKG_INDEX)"; \
rm -f "$(PKG_INDEX)"; \
(\
- echo "if {[catch {package present Tcl 8.5.0}]} return";\
+ echo "if {[catch {package present Tcl 8.6.0}]} return";\
relative=`echo | awk '{ORS=" "; split("$(TK_PKG_DIR)",a,"/"); for (f in a) {print ".."}}'`;\
if test "x$(DLL_INSTALL_DIR)" != "x$(BIN_INSTALL_DIR)"; then \
echo "package ifneeded Tk $(MAJOR_VERSION).$(MINOR_VERSION)$(PATCH_LEVEL) [list load [file normalize [file join \$$dir $${relative}$(TK_LIB_FILE)]] Tk]";\
@@ -731,6 +759,9 @@ install-binaries: $(TK_STUB_LIB_FILE) $(TK_LIB_FILE) ${WISH_EXE}
@INSTALL_STUB_LIB@ ; \
fi
@EXTRA_INSTALL_BINARIES@
+ @echo "Installing pkg-config file to $(LIB_INSTALL_DIR)/pkgconfig/"
+ @$(INSTALL_DATA_DIR) $(LIB_INSTALL_DIR)/pkgconfig
+ @$(INSTALL_DATA) tk.pc $(LIB_INSTALL_DIR)/pkgconfig/tk.pc
install-libraries: libraries
@for i in "$(SCRIPT_INSTALL_DIR)" "$(SCRIPT_INSTALL_DIR)/images" \
@@ -876,7 +907,7 @@ clean:
distclean: clean
rm -rf Makefile config.status config.cache config.log tkConfig.sh \
- $(PACKAGE).* prototype tkConfig.h *.plist Tk.framework tk.pc
+ tkConfig.h *.plist Tk.framework tk.pc
depend:
makedepend -- $(DEPEND_SWITCHES) -- $(SRCS)
@@ -919,6 +950,9 @@ tkBind.o: $(GENERIC_DIR)/tkBind.c
tkBitmap.o: $(GENERIC_DIR)/tkBitmap.c
$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tkBitmap.c
+tkBusy.o: $(GENERIC_DIR)/tkBusy.c
+ $(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tkBusy.c
+
tkClipboard.o: $(GENERIC_DIR)/tkClipboard.c
$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tkClipboard.c
@@ -1078,12 +1112,18 @@ tkImgBmap.o: $(GENERIC_DIR)/tkImgBmap.c
tkImgGIF.o: $(GENERIC_DIR)/tkImgGIF.c
$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tkImgGIF.c
+tkImgPNG.o: $(GENERIC_DIR)/tkImgPNG.c
+ $(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tkImgPNG.c
+
tkImgPPM.o: $(GENERIC_DIR)/tkImgPPM.c
$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tkImgPPM.c
-tkImgPhoto.o: $(GENERIC_DIR)/tkImgPhoto.c
+tkImgPhoto.o: $(GENERIC_DIR)/tkImgPhoto.c $(GENERIC_DIR)/tkImgPhoto.h
$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tkImgPhoto.c
+tkImgPhInstance.o: $(GENERIC_DIR)/tkImgPhInstance.c $(GENERIC_DIR)/tkImgPhoto.h
+ $(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tkImgPhInstance.c
+
tkOldTest.o: $(GENERIC_DIR)/tkOldTest.c
$(CC) -c $(APP_CC_SWITCHES) $(GENERIC_DIR)/tkOldTest.c
@@ -1558,14 +1598,14 @@ dist: $(UNIX_DIR)/configure $(UNIX_DIR)/tkConfig.h.in $(UNIX_DIR)/tk.pc.in $(M
$(MAC_OSX_DIR)/*.sdef $(MAC_OSX_DIR)/configure \
$(DISTDIR)/macosx
cp -p $(TOP_DIR)/license.terms $(DISTDIR)/macosx
- mkdir $(DISTDIR)/macosx/Wish.xcode
- cp -p $(MAC_OSX_DIR)/Wish.xcode/project.pbxproj \
- $(MAC_OSX_DIR)/Wish.xcode/default.pbxuser \
- $(DISTDIR)/macosx/Wish.xcode
- mkdir $(DISTDIR)/macosx/Wish.xcodeproj
- cp -p $(MAC_OSX_DIR)/Wish.xcodeproj/project.pbxproj \
- $(MAC_OSX_DIR)/Wish.xcodeproj/default.pbxuser \
- $(DISTDIR)/macosx/Wish.xcodeproj
+ mkdir $(DISTDIR)/macosx/Tk.xcode
+ cp -p $(MAC_OSX_DIR)/Tk.xcode/project.pbxproj \
+ $(MAC_OSX_DIR)/Tk.xcode/default.pbxuser \
+ $(DISTDIR)/macosx/Tk.xcode
+ mkdir $(DISTDIR)/macosx/Tk.xcodeproj
+ cp -p $(MAC_OSX_DIR)/Tk.xcodeproj/project.pbxproj \
+ $(MAC_OSX_DIR)/Tk.xcodeproj/default.pbxuser \
+ $(DISTDIR)/macosx/Tk.xcodeproj
mkdir $(DISTDIR)/compat
cp -p $(TOP_DIR)/license.terms $(TCLDIR)/compat/unistd.h \
$(TCLDIR)/compat/stdlib.h $(TCLDIR)/compat/limits.h \
@@ -1654,88 +1694,6 @@ BUILD_HTML = \
--srcdir=$(TOP_DIR)/.. $(BUILD_HTML_FLAGS)
#
-# Targets to build Solaris package of the distribution for the current
-# architecture. To build stream packages for both sun4 and i86pc
-# architectures:
-#
-# On the sun4 machine, execute the following:
-# make distclean; ./configure
-# make DISTDIR=<distdir> package
-#
-# Once the build is complete, execute the following on the i86pc
-# machine:
-# make DISTDIR=<distdir> package-quick
-#
-# <distdir> is the absolute path to a directory where the build should
-# take place. These steps will generate the $(PACKAGE).sun4 and
-# $(PACKAGE).i86pc stream packages. It is important that the packages be
-# built in this fashion in order to ensure that the architecture
-# independent files are exactly the same, including timestamps, in
-# both packages.
-#
-
-PACKAGE=SCRPtk
-
-package: dist package-config package-common package-binaries package-generate
-package-quick: package-config package-binaries package-generate
-
-#
-# Configure for the current architecture in the dist directory.
-#
-package-config:
- mkdir -p $(DISTDIR)/unix/`arch`
- cd $(DISTDIR)/unix/`arch`; \
- ../configure --prefix=/opt/SUNWtcl/$(TCLVERSION) \
- --exec_prefix=/opt/SUNWtcl/$(TCLVERSION)/`arch` \
- --with-tcl=$(DISTDIR)/../tcl$(TCLVERSION)/unix/`arch` \
- --enable-shared
- mkdir -p $(DISTDIR)/SUNWtcl/$(TCLVERSION)
- mkdir -p $(DISTDIR)/SUNWtcl/$(TCLVERSION)/`arch`
-
-#
-# Build and install the architecture independent files in the dist directory.
-#
-
-package-common:
- cd $(DISTDIR)/unix/`arch`;\
- $(MAKE); \
- $(MAKE) install-libraries install-doc \
- prefix=$(DISTDIR)/SUNWtcl/$(TCLVERSION) \
- exec_prefix=$(DISTDIR)/SUNWtcl/$(TCLVERSION)/`arch`
- mkdir -p $(DISTDIR)/SUNWtcl/$(TCLVERSION)/bin
- sed -e "s/TCLVERSION/$(TCLVERSION)/g" \
- -e "s/TKVERSION/$(VERSION)/g" < $(UNIX_DIR)/wish.sh \
- > $(DISTDIR)/SUNWtcl/$(TCLVERSION)/bin/wish$(VERSION)
- chmod 755 $(DISTDIR)/SUNWtcl/$(TCLVERSION)/bin/wish$(VERSION)
-
-#
-# Build and install the architecture specific files in the dist directory.
-#
-
-package-binaries:
- cd $(DISTDIR)/unix/`arch`; \
- $(MAKE); \
- $(MAKE) install-binaries prefix=$(DISTDIR)/SUNWtcl/$(TCLVERSION) \
- exec_prefix=$(DISTDIR)/SUNWtcl/$(TCLVERSION)/`arch`
-
-#
-# Generate a package from the installed files in the dist directory for the
-# current architecture.
-#
-
-package-generate:
- pkgproto $(DISTDIR)/SUNWtcl/$(TCLVERSION)/bin=bin \
- $(DISTDIR)/SUNWtcl/$(TCLVERSION)/include=include \
- $(DISTDIR)/SUNWtcl/$(TCLVERSION)/lib=lib \
- $(DISTDIR)/SUNWtcl/$(TCLVERSION)/man=man \
- $(DISTDIR)/SUNWtcl/$(TCLVERSION)/`arch`=`arch` \
- | $(TCL_EXE) $(TCLDIR)/unix/mkProto.tcl $(TCLVERSION) \
- $(UNIX_DIR) > prototype
- pkgmk -o -d . -f prototype -a `arch`
- pkgtrans -s . $(PACKAGE).`arch` $(PACKAGE)
- rm -rf $(PACKAGE)
-
-#
# The list of all the targets that do not correspond to real files. This stops
# 'make' from getting confused when someone makes an error in a rule.
#
diff --git a/unix/configure b/unix/configure
index cd11970..de9eaa9 100755
--- a/unix/configure
+++ b/unix/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.59 for tk 8.5.
+# Generated by GNU Autoconf 2.59 for tk 8.6.
#
# Copyright (C) 2003 Free Software Foundation, Inc.
# This configure script is free software; the Free Software Foundation
@@ -267,8 +267,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package.
PACKAGE_NAME='tk'
PACKAGE_TARNAME='tk'
-PACKAGE_VERSION='8.5'
-PACKAGE_STRING='tk 8.5'
+PACKAGE_VERSION='8.6'
+PACKAGE_STRING='tk 8.6'
PACKAGE_BUGREPORT=''
# Factoring default headers for most tests.
@@ -308,7 +308,7 @@ ac_includes_default="\
# include <unistd.h>
#endif"
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS TCL_VERSION TCL_PATCH_LEVEL TCL_BIN_DIR TCL_SRC_DIR TCL_LIB_FILE TCL_LIB_FLAG TCL_LIB_SPEC TCL_STUB_LIB_FILE TCL_STUB_LIB_FLAG TCL_STUB_LIB_SPEC TCLSH_PROG BUILD_TCLSH MAN_FLAGS CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP EGREP TCL_THREADS RANLIB ac_ct_RANLIB AR ac_ct_AR TCL_LIBS DL_LIBS DL_OBJS PLAT_OBJS PLAT_SRCS LDAIX_SRC CFLAGS_DEBUG CFLAGS_OPTIMIZE CFLAGS_WARNING LDFLAGS_DEBUG LDFLAGS_OPTIMIZE CC_SEARCH_FLAGS LD_SEARCH_FLAGS STLIB_LD SHLIB_LD TCL_SHLIB_LD_EXTRAS TK_SHLIB_LD_EXTRAS SHLIB_LD_LIBS SHLIB_CFLAGS SHLIB_SUFFIX MAKE_LIB MAKE_STUB_LIB INSTALL_LIB DLL_INSTALL_DIR INSTALL_STUB_LIB CFLAGS_DEFAULT LDFLAGS_DEFAULT LIBOBJS XFT_CFLAGS XFT_LIBS UNIX_FONT_OBJS TK_VERSION TK_MAJOR_VERSION TK_MINOR_VERSION TK_PATCH_LEVEL TK_YEAR TK_LIB_FILE TK_LIB_FLAG TK_LIB_SPEC TK_STUB_LIB_FILE TK_STUB_LIB_FLAG TK_STUB_LIB_SPEC TK_STUB_LIB_PATH TK_INCLUDE_SPEC TK_BUILD_STUB_LIB_SPEC TK_BUILD_STUB_LIB_PATH TK_SRC_DIR TK_SHARED_BUILD LD_LIBRARY_PATH_VAR TK_BUILD_LIB_SPEC TCL_STUB_FLAGS XINCLUDES XLIBSW LOCALES TK_WINDOWINGSYSTEM TK_PKG_DIR TK_LIBRARY LIB_RUNTIME_DIR PRIVATE_INCLUDE_DIR HTML_DIR EXTRA_CC_SWITCHES EXTRA_APP_CC_SWITCHES EXTRA_INSTALL EXTRA_INSTALL_BINARIES EXTRA_BUILD_HTML EXTRA_WISH_LIBS CFBUNDLELOCALIZATIONS TK_RSRC_FILE WISH_RSRC_FILE LIB_RSRC_FILE APP_RSRC_FILE REZ REZ_FLAGS LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS TCL_VERSION TCL_PATCH_LEVEL TCL_BIN_DIR TCL_SRC_DIR TCL_LIB_FILE TCL_LIB_FLAG TCL_LIB_SPEC TCL_STUB_LIB_FILE TCL_STUB_LIB_FLAG TCL_STUB_LIB_SPEC TCLSH_PROG BUILD_TCLSH MAN_FLAGS CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP EGREP TCL_THREADS RANLIB ac_ct_RANLIB AR ac_ct_AR LIBOBJS TCL_LIBS DL_LIBS DL_OBJS PLAT_OBJS PLAT_SRCS LDAIX_SRC CFLAGS_DEBUG CFLAGS_OPTIMIZE CFLAGS_WARNING LDFLAGS_DEBUG LDFLAGS_OPTIMIZE CC_SEARCH_FLAGS LD_SEARCH_FLAGS STLIB_LD SHLIB_LD TCL_SHLIB_LD_EXTRAS TK_SHLIB_LD_EXTRAS SHLIB_LD_LIBS SHLIB_CFLAGS SHLIB_SUFFIX MAKE_LIB MAKE_STUB_LIB INSTALL_LIB DLL_INSTALL_DIR INSTALL_STUB_LIB CFLAGS_DEFAULT LDFLAGS_DEFAULT XFT_CFLAGS XFT_LIBS UNIX_FONT_OBJS TK_VERSION TK_MAJOR_VERSION TK_MINOR_VERSION TK_PATCH_LEVEL TK_YEAR TK_LIB_FILE TK_LIB_FLAG TK_LIB_SPEC TK_STUB_LIB_FILE TK_STUB_LIB_FLAG TK_STUB_LIB_SPEC TK_STUB_LIB_PATH TK_INCLUDE_SPEC TK_BUILD_STUB_LIB_SPEC TK_BUILD_STUB_LIB_PATH TK_SRC_DIR TK_SHARED_BUILD LD_LIBRARY_PATH_VAR TK_BUILD_LIB_SPEC TCL_STUB_FLAGS XINCLUDES XLIBSW LOCALES TK_WINDOWINGSYSTEM TK_PKG_DIR TK_LIBRARY LIB_RUNTIME_DIR PRIVATE_INCLUDE_DIR HTML_DIR EXTRA_CC_SWITCHES EXTRA_APP_CC_SWITCHES EXTRA_INSTALL EXTRA_INSTALL_BINARIES EXTRA_BUILD_HTML EXTRA_WISH_LIBS CFBUNDLELOCALIZATIONS TK_RSRC_FILE WISH_RSRC_FILE LIB_RSRC_FILE APP_RSRC_FILE REZ REZ_FLAGS LTLIBOBJS'
ac_subst_files=''
# Initialize some variables set by options.
@@ -777,7 +777,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures tk 8.5 to adapt to many kinds of systems.
+\`configure' configures tk 8.6 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -838,7 +838,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of tk 8.5:";;
+ short | recursive ) echo "Configuration of tk 8.6:";;
esac
cat <<\_ACEOF
@@ -852,7 +852,7 @@ Optional Features:
use STRING as a suffix to manpage file names
(default: no, tk if enabled without
specifying STRING)
- --enable-threads build with threads (default: off)
+ --enable-threads build with threads (default: on)
--enable-shared build and link with shared libraries (default: on)
--enable-64bit enable 64bit support (default: off)
--enable-64bit-vis enable 64bit Sparc VIS support (default: off)
@@ -981,7 +981,7 @@ fi
test -n "$ac_init_help" && exit 0
if $ac_init_version; then
cat <<\_ACEOF
-tk configure 8.5
+tk configure 8.6
generated by GNU Autoconf 2.59
Copyright (C) 2003 Free Software Foundation, Inc.
@@ -995,7 +995,7 @@ cat >&5 <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by tk $as_me 8.5, which was
+It was created by tk $as_me 8.6, which was
generated by GNU Autoconf 2.59. Invocation command line was
$ $0 $@
@@ -1335,10 +1335,10 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
-TK_VERSION=8.5
+TK_VERSION=8.6
TK_MAJOR_VERSION=8
-TK_MINOR_VERSION=5
-TK_PATCH_LEVEL=".15"
+TK_MINOR_VERSION=6
+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"
@@ -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
@@ -1541,13 +1541,18 @@ echo "${ECHO_T}could not find ${TCL_BIN_DIR}/tclConfig.sh" >&6
-if test "${TCL_VERSION}" != "${TK_VERSION}"; then
- { { echo "$as_me:$LINENO: error: ${TCL_BIN_DIR}/tclConfig.sh is for Tcl ${TCL_VERSION}.
-Tk ${TK_VERSION}${TK_PATCH_LEVEL} needs Tcl ${TK_VERSION}.
-Use --with-tcl= option to indicate location of tclConfig.sh file for Tcl ${TK_VERSION}." >&5
-echo "$as_me: error: ${TCL_BIN_DIR}/tclConfig.sh is for Tcl ${TCL_VERSION}.
-Tk ${TK_VERSION}${TK_PATCH_LEVEL} needs Tcl ${TK_VERSION}.
-Use --with-tcl= option to indicate location of tclConfig.sh file for Tcl ${TK_VERSION}." >&2;}
+if test "${TCL_MAJOR_VERSION}" -ne 8 ; then
+ { { echo "$as_me:$LINENO: error: ${PACKAGE_NAME} ${PACKAGE_VERSION} requires Tcl 8.6+
+Found config for Tcl ${TCL_VERSION}" >&5
+echo "$as_me: error: ${PACKAGE_NAME} ${PACKAGE_VERSION} requires Tcl 8.6+
+Found config for Tcl ${TCL_VERSION}" >&2;}
+ { (exit 1); exit 1; }; }
+fi
+if test "${TCL_MINOR_VERSION}" -lt 6 ; then
+ { { echo "$as_me:$LINENO: error: ${PACKAGE_NAME} ${PACKAGE_VERSION} requires Tcl 8.6+
+Found config for Tcl ${TCL_VERSION}" >&5
+echo "$as_me: error: ${PACKAGE_NAME} ${PACKAGE_VERSION} requires Tcl 8.6+
+Found config for Tcl ${TCL_VERSION}" >&2;}
{ (exit 1); exit 1; }; }
fi
@@ -2615,9 +2620,80 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $
ac_compiler_gnu=$ac_cv_c_compiler_gnu
+echo "$as_me:$LINENO: checking for inline" >&5
+echo $ECHO_N "checking for inline... $ECHO_C" >&6
+if test "${ac_cv_c_inline+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_cv_c_inline=no
+for ac_kw in inline __inline__ __inline; do
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#ifndef __cplusplus
+typedef int foo_t;
+static $ac_kw foo_t static_foo () {return 0; }
+$ac_kw foo_t foo () {return 0; }
+#endif
+
+_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
+ ac_cv_c_inline=$ac_kw; break
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+done
+
+fi
+echo "$as_me:$LINENO: result: $ac_cv_c_inline" >&5
+echo "${ECHO_T}$ac_cv_c_inline" >&6
+
+
+case $ac_cv_c_inline in
+ inline | yes) ;;
+ *)
+ case $ac_cv_c_inline in
+ no) ac_val=;;
+ *) ac_val=$ac_cv_c_inline;;
+ esac
+ cat >>confdefs.h <<_ACEOF
+#ifndef __cplusplus
+#define inline $ac_val
+#endif
+_ACEOF
+ ;;
+esac
+
+
# limits header checks must come early to prevent
# an autoconf bug that throws errors on configure
-
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -3544,7 +3620,7 @@ if test "${enable_threads+set}" = set; then
enableval="$enable_threads"
tcl_ok=$enableval
else
- tcl_ok=no
+ tcl_ok=yes
fi;
if test "${TCL_THREADS}" = 1; then
@@ -4064,384 +4140,6 @@ _ACEOF
fi
done
- echo "$as_me:$LINENO: checking for pthread_attr_get_np" >&5
-echo $ECHO_N "checking for pthread_attr_get_np... $ECHO_C" >&6
-if test "${ac_cv_func_pthread_attr_get_np+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. */
-/* Define pthread_attr_get_np to an innocuous variant, in case <limits.h> declares pthread_attr_get_np.
- For example, HP-UX 11i <limits.h> declares gettimeofday. */
-#define pthread_attr_get_np innocuous_pthread_attr_get_np
-
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char pthread_attr_get_np (); below.
- Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
- <limits.h> exists even on freestanding compilers. */
-
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-
-#undef pthread_attr_get_np
-
-/* Override any gcc2 internal prototype to avoid an error. */
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char pthread_attr_get_np ();
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_pthread_attr_get_np) || defined (__stub___pthread_attr_get_np)
-choke me
-#else
-char (*f) () = pthread_attr_get_np;
-#endif
-#ifdef __cplusplus
-}
-#endif
-
-int
-main ()
-{
-return f != pthread_attr_get_np;
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 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_exeext'
- { (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
- ac_cv_func_pthread_attr_get_np=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_func_pthread_attr_get_np=no
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_func_pthread_attr_get_np" >&5
-echo "${ECHO_T}$ac_cv_func_pthread_attr_get_np" >&6
-if test $ac_cv_func_pthread_attr_get_np = yes; then
- tcl_ok=yes
-else
- tcl_ok=no
-fi
-
- if test $tcl_ok = yes ; then
-
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_PTHREAD_ATTR_GET_NP 1
-_ACEOF
-
- echo "$as_me:$LINENO: checking for pthread_attr_get_np declaration" >&5
-echo $ECHO_N "checking for pthread_attr_get_np declaration... $ECHO_C" >&6
-if test "${tcl_cv_grep_pthread_attr_get_np+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. */
-#include <pthread.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "pthread_attr_get_np" >/dev/null 2>&1; then
- tcl_cv_grep_pthread_attr_get_np=present
-else
- tcl_cv_grep_pthread_attr_get_np=missing
-fi
-rm -f conftest*
-
-fi
-echo "$as_me:$LINENO: result: $tcl_cv_grep_pthread_attr_get_np" >&5
-echo "${ECHO_T}$tcl_cv_grep_pthread_attr_get_np" >&6
- if test $tcl_cv_grep_pthread_attr_get_np = missing ; then
-
-cat >>confdefs.h <<\_ACEOF
-#define ATTRGETNP_NOT_DECLARED 1
-_ACEOF
-
- fi
- else
- echo "$as_me:$LINENO: checking for pthread_getattr_np" >&5
-echo $ECHO_N "checking for pthread_getattr_np... $ECHO_C" >&6
-if test "${ac_cv_func_pthread_getattr_np+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. */
-/* Define pthread_getattr_np to an innocuous variant, in case <limits.h> declares pthread_getattr_np.
- For example, HP-UX 11i <limits.h> declares gettimeofday. */
-#define pthread_getattr_np innocuous_pthread_getattr_np
-
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char pthread_getattr_np (); below.
- Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
- <limits.h> exists even on freestanding compilers. */
-
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-
-#undef pthread_getattr_np
-
-/* Override any gcc2 internal prototype to avoid an error. */
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char pthread_getattr_np ();
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_pthread_getattr_np) || defined (__stub___pthread_getattr_np)
-choke me
-#else
-char (*f) () = pthread_getattr_np;
-#endif
-#ifdef __cplusplus
-}
-#endif
-
-int
-main ()
-{
-return f != pthread_getattr_np;
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 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_exeext'
- { (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
- ac_cv_func_pthread_getattr_np=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_func_pthread_getattr_np=no
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_func_pthread_getattr_np" >&5
-echo "${ECHO_T}$ac_cv_func_pthread_getattr_np" >&6
-if test $ac_cv_func_pthread_getattr_np = yes; then
- tcl_ok=yes
-else
- tcl_ok=no
-fi
-
- if test $tcl_ok = yes ; then
-
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_PTHREAD_GETATTR_NP 1
-_ACEOF
-
- echo "$as_me:$LINENO: checking for pthread_getattr_np declaration" >&5
-echo $ECHO_N "checking for pthread_getattr_np declaration... $ECHO_C" >&6
-if test "${tcl_cv_grep_pthread_getattr_np+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. */
-#include <pthread.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "pthread_getattr_np" >/dev/null 2>&1; then
- tcl_cv_grep_pthread_getattr_np=present
-else
- tcl_cv_grep_pthread_getattr_np=missing
-fi
-rm -f conftest*
-
-fi
-echo "$as_me:$LINENO: result: $tcl_cv_grep_pthread_getattr_np" >&5
-echo "${ECHO_T}$tcl_cv_grep_pthread_getattr_np" >&6
- if test $tcl_cv_grep_pthread_getattr_np = missing ; then
-
-cat >>confdefs.h <<\_ACEOF
-#define GETATTRNP_NOT_DECLARED 1
-_ACEOF
-
- fi
- fi
- fi
- if test $tcl_ok = no; then
- # Darwin thread stacksize API
-
-for ac_func in pthread_get_stacksize_np
-do
-as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
-echo "$as_me:$LINENO: checking for $ac_func" >&5
-echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
-if eval "test \"\${$as_ac_var+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. */
-/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
- For example, HP-UX 11i <limits.h> declares gettimeofday. */
-#define $ac_func innocuous_$ac_func
-
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char $ac_func (); below.
- Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
- <limits.h> exists even on freestanding compilers. */
-
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-
-#undef $ac_func
-
-/* Override any gcc2 internal prototype to avoid an error. */
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char $ac_func ();
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
-choke me
-#else
-char (*f) () = $ac_func;
-#endif
-#ifdef __cplusplus
-}
-#endif
-
-int
-main ()
-{
-return f != $ac_func;
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 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_exeext'
- { (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
- eval "$as_ac_var=yes"
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-eval "$as_ac_var=no"
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
-if test `eval echo '${'$as_ac_var'}'` = yes; then
- cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-done
-
- fi
LIBS=$ac_saved_libs
else
TCL_THREADS=0
@@ -4463,8 +4161,8 @@ echo "${ECHO_T}yes (threaded core)" >&6
echo "${ECHO_T}yes" >&6
fi
else
- echo "$as_me:$LINENO: result: no (default)" >&5
-echo "${ECHO_T}no (default)" >&6
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
fi
@@ -4698,6 +4396,11 @@ cat >>confdefs.h <<\_ACEOF
_ACEOF
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_HIDDEN 1
+_ACEOF
+
+
fi
@@ -4827,10 +4530,6 @@ fi
# Require ranlib early so we can override it in special cases below.
- if test x"${SHLIB_VERSION}" = x; then
- SHLIB_VERSION="1.0"
-fi
-
@@ -4849,13 +4548,16 @@ fi
ECHO_VERSION='`echo ${VERSION}`'
TCL_LIB_VERSIONS_OK=ok
CFLAGS_DEBUG=-g
- CFLAGS_OPTIMIZE=-O
if test "$GCC" = yes; then
+ CFLAGS_OPTIMIZE=-O2
CFLAGS_WARNING="-Wall"
else
- CFLAGS_WARNING=""
+
+ CFLAGS_OPTIMIZE=-O
+ CFLAGS_WARNING=""
+
fi
if test -n "$ac_tool_prefix"; then
@@ -4942,6 +4644,10 @@ fi
PLAT_OBJS=""
PLAT_SRCS=""
LDAIX_SRC=""
+ if test x"${SHLIB_VERSION}" = x; then
+ SHLIB_VERSION="1.0"
+fi
+
case $system in
AIX-*)
if test "${TCL_THREADS}" = "1" -a "$GCC" != "yes"; then
@@ -5138,7 +4844,9 @@ fi
SHLIB_CFLAGS=""
SHLIB_LD='${CC} -shared'
SHLIB_SUFFIX=".dll"
- DL_OBJS="tclLoadDl.o tclWinError.o"
+ DL_OBJS="tclLoadDl.o"
+ PLAT_OBJS='${CYGWIN_OBJS}'
+ PLAT_SRCS='${CYGWIN_SRCS}'
DL_LIBS="-ldl"
CC_SEARCH_FLAGS=""
LD_SEARCH_FLAGS=""
@@ -5422,6 +5130,10 @@ fi
SHLIB_LD='${CC} -shared'
LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
+else
+
+ CFLAGS="$CFLAGS -z"
+
fi
@@ -5554,6 +5266,14 @@ fi
SHLIB_SUFFIX=".so"
DL_OBJS="tclLoadDl.o"
DL_LIBS=""
+ case $LIBOBJS in
+ "mkstemp.$ac_objext" | \
+ *" mkstemp.$ac_objext" | \
+ "mkstemp.$ac_objext "* | \
+ *" mkstemp.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS mkstemp.$ac_objext" ;;
+esac
+
if test $doRpath = yes; then
CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
@@ -5567,6 +5287,14 @@ fi
SHLIB_SUFFIX=".so"
DL_OBJS="tclLoadDl.o"
DL_LIBS=""
+ case $LIBOBJS in
+ "mkstemp.$ac_objext" | \
+ *" mkstemp.$ac_objext" | \
+ "mkstemp.$ac_objext "* | \
+ *" mkstemp.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS mkstemp.$ac_objext" ;;
+esac
+
if test $doRpath = yes; then
CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
@@ -5600,6 +5328,14 @@ fi
SHLIB_SUFFIX=".so"
DL_OBJS="tclLoadDl.o"
DL_LIBS=""
+ case $LIBOBJS in
+ "mkstemp.$ac_objext" | \
+ *" mkstemp.$ac_objext" | \
+ "mkstemp.$ac_objext "* | \
+ *" mkstemp.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS mkstemp.$ac_objext" ;;
+esac
+
if test $doRpath = yes; then
CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
@@ -5844,20 +5580,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=""
@@ -6703,7 +6431,7 @@ else
arch=`isainfo`
echo "$as_me:$LINENO: checking whether to use -lsunmath for fp rounding control" >&5
echo $ECHO_N "checking whether to use -lsunmath for fp rounding control... $ECHO_C" >&6
- if test "$arch" = "amd64 i386"; then
+ if test "$arch" = "amd64 i386" -o "$arch" = "i386"; then
echo "$as_me:$LINENO: result: yes" >&5
echo "${ECHO_T}yes" >&6
@@ -6902,7 +6630,7 @@ else
fi
case $system in
- SunOS-5.[1-9][0-9]*)
+ SunOS-5.[1-9][0-9]*|SunOS-5.[7-9])
SHLIB_LD="\${CC} -G -z $textmode \${LDFLAGS}";;
*)
SHLIB_LD="/usr/ccs/bin/ld -G -z $textmode";;
@@ -7065,6 +6793,17 @@ fi
fi
+ if test "$tcl_cv_cc_visibility_hidden" != yes; then
+
+
+cat >>confdefs.h <<\_ACEOF
+#define MODULE_SCOPE extern
+_ACEOF
+
+
+fi
+
+
if test "$SHARED_LIB_SUFFIX" = ""; then
SHARED_LIB_SUFFIX='${VERSION}${SHLIB_SUFFIX}'
@@ -7080,7 +6819,7 @@ fi
if test "${SHARED_BUILD}" = 1 -a "${SHLIB_SUFFIX}" != ""; then
LIB_SUFFIX=${SHARED_LIB_SUFFIX}
- MAKE_LIB='${SHLIB_LD} -o $@ ${OBJS} ${SHLIB_LD_LIBS} ${TCL_SHLIB_LD_EXTRAS} ${TK_SHLIB_LD_EXTRAS} ${LD_SEARCH_FLAGS}'
+ MAKE_LIB='${SHLIB_LD} -o $@ ${OBJS} ${TCL_SHLIB_LD_EXTRAS} ${SHLIB_LD_LIBS} ${TK_SHLIB_LD_EXTRAS} ${LD_SEARCH_FLAGS}'
if test "${SHLIB_SUFFIX}" = ".dll"; then
INSTALL_LIB='$(INSTALL_LIBRARY) $(LIB_FILE) "$(BIN_INSTALL_DIR)/$(LIB_FILE)"'
@@ -8301,7 +8040,7 @@ esac
# search path to reflect this.
#------------------------------------------------------------------------
-LIB_RUNTIME_DIR='${LIB_RUNTIME_DIR}'
+LIB_RUNTIME_DIR='$(libdir)'
if test "$TCL_EXEC_PREFIX" != "$exec_prefix"; then
LIB_RUNTIME_DIR="${LIB_RUNTIME_DIR}:${TCL_EXEC_PREFIX}/lib"
@@ -10976,6 +10715,79 @@ _ACEOF
fi
#--------------------------------------------------------------------
+# Check whether XKeycodeToKeysym is deprecated in X11 headers.
+#--------------------------------------------------------------------
+
+if test $tk_aqua = no && test "$GCC" = yes; then
+ echo "$as_me:$LINENO: checking whether XKeycodeToKeysym is deprecated" >&5
+echo $ECHO_N "checking whether XKeycodeToKeysym is deprecated... $ECHO_C" >&6
+ tk_oldCFlags=$CFLAGS
+ CFLAGS="$CFLAGS -Werror"
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+ #include <X11/Xlib.h>
+
+int
+main ()
+{
+
+ XKeycodeToKeysym(0,0,0);
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 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_exeext'
+ { (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
+
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+cat >>confdefs.h <<\_ACEOF
+#define XKEYCODETOKEYSYM_IS_DEPRECATED 1
+_ACEOF
+
+
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ CFLAGS=$tk_oldCFlags
+fi
+
+#--------------------------------------------------------------------
# XXX Do this last.
# It might modify XLIBSW which could affect other tests.
#
@@ -11502,14 +11314,14 @@ _ACEOF
HTML_DIR="${libdir}/Resources/Documentation/Reference/Tk"
EXTRA_INSTALL="install-private-headers html-tk"
EXTRA_BUILD_HTML='@ln -fs contents.htm "$(HTML_INSTALL_DIR)"/TkTOC.html'
- EXTRA_INSTALL_BINARIES='@echo "Installing Info.plist to $(LIB_INSTALL_DIR)/Resources/" && mkdir -p "$(LIB_INSTALL_DIR)/Resources" && $(INSTALL_DATA) Tk-Info.plist "$(LIB_INSTALL_DIR)/Resources/Info.plist"'
- EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing license.terms to $(LIB_INSTALL_DIR)/Resources" && $(INSTALL_DATA) "$(TOP_DIR)/license.terms" "$(LIB_INSTALL_DIR)/Resources"'
+ EXTRA_INSTALL_BINARIES='@echo "Installing Info.plist to $(LIB_INSTALL_DIR)/Resources/" && $(INSTALL_DATA_DIR) "$(LIB_INSTALL_DIR)/Resources" && $(INSTALL_DATA) Tk-Info.plist "$(LIB_INSTALL_DIR)/Resources/Info.plist"'
+ EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing license.terms to $(LIB_INSTALL_DIR)/Resources/" && $(INSTALL_DATA) "$(TOP_DIR)/license.terms" "$(LIB_INSTALL_DIR)/Resources"'
if test $tk_aqua = yes; then
- EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Images to $(LIB_INSTALL_DIR)/Resources" && mkdir -p "$(LIB_INSTALL_DIR)/Resources" && for i in Tk.tiff Tk.icns; do $(INSTALL_DATA) "$(MAC_OSX_DIR)/$$i" "$(LIB_INSTALL_DIR)/Resources"; done'
- EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing wish$(VERSION) script to $(INSTALL_ROOT)/'"${bindir}"'" && mkdir -p "$(INSTALL_ROOT)/'"${bindir}"'" && printf > "$(INSTALL_ROOT)/'"${bindir}"'/wish$(VERSION)" "#!/bin/sh\n\"\$$(dirname \$$0)'"`eval d="${bindir}"; echo "$d" | sed -e 's#/[^/][^/]*#/..#g'`"'$(bindir)/Wish\" \"\$$@\"" && chmod +x "$(INSTALL_ROOT)/'"${bindir}"'/wish$(VERSION)"'
+ EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Images to $(LIB_INSTALL_DIR)/Resources/" && $(INSTALL_DATA_DIR) "$(LIB_INSTALL_DIR)/Resources" && for i in Tk.tiff Tk.icns; do $(INSTALL_DATA) "$(MAC_OSX_DIR)/$$i" "$(LIB_INSTALL_DIR)/Resources"; done'
+ EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing wish$(VERSION) script to $(INSTALL_ROOT)/'"${bindir}"'/" && $(INSTALL_DATA_DIR) "$(INSTALL_ROOT)/'"${bindir}"'" && printf > "$(INSTALL_ROOT)/'"${bindir}"'/wish$(VERSION)" "#!/bin/sh\n\"\$$(dirname \$$0)'"`eval d="${bindir}"; echo "$d" | sed -e 's#/[^/][^/]*#/..#g'`"'$(bindir)/Wish\" \"\$$@\"" && chmod +x "$(INSTALL_ROOT)/'"${bindir}"'/wish$(VERSION)"'
bindir="${libdir}/Resources/Wish.app/Contents/MacOS"
EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Info.plist to $(BIN_INSTALL_DIR)/.." && $(INSTALL_DATA) Wish-Info.plist "$(BIN_INSTALL_DIR)/../Info.plist" && mv -f "$(BIN_INSTALL_DIR)/wish$(VERSION)" "$(BIN_INSTALL_DIR)/Wish"'
- EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Wish.icns to $(BIN_INSTALL_DIR)/../Resources" && mkdir -p "$(BIN_INSTALL_DIR)/../Resources"'
+ EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Wish.icns to $(BIN_INSTALL_DIR)/../Resources" && $(INSTALL_DATA_DIR) "$(BIN_INSTALL_DIR)/../Resources"'
EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && $(INSTALL_DATA) "$(MAC_OSX_DIR)/Tk.icns" "$(BIN_INSTALL_DIR)/../Resources/Wish.icns"'
EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Wish.sdef to $(BIN_INSTALL_DIR)/../Resources" && $(INSTALL_DATA) "$(MAC_OSX_DIR)/Wish.sdef" "$(BIN_INSTALL_DIR)/../Resources"'
fi
@@ -11521,7 +11333,7 @@ _ACEOF
EXTRA_CC_SWITCHES="$EXTRA_CC_SWITCHES"' -DTK_FRAMEWORK_VERSION=\"$(VERSION)\"'
else
if test $tk_aqua = yes; then
- EXTRA_INSTALL_BINARIES='@echo "Installing Images to $(LIB_INSTALL_DIR)/" && mkdir -p "$(LIB_INSTALL_DIR)" && for i in Tk.tiff Tk.icns; do $(INSTALL_DATA) "$(MAC_OSX_DIR)/$$i" "$(LIB_INSTALL_DIR)"; done'
+ EXTRA_INSTALL_BINARIES='@echo "Installing Images to $(LIB_INSTALL_DIR)/" && $(INSTALL_DATA_DIR) "$(LIB_INSTALL_DIR)" && for i in Tk.tiff Tk.icns; do $(INSTALL_DATA) "$(MAC_OSX_DIR)/$$i" "$(LIB_INSTALL_DIR)"; done'
fi
# libdir must be a fully qualified path and not ${exec_prefix}/lib
eval libdir="$libdir"
@@ -12015,7 +11827,7 @@ _ASBOX
} >&5
cat >&5 <<_CSEOF
-This file was extended by tk $as_me 8.5, which was
+This file was extended by tk $as_me 8.6, which was
generated by GNU Autoconf 2.59. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -12073,7 +11885,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
-tk config.status 8.5
+tk config.status 8.6
configured by $0, generated by GNU Autoconf 2.59,
with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
@@ -12299,6 +12111,7 @@ s,@RANLIB@,$RANLIB,;t t
s,@ac_ct_RANLIB@,$ac_ct_RANLIB,;t t
s,@AR@,$AR,;t t
s,@ac_ct_AR@,$ac_ct_AR,;t t
+s,@LIBOBJS@,$LIBOBJS,;t t
s,@TCL_LIBS@,$TCL_LIBS,;t t
s,@DL_LIBS@,$DL_LIBS,;t t
s,@DL_OBJS@,$DL_OBJS,;t t
@@ -12326,7 +12139,6 @@ s,@DLL_INSTALL_DIR@,$DLL_INSTALL_DIR,;t t
s,@INSTALL_STUB_LIB@,$INSTALL_STUB_LIB,;t t
s,@CFLAGS_DEFAULT@,$CFLAGS_DEFAULT,;t t
s,@LDFLAGS_DEFAULT@,$LDFLAGS_DEFAULT,;t t
-s,@LIBOBJS@,$LIBOBJS,;t t
s,@XFT_CFLAGS@,$XFT_CFLAGS,;t t
s,@XFT_LIBS@,$XFT_LIBS,;t t
s,@UNIX_FONT_OBJS@,$UNIX_FONT_OBJS,;t t
diff --git a/unix/configure.in b/unix/configure.in
index d9862ef..948eae2 100644
--- a/unix/configure.in
+++ b/unix/configure.in
@@ -3,7 +3,7 @@ dnl This file is an input file used by the GNU "autoconf" program to
dnl generate the file "configure", which is run during Tk installation
dnl to configure the system for the local environment.
-AC_INIT([tk],[8.5])
+AC_INIT([tk],[8.6])
AC_PREREQ(2.59)
dnl This is only used when included from macosx/configure.ac
@@ -22,10 +22,10 @@ m4_ifdef([SC_USE_CONFIG_HEADERS], [
#endif /* _TKCONFIG */])
])
-TK_VERSION=8.5
+TK_VERSION=8.6
TK_MAJOR_VERSION=8
-TK_MINOR_VERSION=5
-TK_PATCH_LEVEL=".15"
+TK_MINOR_VERSION=6
+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"
@@ -36,10 +36,13 @@ LOCALES="cs da de el en en_gb eo es fr hu it nl pl pt ru sv"
SC_PATH_TCLCONFIG
SC_LOAD_TCLCONFIG
-if test "${TCL_VERSION}" != "${TK_VERSION}"; then
- AC_MSG_ERROR([${TCL_BIN_DIR}/tclConfig.sh is for Tcl ${TCL_VERSION}.
-Tk ${TK_VERSION}${TK_PATCH_LEVEL} needs Tcl ${TK_VERSION}.
-Use --with-tcl= option to indicate location of tclConfig.sh file for Tcl ${TK_VERSION}.])
+if test "${TCL_MAJOR_VERSION}" -ne 8 ; then
+ AC_MSG_ERROR([${PACKAGE_NAME} ${PACKAGE_VERSION} requires Tcl 8.6+
+Found config for Tcl ${TCL_VERSION}])
+fi
+if test "${TCL_MINOR_VERSION}" -lt 6 ; then
+ AC_MSG_ERROR([${PACKAGE_NAME} ${PACKAGE_VERSION} requires Tcl 8.6+
+Found config for Tcl ${TCL_VERSION}])
fi
SC_PROG_TCLSH
@@ -76,6 +79,7 @@ if test "${CFLAGS+set}" != "set" ; then
fi
AC_PROG_CC
+AC_C_INLINE
# limits header checks must come early to prevent
# an autoconf bug that throws errors on configure
@@ -152,7 +156,7 @@ AC_C_BIGENDIAN
# search path to reflect this.
#------------------------------------------------------------------------
-LIB_RUNTIME_DIR='${LIB_RUNTIME_DIR}'
+LIB_RUNTIME_DIR='$(libdir)'
if test "$TCL_EXEC_PREFIX" != "$exec_prefix"; then
LIB_RUNTIME_DIR="${LIB_RUNTIME_DIR}:${TCL_EXEC_PREFIX}/lib"
@@ -575,6 +579,27 @@ if test $tk_aqua = no; then
fi
#--------------------------------------------------------------------
+# Check whether XKeycodeToKeysym is deprecated in X11 headers.
+#--------------------------------------------------------------------
+
+if test $tk_aqua = no && test "$GCC" = yes; then
+ AC_MSG_CHECKING([whether XKeycodeToKeysym is deprecated])
+ tk_oldCFlags=$CFLAGS
+ CFLAGS="$CFLAGS -Werror"
+ AC_TRY_LINK([
+ #include <X11/Xlib.h>
+ ], [
+ XKeycodeToKeysym(0,0,0);
+ ], [
+ AC_MSG_RESULT([no])
+ ], [
+ AC_MSG_RESULT([yes])
+ AC_DEFINE(XKEYCODETOKEYSYM_IS_DEPRECATED, 1, [Is XKeycodeToKeysym deprecated?])
+ ])
+ CFLAGS=$tk_oldCFlags
+fi
+
+#--------------------------------------------------------------------
# XXX Do this last.
# It might modify XLIBSW which could affect other tests.
#
@@ -709,14 +734,14 @@ if test "$FRAMEWORK_BUILD" = "1" ; then
HTML_DIR="${libdir}/Resources/Documentation/Reference/Tk"
EXTRA_INSTALL="install-private-headers html-tk"
EXTRA_BUILD_HTML='@ln -fs contents.htm "$(HTML_INSTALL_DIR)"/TkTOC.html'
- EXTRA_INSTALL_BINARIES='@echo "Installing Info.plist to $(LIB_INSTALL_DIR)/Resources/" && mkdir -p "$(LIB_INSTALL_DIR)/Resources" && $(INSTALL_DATA) Tk-Info.plist "$(LIB_INSTALL_DIR)/Resources/Info.plist"'
- EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing license.terms to $(LIB_INSTALL_DIR)/Resources" && $(INSTALL_DATA) "$(TOP_DIR)/license.terms" "$(LIB_INSTALL_DIR)/Resources"'
+ EXTRA_INSTALL_BINARIES='@echo "Installing Info.plist to $(LIB_INSTALL_DIR)/Resources/" && $(INSTALL_DATA_DIR) "$(LIB_INSTALL_DIR)/Resources" && $(INSTALL_DATA) Tk-Info.plist "$(LIB_INSTALL_DIR)/Resources/Info.plist"'
+ EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing license.terms to $(LIB_INSTALL_DIR)/Resources/" && $(INSTALL_DATA) "$(TOP_DIR)/license.terms" "$(LIB_INSTALL_DIR)/Resources"'
if test $tk_aqua = yes; then
- EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Images to $(LIB_INSTALL_DIR)/Resources" && mkdir -p "$(LIB_INSTALL_DIR)/Resources" && for i in Tk.tiff Tk.icns; do $(INSTALL_DATA) "$(MAC_OSX_DIR)/$$i" "$(LIB_INSTALL_DIR)/Resources"; done'
- EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing wish$(VERSION) script to $(INSTALL_ROOT)/'"${bindir}"'" && mkdir -p "$(INSTALL_ROOT)/'"${bindir}"'" && printf > "$(INSTALL_ROOT)/'"${bindir}"'/wish$(VERSION)" "#!/bin/sh\n\"\$$(dirname \$$0)'"`eval d="${bindir}"; echo "$d" | sed -e 's#/[^/][^/]*#/..#g'`"'$(bindir)/Wish\" \"\$$@\"" && chmod +x "$(INSTALL_ROOT)/'"${bindir}"'/wish$(VERSION)"'
+ EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Images to $(LIB_INSTALL_DIR)/Resources/" && $(INSTALL_DATA_DIR) "$(LIB_INSTALL_DIR)/Resources" && for i in Tk.tiff Tk.icns; do $(INSTALL_DATA) "$(MAC_OSX_DIR)/$$i" "$(LIB_INSTALL_DIR)/Resources"; done'
+ EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing wish$(VERSION) script to $(INSTALL_ROOT)/'"${bindir}"'/" && $(INSTALL_DATA_DIR) "$(INSTALL_ROOT)/'"${bindir}"'" && printf > "$(INSTALL_ROOT)/'"${bindir}"'/wish$(VERSION)" "#!/bin/sh\n\"\$$(dirname \$$0)'"`eval d="${bindir}"; echo "$d" | sed -e 's#/[^/][^/]*#/..#g'`"'$(bindir)/Wish\" \"\$$@\"" && chmod +x "$(INSTALL_ROOT)/'"${bindir}"'/wish$(VERSION)"'
bindir="${libdir}/Resources/Wish.app/Contents/MacOS"
EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Info.plist to $(BIN_INSTALL_DIR)/.." && $(INSTALL_DATA) Wish-Info.plist "$(BIN_INSTALL_DIR)/../Info.plist" && mv -f "$(BIN_INSTALL_DIR)/wish$(VERSION)" "$(BIN_INSTALL_DIR)/Wish"'
- EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Wish.icns to $(BIN_INSTALL_DIR)/../Resources" && mkdir -p "$(BIN_INSTALL_DIR)/../Resources"'
+ EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Wish.icns to $(BIN_INSTALL_DIR)/../Resources" && $(INSTALL_DATA_DIR) "$(BIN_INSTALL_DIR)/../Resources"'
EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && $(INSTALL_DATA) "$(MAC_OSX_DIR)/Tk.icns" "$(BIN_INSTALL_DIR)/../Resources/Wish.icns"'
EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Wish.sdef to $(BIN_INSTALL_DIR)/../Resources" && $(INSTALL_DATA) "$(MAC_OSX_DIR)/Wish.sdef" "$(BIN_INSTALL_DIR)/../Resources"'
fi
@@ -728,7 +753,7 @@ if test "$FRAMEWORK_BUILD" = "1" ; then
EXTRA_CC_SWITCHES="$EXTRA_CC_SWITCHES"' -DTK_FRAMEWORK_VERSION=\"$(VERSION)\"'
else
if test $tk_aqua = yes; then
- EXTRA_INSTALL_BINARIES='@echo "Installing Images to $(LIB_INSTALL_DIR)/" && mkdir -p "$(LIB_INSTALL_DIR)" && for i in Tk.tiff Tk.icns; do $(INSTALL_DATA) "$(MAC_OSX_DIR)/$$i" "$(LIB_INSTALL_DIR)"; done'
+ EXTRA_INSTALL_BINARIES='@echo "Installing Images to $(LIB_INSTALL_DIR)/" && $(INSTALL_DATA_DIR) "$(LIB_INSTALL_DIR)" && for i in Tk.tiff Tk.icns; do $(INSTALL_DATA) "$(MAC_OSX_DIR)/$$i" "$(LIB_INSTALL_DIR)"; done'
fi
# libdir must be a fully qualified path and not ${exec_prefix}/lib
eval libdir="$libdir"
diff --git a/unix/install-sh b/unix/install-sh
index 7c34c3f..7c34c3f 100755..100644
--- a/unix/install-sh
+++ b/unix/install-sh
diff --git a/unix/installManPage b/unix/installManPage
index 6bdccf0..4d615bf 100755
--- a/unix/installManPage
+++ b/unix/installManPage
@@ -59,9 +59,7 @@ test -z "$SymOrLoc" && SymOrLoc="$Dir/"
# backticks which doesn't pass backslashes literally.
#
Names=`sed -n '
-# Look for a line, that starts with .SH NAME
-# optionally allow NAME to be surrounded
-# by quotes.
+# Look for a line that starts with .SH NAME
/^\.SH NAME/{
# Read next line
n
@@ -71,6 +69,9 @@ Names=`sed -n '
s/\\\ //g
# Delete from \- to the end of line
s/ \\\-.*//
+# Convert all non-space non-alphanum sequences
+# to single underscores.
+ s/[^ A-Za-z0-9][^ A-Za-z0-9]*/_/g
# print the result and exit
p;q
}' $ManPage`
diff --git a/unix/tcl.m4 b/unix/tcl.m4
index e9795b8..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
#------------------------------------------------------------------------
@@ -618,8 +617,8 @@ AC_DEFUN([SC_ENABLE_FRAMEWORK], [
AC_DEFUN([SC_ENABLE_THREADS], [
AC_ARG_ENABLE(threads,
AC_HELP_STRING([--enable-threads],
- [build with threads (default: off)]),
- [tcl_ok=$enableval], [tcl_ok=no])
+ [build with threads (default: on)]),
+ [tcl_ok=$enableval], [tcl_ok=yes])
if test "${TCL_THREADS}" = 1; then
tcl_threaded_core=1;
@@ -680,39 +679,6 @@ AC_DEFUN([SC_ENABLE_THREADS], [
ac_saved_libs=$LIBS
LIBS="$LIBS $THREADS_LIBS"
AC_CHECK_FUNCS(pthread_attr_setstacksize pthread_atfork)
- AC_CHECK_FUNC(pthread_attr_get_np,tcl_ok=yes,tcl_ok=no)
- if test $tcl_ok = yes ; then
- AC_DEFINE(HAVE_PTHREAD_ATTR_GET_NP, 1,
- [Do we want a BSD-like thread-attribute interface?])
- AC_CACHE_CHECK([for pthread_attr_get_np declaration],
- tcl_cv_grep_pthread_attr_get_np, [
- AC_EGREP_HEADER(pthread_attr_get_np, pthread.h,
- tcl_cv_grep_pthread_attr_get_np=present,
- tcl_cv_grep_pthread_attr_get_np=missing)])
- if test $tcl_cv_grep_pthread_attr_get_np = missing ; then
- AC_DEFINE(ATTRGETNP_NOT_DECLARED, 1,
- [Is pthread_attr_get_np() declared in <pthread.h>?])
- fi
- else
- AC_CHECK_FUNC(pthread_getattr_np,tcl_ok=yes,tcl_ok=no)
- if test $tcl_ok = yes ; then
- AC_DEFINE(HAVE_PTHREAD_GETATTR_NP, 1,
- [Do we want a Linux-like thread-attribute interface?])
- AC_CACHE_CHECK([for pthread_getattr_np declaration],
- tcl_cv_grep_pthread_getattr_np, [
- AC_EGREP_HEADER(pthread_getattr_np, pthread.h,
- tcl_cv_grep_pthread_getattr_np=present,
- tcl_cv_grep_pthread_getattr_np=missing)])
- if test $tcl_cv_grep_pthread_getattr_np = missing ; then
- AC_DEFINE(GETATTRNP_NOT_DECLARED, 1,
- [Is pthread_getattr_np declared in <pthread.h>?])
- fi
- fi
- fi
- if test $tcl_ok = no; then
- # Darwin thread stacksize API
- AC_CHECK_FUNCS(pthread_get_stacksize_np)
- fi
LIBS=$ac_saved_libs
else
TCL_THREADS=0
@@ -727,7 +693,7 @@ AC_DEFUN([SC_ENABLE_THREADS], [
AC_MSG_RESULT([yes])
fi
else
- AC_MSG_RESULT([no (default)])
+ AC_MSG_RESULT([no])
fi
AC_SUBST(TCL_THREADS)
@@ -823,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], [
@@ -1088,6 +1053,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])
])
# Step 0.d: Disable -rpath support?
@@ -1110,7 +1076,6 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
AC_CHECK_LIB(dl, dlopen, have_dl=yes, have_dl=no)
# Require ranlib early so we can override it in special cases below.
- AS_IF([test x"${SHLIB_VERSION}" = x], [SHLIB_VERSION="1.0"])
AC_REQUIRE([AC_PROG_RANLIB])
@@ -1129,16 +1094,20 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
ECHO_VERSION='`echo ${VERSION}`'
TCL_LIB_VERSIONS_OK=ok
CFLAGS_DEBUG=-g
- CFLAGS_OPTIMIZE=-O
AS_IF([test "$GCC" = yes], [
+ CFLAGS_OPTIMIZE=-O2
CFLAGS_WARNING="-Wall"
- ], [CFLAGS_WARNING=""])
+ ], [
+ CFLAGS_OPTIMIZE=-O
+ CFLAGS_WARNING=""
+ ])
AC_CHECK_TOOL(AR, ar)
STLIB_LD='${AR} cr'
LD_LIBRARY_PATH_VAR="LD_LIBRARY_PATH"
PLAT_OBJS=""
PLAT_SRCS=""
LDAIX_SRC=""
+ AS_IF([test x"${SHLIB_VERSION}" = x], [SHLIB_VERSION="1.0"])
case $system in
AIX-*)
AS_IF([test "${TCL_THREADS}" = "1" -a "$GCC" != "yes"], [
@@ -1240,7 +1209,9 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
SHLIB_CFLAGS=""
SHLIB_LD='${CC} -shared'
SHLIB_SUFFIX=".dll"
- DL_OBJS="tclLoadDl.o tclWinError.o"
+ DL_OBJS="tclLoadDl.o"
+ PLAT_OBJS='${CYGWIN_OBJS}'
+ PLAT_SRCS='${CYGWIN_SRCS}'
DL_LIBS="-ldl"
CC_SEARCH_FLAGS=""
LD_SEARCH_FLAGS=""
@@ -1318,6 +1289,8 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
AS_IF([test "$GCC" = yes], [
SHLIB_LD='${CC} -shared'
LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
+ ], [
+ CFLAGS="$CFLAGS -z"
])
# Users may want PA-RISC 1.1/2.0 portable code - needs HP cc
@@ -1365,6 +1338,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
SHLIB_SUFFIX=".so"
DL_OBJS="tclLoadDl.o"
DL_LIBS=""
+ AC_LIBOBJ(mkstemp)
AS_IF([test $doRpath = yes], [
CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'])
@@ -1375,6 +1349,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
SHLIB_SUFFIX=".so"
DL_OBJS="tclLoadDl.o"
DL_LIBS=""
+ AC_LIBOBJ(mkstemp)
AS_IF([test $doRpath = yes], [
CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'])
@@ -1400,6 +1375,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
SHLIB_SUFFIX=".so"
DL_OBJS="tclLoadDl.o"
DL_LIBS=""
+ AC_LIBOBJ(mkstemp)
AS_IF([test $doRpath = yes], [
CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'])
@@ -1549,20 +1525,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=""
@@ -1940,7 +1908,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
AS_IF([test "$GCC" = yes],[use_sunmath=no],[
arch=`isainfo`
AC_MSG_CHECKING([whether to use -lsunmath for fp rounding control])
- AS_IF([test "$arch" = "amd64 i386"], [
+ AS_IF([test "$arch" = "amd64 i386" -o "$arch" = "i386"], [
AC_MSG_RESULT([yes])
MATH_LIBS="-lsunmath $MATH_LIBS"
AC_CHECK_HEADER(sunmath.h)
@@ -1973,7 +1941,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
], [
AS_IF([test "$use_sunmath" = yes], [textmode=textoff],[textmode=text])
case $system in
- SunOS-5.[[1-9]][[0-9]]*)
+ SunOS-5.[[1-9]][[0-9]]*|SunOS-5.[[7-9]])
SHLIB_LD="\${CC} -G -z $textmode \${LDFLAGS}";;
*)
SHLIB_LD="/usr/ccs/bin/ld -G -z $textmode";;
@@ -2056,6 +2024,11 @@ dnl # preprocessing tests use only CPPFLAGS.
*) SHLIB_CFLAGS="-fPIC" ;;
esac])
+ AS_IF([test "$tcl_cv_cc_visibility_hidden" != yes], [
+ AC_DEFINE(MODULE_SCOPE, [extern],
+ [No Compiler support for module scope symbols])
+ ])
+
AS_IF([test "$SHARED_LIB_SUFFIX" = ""], [
SHARED_LIB_SUFFIX='${VERSION}${SHLIB_SUFFIX}'])
AS_IF([test "$UNSHARED_LIB_SUFFIX" = ""], [
@@ -2064,7 +2037,7 @@ dnl # preprocessing tests use only CPPFLAGS.
AS_IF([test "${SHARED_BUILD}" = 1 -a "${SHLIB_SUFFIX}" != ""], [
LIB_SUFFIX=${SHARED_LIB_SUFFIX}
- MAKE_LIB='${SHLIB_LD} -o [$]@ ${OBJS} ${SHLIB_LD_LIBS} ${TCL_SHLIB_LD_EXTRAS} ${TK_SHLIB_LD_EXTRAS} ${LD_SEARCH_FLAGS}'
+ MAKE_LIB='${SHLIB_LD} -o [$]@ ${OBJS} ${TCL_SHLIB_LD_EXTRAS} ${SHLIB_LD_LIBS} ${TK_SHLIB_LD_EXTRAS} ${LD_SEARCH_FLAGS}'
AS_IF([test "${SHLIB_SUFFIX}" = ".dll"], [
INSTALL_LIB='$(INSTALL_LIBRARY) $(LIB_FILE) "$(BIN_INSTALL_DIR)/$(LIB_FILE)"'
DLL_INSTALL_DIR="\$(BIN_INSTALL_DIR)"
@@ -2157,124 +2130,6 @@ dnl # preprocessing tests use only CPPFLAGS.
])
#--------------------------------------------------------------------
-# SC_SERIAL_PORT
-#
-# Determine which interface to use to talk to the serial port.
-# Note that #include lines must begin in leftmost column for
-# some compilers to recognize them as preprocessor directives,
-# and some build environments have stdin not pointing at a
-# pseudo-terminal (usually /dev/null instead.)
-#
-# Arguments:
-# none
-#
-# Results:
-#
-# Defines only one of the following vars:
-# HAVE_SYS_MODEM_H
-# USE_TERMIOS
-# USE_TERMIO
-# USE_SGTTY
-#
-#--------------------------------------------------------------------
-
-AC_DEFUN([SC_SERIAL_PORT], [
- AC_CHECK_HEADERS(sys/modem.h)
- AC_CACHE_CHECK([termios vs. termio vs. sgtty], tcl_cv_api_serial, [
- AC_TRY_RUN([
-#include <termios.h>
-
-int main() {
- struct termios t;
- if (tcgetattr(0, &t) == 0) {
- cfsetospeed(&t, 0);
- t.c_cflag |= PARENB | PARODD | CSIZE | CSTOPB;
- return 0;
- }
- return 1;
-}], tcl_cv_api_serial=termios, tcl_cv_api_serial=no, tcl_cv_api_serial=no)
- if test $tcl_cv_api_serial = no ; then
- AC_TRY_RUN([
-#include <termio.h>
-
-int main() {
- struct termio t;
- if (ioctl(0, TCGETA, &t) == 0) {
- t.c_cflag |= CBAUD | PARENB | PARODD | CSIZE | CSTOPB;
- return 0;
- }
- return 1;
-}], tcl_cv_api_serial=termio, tcl_cv_api_serial=no, tcl_cv_api_serial=no)
- fi
- if test $tcl_cv_api_serial = no ; then
- AC_TRY_RUN([
-#include <sgtty.h>
-
-int main() {
- struct sgttyb t;
- if (ioctl(0, TIOCGETP, &t) == 0) {
- t.sg_ospeed = 0;
- t.sg_flags |= ODDP | EVENP | RAW;
- return 0;
- }
- return 1;
-}], tcl_cv_api_serial=sgtty, tcl_cv_api_serial=no, tcl_cv_api_serial=no)
- fi
- if test $tcl_cv_api_serial = no ; then
- AC_TRY_RUN([
-#include <termios.h>
-#include <errno.h>
-
-int main() {
- struct termios t;
- if (tcgetattr(0, &t) == 0
- || errno == ENOTTY || errno == ENXIO || errno == EINVAL) {
- cfsetospeed(&t, 0);
- t.c_cflag |= PARENB | PARODD | CSIZE | CSTOPB;
- return 0;
- }
- return 1;
-}], tcl_cv_api_serial=termios, tcl_cv_api_serial=no, tcl_cv_api_serial=no)
- fi
- if test $tcl_cv_api_serial = no; then
- AC_TRY_RUN([
-#include <termio.h>
-#include <errno.h>
-
-int main() {
- struct termio t;
- if (ioctl(0, TCGETA, &t) == 0
- || errno == ENOTTY || errno == ENXIO || errno == EINVAL) {
- t.c_cflag |= CBAUD | PARENB | PARODD | CSIZE | CSTOPB;
- return 0;
- }
- return 1;
- }], tcl_cv_api_serial=termio, tcl_cv_api_serial=no, tcl_cv_api_serial=no)
- fi
- if test $tcl_cv_api_serial = no; then
- AC_TRY_RUN([
-#include <sgtty.h>
-#include <errno.h>
-
-int main() {
- struct sgttyb t;
- if (ioctl(0, TIOCGETP, &t) == 0
- || errno == ENOTTY || errno == ENXIO || errno == EINVAL) {
- t.sg_ospeed = 0;
- t.sg_flags |= ODDP | EVENP | RAW;
- return 0;
- }
- return 1;
-}], tcl_cv_api_serial=sgtty, tcl_cv_api_serial=none, tcl_cv_api_serial=none)
- fi])
- case $tcl_cv_api_serial in
- termios) AC_DEFINE(USE_TERMIOS, 1, [Use the termios API for serial lines]);;
- termio) AC_DEFINE(USE_TERMIO, 1, [Use the termio API for serial lines]);;
- sgtty) AC_DEFINE(USE_SGTTY, 1, [Use the sgtty API for serial lines]);;
- esac
-])
-
-#--------------------------------------------------------------------
# SC_MISSING_POSIX_HEADERS
#
# Supply substitutes for missing POSIX header files. Special
@@ -2473,11 +2328,6 @@ AC_DEFUN([SC_BLOCKING_STYLE], [
SC_CONFIG_SYSTEM
AC_MSG_CHECKING([FIONBIO vs. O_NONBLOCK for nonblocking I/O])
case $system in
- # There used to be code here to use FIONBIO under AIX. However, it
- # was reported that FIONBIO doesn't work under AIX 3.2.5. Since
- # using O_NONBLOCK seems fine under AIX 4.*, I removed the FIONBIO
- # code (JO, 5/31/97).
-
OSF*)
AC_DEFINE(USE_FIONBIO, 1, [Should we use FIONBIO?])
AC_MSG_RESULT([FIONBIO])
@@ -3019,37 +2869,6 @@ AC_DEFUN([SC_TCL_GETHOSTBYNAME_R], [AC_CHECK_FUNC(gethostbyname_r, [
])])
#--------------------------------------------------------------------
-# SC_TCL_GETADDRINFO
-#
-# Check if we have 'getaddrinfo'
-#
-# Arguments:
-# None
-#
-# Results:
-# Might define the following vars:
-# HAVE_GETADDRINFO
-#
-#--------------------------------------------------------------------
-
-AC_DEFUN([SC_TCL_GETADDRINFO], [AC_CHECK_FUNC(getaddrinfo, [
- AC_CACHE_CHECK([for working getaddrinfo], tcl_cv_api_getaddrinfo, [
- AC_TRY_COMPILE([
- #include <netdb.h>
- ], [
- const char *name, *port;
- struct addrinfo *aiPtr, hints;
- (void)getaddrinfo(name,port, &hints, &aiPtr);
- (void)freeaddrinfo(aiPtr);
- ], tcl_cv_api_getaddrinfo=yes, tcl_cv_getaddrinfo=no)])
- tcl_ok=$tcl_cv_api_getaddrinfo
- if test "$tcl_ok" = yes; then
- AC_DEFINE(HAVE_GETADDRINFO, 1,
- [Define to 1 if getaddrinfo is available.])
- fi
-])])
-
-#--------------------------------------------------------------------
# SC_TCL_GETPWUID_R
#
# Check if we have MT-safe variant of getpwuid() and if yes,
@@ -3289,6 +3108,26 @@ AC_DEFUN([SC_TCL_GETGRNAM_R], [AC_CHECK_FUNC(getgrnam_r, [
fi
])])
+AC_DEFUN([SC_TCL_IPV6],[
+ NEED_FAKE_RFC2553=0
+ AC_CHECK_FUNCS(getnameinfo getaddrinfo freeaddrinfo gai_strerror,,[NEED_FAKE_RFC2553=1])
+ AC_CHECK_TYPES([
+ struct addrinfo,
+ struct in6_addr,
+ struct sockaddr_in6,
+ struct sockaddr_storage],,[NEED_FAKE_RFC2553=1],[[
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netdb.h>
+]])
+if test "x$NEED_FAKE_RFC2553" = "x1"; then
+ AC_DEFINE([NEED_FAKE_RFC2553], 1,
+ [Use compat implementation of getaddrinfo() and friends])
+ AC_LIBOBJ([fake-rfc2553])
+ AC_CHECK_FUNC(strlcpy)
+fi
+])
# Local Variables:
# mode: autoconf
# End:
diff --git a/unix/tk.spec b/unix/tk.spec
index 9302fd4..cafad27 100644
--- a/unix/tk.spec
+++ b/unix/tk.spec
@@ -4,15 +4,15 @@
Name: tk
Summary: Tk graphical toolkit for the Tcl scripting language.
-Version: 8.5.15
+Version: 8.6.1
Release: 2
License: BSD
Group: Development/Languages
Source: http://prdownloads.sourceforge.net/tcl/tk%{version}-src.tar.gz
URL: http://www.tcl.tk/
Buildroot: /var/tmp/%{name}%{version}
-Buildrequires: XFree86-devel tcl >= 8.5.0
-Requires: tcl >= 8.5.0
+Buildrequires: XFree86-devel tcl >= %version
+Requires: tcl >= %version
%description
The Tcl (Tool Command Language) provides a powerful platform for
diff --git a/unix/tkAppInit.c b/unix/tkAppInit.c
index 422b9e1..9a0b053 100644
--- a/unix/tkAppInit.c
+++ b/unix/tkAppInit.c
@@ -1,22 +1,53 @@
/*
* tkAppInit.c --
*
- * Provides a default version of the Tcl_AppInit procedure for use in
- * wish and similar Tk-based applications.
+ * Provides a default version of the main program and Tcl_AppInit
+ * procedure for wish and other Tk-based applications.
*
* Copyright (c) 1993 The Regents of the University of California.
* Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright (c) 1998-1999 Scriptics Corporation.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
+#undef BUILD_tk
+#undef STATIC_BUILD
#include "tk.h"
-#include "locale.h"
#ifdef TK_TEST
-extern int Tktest_Init(Tcl_Interp *interp);
+extern Tcl_PackageInitProc Tktest_Init;
#endif /* TK_TEST */
+
+/*
+ * The following #if block allows you to change the AppInit function by using
+ * a #define of TCL_LOCAL_APPINIT instead of rewriting this entire file. The
+ * #if checks for that #define and uses Tcl_AppInit if it doesn't exist.
+ */
+
+#ifndef TK_LOCAL_APPINIT
+#define TK_LOCAL_APPINIT Tcl_AppInit
+#endif
+#ifndef MODULE_SCOPE
+# define MODULE_SCOPE extern
+#endif
+MODULE_SCOPE int TK_LOCAL_APPINIT(Tcl_Interp *);
+MODULE_SCOPE int main(int, char **);
+
+/*
+ * The following #if block allows you to change how Tcl finds the startup
+ * script, prime the library or encoding paths, fiddle with the argv, etc.,
+ * without needing to rewrite Tk_Main()
+ */
+
+#ifdef TK_LOCAL_MAIN_HOOK
+MODULE_SCOPE int TK_LOCAL_MAIN_HOOK(int *argc, char ***argv);
+#endif
+
+/* Make sure the stubbed variants of those are never used. */
+#undef Tcl_ObjSetVar2
+#undef Tcl_NewStringObj
/*
*----------------------------------------------------------------------
@@ -30,7 +61,7 @@ extern int Tktest_Init(Tcl_Interp *interp);
* either.
*
* Side effects:
- * Whatever the application does.
+ * Just about anything, since from here we call arbitrary Tcl code.
*
*----------------------------------------------------------------------
*/
@@ -40,26 +71,7 @@ main(
int argc, /* Number of command-line arguments. */
char **argv) /* Values of command-line arguments. */
{
- /*
- * The following #if block allows you to change the AppInit function by
- * using a #define of TCL_LOCAL_APPINIT instead of rewriting this entire
- * file. The #if checks for that #define and uses Tcl_AppInit if it
- * doesn't exist.
- */
-
-#ifndef TK_LOCAL_APPINIT
-#define TK_LOCAL_APPINIT Tcl_AppInit
-#endif
- extern int TK_LOCAL_APPINIT (Tcl_Interp *interp);
-
- /*
- * The following #if block allows you to change how Tcl finds the startup
- * script, prime the library or encoding paths, fiddle with the argv,
- * etc., without needing to rewrite Tk_Main()
- */
-
#ifdef TK_LOCAL_MAIN_HOOK
- extern int TK_LOCAL_MAIN_HOOK (int *argc, char ***argv);
TK_LOCAL_MAIN_HOOK(&argc, &argv);
#endif
@@ -90,19 +102,20 @@ int
Tcl_AppInit(
Tcl_Interp *interp) /* Interpreter for application. */
{
- if (Tcl_Init(interp) == TCL_ERROR) {
+ if ((Tcl_Init)(interp) == TCL_ERROR) {
return TCL_ERROR;
}
+
if (Tk_Init(interp) == TCL_ERROR) {
return TCL_ERROR;
}
Tcl_StaticPackage(interp, "Tk", Tk_Init, Tk_SafeInit);
+
#ifdef TK_TEST
if (Tktest_Init(interp) == TCL_ERROR) {
return TCL_ERROR;
}
- Tcl_StaticPackage(interp, "Tktest", Tktest_Init,
- (Tcl_PackageInitProc *) NULL);
+ Tcl_StaticPackage(interp, "Tktest", Tktest_Init, 0);
#endif /* TK_TEST */
/*
@@ -113,7 +126,8 @@ Tcl_AppInit(
* return TCL_ERROR;
* }
*
- * where "Mod" is the name of the module.
+ * where "Mod" is the name of the module. (Dynamically-loadable packages
+ * should have the same entry-point name.)
*/
/*
@@ -125,10 +139,11 @@ Tcl_AppInit(
* Specify a user-specific startup file to invoke if the application is
* run interactively. Typically the startup file is "~/.apprc" where "app"
* is the name of the application. If this line is deleted then no user-
- * -specific startup file will be run under any conditions.
+ * specific startup file will be run under any conditions.
*/
- Tcl_SetVar(interp, "tcl_rcFileName", "~/.wishrc", TCL_GLOBAL_ONLY);
+ Tcl_ObjSetVar2(interp, Tcl_NewStringObj("tcl_rcFileName", -1), NULL,
+ Tcl_NewStringObj("~/.wishrc", -1), TCL_GLOBAL_ONLY);
return TCL_OK;
}
diff --git a/unix/tkConfig.h.in b/unix/tkConfig.h.in
index 732bf94..392566b 100644
--- a/unix/tkConfig.h.in
+++ b/unix/tkConfig.h.in
@@ -7,12 +7,6 @@
/* Define if building universal (internal helper macro) */
#undef AC_APPLE_UNIVERSAL_BUILD
-/* Is pthread_attr_get_np() declared in <pthread.h>? */
-#undef ATTRGETNP_NOT_DECLARED
-
-/* Is pthread_getattr_np declared in <pthread.h>? */
-#undef GETATTRNP_NOT_DECLARED
-
/* Define to 1 if you have the <AvailabilityMacros.h> header file. */
#undef HAVE_AVAILABILITYMACROS_H
@@ -22,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
@@ -46,18 +43,9 @@
/* Define to 1 if you have the `pthread_atfork' function. */
#undef HAVE_PTHREAD_ATFORK
-/* Do we want a BSD-like thread-attribute interface? */
-#undef HAVE_PTHREAD_ATTR_GET_NP
-
/* Define to 1 if you have the `pthread_attr_setstacksize' function. */
#undef HAVE_PTHREAD_ATTR_SETSTACKSIZE
-/* Do we want a Linux-like thread-attribute interface? */
-#undef HAVE_PTHREAD_GETATTR_NP
-
-/* Define to 1 if you have the `pthread_get_stacksize_np' function. */
-#undef HAVE_PTHREAD_GET_STACKSIZE_NP
-
/* Does struct password have a pw_gecos field? */
#undef HAVE_PW_GECOS
@@ -118,7 +106,7 @@
/* Are we building TkAqua? */
#undef MAC_OSX_TK
-/* Compiler support for module scope symbols */
+/* No Compiler support for module scope symbols */
#undef MODULE_SCOPE
/* Is no debugging enabled? */
@@ -211,6 +199,9 @@
# endif
#endif
+/* Is XKeycodeToKeysym deprecated? */
+#undef XKEYCODETOKEYSYM_IS_DEPRECATED
+
/* Are Darwin SUSv3 extensions available? */
#undef _DARWIN_C_SOURCE
@@ -249,6 +240,12 @@
/* Define to `int' if <sys/types.h> doesn't define. */
#undef gid_t
+/* Define to `__inline__' or `__inline' if that's what the C compiler
+ calls it, or to nothing if 'inline' is not supported under any name. */
+#ifndef __cplusplus
+#undef inline
+#endif
+
/* Signed integer type wide enough to hold a pointer. */
#undef intptr_t
diff --git a/unix/tkUnix.c b/unix/tkUnix.c
index 3fa7387..c6fff82 100644
--- a/unix/tkUnix.c
+++ b/unix/tkUnix.c
@@ -13,7 +13,14 @@
#include "tkInt.h"
#ifdef HAVE_XSS
-#include <X11/extensions/scrnsaver.h>
+# include <X11/extensions/scrnsaver.h>
+# ifdef __APPLE__
+/* Support for weak-linked libXss. */
+# define HaveXSSLibrary() (XScreenSaverQueryInfo != NULL)
+# else
+/* Other platforms always link libXss. */
+# define HaveXSSLibrary() (1)
+# endif
#endif
/*
@@ -26,7 +33,7 @@
* server" command.
*
* Results:
- * None.
+ * Sets the interpreter result.
*
* Side effects:
* None.
@@ -41,14 +48,11 @@ TkGetServerInfo(
Tk_Window tkwin) /* Token for window; this selects a particular
* display and server. */
{
- char buffer[8 + TCL_INTEGER_SPACE * 2];
- char buffer2[TCL_INTEGER_SPACE];
-
- sprintf(buffer, "X%dR%d ", ProtocolVersion(Tk_Display(tkwin)),
- ProtocolRevision(Tk_Display(tkwin)));
- sprintf(buffer2, " %d", VendorRelease(Tk_Display(tkwin)));
- Tcl_AppendResult(interp, buffer, ServerVendor(Tk_Display(tkwin)),
- buffer2, (char *) NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf("X%dR%d %s %d",
+ ProtocolVersion(Tk_Display(tkwin)),
+ ProtocolRevision(Tk_Display(tkwin)),
+ ServerVendor(Tk_Display(tkwin)),
+ VendorRelease(Tk_Display(tkwin))));
}
/*
@@ -69,11 +73,11 @@ TkGetServerInfo(
*----------------------------------------------------------------------
*/
-CONST char *
+const char *
TkGetDefaultScreenName(
Tcl_Interp *interp, /* Interp used to find environment
* variables. */
- CONST char *screenName) /* Screen name from command line, or NULL. */
+ const char *screenName) /* Screen name from command line, or NULL. */
{
if ((screenName == NULL) || (screenName[0] == '\0')) {
screenName = Tcl_GetVar2(interp, "env", "DISPLAY", TCL_GLOBAL_ONLY);
@@ -207,13 +211,9 @@ Tk_GetUserInactiveTime(
* on some buggy versions of XFree86.
*/
- if (
-#ifdef __APPLE__
- XScreenSaverQueryInfo != NULL && /* Support for weak-linked libXss. */
-#endif
- XScreenSaverQueryExtension(dpy, &eventBase, &errorBase) &&
- XScreenSaverQueryVersion(dpy, &major, &minor)) {
-
+ if (HaveXSSLibrary()
+ && XScreenSaverQueryExtension(dpy, &eventBase, &errorBase)
+ && XScreenSaverQueryVersion(dpy, &major, &minor)) {
XScreenSaverInfo *info = XScreenSaverAllocInfo();
if (info == NULL) {
diff --git a/unix/tkUnix3d.c b/unix/tkUnix3d.c
index 417866b..38ce683 100644
--- a/unix/tkUnix3d.c
+++ b/unix/tkUnix3d.c
@@ -46,7 +46,8 @@ typedef struct {
TkBorder *
TkpGetBorder(void)
{
- UnixBorder *borderPtr = (UnixBorder *) ckalloc(sizeof(UnixBorder));
+ UnixBorder *borderPtr = ckalloc(sizeof(UnixBorder));
+
borderPtr->solidGC = None;
return (TkBorder *) borderPtr;
}
@@ -377,7 +378,7 @@ TkpGetShadows(
*/
/*
- * Compute the dark shadow color
+ * Compute the dark shadow color.
*/
r = (int) borderPtr->bgColorPtr->red;
@@ -395,7 +396,7 @@ TkpGetShadows(
}
/*
- * Allocate the dark shadow color and its GC
+ * Allocate the dark shadow color and its GC.
*/
borderPtr->darkColorPtr = Tk_GetColorByValue(tkwin, &darkColor);
@@ -403,7 +404,7 @@ TkpGetShadows(
borderPtr->darkGC = Tk_GetGC(tkwin, GCForeground, &gcValues);
/*
- * Compute the light shadow color
+ * Compute the light shadow color.
*/
if (g > MAX_INTENSITY*0.95) {
@@ -431,9 +432,9 @@ TkpGetShadows(
lightColor.blue = (tmp1 > tmp2) ? tmp1 : tmp2;
}
- /*
- * Allocate the light shadow color and its GC
- */
+ /*
+ * Allocate the light shadow color and its GC.
+ */
borderPtr->lightColorPtr = Tk_GetColorByValue(tkwin, &lightColor);
gcValues.foreground = borderPtr->lightColorPtr->pixel;
diff --git a/unix/tkUnixButton.c b/unix/tkUnixButton.c
index 373f2e3..e45812e 100644
--- a/unix/tkUnixButton.c
+++ b/unix/tkUnixButton.c
@@ -35,9 +35,11 @@ typedef struct UnixButton {
* The class function table for the button widgets.
*/
-Tk_ClassProcs tkpButtonProcs = {
+const Tk_ClassProcs tkpButtonProcs = {
sizeof(Tk_ClassProcs), /* size */
TkButtonWorldChanged, /* worldChangedProc */
+ NULL, /* createProc */
+ NULL /* modalProc */
};
/*
@@ -55,7 +57,7 @@ Tk_ClassProcs tkpButtonProcs = {
*/
/* XPM */
-static char *button_images[] = {
+static const char *const button_images[] = {
/* width height ncolors chars_per_pixel */
"52 26 7 1",
/* colors */
@@ -279,7 +281,7 @@ TkpDrawCheckIndicator(
for (iy=0 ; iy<dim ; iy++) {
for (ix=0 ; ix<dim ; ix++) {
XPutPixel(img, ix, iy,
- imgColors[button_images[imgstart+iy][imgsel+ix] - 'A'] );
+ imgColors[button_images[imgstart+iy][imgsel+ix] - 'A']);
}
}
@@ -293,9 +295,9 @@ TkpDrawCheckIndicator(
copyGC = Tk_GetGC(tkwin, 0, &gcValues);
XPutImage(display, pixmap, copyGC, img, 0, 0, 0, 0,
- (unsigned int)dim, (unsigned int)dim);
+ (unsigned)dim, (unsigned)dim);
XCopyArea(display, pixmap, d, copyGC, 0, 0,
- (unsigned int)dim, (unsigned int)dim, x, y);
+ (unsigned)dim, (unsigned)dim, x, y);
/*
* Tidy up.
@@ -326,7 +328,8 @@ TkButton *
TkpCreateButton(
Tk_Window tkwin)
{
- UnixButton *butPtr = (UnixButton *) ckalloc(sizeof(UnixButton));
+ UnixButton *butPtr = ckalloc(sizeof(UnixButton));
+
return (TkButton *) butPtr;
}
diff --git a/unix/tkUnixColor.c b/unix/tkUnixColor.c
index 9474c95..43500ad 100644
--- a/unix/tkUnixColor.c
+++ b/unix/tkUnixColor.c
@@ -10,7 +10,7 @@
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
-#include "tkInt.h"
+#include "tkUnixInt.h"
#include "tkColor.h"
/*
@@ -137,16 +137,23 @@ TkpGetColor(
XColor screen;
if (((*name - 'A') & 0xdf) < sizeof(tkWebColors)/sizeof(tkWebColors[0])) {
- const char *p = tkWebColors[((*name - 'A') & 0x1f)];
- if (p) {
- const char *q = name;
- while (!((*p - *(++q)) & 0xdf)) {
- if (!*p++) {
- name = p;
- goto gotWebColor;
+ if (!((name[0] - 'G') & 0xdf) && !((name[1] - 'R') & 0xdf)
+ && !((name[2] - 'A') & 0xdb) && !((name[3] - 'Y') & 0xdf)
+ && !name[4]) {
+ name = "#808080808080";
+ goto gotWebColor;
+ } else {
+ const char *p = tkWebColors[((*name - 'A') & 0x1f)];
+ if (p) {
+ const char *q = name;
+ while (!((*p - *(++q)) & 0xdf)) {
+ if (!*p++) {
+ name = p;
+ goto gotWebColor;
+ }
}
}
- }
+ }
}
if (strlen(name) > 99) {
/* Don't bother to parse this. [Bug 2809525]*/
@@ -178,7 +185,7 @@ TkpGetColor(
}
}
- tkColPtr = (TkColor *) ckalloc(sizeof(TkColor));
+ tkColPtr = ckalloc(sizeof(TkColor));
tkColPtr->color = color;
return tkColPtr;
@@ -213,7 +220,7 @@ TkpGetColorByValue(
{
Display *display = Tk_Display(tkwin);
Colormap colormap = Tk_Colormap(tkwin);
- TkColor *tkColPtr = (TkColor *) ckalloc(sizeof(TkColor));
+ TkColor *tkColPtr = ckalloc(sizeof(TkColor));
tkColPtr->color.red = colorPtr->red;
tkColPtr->color.green = colorPtr->green;
@@ -271,7 +278,7 @@ FindClosestColor(
for (stressPtr = dispPtr->stressPtr; ; stressPtr = stressPtr->nextPtr) {
if (stressPtr == NULL) {
- stressPtr = (TkStressedCmap *) ckalloc(sizeof(TkStressedCmap));
+ stressPtr = ckalloc(sizeof(TkStressedCmap));
stressPtr->colormap = colormap;
template.visualid = XVisualIDFromVisual(Tk_Visual(tkwin));
@@ -283,8 +290,8 @@ FindClosestColor(
stressPtr->numColors = visInfoPtr->colormap_size;
XFree((char *) visInfoPtr);
- stressPtr->colorPtr = (XColor *) ckalloc((unsigned)
- (stressPtr->numColors * sizeof(XColor)));
+ stressPtr->colorPtr =
+ ckalloc(stressPtr->numColors * sizeof(XColor));
for (i = 0; i < stressPtr->numColors; i++) {
stressPtr->colorPtr[i].pixel = (unsigned long) i;
}
@@ -392,8 +399,8 @@ DeleteStressedCmap(
} else {
prevPtr->nextPtr = stressPtr->nextPtr;
}
- ckfree((char *) stressPtr->colorPtr);
- ckfree((char *) stressPtr);
+ ckfree(stressPtr->colorPtr);
+ ckfree(stressPtr);
return;
}
}
@@ -433,6 +440,7 @@ TkpCmapStressed(
return 0;
}
+
/*
* Local Variables:
* mode: c
diff --git a/unix/tkUnixConfig.c b/unix/tkUnixConfig.c
index 0b3af03..3584494 100644
--- a/unix/tkUnixConfig.c
+++ b/unix/tkUnixConfig.c
@@ -35,8 +35,8 @@
Tcl_Obj *
TkpGetSystemDefault(
Tk_Window tkwin, /* A window to use. */
- CONST char *dbName, /* The option database name. */
- CONST char *className) /* The name of the option class. */
+ const char *dbName, /* The option database name. */
+ const char *className) /* The name of the option class. */
{
return NULL;
}
diff --git a/unix/tkUnixCursor.c b/unix/tkUnixCursor.c
index 1ab238e..5266bde 100644
--- a/unix/tkUnixCursor.c
+++ b/unix/tkUnixCursor.c
@@ -28,8 +28,8 @@ typedef struct {
* the official cursor font:
*/
-static struct CursorName {
- CONST char *name;
+static const struct CursorName {
+ const char *name;
unsigned int shape;
} cursorNames[] = {
{"X_cursor", XC_X_cursor},
@@ -159,9 +159,9 @@ static struct CursorName {
#endif /* DEFINE_MYARROW_CURSOR */
-static struct TkCursorName {
- char *name;
- char *data;
+static const struct TkCursorName {
+ const char *name;
+ const char *data;
char *mask;
} tkCursorNames[] = {
{"none", CURSOR_NONE_DATA, NULL},
@@ -180,8 +180,8 @@ static struct TkCursorName {
#endif
static Cursor CreateCursorFromTableOrFile(Tcl_Interp *interp,
- Tk_Window tkwin, int argc, CONST char **argv,
- struct TkCursorName *tkCursorPtr);
+ Tk_Window tkwin, int argc, const char **argv,
+ const struct TkCursorName *tkCursorPtr);
/*
*----------------------------------------------------------------------
@@ -211,10 +211,10 @@ TkGetCursorByName(
TkUnixCursor *cursorPtr = NULL;
Cursor cursor = None;
int argc;
- CONST char **argv = NULL;
+ const char **argv = NULL;
Display *display = Tk_Display(tkwin);
int inTkTable = 0;
- struct TkCursorName* tkCursorPtr = NULL;
+ const struct TkCursorName *tkCursorPtr = NULL;
if (Tcl_SplitList(interp, string, &argc, &argv) != TCL_OK) {
return NULL;
@@ -245,7 +245,7 @@ TkGetCursorByName(
if ((argv[0][0] != '@') && !inTkTable) {
XColor fg, bg;
unsigned int maskIndex;
- register struct CursorName *namePtr;
+ register const struct CursorName *namePtr;
TkDisplay *dispPtr;
/*
@@ -275,8 +275,9 @@ TkGetCursorByName(
bg.red = bg.green = bg.blue = 65535;
} else {
if (TkParseColor(display, Tk_Colormap(tkwin), argv[1], &fg) == 0) {
- Tcl_AppendResult(interp, "invalid color name \"", argv[1],
- "\"", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "invalid color name \"%s\"", argv[1]));
+ Tcl_SetErrorCode(interp, "TK", "CURSOR", "COLOR", NULL);
goto cleanup;
}
if (argc == 2) {
@@ -284,8 +285,9 @@ TkGetCursorByName(
maskIndex = namePtr->shape;
} else if (TkParseColor(display, Tk_Colormap(tkwin), argv[2],
&bg) == 0) {
- Tcl_AppendResult(interp, "invalid color name \"", argv[2],
- "\"", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "invalid color name \"%s\"", argv[2]));
+ Tcl_SetErrorCode(interp, "TK", "CURSOR", "COLOR", NULL);
goto cleanup;
}
}
@@ -293,7 +295,9 @@ TkGetCursorByName(
if (dispPtr->cursorFont == None) {
dispPtr->cursorFont = XLoadFont(display, CURSORFONT);
if (dispPtr->cursorFont == None) {
- Tcl_SetResult(interp, "couldn't load cursor font", TCL_STATIC);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "couldn't load cursor font", -1));
+ Tcl_SetErrorCode(interp, "TK", "CURSOR", "FONT", NULL);
goto cleanup;
}
}
@@ -306,8 +310,10 @@ TkGetCursorByName(
*/
if (!inTkTable && Tcl_IsSafe(interp)) {
- Tcl_AppendResult(interp, "can't get cursor from a file in",
- " a safe interpreter", NULL);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "can't get cursor from a file in a safe interpreter",
+ -1));
+ Tcl_SetErrorCode(interp, "TK", "SAFE", "CURSOR_FILE", NULL);
cursorPtr = NULL;
goto cleanup;
}
@@ -332,25 +338,26 @@ TkGetCursorByName(
}
if (cursor != None) {
- cursorPtr = (TkUnixCursor *) ckalloc(sizeof(TkUnixCursor));
+ cursorPtr = ckalloc(sizeof(TkUnixCursor));
cursorPtr->info.cursor = (Tk_Cursor) cursor;
cursorPtr->display = display;
}
cleanup:
if (argv != NULL) {
- ckfree((char *) argv);
+ ckfree(argv);
}
return (TkCursor *) cursorPtr;
badString:
if (argv) {
- ckfree((char *) argv);
+ ckfree(argv);
}
- Tcl_AppendResult(interp, "bad cursor spec \"", string, "\"", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad cursor spec \"%s\"", string));
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "CURSOR", NULL);
return NULL;
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -375,8 +382,8 @@ CreateCursorFromTableOrFile(
Tcl_Interp *interp, /* Interpreter to use for error reporting. */
Tk_Window tkwin, /* Window in which cursor will be used. */
int argc,
- CONST char **argv, /* Cursor spec parsed into elements. */
- struct TkCursorName *tkCursorPtr)
+ const char **argv, /* Cursor spec parsed into elements. */
+ const struct TkCursorName *tkCursorPtr)
/* Non-NULL when cursor is defined in Tk
* table. */
{
@@ -386,8 +393,8 @@ CreateCursorFromTableOrFile(
int xHot = -1, yHot = -1;
int dummy1, dummy2;
XColor fg, bg;
- CONST char *fgColor;
- CONST char *bgColor;
+ const char *fgColor;
+ const char *bgColor;
int inTkTable = (tkCursorPtr != NULL);
Display *display = Tk_Display(tkwin);
@@ -419,8 +426,9 @@ CreateCursorFromTableOrFile(
data = TkGetBitmapData(NULL, tkCursorPtr->data, NULL,
&width, &height, &xHot, &yHot);
if (data == NULL) {
- Tcl_AppendResult(interp, "error reading bitmap data for \"",
- argv[0], "\"", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "error reading bitmap data for \"%s\"", argv[0]));
+ Tcl_SetErrorCode(interp, "TK", "CURSOR", "BITMAP_DATA", NULL);
goto cleanup;
}
@@ -428,22 +436,24 @@ CreateCursorFromTableOrFile(
ckfree(data);
} else {
if (TkReadBitmapFile(display, drawable, &argv[0][1],
- (unsigned int *) &width, (unsigned int *) &height,
+ (unsigned *) &width, (unsigned *) &height,
&source, &xHot, &yHot) != BitmapSuccess) {
- Tcl_AppendResult(interp, "cleanup reading bitmap file \"",
- &argv[0][1], "\"", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "cleanup reading bitmap file \"%s\"", &argv[0][1]));
+ Tcl_SetErrorCode(interp, "TK", "CURSOR", "BITMAP_FILE", NULL);
goto cleanup;
}
}
if ((xHot < 0) || (yHot < 0) || (xHot >= width) || (yHot >= height)) {
if (inTkTable) {
- Tcl_AppendResult(interp, "bad hot spot in bitmap data for \"",
- argv[0], "\"", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "bad hot spot in bitmap data for \"%s\"", argv[0]));
} else {
- Tcl_AppendResult(interp, "bad hot spot in bitmap file \"",
- &argv[0][1], "\"", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "bad hot spot in bitmap file \"%s\"", &argv[0][1]));
}
+ Tcl_SetErrorCode(interp, "TK", "CURSOR", "HOTSPOT", NULL);
goto cleanup;
}
@@ -457,8 +467,9 @@ CreateCursorFromTableOrFile(
} else if (argc == 2) {
fgColor = argv[1];
if (TkParseColor(display, Tk_Colormap(tkwin), fgColor, &fg) == 0) {
- Tcl_AppendResult(interp, "invalid color name \"",
- fgColor, "\"", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "invalid color name \"%s\"", fgColor));
+ Tcl_SetErrorCode(interp, "TK", "CURSOR", "COLOR", NULL);
goto cleanup;
}
if (inTkTable) {
@@ -476,13 +487,15 @@ CreateCursorFromTableOrFile(
bgColor = argv[3];
}
if (TkParseColor(display, Tk_Colormap(tkwin), fgColor, &fg) == 0) {
- Tcl_AppendResult(interp, "invalid color name \"",
- fgColor, "\"", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "invalid color name \"%s\"", fgColor));
+ Tcl_SetErrorCode(interp, "TK", "CURSOR", "COLOR", NULL);
goto cleanup;
}
if (TkParseColor(display, Tk_Colormap(tkwin), bgColor, &bg) == 0) {
- Tcl_AppendResult(interp, "invalid color name \"",
- bgColor, "\"", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "invalid color name \"%s\"", bgColor));
+ Tcl_SetErrorCode(interp, "TK", "CURSOR", "COLOR", NULL);
goto cleanup;
}
}
@@ -511,8 +524,9 @@ CreateCursorFromTableOrFile(
data = TkGetBitmapData(NULL, tkCursorPtr->mask, NULL,
&maskWidth, &maskHeight, &dummy1, &dummy2);
if (data == NULL) {
- Tcl_AppendResult(interp, "error reading bitmap mask data for \"",
- argv[0], "\"", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "error reading bitmap mask data for \"%s\"", argv[0]));
+ Tcl_SetErrorCode(interp, "TK", "CURSOR", "MASK_DATA", NULL);
goto cleanup;
}
@@ -524,15 +538,17 @@ CreateCursorFromTableOrFile(
if (TkReadBitmapFile(display, drawable, argv[1],
(unsigned int *) &maskWidth, (unsigned int *) &maskHeight,
&mask, &dummy1, &dummy2) != BitmapSuccess) {
- Tcl_AppendResult(interp, "cleanup reading bitmap file \"",
- argv[1], "\"", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "cleanup reading bitmap file \"%s\"", argv[1]));
+ Tcl_SetErrorCode(interp, "TK", "CURSOR", "MASK_FILE", NULL);
goto cleanup;
}
}
if ((maskWidth != width) || (maskHeight != height)) {
- Tcl_SetResult(interp, "source and mask bitmaps have different sizes",
- TCL_STATIC);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "source and mask bitmaps have different sizes", -1));
+ Tcl_SetErrorCode(interp, "TK", "CURSOR", "SIZE_MATCH", NULL);
goto cleanup;
}
@@ -568,8 +584,8 @@ CreateCursorFromTableOrFile(
TkCursor *
TkCreateCursorFromData(
Tk_Window tkwin, /* Window in which cursor will be used. */
- CONST char *source, /* Bitmap data for cursor shape. */
- CONST char *mask, /* Bitmap data for cursor mask. */
+ const char *source, /* Bitmap data for cursor shape. */
+ const char *mask, /* Bitmap data for cursor mask. */
int width, int height, /* Dimensions of cursor. */
int xHot, int yHot, /* Location of hot-spot in cursor. */
XColor fgColor, /* Foreground color for cursor. */
@@ -592,7 +608,7 @@ TkCreateCursorFromData(
Tk_FreePixmap(display, maskPixmap);
if (cursor != None) {
- cursorPtr = (TkUnixCursor *) ckalloc(sizeof(TkUnixCursor));
+ cursorPtr = ckalloc(sizeof(TkUnixCursor));
cursorPtr->info.cursor = (Tk_Cursor) cursor;
cursorPtr->display = display;
}
diff --git a/unix/tkUnixDefault.h b/unix/tkUnixDefault.h
index 4eb8778..b922278 100644
--- a/unix/tkUnixDefault.h
+++ b/unix/tkUnixDefault.h
@@ -64,7 +64,7 @@
#define DEF_BUTTON_HIGHLIGHT BLACK
#define DEF_LABEL_HIGHLIGHT_WIDTH "0"
#define DEF_BUTTON_HIGHLIGHT_WIDTH "1"
-#define DEF_BUTTON_IMAGE (char *) NULL
+#define DEF_BUTTON_IMAGE ((char *) NULL)
#define DEF_BUTTON_INDICATOR "1"
#define DEF_BUTTON_JUSTIFY "center"
#define DEF_BUTTON_OFF_VALUE "0"
@@ -81,10 +81,10 @@
#define DEF_BUTTON_REPEAT_INTERVAL "0"
#define DEF_BUTTON_SELECT_COLOR CHECK_INDICATOR
#define DEF_BUTTON_SELECT_MONO BLACK
-#define DEF_BUTTON_SELECT_IMAGE (char *) NULL
+#define DEF_BUTTON_SELECT_IMAGE ((char *) NULL)
#define DEF_BUTTON_STATE "normal"
#define DEF_LABEL_TAKE_FOCUS "0"
-#define DEF_BUTTON_TAKE_FOCUS (char *) NULL
+#define DEF_BUTTON_TAKE_FOCUS ((char *) NULL)
#define DEF_BUTTON_TEXT ""
#define DEF_BUTTON_TEXT_VARIABLE ""
#define DEF_BUTTON_UNDERLINE "-1"
@@ -122,7 +122,7 @@
#define DEF_CANVAS_SELECT_BD_MONO "0"
#define DEF_CANVAS_SELECT_FG_COLOR BLACK
#define DEF_CANVAS_SELECT_FG_MONO WHITE
-#define DEF_CANVAS_TAKE_FOCUS (char *) NULL
+#define DEF_CANVAS_TAKE_FOCUS ((char *) NULL)
#define DEF_CANVAS_WIDTH "10c"
#define DEF_CANVAS_X_SCROLL_CMD ""
#define DEF_CANVAS_X_SCROLL_INCREMENT "0"
@@ -163,9 +163,9 @@
#define DEF_ENTRY_SELECT_BD_MONO "0"
#define DEF_ENTRY_SELECT_FG_COLOR BLACK
#define DEF_ENTRY_SELECT_FG_MONO WHITE
-#define DEF_ENTRY_SHOW (char *) NULL
+#define DEF_ENTRY_SHOW ((char *) NULL)
#define DEF_ENTRY_STATE "normal"
-#define DEF_ENTRY_TAKE_FOCUS (char *) NULL
+#define DEF_ENTRY_TAKE_FOCUS ((char *) NULL)
#define DEF_ENTRY_TEXT_VARIABLE ""
#define DEF_ENTRY_WIDTH "20"
@@ -232,36 +232,36 @@
#define DEF_LISTBOX_SELECT_MODE "browse"
#define DEF_LISTBOX_SET_GRID "0"
#define DEF_LISTBOX_STATE "normal"
-#define DEF_LISTBOX_TAKE_FOCUS (char *) NULL
+#define DEF_LISTBOX_TAKE_FOCUS ((char *) NULL)
#define DEF_LISTBOX_WIDTH "20"
/*
* Defaults for individual entries of menus:
*/
-#define DEF_MENU_ENTRY_ACTIVE_BG (char *) NULL
-#define DEF_MENU_ENTRY_ACTIVE_FG (char *) NULL
-#define DEF_MENU_ENTRY_ACCELERATOR (char *) NULL
-#define DEF_MENU_ENTRY_BG (char *) NULL
+#define DEF_MENU_ENTRY_ACTIVE_BG ((char *) NULL)
+#define DEF_MENU_ENTRY_ACTIVE_FG ((char *) NULL)
+#define DEF_MENU_ENTRY_ACCELERATOR ((char *) NULL)
+#define DEF_MENU_ENTRY_BG ((char *) NULL)
#define DEF_MENU_ENTRY_BITMAP None
#define DEF_MENU_ENTRY_COLUMN_BREAK "0"
-#define DEF_MENU_ENTRY_COMMAND (char *) NULL
+#define DEF_MENU_ENTRY_COMMAND ((char *) NULL)
#define DEF_MENU_ENTRY_COMPOUND "none"
-#define DEF_MENU_ENTRY_FG (char *) NULL
-#define DEF_MENU_ENTRY_FONT (char *) NULL
+#define DEF_MENU_ENTRY_FG ((char *) NULL)
+#define DEF_MENU_ENTRY_FONT ((char *) NULL)
#define DEF_MENU_ENTRY_HIDE_MARGIN "0"
-#define DEF_MENU_ENTRY_IMAGE (char *) NULL
+#define DEF_MENU_ENTRY_IMAGE ((char *) NULL)
#define DEF_MENU_ENTRY_INDICATOR "1"
-#define DEF_MENU_ENTRY_LABEL (char *) NULL
-#define DEF_MENU_ENTRY_MENU (char *) NULL
+#define DEF_MENU_ENTRY_LABEL ((char *) NULL)
+#define DEF_MENU_ENTRY_MENU ((char *) NULL)
#define DEF_MENU_ENTRY_OFF_VALUE "0"
#define DEF_MENU_ENTRY_ON_VALUE "1"
-#define DEF_MENU_ENTRY_SELECT_IMAGE (char *) NULL
+#define DEF_MENU_ENTRY_SELECT_IMAGE ((char *) NULL)
#define DEF_MENU_ENTRY_STATE "normal"
-#define DEF_MENU_ENTRY_VALUE (char *) NULL
-#define DEF_MENU_ENTRY_CHECK_VARIABLE (char *) NULL
+#define DEF_MENU_ENTRY_VALUE ((char *) NULL)
+#define DEF_MENU_ENTRY_CHECK_VARIABLE ((char *) NULL)
#define DEF_MENU_ENTRY_RADIO_VARIABLE "selectedButton"
-#define DEF_MENU_ENTRY_SELECT (char *) NULL
+#define DEF_MENU_ENTRY_SELECT ((char *) NULL)
#define DEF_MENU_ENTRY_UNDERLINE "-1"
/*
@@ -287,7 +287,7 @@
#define DEF_MENU_SELECT_MONO BLACK
#define DEF_MENU_TAKE_FOCUS "0"
#define DEF_MENU_TEAROFF "1"
-#define DEF_MENU_TEAROFF_CMD (char *) NULL
+#define DEF_MENU_TEAROFF_CMD ((char *) NULL)
#define DEF_MENU_TITLE ""
#define DEF_MENU_TYPE "normal"
@@ -315,7 +315,7 @@
#define DEF_MENUBUTTON_HIGHLIGHT_BG_MONO DEF_MENUBUTTON_BG_MONO
#define DEF_MENUBUTTON_HIGHLIGHT BLACK
#define DEF_MENUBUTTON_HIGHLIGHT_WIDTH "0"
-#define DEF_MENUBUTTON_IMAGE (char *) NULL
+#define DEF_MENUBUTTON_IMAGE ((char *) NULL)
#define DEF_MENUBUTTON_INDICATOR "0"
#define DEF_MENUBUTTON_JUSTIFY "center"
#define DEF_MENUBUTTON_MENU ""
@@ -415,7 +415,7 @@
#define DEF_SCALE_LENGTH "100"
#define DEF_SCALE_ORIENT "vertical"
#define DEF_SCALE_RELIEF "flat"
-#define DEF_SCALE_REPEAT_DELAY "300"
+#define DEF_SCALE_REPEAT_DELAY "300"
#define DEF_SCALE_REPEAT_INTERVAL "100"
#define DEF_SCALE_RESOLUTION "1"
#define DEF_SCALE_TROUGH_COLOR TROUGH
@@ -424,7 +424,7 @@
#define DEF_SCALE_SLIDER_LENGTH "30"
#define DEF_SCALE_SLIDER_RELIEF "raised"
#define DEF_SCALE_STATE "normal"
-#define DEF_SCALE_TAKE_FOCUS (char *) NULL
+#define DEF_SCALE_TAKE_FOCUS ((char *) NULL)
#define DEF_SCALE_TICK_INTERVAL "0"
#define DEF_SCALE_TO "100"
#define DEF_SCALE_VARIABLE ""
@@ -451,7 +451,7 @@
#define DEF_SCROLLBAR_RELIEF "sunken"
#define DEF_SCROLLBAR_REPEAT_DELAY "300"
#define DEF_SCROLLBAR_REPEAT_INTERVAL "100"
-#define DEF_SCROLLBAR_TAKE_FOCUS (char *) NULL
+#define DEF_SCROLLBAR_TAKE_FOCUS ((char *) NULL)
#define DEF_SCROLLBAR_TROUGH_COLOR TROUGH
#define DEF_SCROLLBAR_TROUGH_MONO WHITE
#define DEF_SCROLLBAR_WIDTH "11"
@@ -478,8 +478,9 @@
#define DEF_TEXT_INSERT_BD_MONO "0"
#define DEF_TEXT_INSERT_OFF_TIME "300"
#define DEF_TEXT_INSERT_ON_TIME "600"
+#define DEF_TEXT_INSERT_UNFOCUSSED "none"
#define DEF_TEXT_INSERT_WIDTH "2"
-#define DEF_TEXT_MAX_UNDO "0"
+#define DEF_TEXT_MAX_UNDO "0"
#define DEF_TEXT_PADX "1"
#define DEF_TEXT_PADY "1"
#define DEF_TEXT_RELIEF "sunken"
@@ -498,8 +499,8 @@
#define DEF_TEXT_STATE "normal"
#define DEF_TEXT_TABS ""
#define DEF_TEXT_TABSTYLE "tabular"
-#define DEF_TEXT_TAKE_FOCUS (char *) NULL
-#define DEF_TEXT_UNDO "0"
+#define DEF_TEXT_TAKE_FOCUS ((char *) NULL)
+#define DEF_TEXT_UNDO "0"
#define DEF_TEXT_WIDTH "80"
#define DEF_TEXT_WRAP "char"
#define DEF_TEXT_XSCROLL_COMMAND ""
@@ -521,4 +522,10 @@
#define DEF_TOPLEVEL_SCREEN ""
#define DEF_TOPLEVEL_USE ""
+/*
+ * Defaults for busy windows:
+ */
+
+#define DEF_BUSY_CURSOR "watch"
+
#endif /* _TKUNIXDEFAULT */
diff --git a/unix/tkUnixDialog.c b/unix/tkUnixDialog.c
index 2b86ca6..afe443f 100644
--- a/unix/tkUnixDialog.c
+++ b/unix/tkUnixDialog.c
@@ -39,21 +39,21 @@ EvalObjv(
Tcl_Interp *interp, /* Current interpreter. */
char *cmdName, /* Name of the TCL command to call */
int objc, /* Number of arguments. */
- Tcl_Obj *CONST *objv) /* Arguments. */
+ Tcl_Obj *const *objv) /* Arguments. */
{
Tcl_Obj *cmdObj, **objs;
int result;
cmdObj = Tcl_NewStringObj(cmdName, -1);
Tcl_IncrRefCount(cmdObj);
- objs = (Tcl_Obj **) ckalloc(sizeof(Tcl_Obj*) * (unsigned)(objc+1));
+ objs = ckalloc(sizeof(Tcl_Obj *) * (objc+1));
objs[0] = cmdObj;
memcpy(objs+1, objv, sizeof(Tcl_Obj *) * (unsigned)objc);
result = Tcl_EvalObjv(interp, objc+1, objs, 0);
Tcl_DecrRefCount(cmdObj);
- ckfree((char *) objs);
+ ckfree(objs);
return result;
}
@@ -82,7 +82,7 @@ Tk_ChooseColorObjCmd(
ClientData clientData, /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
- Tcl_Obj *CONST *objv) /* Arguments. */
+ Tcl_Obj *const *objv) /* Arguments. */
{
return EvalObjv(interp, "tk::ColorDialog", objc-1, objv+1);
}
@@ -111,9 +111,9 @@ Tk_GetOpenFileObjCmd(
ClientData clientData, /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
- Tcl_Obj *CONST *objv) /* Arguments. */
+ Tcl_Obj *const *objv) /* Arguments. */
{
- Tk_Window tkwin = (Tk_Window)clientData;
+ Tk_Window tkwin = clientData;
if (Tk_StrictMotif(tkwin)) {
return EvalObjv(interp, "tk::MotifOpenFDialog", objc-1, objv+1);
@@ -143,9 +143,9 @@ Tk_GetSaveFileObjCmd(
ClientData clientData, /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
- Tcl_Obj *CONST *objv) /* Arguments. */
+ Tcl_Obj *const *objv) /* Arguments. */
{
- Tk_Window tkwin = (Tk_Window)clientData;
+ Tk_Window tkwin = clientData;
if (Tk_StrictMotif(tkwin)) {
return EvalObjv(interp, "tk::MotifSaveFDialog", objc-1, objv+1);
@@ -177,7 +177,7 @@ Tk_MessageBoxCmd(
ClientData clientData, /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
- Tcl_Obj *CONST *objv) /* Arguments. */
+ Tcl_Obj *const *objv) /* Arguments. */
{
return EvalObjv(interp, "tk::MessageBox", objc-1, objv+1);
}
diff --git a/unix/tkUnixDraw.c b/unix/tkUnixDraw.c
index c0d4d7f..55f7464 100644
--- a/unix/tkUnixDraw.c
+++ b/unix/tkUnixDraw.c
@@ -32,7 +32,7 @@ typedef struct ScrollInfo {
* Forward declarations for functions declared later in this file:
*/
-static Tk_RestrictAction ScrollRestrictProc(ClientData arg, XEvent *eventPtr);
+static Tk_RestrictProc ScrollRestrictProc;
/*
*----------------------------------------------------------------------
@@ -63,8 +63,8 @@ TkScrollWindow(
int dx, int dy, /* Distance rectangle should be moved. */
TkRegion damageRgn) /* Region to accumulate damage in. */
{
- Tk_RestrictProc *oldProc;
- ClientData oldArg, dummy;
+ Tk_RestrictProc *prevProc;
+ ClientData prevArg;
ScrollInfo info;
XCopyArea(Tk_Display(tkwin), Tk_WindowId(tkwin), Tk_WindowId(tkwin), gc,
@@ -84,12 +84,11 @@ TkScrollWindow(
*/
TkpSync(info.display);
- oldProc = Tk_RestrictEvents(ScrollRestrictProc, (ClientData) &info,
- &oldArg);
+ prevProc = Tk_RestrictEvents(ScrollRestrictProc, &info, &prevArg);
while (!info.done) {
Tcl_ServiceEvent(TCL_WINDOW_EVENTS);
}
- Tk_RestrictEvents(oldProc, oldArg, &dummy);
+ Tk_RestrictEvents(prevProc, prevArg, &prevArg);
if (XEmptyRegion((Region) damageRgn)) {
return 0;
diff --git a/unix/tkUnixEmbed.c b/unix/tkUnixEmbed.c
index 5b5f486..8a4c368 100644
--- a/unix/tkUnixEmbed.c
+++ b/unix/tkUnixEmbed.c
@@ -4,7 +4,7 @@
* This file contains platform-specific functions for UNIX to provide
* basic operations needed for application embedding (where one
* application can use as its main window an internal window from some
- * other application).
+ * other application). Also includes code to support busy windows.
*
* Copyright (c) 1996-1997 Sun Microsystems, Inc.
*
@@ -13,6 +13,7 @@
*/
#include "tkUnixInt.h"
+#include "tkBusy.h"
/*
* One of the following structures exists for each container in this
@@ -95,7 +96,7 @@ TkpUseWindow(
* string is bogus. */
Tk_Window tkwin, /* Tk window that does not yet have an
* associated X window. */
- CONST char *string) /* String identifying an X window to use for
+ const char *string) /* String identifying an X window to use for
* tkwin; must be an integer value. */
{
TkWindow *winPtr = (TkWindow *) tkwin;
@@ -105,12 +106,13 @@ TkpUseWindow(
Tk_ErrorHandler handler;
Container *containerPtr;
XWindowAttributes parentAtts;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (winPtr->window != None) {
- Tcl_AppendResult(interp,
- "can't modify container after widget is created", NULL);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "can't modify container after widget is created", -1));
+ Tcl_SetErrorCode(interp, "TK", "EMBED", "POST_CREATE", NULL);
return TCL_ERROR;
}
if (Tcl_GetInt(interp, string, &id) != TCL_OK) {
@@ -119,12 +121,12 @@ TkpUseWindow(
parent = (Window) id;
usePtr = (TkWindow *) Tk_IdToWindow(winPtr->display, parent);
- if (usePtr != NULL) {
- if (!(usePtr->flags & TK_CONTAINER)) {
- Tcl_AppendResult(interp, "window \"", usePtr->pathName,
- "\" doesn't have -container option set", NULL);
- return TCL_ERROR;
- }
+ if (usePtr != NULL && !(usePtr->flags & TK_CONTAINER)) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "window \"%s\" doesn't have -container option set",
+ usePtr->pathName));
+ Tcl_SetErrorCode(interp, "TK", "EMBED", "CONTAINER", NULL);
+ return TCL_ERROR;
}
/*
@@ -136,7 +138,7 @@ TkpUseWindow(
anyError = 0;
handler = Tk_CreateErrorHandler(winPtr->display, -1, -1, -1,
- EmbedErrorProc, (ClientData) &anyError);
+ EmbedErrorProc, &anyError);
if (!XGetWindowAttributes(winPtr->display, parent, &parentAtts)) {
anyError = 1;
}
@@ -144,8 +146,9 @@ TkpUseWindow(
Tk_DeleteErrorHandler(handler);
if (anyError) {
if (interp != NULL) {
- Tcl_AppendResult(interp, "couldn't create child of window \"",
- string, "\"", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "couldn't create child of window \"%s\"", string));
+ Tcl_SetErrorCode(interp, "TK", "EMBED", "NO_TARGET", NULL);
}
return TCL_ERROR;
}
@@ -158,7 +161,7 @@ TkpUseWindow(
*/
Tk_CreateEventHandler(tkwin, StructureNotifyMask, EmbeddedEventProc,
- (ClientData) winPtr);
+ winPtr);
/*
* Save information about the container and the embedded window in a
@@ -176,7 +179,7 @@ TkpUseWindow(
}
}
if (containerPtr == NULL) {
- containerPtr = (Container *) ckalloc(sizeof(Container));
+ containerPtr = ckalloc(sizeof(Container));
containerPtr->parent = parent;
containerPtr->parentRoot = parentAtts.root;
containerPtr->parentPtr = NULL;
@@ -214,7 +217,7 @@ TkpMakeWindow(
* the window is to be created. */
{
Container *containerPtr;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (winPtr->flags & TK_EMBEDDED) {
@@ -270,7 +273,7 @@ TkpMakeContainer(
{
TkWindow *winPtr = (TkWindow *) tkwin;
Container *containerPtr;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
@@ -279,7 +282,7 @@ TkpMakeContainer(
*/
Tk_MakeWindowExist(tkwin);
- containerPtr = (Container *) ckalloc(sizeof(Container));
+ containerPtr = ckalloc(sizeof(Container));
containerPtr->parent = Tk_WindowId(tkwin);
containerPtr->parentRoot = RootWindowOfScreen(Tk_Screen(tkwin));
containerPtr->parentPtr = winPtr;
@@ -300,11 +303,11 @@ TkpMakeContainer(
XSelectInput(winPtr->display, winPtr->window, winPtr->atts.event_mask);
Tk_CreateEventHandler(tkwin,
SubstructureNotifyMask|SubstructureRedirectMask,
- ContainerEventProc, (ClientData) winPtr);
+ ContainerEventProc, winPtr);
Tk_CreateEventHandler(tkwin, StructureNotifyMask, EmbedStructureProc,
- (ClientData) containerPtr);
+ containerPtr);
Tk_CreateEventHandler(tkwin, FocusChangeMask, EmbedFocusProc,
- (ClientData) containerPtr);
+ containerPtr);
}
/*
@@ -330,7 +333,7 @@ EmbedErrorProc(
XErrorEvent *errEventPtr) /* Points to information about error (not
* used). */
{
- int *iPtr = (int *) clientData;
+ int *iPtr = clientData;
*iPtr = 1;
return 0;
@@ -360,7 +363,7 @@ EmbeddedEventProc(
ClientData clientData, /* Token for container window. */
XEvent *eventPtr) /* ResizeRequest event. */
{
- TkWindow *winPtr = (TkWindow *) clientData;
+ TkWindow *winPtr = clientData;
if (eventPtr->type == DestroyNotify) {
EmbedWindowDeleted(winPtr);
@@ -392,10 +395,10 @@ ContainerEventProc(
ClientData clientData, /* Token for container window. */
XEvent *eventPtr) /* ResizeRequest event. */
{
- TkWindow *winPtr = (TkWindow *) clientData;
+ TkWindow *winPtr = clientData;
Container *containerPtr;
Tk_ErrorHandler errHandler;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
@@ -405,7 +408,7 @@ ContainerEventProc(
*/
errHandler = Tk_CreateErrorHandler(eventPtr->xfocus.display, -1,
- -1, -1, NULL, (ClientData) NULL);
+ -1, -1, NULL, NULL);
/*
* Find the Container structure associated with the parent window.
@@ -497,7 +500,7 @@ EmbedStructureProc(
ClientData clientData, /* Token for container window. */
XEvent *eventPtr) /* ResizeRequest event. */
{
- Container *containerPtr = (Container *) clientData;
+ Container *containerPtr = clientData;
Tk_ErrorHandler errHandler;
if (eventPtr->type == ConfigureNotify) {
@@ -508,7 +511,7 @@ EmbedStructureProc(
*/
errHandler = Tk_CreateErrorHandler(eventPtr->xfocus.display, -1,
- -1, -1, NULL, (ClientData) NULL);
+ -1, -1, NULL, NULL);
XMoveResizeWindow(eventPtr->xconfigure.display,
containerPtr->wrapper, 0, 0,
(unsigned) Tk_Width((Tk_Window) containerPtr->parentPtr),
@@ -544,7 +547,7 @@ EmbedFocusProc(
ClientData clientData, /* Token for container window. */
XEvent *eventPtr) /* ResizeRequest event. */
{
- Container *containerPtr = (Container *) clientData;
+ Container *containerPtr = clientData;
Tk_ErrorHandler errHandler;
Display *display;
@@ -559,7 +562,7 @@ EmbedFocusProc(
if (containerPtr->wrapper != None) {
errHandler = Tk_CreateErrorHandler(eventPtr->xfocus.display, -1,
- -1, -1, NULL, (ClientData) NULL);
+ -1, -1, NULL, NULL);
XSetInputFocus(display, containerPtr->wrapper, RevertToParent,
CurrentTime);
Tk_DeleteErrorHandler(errHandler);
@@ -702,7 +705,7 @@ TkpGetOtherWindow(
* window. */
{
Container *containerPtr;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
for (containerPtr = tsdPtr->firstContainerPtr;
@@ -748,7 +751,7 @@ TkpRedirectKeyEvent(
{
Container *containerPtr;
Window saved;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
@@ -820,7 +823,7 @@ TkpClaimFocus(
{
XEvent event;
Container *containerPtr;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (!(topLevelPtr->flags & TK_EMBEDDED)) {
@@ -865,13 +868,13 @@ TkpTestembedCmd(
ClientData clientData, /* Main window for application. */
Tcl_Interp *interp, /* Current interpreter. */
int argc, /* Number of arguments. */
- CONST char **argv) /* Argument strings. */
+ const char **argv) /* Argument strings. */
{
int all;
Container *containerPtr;
Tcl_DString dString;
char buffer[50];
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if ((argc > 1) && (strcmp(argv[1], "all") == 0)) {
@@ -941,7 +944,7 @@ EmbedWindowDeleted(
* deleted. */
{
Container *containerPtr, *prevPtr;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
@@ -972,7 +975,7 @@ EmbedWindowDeleted(
} else {
prevPtr->nextPtr = containerPtr->nextPtr;
}
- ckfree((char *) containerPtr);
+ ckfree(containerPtr);
}
}
@@ -999,7 +1002,7 @@ TkUnixContainerId(
TkWindow *winPtr) /* Tk's structure for an embedded window. */
{
Container *containerPtr;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
for (containerPtr = tsdPtr->firstContainerPtr;
@@ -1013,6 +1016,168 @@ TkUnixContainerId(
}
/*
+ *----------------------------------------------------------------------
+ *
+ * TkpShowBusyWindow --
+ *
+ * Makes a busy window "appear".
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Arranges for the busy window to start intercepting events and the
+ * cursor to change to the configured "hey, I'm busy!" setting.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void
+TkpShowBusyWindow(
+ TkBusy busy)
+{
+ Busy *busyPtr = (Busy *) busy;
+
+ if (busyPtr->tkBusy != NULL) {
+ Tk_MapWindow(busyPtr->tkBusy);
+
+ /*
+ * Always raise the busy window just in case new sibling windows have
+ * been created in the meantime. Can't use Tk_RestackWindow because it
+ * doesn't work under Win32.
+ */
+
+ XRaiseWindow(Tk_Display(busyPtr->tkBusy),
+ Tk_WindowId(busyPtr->tkBusy));
+ }
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TkpHideBusyWindow --
+ *
+ * Makes a busy window "disappear".
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Arranges for the busy window to stop intercepting events, and the
+ * cursor to change back to its normal setting.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void
+TkpHideBusyWindow(
+ TkBusy busy)
+{
+ Busy *busyPtr = (Busy *) busy;
+
+ if (busyPtr->tkBusy != NULL) {
+ Tk_UnmapWindow(busyPtr->tkBusy);
+ }
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TkpMakeTransparentWindowExist --
+ *
+ * Construct the platform-specific resources for a transparent window.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Moves the specified window in the stacking order.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void
+TkpMakeTransparentWindowExist(
+ Tk_Window tkwin, /* Token for window. */
+ Window parent) /* Parent window. */
+{
+ TkWindow *winPtr = (TkWindow *) tkwin;
+ long int mask = CWDontPropagate | CWEventMask;
+
+ /*
+ * Ignore the important events while the window is mapped.
+ */
+
+#define USER_EVENTS \
+ (EnterWindowMask | LeaveWindowMask | KeyPressMask | KeyReleaseMask | \
+ ButtonPressMask | ButtonReleaseMask | PointerMotionMask)
+#define PROP_EVENTS \
+ (KeyPressMask | KeyReleaseMask | ButtonPressMask | \
+ ButtonReleaseMask | PointerMotionMask)
+
+ winPtr->atts.do_not_propagate_mask = PROP_EVENTS;
+ winPtr->atts.event_mask = USER_EVENTS;
+ winPtr->changes.border_width = 0;
+ winPtr->depth = 0;
+
+ winPtr->window = XCreateWindow(winPtr->display, parent,
+ winPtr->changes.x, winPtr->changes.y,
+ (unsigned) winPtr->changes.width, /* width */
+ (unsigned) winPtr->changes.height, /* height */
+ (unsigned) winPtr->changes.border_width, /* border_width */
+ winPtr->depth, InputOnly, winPtr->visual, mask, &winPtr->atts);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TkpCreateBusy --
+ *
+ * Construct the platform-specific parts of a busy window. Note that this
+ * postpones the actual creation of the window resource until later.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Sets up part of the busy window structure.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void
+TkpCreateBusy(
+ Tk_FakeWin *winPtr,
+ Tk_Window tkRef,
+ Window *parentPtr,
+ Tk_Window tkParent,
+ TkBusy busy)
+{
+ Window root, parent, *dummy;
+ unsigned int count;
+
+ if (winPtr->flags & TK_REPARENTED) {
+ /*
+ * This works around a bug in the implementation of menubars for
+ * non-MacIntosh window systems (Win32 and X11). Tk doesn't reset the
+ * pointers to the parent window when the menu is reparented (since
+ * winPtr->parentPtr points to the wrong window). We get around this
+ * by determining the parent via the native API calls.
+ */
+
+ if (XQueryTree(Tk_Display(tkRef), Tk_WindowId(tkRef), &root,
+ &parent, &dummy, &count) > 0) {
+ XFree(dummy);
+ *parentPtr = parent;
+ } else {
+ *parentPtr = None;
+ }
+ } else {
+ *parentPtr = Tk_WindowId(tkParent);
+ }
+}
+
+/*
* Local Variables:
* mode: c
* c-basic-offset: 4
diff --git a/unix/tkUnixEvent.c b/unix/tkUnixEvent.c
index 0cc3731..9a29f51 100644
--- a/unix/tkUnixEvent.c
+++ b/unix/tkUnixEvent.c
@@ -118,7 +118,7 @@ DisplayExitHandler(
TkDisplay *
TkpOpenDisplay(
- CONST char *displayNameStr)
+ const char *displayNameStr)
{
TkDisplay *dispPtr;
Display *display;
@@ -128,6 +128,27 @@ TkpOpenDisplay(
int minor = 0;
int reason = 0;
unsigned int use_xkb = 0;
+ /* Disabled, until we have a better test. See [Bug 3613668] */
+#if 0 && defined(XKEYCODETOKEYSYM_IS_DEPRECATED) && defined(TCL_THREADS)
+ static int xinited = 0;
+ static Tcl_Mutex xinitMutex = NULL;
+
+ if (!xinited) {
+ Tcl_MutexLock(&xinitMutex);
+ if (!xinited) {
+ /* Necessary for threaded apps, of no consequence otherwise */
+ /* need only be called once, but must be called before *any* */
+ /* Xlib call is made. If xinitMutex is still NULL after the */
+ /* Tcl_MutexLock call, Tcl was compiled without threads so */
+ /* we cannot use XInitThreads() either. */
+ if (xinitMutex != NULL){
+ XInitThreads();
+ }
+ xinited = 1;
+ }
+ Tcl_MutexUnlock(&xinitMutex);
+ }
+#endif
/*
** Bug [3607830]: Before using Xkb, it must be initialized and confirmed
@@ -152,7 +173,7 @@ TkpOpenDisplay(
if (display == NULL) {
return NULL;
}
- dispPtr = (TkDisplay *) ckalloc(sizeof(TkDisplay));
+ dispPtr = ckalloc(sizeof(TkDisplay));
memset(dispPtr, 0, sizeof(TkDisplay));
dispPtr->display = display;
dispPtr->flags |= use_xkb;
@@ -160,7 +181,7 @@ TkpOpenDisplay(
OpenIM(dispPtr);
#endif
Tcl_CreateFileHandler(ConnectionNumber(display), TCL_READABLE,
- DisplayFileProc, (ClientData) dispPtr);
+ DisplayFileProc, dispPtr);
return dispPtr;
}
@@ -186,8 +207,6 @@ TkpCloseDisplay(
{
TkSendCleanup(dispPtr);
- TkFreeXId(dispPtr);
-
TkWmCleanup(dispPtr);
#ifdef TK_USE_INPUT_METHODS
@@ -236,7 +255,7 @@ TkClipCleanup(
dispPtr->windowAtom);
Tk_DestroyWindow(dispPtr->clipWindow);
- Tcl_Release((ClientData) dispPtr->clipWindow);
+ Tcl_Release(dispPtr->clipWindow);
dispPtr->clipWindow = NULL;
}
}
@@ -312,6 +331,9 @@ TransferXEventsToTcl(
int type;
XEvent x;
TkKeyEvent k;
+#ifdef GenericEvent
+ xGenericEvent xge;
+#endif
} event;
Window w;
TkDisplay *dispPtr = NULL;
@@ -329,6 +351,12 @@ TransferXEventsToTcl(
while (QLength(display) > 0) {
XNextEvent(display, &event.x);
+#ifdef GenericEvent
+ if (event.type == GenericEvent) {
+ Tcl_Panic("Wild GenericEvent; panic! (extension=%d,evtype=%d)",
+ event.xge.extension, event.xge.evtype);
+ }
+#endif
w = None;
if (event.type == KeyPress || event.type == KeyRelease) {
for (dispPtr = TkGetDisplayList(); ; dispPtr = dispPtr->nextPtr) {
@@ -577,7 +605,7 @@ TkUnixDoOneXEvent(
index = fd/(NBBY*sizeof(fd_mask));
bit = ((fd_mask)1) << (fd%(NBBY*sizeof(fd_mask)));
if ((readMask[index] & bit) || (QLength(dispPtr->display) > 0)) {
- DisplayFileProc((ClientData)dispPtr, TCL_READABLE);
+ DisplayFileProc(dispPtr, TCL_READABLE);
}
}
if (Tcl_ServiceEvent(TCL_WINDOW_EVENTS)) {
@@ -720,6 +748,22 @@ error:
}
#endif /* TK_USE_INPUT_METHODS */
+void
+TkpWarpPointer(
+ TkDisplay *dispPtr)
+{
+ Window w; /* Which window to warp relative to. */
+
+ if (dispPtr->warpWindow != NULL) {
+ w = Tk_WindowId(dispPtr->warpWindow);
+ } else {
+ w = RootWindow(dispPtr->display,
+ Tk_ScreenNumber(dispPtr->warpMainwin));
+ }
+ XWarpPointer(dispPtr->display, None, w, 0, 0, 0, 0,
+ (int) dispPtr->warpX, (int) dispPtr->warpY);
+}
+
/*
* Local Variables:
* mode: c
diff --git a/unix/tkUnixFont.c b/unix/tkUnixFont.c
index 897770b..a4998aa 100644
--- a/unix/tkUnixFont.c
+++ b/unix/tkUnixFont.c
@@ -19,7 +19,7 @@
* The preferred font encodings.
*/
-static CONST char *encodingList[] = {
+static const char *const encodingList[] = {
"iso8859-1", "jis0208", "jis0212", NULL
};
@@ -137,9 +137,9 @@ typedef struct UnixFont {
*/
typedef struct EncodingAlias {
- char *realName; /* The real name of the encoding to load if
+ const char *realName; /* The real name of the encoding to load if
* the provided name matched the pattern. */
- char *aliasPattern; /* Pattern for encoding name, of the form that
+ const char *aliasPattern; /* Pattern for encoding name, of the form that
* is acceptable to Tcl_StringMatch. */
} EncodingAlias;
@@ -205,31 +205,31 @@ static void FontPkgCleanup(ClientData clientData);
static FontFamily * AllocFontFamily(Display *display,
XFontStruct *fontStructPtr, int base);
static SubFont * CanUseFallback(UnixFont *fontPtr,
- CONST char *fallbackName, int ch,
+ const char *fallbackName, int ch,
SubFont **fixSubFontPtrPtr);
static SubFont * CanUseFallbackWithAliases(UnixFont *fontPtr,
- char *fallbackName, int ch,
+ const char *fallbackName, int ch,
Tcl_DString *nameTriedPtr,
SubFont **fixSubFontPtrPtr);
-static int ControlUtfProc(ClientData clientData, CONST char *src,
+static int ControlUtfProc(ClientData clientData, const char *src,
int srcLen, int flags, Tcl_EncodingState*statePtr,
char *dst, int dstLen, int *srcReadPtr,
int *dstWrotePtr, int *dstCharsPtr);
static XFontStruct * CreateClosestFont(Tk_Window tkwin,
- CONST TkFontAttributes *faPtr,
- CONST TkXLFDAttributes *xaPtr);
+ const TkFontAttributes *faPtr,
+ const TkXLFDAttributes *xaPtr);
static SubFont * FindSubFontForChar(UnixFont *fontPtr, int ch,
SubFont **fixSubFontPtrPtr);
static void FontMapInsert(SubFont *subFontPtr, int ch);
static void FontMapLoadPage(SubFont *subFontPtr, int row);
static int FontMapLookup(SubFont *subFontPtr, int ch);
static void FreeFontFamily(FontFamily *afPtr);
-static CONST char * GetEncodingAlias(CONST char *name);
+static const char * GetEncodingAlias(const char *name);
static int GetFontAttributes(Display *display,
XFontStruct *fontStructPtr, FontAttributes *faPtr);
static XFontStruct * GetScreenFont(Display *display,
FontAttributes *wantPtr, char **nameList,
- int bestIdx[], unsigned int bestScore[]);
+ int bestIdx[], unsigned bestScore[]);
static XFontStruct * GetSystemFont(Display *display);
static int IdentifySymbolEncodings(FontAttributes *faPtr);
static void InitFont(Tk_Window tkwin, XFontStruct *fontStructPtr,
@@ -237,21 +237,21 @@ static void InitFont(Tk_Window tkwin, XFontStruct *fontStructPtr,
static void InitSubFont(Display *display,
XFontStruct *fontStructPtr, int base,
SubFont *subFontPtr);
-static char ** ListFonts(Display *display, CONST char *faceName,
+static char ** ListFonts(Display *display, const char *faceName,
int *numNamesPtr);
-static char ** ListFontOrAlias(Display *display, CONST char*faceName,
+static char ** ListFontOrAlias(Display *display, const char*faceName,
int *numNamesPtr);
-static unsigned int RankAttributes(FontAttributes *wantPtr,
+static unsigned RankAttributes(FontAttributes *wantPtr,
FontAttributes *gotPtr);
static void ReleaseFont(UnixFont *fontPtr);
static void ReleaseSubFont(Display *display, SubFont *subFontPtr);
-static int SeenName(CONST char *name, Tcl_DString *dsPtr);
+static int SeenName(const char *name, Tcl_DString *dsPtr);
#ifndef WORDS_BIGENDIAN
-static int Ucs2beToUtfProc(ClientData clientData, CONST char*src,
+static int Ucs2beToUtfProc(ClientData clientData, const char*src,
int srcLen, int flags, Tcl_EncodingState*statePtr,
char *dst, int dstLen, int *srcReadPtr,
int *dstWrotePtr, int *dstCharsPtr);
-static int UtfToUcs2beProc(ClientData clientData, CONST char*src,
+static int UtfToUcs2beProc(ClientData clientData, const char*src,
int srcLen, int flags, Tcl_EncodingState*statePtr,
char *dst, int dstLen, int *srcReadPtr,
int *dstWrotePtr, int *dstCharsPtr);
@@ -279,7 +279,7 @@ static void
FontPkgCleanup(
ClientData clientData)
{
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (tsdPtr->controlFamily.encoding != NULL) {
@@ -318,7 +318,7 @@ void
TkpFontPkgInit(
TkMainInfo *mainPtr) /* The application being created. */
{
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
Tcl_EncodingType type;
SubFont dummy;
@@ -380,7 +380,7 @@ TkpFontPkgInit(
static int
ControlUtfProc(
ClientData clientData, /* Not used. */
- CONST char *src, /* Source string in UTF-8. */
+ const char *src, /* Source string in UTF-8. */
int srcLen, /* Source string length in bytes. */
int flags, /* Conversion control flags. */
Tcl_EncodingState *statePtr,/* Place for conversion routine to store state
@@ -404,7 +404,7 @@ ControlUtfProc(
* correspond to the bytes stored in the
* output buffer. */
{
- CONST char *srcStart, *srcEnd;
+ const char *srcStart, *srcEnd;
char *dstStart, *dstEnd;
Tcl_UniChar ch;
int result;
@@ -473,7 +473,7 @@ ControlUtfProc(
static int
Ucs2beToUtfProc(
ClientData clientData, /* Not used. */
- CONST char *src, /* Source string in Unicode. */
+ const char *src, /* Source string in Unicode. */
int srcLen, /* Source string length in bytes. */
int flags, /* Conversion control flags. */
Tcl_EncodingState *statePtr,/* Place for conversion routine to store state
@@ -497,7 +497,7 @@ Ucs2beToUtfProc(
* correspond to the bytes stored in the
* output buffer. */
{
- CONST char *srcStart, *srcEnd;
+ const char *srcStart, *srcEnd;
char *dstEnd, *dstStart;
int result, numChars;
@@ -556,7 +556,7 @@ static int
UtfToUcs2beProc(
ClientData clientData, /* TableEncodingData that specifies
* encoding. */
- CONST char *src, /* Source string in UTF-8. */
+ const char *src, /* Source string in UTF-8. */
int srcLen, /* Source string length in bytes. */
int flags, /* Conversion control flags. */
Tcl_EncodingState *statePtr,/* Place for conversion routine to store state
@@ -580,14 +580,14 @@ UtfToUcs2beProc(
* correspond to the bytes stored in the
* output buffer. */
{
- CONST char *srcStart, *srcEnd, *srcClose, *dstStart, *dstEnd;
+ const char *srcStart, *srcEnd, *srcClose, *dstStart, *dstEnd;
int result, numChars;
Tcl_UniChar ch;
srcStart = src;
srcEnd = src + srcLen;
srcClose = srcEnd;
- if ((flags & TCL_ENCODING_END) == 0) {
+ if (!(flags & TCL_ENCODING_END)) {
srcClose -= TCL_UTF_MAX;
}
@@ -656,12 +656,12 @@ UtfToUcs2beProc(
TkFont *
TkpGetNativeFont(
Tk_Window tkwin, /* For display where font will be used. */
- CONST char *name) /* Platform-specific font name. */
+ const char *name) /* Platform-specific font name. */
{
UnixFont *fontPtr;
XFontStruct *fontStructPtr;
FontAttributes fa;
- CONST char *p;
+ const char *p;
int hasSpace, dashes, hasWild;
/*
@@ -719,7 +719,7 @@ TkpGetNativeFont(
}
fontStructPtr = CreateClosestFont(tkwin, &fa.fa, &fa.xa);
}
- fontPtr = (UnixFont *) ckalloc(sizeof(UnixFont));
+ fontPtr = ckalloc(sizeof(UnixFont));
InitFont(tkwin, fontStructPtr, fontPtr);
return (TkFont *) fontPtr;
@@ -763,7 +763,7 @@ TkpGetFontFromAttributes(
* will be released. If NULL, a new TkFont
* structure is allocated. */
Tk_Window tkwin, /* For display where font will be used. */
- CONST TkFontAttributes *faPtr)
+ const TkFontAttributes *faPtr)
/* Set of attributes to match. */
{
UnixFont *fontPtr;
@@ -775,7 +775,7 @@ TkpGetFontFromAttributes(
fontPtr = (UnixFont *) tkFontPtr;
if (fontPtr == NULL) {
- fontPtr = (UnixFont *) ckalloc(sizeof(UnixFont));
+ fontPtr = ckalloc(sizeof(UnixFont));
} else {
ReleaseFont(fontPtr);
}
@@ -845,8 +845,6 @@ TkpGetFontFamilies(
Tcl_HashSearch search;
Tcl_Obj *resultPtr, *strPtr;
- resultPtr = Tcl_GetObjResult(interp);
-
Tcl_InitHashTable(&familyTable, TCL_STRING_KEYS);
nameList = ListFonts(Tk_Display(tkwin), "*", &numNames);
for (i = 0; i < numNames; i++) {
@@ -874,11 +872,13 @@ TkpGetFontFamilies(
XFreeFontNames(nameList);
hPtr = Tcl_FirstHashEntry(&familyTable, &search);
+ resultPtr = Tcl_NewObj();
while (hPtr != NULL) {
strPtr = Tcl_NewStringObj(Tcl_GetHashKey(&familyTable, hPtr), -1);
Tcl_ListObjAppendElement(NULL, resultPtr, strPtr);
hPtr = Tcl_NextHashEntry(&search);
}
+ Tcl_SetObjResult(interp, resultPtr);
Tcl_DeleteHashTable(&familyTable);
}
@@ -911,7 +911,7 @@ TkpGetSubFonts(
UnixFont *fontPtr;
FontFamily *familyPtr;
- resultPtr = Tcl_GetObjResult(interp);
+ resultPtr = Tcl_NewObj();
fontPtr = (UnixFont *) tkfont;
for (i = 0; i < fontPtr->numSubFonts; i++) {
familyPtr = fontPtr->subFontArray[i].familyPtr;
@@ -922,6 +922,7 @@ TkpGetSubFonts(
listPtr = Tcl_NewListObj(3, objv);
Tcl_ListObjAppendElement(NULL, resultPtr, listPtr);
}
+ Tcl_SetObjResult(interp, resultPtr);
}
/*
@@ -958,6 +959,7 @@ TkpGetFontAttrsForChar(
SubFont *thisSubFontPtr = FindSubFontForChar(fontPtr, c, &lastSubFontPtr);
/* Pointer to the subfont to use for the given
* character */
+
GetFontAttributes(Tk_Display(tkwin), thisSubFontPtr->fontStructPtr, &atts);
*faPtr = atts.fa;
}
@@ -986,7 +988,7 @@ TkpGetFontAttrsForChar(
int
Tk_MeasureChars(
Tk_Font tkfont, /* Font in which characters will be drawn. */
- CONST char *source, /* UTF-8 string to be displayed. Need not be
+ const char *source, /* UTF-8 string to be displayed. Need not be
* '\0' terminated. */
int numBytes, /* Maximum number of bytes to consider from
* source string. */
@@ -1025,7 +1027,7 @@ Tk_MeasureChars(
curX = 0;
curByte = 0;
} else if (maxLength < 0) {
- CONST char *p, *end, *next;
+ const char *p, *end, *next;
Tcl_UniChar ch;
SubFont *thisSubFontPtr;
FontFamily *familyPtr;
@@ -1078,11 +1080,11 @@ Tk_MeasureChars(
Tcl_DStringFree(&runString);
curByte = numBytes;
} else {
- CONST char *p, *end, *next, *term;
+ const char *p, *end, *next, *term;
int newX, termX, sawNonSpace, dstWrote;
Tcl_UniChar ch;
FontFamily *familyPtr;
- char buf[16];
+ XChar2b buf[8];
/*
* How many chars will fit in the space allotted? This first version
@@ -1104,14 +1106,14 @@ Tk_MeasureChars(
} else {
lastSubFontPtr = FindSubFontForChar(fontPtr, ch, NULL);
familyPtr = lastSubFontPtr->familyPtr;
- Tcl_UtfToExternal(NULL, familyPtr->encoding, p, next - p,
- 0, NULL, buf, sizeof(buf), NULL, &dstWrote, NULL);
+ Tcl_UtfToExternal(NULL, familyPtr->encoding, p, next - p, 0, NULL,
+ (char *)&buf[0].byte1, sizeof(buf), NULL, &dstWrote, NULL);
if (familyPtr->isTwoByteFont) {
newX += XTextWidth16(lastSubFontPtr->fontStructPtr,
- (XChar2b *) buf, dstWrote >> 1);
+ buf, dstWrote >> 1);
} else {
- newX += XTextWidth(lastSubFontPtr->fontStructPtr, buf,
- dstWrote);
+ newX += XTextWidth(lastSubFontPtr->fontStructPtr,
+ (char *)&buf[0].byte1, dstWrote);
}
}
if (newX > maxLength) {
@@ -1200,7 +1202,7 @@ Tk_MeasureChars(
int
TkpMeasureCharsInContext(
Tk_Font tkfont, /* Font in which characters will be drawn. */
- CONST char *source, /* UTF-8 string to be displayed. Need not be
+ const char *source, /* UTF-8 string to be displayed. Need not be
* '\0' terminated. */
int numBytes, /* Maximum number of bytes to consider from
* source string in all. */
@@ -1253,7 +1255,7 @@ Tk_DrawChars(
GC gc, /* Graphics context for drawing characters. */
Tk_Font tkfont, /* Font in which characters will be drawn;
* must be the same as font used in GC. */
- CONST char *source, /* UTF-8 string to be displayed. Need not be
+ const char *source, /* UTF-8 string to be displayed. Need not be
* '\0' terminated. All Tk meta-characters
* (tabs, control characters, and newlines)
* should be stripped out of the string that
@@ -1264,22 +1266,20 @@ Tk_DrawChars(
int x, int y) /* Coordinates at which to place origin of
* string when drawing. */
{
- UnixFont *fontPtr;
+ UnixFont *fontPtr = (UnixFont *) tkfont;
SubFont *thisSubFontPtr, *lastSubFontPtr;
Tcl_DString runString;
- CONST char *p, *end, *next;
+ const char *p, *end, *next;
int xStart, needWidth, window_width, do_width;
Tcl_UniChar ch;
FontFamily *familyPtr;
#ifdef TK_DRAW_CHAR_XWINDOW_CHECK
int rx, ry;
- unsigned int width, height, border_width, depth;
+ unsigned width, height, border_width, depth;
Drawable root;
#endif
- fontPtr = (UnixFont *) tkfont;
lastSubFontPtr = &fontPtr->subFontArray[0];
-
xStart = x;
#ifdef TK_DRAW_CHAR_XWINDOW_CHECK
@@ -1392,7 +1392,7 @@ TkpDrawCharsInContext(
GC gc, /* Graphics context for drawing characters. */
Tk_Font tkfont, /* Font in which characters will be drawn;
* must be the same as font used in GC. */
- CONST char *source, /* UTF-8 string to be displayed. Need not be
+ const char *source, /* UTF-8 string to be displayed. Need not be
* '\0' terminated. All Tk meta-characters
* (tabs, control characters, and newlines)
* should be stripped out of the string that
@@ -1441,9 +1441,9 @@ TkpDrawCharsInContext(
static XFontStruct *
CreateClosestFont(
Tk_Window tkwin, /* For display where font will be used. */
- CONST TkFontAttributes *faPtr,
+ const TkFontAttributes *faPtr,
/* Set of generic attributes to match. */
- CONST TkXLFDAttributes *xaPtr)
+ const TkXLFDAttributes *xaPtr)
/* Set of X-specific attributes to match. */
{
FontAttributes want;
@@ -1451,7 +1451,7 @@ CreateClosestFont(
int numNames, nameIdx, bestIdx[2];
Display *display;
XFontStruct *fontStructPtr;
- unsigned int bestScore[2];
+ unsigned bestScore[2];
want.fa = *faPtr;
want.xa = *xaPtr;
@@ -1481,9 +1481,9 @@ CreateClosestFont(
nameList = ListFontOrAlias(display, want.fa.family, &numNames);
if (numNames == 0) {
- char ***fontFallbacks;
+ const char *const *const *fontFallbacks;
int i, j;
- char *fallback;
+ const char *fallback;
fontFallbacks = TkFontGetFallbacks();
for (i = 0; fontFallbacks[i] != NULL; i++) {
@@ -1513,12 +1513,12 @@ CreateClosestFont(
found:
bestIdx[0] = -1;
bestIdx[1] = -1;
- bestScore[0] = (unsigned int) -1;
- bestScore[1] = (unsigned int) -1;
+ bestScore[0] = (unsigned) -1;
+ bestScore[1] = (unsigned) -1;
for (nameIdx = 0; nameIdx < numNames; nameIdx++) {
FontAttributes got;
int scalable;
- unsigned int score;
+ unsigned score;
if (TkFontParseXLFD(nameList[nameIdx], &got.fa, &got.xa) != TCL_OK) {
continue;
@@ -1574,7 +1574,7 @@ InitFont(
UnixFont *fontPtr) /* Filled with information constructed from
* the above arguments. */
{
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
unsigned long value;
int minHi, maxHi, minLo, maxLo, fixed, width, limit, i, n;
@@ -1648,7 +1648,7 @@ InitFont(
pageMap = fontPtr->subFontArray[0].fontMap[0];
for (i = 0; i < 256; i++) {
if ((minHi > 0) || (i < minLo) || (i > maxLo)
- || (((pageMap[i>>3] >> (i&7)) & 1) == 0)) {
+ || !((pageMap[i>>3] >> (i&7)) & 1)) {
n = 0;
} else if (fontStructPtr->per_char == NULL) {
n = fontStructPtr->max_bounds.width;
@@ -1727,7 +1727,7 @@ ReleaseFont(
ReleaseSubFont(fontPtr->display, &fontPtr->subFontArray[i]);
}
if (fontPtr->subFontArray != fontPtr->staticSubFonts) {
- ckfree((char *) fontPtr->subFontArray);
+ ckfree(fontPtr->subFontArray);
}
}
@@ -1827,7 +1827,7 @@ AllocFontFamily(
FontFamily *familyPtr;
FontAttributes fa;
Tcl_Encoding encoding;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
GetFontAttributes(display, fontStructPtr, &fa);
@@ -1844,7 +1844,7 @@ AllocFontFamily(
}
}
- familyPtr = (FontFamily *) ckalloc(sizeof(FontFamily));
+ familyPtr = ckalloc(sizeof(FontFamily));
memset(familyPtr, 0, sizeof(FontFamily));
familyPtr->nextPtr = tsdPtr->fontFamilyList;
tsdPtr->fontFamilyList = familyPtr;
@@ -1901,7 +1901,7 @@ FreeFontFamily(
FontFamily *familyPtr) /* The FontFamily to delete. */
{
FontFamily **familyPtrPtr;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
int i;
@@ -1931,7 +1931,7 @@ FreeFontFamily(
familyPtrPtr = &(*familyPtrPtr)->nextPtr;
}
- ckfree((char *) familyPtr);
+ ckfree(familyPtr);
}
/*
@@ -1967,7 +1967,11 @@ FindSubFontForChar(
{
int i, j, k, numNames;
Tk_Uid faceName;
- char *fallback, **aliases, **nameList, **anyFallbacks, ***fontFallbacks;
+ const char *fallback;
+ const char *const *aliases;
+ char **nameList;
+ const char *const *anyFallbacks;
+ const char *const *const *fontFallbacks;
SubFont *subFontPtr;
Tcl_DString ds;
@@ -2204,10 +2208,10 @@ FontMapLoadPage(
Tcl_Encoding encoding;
XFontStruct *fontStructPtr;
XCharStruct *widths;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
- subFontPtr->fontMap[row] = (char *) ckalloc(FONTMAP_BITSPERPAGE / 8);
+ subFontPtr->fontMap[row] = ckalloc(FONTMAP_BITSPERPAGE / 8);
memset(subFontPtr->fontMap[row], 0, FONTMAP_BITSPERPAGE / 8);
if (subFontPtr->familyPtr == &tsdPtr->controlFamily) {
@@ -2285,7 +2289,7 @@ static SubFont *
CanUseFallbackWithAliases(
UnixFont *fontPtr, /* The font object that will own the new
* screen font. */
- char *faceName, /* Desired face name for new screen font. */
+ const char *faceName, /* Desired face name for new screen font. */
int ch, /* The Unicode character that the new screen
* font must be able to display. */
Tcl_DString *nameTriedPtr, /* Records face names that have already been
@@ -2296,7 +2300,7 @@ CanUseFallbackWithAliases(
* reallocate our subfont table. */
{
SubFont *subFontPtr;
- char **aliases;
+ const char *const *aliases;
int i;
if (SeenName(faceName, nameTriedPtr) == 0) {
@@ -2341,11 +2345,11 @@ CanUseFallbackWithAliases(
static int
SeenName(
- CONST char *name, /* The name to check. */
+ const char *name, /* The name to check. */
Tcl_DString *dsPtr) /* Contains names that have already been
* seen. */
{
- CONST char *seen, *end;
+ const char *seen, *end;
seen = Tcl_DStringValue(dsPtr);
end = seen + Tcl_DStringLength(dsPtr);
@@ -2355,7 +2359,7 @@ SeenName(
}
seen += strlen(seen) + 1;
}
- Tcl_DStringAppend(dsPtr, (char *) name, (int) (strlen(name) + 1));
+ Tcl_DStringAppend(dsPtr, name, (int) (strlen(name) + 1));
return 0;
}
@@ -2390,7 +2394,7 @@ static SubFont *
CanUseFallback(
UnixFont *fontPtr, /* The font object that will own the new
* screen font. */
- CONST char *faceName, /* Desired face name for new screen font. */
+ const char *faceName, /* Desired face name for new screen font. */
int ch, /* The Unicode character that the new screen
* font must be able to display. */
SubFont **fixSubFontPtrPtr) /* Subfont reference to fix up if we
@@ -2398,9 +2402,11 @@ CanUseFallback(
{
int i, nameIdx, numNames, srcLen, numEncodings, bestIdx[2];
Tk_Uid hateFoundry;
- CONST char *charset, *hateCharset;
- unsigned int bestScore[2];
- char **nameList, **nameListOrig, src[TCL_UTF_MAX];
+ const char *charset, *hateCharset;
+ unsigned bestScore[2];
+ char **nameList;
+ char **nameListOrig;
+ char src[TCL_UTF_MAX];
FontAttributes want, got;
Display *display;
SubFont subFont;
@@ -2448,13 +2454,13 @@ CanUseFallback(
retry:
bestIdx[0] = -1;
bestIdx[1] = -1;
- bestScore[0] = (unsigned int) -1;
- bestScore[1] = (unsigned int) -1;
+ bestScore[0] = (unsigned) -1;
+ bestScore[1] = (unsigned) -1;
for (nameIdx = 0; nameIdx < numNames; nameIdx++) {
Tcl_Encoding encoding;
char dst[16];
int scalable, srcRead, dstWrote;
- unsigned int score;
+ unsigned score;
if (nameList[nameIdx] == NULL) {
continue;
@@ -2537,7 +2543,7 @@ CanUseFallback(
* make a copy.
*/
- nameList = (char **) ckalloc(numNames * sizeof(char *));
+ nameList = ckalloc(numNames * sizeof(char *));
memcpy(nameList, nameListOrig, numNames * sizeof(char *));
}
nameList[nameIdx] = NULL;
@@ -2555,7 +2561,7 @@ CanUseFallback(
if (fontStructPtr == NULL) {
if (nameList != nameListOrig) {
- ckfree((char *) nameList);
+ ckfree(nameList);
}
XFreeFontNames(nameListOrig);
return NULL;
@@ -2575,16 +2581,15 @@ CanUseFallback(
goto retry;
}
if (nameList != nameListOrig) {
- ckfree((char *) nameList);
+ ckfree(nameList);
}
XFreeFontNames(nameListOrig);
if (fontPtr->numSubFonts >= SUBFONT_SPACE) {
SubFont *newPtr;
- newPtr = (SubFont *)
- ckalloc(sizeof(SubFont) * (fontPtr->numSubFonts + 1));
- memcpy((char *) newPtr, fontPtr->subFontArray,
+ newPtr = ckalloc(sizeof(SubFont) * (fontPtr->numSubFonts + 1));
+ memcpy(newPtr, fontPtr->subFontArray,
fontPtr->numSubFonts * sizeof(SubFont));
if (fixSubFontPtrPtr != NULL) {
register SubFont *fixSubFontPtr = *fixSubFontPtrPtr;
@@ -2595,7 +2600,7 @@ CanUseFallback(
}
}
if (fontPtr->subFontArray != fontPtr->staticSubFonts) {
- ckfree((char *) fontPtr->subFontArray);
+ ckfree(fontPtr->subFontArray);
}
fontPtr->subFontArray = newPtr;
}
@@ -2622,12 +2627,12 @@ CanUseFallback(
*---------------------------------------------------------------------------
*/
-static unsigned int
+static unsigned
RankAttributes(
FontAttributes *wantPtr, /* The desired attributes. */
FontAttributes *gotPtr) /* The attributes we have to live with. */
{
- unsigned int penalty;
+ unsigned penalty;
penalty = 0;
if (gotPtr->xa.foundry != wantPtr->xa.foundry) {
@@ -2674,7 +2679,7 @@ RankAttributes(
}
if (gotPtr->xa.charset != wantPtr->xa.charset) {
int i;
- CONST char *gotAlias, *wantAlias;
+ const char *gotAlias, *wantAlias;
penalty += 65000;
gotAlias = GetEncodingAlias(gotPtr->xa.charset);
@@ -2719,7 +2724,7 @@ GetScreenFont(
char **nameList, /* Array of XLFDs. */
int bestIdx[2], /* Indices into above array for XLFD of best
* bitmapped and best scalable font. */
- unsigned int bestScore[2]) /* Scores of best bitmapped and best scalable
+ unsigned bestScore[2]) /* Scores of best bitmapped and best scalable
* font. XLFD corresponding to lowest score
* will be constructed. */
{
@@ -2888,7 +2893,7 @@ GetFontAttributes(
static char **
ListFonts(
Display *display, /* Display to query. */
- CONST char *faceName, /* Desired face name, or "*" for all. */
+ const char *faceName, /* Desired face name, or "*" for all. */
int *numNamesPtr) /* Filled with length of returned array, or 0
* if no names were found. */
{
@@ -2901,11 +2906,12 @@ ListFonts(
static char **
ListFontOrAlias(
Display *display, /* Display to query. */
- CONST char *faceName, /* Desired face name, or "*" for all. */
+ const char *faceName, /* Desired face name, or "*" for all. */
int *numNamesPtr) /* Filled with length of returned array, or 0
* if no names were found. */
{
- char **nameList, **aliases;
+ char **nameList;
+ const char *const *aliases;
int i;
nameList = ListFonts(display, faceName, numNamesPtr);
@@ -2954,7 +2960,8 @@ IdentifySymbolEncodings(
FontAttributes *faPtr)
{
int i, j;
- char **aliases, **symbolClass;
+ const char *const *aliases;
+ const char *const *symbolClass;
symbolClass = TkFontGetSymbolClass();
for (i = 0; symbolClass[i] != NULL; i++) {
@@ -2993,14 +3000,14 @@ IdentifySymbolEncodings(
*---------------------------------------------------------------------------
*/
-static CONST char *
+static const char *
GetEncodingAlias(
- CONST char *name) /* The name to look up. */
+ const char *name) /* The name to look up. */
{
EncodingAlias *aliasPtr;
for (aliasPtr = encodingAliases; aliasPtr->aliasPattern != NULL; ) {
- if (Tcl_StringMatch((char *) name, aliasPtr->aliasPattern)) {
+ if (Tcl_StringMatch(name, aliasPtr->aliasPattern)) {
return aliasPtr->realName;
}
aliasPtr++;
@@ -3009,6 +3016,305 @@ GetEncodingAlias(
}
/*
+ *---------------------------------------------------------------------------
+ *
+ * TkDrawAngledChars --
+ *
+ * Draw some characters at an angle. This is awkward here because we have
+ * no reliable way of drawing any characters at an angle in classic X11;
+ * we have to draw on a Pixmap which is converted to an XImage (from
+ * helper function GetImageOfText), rotate the image (hokey code!) onto
+ * another XImage (from helper function InitDestImage), and then use the
+ * rotated image as a mask when drawing. This is pretty awful; improved
+ * versions are welcomed!
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Target drawable is updated.
+ *
+ *---------------------------------------------------------------------------
+ */
+
+static inline XImage *
+GetImageOfText(
+ Display *display, /* Display on which to draw. */
+ Drawable drawable, /* Window or pixmap in which to draw. */
+ Tk_Font tkfont, /* Font in which characters will be drawn. */
+ const char *source, /* UTF-8 string to be displayed. Need not be
+ * '\0' terminated. All Tk meta-characters
+ * (tabs, control characters, and newlines)
+ * should be stripped out of the string that
+ * is passed to this function. If they are not
+ * stripped out, they will be displayed as
+ * regular printing characters. */
+ int numBytes, /* Number of bytes in string. */
+ int *realWidthPtr, int *realHeightPtr)
+{
+ int width, height;
+ TkFont *fontPtr = (TkFont *) tkfont;
+ Pixmap bitmap;
+ GC bitmapGC;
+ XGCValues values;
+ XImage *image;
+
+ (void) Tk_MeasureChars(tkfont, source, numBytes, -1, 0, &width);
+ height = fontPtr->fm.ascent + fontPtr->fm.descent;
+
+ bitmap = Tk_GetPixmap(display, drawable, width, height, 1);
+ values.graphics_exposures = False;
+ values.foreground = BlackPixel(display, DefaultScreen(display));
+ bitmapGC = XCreateGC(display, bitmap, GCGraphicsExposures|GCForeground,
+ &values);
+ XFillRectangle(display, bitmap, bitmapGC, 0, 0, width, height);
+
+ values.font = Tk_FontId(tkfont);
+ values.foreground = WhitePixel(display, DefaultScreen(display));
+ values.background = BlackPixel(display, DefaultScreen(display));
+ XChangeGC(display, bitmapGC, GCFont|GCForeground|GCBackground, &values);
+ Tk_DrawChars(display, bitmap, bitmapGC, tkfont, source, numBytes, 0,
+ fontPtr->fm.ascent);
+ XFreeGC(display, bitmapGC);
+
+ image = XGetImage(display, bitmap, 0, 0, width, height, AllPlanes,
+ ZPixmap);
+ Tk_FreePixmap(display, bitmap);
+
+ *realWidthPtr = width;
+ *realHeightPtr = height;
+ return image;
+}
+
+static inline XImage *
+InitDestImage(
+ Display *display,
+ Drawable drawable,
+ int width,
+ int height,
+ Pixmap *bitmapPtr)
+{
+ Pixmap bitmap;
+ XImage *image;
+ GC bitmapGC;
+ XGCValues values;
+
+ bitmap = Tk_GetPixmap(display, drawable, width, height, 1);
+ values.graphics_exposures = False;
+ values.foreground = BlackPixel(display, DefaultScreen(display));
+ bitmapGC = XCreateGC(display, bitmap, GCGraphicsExposures|GCForeground,
+ &values);
+ XFillRectangle(display, bitmap, bitmapGC, 0, 0, width, height);
+ XFreeGC(display, bitmapGC);
+
+ image = XGetImage(display, bitmap, 0, 0, width, height, AllPlanes,
+ ZPixmap);
+ *bitmapPtr = bitmap;
+ return image;
+}
+
+void
+TkDrawAngledChars(
+ Display *display, /* Display on which to draw. */
+ Drawable drawable, /* Window or pixmap in which to draw. */
+ GC gc, /* Graphics context for drawing characters. */
+ Tk_Font tkfont, /* Font in which characters will be drawn;
+ * must be the same as font used in GC. */
+ const char *source, /* UTF-8 string to be displayed. Need not be
+ * '\0' terminated. All Tk meta-characters
+ * (tabs, control characters, and newlines)
+ * should be stripped out of the string that
+ * is passed to this function. If they are not
+ * stripped out, they will be displayed as
+ * regular printing characters. */
+ int numBytes, /* Number of bytes in string. */
+ double x, double y,
+ double angle)
+{
+ if (angle == 0.0) {
+ Tk_DrawChars(display, drawable, gc, tkfont, source, numBytes, x, y);
+ } else {
+ double sinA = sin(angle * PI/180.0), cosA = cos(angle * PI/180.0);
+ int bufHeight, bufWidth, srcWidth, srcHeight, i, j, dx, dy;
+ Pixmap buf;
+ XImage *srcImage = GetImageOfText(display, drawable, tkfont, source,
+ numBytes, &srcWidth, &srcHeight);
+ XImage *dstImage;
+ enum {Q0=1,R1,Q1,R2,Q2,R3,Q3} quadrant;
+ GC bwgc, cpgc;
+ XGCValues values;
+ int ascent = ((TkFont *) tkfont)->fm.ascent;
+
+ /*
+ * First, work out what quadrant we are operating in. We also handle
+ * the rectilinear rotations as special cases. Conceptually, there's
+ * also R0 (angle == 0.0) but that has been already handled as a
+ * special case above.
+ *
+ * R1
+ * Q1 | Q0
+ * |
+ * R2 ----+---- R0
+ * |
+ * Q2 | Q3
+ * R3
+ */
+
+ if (angle < 90.0) {
+ quadrant = Q0;
+ } else if (angle == 90.0) {
+ quadrant = R1;
+ } else if (angle < 180.0) {
+ quadrant = Q1;
+ } else if (angle == 180.0) {
+ quadrant = R2;
+ } else if (angle < 270.0) {
+ quadrant = Q2;
+ } else if (angle == 270.0) {
+ quadrant = R3;
+ } else {
+ quadrant = Q3;
+ }
+
+ if (srcImage == NULL) {
+ return;
+ }
+ bufWidth = srcWidth*fabs(cosA) + srcHeight*fabs(sinA);
+ bufHeight = srcHeight*fabs(cosA) + srcWidth*fabs(sinA);
+ dstImage = InitDestImage(display, drawable, bufWidth,bufHeight, &buf);
+ if (dstImage == NULL) {
+ Tk_FreePixmap(display, buf);
+ XDestroyImage(srcImage);
+ return;
+ }
+
+ /*
+ * Do the rotation, setting or resetting pixels in the destination
+ * image dependent on whether the corresponding pixel (after rotation
+ * to source image space) is set.
+ */
+
+ for (i=0 ; i<srcWidth ; i++) {
+ for (j=0 ; j<srcHeight ; j++) {
+ switch (quadrant) {
+ case Q0:
+ dx = ROUND16(i*cosA + j*sinA);
+ dy = ROUND16(j*cosA + (srcWidth - i)*sinA);
+ break;
+ case R1:
+ dx = j;
+ dy = srcWidth - i;
+ break;
+ case Q1:
+ dx = ROUND16((i - srcWidth)*cosA + j*sinA);
+ dy = ROUND16((srcWidth-i)*sinA + (j-srcHeight)*cosA);
+ break;
+ case R2:
+ dx = srcWidth - i;
+ dy = srcHeight - j;
+ break;
+ case Q2:
+ dx = ROUND16((i-srcWidth)*cosA + (j-srcHeight)*sinA);
+ dy = ROUND16((j - srcHeight)*cosA - i*sinA);
+ break;
+ case R3:
+ dx = srcHeight - j;
+ dy = i;
+ break;
+ default:
+ dx = ROUND16(i*cosA + (j - srcHeight)*sinA);
+ dy = ROUND16(j*cosA - i*sinA);
+ }
+
+ if (dx < 0 || dy < 0 || dx >= bufWidth || dy >= bufHeight) {
+ continue;
+ }
+ XPutPixel(dstImage, dx, dy,
+ XGetPixel(dstImage,dx,dy) | XGetPixel(srcImage,i,j));
+ }
+ }
+ XDestroyImage(srcImage);
+
+ /*
+ * Schlep the data back to the Xserver.
+ */
+
+ values.function = GXcopy;
+ values.foreground = WhitePixel(display, DefaultScreen(display));
+ values.background = BlackPixel(display, DefaultScreen(display));
+ bwgc = XCreateGC(display, buf, GCFunction|GCForeground|GCBackground,
+ &values);
+ XPutImage(display, buf, bwgc, dstImage, 0,0, 0,0, bufWidth,bufHeight);
+ XFreeGC(display, bwgc);
+ XDestroyImage(dstImage);
+
+ /*
+ * Calculate where we want to draw the text.
+ */
+
+ switch (quadrant) {
+ case Q0:
+ dx = x;
+ dy = y - srcWidth*sinA;
+ break;
+ case R1:
+ dx = x;
+ dy = y - srcWidth;
+ break;
+ case Q1:
+ dx = x + srcWidth*cosA;
+ dy = y + srcHeight*cosA - srcWidth*sinA;
+ break;
+ case R2:
+ dx = x - srcWidth;
+ dy = y - srcHeight;
+ break;
+ case Q2:
+ dx = x + srcWidth*cosA + srcHeight*sinA;
+ dy = y + srcHeight*cosA;
+ break;
+ case R3:
+ dx = x - srcHeight;
+ dy = y;
+ break;
+ default:
+ dx = x + srcHeight*sinA;
+ dy = y;
+ }
+
+ /*
+ * Apply a correction to deal with the fact that we aren't told to
+ * draw from our top-left corner but rather from the left-end of our
+ * baseline.
+ */
+
+ dx -= ascent*sinA;
+ dy -= ascent*cosA;
+
+ /*
+ * Transfer the text to the screen. This is done by using it as a mask
+ * and then drawing through that mask with the original drawing color.
+ */
+
+ values.function = GXcopy;
+ values.fill_style = FillSolid;
+ values.clip_mask = buf;
+ values.clip_x_origin = dx;
+ values.clip_y_origin = dy;
+ cpgc = XCreateGC(display, drawable,
+ GCFunction|GCFillStyle|GCClipMask|GCClipXOrigin|GCClipYOrigin,
+ &values);
+ XCopyGC(display, gc, GCForeground, cpgc);
+ XFillRectangle(display, drawable, cpgc, dx, dy, bufWidth,
+ bufHeight);
+ XFreeGC(display, cpgc);
+
+ Tk_FreePixmap(display, buf);
+ return;
+ }
+}
+
+/*
* Local Variables:
* mode: c
* c-basic-offset: 4
diff --git a/unix/tkUnixInit.c b/unix/tkUnixInit.c
index 1cc90a5..b0aa2fa 100644
--- a/unix/tkUnixInit.c
+++ b/unix/tkUnixInit.c
@@ -67,9 +67,9 @@ TkpGetAppName(
Tcl_Interp *interp,
Tcl_DString *namePtr) /* A previously initialized Tcl_DString. */
{
- CONST char *p, *name;
+ const char *p, *name;
- name = Tcl_GetVar(interp, "argv0", TCL_GLOBAL_ONLY);
+ name = Tcl_GetVar2(interp, "argv0", NULL, TCL_GLOBAL_ONLY);
if ((name == NULL) || (*name == 0)) {
name = "tk";
} else {
@@ -100,10 +100,11 @@ TkpGetAppName(
void
TkpDisplayWarning(
- CONST char *msg, /* Message to be displayed. */
- CONST char *title) /* Title of warning. */
+ const char *msg, /* Message to be displayed. */
+ const char *title) /* Title of warning. */
{
Tcl_Channel errChannel = Tcl_GetStdChannel(TCL_STDERR);
+
if (errChannel) {
Tcl_WriteChars(errChannel, title, -1);
Tcl_WriteChars(errChannel, ": ", 2);
@@ -143,7 +144,7 @@ GetLibraryPath(
"com.tcltk.tklibrary", TK_FRAMEWORK_VERSION, 0, PATH_MAX,
tkLibPath);
if (tkLibPath[0] != '\0') {
- Tcl_SetVar(interp, "tk_library", tkLibPath, TCL_GLOBAL_ONLY);
+ Tcl_SetVar2(interp, "tk_library", NULL, tkLibPath, TCL_GLOBAL_ONLY);
}
return foundInFramework;
#else
diff --git a/unix/tkUnixKey.c b/unix/tkUnixKey.c
index 40cc779..23c4aa4 100644
--- a/unix/tkUnixKey.c
+++ b/unix/tkUnixKey.c
@@ -37,7 +37,7 @@
* Tk_SetCaretPos --
*
* This enables correct placement of the XIM caret. This is called by
- * widgets to indicate their cursor placement. This is currently only
+ * widgets to indicate their cursor placement. This is currently only
* used for over-the-spot XIM.
*
*----------------------------------------------------------------------
@@ -53,11 +53,10 @@ Tk_SetCaretPos(
TkWindow *winPtr = (TkWindow *) tkwin;
TkDisplay *dispPtr = winPtr->dispPtr;
- if ( dispPtr->caret.winPtr == winPtr
- && dispPtr->caret.x == x
- && dispPtr->caret.y == y
- && dispPtr->caret.height == height)
- {
+ if ((dispPtr->caret.winPtr == winPtr)
+ && (dispPtr->caret.x == x)
+ && (dispPtr->caret.y == y)
+ && (dispPtr->caret.height == height)) {
return;
}
@@ -66,22 +65,21 @@ Tk_SetCaretPos(
dispPtr->caret.y = y;
dispPtr->caret.height = height;
-#ifdef TK_USE_INPUT_METHODS
/*
* Adjust the XIM caret position.
*/
- if ( (dispPtr->flags & TK_DISPLAY_USE_IM)
- && (dispPtr->inputStyle & XIMPreeditPosition)
- && (winPtr->inputContext != NULL) )
- {
+
+#ifdef TK_USE_INPUT_METHODS
+ if ((dispPtr->flags & TK_DISPLAY_USE_IM)
+ && (dispPtr->inputStyle & XIMPreeditPosition)
+ && (winPtr->inputContext != NULL)) {
XVaNestedList preedit_attr;
XPoint spot;
spot.x = dispPtr->caret.x;
spot.y = dispPtr->caret.y + dispPtr->caret.height;
preedit_attr = XVaCreateNestedList(0, XNSpotLocation, &spot, NULL);
- XSetICValues(winPtr->inputContext,
- XNPreeditAttributes, preedit_attr,
+ XSetICValues(winPtr->inputContext, XNPreeditAttributes, preedit_attr,
NULL);
XFree(preedit_attr);
}
@@ -106,7 +104,7 @@ Tk_SetCaretPos(
*----------------------------------------------------------------------
*/
-char *
+const char *
TkpGetString(
TkWindow *winPtr, /* Window where event occurred */
XEvent *eventPtr, /* X keyboard event. */
@@ -130,8 +128,7 @@ TkpGetString(
#ifdef TK_USE_INPUT_METHODS
if ((winPtr->dispPtr->flags & TK_DISPLAY_USE_IM)
&& (winPtr->inputContext != NULL)
- && (eventPtr->type == KeyPress))
- {
+ && (eventPtr->type == KeyPress)) {
Status status;
#if X_HAVE_UTF8_STRING
@@ -140,7 +137,11 @@ TkpGetString(
Tcl_DStringValue(dsPtr), Tcl_DStringLength(dsPtr),
&kePtr->keysym, &status);
- if (status == XBufferOverflow) { /* Expand buffer and try again */
+ if (status == XBufferOverflow) {
+ /*
+ * Expand buffer and try again.
+ */
+
Tcl_DStringSetLength(dsPtr, len);
len = Xutf8LookupString(winPtr->inputContext, &eventPtr->xkey,
Tcl_DStringValue(dsPtr), Tcl_DStringLength(dsPtr),
@@ -157,7 +158,6 @@ TkpGetString(
Tcl_DStringInit(&buf);
Tcl_DStringSetLength(&buf, TCL_DSTRING_STATIC_SIZE-1);
-
len = XmbLookupString(winPtr->inputContext, &eventPtr->xkey,
Tcl_DStringValue(&buf), Tcl_DStringLength(&buf),
&kePtr->keysym, &status);
@@ -174,7 +174,6 @@ TkpGetString(
if ((status != XLookupChars) && (status != XLookupBoth)) {
len = 0;
}
-
Tcl_DStringSetLength(&buf, len);
Tcl_ExternalToUtfDString(NULL, Tcl_DStringValue(&buf), len, dsPtr);
Tcl_DStringFree(&buf);
@@ -218,7 +217,7 @@ TkpGetString(
* from having to reenter the XIM engine. [Bug 1373712]
*/
- kePtr->charValuePtr = ckalloc((unsigned) len + 1);
+ kePtr->charValuePtr = ckalloc(len + 1);
kePtr->charValueLen = len;
memcpy(kePtr->charValuePtr, Tcl_DStringValue(dsPtr), (unsigned) len + 1);
return Tcl_DStringValue(dsPtr);
@@ -434,7 +433,7 @@ TkpInitKeymapInfo(
dispPtr->metaModMask = 0;
dispPtr->altModMask = 0;
codePtr = modMapPtr->modifiermap;
- max = 8*modMapPtr->max_keypermod;
+ max = 8 * modMapPtr->max_keypermod;
for (i = 0; i < max; i++, codePtr++) {
if (*codePtr == 0) {
continue;
@@ -456,12 +455,11 @@ TkpInitKeymapInfo(
*/
if (dispPtr->modKeyCodes != NULL) {
- ckfree((char *) dispPtr->modKeyCodes);
+ ckfree(dispPtr->modKeyCodes);
}
dispPtr->numModKeyCodes = 0;
arraySize = KEYCODE_ARRAY_SIZE;
- dispPtr->modKeyCodes = (KeyCode *)
- ckalloc((unsigned) (KEYCODE_ARRAY_SIZE * sizeof(KeyCode)));
+ dispPtr->modKeyCodes = ckalloc(KEYCODE_ARRAY_SIZE * sizeof(KeyCode));
for (i = 0, codePtr = modMapPtr->modifiermap; i < max; i++, codePtr++) {
if (*codePtr == 0) {
continue;
@@ -473,23 +471,26 @@ TkpInitKeymapInfo(
for (j = 0; j < dispPtr->numModKeyCodes; j++) {
if (dispPtr->modKeyCodes[j] == *codePtr) {
+ /*
+ * 'continue' the outer loop.
+ */
+
goto nextModCode;
}
}
if (dispPtr->numModKeyCodes >= arraySize) {
- KeyCode *new;
+ KeyCode *newCodes;
/*
* Ran out of space in the array; grow it.
*/
arraySize *= 2;
- new = (KeyCode *)
- ckalloc((unsigned) (arraySize * sizeof(KeyCode)));
- memcpy(new, dispPtr->modKeyCodes,
- (dispPtr->numModKeyCodes * sizeof(KeyCode)));
- ckfree((char *) dispPtr->modKeyCodes);
- dispPtr->modKeyCodes = new;
+ newCodes = ckalloc(arraySize * sizeof(KeyCode));
+ memcpy(newCodes, dispPtr->modKeyCodes,
+ dispPtr->numModKeyCodes * sizeof(KeyCode));
+ ckfree(dispPtr->modKeyCodes);
+ dispPtr->modKeyCodes = newCodes;
}
dispPtr->modKeyCodes[dispPtr->numModKeyCodes] = *codePtr;
dispPtr->numModKeyCodes++;
diff --git a/unix/tkUnixMenu.c b/unix/tkUnixMenu.c
index eceb5b2..bc1bd2e 100644
--- a/unix/tkUnixMenu.c
+++ b/unix/tkUnixMenu.c
@@ -51,7 +51,7 @@ MODULE_SCOPE void TkpDrawCheckIndicator(Tk_Window tkwin,
static void SetHelpMenu(TkMenu *menuPtr);
static void DrawMenuEntryAccelerator(TkMenu *menuPtr,
TkMenuEntry *mePtr, Drawable d, GC gc,
- Tk_Font tkfont, CONST Tk_FontMetrics *fmPtr,
+ Tk_Font tkfont, const Tk_FontMetrics *fmPtr,
Tk_3DBorder activeBorder, int x, int y,
int width, int height, int drawArrow);
static void DrawMenuEntryBackground(TkMenu *menuPtr,
@@ -62,42 +62,42 @@ static void DrawMenuEntryIndicator(TkMenu *menuPtr,
TkMenuEntry *mePtr, Drawable d,
Tk_3DBorder border, XColor *indicatorColor,
XColor *disableColor, Tk_Font tkfont,
- CONST Tk_FontMetrics *fmPtr, int x, int y,
+ const Tk_FontMetrics *fmPtr, int x, int y,
int width, int height);
static void DrawMenuEntryLabel(TkMenu * menuPtr,
TkMenuEntry *mePtr, Drawable d, GC gc,
- Tk_Font tkfont, CONST Tk_FontMetrics *fmPtr,
+ Tk_Font tkfont, const Tk_FontMetrics *fmPtr,
int x, int y, int width, int height);
static void DrawMenuSeparator(TkMenu *menuPtr,
TkMenuEntry *mePtr, Drawable d, GC gc,
- Tk_Font tkfont, CONST Tk_FontMetrics *fmPtr,
+ Tk_Font tkfont, const Tk_FontMetrics *fmPtr,
int x, int y, int width, int height);
static void DrawTearoffEntry(TkMenu *menuPtr,
TkMenuEntry *mePtr, Drawable d, GC gc,
- Tk_Font tkfont, CONST Tk_FontMetrics *fmPtr,
+ Tk_Font tkfont, const Tk_FontMetrics *fmPtr,
int x, int y, int width, int height);
static void DrawMenuUnderline(TkMenu *menuPtr,
TkMenuEntry *mePtr, Drawable d, GC gc,
- Tk_Font tkfont, CONST Tk_FontMetrics *fmPtr,
+ Tk_Font tkfont, const Tk_FontMetrics *fmPtr,
int x, int y, int width, int height);
static void GetMenuAccelGeometry(TkMenu *menuPtr,
TkMenuEntry *mePtr, Tk_Font tkfont,
- CONST Tk_FontMetrics *fmPtr, int *widthPtr,
+ const Tk_FontMetrics *fmPtr, int *widthPtr,
int *heightPtr);
static void GetMenuLabelGeometry(TkMenuEntry *mePtr,
- Tk_Font tkfont, CONST Tk_FontMetrics *fmPtr,
+ Tk_Font tkfont, const Tk_FontMetrics *fmPtr,
int *widthPtr, int *heightPtr);
static void GetMenuIndicatorGeometry(TkMenu *menuPtr,
TkMenuEntry *mePtr, Tk_Font tkfont,
- CONST Tk_FontMetrics *fmPtr,
+ const Tk_FontMetrics *fmPtr,
int *widthPtr, int *heightPtr);
static void GetMenuSeparatorGeometry(TkMenu *menuPtr,
TkMenuEntry *mePtr, Tk_Font tkfont,
- CONST Tk_FontMetrics *fmPtr,
+ const Tk_FontMetrics *fmPtr,
int *widthPtr, int *heightPtr);
static void GetTearoffEntryGeometry(TkMenu *menuPtr,
TkMenuEntry *mePtr, Tk_Font tkfont,
- CONST Tk_FontMetrics *fmPtr, int *widthPtr,
+ const Tk_FontMetrics *fmPtr, int *widthPtr,
int *heightPtr);
/*
@@ -294,7 +294,7 @@ void
TkpSetMainMenubar(
Tcl_Interp *interp,
Tk_Window tkwin,
- char *menuName)
+ const char *menuName)
{
/*
* Nothing to do.
@@ -324,10 +324,12 @@ GetMenuIndicatorGeometry(
TkMenu *menuPtr, /* The menu we are drawing. */
TkMenuEntry *mePtr, /* The entry we are interested in. */
Tk_Font tkfont, /* The precalculated font */
- CONST Tk_FontMetrics *fmPtr,/* The precalculated metrics */
+ const Tk_FontMetrics *fmPtr,/* The precalculated metrics */
int *widthPtr, /* The resulting width */
int *heightPtr) /* The resulting height */
{
+ int borderWidth;
+
if ((mePtr->type == CHECK_BUTTON_ENTRY)
|| (mePtr->type == RADIO_BUTTON_ENTRY)) {
if (!mePtr->hideMargin && mePtr->indicatorOn) {
@@ -352,23 +354,18 @@ GetMenuIndicatorGeometry(
}
}
} else {
- int borderWidth;
-
- Tk_GetPixelsFromObj(NULL, menuPtr->tkwin,
- menuPtr->borderWidthPtr, &borderWidth);
+ Tk_GetPixelsFromObj(NULL, menuPtr->tkwin, menuPtr->borderWidthPtr,
+ &borderWidth);
*heightPtr = 0;
*widthPtr = borderWidth;
}
} else {
- int borderWidth;
-
Tk_GetPixelsFromObj(NULL, menuPtr->tkwin, menuPtr->borderWidthPtr,
&borderWidth);
- *heightPtr = 0;
- *widthPtr = borderWidth;
+ *heightPtr = 0;
+ *widthPtr = borderWidth;
}
}
-
/*
*----------------------------------------------------------------------
@@ -391,18 +388,17 @@ GetMenuAccelGeometry(
TkMenu *menuPtr, /* The menu was are drawing */
TkMenuEntry *mePtr, /* The entry we are getting the geometry for */
Tk_Font tkfont, /* The precalculated font */
- CONST Tk_FontMetrics *fmPtr,/* The precalculated font metrics */
+ const Tk_FontMetrics *fmPtr,/* The precalculated font metrics */
int *widthPtr, /* The width of the acclerator area */
int *heightPtr) /* The height of the accelerator area */
{
*heightPtr = fmPtr->linespace;
if (mePtr->type == CASCADE_ENTRY) {
*widthPtr = 2 * CASCADE_ARROW_WIDTH;
- } else if ((menuPtr->menuType != MENUBAR)
- && (mePtr->accelPtr != NULL)) {
- char *accel = Tcl_GetStringFromObj(mePtr->accelPtr, NULL);
+ } else if ((menuPtr->menuType != MENUBAR) && (mePtr->accelPtr != NULL)) {
+ const char *accel = Tcl_GetString(mePtr->accelPtr);
- *widthPtr = Tk_TextWidth(tkfont, accel, mePtr->accelLength);
+ *widthPtr = Tk_TextWidth(tkfont, accel, mePtr->accelLength);
} else {
*widthPtr = 0;
}
@@ -483,7 +479,7 @@ DrawMenuEntryAccelerator(
Drawable d, /* The drawable we are drawing into */
GC gc, /* The precalculated gc to draw with */
Tk_Font tkfont, /* The precalculated font */
- CONST Tk_FontMetrics *fmPtr,/* The precalculated metrics */
+ const Tk_FontMetrics *fmPtr,/* The precalculated metrics */
Tk_3DBorder activeBorder, /* The border for an active item */
int x, /* Left coordinate of entry rect */
int y, /* Top coordinate of entry rect */
@@ -508,7 +504,7 @@ DrawMenuEntryAccelerator(
&activeBorderWidth);
if ((mePtr->type == CASCADE_ENTRY) && drawArrow) {
points[0].x = x + width - borderWidth - activeBorderWidth
- - CASCADE_ARROW_WIDTH;
+ - CASCADE_ARROW_WIDTH;
points[0].y = y + (height - CASCADE_ARROW_HEIGHT)/2;
points[1].x = points[0].x;
points[1].y = points[0].y + CASCADE_ARROW_HEIGHT;
@@ -519,9 +515,9 @@ DrawMenuEntryAccelerator(
(menuPtr->postedCascade == mePtr)
? TK_RELIEF_SUNKEN : TK_RELIEF_RAISED);
} else if (mePtr->accelPtr != NULL) {
- char *accel = Tcl_GetStringFromObj(mePtr->accelPtr, NULL);
+ const char *accel = Tcl_GetString(mePtr->accelPtr);
int left = x + mePtr->labelWidth + activeBorderWidth
- + mePtr->indicatorSpace;
+ + mePtr->indicatorSpace;
if (menuPtr->menuType == MENUBAR) {
left += 5;
@@ -557,7 +553,7 @@ DrawMenuEntryIndicator(
XColor *indicatorColor, /* The color to draw indicators with */
XColor *disableColor, /* The color use use when disabled */
Tk_Font tkfont, /* The font to draw with */
- CONST Tk_FontMetrics *fmPtr,/* The font metrics of the font */
+ const Tk_FontMetrics *fmPtr,/* The font metrics of the font */
int x, /* The left of the entry rect */
int y, /* The top of the entry rect */
int width, /* Width of menu entry */
@@ -629,7 +625,7 @@ DrawMenuSeparator(
Drawable d, /* The drawable we are using */
GC gc, /* The gc to draw into */
Tk_Font tkfont, /* The font to draw with */
- CONST Tk_FontMetrics *fmPtr,/* The font metrics from the font */
+ const Tk_FontMetrics *fmPtr,/* The font metrics from the font */
int x, int y,
int width, int height)
{
@@ -672,7 +668,7 @@ DrawMenuEntryLabel(
Drawable d, /* What we are drawing into. */
GC gc, /* The gc we are drawing into.*/
Tk_Font tkfont, /* The precalculated font. */
- CONST Tk_FontMetrics *fmPtr,/* The precalculated font metrics. */
+ const Tk_FontMetrics *fmPtr,/* The precalculated font metrics. */
int x, /* Left edge. */
int y, /* Top edge. */
int width, /* width of entry. */
@@ -701,12 +697,14 @@ DrawMenuEntryLabel(
haveImage = 1;
} else if (mePtr->bitmapPtr != NULL) {
Pixmap bitmap = Tk_GetBitmapFromObj(menuPtr->tkwin, mePtr->bitmapPtr);
+
Tk_SizeOfBitmap(menuPtr->display, bitmap, &imageWidth, &imageHeight);
haveImage = 1;
}
if (!haveImage || (mePtr->compound != COMPOUND_NONE)) {
if (mePtr->labelLength > 0) {
- char *label = Tcl_GetStringFromObj(mePtr->labelPtr, NULL);
+ const char *label = Tcl_GetString(mePtr->labelPtr);
+
textWidth = Tk_TextWidth(tkfont, label, mePtr->labelLength);
textHeight = fmPtr->linespace;
haveText = 1;
@@ -719,6 +717,7 @@ DrawMenuEntryLabel(
if (haveImage && haveText) {
int fullWidth = (imageWidth > textWidth ? imageWidth : textWidth);
+
switch ((enum compound) mePtr->compound) {
case COMPOUND_TOP:
textXOffset = (fullWidth - textWidth)/2;
@@ -801,7 +800,7 @@ DrawMenuEntryLabel(
int baseline = y + (height + fmPtr->ascent - fmPtr->descent) / 2;
if (mePtr->labelLength > 0) {
- char *label = Tcl_GetStringFromObj(mePtr->labelPtr, NULL);
+ const char *label = Tcl_GetString(mePtr->labelPtr);
Tk_DrawChars(menuPtr->display, d, gc, tkfont, label,
mePtr->labelLength, leftEdge + textXOffset,
@@ -849,7 +848,7 @@ DrawMenuUnderline(
Drawable d, /* What we are drawing into */
GC gc, /* The gc to draw into */
Tk_Font tkfont, /* The precalculated font */
- CONST Tk_FontMetrics *fmPtr,/* The precalculated font metrics */
+ const Tk_FontMetrics *fmPtr,/* The precalculated font metrics */
int x, int y,
int width, int height)
{
@@ -863,9 +862,9 @@ DrawMenuUnderline(
Tcl_GetUnicodeFromObj(mePtr->labelPtr, &len);
if (mePtr->underline < len) {
int activeBorderWidth, leftEdge;
- CONST char *label, *start, *end;
+ const char *label, *start, *end;
- label = Tcl_GetStringFromObj(mePtr->labelPtr, NULL);
+ label = Tcl_GetString(mePtr->labelPtr);
start = Tcl_UtfAtIndex(label, mePtr->underline);
end = Tcl_UtfNext(start);
@@ -929,7 +928,7 @@ GetMenuSeparatorGeometry(
TkMenu *menuPtr, /* The menu we are measuring */
TkMenuEntry *mePtr, /* The entry we are measuring */
Tk_Font tkfont, /* The precalculated font */
- CONST Tk_FontMetrics *fmPtr,/* The precalcualted font metrics */
+ const Tk_FontMetrics *fmPtr,/* The precalcualted font metrics */
int *widthPtr, /* The resulting width */
int *heightPtr) /* The resulting height */
{
@@ -958,7 +957,7 @@ GetTearoffEntryGeometry(
TkMenu *menuPtr, /* The menu we are drawing */
TkMenuEntry *mePtr, /* The entry we are measuring */
Tk_Font tkfont, /* The precalculated font */
- CONST Tk_FontMetrics *fmPtr,/* The precalculated font metrics */
+ const Tk_FontMetrics *fmPtr,/* The precalculated font metrics */
int *widthPtr, /* The resulting width */
int *heightPtr) /* The resulting height */
{
@@ -1074,7 +1073,6 @@ TkpComputeMenubarGeometry(
if (mePtr->entryFlags & ENTRY_HELP_MENU) {
helpMenuIndex = i;
} else if (x + mePtr->width + borderWidth > maxWindowWidth) {
-
if (i == lastRowBreak) {
mePtr->y = y;
mePtr->x = x;
@@ -1085,7 +1083,7 @@ TkpComputeMenubarGeometry(
x = borderWidth;
for (j = lastRowBreak; j < i; j++) {
menuPtr->entries[j]->y = y + currentRowHeight
- - menuPtr->entries[j]->height;
+ - menuPtr->entries[j]->height;
menuPtr->entries[j]->x = x;
x += menuPtr->entries[j]->width;
}
@@ -1179,7 +1177,7 @@ DrawTearoffEntry(
Drawable d, /* The drawable we are drawing into */
GC gc, /* The gc we are drawing with */
Tk_Font tkfont, /* The font we are drawing with */
- CONST Tk_FontMetrics *fmPtr,/* The metrics we are drawing with */
+ const Tk_FontMetrics *fmPtr,/* The metrics we are drawing with */
int x, int y,
int width, int height)
{
@@ -1259,7 +1257,7 @@ TkpInitializeMenuBindings(
static void
SetHelpMenu(
- TkMenu *menuPtr) /* The menu we are checking */
+ TkMenu *menuPtr) /* The menu we are checking */
{
TkMenuEntry *cascadeEntryPtr;
int useMotifHelp = 0;
@@ -1317,25 +1315,25 @@ SetHelpMenu(
void
TkpDrawMenuEntry(
- TkMenuEntry *mePtr, /* The entry to draw */
- Drawable d, /* What to draw into */
- Tk_Font tkfont, /* Precalculated font for menu */
- CONST Tk_FontMetrics *menuMetricsPtr,
- /* Precalculated metrics for menu */
- int x, /* X-coordinate of topleft of entry */
- int y, /* Y-coordinate of topleft of entry */
- int width, /* Width of the entry rectangle */
- int height, /* Height of the current rectangle */
- int strictMotif, /* Boolean flag */
- int drawArrow) /* Whether or not to draw the cascade
- * arrow for cascade items. Only applies
- * to Windows. */
+ TkMenuEntry *mePtr, /* The entry to draw */
+ Drawable d, /* What to draw into */
+ Tk_Font tkfont, /* Precalculated font for menu */
+ const Tk_FontMetrics *menuMetricsPtr,
+ /* Precalculated metrics for menu */
+ int x, /* X-coordinate of topleft of entry */
+ int y, /* Y-coordinate of topleft of entry */
+ int width, /* Width of the entry rectangle */
+ int height, /* Height of the current rectangle */
+ int strictMotif, /* Boolean flag */
+ int drawArrow) /* Whether or not to draw the cascade arrow
+ * for cascade items. Only applies to
+ * Windows. */
{
GC gc, indicatorGC;
XColor *indicatorColor, *disableColor = NULL;
TkMenu *menuPtr = mePtr->menuPtr;
Tk_3DBorder bgBorder, activeBorder;
- CONST Tk_FontMetrics *fmPtr;
+ const Tk_FontMetrics *fmPtr;
Tk_FontMetrics entryMetrics;
int padY = (menuPtr->menuType == MENUBAR) ? 3 : 0;
int adjustedY = y + padY;
@@ -1358,7 +1356,7 @@ TkpDrawMenuEntry(
cascadeEntryPtr != NULL;
cascadeEntryPtr = cascadeEntryPtr->nextCascadePtr) {
if (cascadeEntryPtr->namePtr != NULL) {
- char *name = Tcl_GetString(cascadeEntryPtr->namePtr);
+ const char *name = Tcl_GetString(cascadeEntryPtr->namePtr);
if (strcmp(name, Tk_PathName(menuPtr->tkwin)) == 0) {
if (cascadeEntryPtr->state == ENTRY_DISABLED) {
@@ -1470,7 +1468,7 @@ static void
GetMenuLabelGeometry(
TkMenuEntry *mePtr, /* The entry we are computing */
Tk_Font tkfont, /* The precalculated font */
- CONST Tk_FontMetrics *fmPtr,/* The precalculated metrics */
+ const Tk_FontMetrics *fmPtr,/* The precalculated metrics */
int *widthPtr, /* The resulting width of the label portion */
int *heightPtr) /* The resulting height of the label
* portion */
@@ -1483,6 +1481,7 @@ GetMenuLabelGeometry(
haveImage = 1;
} else if (mePtr->bitmapPtr != NULL) {
Pixmap bitmap = Tk_GetBitmapFromObj(menuPtr->tkwin, mePtr->bitmapPtr);
+
Tk_SizeOfBitmap(menuPtr->display, bitmap, widthPtr, heightPtr);
haveImage = 1;
} else {
@@ -1501,9 +1500,9 @@ GetMenuLabelGeometry(
if (mePtr->labelPtr != NULL) {
int textWidth;
- char *label = Tcl_GetStringFromObj(mePtr->labelPtr, NULL);
- textWidth = Tk_TextWidth(tkfont, label, mePtr->labelLength);
+ const char *label = Tcl_GetString(mePtr->labelPtr);
+ textWidth = Tk_TextWidth(tkfont, label, mePtr->labelLength);
if ((mePtr->compound != COMPOUND_NONE) && haveImage) {
switch ((enum compound) mePtr->compound) {
case COMPOUND_TOP:
@@ -1686,8 +1685,8 @@ TkpComputeStandardMenuGeometry(
accelWidth = width;
}
- GetMenuIndicatorGeometry(menuPtr, mePtr, tkfont,
- fmPtr, &width, &height);
+ GetMenuIndicatorGeometry(menuPtr, mePtr, tkfont, fmPtr,
+ &width, &height);
if (height > mePtr->height) {
mePtr->height = height;
}
@@ -1700,7 +1699,7 @@ TkpComputeStandardMenuGeometry(
mePtr->height += 2 * activeBorderWidth + MENU_DIVIDER_HEIGHT;
}
- mePtr->y = y;
+ mePtr->y = y;
y += mePtr->height;
if (y > windowHeight) {
windowHeight = y;
@@ -1759,7 +1758,7 @@ TkpComputeStandardMenuGeometry(
void
TkpMenuNotifyToplevelCreate(
Tcl_Interp *interp, /* The interp the menu lives in. */
- char *menuName) /* The name of the menu to reconfigure. */
+ const char *menuName) /* The name of the menu to reconfigure. */
{
/*
* Nothing to do.
diff --git a/unix/tkUnixMenubu.c b/unix/tkUnixMenubu.c
index 48d3fb9..ad71b7b 100644
--- a/unix/tkUnixMenubu.c
+++ b/unix/tkUnixMenubu.c
@@ -13,17 +13,6 @@
#include "tkInt.h"
#include "tkMenubutton.h"
-/*
- * The structure below defines menubutton class behavior by means of functions
- * that can be invoked from generic window code.
- */
-
-Tk_ClassProcs tkpMenubuttonClass = {
- sizeof(Tk_ClassProcs), /* size */
- TkMenuButtonWorldChanged, /* worldChangedProc */
- NULL,
- NULL
-};
/*
*----------------------------------------------------------------------
@@ -45,7 +34,7 @@ TkMenuButton *
TkpCreateMenuButton(
Tk_Window tkwin)
{
- return (TkMenuButton *)ckalloc(sizeof(TkMenuButton));
+ return ckalloc(sizeof(TkMenuButton));
}
/*
diff --git a/unix/tkUnixPort.h b/unix/tkUnixPort.h
index d122c8c..9051c63 100644
--- a/unix/tkUnixPort.h
+++ b/unix/tkUnixPort.h
@@ -17,21 +17,6 @@
#define __UNIX__ 1
-/*
- * Macro to use instead of "void" for arguments that must have
- * type "void *" in ANSI C; maps them to type "char *" in
- * non-ANSI systems. This macro may be used in some of the include
- * files below, which is why it is defined here.
- */
-
-#ifndef VOID
-# ifdef __STDC__
-# define VOID void
-# else
-# define VOID char
-# endif
-#endif
-
#include <stdio.h>
#include <ctype.h>
#include <fcntl.h>
@@ -208,15 +193,4 @@
sprintf((buf), "%#08lx", (unsigned long) (w))
#endif
-/*
- * The following declaration is used to get access to a private Tcl interface
- * that is needed for portability reasons.
- *
- * Disabled for now to determined whether we really still need this.
-
-#ifndef _TCLINT
-#include <tclInt.h>
-#endif
- */
-
#endif /* _UNIXPORT */
diff --git a/unix/tkUnixRFont.c b/unix/tkUnixRFont.c
index fd0b556..ab2ed4a 100644
--- a/unix/tkUnixRFont.c
+++ b/unix/tkUnixRFont.c
@@ -16,8 +16,10 @@
typedef struct {
XftFont *ftFont;
+ XftFont *ft0Font;
FcPattern *source;
FcCharSet *charset;
+ double angle;
} UnixFtFace;
typedef struct {
@@ -69,13 +71,15 @@ TkpFontPkgInit(
static XftFont *
GetFont(
UnixFtFont *fontPtr,
- FcChar32 ucs4)
+ FcChar32 ucs4,
+ double angle)
{
int i;
if (ucs4) {
for (i = 0; i < fontPtr->nfaces; i++) {
FcCharSet *charset = fontPtr->faces[i].charset;
+
if (charset && FcCharSetHasChar(charset, ucs4)) {
break;
}
@@ -86,34 +90,61 @@ GetFont(
} else {
i = 0;
}
- if (!fontPtr->faces[i].ftFont) {
- FcPattern *pat = FcFontRenderPrepare(0,
- fontPtr->pattern, fontPtr->faces[i].source);
- XftFont *ftFont = XftFontOpenPattern(fontPtr->display, pat);
+ if ((angle == 0.0 && !fontPtr->faces[i].ft0Font) || (angle != 0.0 &&
+ (!fontPtr->faces[i].ftFont || fontPtr->faces[i].angle != angle))){
+ FcPattern *pat = FcFontRenderPrepare(0, fontPtr->pattern,
+ fontPtr->faces[i].source);
+ double s = sin(angle*PI/180.0), c = cos(angle*PI/180.0);
+ FcMatrix mat;
+ XftFont *ftFont;
+ /*
+ * Initialize the matrix manually so this can compile with HP-UX cc
+ * (which does not allow non-constant structure initializers). [Bug
+ * 2978410]
+ */
+
+ mat.xx = mat.yy = c;
+ mat.xy = -(mat.yx = s);
+
+ if (angle != 0.0) {
+ FcPatternAddMatrix(pat, FC_MATRIX, &mat);
+ }
+ ftFont = XftFontOpenPattern(fontPtr->display, pat);
if (!ftFont) {
/*
- * The previous call to XftFontOpenPattern() should not fail,
- * but sometimes does anyway. Usual cause appears to be
- * a misconfigured fontconfig installation; see [Bug 1090382].
- * Try a fallback:
+ * The previous call to XftFontOpenPattern() should not fail, but
+ * sometimes does anyway. Usual cause appears to be a
+ * misconfigured fontconfig installation; see [Bug 1090382]. Try a
+ * fallback:
*/
+
ftFont = XftFontOpen(fontPtr->display, fontPtr->screen,
- FC_FAMILY, FcTypeString, "sans",
- FC_SIZE, FcTypeDouble, 12.0,
- NULL);
+ FC_FAMILY, FcTypeString, "sans",
+ FC_SIZE, FcTypeDouble, 12.0,
+ FC_MATRIX, FcTypeMatrix, &mat,
+ NULL);
}
if (!ftFont) {
/*
- * The previous call should definitely not fail.
- * Impossible to proceed at this point.
+ * The previous call should definitely not fail. Impossible to
+ * proceed at this point.
*/
- Tcl_Panic("Cannot find a usable font.");
+
+ Tcl_Panic("Cannot find a usable font");
}
- fontPtr->faces[i].ftFont = ftFont;
+ if (angle == 0.0) {
+ fontPtr->faces[i].ft0Font = ftFont;
+ } else {
+ if (fontPtr->faces[i].ftFont) {
+ XftFontClose(fontPtr->display, fontPtr->faces[i].ftFont);
+ }
+ fontPtr->faces[i].ftFont = ftFont;
+ fontPtr->faces[i].angle = angle;
+ }
}
- return fontPtr->faces[i].ftFont;
+ return (angle==0.0? fontPtr->faces[i].ft0Font : fontPtr->faces[i].ftFont);
}
/*
@@ -128,14 +159,15 @@ GetTkFontAttributes(
XftFont *ftFont,
TkFontAttributes *faPtr)
{
- char *family = "Unknown", **familyPtr = &family;
+ const char *family = "Unknown";
+ const char *const *familyPtr = &family;
int weight, slant, size, pxsize;
double ptsize;
- (void)XftPatternGetString(ftFont->pattern, XFT_FAMILY, 0, familyPtr);
+ (void) XftPatternGetString(ftFont->pattern, XFT_FAMILY, 0, familyPtr);
if (XftPatternGetDouble(ftFont->pattern, XFT_SIZE, 0,
&ptsize) == XftResultMatch) {
- size = (int)ptsize;
+ size = (int) ptsize;
} else if (XftPatternGetInteger(ftFont->pattern, XFT_PIXEL_SIZE, 0,
&pxsize) == XftResultMatch) {
size = -pxsize;
@@ -171,7 +203,8 @@ GetTkFontAttributes(
* Fill in TkFontMetrics from an XftFont.
*/
-static void GetTkFontMetrics(
+static void
+GetTkFontMetrics(
XftFont *ftFont,
TkFontMetrics *fmPtr)
{
@@ -212,10 +245,10 @@ InitFont(
FcCharSet *charset;
FcResult result;
XftFont *ftFont;
- int i;
+ int i, iWidth;
if (!fontPtr) {
- fontPtr = (UnixFtFont *) ckalloc(sizeof(UnixFtFont));
+ fontPtr = ckalloc(sizeof(UnixFtFont));
}
FcConfigSubstitute(0, pattern, FcMatchPattern);
@@ -227,13 +260,13 @@ InitFont(
set = FcFontSort(0, pattern, FcTrue, NULL, &result);
if (!set) {
- ckfree((char *)fontPtr);
+ ckfree(fontPtr);
return NULL;
}
fontPtr->fontset = set;
fontPtr->pattern = pattern;
- fontPtr->faces = (UnixFtFace *) ckalloc(set->nfont * sizeof(UnixFtFace));
+ fontPtr->faces = ckalloc(set->nfont * sizeof(UnixFtFace));
fontPtr->nfaces = set->nfont;
/*
@@ -242,6 +275,7 @@ InitFont(
for (i = 0; i < set->nfont; i++) {
fontPtr->faces[i].ftFont = 0;
+ fontPtr->faces[i].ft0Font = 0;
fontPtr->faces[i].source = set->fonts[i];
if (FcPatternGetCharSet(set->fonts[i], FC_CHARSET, 0,
&charset) == FcResultMatch) {
@@ -249,6 +283,7 @@ InitFont(
} else {
fontPtr->faces[i].charset = 0;
}
+ fontPtr->faces[i].angle = 0.0;
}
fontPtr->display = Tk_Display(tkwin);
@@ -263,7 +298,8 @@ InitFont(
/*
* Fill in platform-specific fields of TkFont.
*/
- ftFont = GetFont(fontPtr, 0);
+
+ ftFont = GetFont(fontPtr, 0, 0.0);
fontPtr->font.fid = XLoadFont(Tk_Display(tkwin), "fixed");
GetTkFontAttributes(ftFont, &fontPtr->font.fa);
GetTkFontMetrics(ftFont, &fontPtr->font.fm);
@@ -289,7 +325,6 @@ InitFont(
{
TkFont *fPtr = &fontPtr->font;
- int iWidth;
fPtr->underlinePos = fPtr->fm.descent / 2;
Tk_MeasureChars((Tk_Font) fPtr, "I", 1, -1, 0, &iWidth);
@@ -315,19 +350,22 @@ FinishedWithFont(
{
Display *display = fontPtr->display;
int i;
- Tk_ErrorHandler handler = Tk_CreateErrorHandler(display, -1, -1, -1, NULL,
- (ClientData) NULL);
+ Tk_ErrorHandler handler =
+ Tk_CreateErrorHandler(display, -1, -1, -1, NULL, NULL);
for (i = 0; i < fontPtr->nfaces; i++) {
if (fontPtr->faces[i].ftFont) {
XftFontClose(fontPtr->display, fontPtr->faces[i].ftFont);
}
+ if (fontPtr->faces[i].ft0Font) {
+ XftFontClose(fontPtr->display, fontPtr->faces[i].ft0Font);
+ }
if (fontPtr->faces[i].charset) {
FcCharSetDestroy(fontPtr->faces[i].charset);
}
}
if (fontPtr->faces) {
- ckfree((char *)fontPtr->faces);
+ ckfree(fontPtr->faces);
}
if (fontPtr->pattern) {
FcPatternDestroy(fontPtr->pattern);
@@ -347,7 +385,7 @@ FinishedWithFont(
TkFont *
TkpGetNativeFont(
Tk_Window tkwin, /* For display where font will be used. */
- CONST char *name) /* Platform-specific font name. */
+ const char *name) /* Platform-specific font name. */
{
UnixFtFont *fontPtr;
FcPattern *pattern;
@@ -382,7 +420,7 @@ TkpGetFontFromAttributes(
* will be released. If NULL, a new TkFont
* structure is allocated. */
Tk_Window tkwin, /* For display where font will be used. */
- CONST TkFontAttributes *faPtr)
+ const TkFontAttributes *faPtr)
/* Set of attributes to match. */
{
XftPattern *pattern;
@@ -492,14 +530,15 @@ TkpGetFontFamilies(
resultPtr = Tcl_NewListObj(0, NULL);
list = XftListFonts(Tk_Display(tkwin), Tk_ScreenNumber(tkwin),
- (char*)0, /* pattern elements */
- XFT_FAMILY, (char*)0); /* fields */
+ (char *) 0, /* pattern elements */
+ XFT_FAMILY, (char*) 0); /* fields */
for (i = 0; i < list->nfont; i++) {
char *family, **familyPtr = &family;
+
if (XftPatternGetString(list->fonts[i], XFT_FAMILY, 0, familyPtr)
- == XftResultMatch)
- {
+ == XftResultMatch) {
Tcl_Obj *strPtr = Tcl_NewStringObj(family, -1);
+
Tcl_ListObjAppendElement(NULL, resultPtr, strPtr);
}
}
@@ -529,9 +568,12 @@ TkpGetSubFonts(
Tcl_Obj *objv[3], *listPtr, *resultPtr;
UnixFtFont *fontPtr = (UnixFtFont *) tkfont;
FcPattern *pattern;
- char *family = "Unknown", **familyPtr = &family;
- char *foundry = "Unknown", **foundryPtr = &foundry;
- char *encoding = "Unknown", **encodingPtr = &encoding;
+ const char *family = "Unknown";
+ const char *const *familyPtr = &family;
+ const char *foundry = "Unknown";
+ const char *const *foundryPtr = &foundry;
+ const char *encoding = "Unknown";
+ const char *const *encodingPtr = &encoding;
int i;
resultPtr = Tcl_NewListObj(0, NULL);
@@ -574,7 +616,7 @@ TkpGetFontAttrsForChar(
/* Structure describing the logical font */
FcChar32 ucs4 = (FcChar32) c;
/* UCS-4 character to map */
- XftFont *ftFont = GetFont(fontPtr, ucs4);
+ XftFont *ftFont = GetFont(fontPtr, ucs4, 0.0);
/* Actual font used to render the character */
GetTkFontAttributes(ftFont, faPtr);
@@ -585,7 +627,7 @@ TkpGetFontAttrsForChar(
int
Tk_MeasureChars(
Tk_Font tkfont, /* Font in which characters will be drawn. */
- CONST char *source, /* UTF-8 string to be displayed. Need not be
+ const char *source, /* UTF-8 string to be displayed. Need not be
* '\0' terminated. */
int numBytes, /* Maximum number of bytes to consider from
* source string. */
@@ -623,7 +665,7 @@ Tk_MeasureChars(
Tcl_UniChar unichar;
clen = Tcl_UtfToUniChar(source, &unichar);
- c = (FcChar32)unichar;
+ c = (FcChar32) unichar;
if (clen <= 0) {
/*
@@ -649,7 +691,7 @@ Tk_MeasureChars(
#if DEBUG_FONTSEL
string[len++] = (char) c;
#endif /* DEBUG_FONTSEL */
- ftFont = GetFont(fontPtr, c);
+ ftFont = GetFont(fontPtr, c, 0.0);
XftTextExtents32(fontPtr->display, ftFont, &c, 1, &extents);
@@ -681,7 +723,7 @@ Tk_MeasureChars(
int
TkpMeasureCharsInContext(
Tk_Font tkfont,
- CONST char *source,
+ const char *source,
int numBytes,
int rangeStart,
int rangeLength,
@@ -704,7 +746,7 @@ Tk_DrawChars(
GC gc, /* Graphics context for drawing characters. */
Tk_Font tkfont, /* Font in which characters will be drawn;
* must be the same as font used in GC. */
- CONST char *source, /* UTF-8 string to be displayed. Need not be
+ const char *source, /* UTF-8 string to be displayed. Need not be
* '\0' terminated. All Tk meta-characters
* (tabs, control characters, and newlines)
* should be stripped out of the string that
@@ -733,8 +775,8 @@ Tk_DrawChars(
DefaultVisual(display, fontPtr->screen),
DefaultColormap(display, fontPtr->screen));
} else {
- Tk_ErrorHandler handler = Tk_CreateErrorHandler(display, -1, -1, -1,
- NULL, (ClientData) NULL);
+ Tk_ErrorHandler handler =
+ Tk_CreateErrorHandler(display, -1, -1, -1, NULL, NULL);
XftDrawChange(fontPtr->ftDraw, drawable);
Tk_DeleteErrorHandler(handler);
@@ -769,7 +811,7 @@ Tk_DrawChars(
source += clen;
numBytes -= clen;
- ftFont = GetFont(fontPtr, c);
+ ftFont = GetFont(fontPtr, c, 0.0);
if (ftFont) {
specs[nspec].font = ftFont;
specs[nspec].glyph = XftCharIndex(fontPtr->display, ftFont, c);
@@ -790,11 +832,11 @@ Tk_DrawChars(
if (nspec) {
XftDrawGlyphFontSpec(fontPtr->ftDraw, &fontPtr->color, specs, nspec);
}
+
+ doUnderlineStrikeout:
if (tsdPtr->clipRegion != None) {
XftDrawSetClip(fontPtr->ftDraw, None);
}
-
- doUnderlineStrikeout:
if (fontPtr->font.fa.underline != 0) {
XFillRectangle(display, drawable, gc, xStart,
y + fontPtr->font.underlinePos, (unsigned) (x - xStart),
@@ -807,8 +849,280 @@ Tk_DrawChars(
(unsigned) fontPtr->font.underlineHeight);
}
}
+
+/*
+ *---------------------------------------------------------------------------
+ *
+ * TkDrawAngledChars --
+ *
+ * Draw some characters at an angle. This would be simple code, except
+ * Xft has bugs with cumulative errors in character positioning which are
+ * caused by trying to perform all calculations internally with integers.
+ * So we have to do the work ourselves with floating-point math.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Target drawable is updated.
+ *
+ *---------------------------------------------------------------------------
+ */
void
+TkDrawAngledChars(
+ Display *display, /* Display on which to draw. */
+ Drawable drawable, /* Window or pixmap in which to draw. */
+ GC gc, /* Graphics context for drawing characters. */
+ Tk_Font tkfont, /* Font in which characters will be drawn;
+ * must be the same as font used in GC. */
+ const char *source, /* UTF-8 string to be displayed. Need not be
+ * '\0' terminated. All Tk meta-characters
+ * (tabs, control characters, and newlines)
+ * should be stripped out of the string that
+ * is passed to this function. If they are not
+ * stripped out, they will be displayed as
+ * regular printing characters. */
+ int numBytes, /* Number of bytes in string. */
+ double x, double y, /* Coordinates at which to place origin of
+ * string when drawing. */
+ double angle) /* What angle to put text at, in degrees. */
+{
+ const int maxCoord = 0x7FFF;/* Xft coordinates are 16 bit values */
+ const int minCoord = -1000; /* Should be good enough... */
+ UnixFtFont *fontPtr = (UnixFtFont *) tkfont;
+ XGCValues values;
+ XColor xcolor;
+ int xStart = x, yStart = y;
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+#ifdef XFT_HAS_FIXED_ROTATED_PLACEMENT
+ int clen, nglyph;
+ FT_UInt glyphs[NUM_SPEC];
+ XGlyphInfo metrics;
+ XftFont *currentFtFont;
+ int originX, originY;
+
+ if (fontPtr->ftDraw == 0) {
+#if DEBUG_FONTSEL
+ printf("Switch to drawable 0x%x\n", drawable);
+#endif /* DEBUG_FONTSEL */
+ fontPtr->ftDraw = XftDrawCreate(display, drawable,
+ DefaultVisual(display, fontPtr->screen),
+ DefaultColormap(display, fontPtr->screen));
+ } else {
+ Tk_ErrorHandler handler =
+ Tk_CreateErrorHandler(display, -1, -1, -1, NULL, NULL);
+
+ XftDrawChange(fontPtr->ftDraw, drawable);
+ Tk_DeleteErrorHandler(handler);
+ }
+
+ XGetGCValues(display, gc, GCForeground, &values);
+ if (values.foreground != fontPtr->color.pixel) {
+ xcolor.pixel = values.foreground;
+ XQueryColor(display, DefaultColormap(display, fontPtr->screen),
+ &xcolor);
+ fontPtr->color.color.red = xcolor.red;
+ fontPtr->color.color.green = xcolor.green;
+ fontPtr->color.color.blue = xcolor.blue;
+ fontPtr->color.color.alpha = 0xffff;
+ fontPtr->color.pixel = values.foreground;
+ }
+ if (tsdPtr->clipRegion != None) {
+ XftDrawSetClip(fontPtr->ftDraw, tsdPtr->clipRegion);
+ }
+
+ nglyph = 0;
+ currentFtFont = NULL;
+ originX = originY = 0; /* lint */
+
+ while (numBytes > 0 && x <= maxCoord && x >= minCoord && y <= maxCoord
+ && y >= minCoord) {
+ XftFont *ftFont;
+ FcChar32 c;
+
+ clen = FcUtf8ToUcs4((FcChar8 *) source, &c, numBytes);
+ if (clen <= 0) {
+ /*
+ * This should not happen, but it can.
+ */
+
+ goto doUnderlineStrikeout;
+ }
+ source += clen;
+ numBytes -= clen;
+
+ ftFont = GetFont(fontPtr, c, angle);
+ if (!ftFont) {
+ continue;
+ }
+
+ if (ftFont != currentFtFont || nglyph == NUM_SPEC) {
+ if (nglyph) {
+ /*
+ * We pass multiple glyphs at once to enable the code to
+ * perform better rendering of sub-pixel inter-glyph spacing.
+ * If only the current Xft implementation could make use of
+ * this information... but we'll be ready when it does!
+ */
+
+ XftDrawGlyphs(fontPtr->ftDraw, &fontPtr->color, currentFtFont,
+ originX, originY, glyphs, nglyph);
+ }
+ originX = ROUND16(x);
+ originY = ROUND16(y);
+ if (nglyph) {
+ XftGlyphExtents(fontPtr->display, currentFtFont, glyphs,
+ nglyph, &metrics);
+ nglyph = 0;
+ x += metrics.xOff;
+ y += metrics.yOff;
+ }
+ currentFtFont = ftFont;
+ }
+ glyphs[nglyph++] = XftCharIndex(fontPtr->display, ftFont, c);
+ }
+ if (nglyph) {
+ XftDrawGlyphs(fontPtr->ftDraw, &fontPtr->color, currentFtFont,
+ originX, originY, glyphs, nglyph);
+ }
+#else /* !XFT_HAS_FIXED_ROTATED_PLACEMENT */
+ int clen, nspec;
+ XftGlyphFontSpec specs[NUM_SPEC];
+ XGlyphInfo metrics;
+ double sinA = sin(angle * PI/180.0), cosA = cos(angle * PI/180.0);
+
+ if (fontPtr->ftDraw == 0) {
+#if DEBUG_FONTSEL
+ printf("Switch to drawable 0x%x\n", drawable);
+#endif /* DEBUG_FONTSEL */
+ fontPtr->ftDraw = XftDrawCreate(display, drawable,
+ DefaultVisual(display, fontPtr->screen),
+ DefaultColormap(display, fontPtr->screen));
+ } else {
+ Tk_ErrorHandler handler =
+ Tk_CreateErrorHandler(display, -1, -1, -1, NULL, NULL);
+
+ XftDrawChange(fontPtr->ftDraw, drawable);
+ Tk_DeleteErrorHandler(handler);
+ }
+ XGetGCValues(display, gc, GCForeground, &values);
+ if (values.foreground != fontPtr->color.pixel) {
+ xcolor.pixel = values.foreground;
+ XQueryColor(display, DefaultColormap(display, fontPtr->screen),
+ &xcolor);
+ fontPtr->color.color.red = xcolor.red;
+ fontPtr->color.color.green = xcolor.green;
+ fontPtr->color.color.blue = xcolor.blue;
+ fontPtr->color.color.alpha = 0xffff;
+ fontPtr->color.pixel = values.foreground;
+ }
+ if (tsdPtr->clipRegion != None) {
+ XftDrawSetClip(fontPtr->ftDraw, tsdPtr->clipRegion);
+ }
+ nspec = 0;
+ while (numBytes > 0 && x <= maxCoord && x >= minCoord
+ && y <= maxCoord && y >= minCoord) {
+ XftFont *ftFont, *ft0Font;
+ FcChar32 c;
+
+ clen = FcUtf8ToUcs4((FcChar8 *) source, &c, numBytes);
+ if (clen <= 0) {
+ /*
+ * This should not happen, but it can.
+ */
+
+ goto doUnderlineStrikeout;
+ }
+ source += clen;
+ numBytes -= clen;
+
+ ftFont = GetFont(fontPtr, c, angle);
+ ft0Font = GetFont(fontPtr, c, 0.0);
+ if (ftFont && ft0Font) {
+ specs[nspec].font = ftFont;
+ specs[nspec].glyph = XftCharIndex(fontPtr->display, ftFont, c);
+ specs[nspec].x = ROUND16(x);
+ specs[nspec].y = ROUND16(y);
+ XftGlyphExtents(fontPtr->display, ft0Font, &specs[nspec].glyph, 1,
+ &metrics);
+ x += metrics.xOff*cosA + metrics.yOff*sinA;
+ y += metrics.yOff*cosA - metrics.xOff*sinA;
+ nspec++;
+ if (nspec == NUM_SPEC) {
+ XftDrawGlyphFontSpec(fontPtr->ftDraw, &fontPtr->color,
+ specs, nspec);
+ nspec = 0;
+ }
+ }
+ }
+ if (nspec) {
+ XftDrawGlyphFontSpec(fontPtr->ftDraw, &fontPtr->color, specs, nspec);
+ }
+#endif /* XFT_HAS_FIXED_ROTATED_PLACEMENT */
+
+ doUnderlineStrikeout:
+ if (tsdPtr->clipRegion != None) {
+ XftDrawSetClip(fontPtr->ftDraw, None);
+ }
+ if (fontPtr->font.fa.underline || fontPtr->font.fa.overstrike) {
+ XPoint points[5];
+ double width = (x - xStart) * cosA + (yStart - y) * sinA;
+ double barHeight = fontPtr->font.underlineHeight;
+ double dy = fontPtr->font.underlinePos;
+
+ if (fontPtr->font.fa.underline != 0) {
+ if (fontPtr->font.underlineHeight == 1) {
+ dy++;
+ }
+ points[0].x = xStart + ROUND16(dy*sinA);
+ points[0].y = yStart + ROUND16(dy*cosA);
+ points[1].x = xStart + ROUND16(dy*sinA + width*cosA);
+ points[1].y = yStart + ROUND16(dy*cosA - width*sinA);
+ if (fontPtr->font.underlineHeight == 1) {
+ XDrawLines(display, drawable, gc, points, 2, CoordModeOrigin);
+ } else {
+ points[2].x = xStart + ROUND16(dy*sinA + width*cosA
+ + barHeight*sinA);
+ points[2].y = yStart + ROUND16(dy*cosA - width*sinA
+ + barHeight*cosA);
+ points[3].x = xStart + ROUND16(dy*sinA + barHeight*sinA);
+ points[3].y = yStart + ROUND16(dy*cosA + barHeight*cosA);
+ points[4].x = points[0].x;
+ points[4].y = points[0].y;
+ XFillPolygon(display, drawable, gc, points, 5, Complex,
+ CoordModeOrigin);
+ XDrawLines(display, drawable, gc, points, 5, CoordModeOrigin);
+ }
+ }
+ if (fontPtr->font.fa.overstrike != 0) {
+ dy = -fontPtr->font.fm.descent
+ - (fontPtr->font.fm.ascent) / 10;
+ points[0].x = xStart + ROUND16(dy*sinA);
+ points[0].y = yStart + ROUND16(dy*cosA);
+ points[1].x = xStart + ROUND16(dy*sinA + width*cosA);
+ points[1].y = yStart + ROUND16(dy*cosA - width*sinA);
+ if (fontPtr->font.underlineHeight == 1) {
+ XDrawLines(display, drawable, gc, points, 2, CoordModeOrigin);
+ } else {
+ points[2].x = xStart + ROUND16(dy*sinA + width*cosA
+ + barHeight*sinA);
+ points[2].y = yStart + ROUND16(dy*cosA - width*sinA
+ + barHeight*cosA);
+ points[3].x = xStart + ROUND16(dy*sinA + barHeight*sinA);
+ points[3].y = yStart + ROUND16(dy*cosA + barHeight*cosA);
+ points[4].x = points[0].x;
+ points[4].y = points[0].y;
+ XFillPolygon(display, drawable, gc, points, 5, Complex,
+ CoordModeOrigin);
+ XDrawLines(display, drawable, gc, points, 5, CoordModeOrigin);
+ }
+ }
+ }
+}
+
+void
TkUnixSetXftClipRegion(
TkRegion clipRegion) /* The clipping region to install. */
{
@@ -817,3 +1131,10 @@ TkUnixSetXftClipRegion(
tsdPtr->clipRegion = (Region) clipRegion;
}
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */
diff --git a/unix/tkUnixScale.c b/unix/tkUnixScale.c
index e158549..cc33a27 100644
--- a/unix/tkUnixScale.c
+++ b/unix/tkUnixScale.c
@@ -46,7 +46,7 @@ TkScale *
TkpCreateScale(
Tk_Window tkwin)
{
- return (TkScale *) ckalloc(sizeof(TkScale));
+ return ckalloc(sizeof(TkScale));
}
/*
@@ -71,7 +71,7 @@ void
TkpDestroyScale(
TkScale *scalePtr)
{
- Tcl_EventuallyFree((ClientData) scalePtr, TCL_DYNAMIC);
+ Tcl_EventuallyFree(scalePtr, TCL_DYNAMIC);
}
/*
@@ -537,6 +537,7 @@ TkpDisplayScale(
int result;
char string[PRINT_CHARS];
XRectangle drawnArea;
+ Tcl_DString buf;
scalePtr->flags &= ~REDRAW_PENDING;
if ((scalePtr->tkwin == NULL) || !Tk_IsMapped(scalePtr->tkwin)) {
@@ -547,24 +548,28 @@ TkpDisplayScale(
* Invoke the scale's command if needed.
*/
- Tcl_Preserve((ClientData) scalePtr);
+ Tcl_Preserve(scalePtr);
if ((scalePtr->flags & INVOKE_COMMAND) && (scalePtr->command != NULL)) {
- Tcl_Preserve((ClientData) interp);
+ Tcl_Preserve(interp);
sprintf(string, scalePtr->format, scalePtr->value);
- result = Tcl_VarEval(interp, scalePtr->command, " ", string,
- (char *) NULL);
+ Tcl_DStringInit(&buf);
+ Tcl_DStringAppend(&buf, scalePtr->command, -1);
+ Tcl_DStringAppend(&buf, " ", -1);
+ Tcl_DStringAppend(&buf, string, -1);
+ result = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), -1, 0);
+ Tcl_DStringFree(&buf);
if (result != TCL_OK) {
Tcl_AddErrorInfo(interp, "\n (command executed by scale)");
- Tcl_BackgroundError(interp);
+ Tcl_BackgroundException(interp, result);
}
- Tcl_Release((ClientData) interp);
+ Tcl_Release(interp);
}
scalePtr->flags &= ~INVOKE_COMMAND;
if (scalePtr->flags & SCALE_DELETED) {
- Tcl_Release((ClientData) scalePtr);
+ Tcl_Release(scalePtr);
return;
}
- Tcl_Release((ClientData) scalePtr);
+ Tcl_Release(scalePtr);
#ifndef TK_NO_DOUBLE_BUFFERING
/*
diff --git a/unix/tkUnixScrlbr.c b/unix/tkUnixScrlbr.c
index 1e70925..0507211 100644
--- a/unix/tkUnixScrlbr.c
+++ b/unix/tkUnixScrlbr.c
@@ -36,8 +36,11 @@ typedef struct UnixScrollbar {
* variable is declared at this scope.
*/
-Tk_ClassProcs tkpScrollbarProcs = {
- sizeof(Tk_ClassProcs) /* size */
+const Tk_ClassProcs tkpScrollbarProcs = {
+ sizeof(Tk_ClassProcs), /* size */
+ NULL, /* worldChangedProc */
+ NULL, /* createProc */
+ NULL /* modalProc */
};
/*
@@ -60,13 +63,14 @@ TkScrollbar *
TkpCreateScrollbar(
Tk_Window tkwin)
{
- UnixScrollbar *scrollPtr = (UnixScrollbar *)ckalloc(sizeof(UnixScrollbar));
+ UnixScrollbar *scrollPtr = ckalloc(sizeof(UnixScrollbar));
+
scrollPtr->troughGC = None;
scrollPtr->copyGC = None;
Tk_CreateEventHandler(tkwin,
ExposureMask|StructureNotifyMask|FocusChangeMask,
- TkScrollbarEventProc, (ClientData) scrollPtr);
+ TkScrollbarEventProc, scrollPtr);
return (TkScrollbar *) scrollPtr;
}
@@ -301,14 +305,13 @@ TkpComputeScrollbarGeometry(
* grabbed with the mouse).
*/
- if (scrollPtr->sliderFirst > (fieldLength - MIN_SLIDER_LENGTH)) {
+ if (scrollPtr->sliderFirst > fieldLength - MIN_SLIDER_LENGTH) {
scrollPtr->sliderFirst = fieldLength - MIN_SLIDER_LENGTH;
}
if (scrollPtr->sliderFirst < 0) {
scrollPtr->sliderFirst = 0;
}
- if (scrollPtr->sliderLast < (scrollPtr->sliderFirst
- + MIN_SLIDER_LENGTH)) {
+ if (scrollPtr->sliderLast < scrollPtr->sliderFirst + MIN_SLIDER_LENGTH) {
scrollPtr->sliderLast = scrollPtr->sliderFirst + MIN_SLIDER_LENGTH;
}
if (scrollPtr->sliderLast > fieldLength) {
@@ -404,8 +407,8 @@ TkpConfigureScrollbar(
unixScrollPtr->troughGC = new;
if (unixScrollPtr->copyGC == None) {
gcValues.graphics_exposures = False;
- unixScrollPtr->copyGC = Tk_GetGC(scrollPtr->tkwin, GCGraphicsExposures,
- &gcValues);
+ unixScrollPtr->copyGC = Tk_GetGC(scrollPtr->tkwin,
+ GCGraphicsExposures, &gcValues);
}
}
@@ -434,6 +437,7 @@ TkpScrollbarPosition(
int x, int y) /* Coordinates within scrollPtr's window. */
{
int length, width, tmp;
+ register const int inset = scrollPtr->inset;
if (scrollPtr->vertical) {
length = Tk_Height(scrollPtr->tkwin);
@@ -446,8 +450,7 @@ TkpScrollbarPosition(
width = Tk_Height(scrollPtr->tkwin);
}
- if ((x < scrollPtr->inset) || (x >= (width - scrollPtr->inset))
- || (y < scrollPtr->inset) || (y >= (length - scrollPtr->inset))) {
+ if (x<inset || x>=width-inset || y<inset || y>=length-inset) {
return OUTSIDE;
}
@@ -456,7 +459,7 @@ TkpScrollbarPosition(
* TkpDisplayScrollbar. Be sure to keep the two consistent.
*/
- if (y < (scrollPtr->inset + scrollPtr->arrowLength)) {
+ if (y < inset + scrollPtr->arrowLength) {
return TOP_ARROW;
}
if (y < scrollPtr->sliderFirst) {
@@ -465,7 +468,7 @@ TkpScrollbarPosition(
if (y < scrollPtr->sliderLast) {
return SLIDER;
}
- if (y >= (length - (scrollPtr->arrowLength + scrollPtr->inset))) {
+ if (y >= length - (scrollPtr->arrowLength + inset)) {
return BOTTOM_ARROW;
}
return BOTTOM_GAP;
diff --git a/unix/tkUnixSelect.c b/unix/tkUnixSelect.c
index 060fdd1..4bb462e 100644
--- a/unix/tkUnixSelect.c
+++ b/unix/tkUnixSelect.c
@@ -183,7 +183,7 @@ TkSelGetSelection(
*/
retr.timeout = Tcl_CreateTimerHandler(1000, SelTimeoutProc,
- (ClientData) &retr);
+ &retr);
while (retr.result == -1) {
Tcl_DoOneEvent(0);
}
@@ -243,7 +243,7 @@ TkSelPropProc(
long buffer[TK_SEL_WORDS_AT_ONCE];
TkDisplay *dispPtr = TkGetDisplay(eventPtr->xany.display);
Tk_ErrorHandler errorHandler;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
@@ -326,7 +326,7 @@ TkSelPropProc(
length = strlen(incrPtr->converts[i].buffer);
strcpy((char *)buffer, incrPtr->converts[i].buffer);
- numItems = (*selPtr->proc)(selPtr->clientData,
+ numItems = selPtr->proc(selPtr->clientData,
incrPtr->converts[i].offset,
((char *) buffer) + length,
TK_SEL_BYTES_AT_ONCE - length);
@@ -552,12 +552,12 @@ TkSelEventProc(
break;
}
if (eventPtr->xselection.property == None) {
- Tcl_SetResult(retrPtr->interp, NULL, TCL_STATIC);
- Tcl_AppendResult(retrPtr->interp,
+ Tcl_SetObjResult(retrPtr->interp, Tcl_ObjPrintf(
+ "%s selection doesn't exist or form \"%s\" not defined",
Tk_GetAtomName(tkwin, retrPtr->selection),
- " selection doesn't exist or form \"",
- Tk_GetAtomName(tkwin, retrPtr->target),
- "\" not defined", NULL);
+ Tk_GetAtomName(tkwin, retrPtr->target)));
+ Tcl_SetErrorCode(retrPtr->interp, "TK", "SELECTION",
+ "NONE", NULL);
retrPtr->result = TCL_ERROR;
return;
}
@@ -574,8 +574,9 @@ TkSelEventProc(
return;
}
if (bytesAfter != 0) {
- Tcl_SetResult(retrPtr->interp, "selection property too large",
- TCL_STATIC);
+ Tcl_SetObjResult(retrPtr->interp, Tcl_NewStringObj(
+ "selection property too large", -1));
+ Tcl_SetErrorCode(retrPtr->interp, "TK", "SELECTION", "SIZE",NULL);
retrPtr->result = TCL_ERROR;
XFree(propInfo);
return;
@@ -583,18 +584,18 @@ TkSelEventProc(
if ((type == XA_STRING) || (type == dispPtr->textAtom)
|| (type == dispPtr->compoundTextAtom)) {
Tcl_Encoding encoding;
- if (format != 8) {
- char buf[64 + TCL_INTEGER_SPACE];
- sprintf(buf,
+ if (format != 8) {
+ Tcl_SetObjResult(retrPtr->interp, Tcl_ObjPrintf(
"bad format for string selection: wanted \"8\", got \"%d\"",
- format);
- Tcl_SetResult(retrPtr->interp, buf, TCL_VOLATILE);
+ format));
+ Tcl_SetErrorCode(retrPtr->interp, "TK", "SELECTION", "FORMAT",
+ NULL);
retrPtr->result = TCL_ERROR;
return;
}
interp = retrPtr->interp;
- Tcl_Preserve((ClientData) interp);
+ Tcl_Preserve(interp);
/*
* Convert the X selection data into UTF before passing it to the
@@ -617,10 +618,10 @@ TkSelEventProc(
Tcl_FreeEncoding(encoding);
}
- retrPtr->result = (*retrPtr->proc)(retrPtr->clientData,
- interp, Tcl_DStringValue(&ds));
+ retrPtr->result = retrPtr->proc(retrPtr->clientData, interp,
+ Tcl_DStringValue(&ds));
Tcl_DStringFree(&ds);
- Tcl_Release((ClientData) interp);
+ Tcl_Release(interp);
} else if (type == dispPtr->utf8Atom) {
/*
* The X selection data is in UTF-8 format already. We can't
@@ -631,25 +632,24 @@ TkSelEventProc(
char *propData = propInfo;
if (format != 8) {
- char buf[64 + TCL_INTEGER_SPACE];
-
- sprintf(buf,
+ Tcl_SetObjResult(retrPtr->interp, Tcl_ObjPrintf(
"bad format for string selection: wanted \"8\", got \"%d\"",
- format);
- Tcl_SetResult(retrPtr->interp, buf, TCL_VOLATILE);
+ format));
+ Tcl_SetErrorCode(retrPtr->interp, "TK", "SELECTION", "FORMAT",
+ NULL);
retrPtr->result = TCL_ERROR;
return;
}
if (propInfo[numItems] != '\0') {
- propData = ckalloc((size_t) numItems + 1);
+ propData = ckalloc(numItems + 1);
strcpy(propData, propInfo);
propData[numItems] = '\0';
}
- retrPtr->result = (*retrPtr->proc)(retrPtr->clientData,
+ retrPtr->result = retrPtr->proc(retrPtr->clientData,
retrPtr->interp, propData);
if (propData != propInfo) {
- ckfree((char *) propData);
+ ckfree(propData);
}
} else if (type == dispPtr->incrAtom) {
@@ -661,23 +661,23 @@ TkSelEventProc(
retrPtr->idleTime = 0;
Tk_CreateEventHandler(tkwin, PropertyChangeMask, SelRcvIncrProc,
- (ClientData) retrPtr);
+ retrPtr);
XDeleteProperty(Tk_Display(tkwin), Tk_WindowId(tkwin),
retrPtr->property);
while (retrPtr->result == -1) {
Tcl_DoOneEvent(0);
}
Tk_DeleteEventHandler(tkwin, PropertyChangeMask, SelRcvIncrProc,
- (ClientData) retrPtr);
+ retrPtr);
} else {
Tcl_DString ds;
if (format != 32 && format != 8) {
- char buf[64 + TCL_INTEGER_SPACE];
-
- sprintf(buf, "bad format for selection: wanted \"32\" or "
- "\"8\", got \"%d\"", format);
- Tcl_SetResult(retrPtr->interp, buf, TCL_VOLATILE);
+ Tcl_SetObjResult(retrPtr->interp, Tcl_ObjPrintf(
+ "bad format for selection: wanted \"32\" or "
+ "\"8\", got \"%d\"", format));
+ Tcl_SetErrorCode(retrPtr->interp, "TK", "SELECTION", "FORMAT",
+ NULL);
retrPtr->result = TCL_ERROR;
return;
}
@@ -690,10 +690,10 @@ TkSelEventProc(
(Tk_Window) winPtr, &ds);
}
interp = retrPtr->interp;
- Tcl_Preserve((ClientData) interp);
- retrPtr->result = (*retrPtr->proc)(retrPtr->clientData,
+ Tcl_Preserve(interp);
+ retrPtr->result = retrPtr->proc(retrPtr->clientData,
interp, Tcl_DStringValue(&ds));
- Tcl_Release((ClientData) interp);
+ Tcl_Release(interp);
Tcl_DStringFree(&ds);
}
XFree(propInfo);
@@ -735,7 +735,7 @@ static void
SelTimeoutProc(
ClientData clientData) /* Information about retrieval in progress. */
{
- register TkSelRetrievalInfo *retrPtr = (TkSelRetrievalInfo *) clientData;
+ register TkSelRetrievalInfo *retrPtr = clientData;
/*
* Make sure that the retrieval is still in progress. Then see how long
@@ -753,8 +753,9 @@ SelTimeoutProc(
* selection return.
*/
- Tcl_SetResult(retrPtr->interp, "selection owner didn't respond",
- TCL_STATIC);
+ Tcl_SetObjResult(retrPtr->interp, Tcl_NewStringObj(
+ "selection owner didn't respond", -1));
+ Tcl_SetErrorCode(retrPtr->interp, "TK", "SELECTION", "IGNORED", NULL);
retrPtr->result = TCL_ERROR;
} else {
retrPtr->timeout = Tcl_CreateTimerHandler(1000, SelTimeoutProc,
@@ -791,7 +792,10 @@ ConvertSelection(
register XSelectionRequestEvent *eventPtr)
/* Event describing request. */
{
- XSelectionEvent reply; /* Used to notify requestor that selection
+ union {
+ XSelectionEvent xsel;
+ XEvent ev;
+ } reply; /* Used to notify requestor that selection
* info is ready. */
int multiple; /* Non-zero means a MULTIPLE request is being
* handled. */
@@ -802,7 +806,7 @@ ConvertSelection(
Tk_ErrorHandler errorHandler;
TkSelectionInfo *infoPtr;
TkSelInProgress ip;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
errorHandler = Tk_CreateErrorHandler(eventPtr->display, -1, -1,-1,
@@ -812,18 +816,18 @@ ConvertSelection(
* Initialize the reply event.
*/
- reply.type = SelectionNotify;
- reply.serial = 0;
- reply.send_event = True;
- reply.display = eventPtr->display;
- reply.requestor = eventPtr->requestor;
- reply.selection = eventPtr->selection;
- reply.target = eventPtr->target;
- reply.property = eventPtr->property;
- if (reply.property == None) {
- reply.property = reply.target;
+ reply.xsel.type = SelectionNotify;
+ reply.xsel.serial = 0;
+ reply.xsel.send_event = True;
+ reply.xsel.display = eventPtr->display;
+ reply.xsel.requestor = eventPtr->requestor;
+ reply.xsel.selection = eventPtr->selection;
+ reply.xsel.target = eventPtr->target;
+ reply.xsel.property = eventPtr->property;
+ if (reply.xsel.property == None) {
+ reply.xsel.property = reply.xsel.target;
}
- reply.time = eventPtr->time;
+ reply.xsel.time = eventPtr->time;
for (infoPtr = winPtr->dispPtr->selectionInfoPtr; infoPtr != NULL;
infoPtr = infoPtr->nextPtr) {
@@ -846,8 +850,8 @@ ConvertSelection(
incr.selection = eventPtr->selection;
if (eventPtr->target != winPtr->dispPtr->multipleAtom) {
multiple = 0;
- singleInfo[0] = reply.target;
- singleInfo[1] = reply.property;
+ singleInfo[0] = reply.xsel.target;
+ singleInfo[1] = reply.xsel.property;
incr.multAtoms = singleInfo;
incr.numConversions = 1;
} else {
@@ -871,7 +875,7 @@ ConvertSelection(
}
goto refuse;
}
- incr.numConversions /= 2; /* Two atoms per conversion. */
+ incr.numConversions /= 2; /* Two atoms per conversion. */
}
/*
@@ -881,8 +885,7 @@ ConvertSelection(
* below).
*/
- incr.converts = (ConvertInfo *)
- ckalloc((unsigned) incr.numConversions * sizeof(ConvertInfo));
+ incr.converts = ckalloc(incr.numConversions * sizeof(ConvertInfo));
incr.numIncrs = 0;
for (i = 0; i < incr.numConversions; i++) {
Atom target, property, type;
@@ -922,8 +925,8 @@ ConvertSelection(
ip.nextPtr = TkSelGetInProgress();
TkSelSetInProgress(&ip);
type = selPtr->format;
- numItems = (*selPtr->proc)(selPtr->clientData, 0,
- (char *) buffer, TK_SEL_BYTES_AT_ONCE);
+ numItems = selPtr->proc(selPtr->clientData, 0, (char *) buffer,
+ TK_SEL_BYTES_AT_ONCE);
TkSelSetInProgress(ip.nextPtr);
if ((ip.selPtr == NULL) || (numItems < 0)) {
incr.multAtoms[2*i + 1] = None;
@@ -956,7 +959,7 @@ ConvertSelection(
propPtr = (char *) buffer;
format = 32;
incr.converts[i].offset = 0;
- XChangeProperty(reply.display, reply.requestor,
+ XChangeProperty(reply.xsel.display, reply.xsel.requestor,
property, type, format, PropModeReplace,
(unsigned char *) propPtr, numItems);
} else if (type == winPtr->dispPtr->utf8Atom) {
@@ -965,8 +968,9 @@ ConvertSelection(
* allows us to pass our utf-8 information untouched.
*/
- XChangeProperty(reply.display, reply.requestor, property, type, 8,
- PropModeReplace, (unsigned char *) buffer, numItems);
+ XChangeProperty(reply.xsel.display, reply.xsel.requestor,
+ property, type, 8, PropModeReplace,
+ (unsigned char *) buffer, numItems);
} else if ((type == XA_STRING)
|| (type == winPtr->dispPtr->compoundTextAtom)) {
Tcl_DString ds;
@@ -984,8 +988,9 @@ ConvertSelection(
encoding = Tcl_GetEncoding(NULL, "iso2022");
}
Tcl_UtfToExternalDString(encoding, (char *) buffer, -1, &ds);
- XChangeProperty(reply.display, reply.requestor, property, type, 8,
- PropModeReplace, (unsigned char *) Tcl_DStringValue(&ds),
+ XChangeProperty(reply.xsel.display, reply.xsel.requestor,
+ property, type, 8, PropModeReplace,
+ (unsigned char *) Tcl_DStringValue(&ds),
Tcl_DStringLength(&ds));
if (encoding) {
Tcl_FreeEncoding(encoding);
@@ -998,9 +1003,9 @@ ConvertSelection(
goto refuse;
}
format = 32;
- XChangeProperty(reply.display, reply.requestor, property, type,
- format, PropModeReplace, (unsigned char *) propPtr,
- numItems);
+ XChangeProperty(reply.xsel.display, reply.xsel.requestor,
+ property, type, format, PropModeReplace,
+ (unsigned char *) propPtr, numItems);
ckfree(propPtr);
}
}
@@ -1012,18 +1017,18 @@ ConvertSelection(
*/
if (incr.numIncrs > 0) {
- XSelectInput(reply.display, reply.requestor, PropertyChangeMask);
- incr.timeout = Tcl_CreateTimerHandler(1000, IncrTimeoutProc,
- (ClientData) &incr);
+ XSelectInput(reply.xsel.display, reply.xsel.requestor,
+ PropertyChangeMask);
+ incr.timeout = Tcl_CreateTimerHandler(1000, IncrTimeoutProc, &incr);
incr.idleTime = 0;
- incr.reqWindow = reply.requestor;
+ incr.reqWindow = reply.xsel.requestor;
incr.time = infoPtr->time;
incr.nextPtr = tsdPtr->pendingIncrs;
tsdPtr->pendingIncrs = &incr;
}
if (multiple) {
- XChangeProperty(reply.display, reply.requestor, reply.property,
- XA_ATOM, 32, PropModeReplace,
+ XChangeProperty(reply.xsel.display, reply.xsel.requestor,
+ reply.xsel.property, XA_ATOM, 32, PropModeReplace,
(unsigned char *) incr.multAtoms,
(int) incr.numConversions*2);
} else {
@@ -1032,9 +1037,9 @@ ConvertSelection(
* to None if there was an error in conversion.
*/
- reply.property = incr.multAtoms[1];
+ reply.xsel.property = incr.multAtoms[1];
}
- XSendEvent(reply.display, reply.requestor, False, 0, (XEvent *) &reply);
+ XSendEvent(reply.xsel.display, reply.xsel.requestor, False, 0, &reply.ev);
Tk_DeleteErrorHandler(errorHandler);
/*
@@ -1051,8 +1056,8 @@ ConvertSelection(
}
Tcl_DeleteTimerHandler(incr.timeout);
errorHandler = Tk_CreateErrorHandler(winPtr->display,
- -1, -1,-1, (int (*)()) NULL, NULL);
- XSelectInput(reply.display, reply.requestor, 0L);
+ -1, -1, -1, (int (*)()) NULL, NULL);
+ XSelectInput(reply.xsel.display, reply.xsel.requestor, 0L);
Tk_DeleteErrorHandler(errorHandler);
if (tsdPtr->pendingIncrs == &incr) {
tsdPtr->pendingIncrs = incr.nextPtr;
@@ -1071,7 +1076,7 @@ ConvertSelection(
* All done. Cleanup and return.
*/
- ckfree((char *) incr.converts);
+ ckfree(incr.converts);
if (multiple) {
XFree((char *) incr.multAtoms);
}
@@ -1082,8 +1087,8 @@ ConvertSelection(
*/
refuse:
- reply.property = None;
- XSendEvent(reply.display, reply.requestor, False, 0, (XEvent *) &reply);
+ reply.xsel.property = None;
+ XSendEvent(reply.xsel.display, reply.xsel.requestor, False, 0, &reply.ev);
Tk_DeleteErrorHandler(errorHandler);
return;
}
@@ -1113,7 +1118,7 @@ SelRcvIncrProc(
ClientData clientData, /* Information about retrieval. */
register XEvent *eventPtr) /* X PropertyChange event. */
{
- register TkSelRetrievalInfo *retrPtr = (TkSelRetrievalInfo *) clientData;
+ register TkSelRetrievalInfo *retrPtr = clientData;
char *propInfo, **propInfoPtr = &propInfo;
Atom type;
int format, result;
@@ -1134,8 +1139,9 @@ SelRcvIncrProc(
return;
}
if (bytesAfter != 0) {
- Tcl_SetResult(retrPtr->interp, "selection property too large",
- TCL_STATIC);
+ Tcl_SetObjResult(retrPtr->interp, Tcl_NewStringObj(
+ "selection property too large", -1));
+ Tcl_SetErrorCode(retrPtr->interp, "TK", "SELECTION", "SIZE", NULL);
retrPtr->result = TCL_ERROR;
goto done;
}
@@ -1149,17 +1155,16 @@ SelRcvIncrProc(
Tcl_DString *dstPtr, temp;
if (format != 8) {
- char buf[64 + TCL_INTEGER_SPACE];
-
- sprintf(buf,
+ Tcl_SetObjResult(retrPtr->interp, Tcl_ObjPrintf(
"bad format for string selection: wanted \"8\", got \"%d\"",
- format);
- Tcl_SetResult(retrPtr->interp, buf, TCL_VOLATILE);
+ format));
+ Tcl_SetErrorCode(retrPtr->interp, "TK", "SELECTION", "FORMAT",
+ NULL);
retrPtr->result = TCL_ERROR;
goto done;
}
interp = retrPtr->interp;
- Tcl_Preserve((ClientData) interp);
+ Tcl_Preserve(interp);
if (type == retrPtr->winPtr->dispPtr->compoundTextAtom) {
encoding = Tcl_GetEncoding(NULL, "iso2022");
@@ -1190,7 +1195,7 @@ SelRcvIncrProc(
*/
retrPtr->result = TCL_OK;
- Tcl_Release((ClientData) interp);
+ Tcl_Release(interp);
goto done;
} else {
src = propInfo;
@@ -1231,9 +1236,9 @@ SelRcvIncrProc(
}
Tcl_DStringSetLength(dstPtr, soFar);
- result = (*retrPtr->proc)(retrPtr->clientData, interp,
+ result = retrPtr->proc(retrPtr->clientData, interp,
Tcl_DStringValue(dstPtr));
- Tcl_Release((ClientData) interp);
+ Tcl_Release(interp);
/*
* Copy any unused data into the destination buffer so we can pick it
@@ -1256,11 +1261,11 @@ SelRcvIncrProc(
Tcl_DString ds;
if (format != 32 && format != 8) {
- char buf[64 + TCL_INTEGER_SPACE];
-
- sprintf(buf, "bad format for selection: wanted \"32\" or "
- "\"8\", got \"%d\"", format);
- Tcl_SetResult(retrPtr->interp, buf, TCL_VOLATILE);
+ Tcl_SetObjResult(retrPtr->interp, Tcl_ObjPrintf(
+ "bad format for selection: wanted \"32\" or "
+ "\"8\", got \"%d\"", format));
+ Tcl_SetErrorCode(retrPtr->interp, "TK", "SELECTION", "FORMAT",
+ NULL);
retrPtr->result = TCL_ERROR;
goto done;
}
@@ -1273,10 +1278,10 @@ SelRcvIncrProc(
(Tk_Window) retrPtr->winPtr, &ds);
}
interp = retrPtr->interp;
- Tcl_Preserve((ClientData) interp);
- result = (*retrPtr->proc)(retrPtr->clientData, interp,
+ Tcl_Preserve(interp);
+ result = retrPtr->proc(retrPtr->clientData, interp,
Tcl_DStringValue(&ds));
- Tcl_Release((ClientData) interp);
+ Tcl_Release(interp);
Tcl_DStringFree(&ds);
if (result != TCL_OK) {
retrPtr->result = result;
@@ -1322,7 +1327,7 @@ SelectionSize(
TkSelSetInProgress(&ip);
do {
- chunkSize = (*selPtr->proc)(selPtr->clientData, size, (char *) buffer,
+ chunkSize = selPtr->proc(selPtr->clientData, size, (char *) buffer,
TK_SEL_BYTES_AT_ONCE);
if (ip.selPtr == NULL) {
size = 0;
@@ -1361,14 +1366,14 @@ IncrTimeoutProc(
* retrieval for which we are selection
* owner. */
{
- register IncrInfo *incrPtr = (IncrInfo *) clientData;
+ register IncrInfo *incrPtr = clientData;
incrPtr->idleTime++;
if (incrPtr->idleTime >= 5) {
incrPtr->numIncrs = 0;
} else {
incrPtr->timeout = Tcl_CreateTimerHandler(1000, IncrTimeoutProc,
- (ClientData) incrPtr);
+ incrPtr);
}
}
@@ -1422,7 +1427,7 @@ SelCvtToX(
if (Tcl_SplitList(NULL, string, &numFields, &field) != TCL_OK) {
return NULL;
}
- propPtr = (long *) ckalloc((unsigned) numFields*sizeof(long));
+ propPtr = ckalloc(numFields * sizeof(long));
/*
* Convert the fields one-by-one.
@@ -1447,7 +1452,7 @@ SelCvtToX(
* Release the parsed list.
*/
- ckfree((char *) field);
+ ckfree(field);
*numLongsPtr = i;
return propPtr;
}
diff --git a/unix/tkUnixSend.c b/unix/tkUnixSend.c
index 3fb745e..53a2196 100644
--- a/unix/tkUnixSend.c
+++ b/unix/tkUnixSend.c
@@ -77,7 +77,7 @@ typedef struct NameRegistry {
typedef struct PendingCommand {
int serial; /* Serial number expected in result. */
TkDisplay *dispPtr; /* Display being used for communication. */
- CONST char *target; /* Name of interpreter command is being sent
+ const char *target; /* Name of interpreter command is being sent
* to. */
Window commWindow; /* Target's communication window. */
Tcl_Interp *interp; /* Interpreter from which the send was
@@ -210,19 +210,18 @@ static void AppendPropCarefully(Display *display,
int length, PendingCommand *pendingPtr);
static void DeleteProc(ClientData clientData);
static void RegAddName(NameRegistry *regPtr,
- CONST char *name, Window commWindow);
+ const char *name, Window commWindow);
static void RegClose(NameRegistry *regPtr);
-static void RegDeleteName(NameRegistry *regPtr, CONST char *name);
-static Window RegFindName(NameRegistry *regPtr, CONST char *name);
+static void RegDeleteName(NameRegistry *regPtr, const char *name);
+static Window RegFindName(NameRegistry *regPtr, const char *name);
static NameRegistry * RegOpen(Tcl_Interp *interp,
TkDisplay *dispPtr, int lock);
static void SendEventProc(ClientData clientData, XEvent *eventPtr);
static int SendInit(Tcl_Interp *interp, TkDisplay *dispPtr);
-static Tk_RestrictAction SendRestrictProc(ClientData clientData,
- XEvent *eventPtr);
+static Tk_RestrictProc SendRestrictProc;
static int ServerSecure(TkDisplay *dispPtr);
static void UpdateCommWindow(TkDisplay *dispPtr);
-static int ValidateName(TkDisplay *dispPtr, CONST char *name,
+static int ValidateName(TkDisplay *dispPtr, const char *name,
Window commWindow, int oldOK);
/*
@@ -267,7 +266,7 @@ RegOpen(
SendInit(interp, dispPtr);
}
- regPtr = (NameRegistry *) ckalloc(sizeof(NameRegistry));
+ regPtr = ckalloc(sizeof(NameRegistry));
regPtr->dispPtr = dispPtr;
regPtr->locked = 0;
regPtr->modified = 0;
@@ -347,7 +346,7 @@ static Window
RegFindName(
NameRegistry *regPtr, /* Pointer to a registry opened with a
* previous call to RegOpen. */
- CONST char *name) /* Name of an application. */
+ const char *name) /* Name of an application. */
{
char *p;
@@ -358,7 +357,7 @@ RegFindName(
p++;
}
if ((*p != 0) && (strcmp(name, p+1) == 0)) {
- unsigned int id;
+ unsigned id;
if (sscanf(entry, "%x", &id) == 1) {
/*
@@ -400,7 +399,7 @@ static void
RegDeleteName(
NameRegistry *regPtr, /* Pointer to a registry opened with a
* previous call to RegOpen. */
- CONST char *name) /* Name of an application. */
+ const char *name) /* Name of an application. */
{
char *p;
@@ -462,7 +461,7 @@ static void
RegAddName(
NameRegistry *regPtr, /* Pointer to a registry opened with a
* previous call to RegOpen. */
- CONST char *name, /* Name of an application. The caller must
+ const char *name, /* Name of an application. The caller must
* ensure that this name isn't already
* registered. */
Window commWindow) /* X identifier for comm. window of
@@ -471,10 +470,10 @@ RegAddName(
char id[30], *newProp;
int idLength, newBytes;
- sprintf(id, "%x ", (unsigned int) commWindow);
+ sprintf(id, "%x ", (unsigned) commWindow);
idLength = strlen(id);
newBytes = idLength + strlen(name) + 1;
- newProp = ckalloc((unsigned) (regPtr->propLength + newBytes));
+ newProp = ckalloc(regPtr->propLength + newBytes);
strcpy(newProp, id);
strcpy(newProp+idLength, name);
if (regPtr->property != NULL) {
@@ -548,7 +547,7 @@ RegClose(
ckfree(regPtr->property);
}
}
- ckfree((char *) regPtr);
+ ckfree(regPtr);
}
/*
@@ -573,7 +572,7 @@ static int
ValidateName(
TkDisplay *dispPtr, /* Display for which to perform the
* validation. */
- CONST char *name, /* The name of an application. */
+ const char *name, /* The name of an application. */
Window commWindow, /* X identifier for the application's comm.
* window. */
int oldOK) /* Non-zero means that we should consider an
@@ -586,7 +585,7 @@ ValidateName(
Atom actualType;
char *property, **propertyPtr = &property;
Tk_ErrorHandler handler;
- CONST char **argv;
+ const char **argv;
property = NULL;
@@ -634,7 +633,7 @@ ValidateName(
break;
}
}
- ckfree((char *) argv);
+ ckfree(argv);
}
} else {
result = 0;
@@ -743,7 +742,7 @@ ServerSecure(
* the side of safety.
*/
- goto insecure;
+ secure = 0;
#endif /* FamilyServerInterpreted */
}
if (addrPtr != NULL) {
@@ -754,7 +753,7 @@ ServerSecure(
}
/*
- *--------------------------------------------------------------
+ *----------------------------------------------------------------------
*
* Tk_SetAppName --
*
@@ -775,15 +774,15 @@ ServerSecure(
* registration will be removed automatically if the interpreter is
* deleted or the "send" command is removed.
*
- *--------------------------------------------------------------
+ *----------------------------------------------------------------------
*/
-CONST char *
+const char *
Tk_SetAppName(
Tk_Window tkwin, /* Token for any window in the application to
* be named: it is just used to identify the
* application and the display. */
- CONST char *name) /* The name that will be used to refer to the
+ const char *name) /* The name that will be used to refer to the
* interpreter in later "send" commands. Must
* be globally unique. */
{
@@ -793,10 +792,10 @@ Tk_SetAppName(
TkDisplay *dispPtr = winPtr->dispPtr;
NameRegistry *regPtr;
Tcl_Interp *interp;
- CONST char *actualName;
+ const char *actualName;
Tcl_DString dString;
int offset, i;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
interp = winPtr->mainPtr->interp;
@@ -818,14 +817,13 @@ Tk_SetAppName(
* the "send" command to the interpreter.
*/
- riPtr = (RegisteredInterp *) ckalloc(sizeof(RegisteredInterp));
+ riPtr = ckalloc(sizeof(RegisteredInterp));
riPtr->interp = interp;
riPtr->dispPtr = winPtr->dispPtr;
riPtr->nextPtr = tsdPtr->interpListPtr;
tsdPtr->interpListPtr = riPtr;
riPtr->name = NULL;
- Tcl_CreateCommand(interp, "send", Tk_SendCmd, (ClientData) riPtr,
- DeleteProc);
+ Tcl_CreateCommand(interp, "send", Tk_SendCmd, riPtr, DeleteProc);
if (Tcl_IsSafe(interp)) {
Tcl_HideCommand(interp, "send", "send");
}
@@ -903,7 +901,7 @@ Tk_SetAppName(
RegAddName(regPtr, actualName, Tk_WindowId(dispPtr->commTkwin));
RegClose(regPtr);
- riPtr->name = (char *) ckalloc((unsigned) (strlen(actualName) + 1));
+ riPtr->name = ckalloc(strlen(actualName) + 1);
strcpy(riPtr->name, actualName);
if (actualName != name) {
Tcl_DStringFree(&dString);
@@ -936,22 +934,22 @@ Tk_SendCmd(
* field is used). */
Tcl_Interp *interp, /* Current interpreter. */
int argc, /* Number of arguments. */
- CONST char **argv) /* Argument strings. */
+ const char **argv) /* Argument strings. */
{
TkWindow *winPtr;
Window commWindow;
PendingCommand pending;
register RegisteredInterp *riPtr;
- CONST char *destName;
+ const char *destName;
int result, c, async, i, firstArg;
size_t length;
- Tk_RestrictProc *prevRestrictProc;
+ Tk_RestrictProc *prevProc;
ClientData prevArg;
TkDisplay *dispPtr;
Tcl_Time timeout;
NameRegistry *regPtr;
Tcl_DString request;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
Tcl_Interp *localInterp; /* Used when the interpreter to send the
* command to is within the same process. */
@@ -986,15 +984,19 @@ Tk_SendCmd(
i++;
break;
} else {
- Tcl_AppendResult(interp, "bad option \"", argv[i],
- "\": must be -async, -displayof, or --", NULL);
+ 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_AppendResult(interp, "wrong # args: should be \"", argv[0],
- " ?options? interpName arg ?arg ...?\"", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf("wrong # args: should be "
+ "\"%s ?-option value ...? interpName arg ?arg ...?\"",
+ argv[0]));
+ Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", NULL);
return TCL_ERROR;
}
destName = argv[i];
@@ -1018,9 +1020,9 @@ Tk_SendCmd(
|| (strcmp(riPtr->name, destName) != 0)) {
continue;
}
- Tcl_Preserve((ClientData) riPtr);
+ Tcl_Preserve(riPtr);
localInterp = riPtr->interp;
- Tcl_Preserve((ClientData) localInterp);
+ Tcl_Preserve(localInterp);
if (firstArg == (argc-1)) {
result = Tcl_EvalEx(localInterp, argv[firstArg], -1, TCL_EVAL_GLOBAL);
} else {
@@ -1056,8 +1058,8 @@ Tk_SendCmd(
Tcl_SetObjResult(interp, Tcl_GetObjResult(localInterp));
Tcl_ResetResult(localInterp);
}
- Tcl_Release((ClientData) riPtr);
- Tcl_Release((ClientData) localInterp);
+ Tcl_Release(riPtr);
+ Tcl_Release(localInterp);
return result;
}
@@ -1069,7 +1071,10 @@ Tk_SendCmd(
commWindow = RegFindName(regPtr, destName);
RegClose(regPtr);
if (commWindow == None) {
- Tcl_AppendResult(interp, "no application named \"",destName,"\"",NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "no application named \"%s\"", destName));
+ Tcl_SetErrorCode(interp, "TK", "LOOKUP", "APPLICATION", destName,
+ NULL);
return TCL_ERROR;
}
@@ -1086,7 +1091,7 @@ Tk_SendCmd(
char buffer[TCL_INTEGER_SPACE * 2];
sprintf(buffer, "%x %d",
- (unsigned int) Tk_WindowId(dispPtr->commTkwin),
+ (unsigned) Tk_WindowId(dispPtr->commTkwin),
localData.sendSerial);
Tcl_DStringAppend(&request, "\0-r ", 4);
Tcl_DStringAppend(&request, buffer, -1);
@@ -1137,7 +1142,7 @@ Tk_SendCmd(
* other events in the application.
*/
- prevRestrictProc = Tk_RestrictEvents(SendRestrictProc, NULL, &prevArg);
+ prevProc = Tk_RestrictEvents(SendRestrictProc, NULL, &prevArg);
Tcl_GetTime(&timeout);
timeout.sec += 2;
while (!pending.gotResponse) {
@@ -1150,7 +1155,7 @@ Tk_SendCmd(
if (!ValidateName(pending.dispPtr, pending.target,
pending.commWindow, 0)) {
- char *msg;
+ const char *msg;
if (ValidateName(pending.dispPtr, pending.target,
pending.commWindow, 1)) {
@@ -1159,7 +1164,7 @@ Tk_SendCmd(
msg = "target application died";
}
pending.code = TCL_ERROR;
- pending.result = (char *) ckalloc((unsigned) (strlen(msg) + 1));
+ pending.result = ckalloc(strlen(msg) + 1);
strcpy(pending.result, msg);
pending.gotResponse = 1;
} else {
@@ -1168,7 +1173,7 @@ Tk_SendCmd(
}
}
}
- (void) Tk_RestrictEvents(prevRestrictProc, prevArg, &prevArg);
+ Tk_RestrictEvents(prevProc, prevArg, &prevArg);
/*
* Unregister the information about the pending command and return the
@@ -1192,12 +1197,11 @@ Tk_SendCmd(
ckfree(pending.errorInfo);
}
if (pending.errorCode != NULL) {
- Tcl_Obj *errorObjPtr = Tcl_NewStringObj(pending.errorCode, -1);
-
- Tcl_SetObjErrorCode(interp, errorObjPtr);
+ Tcl_SetObjErrorCode(interp, Tcl_NewStringObj(pending.errorCode, -1));
ckfree(pending.errorCode);
}
- Tcl_SetResult(interp, pending.result, TCL_DYNAMIC);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(pending.result, -1));
+ ckfree(pending.result);
return pending.code;
}
@@ -1229,6 +1233,7 @@ TkGetInterpNames(
{
TkWindow *winPtr = (TkWindow *) tkwin;
NameRegistry *regPtr;
+ Tcl_Obj *resultObj = Tcl_NewObj();
char *p;
/*
@@ -1240,9 +1245,9 @@ TkGetInterpNames(
for (p=regPtr->property ; p-regPtr->property<(int)regPtr->propLength ;) {
char *entry = p, *entryName;
Window commWindow;
- unsigned int id;
+ unsigned id;
- if (sscanf(p, "%x",(unsigned int *) &id) != 1) {
+ if (sscanf(p, "%x", (unsigned *) &id) != 1) {
commWindow = None;
} else {
commWindow = id;
@@ -1263,7 +1268,8 @@ TkGetInterpNames(
* The application still exists; add its name to the result.
*/
- Tcl_AppendElement(interp, entryName);
+ Tcl_ListObjAppendElement(NULL, resultObj,
+ Tcl_NewStringObj(entryName, -1));
} else {
int count;
@@ -1286,6 +1292,7 @@ TkGetInterpNames(
}
}
RegClose(regPtr);
+ Tcl_SetObjResult(interp, resultObj);
return TCL_OK;
}
@@ -1312,9 +1319,9 @@ TkSendCleanup(
{
if (dispPtr->commTkwin != NULL) {
Tk_DeleteEventHandler(dispPtr->commTkwin, PropertyChangeMask,
- SendEventProc, (ClientData) dispPtr);
+ SendEventProc, dispPtr);
Tk_DestroyWindow(dispPtr->commTkwin);
- Tcl_Release((ClientData) dispPtr->commTkwin);
+ Tcl_Release(dispPtr->commTkwin);
dispPtr->commTkwin = NULL;
}
}
@@ -1352,14 +1359,15 @@ SendInit(
dispPtr->commTkwin = (Tk_Window) TkAllocWindow(dispPtr,
DefaultScreen(dispPtr->display), NULL);
- Tcl_Preserve((ClientData) dispPtr->commTkwin);
- ((TkWindow *) dispPtr->commTkwin)->flags |=TK_TOP_HIERARCHY|TK_TOP_LEVEL|TK_HAS_WRAPPER|TK_WIN_MANAGED;
+ Tcl_Preserve(dispPtr->commTkwin);
+ ((TkWindow *) dispPtr->commTkwin)->flags |=
+ TK_TOP_HIERARCHY|TK_TOP_LEVEL|TK_HAS_WRAPPER|TK_WIN_MANAGED;
TkWmNewWindow((TkWindow *) dispPtr->commTkwin);
atts.override_redirect = True;
Tk_ChangeWindowAttributes(dispPtr->commTkwin,
CWOverrideRedirect, &atts);
Tk_CreateEventHandler(dispPtr->commTkwin, PropertyChangeMask,
- SendEventProc, (ClientData) dispPtr);
+ SendEventProc, dispPtr);
Tk_MakeWindowExist(dispPtr->commTkwin);
/*
@@ -1400,14 +1408,14 @@ SendEventProc(
ClientData clientData, /* Display information. */
XEvent *eventPtr) /* Information about event. */
{
- TkDisplay *dispPtr = (TkDisplay *) clientData;
+ TkDisplay *dispPtr = clientData;
char *propInfo, **propInfoPtr = &propInfo;
- register char *p;
+ const char *p;
int result, actualFormat;
unsigned long numItems, bytesAfter;
Atom actualType;
Tcl_Interp *remoteInterp; /* Interp in which to execute the command. */
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if ((eventPtr->xproperty.atom != dispPtr->commProperty)
@@ -1457,7 +1465,8 @@ SendEventProc(
if ((*p == 'c') && (p[1] == 0)) {
Window commWindow;
- char *interpName, *script, *serial, *end;
+ const char *interpName, *script, *serial;
+ char *end;
Tcl_DString reply;
RegisteredInterp *riPtr;
@@ -1546,7 +1555,7 @@ SendEventProc(
break;
}
}
- Tcl_Preserve((ClientData) riPtr);
+ Tcl_Preserve(riPtr);
/*
* We must protect the interpreter because the script may enter
@@ -1554,7 +1563,7 @@ SendEventProc(
*/
remoteInterp = riPtr->interp;
- Tcl_Preserve((ClientData) remoteInterp);
+ Tcl_Preserve(remoteInterp);
result = Tcl_EvalEx(remoteInterp, script, -1, TCL_EVAL_GLOBAL);
@@ -1566,10 +1575,10 @@ SendEventProc(
*/
if (commWindow != None) {
- Tcl_DStringAppend(&reply, Tcl_GetStringResult(remoteInterp),
+ Tcl_DStringAppend(&reply, Tcl_GetString(Tcl_GetObjResult(remoteInterp)),
-1);
if (result == TCL_ERROR) {
- CONST char *varValue;
+ const char *varValue;
varValue = Tcl_GetVar2(remoteInterp, "errorInfo",
NULL, TCL_GLOBAL_ONLY);
@@ -1585,8 +1594,8 @@ SendEventProc(
}
}
}
- Tcl_Release((ClientData) remoteInterp);
- Tcl_Release((ClientData) riPtr);
+ Tcl_Release(remoteInterp);
+ Tcl_Release(riPtr);
/*
* Return the result to the sender if a commWindow was specified
@@ -1612,7 +1621,7 @@ SendEventProc(
}
} else if ((*p == 'r') && (p[1] == 0)) {
int serial, code, gotSerial;
- char *errorInfo, *errorCode, *resultString;
+ const char *errorInfo, *errorCode, *resultString;
PendingCommand *pcPtr;
/*
@@ -1678,19 +1687,16 @@ SendEventProc(
}
pcPtr->code = code;
if (resultString != NULL) {
- pcPtr->result = (char *) ckalloc((unsigned)
- (strlen(resultString) + 1));
+ pcPtr->result = ckalloc(strlen(resultString) + 1);
strcpy(pcPtr->result, resultString);
}
if (code == TCL_ERROR) {
if (errorInfo != NULL) {
- pcPtr->errorInfo = (char *) ckalloc((unsigned)
- (strlen(errorInfo) + 1));
+ pcPtr->errorInfo = ckalloc(strlen(errorInfo) + 1);
strcpy(pcPtr->errorInfo, errorInfo);
}
if (errorCode != NULL) {
- pcPtr->errorCode = (char *) ckalloc((unsigned)
- (strlen(errorCode) + 1));
+ pcPtr->errorCode = ckalloc(strlen(errorCode) + 1);
strcpy(pcPtr->errorCode, errorCode);
}
}
@@ -1746,7 +1752,7 @@ AppendPropCarefully(
Tk_ErrorHandler handler;
handler = Tk_CreateErrorHandler(display, -1, -1, -1, AppendErrorProc,
- (ClientData) pendingPtr);
+ pendingPtr);
XChangeProperty(display, window, property, XA_STRING, 8,
PropModeAppend, (unsigned char *) value, length);
Tk_DeleteErrorHandler(handler);
@@ -1763,9 +1769,9 @@ AppendErrorProc(
ClientData clientData, /* Command to mark complete, or NULL. */
XErrorEvent *errorPtr) /* Information about error. */
{
- PendingCommand *pendingPtr = (PendingCommand *) clientData;
+ PendingCommand *pendingPtr = clientData;
register PendingCommand *pcPtr;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (pendingPtr == NULL) {
@@ -1779,8 +1785,7 @@ AppendErrorProc(
for (pcPtr = tsdPtr->pendingCommands; pcPtr != NULL;
pcPtr = pcPtr->nextPtr) {
if ((pcPtr == pendingPtr) && (pcPtr->result == NULL)) {
- pcPtr->result = (char *) ckalloc((unsigned)
- (strlen(pcPtr->target) + 50));
+ pcPtr->result = ckalloc(strlen(pcPtr->target) + 50);
sprintf(pcPtr->result, "no application named \"%s\"",
pcPtr->target);
pcPtr->code = TCL_ERROR;
@@ -1813,10 +1818,10 @@ DeleteProc(
ClientData clientData) /* Info about registration, passed as
* ClientData. */
{
- RegisteredInterp *riPtr = (RegisteredInterp *) clientData;
+ RegisteredInterp *riPtr = clientData;
register RegisteredInterp *riPtr2;
NameRegistry *regPtr;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
regPtr = RegOpen(riPtr->interp, riPtr->dispPtr, 1);
@@ -1834,10 +1839,10 @@ DeleteProc(
}
}
}
- ckfree((char *) riPtr->name);
+ ckfree(riPtr->name);
riPtr->interp = NULL;
UpdateCommWindow(riPtr->dispPtr);
- Tcl_EventuallyFree((ClientData) riPtr, TCL_DYNAMIC);
+ Tcl_EventuallyFree(riPtr, TCL_DYNAMIC);
}
/*
@@ -1905,7 +1910,7 @@ UpdateCommWindow(
{
Tcl_DString names;
RegisteredInterp *riPtr;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
Tcl_DStringInit(&names);
@@ -1944,9 +1949,9 @@ TkpTestsendCmd(
ClientData clientData, /* Main window for application. */
Tcl_Interp *interp, /* Current interpreter. */
int argc, /* Number of arguments. */
- CONST char **argv) /* Argument strings. */
+ const char **argv) /* Argument strings. */
{
- TkWindow *winPtr = (TkWindow *) clientData;
+ TkWindow *winPtr = clientData;
if (argc < 2) {
Tcl_AppendResult(interp, "wrong # args; must be \"", argv[0],
@@ -1992,7 +1997,7 @@ TkpTestsendCmd(
*p = '\n';
}
}
- Tcl_SetResult(interp, property, TCL_VOLATILE);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(property, -1));
}
if (property != NULL) {
XFree(property);
@@ -2016,10 +2021,7 @@ TkpTestsendCmd(
Tcl_DStringFree(&tmp);
}
} else if (strcmp(argv[1], "serial") == 0) {
- char buf[TCL_INTEGER_SPACE];
-
- sprintf(buf, "%d", localData.sendSerial+1);
- Tcl_SetResult(interp, buf, TCL_VOLATILE);
+ Tcl_SetObjResult(interp, Tcl_NewIntObj(localData.sendSerial+1));
} else {
Tcl_AppendResult(interp, "bad option \"", argv[1],
"\": must be bogus, prop, or serial", NULL);
diff --git a/unix/tkUnixWm.c b/unix/tkUnixWm.c
index d230b9f..8a7ec3c 100644
--- a/unix/tkUnixWm.c
+++ b/unix/tkUnixWm.c
@@ -28,7 +28,7 @@ typedef struct ProtocolHandler {
* same top-level window, or NULL for end of
* list. */
Tcl_Interp *interp; /* Interpreter in which to invoke command. */
- char command[4]; /* Tcl command to invoke when a client message
+ char command[1]; /* Tcl command to invoke when a client message
* for this protocol arrives. The actual size
* of the structure varies to accommodate the
* needs of the actual command. THIS MUST BE
@@ -36,16 +36,17 @@ typedef struct ProtocolHandler {
} ProtocolHandler;
#define HANDLER_SIZE(cmdLength) \
- ((unsigned) (sizeof(ProtocolHandler) - 3 + cmdLength))
+ ((unsigned) ((Tk_Offset(ProtocolHandler, command) + 1) + cmdLength))
/*
* Data for [wm attributes] command:
*/
+
typedef struct {
- double alpha; /* Transparency; 0.0=transparent, 1.0=opaque */
- int topmost; /* Flag: true=>stay-on-top */
- int zoomed; /* Flag: true=>maximized */
- int fullscreen; /* Flag: true=>fullscreen */
+ double alpha; /* Transparency; 0.0=transparent, 1.0=opaque */
+ int topmost; /* Flag: true=>stay-on-top */
+ int zoomed; /* Flag: true=>maximized */
+ int fullscreen; /* Flag: true=>fullscreen */
} WmAttributes;
typedef enum {
@@ -53,7 +54,7 @@ typedef enum {
WMATT_TYPE, _WMATT_LAST_ATTRIBUTE
} WmAttribute;
-static const char *WmAttributeNames[] = {
+static const char *const WmAttributeNames[] = {
"-alpha", "-topmost", "-zoomed", "-fullscreen",
"-type", NULL
};
@@ -205,7 +206,7 @@ typedef struct TkWmInfo {
ProtocolHandler *protPtr; /* First in list of protocol handlers for this
* window (NULL means none). */
int cmdArgc; /* Number of elements in cmdArgv below. */
- CONST char **cmdArgv; /* Array of strings to store in the WM_COMMAND
+ const char **cmdArgv; /* Array of strings to store in the WM_COMMAND
* property. NULL means nothing available. */
char *clientMachine; /* String to store in WM_CLIENT_MACHINE
* property, or NULL. */
@@ -277,6 +278,22 @@ typedef struct TkWmInfo {
#define WM_WITHDRAWN 0x4000
/*
+ * Wrapper for XGetWindowProperty and XChangeProperty to make them a *bit*
+ * less verbose.
+ */
+
+#define GetWindowProperty(wrapperPtr, atom, length, type, typePtr, formatPtr, numItemsPtr, bytesAfterPtr, itemsPtr) \
+ (XGetWindowProperty((wrapperPtr)->display, (wrapperPtr)->window, \
+ (atom), 0, (long) (length), False, (type), \
+ (typePtr), (formatPtr), (numItemsPtr), (bytesAfterPtr), \
+ (unsigned char **) (itemsPtr)) == Success)
+#define SetWindowProperty(wrapperPtr, atomName, type, width, data, length) \
+ XChangeProperty((wrapperPtr)->display, (wrapperPtr)->window, \
+ Tk_InternAtom((Tk_Window) wrapperPtr, (atomName)), \
+ (type), (width), PropModeReplace, (unsigned char *) (data), \
+ (int) (length))
+
+/*
* This module keeps a list of all top-level windows, primarily to simplify
* the job of Tk_CoordsToWindow. The list is called firstWmPtr and is stored
* in the TkDisplay structure.
@@ -289,17 +306,18 @@ typedef struct TkWmInfo {
static void TopLevelReqProc(ClientData dummy, Tk_Window tkwin);
static void RemapWindows(TkWindow *winPtr, TkWindow *parentPtr);
-static void MenubarReqProc(ClientData clientData, Tk_Window tkwin);
+static void MenubarReqProc(ClientData clientData,
+ Tk_Window tkwin);
static const Tk_GeomMgr wmMgrType = {
- "wm", /* name */
- TopLevelReqProc, /* requestProc */
- NULL, /* lostSlaveProc */
+ "wm", /* name */
+ TopLevelReqProc, /* requestProc */
+ NULL, /* lostSlaveProc */
};
static const Tk_GeomMgr menubarMgrType = {
- "menubar", /* name */
- MenubarReqProc, /* requestProc */
- NULL, /* lostSlaveProc */
+ "menubar", /* name */
+ MenubarReqProc, /* requestProc */
+ NULL, /* lostSlaveProc */
};
/*
@@ -328,7 +346,7 @@ static void GetMaxSize(WmInfo *wmPtr, int *maxWidthPtr,
int *maxHeightPtr);
static void MenubarDestroyProc(ClientData clientData,
XEvent *eventPtr);
-static int ParseGeometry(Tcl_Interp *interp, char *string,
+static int ParseGeometry(Tcl_Interp *interp, const char *string,
TkWindow *winPtr);
static void ReparentEvent(WmInfo *wmPtr, XReparentEvent *eventPtr);
static void PropertyEvent(WmInfo *wmPtr, XPropertyEvent *eventPtr);
@@ -355,108 +373,107 @@ static void WaitForConfigureNotify(TkWindow *winPtr,
static int WaitForEvent(Display *display,
WmInfo *wmInfoPtr, int type, XEvent *eventPtr);
static void WaitForMapNotify(TkWindow *winPtr, int mapped);
-static Tk_RestrictAction
- WaitRestrictProc(ClientData clientData,
- XEvent *eventPtr);
+static Tk_RestrictProc WaitRestrictProc;
static void WrapperEventProc(ClientData clientData,
XEvent *eventPtr);
-static void WmWaitMapProc(ClientData clientData, XEvent *eventPtr);
+static void WmWaitMapProc(ClientData clientData,
+ XEvent *eventPtr);
static int WmAspectCmd(Tk_Window tkwin, TkWindow *winPtr,
Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]);
+ Tcl_Obj *const objv[]);
static int WmAttributesCmd(Tk_Window tkwin, TkWindow *winPtr,
Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]);
+ Tcl_Obj *const objv[]);
static int WmClientCmd(Tk_Window tkwin, TkWindow *winPtr,
Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]);
-static int WmColormapwindowsCmd(Tk_Window tkwin, TkWindow *winPtr,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]);
+ Tcl_Obj *const objv[]);
+static int WmColormapwindowsCmd(Tk_Window tkwin,
+ TkWindow *winPtr, Tcl_Interp *interp, int objc,
+ Tcl_Obj *const objv[]);
static int WmCommandCmd(Tk_Window tkwin, TkWindow *winPtr,
Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]);
+ Tcl_Obj *const objv[]);
static int WmDeiconifyCmd(Tk_Window tkwin, TkWindow *winPtr,
Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]);
+ Tcl_Obj *const objv[]);
static int WmFocusmodelCmd(Tk_Window tkwin, TkWindow *winPtr,
Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]);
+ Tcl_Obj *const objv[]);
static int WmForgetCmd(Tk_Window tkwin, TkWindow *winPtr,
Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]);
+ Tcl_Obj *const objv[]);
static int WmFrameCmd(Tk_Window tkwin, TkWindow *winPtr,
Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]);
+ Tcl_Obj *const objv[]);
static int WmGeometryCmd(Tk_Window tkwin, TkWindow *winPtr,
Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]);
+ Tcl_Obj *const objv[]);
static int WmGridCmd(Tk_Window tkwin, TkWindow *winPtr,
Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]);
+ Tcl_Obj *const objv[]);
static int WmGroupCmd(Tk_Window tkwin, TkWindow *winPtr,
Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]);
+ Tcl_Obj *const objv[]);
static int WmIconbitmapCmd(Tk_Window tkwin, TkWindow *winPtr,
Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]);
+ Tcl_Obj *const objv[]);
static int WmIconifyCmd(Tk_Window tkwin, TkWindow *winPtr,
Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]);
+ Tcl_Obj *const objv[]);
static int WmIconmaskCmd(Tk_Window tkwin, TkWindow *winPtr,
Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]);
+ Tcl_Obj *const objv[]);
static int WmIconnameCmd(Tk_Window tkwin, TkWindow *winPtr,
Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]);
+ Tcl_Obj *const objv[]);
static int WmIconphotoCmd(Tk_Window tkwin, TkWindow *winPtr,
Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]);
+ Tcl_Obj *const objv[]);
static int WmIconpositionCmd(Tk_Window tkwin, TkWindow *winPtr,
Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]);
+ Tcl_Obj *const objv[]);
static int WmIconwindowCmd(Tk_Window tkwin, TkWindow *winPtr,
Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]);
+ Tcl_Obj *const objv[]);
static int WmManageCmd(Tk_Window tkwin, TkWindow *winPtr,
Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]);
+ Tcl_Obj *const objv[]);
static int WmMaxsizeCmd(Tk_Window tkwin, TkWindow *winPtr,
Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]);
+ Tcl_Obj *const objv[]);
static int WmMinsizeCmd(Tk_Window tkwin, TkWindow *winPtr,
Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]);
-static int WmOverrideredirectCmd(Tk_Window tkwin,TkWindow *winPtr,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]);
+ Tcl_Obj *const objv[]);
+static int WmOverrideredirectCmd(Tk_Window tkwin,
+ TkWindow *winPtr, Tcl_Interp *interp, int objc,
+ Tcl_Obj *const objv[]);
static int WmPositionfromCmd(Tk_Window tkwin, TkWindow *winPtr,
Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]);
+ Tcl_Obj *const objv[]);
static int WmProtocolCmd(Tk_Window tkwin, TkWindow *winPtr,
Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]);
+ Tcl_Obj *const objv[]);
static int WmResizableCmd(Tk_Window tkwin, TkWindow *winPtr,
Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]);
+ Tcl_Obj *const objv[]);
static int WmSizefromCmd(Tk_Window tkwin, TkWindow *winPtr,
Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]);
+ Tcl_Obj *const objv[]);
static int WmStackorderCmd(Tk_Window tkwin, TkWindow *winPtr,
Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]);
+ Tcl_Obj *const objv[]);
static int WmStateCmd(Tk_Window tkwin, TkWindow *winPtr,
Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]);
+ Tcl_Obj *const objv[]);
static int WmTitleCmd(Tk_Window tkwin, TkWindow *winPtr,
Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]);
+ Tcl_Obj *const objv[]);
static int WmTransientCmd(Tk_Window tkwin, TkWindow *winPtr,
Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]);
+ Tcl_Obj *const objv[]);
static int WmWithdrawCmd(Tk_Window tkwin, TkWindow *winPtr,
Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]);
+ Tcl_Obj *const objv[]);
static void WmUpdateGeom(WmInfo *wmPtr, TkWindow *winPtr);
/*
@@ -495,7 +512,7 @@ void TkWmCleanup(
ckfree(wmPtr->iconName);
}
if (wmPtr->iconDataPtr != NULL) {
- ckfree((char *) wmPtr->iconDataPtr);
+ ckfree(wmPtr->iconDataPtr);
}
if (wmPtr->leaderName != NULL) {
ckfree(wmPtr->leaderName);
@@ -507,22 +524,21 @@ void TkWmCleanup(
Tk_DestroyWindow((Tk_Window) wmPtr->wrapperPtr);
}
while (wmPtr->protPtr != NULL) {
- ProtocolHandler *protPtr;
+ ProtocolHandler *protPtr = wmPtr->protPtr;
- protPtr = wmPtr->protPtr;
wmPtr->protPtr = protPtr->nextPtr;
- Tcl_EventuallyFree((ClientData) protPtr, TCL_DYNAMIC);
+ Tcl_EventuallyFree(protPtr, TCL_DYNAMIC);
}
if (wmPtr->cmdArgv != NULL) {
- ckfree((char *) wmPtr->cmdArgv);
+ ckfree(wmPtr->cmdArgv);
}
if (wmPtr->clientMachine != NULL) {
- ckfree((char *) wmPtr->clientMachine);
+ ckfree(wmPtr->clientMachine);
}
- ckfree((char *) wmPtr);
+ ckfree(wmPtr);
}
if (dispPtr->iconDataPtr != NULL) {
- ckfree((char *) dispPtr->iconDataPtr);
+ ckfree(dispPtr->iconDataPtr);
dispPtr->iconDataPtr = NULL;
}
}
@@ -551,7 +567,7 @@ TkWmNewWindow(
register WmInfo *wmPtr;
TkDisplay *dispPtr = winPtr->dispPtr;
- wmPtr = (WmInfo *) ckalloc(sizeof(WmInfo));
+ wmPtr = ckalloc(sizeof(WmInfo));
memset(wmPtr, 0, sizeof(WmInfo));
wmPtr->winPtr = winPtr;
wmPtr->reparent = None;
@@ -569,6 +585,7 @@ TkWmNewWindow(
/*
* Initialize attributes.
*/
+
wmPtr->attributes.alpha = 1.0;
wmPtr->attributes.topmost = 0;
wmPtr->attributes.zoomed = 0;
@@ -611,7 +628,7 @@ TkWmNewWindow(
* window manager.
*/
- Tk_ManageGeometry((Tk_Window) winPtr, &wmMgrType, (ClientData) 0);
+ Tk_ManageGeometry((Tk_Window) winPtr, &wmMgrType, NULL);
}
/*
@@ -697,10 +714,9 @@ TkWmMapWindow(
if (XStringListToTextProperty(&(Tcl_DStringValue(&ds)), 1,
&textProp) != 0) {
unsigned long pid = (unsigned long) getpid();
- Atom atom;
- XSetWMClientMachine(winPtr->display, wmPtr->wrapperPtr->window,
- &textProp);
+ XSetWMClientMachine(winPtr->display,
+ wmPtr->wrapperPtr->window, &textProp);
XFree((char *) textProp.value);
/*
@@ -710,10 +726,8 @@ TkWmMapWindow(
* _NET_WM_PID requires that to be set too.
*/
- atom = Tk_InternAtom((Tk_Window) winPtr, "_NET_WM_PID");
- XChangeProperty(winPtr->display, wmPtr->wrapperPtr->window,
- atom, XA_CARDINAL, 32, PropModeReplace,
- (unsigned char *) &pid, 1);
+ SetWindowProperty(wmPtr->wrapperPtr, "_NET_WM_PID",
+ XA_CARDINAL, 32, &pid, 1);
}
Tcl_DStringFree(&ds);
}
@@ -728,16 +742,16 @@ TkWmMapWindow(
*/
if (wmPtr->flags & WM_UPDATE_PENDING) {
- Tcl_CancelIdleCall(UpdateGeometryInfo, (ClientData) winPtr);
+ Tcl_CancelIdleCall(UpdateGeometryInfo, winPtr);
}
- UpdateGeometryInfo((ClientData) winPtr);
+ UpdateGeometryInfo(winPtr);
return;
}
wmPtr->flags |= WM_ABOUT_TO_MAP;
if (wmPtr->flags & WM_UPDATE_PENDING) {
- Tcl_CancelIdleCall(UpdateGeometryInfo, (ClientData) winPtr);
+ Tcl_CancelIdleCall(UpdateGeometryInfo, winPtr);
}
- UpdateGeometryInfo((ClientData) winPtr);
+ UpdateGeometryInfo(winPtr);
wmPtr->flags &= ~WM_ABOUT_TO_MAP;
/*
@@ -840,7 +854,7 @@ TkWmDeadWindow(
ckfree(wmPtr->iconName);
}
if (wmPtr->iconDataPtr != NULL) {
- ckfree((char *) wmPtr->iconDataPtr);
+ ckfree(wmPtr->iconDataPtr);
}
if (wmPtr->hints.flags & IconPixmapHint) {
Tk_FreeBitmap(winPtr->display, wmPtr->hints.icon_pixmap);
@@ -879,20 +893,19 @@ TkWmDeadWindow(
Tk_DestroyWindow((Tk_Window) wmPtr->wrapperPtr);
}
while (wmPtr->protPtr != NULL) {
- ProtocolHandler *protPtr;
+ ProtocolHandler *protPtr = wmPtr->protPtr;
- protPtr = wmPtr->protPtr;
wmPtr->protPtr = protPtr->nextPtr;
- Tcl_EventuallyFree((ClientData) protPtr, TCL_DYNAMIC);
+ Tcl_EventuallyFree(protPtr, TCL_DYNAMIC);
}
if (wmPtr->cmdArgv != NULL) {
- ckfree((char *) wmPtr->cmdArgv);
+ ckfree(wmPtr->cmdArgv);
}
if (wmPtr->clientMachine != NULL) {
- ckfree((char *) wmPtr->clientMachine);
+ ckfree(wmPtr->clientMachine);
}
if (wmPtr->flags & WM_UPDATE_PENDING) {
- Tcl_CancelIdleCall(UpdateGeometryInfo, (ClientData) winPtr);
+ Tcl_CancelIdleCall(UpdateGeometryInfo, winPtr);
}
/*
@@ -904,8 +917,7 @@ TkWmDeadWindow(
if (wmPtr2->masterPtr == winPtr) {
wmPtr->numTransients--;
Tk_DeleteEventHandler((Tk_Window) wmPtr2->masterPtr,
- StructureNotifyMask,
- WmWaitMapProc, (ClientData) wmPtr2->winPtr);
+ StructureNotifyMask, WmWaitMapProc, wmPtr2->winPtr);
wmPtr2->masterPtr = NULL;
if (!(wmPtr2->flags & WM_NEVER_MAPPED)) {
XDeleteProperty(winPtr->display, wmPtr2->wrapperPtr->window,
@@ -932,10 +944,10 @@ TkWmDeadWindow(
wmPtr2->numTransients--;
}
Tk_DeleteEventHandler((Tk_Window) wmPtr->masterPtr,
- StructureNotifyMask, WmWaitMapProc, (ClientData) winPtr);
+ StructureNotifyMask, WmWaitMapProc, winPtr);
wmPtr->masterPtr = NULL;
}
- ckfree((char *) wmPtr);
+ ckfree(wmPtr);
winPtr->wmInfoPtr = NULL;
}
@@ -999,32 +1011,30 @@ Tk_WmObjCmd(
ClientData clientData, /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
- Tcl_Obj *CONST objv[]) /* Argument objects. */
+ Tcl_Obj *const objv[]) /* Argument objects. */
{
- Tk_Window tkwin = (Tk_Window) clientData;
- static CONST char *optionStrings[] = {
+ Tk_Window tkwin = clientData;
+ static const char *const optionStrings[] = {
"aspect", "attributes", "client", "colormapwindows",
- "command", "deiconify", "focusmodel", "forget", "frame",
- "geometry", "grid", "group", "iconbitmap",
- "iconify", "iconmask", "iconname",
- "iconphoto", "iconposition",
- "iconwindow", "manage", "maxsize", "minsize", "overrideredirect",
- "positionfrom", "protocol", "resizable", "sizefrom",
- "stackorder", "state", "title", "transient",
- "withdraw", NULL };
+ "command", "deiconify", "focusmodel", "forget",
+ "frame", "geometry", "grid", "group", "iconbitmap",
+ "iconify", "iconmask", "iconname", "iconphoto",
+ "iconposition", "iconwindow", "manage", "maxsize",
+ "minsize", "overrideredirect", "positionfrom",
+ "protocol", "resizable", "sizefrom", "stackorder",
+ "state", "title", "transient", "withdraw", NULL };
enum options {
WMOPT_ASPECT, WMOPT_ATTRIBUTES, WMOPT_CLIENT, WMOPT_COLORMAPWINDOWS,
- WMOPT_COMMAND, WMOPT_DEICONIFY, WMOPT_FOCUSMODEL, WMOPT_FORGET, WMOPT_FRAME,
- WMOPT_GEOMETRY, WMOPT_GRID, WMOPT_GROUP, WMOPT_ICONBITMAP,
- WMOPT_ICONIFY, WMOPT_ICONMASK, WMOPT_ICONNAME,
- WMOPT_ICONPHOTO, WMOPT_ICONPOSITION,
- WMOPT_ICONWINDOW, WMOPT_MANAGE, WMOPT_MAXSIZE, WMOPT_MINSIZE, WMOPT_OVERRIDEREDIRECT,
- WMOPT_POSITIONFROM, WMOPT_PROTOCOL, WMOPT_RESIZABLE, WMOPT_SIZEFROM,
- WMOPT_STACKORDER, WMOPT_STATE, WMOPT_TITLE, WMOPT_TRANSIENT,
- WMOPT_WITHDRAW };
- int index;
- int length;
- char *argv1;
+ WMOPT_COMMAND, WMOPT_DEICONIFY, WMOPT_FOCUSMODEL, WMOPT_FORGET,
+ WMOPT_FRAME, WMOPT_GEOMETRY, WMOPT_GRID, WMOPT_GROUP,
+ WMOPT_ICONBITMAP,
+ WMOPT_ICONIFY, WMOPT_ICONMASK, WMOPT_ICONNAME, WMOPT_ICONPHOTO,
+ WMOPT_ICONPOSITION, WMOPT_ICONWINDOW, WMOPT_MANAGE, WMOPT_MAXSIZE,
+ WMOPT_MINSIZE, WMOPT_OVERRIDEREDIRECT, WMOPT_POSITIONFROM,
+ WMOPT_PROTOCOL, WMOPT_RESIZABLE, WMOPT_SIZEFROM, WMOPT_STACKORDER,
+ WMOPT_STATE, WMOPT_TITLE, WMOPT_TRANSIENT, WMOPT_WITHDRAW };
+ int index, length;
+ const char *argv1;
TkWindow *winPtr;
Tk_Window targetWin;
TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
@@ -1039,14 +1049,14 @@ Tk_WmObjCmd(
if ((argv1[0] == 't') && (strncmp(argv1, "tracing", (size_t) length) == 0)
&& (length >= 3)) {
int wmTracing;
+
if ((objc != 2) && (objc != 3)) {
Tcl_WrongNumArgs(interp, 2, objv, "?boolean?");
return TCL_ERROR;
}
if (objc == 2) {
- Tcl_SetResult(interp,
- ((dispPtr->flags & TK_DISPLAY_WM_TRACING) ? "on" : "off"),
- TCL_STATIC);
+ Tcl_SetObjResult(interp, Tcl_NewBooleanObj(
+ dispPtr->flags & TK_DISPLAY_WM_TRACING));
return TCL_OK;
}
if (Tcl_GetBooleanFromObj(interp, objv[2], &wmTracing) != TCL_OK) {
@@ -1060,8 +1070,8 @@ Tk_WmObjCmd(
return TCL_OK;
}
- if (Tcl_GetIndexFromObj(interp, objv[1], optionStrings, "option", 0,
- &index) != TCL_OK) {
+ if (Tcl_GetIndexFromObjStruct(interp, objv[1], optionStrings,
+ sizeof(char *), "option", 0, &index) != TCL_OK) {
return TCL_ERROR;
}
@@ -1075,8 +1085,10 @@ Tk_WmObjCmd(
winPtr = (TkWindow *) targetWin;
if (!Tk_IsTopLevel(winPtr) &&
(index != WMOPT_MANAGE) && (index != WMOPT_FORGET)) {
- Tcl_AppendResult(interp, "window \"", winPtr->pathName,
- "\" isn't a top-level window", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "window \"%s\" isn't a top-level window", winPtr->pathName));
+ Tcl_SetErrorCode(interp, "TK", "LOOKUP", "TOPLEVEL", winPtr->pathName,
+ NULL);
return TCL_ERROR;
}
@@ -1174,7 +1186,7 @@ WmAspectCmd(
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
- Tcl_Obj *CONST objv[]) /* Argument objects. */
+ Tcl_Obj *const objv[]) /* Argument objects. */
{
register WmInfo *wmPtr = winPtr->wmInfoPtr;
int numer1, denom1, numer2, denom2;
@@ -1186,12 +1198,13 @@ WmAspectCmd(
}
if (objc == 3) {
if (wmPtr->sizeHintsFlags & PAspect) {
- char buf[TCL_INTEGER_SPACE * 4];
+ Tcl_Obj *results[4];
- sprintf(buf, "%d %d %d %d", wmPtr->minAspect.x,
- wmPtr->minAspect.y, wmPtr->maxAspect.x,
- wmPtr->maxAspect.y);
- Tcl_SetResult(interp, buf, TCL_VOLATILE);
+ results[0] = Tcl_NewIntObj(wmPtr->minAspect.x);
+ results[1] = Tcl_NewIntObj(wmPtr->minAspect.y);
+ results[2] = Tcl_NewIntObj(wmPtr->maxAspect.x);
+ results[3] = Tcl_NewIntObj(wmPtr->maxAspect.y);
+ Tcl_SetObjResult(interp, Tcl_NewListObj(4, results));
}
return TCL_OK;
}
@@ -1206,8 +1219,9 @@ WmAspectCmd(
}
if ((numer1 <= 0) || (denom1 <= 0) || (numer2 <= 0) ||
(denom2 <= 0)) {
- Tcl_SetResult(interp, "aspect number can't be <= 0",
- TCL_STATIC);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "aspect number can't be <= 0", -1));
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "ASPECT", NULL);
return TCL_ERROR;
}
wmPtr->minAspect.x = numer1;
@@ -1245,6 +1259,7 @@ WmSetAttribute(
Tcl_Obj *value) /* New value */
{
WmInfo *wmPtr = winPtr->wmInfoPtr;
+
switch (attribute) {
case WMATT_ALPHA: {
unsigned long opacity; /* 0=transparent, 0xFFFFFFFF=opaque */
@@ -1265,29 +1280,26 @@ WmSetAttribute(
}
opacity = 0xFFFFFFFFul * wmPtr->reqState.alpha;
- XChangeProperty(winPtr->display, wmPtr->wrapperPtr->window,
- Tk_InternAtom((Tk_Window) winPtr, "_NET_WM_WINDOW_OPACITY"),
- XA_CARDINAL, 32, PropModeReplace,
- (unsigned char *)&opacity, 1L);
+ SetWindowProperty(wmPtr->wrapperPtr, "_NET_WM_WINDOW_OPACITY",
+ XA_CARDINAL, 32, &opacity, 1L);
wmPtr->attributes.alpha = wmPtr->reqState.alpha;
break;
}
case WMATT_TOPMOST:
- if (TCL_OK != Tcl_GetBooleanFromObj(interp, value,
- &wmPtr->reqState.topmost)) {
+ if (Tcl_GetBooleanFromObj(interp, value,
+ &wmPtr->reqState.topmost) != TCL_OK) {
return TCL_ERROR;
}
- SetNetWmState(winPtr, "_NET_WM_STATE_ABOVE",
- wmPtr->reqState.topmost);
+ SetNetWmState(winPtr, "_NET_WM_STATE_ABOVE", wmPtr->reqState.topmost);
break;
case WMATT_TYPE:
if (TCL_OK != SetNetWmType(winPtr, value))
return TCL_ERROR;
break;
case WMATT_ZOOMED:
- if (TCL_OK != Tcl_GetBooleanFromObj(interp, value,
- &wmPtr->reqState.zoomed)) {
+ if (Tcl_GetBooleanFromObj(interp, value,
+ &wmPtr->reqState.zoomed) != TCL_OK) {
return TCL_ERROR;
}
SetNetWmState(winPtr, "_NET_WM_STATE_MAXIMIZED_VERT",
@@ -1296,8 +1308,8 @@ WmSetAttribute(
wmPtr->reqState.zoomed);
break;
case WMATT_FULLSCREEN:
- if (TCL_OK != Tcl_GetBooleanFromObj(interp, value,
- &wmPtr->reqState.fullscreen)) {
+ if (Tcl_GetBooleanFromObj(interp, value,
+ &wmPtr->reqState.fullscreen) != TCL_OK) {
return TCL_ERROR;
}
SetNetWmState(winPtr, "_NET_WM_STATE_FULLSCREEN",
@@ -1377,7 +1389,7 @@ WmAttributesCmd(
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
- Tcl_Obj *CONST objv[]) /* Argument objects. */
+ Tcl_Obj *const objv[]) /* Argument objects. */
{
int attribute = 0;
@@ -1393,8 +1405,8 @@ WmAttributesCmd(
Tcl_SetObjResult(interp, result);
return TCL_OK;
} else if (objc == 4) { /* wm attributes $win -attribute */
- if (Tcl_GetIndexFromObj(interp, objv[3], WmAttributeNames,
- "attribute", 0, &attribute) != TCL_OK) {
+ if (Tcl_GetIndexFromObjStruct(interp, objv[3], WmAttributeNames,
+ sizeof(char *), "attribute", 0, &attribute) != TCL_OK) {
return TCL_ERROR;
}
Tcl_SetObjResult(interp, WmGetAttribute(winPtr, attribute));
@@ -1403,8 +1415,8 @@ WmAttributesCmd(
int i;
for (i = 3; i < objc; i += 2) {
- if (Tcl_GetIndexFromObj(interp, objv[i], WmAttributeNames,
- "attribute", 0, &attribute) != TCL_OK) {
+ if (Tcl_GetIndexFromObjStruct(interp, objv[i], WmAttributeNames,
+ sizeof(char *), "attribute", 0, &attribute) != TCL_OK) {
return TCL_ERROR;
}
if (WmSetAttribute(winPtr,interp,attribute,objv[i+1]) != TCL_OK) {
@@ -1441,10 +1453,10 @@ WmClientCmd(
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
- Tcl_Obj *CONST objv[]) /* Argument objects. */
+ Tcl_Obj *const objv[]) /* Argument objects. */
{
register WmInfo *wmPtr = winPtr->wmInfoPtr;
- char *argv3;
+ const char *argv3;
int length;
if ((objc != 3) && (objc != 4)) {
@@ -1453,14 +1465,15 @@ WmClientCmd(
}
if (objc == 3) {
if (wmPtr->clientMachine != NULL) {
- Tcl_SetResult(interp, wmPtr->clientMachine, TCL_STATIC);
+ Tcl_SetObjResult(interp,
+ Tcl_NewStringObj(wmPtr->clientMachine, -1));
}
return TCL_OK;
}
argv3 = Tcl_GetStringFromObj(objv[3], &length);
if (argv3[0] == 0) {
if (wmPtr->clientMachine != NULL) {
- ckfree((char *) wmPtr->clientMachine);
+ ckfree(wmPtr->clientMachine);
wmPtr->clientMachine = NULL;
if (!(wmPtr->flags & WM_NEVER_MAPPED)) {
XDeleteProperty(winPtr->display, wmPtr->wrapperPtr->window,
@@ -1471,9 +1484,9 @@ WmClientCmd(
return TCL_OK;
}
if (wmPtr->clientMachine != NULL) {
- ckfree((char *) wmPtr->clientMachine);
+ ckfree(wmPtr->clientMachine);
}
- wmPtr->clientMachine = ckalloc((unsigned) length + 1);
+ wmPtr->clientMachine = ckalloc(length + 1);
strcpy(wmPtr->clientMachine, argv3);
if (!(wmPtr->flags & WM_NEVER_MAPPED)) {
XTextProperty textProp;
@@ -1495,10 +1508,8 @@ WmClientCmd(
* be set too.
*/
- XChangeProperty(winPtr->display, wmPtr->wrapperPtr->window,
- Tk_InternAtom((Tk_Window) winPtr, "_NET_WM_PID"),
- XA_CARDINAL,32, PropModeReplace, (unsigned char *) &pid,
- 1);
+ SetWindowProperty(wmPtr->wrapperPtr, "_NET_WM_PID", XA_CARDINAL,
+ 32, &pid, 1);
}
Tcl_DStringFree(&ds);
}
@@ -1528,14 +1539,13 @@ WmColormapwindowsCmd(
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
- Tcl_Obj *CONST objv[]) /* Argument objects. */
+ Tcl_Obj *const objv[]) /* Argument objects. */
{
register WmInfo *wmPtr = winPtr->wmInfoPtr;
Window *cmapList;
TkWindow *winPtr2;
int count, i, windowObjc, gotToplevel;
- Tcl_Obj **windowObjv;
- char buffer[20];
+ Tcl_Obj **windowObjv, *resultObj;
if ((objc != 3) && (objc != 4)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?windowList?");
@@ -1550,36 +1560,38 @@ WmColormapwindowsCmd(
wmPtr->wrapperPtr->window, &cmapList, &count) == 0) {
return TCL_OK;
}
+ resultObj = Tcl_NewObj();
for (i = 0; i < count; i++) {
if ((i == (count-1))
&& (wmPtr->flags & WM_ADDED_TOPLEVEL_COLORMAP)) {
break;
}
- winPtr2 = (TkWindow *) Tk_IdToWindow(winPtr->display,
- cmapList[i]);
+ winPtr2 = (TkWindow *)
+ Tk_IdToWindow(winPtr->display, cmapList[i]);
if (winPtr2 == NULL) {
- sprintf(buffer, "0x%lx", cmapList[i]);
- Tcl_AppendElement(interp, buffer);
+ Tcl_ListObjAppendElement(NULL, resultObj,
+ Tcl_ObjPrintf("0x%lx", cmapList[i]));
} else {
- Tcl_AppendElement(interp, winPtr2->pathName);
+ Tcl_ListObjAppendElement(NULL, resultObj,
+ Tcl_NewStringObj(winPtr2->pathName, -1));
}
}
XFree((char *) cmapList);
+ Tcl_SetObjResult(interp, resultObj);
return TCL_OK;
}
if (Tcl_ListObjGetElements(interp, objv[3], &windowObjc, &windowObjv)
!= TCL_OK) {
return TCL_ERROR;
}
- cmapList = (Window *) ckalloc((unsigned)
- (windowObjc+1) * sizeof(Window));
+ cmapList = ckalloc((windowObjc+1) * sizeof(Window));
gotToplevel = 0;
for (i = 0; i < windowObjc; i++) {
Tk_Window mapWin;
if (TkGetWindowFromObj(interp, tkwin, windowObjv[i],
&mapWin) != TCL_OK) {
- ckfree((char *) cmapList);
+ ckfree(cmapList);
return TCL_ERROR;
}
winPtr2 = (TkWindow *) mapWin;
@@ -1601,7 +1613,7 @@ WmColormapwindowsCmd(
wmPtr->flags |= WM_COLORMAPS_EXPLICIT;
XSetWMColormapWindows(winPtr->display, wmPtr->wrapperPtr->window,
cmapList, windowObjc);
- ckfree((char *) cmapList);
+ ckfree(cmapList);
return TCL_OK;
}
@@ -1628,12 +1640,12 @@ WmCommandCmd(
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
- Tcl_Obj *CONST objv[]) /* Argument objects. */
+ Tcl_Obj *const objv[]) /* Argument objects. */
{
register WmInfo *wmPtr = winPtr->wmInfoPtr;
- char *argv3;
+ const char *argv3;
int cmdArgc;
- CONST char **cmdArgv;
+ const char **cmdArgv;
if ((objc != 3) && (objc != 4)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?value?");
@@ -1641,16 +1653,17 @@ WmCommandCmd(
}
if (objc == 3) {
if (wmPtr->cmdArgv != NULL) {
- Tcl_SetResult(interp,
- Tcl_Merge(wmPtr->cmdArgc, wmPtr->cmdArgv),
- TCL_DYNAMIC);
+ char *arg = Tcl_Merge(wmPtr->cmdArgc, wmPtr->cmdArgv);
+
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(arg, -1));
+ ckfree(arg);
}
return TCL_OK;
}
argv3 = Tcl_GetString(objv[3]);
if (argv3[0] == 0) {
if (wmPtr->cmdArgv != NULL) {
- ckfree((char *) wmPtr->cmdArgv);
+ ckfree(wmPtr->cmdArgv);
wmPtr->cmdArgv = NULL;
if (!(wmPtr->flags & WM_NEVER_MAPPED)) {
XDeleteProperty(winPtr->display, wmPtr->wrapperPtr->window,
@@ -1663,7 +1676,7 @@ WmCommandCmd(
return TCL_ERROR;
}
if (wmPtr->cmdArgv != NULL) {
- ckfree((char *) wmPtr->cmdArgv);
+ ckfree(wmPtr->cmdArgv);
}
wmPtr->cmdArgc = cmdArgc;
wmPtr->cmdArgv = cmdArgv;
@@ -1696,7 +1709,7 @@ WmDeiconifyCmd(
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
- Tcl_Obj *CONST objv[]) /* Argument objects. */
+ Tcl_Obj *const objv[]) /* Argument objects. */
{
register WmInfo *wmPtr = winPtr->wmInfoPtr;
@@ -1705,13 +1718,17 @@ WmDeiconifyCmd(
return TCL_ERROR;
}
if (wmPtr->iconFor != NULL) {
- Tcl_AppendResult(interp, "can't deiconify ", Tcl_GetString(objv[2]),
- ": it is an icon for ", Tk_PathName(wmPtr->iconFor), NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't deiconify %s: it is an icon for %s",
+ Tcl_GetString(objv[2]), Tk_PathName(wmPtr->iconFor)));
+ Tcl_SetErrorCode(interp, "TK", "WM", "DEICONIFY", "ICON", NULL);
return TCL_ERROR;
}
if (winPtr->flags & TK_EMBEDDED) {
- Tcl_AppendResult(interp, "can't deiconify ", winPtr->pathName,
- ": it is an embedded window", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't deiconify %s: it is an embedded window",
+ winPtr->pathName));
+ Tcl_SetErrorCode(interp, "TK", "WM", "DEICONIFY", "EMBEDDED", NULL);
return TCL_ERROR;
}
wmPtr->flags &= ~WM_WITHDRAWN;
@@ -1742,10 +1759,10 @@ WmFocusmodelCmd(
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
- Tcl_Obj *CONST objv[]) /* Argument objects. */
+ Tcl_Obj *const objv[]) /* Argument objects. */
{
register WmInfo *wmPtr = winPtr->wmInfoPtr;
- static CONST char *optionStrings[] = {
+ static const char *const optionStrings[] = {
"active", "passive", NULL };
enum options {
OPT_ACTIVE, OPT_PASSIVE };
@@ -1756,13 +1773,13 @@ WmFocusmodelCmd(
return TCL_ERROR;
}
if (objc == 3) {
- Tcl_SetResult(interp, (wmPtr->hints.input ? "passive" : "active"),
- TCL_STATIC);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ wmPtr->hints.input ? "passive" : "active", -1));
return TCL_OK;
}
- if (Tcl_GetIndexFromObj(interp, objv[3], optionStrings, "argument", 0,
- &index) != TCL_OK) {
+ if (Tcl_GetIndexFromObjStruct(interp, objv[3], optionStrings,
+ sizeof(char *), "argument", 0, &index) != TCL_OK) {
return TCL_ERROR;
}
if (index == OPT_ACTIVE) {
@@ -1779,8 +1796,8 @@ WmFocusmodelCmd(
*
* WmForgetCmd --
*
- * This procedure is invoked to process the "wm forget" Tcl command.
- * See the user documentation for details on what it does.
+ * This procedure is invoked to process the "wm forget" Tcl command. See
+ * the user documentation for details on what it does.
*
* Results:
* A standard Tcl result.
@@ -1792,12 +1809,12 @@ WmFocusmodelCmd(
*/
static int
-WmForgetCmd(tkwin, winPtr, interp, objc, objv)
- Tk_Window tkwin; /* Main window of the application. */
- TkWindow *winPtr; /* Toplevel or Frame to work with */
- Tcl_Interp *interp; /* Current interpreter. */
- int objc; /* Number of arguments. */
- Tcl_Obj *CONST objv[]; /* Argument objects. */
+WmForgetCmd(
+ Tk_Window tkwin, /* Main window of the application. */
+ TkWindow *winPtr, /* Toplevel or Frame to work with */
+ Tcl_Interp *interp, /* Current interpreter. */
+ int objc, /* Number of arguments. */
+ Tcl_Obj *const objv[]) /* Argument objects. */
{
register Tk_Window frameWin = (Tk_Window) winPtr;
@@ -1805,13 +1822,19 @@ WmForgetCmd(tkwin, winPtr, interp, objc, objv)
TkFocusJoin(winPtr);
Tk_UnmapWindow(frameWin);
TkWmDeadWindow(winPtr);
- winPtr->flags &= ~(TK_TOP_HIERARCHY|TK_TOP_LEVEL|TK_HAS_WRAPPER|TK_WIN_MANAGED);
+ winPtr->flags &=
+ ~(TK_TOP_HIERARCHY|TK_TOP_LEVEL|TK_HAS_WRAPPER|TK_WIN_MANAGED);
RemapWindows(winPtr, winPtr->parentPtr);
- /* flags (above) must be cleared before calling */
- /* TkMapTopFrame (below) */
+
+ /*
+ * Flags (above) must be cleared before calling TkMapTopFrame (below).
+ */
+
TkMapTopFrame(frameWin);
} else {
- /* Already not managed by wm - ignore it */
+ /*
+ * Already not managed by wm - ignore it.
+ */
}
return TCL_OK;
}
@@ -1839,11 +1862,10 @@ WmFrameCmd(
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
- Tcl_Obj *CONST objv[]) /* Argument objects. */
+ Tcl_Obj *const objv[]) /* Argument objects. */
{
register WmInfo *wmPtr = winPtr->wmInfoPtr;
Window window;
- char buf[TCL_INTEGER_SPACE];
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "window");
@@ -1853,8 +1875,7 @@ WmFrameCmd(
if (window == None) {
window = Tk_WindowId((Tk_Window) winPtr);
}
- sprintf(buf, "0x%x", (unsigned int) window);
- Tcl_SetResult(interp, buf, TCL_VOLATILE);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf("0x%x", (unsigned) window));
return TCL_OK;
}
@@ -1881,20 +1902,18 @@ WmGeometryCmd(
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
- Tcl_Obj *CONST objv[]) /* Argument objects. */
+ Tcl_Obj *const objv[]) /* Argument objects. */
{
register WmInfo *wmPtr = winPtr->wmInfoPtr;
char xSign, ySign;
int width, height;
- char *argv3;
+ const char *argv3;
if ((objc != 3) && (objc != 4)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?newGeometry?");
return TCL_ERROR;
}
if (objc == 3) {
- char buf[16 + TCL_INTEGER_SPACE * 4];
-
xSign = (wmPtr->flags & WM_NEGATIVE_X) ? '-' : '+';
ySign = (wmPtr->flags & WM_NEGATIVE_Y) ? '-' : '+';
if (wmPtr->gridWin != NULL) {
@@ -1906,9 +1925,8 @@ WmGeometryCmd(
width = winPtr->changes.width;
height = winPtr->changes.height;
}
- sprintf(buf, "%dx%d%c%d%c%d", width, height, xSign, wmPtr->x,
- ySign, wmPtr->y);
- Tcl_SetResult(interp, buf, TCL_VOLATILE);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf("%dx%d%c%d%c%d",
+ width, height, xSign, wmPtr->x, ySign, wmPtr->y));
return TCL_OK;
}
argv3 = Tcl_GetString(objv[3]);
@@ -1944,7 +1962,7 @@ WmGridCmd(
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
- Tcl_Obj *CONST objv[]) /* Argument objects. */
+ Tcl_Obj *const objv[]) /* Argument objects. */
{
register WmInfo *wmPtr = winPtr->wmInfoPtr;
int reqWidth, reqHeight, widthInc, heightInc;
@@ -1956,12 +1974,13 @@ WmGridCmd(
}
if (objc == 3) {
if (wmPtr->sizeHintsFlags & PBaseSize) {
- char buf[TCL_INTEGER_SPACE * 4];
+ Tcl_Obj *results[4];
- sprintf(buf, "%d %d %d %d", wmPtr->reqGridWidth,
- wmPtr->reqGridHeight, wmPtr->widthInc,
- wmPtr->heightInc);
- Tcl_SetResult(interp, buf, TCL_VOLATILE);
+ results[0] = Tcl_NewIntObj(wmPtr->reqGridWidth);
+ results[1] = Tcl_NewIntObj(wmPtr->reqGridHeight);
+ results[2] = Tcl_NewIntObj(wmPtr->widthInc);
+ results[3] = Tcl_NewIntObj(wmPtr->heightInc);
+ Tcl_SetObjResult(interp, Tcl_NewListObj(4, results));
}
return TCL_OK;
}
@@ -1988,19 +2007,27 @@ WmGridCmd(
return TCL_ERROR;
}
if (reqWidth < 0) {
- Tcl_SetResult(interp, "baseWidth can't be < 0", TCL_STATIC);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "baseWidth can't be < 0", -1));
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "GRID", NULL);
return TCL_ERROR;
}
if (reqHeight < 0) {
- Tcl_SetResult(interp, "baseHeight can't be < 0", TCL_STATIC);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "baseHeight can't be < 0", -1));
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "GRID", NULL);
return TCL_ERROR;
}
if (widthInc <= 0) {
- Tcl_SetResult(interp, "widthInc can't be <= 0", TCL_STATIC);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "widthInc can't be <= 0", -1));
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "GRID", NULL);
return TCL_ERROR;
}
if (heightInc <= 0) {
- Tcl_SetResult(interp, "heightInc can't be <= 0", TCL_STATIC);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "heightInc can't be <= 0", -1));
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "GRID", NULL);
return TCL_ERROR;
}
Tk_SetGrid((Tk_Window) winPtr, reqWidth, reqHeight, widthInc,
@@ -2034,12 +2061,12 @@ WmGroupCmd(
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
- Tcl_Obj *CONST objv[]) /* Argument objects. */
+ Tcl_Obj *const objv[]) /* Argument objects. */
{
register WmInfo *wmPtr = winPtr->wmInfoPtr;
Tk_Window tkwin2;
WmInfo *wmPtr2;
- char *argv3;
+ const char *argv3;
int length;
if ((objc != 3) && (objc != 4)) {
@@ -2048,7 +2075,7 @@ WmGroupCmd(
}
if (objc == 3) {
if (wmPtr->hints.flags & WindowGroupHint) {
- Tcl_SetResult(interp, wmPtr->leaderName, TCL_STATIC);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(wmPtr->leaderName, -1));
}
return TCL_OK;
}
@@ -2080,7 +2107,7 @@ WmGroupCmd(
}
wmPtr->hints.window_group = Tk_WindowId(wmPtr2->wrapperPtr);
wmPtr->hints.flags |= WindowGroupHint;
- wmPtr->leaderName = ckalloc((unsigned) length + 1);
+ wmPtr->leaderName = ckalloc(length + 1);
strcpy(wmPtr->leaderName, argv3);
}
UpdateHints(winPtr);
@@ -2110,11 +2137,11 @@ WmIconbitmapCmd(
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
- Tcl_Obj *CONST objv[]) /* Argument objects. */
+ Tcl_Obj *const objv[]) /* Argument objects. */
{
register WmInfo *wmPtr = winPtr->wmInfoPtr;
Pixmap pixmap;
- char *argv3;
+ const char *argv3;
if ((objc < 3) || (objc > 4)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?bitmap?");
@@ -2122,9 +2149,9 @@ WmIconbitmapCmd(
}
if (objc == 3) {
if (wmPtr->hints.flags & IconPixmapHint) {
- Tcl_SetResult(interp, (char *)
- Tk_NameOfBitmap(winPtr->display, wmPtr->hints.icon_pixmap),
- TCL_STATIC);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ Tk_NameOfBitmap(winPtr->display,
+ wmPtr->hints.icon_pixmap), -1));
}
return TCL_OK;
}
@@ -2170,37 +2197,47 @@ WmIconifyCmd(
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
- Tcl_Obj *CONST objv[]) /* Argument objects. */
+ Tcl_Obj *const objv[]) /* Argument objects. */
{
register WmInfo *wmPtr = winPtr->wmInfoPtr;
+
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "window");
return TCL_ERROR;
}
if (Tk_Attributes((Tk_Window) winPtr)->override_redirect) {
- Tcl_AppendResult(interp, "can't iconify \"", winPtr->pathName,
- "\": override-redirect flag is set", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't iconify \"%s\": override-redirect flag is set",
+ winPtr->pathName));
+ Tcl_SetErrorCode(interp, "TK", "WM", "ICONIFY", "OVERRIDE_REDIRECT",
+ NULL);
return TCL_ERROR;
}
if (wmPtr->masterPtr != NULL) {
- Tcl_AppendResult(interp, "can't iconify \"", winPtr->pathName,
- "\": it is a transient", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't iconify \"%s\": it is a transient",
+ winPtr->pathName));
+ Tcl_SetErrorCode(interp, "TK", "WM", "ICONIFY", "TRANSIENT", NULL);
return TCL_ERROR;
}
if (wmPtr->iconFor != NULL) {
- Tcl_AppendResult(interp, "can't iconify ", winPtr->pathName,
- ": it is an icon for ", Tk_PathName(wmPtr->iconFor), NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't iconify %s: it is an icon for %s",
+ winPtr->pathName, Tk_PathName(wmPtr->iconFor)));
+ Tcl_SetErrorCode(interp, "TK", "WM", "ICONIFY", "ICON", NULL);
return TCL_ERROR;
}
if (winPtr->flags & TK_EMBEDDED) {
- Tcl_AppendResult(interp, "can't iconify ", winPtr->pathName,
- ": it is an embedded window", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't iconify %s: it is an embedded window",
+ winPtr->pathName));
+ Tcl_SetErrorCode(interp, "TK", "WM", "ICONIFY", "EMBEDDED", NULL);
return TCL_ERROR;
}
if (TkpWmSetState(winPtr, IconicState) == 0) {
- Tcl_SetResult(interp,
- "couldn't send iconify message to window manager",
- TCL_STATIC);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "couldn't send iconify message to window manager", -1));
+ Tcl_SetErrorCode(interp, "TK", "WM", "COMMUNICATION", NULL);
return TCL_ERROR;
}
return TCL_OK;
@@ -2229,11 +2266,11 @@ WmIconmaskCmd(
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
- Tcl_Obj *CONST objv[]) /* Argument objects. */
+ Tcl_Obj *const objv[]) /* Argument objects. */
{
register WmInfo *wmPtr = winPtr->wmInfoPtr;
Pixmap pixmap;
- char *argv3;
+ const char *argv3;
if ((objc != 3) && (objc != 4)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?bitmap?");
@@ -2241,9 +2278,9 @@ WmIconmaskCmd(
}
if (objc == 3) {
if (wmPtr->hints.flags & IconMaskHint) {
- Tcl_SetResult(interp, (char *)
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
Tk_NameOfBitmap(winPtr->display, wmPtr->hints.icon_mask),
- TCL_STATIC);
+ -1));
}
return TCL_OK;
}
@@ -2288,10 +2325,10 @@ WmIconnameCmd(
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
- Tcl_Obj *CONST objv[]) /* Argument objects. */
+ Tcl_Obj *const objv[]) /* Argument objects. */
{
register WmInfo *wmPtr = winPtr->wmInfoPtr;
- char *argv3;
+ const char *argv3;
int length;
if (objc > 4) {
@@ -2299,16 +2336,16 @@ WmIconnameCmd(
return TCL_ERROR;
}
if (objc == 3) {
- Tcl_SetResult(interp,
- ((wmPtr->iconName != NULL) ? wmPtr->iconName : ""),
- TCL_STATIC);
+ if (wmPtr->iconName != NULL) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(wmPtr->iconName, -1));
+ }
return TCL_OK;
} else {
if (wmPtr->iconName != NULL) {
- ckfree((char *) wmPtr->iconName);
+ ckfree(wmPtr->iconName);
}
argv3 = Tcl_GetStringFromObj(objv[3], &length);
- wmPtr->iconName = ckalloc((unsigned) length + 1);
+ wmPtr->iconName = ckalloc(length + 1);
strcpy(wmPtr->iconName, argv3);
if (!(wmPtr->flags & WM_NEVER_MAPPED)) {
UpdateTitle(winPtr);
@@ -2340,7 +2377,7 @@ WmIconphotoCmd(
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
- Tcl_Obj *CONST objv[]) /* Argument objects. */
+ Tcl_Obj *const objv[]) /* Argument objects. */
{
register WmInfo *wmPtr = winPtr->wmInfoPtr;
Tk_PhotoHandle photo;
@@ -2370,8 +2407,10 @@ WmIconphotoCmd(
for (i = 3 + isDefault; i < objc; i++) {
photo = Tk_FindPhoto(interp, Tcl_GetString(objv[i]));
if (photo == NULL) {
- Tcl_AppendResult(interp, "can't use \"", Tcl_GetString(objv[i]),
- "\" as iconphoto: not a photo image", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't use \"%s\" as iconphoto: not a photo image",
+ Tcl_GetString(objv[i])));
+ Tcl_SetErrorCode(interp, "TK", "WM", "ICONPHOTO", "PHOTO", NULL);
return TCL_ERROR;
}
Tk_PhotoGetSize(photo, &width, &height);
@@ -2391,8 +2430,7 @@ WmIconphotoCmd(
* defines CARD32 arrays to use. [Bug 2902814]
*/
- iconPropertyData = (unsigned long *)
- attemptckalloc(sizeof(unsigned long) * size);
+ iconPropertyData = attemptckalloc(sizeof(unsigned long) * size);
if (iconPropertyData == NULL) {
return TCL_ERROR;
}
@@ -2422,14 +2460,12 @@ WmIconphotoCmd(
* A, low byte being B. The first two cardinals are width, height.
* Data is in rows, left to right and top to bottom. The data will be
* endian-swapped going to the server if necessary. [Bug 2830420]
+ *
+ * The image data will be encoded in the iconPropertyData array.
*/
- /*
- * Encode the image data in the iconPropertyData array.
- */
-
- iconPropertyData[index++] = (unsigned) width;
- iconPropertyData[index++] = (unsigned) height;
+ iconPropertyData[index++] = (unsigned long) width;
+ iconPropertyData[index++] = (unsigned long) height;
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {
register unsigned char *pixelPtr =
@@ -2445,12 +2481,12 @@ WmIconphotoCmd(
}
}
if (wmPtr->iconDataPtr != NULL) {
- ckfree((char *) wmPtr->iconDataPtr);
+ ckfree(wmPtr->iconDataPtr);
wmPtr->iconDataPtr = NULL;
}
if (isDefault) {
if (winPtr->dispPtr->iconDataPtr != NULL) {
- ckfree((char *) winPtr->dispPtr->iconDataPtr);
+ ckfree(winPtr->dispPtr->iconDataPtr);
}
winPtr->dispPtr->iconDataPtr = (unsigned char *) iconPropertyData;
winPtr->dispPtr->iconDataSize = size;
@@ -2487,7 +2523,7 @@ WmIconpositionCmd(
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
- Tcl_Obj *CONST objv[]) /* Argument objects. */
+ Tcl_Obj *const objv[]) /* Argument objects. */
{
register WmInfo *wmPtr = winPtr->wmInfoPtr;
int x, y;
@@ -2498,19 +2534,19 @@ WmIconpositionCmd(
}
if (objc == 3) {
if (wmPtr->hints.flags & IconPositionHint) {
- char buf[TCL_INTEGER_SPACE * 2];
+ Tcl_Obj *results[2];
- sprintf(buf, "%d %d", wmPtr->hints.icon_x,
- wmPtr->hints.icon_y);
- Tcl_SetResult(interp, buf, TCL_VOLATILE);
+ results[0] = Tcl_NewIntObj(wmPtr->hints.icon_x);
+ results[1] = Tcl_NewIntObj(wmPtr->hints.icon_y);
+ Tcl_SetObjResult(interp, Tcl_NewListObj(2, results));
}
return TCL_OK;
}
- if (*Tcl_GetString(objv[3]) == '\0') {
+ if (Tcl_GetString(objv[3])[0] == '\0') {
wmPtr->hints.flags &= ~IconPositionHint;
} else {
if ((Tcl_GetIntFromObj(interp, objv[3], &x) != TCL_OK)
- || (Tcl_GetIntFromObj(interp, objv[4], &y) != TCL_OK)){
+ || (Tcl_GetIntFromObj(interp, objv[4], &y) != TCL_OK)) {
return TCL_ERROR;
}
wmPtr->hints.icon_x = x;
@@ -2544,7 +2580,7 @@ WmIconwindowCmd(
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
- Tcl_Obj *CONST objv[]) /* Argument objects. */
+ Tcl_Obj *const objv[]) /* Argument objects. */
{
register WmInfo *wmPtr = winPtr->wmInfoPtr;
Tk_Window tkwin2;
@@ -2557,7 +2593,7 @@ WmIconwindowCmd(
}
if (objc == 3) {
if (wmPtr->icon != NULL) {
- Tcl_SetResult(interp, Tk_PathName(wmPtr->icon), TCL_STATIC);
+ Tcl_SetObjResult(interp, TkNewWindowObj(wmPtr->icon));
}
return TCL_OK;
}
@@ -2584,19 +2620,23 @@ WmIconwindowCmd(
return TCL_ERROR;
}
if (!Tk_IsTopLevel(tkwin2)) {
- Tcl_AppendResult(interp, "can't use ", Tcl_GetString(objv[3]),
- " as icon window: not at top level", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't use %s as icon window: not at top level",
+ Tcl_GetString(objv[3])));
+ Tcl_SetErrorCode(interp, "TK", "WM", "ICONWINDOW", "INNER", NULL);
return TCL_ERROR;
}
wmPtr2 = ((TkWindow *) tkwin2)->wmInfoPtr;
if (wmPtr2->iconFor != NULL) {
- Tcl_AppendResult(interp, Tcl_GetString(objv[3]),
- " is already an icon for ", Tk_PathName(wmPtr2->iconFor),
- NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "%s is already an icon for %s",
+ Tcl_GetString(objv[3]), Tk_PathName(wmPtr2->iconFor)));
+ Tcl_SetErrorCode(interp, "TK", "WM", "ICONWINDOW", "ICON", NULL);
return TCL_ERROR;
}
if (wmPtr->icon != NULL) {
WmInfo *wmPtr3 = ((TkWindow *) wmPtr->icon)->wmInfoPtr;
+
wmPtr3->iconFor = NULL;
wmPtr3->withdrawn = 1;
wmPtr3->hints.initial_state = WithdrawnState;
@@ -2624,9 +2664,10 @@ WmIconwindowCmd(
if (XWithdrawWindow(Tk_Display(tkwin2),
Tk_WindowId(wmPtr2->wrapperPtr),
Tk_ScreenNumber(tkwin2)) == 0) {
- Tcl_SetResult(interp,
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
"couldn't send withdraw message to window manager",
- TCL_STATIC);
+ -1));
+ Tcl_SetErrorCode(interp, "TK", "WM", "COMMUNICATION", NULL);
return TCL_ERROR;
}
WaitForMapNotify((TkWindow *) tkwin2, 0);
@@ -2641,8 +2682,8 @@ WmIconwindowCmd(
*
* WmManageCmd --
*
- * This procedure is invoked to process the "wm manage" Tcl command.
- * See the user documentation for details on what it does.
+ * This procedure is invoked to process the "wm manage" Tcl command. See
+ * the user documentation for details on what it does.
*
* Results:
* A standard Tcl result.
@@ -2654,26 +2695,28 @@ WmIconwindowCmd(
*/
static int
-WmManageCmd(tkwin, winPtr, interp, objc, objv)
- Tk_Window tkwin; /* Main window of the application. */
- TkWindow *winPtr; /* Toplevel or Frame to work with */
- Tcl_Interp *interp; /* Current interpreter. */
- int objc; /* Number of arguments. */
- Tcl_Obj *CONST objv[]; /* Argument objects. */
+WmManageCmd(
+ Tk_Window tkwin, /* Main window of the application. */
+ TkWindow *winPtr, /* Toplevel or Frame to work with */
+ Tcl_Interp *interp, /* Current interpreter. */
+ int objc, /* Number of arguments. */
+ Tcl_Obj *const objv[]) /* Argument objects. */
{
register Tk_Window frameWin = (Tk_Window) winPtr;
register WmInfo *wmPtr = winPtr->wmInfoPtr;
if (!Tk_IsTopLevel(frameWin)) {
if (!Tk_IsManageable(frameWin)) {
- Tcl_AppendResult(interp, "window \"",
- Tk_PathName(frameWin), "\" is not manageable: must be "
- "a frame, labelframe or toplevel", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "window \"%s\" is not manageable: must be a frame,"
+ " labelframe or toplevel", Tk_PathName(frameWin)));
+ Tcl_SetErrorCode(interp, "TK", "WM", "MANAGE", NULL);
return TCL_ERROR;
}
TkFocusSplit(winPtr);
Tk_UnmapWindow(frameWin);
- winPtr->flags |= TK_TOP_HIERARCHY|TK_TOP_LEVEL|TK_HAS_WRAPPER|TK_WIN_MANAGED;
+ winPtr->flags |=
+ TK_TOP_HIERARCHY|TK_TOP_LEVEL|TK_HAS_WRAPPER|TK_WIN_MANAGED;
if (wmPtr == NULL) {
TkWmNewWindow(winPtr);
TkWmMapWindow(winPtr);
@@ -2682,11 +2725,16 @@ WmManageCmd(tkwin, winPtr, interp, objc, objv)
wmPtr = winPtr->wmInfoPtr;
winPtr->flags &= ~TK_MAPPED;
RemapWindows(winPtr, wmPtr->wrapperPtr);
- /* flags (above) must be set before calling */
- /* TkMapTopFrame (below) */
- TkMapTopFrame (frameWin);
+
+ /*
+ * Flags (above) must be set before calling TkMapTopFrame (below).
+ */
+
+ TkMapTopFrame(frameWin);
} else if (Tk_IsTopLevel(frameWin)) {
- /* Already managed by wm - ignore it */
+ /*
+ * Already managed by wm - ignore it.
+ */
}
return TCL_OK;
}
@@ -2714,7 +2762,7 @@ WmMaxsizeCmd(
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
- Tcl_Obj *CONST objv[]) /* Argument objects. */
+ Tcl_Obj *const objv[]) /* Argument objects. */
{
register WmInfo *wmPtr = winPtr->wmInfoPtr;
int width, height;
@@ -2724,11 +2772,12 @@ WmMaxsizeCmd(
return TCL_ERROR;
}
if (objc == 3) {
- char buf[TCL_INTEGER_SPACE * 2];
+ Tcl_Obj *results[2];
GetMaxSize(wmPtr, &width, &height);
- sprintf(buf, "%d %d", width, height);
- Tcl_SetResult(interp, buf, TCL_VOLATILE);
+ results[0] = Tcl_NewIntObj(width);
+ results[1] = Tcl_NewIntObj(height);
+ Tcl_SetObjResult(interp, Tcl_NewListObj(2, results));
return TCL_OK;
}
if ((Tcl_GetIntFromObj(interp, objv[3], &width) != TCL_OK)
@@ -2772,7 +2821,7 @@ WmMinsizeCmd(
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
- Tcl_Obj *CONST objv[]) /* Argument objects. */
+ Tcl_Obj *const objv[]) /* Argument objects. */
{
register WmInfo *wmPtr = winPtr->wmInfoPtr;
int width, height;
@@ -2782,10 +2831,11 @@ WmMinsizeCmd(
return TCL_ERROR;
}
if (objc == 3) {
- char buf[TCL_INTEGER_SPACE * 2];
+ Tcl_Obj *results[2];
- sprintf(buf, "%d %d", wmPtr->minWidth, wmPtr->minHeight);
- Tcl_SetResult(interp, buf, TCL_VOLATILE);
+ results[0] = Tcl_NewIntObj(wmPtr->minWidth);
+ results[1] = Tcl_NewIntObj(wmPtr->minHeight);
+ Tcl_SetObjResult(interp, Tcl_NewListObj(2, results));
return TCL_OK;
}
if ((Tcl_GetIntFromObj(interp, objv[3], &width) != TCL_OK)
@@ -2822,7 +2872,7 @@ WmOverrideredirectCmd(
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
- Tcl_Obj *CONST objv[]) /* Argument objects. */
+ Tcl_Obj *const objv[]) /* Argument objects. */
{
int boolean, curValue;
XSetWindowAttributes atts;
@@ -2833,7 +2883,7 @@ WmOverrideredirectCmd(
}
curValue = Tk_Attributes((Tk_Window) winPtr)->override_redirect;
if (objc == 3) {
- Tcl_SetBooleanObj(Tcl_GetObjResult(interp), curValue);
+ Tcl_SetObjResult(interp, Tcl_NewBooleanObj(curValue));
return TCL_OK;
}
if (Tcl_GetBooleanFromObj(interp, objv[3], &boolean) != TCL_OK) {
@@ -2880,10 +2930,10 @@ WmPositionfromCmd(
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
- Tcl_Obj *CONST objv[]) /* Argument objects. */
+ Tcl_Obj *const objv[]) /* Argument objects. */
{
register WmInfo *wmPtr = winPtr->wmInfoPtr;
- static CONST char *optionStrings[] = {
+ static const char *const optionStrings[] = {
"program", "user", NULL };
enum options {
OPT_PROGRAM, OPT_USER };
@@ -2894,18 +2944,21 @@ WmPositionfromCmd(
return TCL_ERROR;
}
if (objc == 3) {
+ const char *sourceStr = "";
+
if (wmPtr->sizeHintsFlags & USPosition) {
- Tcl_SetResult(interp, "user", TCL_STATIC);
+ sourceStr = "user";
} else if (wmPtr->sizeHintsFlags & PPosition) {
- Tcl_SetResult(interp, "program", TCL_STATIC);
+ sourceStr = "program";
}
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(sourceStr, -1));
return TCL_OK;
}
if (*Tcl_GetString(objv[3]) == '\0') {
wmPtr->sizeHintsFlags &= ~(USPosition|PPosition);
} else {
- if (Tcl_GetIndexFromObj(interp, objv[3], optionStrings, "argument", 0,
- &index) != TCL_OK) {
+ if (Tcl_GetIndexFromObjStruct(interp, objv[3], optionStrings,
+ sizeof(char *), "argument", 0, &index) != TCL_OK) {
return TCL_ERROR;
}
if (index == OPT_USER) {
@@ -2944,12 +2997,12 @@ WmProtocolCmd(
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
- Tcl_Obj *CONST objv[]) /* Argument objects. */
+ Tcl_Obj *const objv[]) /* Argument objects. */
{
register WmInfo *wmPtr = winPtr->wmInfoPtr;
register ProtocolHandler *protPtr, *prevPtr;
Atom protocol;
- char *cmd;
+ const char *cmd;
int cmdLength;
if ((objc < 3) || (objc > 5)) {
@@ -2961,11 +3014,14 @@ WmProtocolCmd(
* Return a list of all defined protocols for the window.
*/
+ Tcl_Obj *resultObj = Tcl_NewObj();
+
for (protPtr = wmPtr->protPtr; protPtr != NULL;
protPtr = protPtr->nextPtr) {
- Tcl_AppendElement(interp,
- Tk_GetAtomName((Tk_Window) winPtr, protPtr->protocol));
+ Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj(
+ Tk_GetAtomName((Tk_Window)winPtr, protPtr->protocol),-1));
}
+ Tcl_SetObjResult(interp, resultObj);
return TCL_OK;
}
protocol = Tk_InternAtom((Tk_Window) winPtr, Tcl_GetString(objv[3]));
@@ -2977,7 +3033,8 @@ WmProtocolCmd(
for (protPtr = wmPtr->protPtr; protPtr != NULL;
protPtr = protPtr->nextPtr) {
if (protPtr->protocol == protocol) {
- Tcl_SetResult(interp, protPtr->command, TCL_STATIC);
+ Tcl_SetObjResult(interp,
+ Tcl_NewStringObj(protPtr->command, -1));
return TCL_OK;
}
}
@@ -2989,8 +3046,9 @@ WmProtocolCmd(
*/
if (strcmp(Tcl_GetString(objv[3]), "_NET_WM_PING") == 0) {
- Tcl_SetResult(interp, "may not alter handling of that protocol",
- TCL_STATIC);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "may not alter handling of that protocol", -1));
+ Tcl_SetErrorCode(interp, "TK", "WM", "PROTOCOL", "RESERVED", NULL);
return TCL_ERROR;
}
@@ -3007,13 +3065,13 @@ WmProtocolCmd(
} else {
prevPtr->nextPtr = protPtr->nextPtr;
}
- Tcl_EventuallyFree((ClientData) protPtr, TCL_DYNAMIC);
+ Tcl_EventuallyFree(protPtr, TCL_DYNAMIC);
break;
}
}
cmd = Tcl_GetStringFromObj(objv[4], &cmdLength);
if (cmdLength > 0) {
- protPtr = (ProtocolHandler *) ckalloc(HANDLER_SIZE(cmdLength));
+ protPtr = ckalloc(HANDLER_SIZE(cmdLength));
protPtr->protocol = protocol;
protPtr->nextPtr = wmPtr->protPtr;
wmPtr->protPtr = protPtr;
@@ -3049,7 +3107,7 @@ WmResizableCmd(
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
- Tcl_Obj *CONST objv[]) /* Argument objects. */
+ Tcl_Obj *const objv[]) /* Argument objects. */
{
register WmInfo *wmPtr = winPtr->wmInfoPtr;
int width, height;
@@ -3059,12 +3117,11 @@ WmResizableCmd(
return TCL_ERROR;
}
if (objc == 3) {
- char buf[TCL_INTEGER_SPACE * 2];
+ Tcl_Obj *results[2];
- sprintf(buf, "%d %d",
- (wmPtr->flags & WM_WIDTH_NOT_RESIZABLE) ? 0 : 1,
- (wmPtr->flags & WM_HEIGHT_NOT_RESIZABLE) ? 0 : 1);
- Tcl_SetResult(interp, buf, TCL_VOLATILE);
+ results[0] = Tcl_NewBooleanObj(!(wmPtr->flags&WM_WIDTH_NOT_RESIZABLE));
+ results[1] = Tcl_NewBooleanObj(!(wmPtr->flags&WM_HEIGHT_NOT_RESIZABLE));
+ Tcl_SetObjResult(interp, Tcl_NewListObj(2, results));
return TCL_OK;
}
if ((Tcl_GetBooleanFromObj(interp, objv[3], &width) != TCL_OK)
@@ -3109,10 +3166,10 @@ WmSizefromCmd(
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
- Tcl_Obj *CONST objv[]) /* Argument objects. */
+ Tcl_Obj *const objv[]) /* Argument objects. */
{
register WmInfo *wmPtr = winPtr->wmInfoPtr;
- static CONST char *optionStrings[] = {
+ static const char *const optionStrings[] = {
"program", "user", NULL };
enum options {
OPT_PROGRAM, OPT_USER };
@@ -3123,19 +3180,22 @@ WmSizefromCmd(
return TCL_ERROR;
}
if (objc == 3) {
+ const char *sourceStr = "";
+
if (wmPtr->sizeHintsFlags & USSize) {
- Tcl_SetResult(interp, "user", TCL_STATIC);
+ sourceStr = "user";
} else if (wmPtr->sizeHintsFlags & PSize) {
- Tcl_SetResult(interp, "program", TCL_STATIC);
+ sourceStr = "program";
}
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(sourceStr, -1));
return TCL_OK;
}
if (*Tcl_GetString(objv[3]) == '\0') {
wmPtr->sizeHintsFlags &= ~(USSize|PSize);
} else {
- if (Tcl_GetIndexFromObj(interp, objv[3], optionStrings, "argument", 0,
- &index) != TCL_OK) {
+ if (Tcl_GetIndexFromObjStruct(interp, objv[3], optionStrings,
+ sizeof(char *), "argument", 0, &index) != TCL_OK) {
return TCL_ERROR;
}
if (index == OPT_USER) {
@@ -3174,10 +3234,10 @@ WmStackorderCmd(
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
- Tcl_Obj *CONST objv[]) /* Argument objects. */
+ Tcl_Obj *const objv[]) /* Argument objects. */
{
TkWindow **windows, **window_ptr;
- static CONST char *optionStrings[] = {
+ static const char *const optionStrings[] = {
"isabove", "isbelow", NULL };
enum options {
OPT_ISABOVE, OPT_ISBELOW };
@@ -3191,11 +3251,15 @@ WmStackorderCmd(
if (objc == 3) {
windows = TkWmStackorderToplevel(winPtr);
if (windows != NULL) {
+ Tcl_Obj *resultObj = Tcl_NewObj();
+
/* ASSERT: true [Bug 1789819]*/
for (window_ptr = windows; *window_ptr ; window_ptr++) {
- Tcl_AppendElement(interp, (*window_ptr)->pathName);
+ Tcl_ListObjAppendElement(NULL, resultObj,
+ Tcl_NewStringObj((*window_ptr)->pathName, -1));
}
- ckfree((char *) windows);
+ ckfree(windows);
+ Tcl_SetObjResult(interp, resultObj);
return TCL_OK;
}
} else {
@@ -3209,20 +3273,24 @@ WmStackorderCmd(
winPtr2 = (TkWindow *) relWin;
if (!Tk_IsTopLevel(winPtr2)) {
- Tcl_AppendResult(interp, "window \"", winPtr2->pathName,
- "\" isn't a top-level window", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "window \"%s\" isn't a top-level window",
+ winPtr2->pathName));
+ Tcl_SetErrorCode(interp, "TK", "WM", "STACK", "TOPLEVEL", NULL);
return TCL_ERROR;
}
if (!Tk_IsMapped(winPtr)) {
- Tcl_AppendResult(interp, "window \"", winPtr->pathName,
- "\" isn't mapped", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "window \"%s\" isn't mapped", winPtr->pathName));
+ Tcl_SetErrorCode(interp, "TK", "WM", "STACK", "MAPPED", NULL);
return TCL_ERROR;
}
if (!Tk_IsMapped(winPtr2)) {
- Tcl_AppendResult(interp, "window \"", winPtr2->pathName,
- "\" isn't mapped", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "window \"%s\" isn't mapped", winPtr2->pathName));
+ Tcl_SetErrorCode(interp, "TK", "WM", "STACK", "MAPPED", NULL);
return TCL_ERROR;
}
@@ -3232,25 +3300,26 @@ WmStackorderCmd(
*/
windows = TkWmStackorderToplevel(winPtr->mainPtr->winPtr);
-
if (windows == NULL) {
- Tcl_AppendResult(interp, "TkWmStackorderToplevel failed", NULL);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "TkWmStackorderToplevel failed", -1));
+ Tcl_SetErrorCode(interp, "TK", "WM", "COMMUNICATION", NULL);
return TCL_ERROR;
- } else {
- for (window_ptr = windows; *window_ptr ; window_ptr++) {
- if (*window_ptr == winPtr) {
- index1 = (window_ptr - windows);
- }
- if (*window_ptr == winPtr2) {
- index2 = (window_ptr - windows);
- }
+ }
+
+ for (window_ptr = windows; *window_ptr ; window_ptr++) {
+ if (*window_ptr == winPtr) {
+ index1 = (window_ptr - windows);
+ }
+ if (*window_ptr == winPtr2) {
+ index2 = (window_ptr - windows);
}
- /* ASSERT: index1 != -1 && index2 != -2 [Bug 1789819] */
- ckfree((char *) windows);
}
+ /* ASSERT: index1 != -1 && index2 != -2 [Bug 1789819] */
+ ckfree(windows);
- if (Tcl_GetIndexFromObj(interp, objv[3], optionStrings, "argument", 0,
- &index) != TCL_OK) {
+ if (Tcl_GetIndexFromObjStruct(interp, objv[3], optionStrings,
+ sizeof(char *), "argument", 0, &index) != TCL_OK) {
return TCL_ERROR;
}
if (index == OPT_ISABOVE) {
@@ -3258,7 +3327,7 @@ WmStackorderCmd(
} else { /* OPT_ISBELOW */
result = index1 < index2;
}
- Tcl_SetIntObj(Tcl_GetObjResult(interp), result);
+ Tcl_SetObjResult(interp, Tcl_NewBooleanObj(result));
return TCL_OK;
}
return TCL_OK;
@@ -3287,10 +3356,10 @@ WmStateCmd(
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
- Tcl_Obj *CONST objv[]) /* Argument objects. */
+ Tcl_Obj *const objv[]) /* Argument objects. */
{
register WmInfo *wmPtr = winPtr->wmInfoPtr;
- static CONST char *optionStrings[] = {
+ static const char *const optionStrings[] = {
"normal", "iconic", "withdrawn", NULL };
enum options {
OPT_NORMAL, OPT_ICONIC, OPT_WITHDRAWN };
@@ -3302,14 +3371,15 @@ WmStateCmd(
}
if (objc == 4) {
if (wmPtr->iconFor != NULL) {
- Tcl_AppendResult(interp, "can't change state of ",
- Tcl_GetString(objv[2]), ": it is an icon for ",
- Tk_PathName(wmPtr->iconFor), NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't change state of %s: it is an icon for %s",
+ Tcl_GetString(objv[2]), Tk_PathName(wmPtr->iconFor)));
+ Tcl_SetErrorCode(interp, "TK", "WM", "STATE", "ICON", NULL);
return TCL_ERROR;
}
- if (Tcl_GetIndexFromObj(interp, objv[3], optionStrings, "argument", 0,
- &index) != TCL_OK) {
+ if (Tcl_GetIndexFromObjStruct(interp, objv[3], optionStrings,
+ sizeof(char *), "argument", 0, &index) != TCL_OK) {
return TCL_ERROR;
}
@@ -3318,42 +3388,53 @@ WmStateCmd(
(void) TkpWmSetState(winPtr, NormalState);
} else if (index == OPT_ICONIC) {
if (Tk_Attributes((Tk_Window) winPtr)->override_redirect) {
- Tcl_AppendResult(interp, "can't iconify \"", winPtr->pathName,
- "\": override-redirect flag is set", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't iconify \"%s\": override-redirect flag is set",
+ winPtr->pathName));
+ Tcl_SetErrorCode(interp, "TK", "WM", "STATE",
+ "OVERRIDE_REDIRECT", NULL);
return TCL_ERROR;
}
if (wmPtr->masterPtr != NULL) {
- Tcl_AppendResult(interp, "can't iconify \"", winPtr->pathName,
- "\": it is a transient", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't iconify \"%s\": it is a transient",
+ winPtr->pathName));
+ Tcl_SetErrorCode(interp, "TK", "WM", "STATE", "TRANSIENT",
+ NULL);
return TCL_ERROR;
}
if (TkpWmSetState(winPtr, IconicState) == 0) {
- Tcl_SetResult(interp,
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
"couldn't send iconify message to window manager",
- TCL_STATIC);
+ -1));
+ Tcl_SetErrorCode(interp, "TK", "WM", "COMMUNICATION", NULL);
return TCL_ERROR;
}
} else { /* OPT_WITHDRAWN */
wmPtr->flags |= WM_WITHDRAWN;
if (TkpWmSetState(winPtr, WithdrawnState) == 0) {
- Tcl_SetResult(interp,
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
"couldn't send withdraw message to window manager",
- TCL_STATIC);
+ -1));
+ Tcl_SetErrorCode(interp, "TK", "WM", "COMMUNICATION", NULL);
return TCL_ERROR;
}
}
} else {
+ const char *state;
+
if (wmPtr->iconFor != NULL) {
- Tcl_SetResult(interp, "icon", TCL_STATIC);
+ state = "icon";
} else if (wmPtr->withdrawn) {
- Tcl_SetResult(interp, "withdrawn", TCL_STATIC);
+ state = "withdrawn";
} else if (Tk_IsMapped((Tk_Window) winPtr)
|| ((wmPtr->flags & WM_NEVER_MAPPED)
&& (wmPtr->hints.initial_state == NormalState))) {
- Tcl_SetResult(interp, "normal", TCL_STATIC);
+ state = "normal";
} else {
- Tcl_SetResult(interp, "iconic", TCL_STATIC);
+ state = "iconic";
}
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(state, -1));
}
return TCL_OK;
}
@@ -3381,10 +3462,10 @@ WmTitleCmd(
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
- Tcl_Obj *CONST objv[]) /* Argument objects. */
+ Tcl_Obj *const objv[]) /* Argument objects. */
{
register WmInfo *wmPtr = winPtr->wmInfoPtr;
- char *argv3;
+ const char *argv3;
int length;
if (objc > 4) {
@@ -3392,16 +3473,17 @@ WmTitleCmd(
return TCL_ERROR;
}
if (objc == 3) {
- Tcl_SetResult(interp, (char *)
- ((wmPtr->title != NULL) ? wmPtr->title : winPtr->nameUid),
- TCL_STATIC);
- return TCL_OK;
+ if (wmPtr->title) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(wmPtr->title, -1));
+ } else {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(winPtr->nameUid, -1));
+ }
} else {
if (wmPtr->title != NULL) {
- ckfree((char *) wmPtr->title);
+ ckfree(wmPtr->title);
}
argv3 = Tcl_GetStringFromObj(objv[3], &length);
- wmPtr->title = ckalloc((unsigned) length + 1);
+ wmPtr->title = ckalloc(length + 1);
strcpy(wmPtr->title, argv3);
if (!(wmPtr->flags & WM_NEVER_MAPPED)) {
@@ -3434,7 +3516,7 @@ WmTransientCmd(
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
- Tcl_Obj *CONST objv[]) /* Argument objects. */
+ Tcl_Obj *const objv[]) /* Argument objects. */
{
register WmInfo *wmPtr = winPtr->wmInfoPtr;
TkWindow *masterPtr = wmPtr->masterPtr;
@@ -3446,7 +3528,7 @@ WmTransientCmd(
}
if (objc == 3) {
if (masterPtr != NULL) {
- Tcl_SetResult(interp, Tk_PathName(masterPtr), TCL_STATIC);
+ Tcl_SetObjResult(interp, TkNewWindowObj((Tk_Window) masterPtr));
}
return TCL_OK;
}
@@ -3459,7 +3541,7 @@ WmTransientCmd(
masterPtr->wmInfoPtr->numTransients--;
Tk_DeleteEventHandler((Tk_Window) masterPtr, StructureNotifyMask,
- WmWaitMapProc, (ClientData) winPtr);
+ WmWaitMapProc, winPtr);
/*
* FIXME: Need a call like Win32's UpdateWrapper() so we can
@@ -3486,9 +3568,10 @@ WmTransientCmd(
Tk_MakeWindowExist((Tk_Window) masterPtr);
if (wmPtr->iconFor != NULL) {
- Tcl_AppendResult(interp, "can't make \"", Tcl_GetString(objv[2]),
- "\" a transient: it is an icon for ",
- Tk_PathName(wmPtr->iconFor), NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't make \"%s\" a transient: it is an icon for %s",
+ Tcl_GetString(objv[2]), Tk_PathName(wmPtr->iconFor)));
+ Tcl_SetErrorCode(interp, "TK", "WM", "TRANSIENT", "ICON", NULL);
return TCL_ERROR;
}
@@ -3498,15 +3581,17 @@ WmTransientCmd(
}
if (wmPtr2->iconFor != NULL) {
- Tcl_AppendResult(interp, "can't make \"", Tcl_GetString(objv[3]),
- "\" a master: it is an icon for ",
- Tk_PathName(wmPtr2->iconFor), NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't make \"%s\" a master: it is an icon for %s",
+ Tcl_GetString(objv[3]), Tk_PathName(wmPtr2->iconFor)));
+ Tcl_SetErrorCode(interp, "TK", "WM", "TRANSIENT", "ICON", NULL);
return TCL_ERROR;
}
if (masterPtr == winPtr) {
- Tcl_AppendResult(interp, "can't make \"", Tk_PathName(winPtr),
- "\" its own master", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't make \"%s\" its own master", Tk_PathName(winPtr)));
+ Tcl_SetErrorCode(interp, "TK", "WM", "TRANSIENT", "SELF", NULL);
return TCL_ERROR;
} else if (masterPtr != wmPtr->masterPtr) {
/*
@@ -3518,13 +3603,12 @@ WmTransientCmd(
if (wmPtr->masterPtr != NULL) {
wmPtr->masterPtr->wmInfoPtr->numTransients--;
Tk_DeleteEventHandler((Tk_Window) wmPtr->masterPtr,
- StructureNotifyMask,
- WmWaitMapProc, (ClientData) winPtr);
+ StructureNotifyMask, WmWaitMapProc, winPtr);
}
masterPtr->wmInfoPtr->numTransients++;
Tk_CreateEventHandler((Tk_Window) masterPtr,
- StructureNotifyMask, WmWaitMapProc, (ClientData) winPtr);
+ StructureNotifyMask, WmWaitMapProc, winPtr);
wmPtr->masterPtr = masterPtr;
}
@@ -3532,9 +3616,10 @@ WmTransientCmd(
if (!(wmPtr->flags & WM_NEVER_MAPPED)) {
if (wmPtr->masterPtr != NULL && !Tk_IsMapped(wmPtr->masterPtr)) {
if (TkpWmSetState(winPtr, WithdrawnState) == 0) {
- Tcl_SetResult(interp,
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
"couldn't send withdraw message to window manager",
- TCL_STATIC);
+ -1));
+ Tcl_SetErrorCode(interp, "TK", "WM", "COMMUNICATION", NULL);
return TCL_ERROR;
}
} else {
@@ -3544,7 +3629,7 @@ WmTransientCmd(
wmPtr->masterPtr->wmInfoPtr->wrapperPtr->window);
} else {
XDeleteProperty(winPtr->display, wmPtr->wrapperPtr->window,
- Tk_InternAtom((Tk_Window) winPtr, "WM_TRANSIENT_FOR"));
+ Tk_InternAtom((Tk_Window) winPtr,"WM_TRANSIENT_FOR"));
}
}
}
@@ -3574,7 +3659,7 @@ WmWithdrawCmd(
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
- Tcl_Obj *CONST objv[]) /* Argument objects. */
+ Tcl_Obj *const objv[]) /* Argument objects. */
{
register WmInfo *wmPtr = winPtr->wmInfoPtr;
@@ -3583,15 +3668,17 @@ WmWithdrawCmd(
return TCL_ERROR;
}
if (wmPtr->iconFor != NULL) {
- Tcl_AppendResult(interp, "can't withdraw ", Tcl_GetString(objv[2]),
- ": it is an icon for ", Tk_PathName(wmPtr->iconFor), NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't withdraw %s: it is an icon for %s",
+ Tcl_GetString(objv[2]), Tk_PathName(wmPtr->iconFor)));
+ Tcl_SetErrorCode(interp, "TK", "WM", "WITHDRAW", "ICON", NULL);
return TCL_ERROR;
}
wmPtr->flags |= WM_WITHDRAWN;
if (TkpWmSetState(winPtr, WithdrawnState) == 0) {
- Tcl_SetResult(interp,
- "couldn't send withdraw message to window manager",
- TCL_STATIC);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "couldn't send withdraw message to window manager", -1));
+ Tcl_SetErrorCode(interp, "TK", "WM", "COMMUNICATION", NULL);
return TCL_ERROR;
}
return TCL_OK;
@@ -3608,7 +3695,7 @@ WmUpdateGeom(
TkWindow *winPtr)
{
if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) {
- Tcl_DoWhenIdle(UpdateGeometryInfo, (ClientData) winPtr);
+ Tcl_DoWhenIdle(UpdateGeometryInfo, winPtr);
wmPtr->flags |= WM_UPDATE_PENDING;
}
}
@@ -3623,7 +3710,7 @@ WmWaitMapProc(
ClientData clientData, /* Pointer to window. */
XEvent *eventPtr) /* Information about event. */
{
- TkWindow *winPtr = (TkWindow *) clientData;
+ TkWindow *winPtr = clientData;
TkWindow *masterPtr = winPtr->wmInfoPtr->masterPtr;
if (masterPtr == NULL) {
@@ -3750,7 +3837,7 @@ Tk_SetGrid(
wmPtr->sizeHintsFlags |= PBaseSize|PResizeInc;
wmPtr->flags |= WM_UPDATE_SIZE_HINTS;
if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) {
- Tcl_DoWhenIdle(UpdateGeometryInfo, (ClientData) winPtr);
+ Tcl_DoWhenIdle(UpdateGeometryInfo, winPtr);
wmPtr->flags |= WM_UPDATE_PENDING;
}
}
@@ -3818,7 +3905,7 @@ Tk_UnsetGrid(
wmPtr->flags |= WM_UPDATE_SIZE_HINTS;
if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) {
- Tcl_DoWhenIdle(UpdateGeometryInfo, (ClientData) winPtr);
+ Tcl_DoWhenIdle(UpdateGeometryInfo, winPtr);
wmPtr->flags |= WM_UPDATE_PENDING;
}
}
@@ -4043,9 +4130,11 @@ ReparentEvent(
Atom actualType;
int actualFormat;
unsigned long numItems, bytesAfter;
- unsigned int dummy;
+ unsigned dummy;
Tk_ErrorHandler handler;
TkDisplay *dispPtr = wmPtr->winPtr->dispPtr;
+ Atom WM_ROOT = Tk_InternAtom((Tk_Window) wrapperPtr, "__WM_ROOT");
+ Atom SWM_ROOT = Tk_InternAtom((Tk_Window) wrapperPtr, "__SWM_ROOT");
/*
* Identify the root window for wrapperPtr. This is tricky because of
@@ -4059,15 +4148,11 @@ ReparentEvent(
wmPtr->vRoot = None;
handler = Tk_CreateErrorHandler(wrapperPtr->display, -1,-1,-1, NULL,NULL);
vrPtrPtr = &virtualRootPtr; /* Silence GCC warning */
- if (((XGetWindowProperty(wrapperPtr->display, wrapperPtr->window,
- Tk_InternAtom((Tk_Window) wrapperPtr, "__WM_ROOT"), 0, (long) 1,
- False, XA_WINDOW, &actualType, &actualFormat, &numItems,
- &bytesAfter, (unsigned char **) vrPtrPtr) == Success)
+ if ((GetWindowProperty(wrapperPtr, WM_ROOT, 1, XA_WINDOW,
+ &actualType, &actualFormat, &numItems, &bytesAfter, vrPtrPtr)
&& (actualType == XA_WINDOW))
- || ((XGetWindowProperty(wrapperPtr->display, wrapperPtr->window,
- Tk_InternAtom((Tk_Window) wrapperPtr, "__SWM_ROOT"), 0, (long) 1,
- False, XA_WINDOW, &actualType, &actualFormat, &numItems,
- &bytesAfter, (unsigned char **) vrPtrPtr) == Success)
+ || (GetWindowProperty(wrapperPtr, SWM_ROOT, 1, XA_WINDOW,
+ &actualType, &actualFormat, &numItems, &bytesAfter, vrPtrPtr)
&& (actualType == XA_WINDOW))) {
if ((actualFormat == 32) && (numItems == 1)) {
vRoot = wmPtr->vRoot = *virtualRootPtr;
@@ -4083,7 +4168,7 @@ ReparentEvent(
if (dispPtr->flags & TK_DISPLAY_WM_TRACING) {
printf("ReparentEvent: %s (%p) reparented to 0x%x, vRoot = 0x%x\n",
wmPtr->winPtr->pathName, wmPtr->winPtr,
- (unsigned int) reparentEventPtr->parent, (unsigned int) vRoot);
+ (unsigned) reparentEventPtr->parent, (unsigned) vRoot);
}
/*
@@ -4170,7 +4255,7 @@ ComputeReparentGeometry(
{
TkWindow *wrapperPtr = wmPtr->wrapperPtr;
int width, height, bd;
- unsigned int dummy;
+ unsigned dummy;
int xOffset, yOffset, x, y;
Window dummy2;
Status status;
@@ -4181,8 +4266,8 @@ ComputeReparentGeometry(
(void) XTranslateCoordinates(wrapperPtr->display, wrapperPtr->window,
wmPtr->reparent, 0, 0, &xOffset, &yOffset, &dummy2);
status = XGetGeometry(wrapperPtr->display, wmPtr->reparent,
- &dummy2, &x, &y, (unsigned int *) &width,
- (unsigned int *) &height, (unsigned int *) &bd, &dummy);
+ &dummy2, &x, &y, (unsigned *) &width, (unsigned *) &height,
+ (unsigned *) &bd, &dummy);
Tk_DeleteErrorHandler(handler);
if (status == 0) {
/*
@@ -4279,11 +4364,9 @@ PropertyEvent(
unsigned char *propertyValue = 0;
long maxLength = 1024;
- if (XGetWindowProperty(
- wrapperPtr->display, wrapperPtr->window, _NET_WM_STATE,
- 0l, maxLength, False, XA_ATOM,
+ if (GetWindowProperty(wrapperPtr, _NET_WM_STATE, maxLength, XA_ATOM,
&actualType, &actualFormat, &numItems, &bytesAfter,
- &propertyValue) == Success) {
+ &propertyValue)) {
CheckNetWmState(wmPtr, (Atom *) propertyValue, (int) numItems);
XFree(propertyValue);
}
@@ -4308,15 +4391,15 @@ PropertyEvent(
*----------------------------------------------------------------------
*/
-static const unsigned int WrapperEventMask =
- (StructureNotifyMask | PropertyChangeMask);
+static const unsigned WrapperEventMask =
+ (StructureNotifyMask | PropertyChangeMask);
static void
WrapperEventProc(
ClientData clientData, /* Information about toplevel window. */
XEvent *eventPtr) /* Event that just happened. */
{
- WmInfo *wmPtr = (WmInfo *) clientData;
+ WmInfo *wmPtr = clientData;
XEvent mapEvent;
TkDisplay *dispPtr = wmPtr->winPtr->dispPtr;
@@ -4403,10 +4486,11 @@ TopLevelReqProc(
Tk_Window tkwin) /* Information about window. */
{
TkWindow *winPtr = (TkWindow *) tkwin;
- WmInfo *wmPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
- if ((wmPtr = winPtr->wmInfoPtr) == NULL)
+ if (wmPtr == NULL) {
return;
+ }
if ((wmPtr->width >= 0) && (wmPtr->height >= 0)) {
/*
@@ -4426,7 +4510,7 @@ TopLevelReqProc(
wmPtr->flags |= WM_UPDATE_SIZE_HINTS;
if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) {
- Tcl_DoWhenIdle(UpdateGeometryInfo, (ClientData) winPtr);
+ Tcl_DoWhenIdle(UpdateGeometryInfo, winPtr);
wmPtr->flags |= WM_UPDATE_PENDING;
}
@@ -4465,7 +4549,7 @@ static void
UpdateGeometryInfo(
ClientData clientData) /* Pointer to the window's record. */
{
- register TkWindow *winPtr = (TkWindow *) clientData;
+ register TkWindow *winPtr = clientData;
register WmInfo *wmPtr = winPtr->wmInfoPtr;
int x, y, width, height, min, max;
unsigned long serial;
@@ -4583,7 +4667,7 @@ UpdateGeometryInfo(
if (((width != winPtr->changes.width)
|| (height != winPtr->changes.height))
&& (wmPtr->gridWin == NULL)
- && ((wmPtr->sizeHintsFlags & (PMinSize|PMaxSize)) == 0)) {
+ && !(wmPtr->sizeHintsFlags & (PMinSize|PMaxSize))) {
wmPtr->flags |= WM_UPDATE_SIZE_HINTS;
}
if (wmPtr->flags & WM_UPDATE_SIZE_HINTS) {
@@ -4594,7 +4678,7 @@ UpdateGeometryInfo(
* Reconfigure the wrapper if it isn't already configured correctly. A few
* tricky points:
*
- * 1. If the window is embeddedand the container is also in this process,
+ * 1. If the window is embedded and the container is also in this process,
* don't actually reconfigure the window; just pass the desired size on
* to the container. Also, zero out any position information, since
* embedded windows are not allowed to move.
@@ -4635,7 +4719,7 @@ UpdateGeometryInfo(
height += wmPtr->menuHeight;
if (wmPtr->flags & WM_MOVE_PENDING) {
if ((x + wmPtr->xInParent == winPtr->changes.x) &&
- (y + wmPtr->yInParent + wmPtr->menuHeight == winPtr->changes.y)
+ (y+wmPtr->yInParent+wmPtr->menuHeight == winPtr->changes.y)
&& (width == wmPtr->wrapperPtr->changes.width)
&& (height == wmPtr->wrapperPtr->changes.height)) {
/*
@@ -4841,10 +4925,8 @@ UpdateTitle(
Tcl_DStringValue(&ds));
Tcl_DStringFree(&ds);
- XChangeProperty(winPtr->display, wmPtr->wrapperPtr->window,
- Tk_InternAtom((Tk_Window) winPtr, "_NET_WM_NAME"),
- XA_UTF8_STRING, 8, PropModeReplace,
- (const unsigned char *) string, (signed int) strlen(string));
+ SetWindowProperty(wmPtr->wrapperPtr, "_NET_WM_NAME", XA_UTF8_STRING, 8,
+ string, strlen(string));
/*
* Set icon name:
@@ -4856,11 +4938,8 @@ UpdateTitle(
Tcl_DStringValue(&ds));
Tcl_DStringFree(&ds);
- XChangeProperty(winPtr->display, wmPtr->wrapperPtr->window,
- Tk_InternAtom((Tk_Window) winPtr, "_NET_WM_ICON_NAME"),
- XA_UTF8_STRING, 8, PropModeReplace,
- (const unsigned char *) wmPtr->iconName,
- (signed int) strlen(wmPtr->iconName));
+ SetWindowProperty(wmPtr->wrapperPtr, "_NET_WM_ICON_NAME",
+ XA_UTF8_STRING, 8, wmPtr->iconName, strlen(wmPtr->iconName));
}
}
@@ -4891,14 +4970,8 @@ UpdatePhotoIcon(
size = winPtr->dispPtr->iconDataSize;
}
if (data != NULL) {
- /*
- * Set icon:
- */
-
- XChangeProperty(winPtr->display, wmPtr->wrapperPtr->window,
- Tk_InternAtom((Tk_Window) winPtr, "_NET_WM_ICON"),
- XA_CARDINAL, 32, PropModeReplace,
- (unsigned char *) data, size);
+ SetWindowProperty(wmPtr->wrapperPtr, "_NET_WM_ICON", XA_CARDINAL, 32,
+ data, size);
}
}
@@ -5039,11 +5112,10 @@ UpdateNetWmState(
atoms[numAtoms++] = Tk_InternAtom(tkwin, "_NET_WM_STATE_FULLSCREEN");
}
- XChangeProperty(Tk_Display(tkwin), wmPtr->wrapperPtr->window,
- Tk_InternAtom(tkwin, "_NET_WM_STATE"), XA_ATOM, 32,
- PropModeReplace, (unsigned char *) atoms, numAtoms);
+ SetWindowProperty(wmPtr->wrapperPtr, "_NET_WM_STATE", XA_ATOM, 32, atoms,
+ numAtoms);
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -5158,8 +5230,8 @@ WaitForEvent(
XEvent *eventPtr) /* Place to store event. */
{
WaitRestrictInfo info;
- Tk_RestrictProc *oldRestrictProc;
- ClientData oldRestrictData;
+ Tk_RestrictProc *prevProc;
+ ClientData prevArg;
Tcl_Time timeout;
/*
@@ -5173,8 +5245,7 @@ WaitForEvent(
info.type = type;
info.eventPtr = eventPtr;
info.foundEvent = 0;
- oldRestrictProc = Tk_RestrictEvents(WaitRestrictProc, (ClientData) &info,
- &oldRestrictData);
+ prevProc = Tk_RestrictEvents(WaitRestrictProc, &info, &prevArg);
Tcl_GetTime(&timeout);
timeout.sec += 2;
@@ -5184,8 +5255,7 @@ WaitForEvent(
break;
}
}
- (void) Tk_RestrictEvents(oldRestrictProc, oldRestrictData,
- &oldRestrictData);
+ Tk_RestrictEvents(prevProc, prevArg, &prevArg);
if (info.foundEvent) {
return TCL_OK;
}
@@ -5218,7 +5288,7 @@ WaitRestrictProc(
ClientData clientData, /* Pointer to WaitRestrictInfo structure. */
XEvent *eventPtr) /* Event that is about to be handled. */
{
- WaitRestrictInfo *infoPtr = (WaitRestrictInfo *) clientData;
+ WaitRestrictInfo *infoPtr = clientData;
if (eventPtr->type == ReparentNotify) {
return TK_PROCESS_EVENT;
@@ -5343,25 +5413,26 @@ UpdateHints(
*
* SetNetWmType --
*
- * Set the extended window manager hints for a toplevel window
- * to the types provided. The specification states that this
- * may be a list of window types in preferred order. To permit
- * for future type definitions, the set of names is unconstrained
- * and names are converted to upper-case and appended to
- * "_NET_WM_WINDOW_TYPE_" before being converted to an Atom.
+ * Set the extended window manager hints for a toplevel window to the
+ * types provided. The specification states that this may be a list of
+ * window types in preferred order. To permit for future type
+ * definitions, the set of names is unconstrained and names are converted
+ * to upper-case and appended to "_NET_WM_WINDOW_TYPE_" before being
+ * converted to an Atom.
*
*----------------------------------------------------------------------
*/
static int
-SetNetWmType(TkWindow *winPtr, Tcl_Obj *typePtr)
+SetNetWmType(
+ TkWindow *winPtr,
+ Tcl_Obj *typePtr)
{
- Atom typeAtom, *atoms = NULL;
+ Atom *atoms = NULL;
WmInfo *wmPtr;
- TkWindow *wrapperPtr;
Tcl_Obj **objv;
int objc, n;
- Tk_Window tkwin = (Tk_Window)winPtr;
+ Tk_Window tkwin = (Tk_Window) winPtr;
Tcl_Interp *interp = Tk_Interp(tkwin);
if (TCL_OK != Tcl_ListObjGetElements(interp, typePtr, &objc, &objv)) {
@@ -5373,13 +5444,14 @@ SetNetWmType(TkWindow *winPtr, Tcl_Obj *typePtr)
}
if (objc > 0) {
- atoms = (Atom *)ckalloc(sizeof(Atom) * objc);
+ atoms = ckalloc(sizeof(Atom) * objc);
}
for (n = 0; n < objc; ++n) {
Tcl_DString ds, dsName;
int len;
char *name = Tcl_GetStringFromObj(objv[n], &len);
+
Tcl_UtfToUpper(name);
Tcl_UtfToExternalDString(NULL, name, len, &dsName);
Tcl_DStringInit(&ds);
@@ -5395,13 +5467,11 @@ SetNetWmType(TkWindow *winPtr, Tcl_Obj *typePtr)
if (wmPtr->wrapperPtr == NULL) {
CreateWrapper(wmPtr);
}
- wrapperPtr = wmPtr->wrapperPtr;
- typeAtom = Tk_InternAtom(tkwin, "_NET_WM_WINDOW_TYPE");
- XChangeProperty(Tk_Display(tkwin), wrapperPtr->window, typeAtom,
- XA_ATOM, 32, PropModeReplace, (unsigned char *) atoms, objc);
+ SetWindowProperty(wmPtr->wrapperPtr, "_NET_WM_WINDOW_TYPE", XA_ATOM, 32,
+ atoms, objc);
- ckfree((char *)atoms);
+ ckfree(atoms);
return TCL_OK;
}
@@ -5410,22 +5480,22 @@ SetNetWmType(TkWindow *winPtr, Tcl_Obj *typePtr)
*
* GetNetWmType --
*
- * Read the extended window manager type hint from a window
- * and return as a list of names suitable for use with
- * SetNetWmType.
+ * Read the extended window manager type hint from a window and return as
+ * a list of names suitable for use with SetNetWmType.
*
*----------------------------------------------------------------------
*/
static Tcl_Obj *
-GetNetWmType(TkWindow *winPtr)
+GetNetWmType(
+ TkWindow *winPtr)
{
Atom typeAtom, actualType, *atoms;
int actualFormat;
unsigned long n, count, bytesAfter;
unsigned char *propertyValue = NULL;
long maxLength = 1024;
- Tk_Window tkwin = (Tk_Window)winPtr;
+ Tk_Window tkwin = (Tk_Window) winPtr;
TkWindow *wrapperPtr;
Tcl_Obj *typePtr;
Tcl_Interp *interp;
@@ -5440,13 +5510,12 @@ GetNetWmType(TkWindow *winPtr)
wrapperPtr = winPtr->wmInfoPtr->wrapperPtr;
typeAtom = Tk_InternAtom(tkwin, "_NET_WM_WINDOW_TYPE");
- if (Success == XGetWindowProperty(wrapperPtr->display,
- wrapperPtr->window, typeAtom, 0L, maxLength, False,
- XA_ATOM, &actualType, &actualFormat, &count,
- &bytesAfter, &propertyValue)) {
- atoms = (Atom *)propertyValue;
+ if (GetWindowProperty(wrapperPtr, typeAtom, maxLength, XA_ATOM,
+ &actualType, &actualFormat, &count, &bytesAfter, &propertyValue)){
+ atoms = (Atom *) propertyValue;
for (n = 0; n < count; ++n) {
const char *name = Tk_GetAtomName(tkwin, atoms[n]);
+
if (strncmp("_NET_WM_WINDOW_TYPE_", name, 20) == 0) {
Tcl_ExternalToUtfDString(NULL, name+20, -1, &ds);
Tcl_UtfToLower(Tcl_DStringValue(&ds));
@@ -5483,7 +5552,7 @@ GetNetWmType(TkWindow *winPtr)
static int
ParseGeometry(
Tcl_Interp *interp, /* Used for error reporting. */
- char *string, /* String containing new geometry. Has the
+ const char *string, /* String containing new geometry. Has the
* standard form "=wxh+x+y". */
TkWindow *winPtr) /* Pointer to top-level window whose geometry
* is to be changed. */
@@ -5491,7 +5560,7 @@ ParseGeometry(
register WmInfo *wmPtr = winPtr->wmInfoPtr;
int x, y, width, height, flags;
char *end;
- register char *p = string;
+ register const char *p = string;
/*
* The leading "=" is optional.
@@ -5564,7 +5633,7 @@ ParseGeometry(
* them.
*/
- if ((wmPtr->sizeHintsFlags & (USPosition|PPosition)) == 0) {
+ if (!(wmPtr->sizeHintsFlags & (USPosition|PPosition))) {
wmPtr->sizeHintsFlags |= USPosition;
flags |= WM_UPDATE_SIZE_HINTS;
}
@@ -5584,13 +5653,15 @@ ParseGeometry(
wmPtr->flags = flags;
if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) {
- Tcl_DoWhenIdle(UpdateGeometryInfo, (ClientData) winPtr);
+ Tcl_DoWhenIdle(UpdateGeometryInfo, winPtr);
wmPtr->flags |= WM_UPDATE_PENDING;
}
return TCL_OK;
error:
- Tcl_AppendResult(interp, "bad geometry specifier \"", string, "\"", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "bad geometry specifier \"%s\"", string));
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "GEOMETRY", NULL);
return TCL_ERROR;
}
@@ -5916,7 +5987,7 @@ UpdateVRootGeometry(
{
TkWindow *winPtr = wmPtr->winPtr;
int bd;
- unsigned int dummy;
+ unsigned dummy;
Window dummy2;
Status status;
Tk_ErrorHandler handler;
@@ -5942,8 +6013,8 @@ UpdateVRootGeometry(
handler = Tk_CreateErrorHandler(winPtr->display, -1, -1, -1, NULL, NULL);
status = XGetGeometry(winPtr->display, wmPtr->vRoot,
&dummy2, &wmPtr->vRootX, &wmPtr->vRootY,
- (unsigned int *) &wmPtr->vRootWidth,
- (unsigned int *) &wmPtr->vRootHeight, (unsigned int *) &bd,
+ (unsigned *) &wmPtr->vRootWidth,
+ (unsigned *) &wmPtr->vRootHeight, (unsigned *) &bd,
&dummy);
if (winPtr->dispPtr->flags & TK_DISPLAY_WM_TRACING) {
printf("UpdateVRootGeometry: x = %d, y = %d, width = %d, ",
@@ -6061,7 +6132,7 @@ Tk_MoveToplevelWindow(
wmPtr->y = y;
wmPtr->flags |= WM_MOVE_PENDING;
wmPtr->flags &= ~(WM_NEGATIVE_X|WM_NEGATIVE_Y);
- if ((wmPtr->sizeHintsFlags & (USPosition|PPosition)) == 0) {
+ if (!(wmPtr->sizeHintsFlags & (USPosition|PPosition))) {
wmPtr->sizeHintsFlags |= USPosition;
wmPtr->flags |= WM_UPDATE_SIZE_HINTS;
}
@@ -6074,9 +6145,9 @@ Tk_MoveToplevelWindow(
if (!(wmPtr->flags & WM_NEVER_MAPPED)) {
if (wmPtr->flags & WM_UPDATE_PENDING) {
- Tcl_CancelIdleCall(UpdateGeometryInfo, (ClientData) winPtr);
+ Tcl_CancelIdleCall(UpdateGeometryInfo, winPtr);
}
- UpdateGeometryInfo((ClientData) winPtr);
+ UpdateGeometryInfo(winPtr);
}
}
@@ -6119,7 +6190,7 @@ UpdateWmProtocols(
protPtr = protPtr->nextPtr, count++) {
/* Empty loop body; we're just counting the handlers. */
}
- arrayPtr = (Atom *) ckalloc((unsigned) count * sizeof(Atom));
+ arrayPtr = ckalloc(count * sizeof(Atom));
deleteWindowAtom = Tk_InternAtom((Tk_Window) wmPtr->winPtr,
"WM_DELETE_WINDOW");
pingAtom = Tk_InternAtom((Tk_Window) wmPtr->winPtr, "_NET_WM_PING");
@@ -6132,11 +6203,9 @@ UpdateWmProtocols(
*(atomPtr++) = protPtr->protocol;
}
}
- XChangeProperty(wmPtr->winPtr->display, wmPtr->wrapperPtr->window,
- Tk_InternAtom((Tk_Window) wmPtr->winPtr, "WM_PROTOCOLS"),
- XA_ATOM, 32, PropModeReplace, (unsigned char *) arrayPtr,
- atomPtr-arrayPtr);
- ckfree((char *) arrayPtr);
+ SetWindowProperty(wmPtr->wrapperPtr, "WM_PROTOCOLS", XA_ATOM, 32,
+ arrayPtr, atomPtr-arrayPtr);
+ ckfree(arrayPtr);
}
/*
@@ -6166,7 +6235,7 @@ TkWmProtocolEventProc(
register ProtocolHandler *protPtr;
Atom protocol;
int result;
- CONST char *protocolName;
+ const char *protocolName;
Tcl_Interp *interp;
protocol = (Atom) eventPtr->xclient.data.l[0];
@@ -6203,19 +6272,18 @@ TkWmProtocolEventProc(
for (protPtr = wmPtr->protPtr; protPtr != NULL;
protPtr = protPtr->nextPtr) {
if (protocol == protPtr->protocol) {
- Tcl_Preserve((ClientData) protPtr);
+ Tcl_Preserve(protPtr);
interp = protPtr->interp;
- Tcl_Preserve((ClientData) interp);
+ Tcl_Preserve(interp);
result = Tcl_EvalEx(interp, protPtr->command, -1, TCL_EVAL_GLOBAL);
if (result != TCL_OK) {
- Tcl_AddErrorInfo(interp, "\n (command for \"");
- Tcl_AddErrorInfo(interp, protocolName);
- Tcl_AddErrorInfo(interp,
- "\" window manager protocol)");
- Tcl_BackgroundError(interp);
+ Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf(
+ "\n (command for \"%s\" window manager protocol)",
+ protocolName));
+ Tcl_BackgroundException(interp, result);
}
- Tcl_Release((ClientData) interp);
- Tcl_Release((ClientData) protPtr);
+ Tcl_Release(interp);
+ Tcl_Release(protPtr);
return;
}
}
@@ -6300,7 +6368,7 @@ TkWmStackorderToplevel(
{
Window dummy1, dummy2, vRoot;
Window *children;
- unsigned int numChildren, i;
+ unsigned numChildren, i;
TkWindow *childWinPtr, **windows, **window_ptr;
Tcl_HashTable table;
Tcl_HashEntry *hPtr;
@@ -6313,8 +6381,7 @@ TkWmStackorderToplevel(
Tcl_InitHashTable(&table, TCL_ONE_WORD_KEYS);
TkWmStackorderToplevelWrapperMap(parentPtr, parentPtr->display, &table);
- window_ptr = windows = (TkWindow **)
- ckalloc((table.numEntries+1) * sizeof(TkWindow *));
+ window_ptr = windows = ckalloc((table.numEntries+1) * sizeof(TkWindow *));
/*
* Special cases: If zero or one toplevels were mapped there is no need to
@@ -6327,7 +6394,7 @@ TkWmStackorderToplevel(
goto done;
case 1:
hPtr = Tcl_FirstHashEntry(&table, &search);
- windows[0] = (TkWindow *) Tcl_GetHashValue(hPtr);
+ windows[0] = Tcl_GetHashValue(hPtr);
windows[1] = NULL;
goto done;
}
@@ -6339,19 +6406,22 @@ TkWmStackorderToplevel(
if (XQueryTree(parentPtr->display, vRoot, &dummy1, &dummy2,
&children, &numChildren) == 0) {
- ckfree((char *) windows);
+ ckfree(windows);
windows = NULL;
} else {
for (i = 0; i < numChildren; i++) {
hPtr = Tcl_FindHashEntry(&table, (char *) children[i]);
if (hPtr != NULL) {
- childWinPtr = (TkWindow *) Tcl_GetHashValue(hPtr);
+ childWinPtr = Tcl_GetHashValue(hPtr);
*window_ptr++ = childWinPtr;
}
}
- /* ASSERT: window_ptr - windows == table.numEntries
+
+ /*
+ * ASSERT: window_ptr - windows == table.numEntries
* (#matched toplevel windows == #children) [Bug 1789819]
*/
+
*window_ptr = NULL;
if (numChildren) {
XFree((char *) children);
@@ -6389,7 +6459,7 @@ TkWmRestackToplevel(
* below *all* siblings. */
{
XWindowChanges changes;
- unsigned int mask;
+ unsigned mask;
TkWindow *wrapperPtr;
memset(&changes, 0, sizeof(XWindowChanges));
@@ -6515,7 +6585,7 @@ TkWmAddToColormapWindows(
* add the toplevel itself as the last element of the list.
*/
- newPtr = (Window *) ckalloc((unsigned) (count+2) * sizeof(Window));
+ newPtr = ckalloc((count+2) * sizeof(Window));
for (i = 0; i < count; i++) {
newPtr[i] = oldPtr[i];
}
@@ -6526,7 +6596,7 @@ TkWmAddToColormapWindows(
newPtr[count] = topPtr->window;
XSetWMColormapWindows(topPtr->display, wrapperPtr->window, newPtr,
count+1);
- ckfree((char *) newPtr);
+ ckfree(newPtr);
if (oldPtr != NULL) {
XFree((char *) oldPtr);
}
@@ -6656,7 +6726,7 @@ TkGetPointerCoords(
WmInfo *wmPtr;
Window w, root, child;
int rootX, rootY;
- unsigned int mask;
+ unsigned mask;
wmPtr = winPtr->wmInfoPtr;
@@ -6772,8 +6842,8 @@ TkSetTransientFor(Tk_Window tkwin, Tk_Window parent)
*
* TkpMakeMenuWindow --
*
- * Configure the window to be either a pull-down (or pop-up) menu, or as
- * a toplevel (torn-off) menu or palette.
+ * Configure the window to be either a pull-down menu, a pop-up menu, or
+ * as a toplevel (torn-off) menu or palette.
*
* Results:
* None.
@@ -6787,11 +6857,14 @@ TkSetTransientFor(Tk_Window tkwin, Tk_Window parent)
void
TkpMakeMenuWindow(
Tk_Window tkwin, /* New window. */
- int transient) /* 1 means menu is only posted briefly as a
- * popup or pulldown or cascade. 0 means menu
- * is always visible, e.g. as a torn-off menu.
+ int typeFlag) /* TK_MAKE_MENU_DROPDOWN means menu is only
+ * posted briefly as a pulldown or cascade,
+ * TK_MAKE_MENU_POPUP means it is a popup.
+ * TK_MAKE_MENU_TEAROFF means menu is always
+ * visible, e.g. as a torn-off menu.
* Determines whether save_under and
- * override_redirect should be set. */
+ * override_redirect should be set, plus how
+ * to flag it for the window manager. */
{
WmInfo *wmPtr;
XSetWindowAttributes atts;
@@ -6806,15 +6879,19 @@ TkpMakeMenuWindow(
CreateWrapper(wmPtr);
}
wrapperPtr = wmPtr->wrapperPtr;
- if (transient) {
- atts.override_redirect = True;
- atts.save_under = True;
- typeObj = Tcl_NewStringObj("dropdown_menu", -1);
- } else {
+ if (typeFlag == TK_MAKE_MENU_TEAROFF) {
atts.override_redirect = False;
atts.save_under = False;
typeObj = Tcl_NewStringObj("menu", -1);
- TkSetTransientFor(tkwin, None);
+ TkSetTransientFor(tkwin, NULL);
+ } else {
+ atts.override_redirect = True;
+ atts.save_under = True;
+ if (typeFlag == TK_MAKE_MENU_DROPDOWN) {
+ typeObj = Tcl_NewStringObj("dropdown_menu", -1);
+ } else {
+ typeObj = Tcl_NewStringObj("popup_menu", -1);
+ }
}
SetNetWmType((TkWindow *)tkwin, typeObj);
@@ -6927,7 +7004,7 @@ CreateWrapper(
*/
Tk_CreateEventHandler((Tk_Window) wmPtr->wrapperPtr,
- WrapperEventMask, WrapperEventProc, (ClientData) wmPtr);
+ WrapperEventMask, WrapperEventProc, wmPtr);
}
/*
@@ -6996,9 +7073,13 @@ TkUnixSetMenubar(
Tk_Window parent;
TkWindow *menubarPtr = (TkWindow *) menubar;
- /* Could be a Frame (i.e. not a toplevel) */
- if (wmPtr == NULL)
+ /*
+ * Could be a Frame (i.e. not a toplevel).
+ */
+
+ if (wmPtr == NULL) {
return;
+ }
if (wmPtr->menubar != NULL) {
/*
@@ -7020,7 +7101,7 @@ TkUnixSetMenubar(
Tk_WindowId(wmPtr->menubar), Tk_WindowId(parent), 0, 0);
}
Tk_DeleteEventHandler(wmPtr->menubar, StructureNotifyMask,
- MenubarDestroyProc, (ClientData) wmPtr->menubar);
+ MenubarDestroyProc, wmPtr->menubar);
Tk_ManageGeometry(wmPtr->menubar, NULL, NULL);
}
@@ -7046,14 +7127,14 @@ TkUnixSetMenubar(
menubarPtr->wmInfoPtr = wmPtr;
Tk_MoveResizeWindow(menubar, 0, 0, Tk_Width(tkwin), wmPtr->menuHeight);
Tk_MapWindow(menubar);
- Tk_CreateEventHandler(menubar, StructureNotifyMask, MenubarDestroyProc,
- (ClientData) menubar);
- Tk_ManageGeometry(menubar, &menubarMgrType, (ClientData) wmPtr);
+ Tk_CreateEventHandler(menubar, StructureNotifyMask,
+ MenubarDestroyProc, menubar);
+ Tk_ManageGeometry(menubar, &menubarMgrType, wmPtr);
menubarPtr->flags |= TK_REPARENTED;
}
wmPtr->flags |= WM_UPDATE_SIZE_HINTS;
if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) {
- Tcl_DoWhenIdle(UpdateGeometryInfo, (ClientData) tkwin);
+ Tcl_DoWhenIdle(UpdateGeometryInfo, tkwin);
wmPtr->flags |= WM_UPDATE_PENDING;
}
}
@@ -7092,7 +7173,7 @@ MenubarDestroyProc(
wmPtr->menuHeight = 0;
wmPtr->flags |= WM_UPDATE_SIZE_HINTS;
if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) {
- Tcl_DoWhenIdle(UpdateGeometryInfo, (ClientData) wmPtr->winPtr);
+ Tcl_DoWhenIdle(UpdateGeometryInfo, wmPtr->winPtr);
wmPtr->flags |= WM_UPDATE_PENDING;
}
}
@@ -7120,7 +7201,7 @@ MenubarReqProc(
* for tkwin's toplevel. */
Tk_Window tkwin) /* Handle for menubar window. */
{
- WmInfo *wmPtr = (WmInfo *) clientData;
+ WmInfo *wmPtr = clientData;
wmPtr->menuHeight = Tk_ReqHeight(tkwin);
if (wmPtr->menuHeight <= 0) {
@@ -7128,7 +7209,7 @@ MenubarReqProc(
}
wmPtr->flags |= WM_UPDATE_SIZE_HINTS;
if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) {
- Tcl_DoWhenIdle(UpdateGeometryInfo, (ClientData) wmPtr->winPtr);
+ Tcl_DoWhenIdle(UpdateGeometryInfo, wmPtr->winPtr);
wmPtr->flags |= WM_UPDATE_PENDING;
}
}
@@ -7202,8 +7283,8 @@ UpdateCommand(
* entire DString is done.
*/
- cmdArgv = (char **) ckalloc(sizeof(char *) * wmPtr->cmdArgc);
- offsets = (int *) ckalloc(sizeof(int) * wmPtr->cmdArgc);
+ cmdArgv = ckalloc(sizeof(char *) * wmPtr->cmdArgc);
+ offsets = ckalloc(sizeof(int) * wmPtr->cmdArgc);
Tcl_DStringInit(&cmds);
for (i = 0; i < wmPtr->cmdArgc; i++) {
Tcl_UtfToExternalDString(NULL, wmPtr->cmdArgv[i], -1, &ds);
@@ -7220,8 +7301,8 @@ UpdateCommand(
XSetCommand(winPtr->display, wmPtr->wrapperPtr->window,
cmdArgv, wmPtr->cmdArgc);
Tcl_DStringFree(&cmds);
- ckfree((char *) cmdArgv);
- ckfree((char *) offsets);
+ ckfree(cmdArgv);
+ ckfree(offsets);
}
/*
@@ -7294,22 +7375,21 @@ TkpWmSetState(
*
* RemapWindows
*
- * Adjust parent/child relation ships of
- * the given window hierarchy.
+ * Adjust parent/child relationships of the given window hierarchy.
*
* Results:
- * none
+ * None
*
* Side effects:
- * keeps windowing system (X11) happy
+ * Keeps windowing system (X11) happy
*
*----------------------------------------------------------------------
*/
static void
-RemapWindows(winPtr, parentPtr)
- TkWindow *winPtr;
- TkWindow *parentPtr;
+RemapWindows(
+ TkWindow *winPtr,
+ TkWindow *parentPtr)
{
XWindowAttributes win_attr;
@@ -7317,7 +7397,7 @@ RemapWindows(winPtr, parentPtr)
XGetWindowAttributes(winPtr->display, winPtr->window, &win_attr);
if (parentPtr == NULL) {
XReparentWindow(winPtr->display, winPtr->window,
- XRootWindow(winPtr->display, winPtr->screenNum),
+ XRootWindow(winPtr->display, winPtr->screenNum),
win_attr.x, win_attr.y);
} else if (parentPtr->window) {
XReparentWindow(parentPtr->display, winPtr->window,
diff --git a/unix/tkUnixXId.c b/unix/tkUnixXId.c
index ca2eb33..819b7aa 100644
--- a/unix/tkUnixXId.c
+++ b/unix/tkUnixXId.c
@@ -1,15 +1,6 @@
/*
* tkUnixXId.c --
*
- * This file provides a replacement function for the default X resource
- * allocator (_XAllocID). The problem with the default allocator is that
- * it never re-uses ids, which causes long-lived applications to crash
- * when X resource identifiers wrap around. The replacement functions in
- * this file re-use old identifiers to prevent this problem.
- *
- * The code in this file is based on similar implementations by
- * George C. Kaplan and Michael Hoegeman.
- *
* Copyright (c) 1993 The Regents of the University of California.
* Copyright (c) 1994-1997 Sun Microsystems, Inc.
*
@@ -17,170 +8,8 @@
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
-/*
- * The definition below is needed on some systems so that we can access the
- * resource_alloc field of Display structures in order to replace the resource
- * allocator.
- */
-
-#define XLIB_ILLEGAL_ACCESS 1
-
#include "tkUnixInt.h"
-/*
- * A structure of the following type is used to hold one or more available
- * resource identifiers. There is a list of these structures for each display.
- */
-
-#define IDS_PER_STACK 10
-typedef struct TkIdStack {
- XID ids[IDS_PER_STACK]; /* Array of free identifiers. */
- int numUsed; /* Indicates how many of the entries in ids
- * are currently in use. */
- TkDisplay *dispPtr; /* Display to which ids belong. */
- struct TkIdStack *nextPtr; /* Next bunch of free identifiers for the same
- * display. */
-} TkIdStack;
-
-/*
- * Forward declarations for functions defined in this file:
- */
-
-static XID AllocXId(Display *display);
-static Tk_RestrictAction CheckRestrictProc(ClientData clientData,
- XEvent *eventPtr);
-static void WindowIdCleanup(ClientData clientData);
-static void WindowIdCleanup2(ClientData clientData);
-
-/*
- *----------------------------------------------------------------------
- *
- * TkInitXId --
- *
- * This function is called to initialize the id allocator for a given
- * display.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The official allocator for the display is set up to be AllocXId.
- *
- *----------------------------------------------------------------------
- */
-
-void
-TkInitXId(
- TkDisplay *dispPtr) /* Tk's information about the display. */
-{
- dispPtr->idStackPtr = NULL;
- dispPtr->defaultAllocProc = (XID (*) (Display *display))
- dispPtr->display->resource_alloc;
- dispPtr->display->resource_alloc = AllocXId;
- dispPtr->windowStackPtr = NULL;
- dispPtr->idCleanupScheduled = (Tcl_TimerToken) 0;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkFreeXId --
- *
- * This function is called to free resources for the id allocator for a
- * given display.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Frees the id and window stack pools.
- *
- *----------------------------------------------------------------------
- */
-
-void
-TkFreeXId(
- TkDisplay *dispPtr) /* Tk's information about the display. */
-{
- TkIdStack *stackPtr, *freePtr;
-
- if (dispPtr->idCleanupScheduled) {
- Tcl_DeleteTimerHandler(dispPtr->idCleanupScheduled);
- }
-
- for (stackPtr = dispPtr->idStackPtr; stackPtr != NULL; ) {
- freePtr = stackPtr;
- stackPtr = stackPtr->nextPtr;
- ckfree((char *) freePtr);
- }
- dispPtr->idStackPtr = NULL;
-
- for (stackPtr = dispPtr->windowStackPtr; stackPtr != NULL; ) {
- freePtr = stackPtr;
- stackPtr = stackPtr->nextPtr;
- ckfree((char *) freePtr);
- }
- dispPtr->windowStackPtr = NULL;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * AllocXId --
- *
- * This function is invoked by Xlib as the resource allocator for a
- * display.
- *
- * Results:
- * The return value is an X resource identifier that isn't currently in
- * use.
- *
- * Side effects:
- * The identifier is removed from the stack of free identifiers, if it
- * was previously on the stack.
- *
- *----------------------------------------------------------------------
- */
-
-static XID
-AllocXId(
- Display *display) /* Display for which to allocate. */
-{
- TkDisplay *dispPtr;
- TkIdStack *stackPtr;
-
- /*
- * Find Tk's information about the display.
- */
-
- dispPtr = TkGetDisplay(display);
-
- /*
- * If the topmost chunk on the stack is empty then free it. Then check for
- * a free id on the stack and return it if it exists.
- */
-
- stackPtr = dispPtr->idStackPtr;
- if (stackPtr != NULL) {
- while (stackPtr->numUsed == 0) {
- dispPtr->idStackPtr = stackPtr->nextPtr;
- ckfree((char *) stackPtr);
- stackPtr = dispPtr->idStackPtr;
- if (stackPtr == NULL) {
- goto defAlloc;
- }
- }
- stackPtr->numUsed--;
- return stackPtr->ids[stackPtr->numUsed];
- }
-
- /*
- * No free ids in the stack: just get one from the default allocator.
- */
-
- defAlloc:
- return (*dispPtr->defaultAllocProc)(display);
-}
/*
*----------------------------------------------------------------------
@@ -205,268 +34,15 @@ Tk_FreeXId(
Display *display, /* Display for which xid was allocated. */
XID xid) /* Identifier that is no longer in use. */
{
- TkDisplay *dispPtr;
- TkIdStack *stackPtr;
-
- /*
- * Find Tk's information about the display.
- */
-
- dispPtr = TkGetDisplay(display);
-
- /*
- * Add a new chunk to the stack if the current chunk is full.
- */
-
- stackPtr = dispPtr->idStackPtr;
- if ((stackPtr == NULL) || (stackPtr->numUsed >= IDS_PER_STACK)) {
- stackPtr = (TkIdStack *) ckalloc(sizeof(TkIdStack));
- stackPtr->numUsed = 0;
- stackPtr->dispPtr = dispPtr;
- stackPtr->nextPtr = dispPtr->idStackPtr;
- dispPtr->idStackPtr = stackPtr;
- }
-
- /*
- * Add the id to the current chunk.
- */
-
- stackPtr->ids[stackPtr->numUsed] = xid;
- stackPtr->numUsed++;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkFreeWindowId --
- *
- * This function is invoked instead of TkFreeXId for window ids. See
- * below for the reason why.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The id given by w will eventually be freed, so that it can be reused
- * for other resources.
- *
- * Design:
- * Freeing window ids is very tricky because there could still be events
- * pending for a window in the event queue (or even in the server) at the
- * time the window is destroyed. If the window id were to get reused
- * immediately for another window, old events could "drop in" on the new
- * window, causing unexpected behavior.
- *
- * Thus we have to wait to re-use a window id until we know that there
- * are no events left for it. Right now this is done in two steps. First,
- * we wait until we know that the server has seen the XDestroyWindow
- * request, so we can be sure that it won't generate more events for the
- * window and that any existing events are in our queue. Second, we make
- * sure that there are no events whatsoever in our queue (this is
- * conservative but safe).
- *
- * The first step is done by remembering the request id of the
- * XDestroyWindow request and using LastKnownRequestProcessed to see what
- * events the server has processed. If multiple windows get destroyed at
- * about the same time, we just remember the most recent request number
- * for any of them (again, conservative but safe).
- *
- * There are a few other complications as well. When Tk destroys a
- * sub-tree of windows, it only issues a single XDestroyWindow call, at
- * the very end for the root of the subtree. We can't free any of the
- * window ids until the final XDestroyWindow call. To make sure that this
- * happens, we have to keep track of deletions in progress, hence the
- * need for the "destroyCount" field of the display.
- *
- * One final problem. Some servers, like Sun X11/News servers still seem
- * to have problems with ids getting reused too quickly. I'm not
- * completely sure why this is a problem, but delaying the recycling of
- * ids appears to eliminate it. Therefore, we wait an additional few
- * seconds, even after "the coast is clear" before reusing the ids.
- *
- *----------------------------------------------------------------------
- */
-
-void
-TkFreeWindowId(
- TkDisplay *dispPtr, /* Display that w belongs to. */
- Window w) /* X identifier for window on dispPtr. */
-{
- TkIdStack *stackPtr;
-
- /*
- * Put the window id on a separate stack of window ids, rather than the
- * main stack, so it won't get reused right away. Add a new chunk to the
- * stack if the current chunk is full.
- */
-
- stackPtr = dispPtr->windowStackPtr;
- if ((stackPtr == NULL) || (stackPtr->numUsed >= IDS_PER_STACK)) {
- stackPtr = (TkIdStack *) ckalloc(sizeof(TkIdStack));
- stackPtr->numUsed = 0;
- stackPtr->dispPtr = dispPtr;
- stackPtr->nextPtr = dispPtr->windowStackPtr;
- dispPtr->windowStackPtr = stackPtr;
- }
-
- /*
- * Add the id to the current chunk.
- */
-
- stackPtr->ids[stackPtr->numUsed] = w;
- stackPtr->numUsed++;
-
- /*
- * Schedule a call to WindowIdCleanup if one isn't already scheduled.
- */
-
- if (!dispPtr->idCleanupScheduled) {
- dispPtr->idCleanupScheduled = Tcl_CreateTimerHandler(100,
- WindowIdCleanup, (ClientData) dispPtr);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * WindowIdCleanup --
- *
- * See if we can now free up all the accumulated ids of deleted windows.
- *
- * Results:
- * None.
- *
- * Side effects:
- * If it's safe to move the window ids back to the main free list, we
- * schedule this to happen after a few mores seconds of delay. If it's
- * not safe to move them yet, a timer handler gets invoked to try again
- * later.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-WindowIdCleanup(
- ClientData clientData) /* Pointer to TkDisplay for display */
-{
- TkDisplay *dispPtr = (TkDisplay *) clientData;
- int anyEvents, delta;
- Tk_RestrictProc *oldProc;
- ClientData oldData;
- static Tcl_Time timeout = {0, 0};
-
- dispPtr->idCleanupScheduled = (Tcl_TimerToken) 0;
-
- /*
- * See if it's safe to recycle the window ids. It's safe if:
- * (a) no deletions are in progress.
- * (b) the server has seen all of the requests up to the last
- * XDestroyWindow request.
- * (c) there are no events in the event queue; the only way to test for
- * this right now is to create a restrict proc that will filter the
- * events, then call Tcl_DoOneEvent to see if the function gets
- * invoked.
- */
-
- if (dispPtr->destroyCount > 0) {
- goto tryAgain;
- }
- delta = LastKnownRequestProcessed(dispPtr->display)
- - dispPtr->lastDestroyRequest;
- if (delta < 0) {
- XSync(dispPtr->display, False);
- }
- anyEvents = 0;
- oldProc = Tk_RestrictEvents(CheckRestrictProc, (ClientData) &anyEvents,
- &oldData);
- TkUnixDoOneXEvent(&timeout);
- Tk_RestrictEvents(oldProc, oldData, &oldData);
- if (anyEvents) {
- goto tryAgain;
- }
-
- /*
- * These ids look safe to recycle, but we still need to delay a bit more
- * (see comments for TkFreeWindowId). Schedule the final freeing.
- */
-
- if (dispPtr->windowStackPtr != NULL) {
- Tcl_CreateTimerHandler(5000, WindowIdCleanup2,
- (ClientData) dispPtr->windowStackPtr);
- dispPtr->windowStackPtr = NULL;
- }
- return;
-
/*
- * It's still not safe to free up the ids. Try again a bit later.
+ * This does nothing, because the XC-MISC extension takes care of
+ * freeing XIDs for us. It has been a standard X11 extension for
+ * about 15 years as of 2008. Keith Packard and another X.org
+ * developer suggested that we remove the previous code that used:
+ * #define XLIB_ILLEGAL_ACCESS.
*/
-
- tryAgain:
- dispPtr->idCleanupScheduled = Tcl_CreateTimerHandler(500,
- WindowIdCleanup, (ClientData) dispPtr);
}
-
-/*
- *----------------------------------------------------------------------
- *
- * WindowIdCleanup2 --
- *
- * This function is the last one in the chain that recycles window ids.
- * It takes all of the ids indicated by its argument and adds them back
- * to the main id free list.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Window ids get added to the main free list for their display.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-WindowIdCleanup2(
- ClientData clientData) /* Pointer to TkIdStack list. */
-{
- TkIdStack *stackPtr = (TkIdStack *) clientData;
- TkIdStack *lastPtr;
- lastPtr = stackPtr;
- while (lastPtr->nextPtr != NULL) {
- lastPtr = lastPtr->nextPtr;
- }
- lastPtr->nextPtr = stackPtr->dispPtr->idStackPtr;
- stackPtr->dispPtr->idStackPtr = stackPtr;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * CheckRestrictProc --
- *
- * This function is a restrict function, called by Tcl_DoOneEvent to
- * filter X events. All it does is to set a flag to indicate that there
- * are X events present.
- *
- * Results:
- * Sets the integer pointed to by the argument, then returns
- * TK_DEFER_EVENT.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-static Tk_RestrictAction
-CheckRestrictProc(
- ClientData clientData, /* Pointer to flag to set. */
- XEvent *eventPtr) /* Event to filter; not used. */
-{
- int *flag = (int *) clientData;
- *flag = 1;
- return TK_DEFER_EVENT;
-}
/*
*----------------------------------------------------------------------
@@ -522,44 +98,7 @@ Tk_FreePixmap(
XFreePixmap(display, pixmap);
Tk_FreeXId(display, (XID) pixmap);
}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkpWindowWasRecentlyDeleted --
- *
- * Checks whether the window was recently deleted. This is called by the
- * generic error handler to detect asynchronous notification of errors
- * due to operations by Tk on a window that was already deleted by the
- * server.
- *
- * Results:
- * 1 if the window was deleted recently, 0 otherwise.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-int
-TkpWindowWasRecentlyDeleted(
- Window win, /* The window to check for. */
- TkDisplay *dispPtr) /* The window belongs to this display. */
-{
- TkIdStack *stackPtr;
- int i;
- for (stackPtr = dispPtr->windowStackPtr; stackPtr != NULL;
- stackPtr = stackPtr->nextPtr) {
- for (i = 0; i < stackPtr->numUsed; i++) {
- if ((Window) stackPtr->ids[i] == win) {
- return 1;
- }
- }
- }
- return 0;
-}
/*
*----------------------------------------------------------------------
@@ -583,7 +122,7 @@ TkpWindowWasRecentlyDeleted(
int
TkpScanWindowId(
Tcl_Interp *interp,
- CONST char *string,
+ const char *string,
Window *idPtr)
{
int value;