diff options
Diffstat (limited to 'unix')
34 files changed, 2869 insertions, 2265 deletions
diff --git a/unix/Makefile.in b/unix/Makefile.in index 7dc543d..b88001d 100644 --- a/unix/Makefile.in +++ b/unix/Makefile.in @@ -50,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) @@ -155,7 +155,7 @@ AQUA_INCLUDES = -I$(MAC_OSX_DIR) -I$(XLIB_DIR) # Linker switch(es) to use to link with the X11 library archive (the # configure script will try to set this value automatically, but you # can override it). -X11_LIB_SWITCHES = @XLIBSW@ $(XFT_LIBS) +X11_LIB_SWITCHES = $(XFT_LIBS) @XLIBSW@ # To turn off the security checks that disallow incoming sends when @@ -200,16 +200,17 @@ SHELL = @SHELL@ # path. Targets that need an installed tclsh should not depend # on this variable. -BUILD_TCLSH = @BUILD_TCLSH@@EXEEXT@ +BUILD_TCLSH = @BUILD_TCLSH@ # TCL_EXE is the name of a tclsh executable that is available *BEFORE* # running make for the first time. Certain build targets (make genstubs) # need it to be available on the PATH. This executable should *NOT* be # required just to do a normal build although it can be required to run # make dist. This variable is set to "" if no tclsh is available. +EXE_SUFFIX = @EXEEXT@ TCL_EXE = @TCLSH_PROG@ -WISH_EXE = wish@EXEEXT@ -TKTEST_EXE = tktest@EXEEXT@ +WISH_EXE = wish${EXE_SUFFIX} +TKTEST_EXE = tktest${EXE_SUFFIX} # Tk used to let the configure script choose which program to use # for installing, but there are just too many different versions of @@ -219,16 +220,17 @@ TKTEST_EXE = tktest@EXEEXT@ INSTALL_STRIP_PROGRAM = -s INSTALL_STRIP_LIBRARY = -S -x -INSTALL = @srcdir@/install-sh -c +INSTALL = $(SHELL) $(UNIX_DIR)/install-sh -c INSTALL_PROGRAM = ${INSTALL} INSTALL_LIBRARY = ${INSTALL} INSTALL_DATA = ${INSTALL} -m 644 +INSTALL_DATA_DIR = ${INSTALL} -d -m 755 # The symbol below provides support for dynamic loading and shared # 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@ @@ -310,7 +312,7 @@ UNIX_DIR = $(TOP_DIR)/unix BMAP_DIR = $(TOP_DIR)/bitmaps TOOL_DIR = @TCL_SRC_DIR@/tools TEST_DIR = $(TOP_DIR)/tests -MAC_OSX_DIR = $(TOP_DIR)/macosx +MAC_OSX_DIR = $(TOP_DIR)/@MACOSX_SRC_DIR@ XLIB_DIR = $(TOP_DIR)/xlib #---------------------------------------------------------------- @@ -331,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@ @@ -353,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 @@ -362,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 \ @@ -377,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 @@ -395,7 +399,7 @@ AQUA_OBJS = tkMacOSXBitmap.o tkMacOSXButton.o tkMacOSXClipboard.o \ tkMacOSXMenubutton.o tkMacOSXMenus.o tkMacOSXMouseEvent.o \ tkMacOSXNotify.o tkMacOSXRegion.o tkMacOSXScrlbr.o tkMacOSXSend.o \ tkMacOSXSubwindows.o tkMacOSXWindowEvent.o \ - tkMacOSXWm.o tkMacOSXXStubs.o tkMacOSXCarbonEvents.o \ + tkMacOSXWm.o tkMacOSXXStubs.o @EXTRA_AQUA_OBJS@ \ tkFileFilter.o tkMacWinMenu.o tkPointer.o tkUnix3d.o tkUnixScale.o \ xcolors.o xdraw.o xgc.o ximage.o xutil.o \ ttkMacOSXTheme.o @@ -416,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 \ @@ -443,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 \ @@ -521,7 +527,7 @@ AQUA_SRCS = \ $(MAC_OSX_DIR)/tkMacOSXSend.c $(MAC_OSX_DIR)/tkMacOSXSubwindows.c \ $(MAC_OSX_DIR)/tkMacOSXTest.c $(MAC_OSX_DIR)/tkMacOSXWindowEvent.c \ $(MAC_OSX_DIR)/tkMacOSXWm.c $(MAC_OSX_DIR)/tkMacOSXXStubs.c \ - $(MAC_OSX_DIR)/tkMacOSXCarbonEvents.c \ + @EXTRA_AQUA_SRCS@ \ $(GENERIC_DIR)/tkFileFilter.c $(GENERIC_DIR)/tkMacWinMenu.c \ $(GENERIC_DIR)/tkPointer.c $(UNIX_DIR)/tkUnix3d.c \ $(UNIX_DIR)/tkUnixScale.c $(XLIB_DIR)/xcolors.c $(XLIB_DIR)/xdraw.c \ @@ -570,7 +576,6 @@ binaries: ${LIB_FILE} ${STUB_LIB_FILE} ${WISH_EXE} libraries: $(TOP_DIR)/doc/man.macros: - chmod +x $(UNIX_DIR)/install-sh $(INSTALL_DATA) @TCL_SRC_DIR@/doc/man.macros $(TOP_DIR)/doc/man.macros doc: $(TOP_DIR)/doc/man.macros @@ -623,18 +628,18 @@ ${WISH_EXE}: $(WISH_OBJS) $(TK_LIB_FILE) $(TK_STUB_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 @@ -690,7 +695,13 @@ valgrind: $(TKTEST_EXE) valgrindshell: $(TKTEST_EXE) $(SHELL_ENV) valgrind $(VALGRINDARGS) ./$(TKTEST_EXE) $(SCRIPT) -INSTALL_TARGETS = install-binaries install-libraries install-demos install-doc @EXTRA_INSTALL@ +INSTALL_BASE_TARGETS = install-binaries install-libraries +INSTALL_DOC_TARGETS = install-doc +INSTALL_DEV_TARGETS = install-headers +INSTALL_DEMO_TARGETS = install-demos +INSTALL_EXTRA_TARGETS = @EXTRA_INSTALL@ +INSTALL_TARGETS = $(INSTALL_BASE_TARGETS) $(INSTALL_DOC_TARGETS) $(INSTALL_DEV_TARGETS) \ + $(INSTALL_DEMO_TARGETS) $(INSTALL_EXTRA_TARGETS) install: $(INSTALL_TARGETS) @@ -709,19 +720,15 @@ install-binaries: $(TK_LIB_FILE) $(TK_STUB_LIB_FILE) ${WISH_EXE} do \ if [ ! -d "$$i" ] ; then \ echo "Making directory $$i"; \ - mkdir -p "$$i"; \ - chmod 755 "$$i"; \ + $(INSTALL_DATA_DIR) "$$i"; \ else true; \ fi; \ done; - @if test ! -x $(SRC_DIR)/install-sh; then \ - chmod +x $(SRC_DIR)/install-sh; \ - fi @if test "x$(TK_SHARED_BUILD)" = "x1"; then \ 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 $(TCLVERSION)$(TCLPATCHL)}]} 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 join \$$dir $${relative}$(TK_LIB_FILE)] Tk]";\ @@ -739,11 +746,11 @@ install-binaries: $(TK_LIB_FILE) $(TK_STUB_LIB_FILE) ${WISH_EXE} @@INSTALL_LIB@ @chmod 555 "$(DLL_INSTALL_DIR)/$(LIB_FILE)" @if test -f "tk${MAJOR_VERSION}${MINOR_VERSION}.dll"; then \ - $(INSTALL_LIBRARY) "${TOP_DIR}/win/tk${MAJOR_VERSION}${MINOR_VERSION}.dll" "$(DLL_INSTALL_DIR)";\ + $(INSTALL_LIBRARY) "tk${MAJOR_VERSION}${MINOR_VERSION}.dll" "$(DLL_INSTALL_DIR)";\ chmod 555 "$(DLL_INSTALL_DIR)/tk${MAJOR_VERSION}${MINOR_VERSION}.dll";\ fi - @echo "Installing ${WISH_EXE} as $(BIN_INSTALL_DIR)/wish$(VERSION)@EXEEXT@" - @$(INSTALL_PROGRAM) ${WISH_EXE} "$(BIN_INSTALL_DIR)/wish$(VERSION)@EXEEXT@" + @echo "Installing ${WISH_EXE} as $(BIN_INSTALL_DIR)/wish$(VERSION)${EXE_SUFFIX}" + @$(INSTALL_PROGRAM) ${WISH_EXE} "$(BIN_INSTALL_DIR)/wish$(VERSION)${EXE_SUFFIX}" @echo "Installing tkConfig.sh to $(CONFIG_INSTALL_DIR)/" @$(INSTALL_DATA) tkConfig.sh "$(CONFIG_INSTALL_DIR)/tkConfig.sh" @if test "$(STUB_LIB_FILE)" != "" ; then \ @@ -751,54 +758,41 @@ install-binaries: $(TK_LIB_FILE) $(TK_STUB_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 - @if test "$(@TK_WINDOWINGSYSTEM@_XLIB_HDRS)" != ""; then \ - XLIB_INCLUDE_INSTALL_DIR="$(INCLUDE_INSTALL_DIR)/X11"; fi; \ - for i in "$(INCLUDE_INSTALL_DIR)" "$${XLIB_INCLUDE_INSTALL_DIR}" \ - "$(SCRIPT_INSTALL_DIR)" "$(SCRIPT_INSTALL_DIR)/images" \ + @for i in "$(SCRIPT_INSTALL_DIR)" "$(SCRIPT_INSTALL_DIR)/images" \ "$(SCRIPT_INSTALL_DIR)/msgs" "$(SCRIPT_INSTALL_DIR)/ttk"; \ do \ if [ -n "$$i" -a ! -d "$$i" ] ; then \ echo "Making directory $$i"; \ - mkdir -p "$$i"; \ - chmod 755 "$$i"; \ + $(INSTALL_DATA_DIR) "$$i"; \ else true; \ fi; \ done; - @if test ! -x $(SRC_DIR)/install-sh; then \ - chmod +x $(SRC_DIR)/install-sh; \ - fi - @echo "Installing header files"; - @for i in $(PUBLIC_HDRS); \ - do \ - $(INSTALL_DATA) $$i "$(INCLUDE_INSTALL_DIR)"; \ - done; - @list='$(@TK_WINDOWINGSYSTEM@_XLIB_HDRS)'; for i in $$list ; \ - do \ - $(INSTALL_DATA) $$i "$(INCLUDE_INSTALL_DIR)/X11"; \ - done; - @echo "Installing library files to $(SCRIPT_INSTALL_DIR)"; - @for i in $(TOP_DIR)/library/*.tcl \ - $(TOP_DIR)/library/tclIndex $(UNIX_DIR)/tkAppInit.c; \ + @echo "Installing library files to $(SCRIPT_INSTALL_DIR)/"; + @for i in $(TOP_DIR)/library/*.tcl $(TOP_DIR)/library/tclIndex \ + $(UNIX_DIR)/tkAppInit.c; \ do \ $(INSTALL_DATA) $$i "$(SCRIPT_INSTALL_DIR)"; \ done; - @echo "Installing library ttk directory"; + @echo "Installing library ttk files to $(SCRIPT_INSTALL_DIR)/ttk/"; @for i in $(TOP_DIR)/library/ttk/*.tcl; \ do \ if [ -f $$i ] ; then \ $(INSTALL_DATA) $$i "$(SCRIPT_INSTALL_DIR)/ttk"; \ fi; \ done; - @echo "Installing library images directory"; + @echo "Installing library image files to $(SCRIPT_INSTALL_DIR)/images/"; @for i in $(TOP_DIR)/library/images/*; \ do \ if [ -f $$i ] ; then \ $(INSTALL_DATA) $$i "$(SCRIPT_INSTALL_DIR)/images"; \ fi; \ done; - @echo "Installing translation directory"; + @echo "Installing message catalog files to $(SCRIPT_INSTALL_DIR)/msgs/"; @for i in $(TOP_DIR)/library/msgs/*.msg; \ do \ if [ -f $$i ] ; then \ @@ -807,16 +801,15 @@ install-libraries: libraries done; install-demos: - @for i in "$(DEMO_INSTALL_DIR)" "$(DEMO_INSTALL_DIR)/images" ; \ + @for i in "$(DEMO_INSTALL_DIR)" "$(DEMO_INSTALL_DIR)"/images ; \ do \ if [ ! -d "$$i" ] ; then \ echo "Making directory $$i"; \ - mkdir -p "$$i"; \ - chmod 755 "$$i"; \ + $(INSTALL_DATA_DIR) "$$i"; \ else true; \ fi; \ done; - @echo "Installing demos to $(DEMO_INSTALL_DIR)/"; + @echo "Installing demo files to $(DEMO_INSTALL_DIR)/"; @for i in $(TOP_DIR)/library/demos/*; \ do \ if [ -f $$i ] ; then \ @@ -832,7 +825,7 @@ install-demos: chmod 755 "$(DEMO_INSTALL_DIR)/$$i"; \ fi; \ done; - @echo "Installing demo images"; + @echo "Installing demo images to $(DEMO_INSTALL_DIR)/images/"; @for i in $(TOP_DIR)/library/demos/images/*; \ do \ if [ -f $$i ] ; then \ @@ -845,41 +838,55 @@ install-doc: do \ if [ ! -d "$$i" ] ; then \ echo "Making directory $$i"; \ - mkdir -p "$$i"; \ - chmod 755 "$$i"; \ + $(INSTALL_DATA_DIR) "$$i"; \ else true; \ fi; \ done; - @echo "Installing and cross-linking top-level (.1) docs"; + @echo "Installing and cross-linking top-level (.1) docs to $(MAN1_INSTALL_DIR)/"; @for i in $(TOP_DIR)/doc/*.1; do \ $(SHELL) $(UNIX_DIR)/installManPage $(MAN_FLAGS) $$i "$(MAN1_INSTALL_DIR)"; \ done - - @echo "Installing and cross-linking C API (.3) docs"; + @echo "Installing and cross-linking C API (.3) docs to $(MAN3_INSTALL_DIR)/"; @for i in $(TOP_DIR)/doc/*.3; do \ $(SHELL) $(UNIX_DIR)/installManPage $(MAN_FLAGS) $$i "$(MAN3_INSTALL_DIR)"; \ done - - @echo "Installing and cross-linking command (.n) docs"; + @echo "Installing and cross-linking command (.n) docs to $(MANN_INSTALL_DIR)/"; @for i in $(TOP_DIR)/doc/*.n; do \ $(SHELL) $(UNIX_DIR)/installManPage $(MAN_FLAGS) $$i "$(MANN_INSTALL_DIR)"; \ done +install-headers: + @if test "$(@TK_WINDOWINGSYSTEM@_XLIB_HDRS)" != ""; then \ + XLIB_INCLUDE_INSTALL_DIR="$(INCLUDE_INSTALL_DIR)"/X11; fi; \ + for i in "$(INCLUDE_INSTALL_DIR)" "$${XLIB_INCLUDE_INSTALL_DIR}"; \ + do \ + if [ -n "$$i" -a ! -d "$$i" ] ; then \ + echo "Making directory $$i"; \ + $(INSTALL_DATA_DIR) "$$i"; \ + else true; \ + fi; \ + done; + @echo "Installing header files to $(INCLUDE_INSTALL_DIR)/"; + @for i in $(PUBLIC_HDRS); \ + do \ + $(INSTALL_DATA) $$i "$(INCLUDE_INSTALL_DIR)"; \ + done; + @list='$(@TK_WINDOWINGSYSTEM@_XLIB_HDRS)'; for i in $$list ; \ + do \ + $(INSTALL_DATA) $$i "$(INCLUDE_INSTALL_DIR)"/X11; \ + done; + # Optional target to install private headers -install-private-headers: libraries +install-private-headers: @for i in "$(PRIVATE_INCLUDE_INSTALL_DIR)"; \ do \ if [ ! -d "$$i" ] ; then \ echo "Making directory $$i"; \ - mkdir -p "$$i"; \ - chmod 755 "$$i"; \ + $(INSTALL_DATA_DIR) "$$i"; \ else true; \ fi; \ done; - @if test ! -x $(SRC_DIR)/install-sh; then \ - chmod +x $(SRC_DIR)/install-sh; \ - fi - @echo "Installing private header files"; + @echo "Installing private header files to $(PRIVATE_INCLUDE_INSTALL_DIR)/"; @for i in $(PRIVATE_HDRS); \ do \ $(INSTALL_DATA) $$i "$(PRIVATE_INCLUDE_INSTALL_DIR)"; \ @@ -899,7 +906,7 @@ clean: distclean: clean rm -rf Makefile config.status config.cache config.log tkConfig.sh \ - $(PACKAGE).* prototype tkConfig.h *.plist Tk.framework + tkConfig.h *.plist Tk.framework tk.pc depend: makedepend -- $(DEPEND_SWITCHES) -- $(SRCS) @@ -942,6 +949,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 @@ -1101,12 +1111,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 @@ -1223,9 +1239,6 @@ tkMacOSXBitmap.o: $(MAC_OSX_DIR)/tkMacOSXBitmap.c tkMacOSXButton.o: $(MAC_OSX_DIR)/tkMacOSXButton.c $(CC) -c $(CC_SWITCHES) $(MAC_OSX_DIR)/tkMacOSXButton.c -tkMacOSXCarbonEvents.o: $(MAC_OSX_DIR)/tkMacOSXCarbonEvents.c - $(CC) -c $(CC_SWITCHES) $(MAC_OSX_DIR)/tkMacOSXCarbonEvents.c - tkMacOSXClipboard.o: $(MAC_OSX_DIR)/tkMacOSXClipboard.c $(CC) -c $(CC_SWITCHES) $(MAC_OSX_DIR)/tkMacOSXClipboard.c @@ -1314,6 +1327,9 @@ tkMacOSXWm.o: $(MAC_OSX_DIR)/tkMacOSXWm.c tkMacOSXXStubs.o: $(MAC_OSX_DIR)/tkMacOSXXStubs.c $(CC) -c $(CC_SWITCHES) $(MAC_OSX_DIR)/tkMacOSXXStubs.c +tkMacOSXCarbonEvents.o: $(TOP_DIR)/carbon/tkMacOSXCarbonEvents.c + $(CC) -c $(CC_SWITCHES) $(TOP_DIR)/carbon/tkMacOSXCarbonEvents.c + tkFileFilter.o: $(GENERIC_DIR)/tkFileFilter.c $(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tkFileFilter.c @@ -1526,7 +1542,7 @@ $(MAC_OSX_DIR)/configure: $(MAC_OSX_DIR)/configure.ac $(UNIX_DIR)/configure $(UNIX_DIR)/tkConfig.h.in: $(MAC_OSX_DIR)/configure cd $(MAC_OSX_DIR); autoheader; touch $@ -dist: $(UNIX_DIR)/configure $(UNIX_DIR)/tkConfig.h.in $(MAC_OSX_DIR)/configure genstubs +dist: $(UNIX_DIR)/configure $(UNIX_DIR)/tkConfig.h.in $(UNIX_DIR)/tk.pc.in $(MAC_OSX_DIR)/configure genstubs rm -rf $(DISTDIR) mkdir -p $(DISTDIR)/unix cp -p $(UNIX_DIR)/*.c $(UNIX_DIR)/*.h $(DISTDIR)/unix @@ -1536,7 +1552,7 @@ dist: $(UNIX_DIR)/configure $(UNIX_DIR)/tkConfig.h.in $(MAC_OSX_DIR)/configure $(UNIX_DIR)/aclocal.m4 $(UNIX_DIR)/tcl.m4 \ $(UNIX_DIR)/tkConfig.sh.in $(TCLDIR)/unix/install-sh \ $(UNIX_DIR)/README $(UNIX_DIR)/installManPage \ - $(UNIX_DIR)/tkConfig.h.in $(DISTDIR)/unix + $(UNIX_DIR)/tkConfig.h.in $(UNIX_DIR)/tk.pc.in $(DISTDIR)/unix chmod 775 $(DISTDIR)/unix/configure $(DISTDIR)/unix/configure.in chmod +x $(DISTDIR)/unix/install-sh mkdir $(DISTDIR)/bitmaps @@ -1578,19 +1594,35 @@ dist: $(UNIX_DIR)/configure $(UNIX_DIR)/tkConfig.h.in $(MAC_OSX_DIR)/configure $(TCL_EXE) $(TOOL_DIR)/eolFix.tcl -crlf $(DISTDIR)/win/rc/*.rc $(TCL_EXE) $(TOOL_DIR)/eolFix.tcl -crlf $(DISTDIR)/win/wish.exe.manifest.in mkdir $(DISTDIR)/macosx - cp -p $(MAC_OSX_DIR)/GNUmakefile $(MAC_OSX_DIR)/README \ - $(MAC_OSX_DIR)/Wish.icns $(MAC_OSX_DIR)/*.[chr] \ - $(MAC_OSX_DIR)/*.in $(MAC_OSX_DIR)/*.ac \ - $(MAC_OSX_DIR)/*.xcconfig $(MAC_OSX_DIR)/configure \ + cp -p $(TOP_DIR)/macosx/GNUmakefile $(TOP_DIR)/macosx/README \ + $(TOP_DIR)/macosx/*.icns $(TOP_DIR)/macosx/*.tiff \ + $(TOP_DIR)/macosx/*.[ch] $(TOP_DIR)/macosx/*.in \ + $(TOP_DIR)/macosx/*.ac $(TOP_DIR)/macosx/*.xcconfig \ + $(TOP_DIR)/macosx/*.sdef $(TOP_DIR)/macosx/configure \ $(DISTDIR)/macosx cp -p $(TOP_DIR)/license.terms $(DISTDIR)/macosx - mkdir $(DISTDIR)/macosx/Wish.pbproj - cp -p $(MAC_OSX_DIR)/Wish.pbproj/*.pbx* $(DISTDIR)/macosx/Wish.pbproj - mkdir $(DISTDIR)/macosx/Wish.xcode - cp -p $(MAC_OSX_DIR)/Wish.xcode/*.pbx* $(DISTDIR)/macosx/Wish.xcode - mkdir $(DISTDIR)/macosx/Wish.xcodeproj - cp -p $(MAC_OSX_DIR)/Wish.xcodeproj/*.pbx* \ - $(DISTDIR)/macosx/Wish.xcodeproj + mkdir $(DISTDIR)/macosx/Tk.xcode + cp -p $(TOP_DIR)/macosx/Tk.xcode/project.pbxproj \ + $(TOP_DIR)/macosx/Tk.xcode/default.pbxuser \ + $(DISTDIR)/macosx/Tk.xcode + mkdir $(DISTDIR)/macosx/Tk.xcodeproj + cp -p $(TOP_DIR)/macosx/Tk.xcodeproj/project.pbxproj \ + $(TOP_DIR)/macosx/Tk.xcodeproj/default.pbxuser \ + $(DISTDIR)/macosx/Tk.xcodeproj + mkdir $(DISTDIR)/carbon + cp -p $(TOP_DIR)/carbon/GNUmakefile $(TOP_DIR)/carbon/README \ + $(TOP_DIR)/carbon/Wish.icns $(TOP_DIR)/carbon/*.[chr] \ + $(TOP_DIR)/carbon/*.in $(TOP_DIR)/carbon/*.ac \ + $(TOP_DIR)/carbon/*.xcconfig $(DISTDIR)/carbon + cp -p $(TOP_DIR)/license.terms $(DISTDIR)/carbon + mkdir $(DISTDIR)/carbon/Wish.xcode + cp -p $(TOP_DIR)/carbon/Wish.xcode/project.pbxproj \ + $(TOP_DIR)/carbon/Wish.xcode/default.pbxuser \ + $(DISTDIR)/carbon/Wish.xcode + mkdir $(DISTDIR)/carbon/Wish.xcodeproj + cp -p $(TOP_DIR)/carbon/Wish.xcodeproj/project.pbxproj \ + $(TOP_DIR)/carbon/Wish.xcodeproj/default.pbxuser \ + $(DISTDIR)/carbon/Wish.xcodeproj mkdir $(DISTDIR)/compat cp -p $(TOP_DIR)/license.terms $(TCLDIR)/compat/unistd.h \ $(TCLDIR)/compat/stdlib.h $(TCLDIR)/compat/limits.h \ @@ -1679,88 +1711,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 67e7cb3..c6209ac 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 WISH_BUILD_LIB_SPEC TCL_STUB_FLAGS XINCLUDES XLIBSW LOCALES TK_WINDOWINGSYSTEM TK_PKG_DIR TK_LIBRARY 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 WISH_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 EXTRA_AQUA_OBJS EXTRA_AQUA_SRCS CFBUNDLELOCALIZATIONS MACOSX_SRC_DIR 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) @@ -861,7 +861,8 @@ Optional Features: --enable-load allow dynamic loading and "load" command (default: on) --enable-symbols build with debugging symbols (default: off) - --enable-aqua use Aqua windowingsystem on Mac OS X (default: off) + --enable-aqua=yes|carbon|no + use Aqua windowingsystem on Mac OS X (default: no) --enable-xss use XScreenSaver for activity timer (default: on) --enable-xft use freetype/fontconfig/xft (default: on) --enable-framework package shared libraries in MacOSX frameworks @@ -981,7 +982,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 +996,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 +1336,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=".11" +TK_MINOR_VERSION=6 +TK_PATCH_LEVEL="b2" VERSION=${TK_VERSION} LOCALES="cs da de el en en_gb eo es fr hu it nl pl pt ru sv" @@ -1585,16 +1586,6 @@ echo "${ECHO_T}$BUILD_TCLSH" >&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;} - { (exit 1); exit 1; }; } -fi - #------------------------------------------------------------------------ # Handle the --prefix=... option #------------------------------------------------------------------------ @@ -2615,9 +2606,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 +3606,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 @@ -3959,9 +4021,6 @@ echo "$as_me: WARNING: Don't know how to find pthread lib on your system - you m # Does the pthread-implementation provide # 'pthread_attr_setstacksize' ? - ac_saved_libs=$LIBS - LIBS="$LIBS $THREADS_LIBS" - for ac_func in pthread_attr_setstacksize do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` @@ -4063,385 +4122,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 fi @@ -4462,8 +4142,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 @@ -4636,6 +4316,80 @@ if test "${tcl_cv_cc_visibility_hidden+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else + if test "$SHARED_BUILD" = 1; then + + hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -fvisibility=hidden -Werror" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +#if !defined(__GNUC__) || __GNUC__ < 4 +#error visibility hidden is not supported for this compiler +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + tcl_cv_cc_visibility_hidden=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +tcl_cv_cc_visibility_hidden=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS=$hold_cflags + +else + + tcl_cv_cc_visibility_hidden=no + +fi + + +fi +echo "$as_me:$LINENO: result: $tcl_cv_cc_visibility_hidden" >&5 +echo "${ECHO_T}$tcl_cv_cc_visibility_hidden" >&6 + if test $tcl_cv_cc_visibility_hidden = yes; then + + CFLAGS="$CFLAGS -fvisibility=hidden" + +cat >>confdefs.h <<\_ACEOF +#define MODULE_SCOPE extern +_ACEOF + + +else + hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -Werror" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -4686,10 +4440,7 @@ fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext CFLAGS=$hold_cflags -fi -echo "$as_me:$LINENO: result: $tcl_cv_cc_visibility_hidden" >&5 -echo "${ECHO_T}$tcl_cv_cc_visibility_hidden" >&6 - if test $tcl_cv_cc_visibility_hidden = yes; then + if test $tcl_cv_cc_visibility_hidden = yes; then cat >>confdefs.h <<\_ACEOF @@ -4700,6 +4451,9 @@ _ACEOF fi +fi + + # Step 0.d: Disable -rpath support? echo "$as_me:$LINENO: checking if rpath support is requested" >&5 @@ -4826,10 +4580,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 - @@ -4848,13 +4598,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 @@ -4941,6 +4694,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 @@ -5212,7 +4969,7 @@ echo "$as_me: error: ${CC} is not a cygwin compiler." >&2;} echo "$as_me: error: CYGWIN compile is only supported with --enable-threads" >&2;} { (exit 1); exit 1; }; } fi - if test "x${SHARED_BUILD}" = "x1" -a ! -f "../win/tcldde13.dll" -a ! -f "../win/tk85.dll"; then + if test "x${SHARED_BUILD}" = "x1" -a ! -f "../win/tcldde14.dll" -a ! -f "../win/tk86.dll"; then { { echo "$as_me:$LINENO: error: Please configure and make the ../win directory first." >&5 echo "$as_me: error: Please configure and make the ../win directory first." >&2;} { (exit 1); exit 1; }; } @@ -5416,6 +5173,10 @@ fi SHLIB_LD='${CC} -shared' LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} +else + + CFLAGS="$CFLAGS -z" + fi @@ -5548,6 +5309,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}' @@ -5561,6 +5330,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}' @@ -5594,6 +5371,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}' @@ -6295,6 +6080,7 @@ cat >>confdefs.h <<\_ACEOF #define MODULE_SCOPE __private_extern__ _ACEOF + tcl_cv_cc_visibility_hidden=yes fi @@ -7167,6 +6953,22 @@ fi fi + if test "$tcl_cv_cc_visibility_hidden" != yes; then + + +cat >>confdefs.h <<\_ACEOF +#define MODULE_SCOPE extern +_ACEOF + + +cat >>confdefs.h <<\_ACEOF +#define NO_VIZ +_ACEOF + + +fi + + if test "$SHARED_LIB_SUFFIX" = ""; then SHARED_LIB_SUFFIX='${VERSION}${SHLIB_SUFFIX}' @@ -7182,7 +6984,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)"' @@ -8403,7 +8205,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" @@ -9516,6 +9318,7 @@ fi # On Mac OS X, we can build either with X11 or with Aqua #-------------------------------------------------------------------- +MACOSX_SRC_DIR=macosx if test "`uname -s`" = "Darwin" ; then echo "$as_me:$LINENO: checking whether to use Aqua" >&5 echo $ECHO_N "checking whether to use Aqua... $ECHO_C" >&6 @@ -9526,12 +9329,19 @@ if test "${enable_aqua+set}" = set; then else tk_aqua=no fi; - if test $tk_aqua = yes; then - if test $tcl_corefoundation = no; then - { echo "$as_me:$LINENO: WARNING: Aqua can only be used when CoreFoundation is available" >&5 -echo "$as_me: WARNING: Aqua can only be used when CoreFoundation is available" >&2;} + if test $tk_aqua = yes -o $tk_aqua = cocoa; then + tk_aqua=yes + if test ! -d /System/Library/Frameworks/Cocoa.framework; then + { echo "$as_me:$LINENO: WARNING: Aqua can only be used when Cocoa is available" >&5 +echo "$as_me: WARNING: Aqua can only be used when Cocoa is available" >&2;} + tk_aqua=no + fi + if test "`uname -r | awk -F. '{print $1}'`" -lt 9; then + { echo "$as_me:$LINENO: WARNING: Aqua requires Mac OS X 10.5 or later" >&5 +echo "$as_me: WARNING: Aqua requires Mac OS X 10.5 or later" >&2;} tk_aqua=no fi + elif test $tk_aqua = carbon; then if test ! -d /System/Library/Frameworks/Carbon.framework; then { echo "$as_me:$LINENO: WARNING: Aqua can only be used when Carbon is available" >&5 echo "$as_me: WARNING: Aqua can only be used when Carbon is available" >&2;} @@ -9542,9 +9352,22 @@ echo "$as_me: WARNING: Aqua can only be used when Carbon is available" >&2;} echo "$as_me: WARNING: Aqua requires Mac OS X 10.2 or later" >&2;} tk_aqua=no fi + else + tk_aqua=no + fi + if test $tk_aqua != no -a $tcl_corefoundation = no; then + { echo "$as_me:$LINENO: WARNING: Aqua can only be used when CoreFoundation is available" >&5 +echo "$as_me: WARNING: Aqua can only be used when CoreFoundation is available" >&2;} + tk_aqua=no fi - echo "$as_me:$LINENO: result: $tk_aqua" >&5 + if test $tk_aqua = carbon; then + MACOSX_SRC_DIR=carbon + echo "$as_me:$LINENO: result: yes (deprecated legacy Carbon implementation)" >&5 +echo "${ECHO_T}yes (deprecated legacy Carbon implementation)" >&6 + else + echo "$as_me:$LINENO: result: $tk_aqua" >&5 echo "${ECHO_T}$tk_aqua" >&6 + fi if test "$fat_32_64" = yes; then if test $tk_aqua = no; then echo "$as_me:$LINENO: checking for 64-bit X11" >&5 @@ -9613,7 +9436,7 @@ echo "${ECHO_T}$tcl_cv_lib_x11_64" >&6 fi # remove 64-bit arch flags from CFLAGS et al. for combined 32 & 64 bit # fat builds if configuration does not support 64-bit. - if test $tk_aqua = yes -o "$tcl_cv_lib_x11_64" = no; then + if test $tk_aqua = carbon -o "$tcl_cv_lib_x11_64" = no; then { echo "$as_me:$LINENO: Removing 64-bit architectures from compiler & linker flags" >&5 echo "$as_me: Removing 64-bit architectures from compiler & linker flags" >&6;} for v in CFLAGS CPPFLAGS LDFLAGS; do @@ -9984,14 +9807,19 @@ else tk_aqua=no fi -if test $tk_aqua = yes; then +if test $tk_aqua != no; then + if test $tk_aqua = yes; then + LIBS="$LIBS -framework Cocoa -framework Carbon -framework IOKit" + EXTRA_CC_SWITCHES='-std=gnu99 -x objective-c -fobjc-gc' + else + LIBS="$LIBS -framework Carbon -framework IOKit" + CFLAGS="$CFLAGS -fpascal-strings" + fi cat >>confdefs.h <<\_ACEOF #define MAC_OSX_TK 1 _ACEOF - LIBS="$LIBS -framework Carbon -framework IOKit" - CFLAGS="$CFLAGS -fpascal-strings" TK_WINDOWINGSYSTEM=AQUA if test -n "${enable_symbols}" -a "${enable_symbols}" != no; then @@ -10464,7 +10292,9 @@ fi #-------------------------------------------------------------------- if test "x${x_libraries}" != "x"; then + if test "x${x_libraries}" != "xNONE"; then LIB_RUNTIME_DIR="${LIB_RUNTIME_DIR}:${x_libraries}" + fi fi if test "${TCL_LD_SEARCH_FLAGS}" = '-L${LIB_RUNTIME_DIR}'; then LIB_RUNTIME_DIR=`echo ${LIB_RUNTIME_DIR} |sed -e 's/:/ -L/g'` @@ -11323,12 +11153,15 @@ echo "${ECHO_T}static library" >&6 fi TK_SHLIB_LD_EXTRAS="-compatibility_version ${TK_VERSION} -current_version ${TK_VERSION}`echo ${TK_PATCH_LEVEL} | awk '{match($0, "\\\.[0-9]+"); print substr($0,RSTART,RLENGTH)}'`" - TK_SHLIB_LD_EXTRAS="${TK_SHLIB_LD_EXTRAS}"' -install_name "${DYLIB_INSTALL_DIR}/${TK_LIB_FILE}" -unexported_symbols_list $$(f=$(TCL_STUB_LIB_FILE).E && nm -gjp "$(TCL_BIN_DIR)/$(TCL_STUB_LIB_FILE)" | grep ^_[^_] > $$f && echo $$f)' + TK_SHLIB_LD_EXTRAS="${TK_SHLIB_LD_EXTRAS}"' -install_name "${DYLIB_INSTALL_DIR}/${TK_LIB_FILE}"' + if test $tk_aqua = yes; then + TK_SHLIB_LD_EXTRAS="${TK_SHLIB_LD_EXTRAS}"' -unexported_symbols_list $$(f=$(TK_LIB_FILE).E && nm -gp tkMacOSX*.o 2>/dev/null | awk "/^[0-9a-f]+ . \.objc/ {print \$$3}" > $$f && echo $$f)' + fi echo "$LDFLAGS " | grep -q -- '-prebind ' && TK_SHLIB_LD_EXTRAS="${TK_SHLIB_LD_EXTRAS}"' -seg1addr 0xb000000' TK_SHLIB_LD_EXTRAS="${TK_SHLIB_LD_EXTRAS}"' -sectcreate __TEXT __info_plist Tk-Info.plist' EXTRA_WISH_LIBS='-sectcreate __TEXT __info_plist Wish-Info.plist' EXTRA_APP_CC_SWITCHES="${EXTRA_APP_CC_SWITCHES}"' -mdynamic-no-pic' - ac_config_files="$ac_config_files Tk-Info.plist:../macosx/Tk-Info.plist.in Wish-Info.plist:../macosx/Wish-Info.plist.in" + ac_config_files="$ac_config_files Tk-Info.plist:../${MACOSX_SRC_DIR}/Tk-Info.plist.in Wish-Info.plist:../${MACOSX_SRC_DIR}/Wish-Info.plist.in" for l in ${LOCALES}; do CFBUNDLELOCALIZATIONS="${CFBUNDLELOCALIZATIONS}<string>$l</string>"; done TK_YEAR="`date +%Y`" @@ -11366,13 +11199,22 @@ _ACEOF 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"' - if test $tk_aqua = yes; then - EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing ${TK_RSRC_FILE} to $(LIB_INSTALL_DIR)/Resources" && mkdir -p "$(LIB_INSTALL_DIR)/Resources" && $(INSTALL_DATA) "${TK_RSRC_FILE}" "$(LIB_INSTALL_DIR)/Resources"' + if test $tk_aqua != no; then + 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' + else + EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing ${TK_RSRC_FILE} to $(LIB_INSTALL_DIR)/Resources" && mkdir -p "$(LIB_INSTALL_DIR)/Resources" && $(INSTALL_DATA) "${TK_RSRC_FILE}" "$(LIB_INSTALL_DIR)/Resources"' + fi 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)"' 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" && $(INSTALL_DATA) "$(MAC_OSX_DIR)/Wish.icns" "$(BIN_INSTALL_DIR)/../Resources"' - EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing ${WISH_RSRC_FILE} to $(BIN_INSTALL_DIR)/../Resources" && $(INSTALL_DATA) "${WISH_RSRC_FILE}" "$(BIN_INSTALL_DIR)/../Resources"' + EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Wish.icns to $(BIN_INSTALL_DIR)/../Resources" && mkdir -p "$(BIN_INSTALL_DIR)/../Resources"' + if test $tk_aqua = yes; then + 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"' + else + EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && $(INSTALL_DATA) "$(MAC_OSX_DIR)/Wish.icns" "$(BIN_INSTALL_DIR)/../Resources" && echo "Installing ${WISH_RSRC_FILE} to $(BIN_INSTALL_DIR)/../Resources" && $(INSTALL_DATA) "${WISH_RSRC_FILE}" "$(BIN_INSTALL_DIR)/../Resources"' + fi fi EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Finalizing Tk.framework" && rm -f "$(LIB_INSTALL_DIR)/../Current" && ln -s "$(VERSION)" "$(LIB_INSTALL_DIR)/../Current" && for f in "$(LIB_FILE)" tkConfig.sh Resources Headers PrivateHeaders; do rm -f "$(LIB_INSTALL_DIR)/../../$$f" && ln -s "Versions/Current/$$f" "$(LIB_INSTALL_DIR)/../.."; done && f="$(STUB_LIB_FILE)" && rm -f "$(LIB_INSTALL_DIR)/../../$$f" && ln -s "Versions/$(VERSION)/$$f" "$(LIB_INSTALL_DIR)/../.."' # Don't use AC_DEFINE for the following as the framework version define @@ -11381,6 +11223,9 @@ _ACEOF # into CFLAGS as it should not go into tkConfig.sh 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' + fi # libdir must be a fully qualified path and not ${exec_prefix}/lib eval libdir="$libdir" if test "${TCL_LIB_VERSIONS_OK}" = "ok"; then @@ -11389,7 +11234,7 @@ else TK_LIB_FLAG="-ltk`echo ${TK_VERSION} | tr -d .`" fi TK_BUILD_LIB_SPEC="-L`pwd | sed -e 's/ /\\\\ /g'` ${TK_LIB_FLAG}" - if test "${ac_cv_cygwin}" = "yes" -a "$SHARED_BUILD" = "1"; then + if test "${ac_cv_cygwin}" = "yes" -a "$SHARED_BUILD" = "1"; then WISH_BUILD_LIB_SPEC="-L\$(TOP_DIR)/win -ltk${TK_MAJOR_VERSION}${TK_MINOR_VERSION} \${TCL_LIB_SPEC}" else WISH_BUILD_LIB_SPEC="-L`pwd | sed -e 's/ /\\\\ /g'` ${TK_LIB_FLAG} \${WISH_LIBS}" @@ -11397,8 +11242,10 @@ else TK_LIB_SPEC="-L${libdir} ${TK_LIB_FLAG}" fi -# Support for building the Aqua resource files -if test $tk_aqua = yes; then +# Extra bits for legacy Aqua Carbon build (carbon sources and resource files) +if test $tk_aqua = carbon; then + EXTRA_AQUA_OBJS='tkMacOSXCarbonEvents.o' + EXTRA_AQUA_SRCS='$(TOP_DIR)/carbon/tkMacOSXCarbonEvents.c' LIB_RSRC_FILE='${TK_RSRC_FILE}' APP_RSRC_FILE='${WISH_RSRC_FILE}' REZ=/Developer/Tools/Rez @@ -11493,7 +11340,11 @@ TK_SHARED_BUILD=${SHARED_BUILD} - ac_config_files="$ac_config_files Makefile:../unix/Makefile.in tkConfig.sh:../unix/tkConfig.sh.in" + + + + + ac_config_files="$ac_config_files Makefile:../unix/Makefile.in tkConfig.sh:../unix/tkConfig.sh.in tk.pc:../unix/tk.pc.in" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure @@ -11889,7 +11740,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 @@ -11947,7 +11798,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'`\\" @@ -12056,10 +11907,11 @@ for ac_config_target in $ac_config_targets do case "$ac_config_target" in # Handling of arguments. - "Tk-Info.plist" ) CONFIG_FILES="$CONFIG_FILES Tk-Info.plist:../macosx/Tk-Info.plist.in" ;; - "Wish-Info.plist" ) CONFIG_FILES="$CONFIG_FILES Wish-Info.plist:../macosx/Wish-Info.plist.in" ;; + "Tk-Info.plist" ) CONFIG_FILES="$CONFIG_FILES Tk-Info.plist:../${MACOSX_SRC_DIR}/Tk-Info.plist.in" ;; + "Wish-Info.plist" ) CONFIG_FILES="$CONFIG_FILES Wish-Info.plist:../${MACOSX_SRC_DIR}/Wish-Info.plist.in" ;; "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile:../unix/Makefile.in" ;; "tkConfig.sh" ) CONFIG_FILES="$CONFIG_FILES tkConfig.sh:../unix/tkConfig.sh.in" ;; + "tk.pc" ) CONFIG_FILES="$CONFIG_FILES tk.pc:../unix/tk.pc.in" ;; "Tk.framework" ) CONFIG_COMMANDS="$CONFIG_COMMANDS Tk.framework" ;; *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 echo "$as_me: error: invalid argument: $ac_config_target" >&2;} @@ -12172,6 +12024,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 @@ -12199,7 +12052,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 @@ -12230,6 +12082,7 @@ s,@LOCALES@,$LOCALES,;t t s,@TK_WINDOWINGSYSTEM@,$TK_WINDOWINGSYSTEM,;t t s,@TK_PKG_DIR@,$TK_PKG_DIR,;t t s,@TK_LIBRARY@,$TK_LIBRARY,;t t +s,@LIB_RUNTIME_DIR@,$LIB_RUNTIME_DIR,;t t s,@PRIVATE_INCLUDE_DIR@,$PRIVATE_INCLUDE_DIR,;t t s,@HTML_DIR@,$HTML_DIR,;t t s,@EXTRA_CC_SWITCHES@,$EXTRA_CC_SWITCHES,;t t @@ -12238,7 +12091,10 @@ s,@EXTRA_INSTALL@,$EXTRA_INSTALL,;t t s,@EXTRA_INSTALL_BINARIES@,$EXTRA_INSTALL_BINARIES,;t t s,@EXTRA_BUILD_HTML@,$EXTRA_BUILD_HTML,;t t s,@EXTRA_WISH_LIBS@,$EXTRA_WISH_LIBS,;t t +s,@EXTRA_AQUA_OBJS@,$EXTRA_AQUA_OBJS,;t t +s,@EXTRA_AQUA_SRCS@,$EXTRA_AQUA_SRCS,;t t s,@CFBUNDLELOCALIZATIONS@,$CFBUNDLELOCALIZATIONS,;t t +s,@MACOSX_SRC_DIR@,$MACOSX_SRC_DIR,;t t s,@TK_RSRC_FILE@,$TK_RSRC_FILE,;t t s,@WISH_RSRC_FILE@,$WISH_RSRC_FILE,;t t s,@LIB_RSRC_FILE@,$LIB_RSRC_FILE,;t t @@ -12598,7 +12454,7 @@ echo "$as_me: executing $ac_dest commands" >&6;} rm -rf $f && mkdir -p $f/$v/Resources && ln -s $v/$n $v/Resources $f && ln -s ../../../$n $f/$v && ln -s ../../../../$n-Info.plist $f/$v/Resources/Info.plist && - if test $tk_aqua = yes; then ln -s ../../../../$n.rsrc $f/$v/Resources; fi && + if test $tk_aqua != no; then ln -s ../../../../$n.rsrc $f/$v/Resources; fi && unset n f v ;; esac @@ -12634,3 +12490,4 @@ if test "$no_create" != yes; then $ac_cs_success || { (exit 1); exit 1; } fi + diff --git a/unix/configure.in b/unix/configure.in index a7bc887..5759e04 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=".11" +TK_MINOR_VERSION=6 +TK_PATCH_LEVEL="b2" VERSION=${TK_VERSION} LOCALES="cs da de el en en_gb eo es fr hu it nl pl pt ru sv" @@ -39,12 +39,6 @@ SC_LOAD_TCLCONFIG SC_PROG_TCLSH SC_BUILD_TCLSH -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}.]) -fi - #------------------------------------------------------------------------ # Handle the --prefix=... option #------------------------------------------------------------------------ @@ -76,6 +70,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 +147,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" @@ -265,17 +260,24 @@ fi # On Mac OS X, we can build either with X11 or with Aqua #-------------------------------------------------------------------- +MACOSX_SRC_DIR=macosx if test "`uname -s`" = "Darwin" ; then AC_MSG_CHECKING([whether to use Aqua]) AC_ARG_ENABLE(aqua, - AC_HELP_STRING([--enable-aqua], - [use Aqua windowingsystem on Mac OS X (default: off)]), + AC_HELP_STRING([--enable-aqua=yes|carbon|no], + [use Aqua windowingsystem on Mac OS X (default: no)]), [tk_aqua=$enableval], [tk_aqua=no]) - if test $tk_aqua = yes; then - if test $tcl_corefoundation = no; then - AC_MSG_WARN([Aqua can only be used when CoreFoundation is available]) + if test $tk_aqua = yes -o $tk_aqua = cocoa; then + tk_aqua=yes + if test ! -d /System/Library/Frameworks/Cocoa.framework; then + AC_MSG_WARN([Aqua can only be used when Cocoa is available]) + tk_aqua=no + fi + if test "`uname -r | awk -F. '{print [$]1}'`" -lt 9; then + AC_MSG_WARN([Aqua requires Mac OS X 10.5 or later]) tk_aqua=no fi + elif test $tk_aqua = carbon; then if test ! -d /System/Library/Frameworks/Carbon.framework; then AC_MSG_WARN([Aqua can only be used when Carbon is available]) tk_aqua=no @@ -284,8 +286,19 @@ if test "`uname -s`" = "Darwin" ; then AC_MSG_WARN([Aqua requires Mac OS X 10.2 or later]) tk_aqua=no fi + else + tk_aqua=no + fi + if test $tk_aqua != no -a $tcl_corefoundation = no; then + AC_MSG_WARN([Aqua can only be used when CoreFoundation is available]) + tk_aqua=no + fi + if test $tk_aqua = carbon; then + MACOSX_SRC_DIR=carbon + AC_MSG_RESULT([yes (deprecated legacy Carbon implementation)]) + else + AC_MSG_RESULT([$tk_aqua]) fi - AC_MSG_RESULT([$tk_aqua]) if test "$fat_32_64" = yes; then if test $tk_aqua = no; then AC_CACHE_CHECK([for 64-bit X11], tcl_cv_lib_x11_64, [ @@ -302,7 +315,7 @@ if test "`uname -s`" = "Darwin" ; then fi # remove 64-bit arch flags from CFLAGS et al. for combined 32 & 64 bit # fat builds if configuration does not support 64-bit. - if test $tk_aqua = yes -o "$tcl_cv_lib_x11_64" = no; then + if test $tk_aqua = carbon -o "$tcl_cv_lib_x11_64" = no; then AC_MSG_NOTICE([Removing 64-bit architectures from compiler & linker flags]) for v in CFLAGS CPPFLAGS LDFLAGS; do eval $v'="`echo "$'$v' "|sed -e "s/-arch ppc64 / /g" -e "s/-arch x86_64 / /g"`"' @@ -361,10 +374,15 @@ else tk_aqua=no fi -if test $tk_aqua = yes; then +if test $tk_aqua != no; then + if test $tk_aqua = yes; then + LIBS="$LIBS -framework Cocoa -framework Carbon -framework IOKit" + EXTRA_CC_SWITCHES='-std=gnu99 -x objective-c -fobjc-gc' + else + LIBS="$LIBS -framework Carbon -framework IOKit" + CFLAGS="$CFLAGS -fpascal-strings" + fi AC_DEFINE(MAC_OSX_TK, 1, [Are we building TkAqua?]) - LIBS="$LIBS -framework Carbon -framework IOKit" - CFLAGS="$CFLAGS -fpascal-strings" TK_WINDOWINGSYSTEM=AQUA if test -n "${enable_symbols}" -a "${enable_symbols}" != no; then AC_DEFINE(TK_MAC_DEBUG, 1, [Are TkAqua debug messages enabled?]) @@ -398,7 +416,9 @@ fi #-------------------------------------------------------------------- if test "x${x_libraries}" != "x"; then + if test "x${x_libraries}" != "xNONE"; then LIB_RUNTIME_DIR="${LIB_RUNTIME_DIR}:${x_libraries}" + fi fi if test "${TCL_LD_SEARCH_FLAGS}" = '-L${LIB_RUNTIME_DIR}'; then LIB_RUNTIME_DIR=`echo ${LIB_RUNTIME_DIR} |sed -e 's/:/ -L/g'` @@ -620,12 +640,15 @@ WISH_RSRC_FILE='wish$(VERSION).rsrc' if test "`uname -s`" = "Darwin" ; then SC_ENABLE_FRAMEWORK TK_SHLIB_LD_EXTRAS="-compatibility_version ${TK_VERSION} -current_version ${TK_VERSION}`echo ${TK_PATCH_LEVEL} | awk ['{match($0, "\\\.[0-9]+"); print substr($0,RSTART,RLENGTH)}']`" - TK_SHLIB_LD_EXTRAS="${TK_SHLIB_LD_EXTRAS}"' -install_name "${DYLIB_INSTALL_DIR}/${TK_LIB_FILE}" -unexported_symbols_list $$(f=$(TCL_STUB_LIB_FILE).E && nm -gjp "$(TCL_BIN_DIR)/$(TCL_STUB_LIB_FILE)" | grep ^_[[^_]] > $$f && echo $$f)' + TK_SHLIB_LD_EXTRAS="${TK_SHLIB_LD_EXTRAS}"' -install_name "${DYLIB_INSTALL_DIR}/${TK_LIB_FILE}"' + if test $tk_aqua = yes; then + TK_SHLIB_LD_EXTRAS="${TK_SHLIB_LD_EXTRAS}"' -unexported_symbols_list $$(f=$(TK_LIB_FILE).E && nm -gp tkMacOSX*.o 2>/dev/null | awk "/^[[0-9a-f]]+ . \.objc/ {print \$$3}" > $$f && echo $$f)' + fi echo "$LDFLAGS " | grep -q -- '-prebind ' && TK_SHLIB_LD_EXTRAS="${TK_SHLIB_LD_EXTRAS}"' -seg1addr 0xb000000' TK_SHLIB_LD_EXTRAS="${TK_SHLIB_LD_EXTRAS}"' -sectcreate __TEXT __info_plist Tk-Info.plist' EXTRA_WISH_LIBS='-sectcreate __TEXT __info_plist Wish-Info.plist' EXTRA_APP_CC_SWITCHES="${EXTRA_APP_CC_SWITCHES}"' -mdynamic-no-pic' - AC_CONFIG_FILES([Tk-Info.plist:../macosx/Tk-Info.plist.in Wish-Info.plist:../macosx/Wish-Info.plist.in]) + AC_CONFIG_FILES([Tk-Info.plist:../${MACOSX_SRC_DIR}/Tk-Info.plist.in Wish-Info.plist:../${MACOSX_SRC_DIR}/Wish-Info.plist.in]) for l in ${LOCALES}; do CFBUNDLELOCALIZATIONS="${CFBUNDLELOCALIZATIONS}<string>$l</string>"; done TK_YEAR="`date +%Y`" fi @@ -639,7 +662,7 @@ if test "$FRAMEWORK_BUILD" = "1" ; then rm -rf $f && mkdir -p $f/$v/Resources && ln -s $v/$n $v/Resources $f && ln -s ../../../$n $f/$v && ln -s ../../../../$n-Info.plist $f/$v/Resources/Info.plist && - if test $tk_aqua = yes; then ln -s ../../../../$n.rsrc $f/$v/Resources; fi && + if test $tk_aqua != no; then ln -s ../../../../$n.rsrc $f/$v/Resources; fi && unset n f v ], VERSION=${TK_VERSION} && tk_aqua=${tk_aqua}) LD_LIBRARY_PATH_VAR="DYLD_FRAMEWORK_PATH" @@ -664,13 +687,22 @@ if test "$FRAMEWORK_BUILD" = "1" ; then 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"' - if test $tk_aqua = yes; then - EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing ${TK_RSRC_FILE} to $(LIB_INSTALL_DIR)/Resources" && mkdir -p "$(LIB_INSTALL_DIR)/Resources" && $(INSTALL_DATA) "${TK_RSRC_FILE}" "$(LIB_INSTALL_DIR)/Resources"' + if test $tk_aqua != no; then + 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' + else + EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing ${TK_RSRC_FILE} to $(LIB_INSTALL_DIR)/Resources" && mkdir -p "$(LIB_INSTALL_DIR)/Resources" && $(INSTALL_DATA) "${TK_RSRC_FILE}" "$(LIB_INSTALL_DIR)/Resources"' + fi 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)"' 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" && $(INSTALL_DATA) "$(MAC_OSX_DIR)/Wish.icns" "$(BIN_INSTALL_DIR)/../Resources"' - EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing ${WISH_RSRC_FILE} to $(BIN_INSTALL_DIR)/../Resources" && $(INSTALL_DATA) "${WISH_RSRC_FILE}" "$(BIN_INSTALL_DIR)/../Resources"' + EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing Wish.icns to $(BIN_INSTALL_DIR)/../Resources" && mkdir -p "$(BIN_INSTALL_DIR)/../Resources"' + if test $tk_aqua = yes; then + 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"' + else + EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && $(INSTALL_DATA) "$(MAC_OSX_DIR)/Wish.icns" "$(BIN_INSTALL_DIR)/../Resources" && echo "Installing ${WISH_RSRC_FILE} to $(BIN_INSTALL_DIR)/../Resources" && $(INSTALL_DATA) "${WISH_RSRC_FILE}" "$(BIN_INSTALL_DIR)/../Resources"' + fi fi EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Finalizing Tk.framework" && rm -f "$(LIB_INSTALL_DIR)/../Current" && ln -s "$(VERSION)" "$(LIB_INSTALL_DIR)/../Current" && for f in "$(LIB_FILE)" tkConfig.sh Resources Headers PrivateHeaders; do rm -f "$(LIB_INSTALL_DIR)/../../$$f" && ln -s "Versions/Current/$$f" "$(LIB_INSTALL_DIR)/../.."; done && f="$(STUB_LIB_FILE)" && rm -f "$(LIB_INSTALL_DIR)/../../$$f" && ln -s "Versions/$(VERSION)/$$f" "$(LIB_INSTALL_DIR)/../.."' # Don't use AC_DEFINE for the following as the framework version define @@ -679,6 +711,9 @@ if test "$FRAMEWORK_BUILD" = "1" ; then # into CFLAGS as it should not go into tkConfig.sh 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' + fi # libdir must be a fully qualified path and not ${exec_prefix}/lib eval libdir="$libdir" if test "${TCL_LIB_VERSIONS_OK}" = "ok"; then @@ -687,7 +722,7 @@ else TK_LIB_FLAG="-ltk`echo ${TK_VERSION} | tr -d .`" fi TK_BUILD_LIB_SPEC="-L`pwd | sed -e 's/ /\\\\ /g'` ${TK_LIB_FLAG}" - if test "${ac_cv_cygwin}" = "yes" -a "$SHARED_BUILD" = "1"; then + if test "${ac_cv_cygwin}" = "yes" -a "$SHARED_BUILD" = "1"; then WISH_BUILD_LIB_SPEC="-L\$(TOP_DIR)/win -ltk${TK_MAJOR_VERSION}${TK_MINOR_VERSION} \${TCL_LIB_SPEC}" else WISH_BUILD_LIB_SPEC="-L`pwd | sed -e 's/ /\\\\ /g'` ${TK_LIB_FLAG} \${WISH_LIBS}" @@ -695,8 +730,10 @@ else TK_LIB_SPEC="-L${libdir} ${TK_LIB_FLAG}" fi -# Support for building the Aqua resource files -if test $tk_aqua = yes; then +# Extra bits for legacy Aqua Carbon build (carbon sources and resource files) +if test $tk_aqua = carbon; then + EXTRA_AQUA_OBJS='tkMacOSXCarbonEvents.o' + EXTRA_AQUA_SRCS='$(TOP_DIR)/carbon/tkMacOSXCarbonEvents.c' LIB_RSRC_FILE='${TK_RSRC_FILE}' APP_RSRC_FILE='${WISH_RSRC_FILE}' REZ=/Developer/Tools/Rez @@ -773,6 +810,7 @@ AC_SUBST(LOCALES) AC_SUBST(TK_WINDOWINGSYSTEM) AC_SUBST(TK_PKG_DIR) AC_SUBST(TK_LIBRARY) +AC_SUBST(LIB_RUNTIME_DIR) AC_SUBST(PRIVATE_INCLUDE_DIR) AC_SUBST(HTML_DIR) @@ -782,8 +820,11 @@ AC_SUBST(EXTRA_INSTALL) AC_SUBST(EXTRA_INSTALL_BINARIES) AC_SUBST(EXTRA_BUILD_HTML) AC_SUBST(EXTRA_WISH_LIBS) +AC_SUBST(EXTRA_AQUA_OBJS) +AC_SUBST(EXTRA_AQUA_SRCS) AC_SUBST(CFBUNDLELOCALIZATIONS) +AC_SUBST(MACOSX_SRC_DIR) AC_SUBST(TK_RSRC_FILE) AC_SUBST(WISH_RSRC_FILE) AC_SUBST(LIB_RSRC_FILE) @@ -794,5 +835,10 @@ AC_SUBST(REZ_FLAGS) AC_CONFIG_FILES([ Makefile:../unix/Makefile.in tkConfig.sh:../unix/tkConfig.sh.in + tk.pc:../unix/tk.pc.in ]) AC_OUTPUT + +dnl Local Variables: +dnl mode: autoconf +dnl End: diff --git a/unix/install-sh b/unix/install-sh index 1572b93..5975819 100755..100644 --- a/unix/install-sh +++ b/unix/install-sh @@ -1,122 +1,528 @@ #!/bin/sh +# install - install a program, script, or datafile + +scriptversion=2011-04-20.01; # UTC +# This originates from X11R5 (mit/util/scripts/install.sh), which was +# later released in X11R6 (xc/config/util/install.sh) with the +# following copyright and license. # -# install - install a program, script, or datafile -# This comes from X11R5; it is not part of GNU. +# Copyright (C) 1994 X Consortium +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- +# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +# Except as contained in this notice, the name of the X Consortium shall not +# be used in advertising or otherwise to promote the sale, use or other deal- +# ings in this Software without prior written authorization from the X Consor- +# tium. +# +# +# FSF changes to this file are in the public domain. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# `make' implicit rules from creating a file called install from it +# when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. -# +nl=' +' +IFS=" "" $nl" # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. -doit="${DOITPROG-}" +doit=${DOITPROG-} +if test -z "$doit"; then + doit_exec=exec +else + doit_exec=$doit +fi + +# Put in absolute file names if you don't have them in your path; +# or use environment vars. +chgrpprog=${CHGRPPROG-chgrp} +chmodprog=${CHMODPROG-chmod} +chownprog=${CHOWNPROG-chown} +cmpprog=${CMPPROG-cmp} +cpprog=${CPPROG-cp} +mkdirprog=${MKDIRPROG-mkdir} +mvprog=${MVPROG-mv} +rmprog=${RMPROG-rm} +stripprog=${STRIPPROG-strip} -# put in absolute paths if you don't have them in your path; or use env. vars. +posix_glob='?' +initialize_posix_glob=' + test "$posix_glob" != "?" || { + if (set -f) 2>/dev/null; then + posix_glob= + else + posix_glob=: + fi + } +' -mvprog="${MVPROG-mv}" -cpprog="${CPPROG-cp}" -chmodprog="${CHMODPROG-chmod}" -chownprog="${CHOWNPROG-chown}" -chgrpprog="${CHGRPPROG-chgrp}" -stripprog="${STRIPPROG-strip}" -rmprog="${RMPROG-rm}" +posix_mkdir= -instcmd="$mvprog" -chmodcmd="" -chowncmd="" -chgrpcmd="" -stripcmd="" +# Desired mode of installed file. +mode=0755 + +chgrpcmd= +chmodcmd=$chmodprog +chowncmd= +mvcmd=$mvprog rmcmd="$rmprog -f" -mvcmd="$mvprog" -src="" -dst="" - -while [ x"$1" != x ]; do - case $1 in - -c) instcmd="$cpprog" - shift - continue;; - - -m) chmodcmd="$chmodprog $2" - shift - shift - continue;; - - -o) chowncmd="$chownprog $2" - shift - shift - continue;; - - -g) chgrpcmd="$chgrpprog $2" - shift - shift - continue;; - - -s) stripcmd="$stripprog" - shift - continue;; - - -S) stripcmd="$stripprog $2" - shift - shift - continue;; - - *) if [ x"$src" = x ] - then - src=$1 - else - dst=$1 - fi - shift - continue;; - esac +stripcmd= + +src= +dst= +dir_arg= +dst_arg= + +copy_on_change=false +no_target_directory= + +usage="\ +Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE + or: $0 [OPTION]... SRCFILES... DIRECTORY + or: $0 [OPTION]... -t DIRECTORY SRCFILES... + or: $0 [OPTION]... -d DIRECTORIES... + +In the 1st form, copy SRCFILE to DSTFILE. +In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. +In the 4th, create DIRECTORIES. + +Options: + --help display this help and exit. + --version display version info and exit. + + -c (ignored) + -C install only if different (preserve the last data modification time) + -d create directories instead of installing files. + -g GROUP $chgrpprog installed files to GROUP. + -m MODE $chmodprog installed files to MODE. + -o USER $chownprog installed files to USER. + -s $stripprog installed files. + -S $stripprog installed files. + -t DIRECTORY install into DIRECTORY. + -T report an error if DSTFILE is a directory. + +Environment variables override the default commands: + CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG + RMPROG STRIPPROG +" + +while test $# -ne 0; do + case $1 in + -c) ;; + + -C) copy_on_change=true;; + + -d) dir_arg=true;; + + -g) chgrpcmd="$chgrpprog $2" + shift;; + + --help) echo "$usage"; exit $?;; + + -m) mode=$2 + case $mode in + *' '* | *' '* | *' +'* | *'*'* | *'?'* | *'['*) + echo "$0: invalid mode: $mode" >&2 + exit 1;; + esac + shift;; + + -o) chowncmd="$chownprog $2" + shift;; + + -s) stripcmd=$stripprog;; + +-S) stripcmd="$stripprog $2" + shift;; + + -t) dst_arg=$2 + shift;; + + -T) no_target_directory=true;; + + --version) echo "$0 $scriptversion"; exit $?;; + + --) shift + break;; + + -*) echo "$0: invalid option: $1" >&2 + exit 1;; + + *) break;; + esac + shift done -if [ x"$src" = x ] -then - echo "install: no input file specified" - exit 1 +if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then + # When -d is used, all remaining arguments are directories to create. + # When -t is used, the destination is already specified. + # Otherwise, the last argument is the destination. Remove it from $@. + for arg + do + if test -n "$dst_arg"; then + # $@ is not empty: it contains at least $arg. + set fnord "$@" "$dst_arg" + shift # fnord + fi + shift # arg + dst_arg=$arg + done fi -if [ x"$dst" = x ] -then - echo "install: no destination specified" - exit 1 +if test $# -eq 0; then + if test -z "$dir_arg"; then + echo "$0: no input file specified." >&2 + exit 1 + fi + # It's OK to call `install-sh -d' without argument. + # This can happen when creating conditional directories. + exit 0 fi +if test -z "$dir_arg"; then + do_exit='(exit $ret); exit $ret' + trap "ret=129; $do_exit" 1 + trap "ret=130; $do_exit" 2 + trap "ret=141; $do_exit" 13 + trap "ret=143; $do_exit" 15 -# If destination is a directory, append the input filename; if your system -# does not like double slashes in filenames, you may need to add some logic + # Set umask so as not to create temps with too-generous modes. + # However, 'strip' requires both read and write access to temps. + case $mode in + # Optimize common cases. + *644) cp_umask=133;; + *755) cp_umask=22;; -if [ -d "$dst" ] -then - dst="$dst/`basename "$src"`" + *[0-7]) + if test -z "$stripcmd"; then + u_plus_rw= + else + u_plus_rw='% 200' + fi + cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; + *) + if test -z "$stripcmd"; then + u_plus_rw= + else + u_plus_rw=,u+rw + fi + cp_umask=$mode$u_plus_rw;; + esac fi -# Make a temp file name in the proper directory. +for src +do + # Protect names starting with `-'. + case $src in + -*) src=./$src;; + esac + + if test -n "$dir_arg"; then + dst=$src + dstdir=$dst + test -d "$dstdir" + dstdir_status=$? + else + + # Waiting for this to be detected by the "$cpprog $src $dsttmp" command + # might cause directories to be created, which would be especially bad + # if $src (and thus $dsttmp) contains '*'. + if test ! -f "$src" && test ! -d "$src"; then + echo "$0: $src does not exist." >&2 + exit 1 + fi + + if test -z "$dst_arg"; then + echo "$0: no destination specified." >&2 + exit 1 + fi + + dst=$dst_arg + # Protect names starting with `-'. + case $dst in + -*) dst=./$dst;; + esac + + # If destination is a directory, append the input filename; won't work + # if double slashes aren't ignored. + if test -d "$dst"; then + if test -n "$no_target_directory"; then + echo "$0: $dst_arg: Is a directory" >&2 + exit 1 + fi + dstdir=$dst + dst=$dstdir/`basename "$src"` + dstdir_status=0 + else + # Prefer dirname, but fall back on a substitute if dirname fails. + dstdir=` + (dirname "$dst") 2>/dev/null || + expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$dst" : 'X\(//\)[^/]' \| \ + X"$dst" : 'X\(//\)$' \| \ + X"$dst" : 'X\(/\)' \| . 2>/dev/null || + echo X"$dst" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q' + ` + + test -d "$dstdir" + dstdir_status=$? + fi + fi + + obsolete_mkdir_used=false + + if test $dstdir_status != 0; then + case $posix_mkdir in + '') + # Create intermediate dirs using mode 755 as modified by the umask. + # This is like FreeBSD 'install' as of 1997-10-28. + umask=`umask` + case $stripcmd.$umask in + # Optimize common cases. + *[2367][2367]) mkdir_umask=$umask;; + .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; + + *[0-7]) + mkdir_umask=`expr $umask + 22 \ + - $umask % 100 % 40 + $umask % 20 \ + - $umask % 10 % 4 + $umask % 2 + `;; + *) mkdir_umask=$umask,go-w;; + esac + + # With -d, create the new directory with the user-specified mode. + # Otherwise, rely on $mkdir_umask. + if test -n "$dir_arg"; then + mkdir_mode=-m$mode + else + mkdir_mode= + fi + + posix_mkdir=false + case $umask in + *[123567][0-7][0-7]) + # POSIX mkdir -p sets u+wx bits regardless of umask, which + # is incompatible with FreeBSD 'install' when (umask & 300) != 0. + ;; + *) + tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ + trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 -dstdir="`dirname "$dst"`" -dsttmp="$dstdir"/#inst.$$# + if (umask $mkdir_umask && + exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 + then + if test -z "$dir_arg" || { + # Check for POSIX incompatibilities with -m. + # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or + # other-writeable bit of parent directory when it shouldn't. + # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. + ls_ld_tmpdir=`ls -ld "$tmpdir"` + case $ls_ld_tmpdir in + d????-?r-*) different_mode=700;; + d????-?--*) different_mode=755;; + *) false;; + esac && + $mkdirprog -m$different_mode -p -- "$tmpdir" && { + ls_ld_tmpdir_1=`ls -ld "$tmpdir"` + test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" + } + } + then posix_mkdir=: + fi + rmdir "$tmpdir/d" "$tmpdir" + else + # Remove any dirs left behind by ancient mkdir implementations. + rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null + fi + trap '' 0;; + esac;; + esac + + if + $posix_mkdir && ( + umask $mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" + ) + then : + else + + # The umask is ridiculous, or mkdir does not conform to POSIX, + # or it failed possibly due to a race condition. Create the + # directory the slow way, step by step, checking for races as we go. + + case $dstdir in + /*) prefix='/';; + -*) prefix='./';; + *) prefix='';; + esac + + eval "$initialize_posix_glob" + + oIFS=$IFS + IFS=/ + $posix_glob set -f + set fnord $dstdir + shift + $posix_glob set +f + IFS=$oIFS -# Move or copy the file name to the temp name + prefixes= -$doit $instcmd "$src" "$dsttmp" + for d + do + test -z "$d" && continue -# and set any options; do chmod last to preserve setuid bits + prefix=$prefix$d + if test -d "$prefix"; then + prefixes= + else + if $posix_mkdir; then + (umask=$mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break + # Don't fail if two instances are running concurrently. + test -d "$prefix" || exit 1 + else + case $prefix in + *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; + *) qprefix=$prefix;; + esac + prefixes="$prefixes '$qprefix'" + fi + fi + prefix=$prefix/ + done -if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dsttmp"; fi -if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dsttmp"; fi -if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dsttmp"; fi -if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dsttmp"; fi + if test -n "$prefixes"; then + # Don't fail if two instances are running concurrently. + (umask $mkdir_umask && + eval "\$doit_exec \$mkdirprog $prefixes") || + test -d "$dstdir" || exit 1 + obsolete_mkdir_used=true + fi + fi + fi -# Now rename the file to the real destination. + if test -n "$dir_arg"; then + { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && + { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && + { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || + test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 + else -$doit $rmcmd "$dst" -$doit $mvcmd "$dsttmp" "$dst" + # Make a couple of temp file names in the proper directory. + dsttmp=$dstdir/_inst.$$_ + rmtmp=$dstdir/_rm.$$_ + # Trap to clean up those temp files at exit. + trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 + + # Copy the file name to the temp name. + (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && + + # and set any options; do chmod last to preserve setuid bits. + # + # If any of these fail, we abort the whole thing. If we want to + # ignore errors from any of these, just make sure not to ignore + # errors from the above "$doit $cpprog $src $dsttmp" command. + # + { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && + { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && + { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && + { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && + + # If -C, don't bother to copy if it wouldn't change the file. + if $copy_on_change && + old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && + new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && + + eval "$initialize_posix_glob" && + $posix_glob set -f && + set X $old && old=:$2:$4:$5:$6 && + set X $new && new=:$2:$4:$5:$6 && + $posix_glob set +f && + + test "$old" = "$new" && + $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 + then + rm -f "$dsttmp" + else + # Rename the file to the real destination. + $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || + + # The rename failed, perhaps because mv can't rename something else + # to itself, or perhaps because mv is so ancient that it does not + # support -f. + { + # Now remove or move aside any old file at destination location. + # We try this two ways since rm can't unlink itself on some + # systems and the destination file might be busy for other + # reasons. In this case, the final cleanup might fail but the new + # file should still install successfully. + { + test ! -f "$dst" || + $doit $rmcmd -f "$dst" 2>/dev/null || + { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && + { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } + } || + { echo "$0: cannot unlink or rename $dst" >&2 + (exit 1); exit 1 + } + } && + + # Now rename the file to the real destination. + $doit $mvcmd "$dsttmp" "$dst" + } + fi || exit 1 + + trap '' 0 + fi +done -exit 0 +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC" +# time-stamp-end: "; # UTC" +# End: 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 3974753..a142baf 100644 --- a/unix/tcl.m4 +++ b/unix/tcl.m4 @@ -618,8 +618,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; @@ -676,44 +676,7 @@ AC_DEFUN([SC_ENABLE_THREADS], [ # Does the pthread-implementation provide # 'pthread_attr_setstacksize' ? - - ac_saved_libs=$LIBS - LIBS="$LIBS $THREADS_LIBS" AC_CHECK_FUNCS(pthread_attr_setstacksize) - 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 fi @@ -727,7 +690,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) @@ -1078,16 +1041,33 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [ AC_CACHE_CHECK([if compiler supports visibility "hidden"], tcl_cv_cc_visibility_hidden, [ + AS_IF([test "$SHARED_BUILD" = 1], [ + hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -fvisibility=hidden -Werror" + AC_TRY_COMPILE(,[#if !defined(__GNUC__) || __GNUC__ < 4 +#error visibility hidden is not supported for this compiler +#endif + ], tcl_cv_cc_visibility_hidden=yes, + tcl_cv_cc_visibility_hidden=no) + CFLAGS=$hold_cflags + ], [ + tcl_cv_cc_visibility_hidden=no + ]) + ]) + AS_IF([test $tcl_cv_cc_visibility_hidden = yes], [ + CFLAGS="$CFLAGS -fvisibility=hidden" + AC_DEFINE(MODULE_SCOPE, [extern], [No need to mark inidividual symbols as hidden]) + ], [ hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -Werror" AC_TRY_LINK([ extern __attribute__((__visibility__("hidden"))) void f(void); void f(void) {}], [f();], tcl_cv_cc_visibility_hidden=yes, tcl_cv_cc_visibility_hidden=no) - CFLAGS=$hold_cflags]) - AS_IF([test $tcl_cv_cc_visibility_hidden = yes], [ - AC_DEFINE(MODULE_SCOPE, - [extern __attribute__((__visibility__("hidden")))], - [Compiler support for module scope symbols]) + CFLAGS=$hold_cflags + AS_IF([test $tcl_cv_cc_visibility_hidden = yes], [ + AC_DEFINE(MODULE_SCOPE, + [extern __attribute__((__visibility__("hidden")))], + [Compiler support for module scope symbols]) + ]) ]) # Step 0.d: Disable -rpath support? @@ -1110,7 +1090,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 +1108,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"], [ @@ -1263,7 +1246,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [ if test "x${TCL_THREADS}" = "x0"; then AC_MSG_ERROR([CYGWIN compile is only supported with --enable-threads]) fi - if test "x${SHARED_BUILD}" = "x1" -a ! -f "../win/tcldde13.dll" -a ! -f "../win/tk85.dll"; then + if test "x${SHARED_BUILD}" = "x1" -a ! -f "../win/tcldde14.dll" -a ! -f "../win/tk86.dll"; then AC_MSG_ERROR([Please configure and make the ../win directory first.]) fi ;; @@ -1311,6 +1294,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 @@ -1358,6 +1343,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}']) @@ -1368,6 +1354,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}']) @@ -1393,6 +1380,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}']) @@ -1697,6 +1685,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [ AS_IF([test "$tcl_cv_cc_visibility_hidden" != yes], [ AC_DEFINE(MODULE_SCOPE, [__private_extern__], [Compiler support for module scope symbols]) + tcl_cv_cc_visibility_hidden=yes ]) CC_SEARCH_FLAGS="" LD_SEARCH_FLAGS="" @@ -2095,6 +2084,12 @@ 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]) + AC_DEFINE(NO_VIZ, [], [No visibility attribute]) + ]) + AS_IF([test "$SHARED_LIB_SUFFIX" = ""], [ SHARED_LIB_SUFFIX='${VERSION}${SHLIB_SUFFIX}']) AS_IF([test "$UNSHARED_LIB_SUFFIX" = ""], [ @@ -2103,7 +2098,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)" @@ -2512,11 +2507,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]) @@ -3058,37 +3048,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, @@ -3328,6 +3287,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.pc.in b/unix/tk.pc.in new file mode 100644 index 0000000..d84a1cf --- /dev/null +++ b/unix/tk.pc.in @@ -0,0 +1,15 @@ +# tk pkg-config source file + +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: The Tk Toolkit +Description: Tk is a cross-platform graphical user interface toolkit, the standard GUI not only for Tcl, but for many other dynamic languages as well. +URL: http://www.tcl.tk/ +Version: @TK_VERSION@ +Requires: +Conflicts: +Libs: -L${libdir} @TK_LIBS@ +Cflags: -I${includedir} diff --git a/unix/tk.spec b/unix/tk.spec index 21a4b7d..88a3007 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.11 +Version: 8.6b2 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..5fce66e 100644 --- a/unix/tkAppInit.c +++ b/unix/tkAppInit.c @@ -1,22 +1,49 @@ /* * 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 +extern int TK_LOCAL_MAIN_HOOK(int *argc, char ***argv); +#endif /* *---------------------------------------------------------------------- @@ -30,7 +57,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 +67,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 +98,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 +122,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 +135,10 @@ 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_SetVar)(interp, "tcl_rcFileName", "~/.wishrc", TCL_GLOBAL_ONLY); return TCL_OK; } diff --git a/unix/tkConfig.h.in b/unix/tkConfig.h.in index cfa8a32..3318552 100644 --- a/unix/tkConfig.h.in +++ b/unix/tkConfig.h.in @@ -4,12 +4,6 @@ #ifndef _TKCONFIG #define _TKCONFIG -/* 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 @@ -37,18 +31,9 @@ /* Define to 1 if you have the `open64' function. */ #undef HAVE_OPEN64 -/* 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 @@ -106,7 +91,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 Darwin CoreFoundation unavailable for 64-bit? */ @@ -121,6 +106,9 @@ /* Do we have <stdlib.h>? */ #undef NO_STDLIB_H +/* No visibility attribute */ +#undef NO_VIZ + /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT @@ -226,6 +214,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..841a1b7 100644 --- a/unix/tkUnix.c +++ b/unix/tkUnix.c @@ -69,11 +69,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); 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 a455118..9bfe8bb 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" /* @@ -165,7 +165,7 @@ TkpGetColor( } } - tkColPtr = (TkColor *) ckalloc(sizeof(TkColor)); + tkColPtr = ckalloc(sizeof(TkColor)); tkColPtr->color = color; return tkColPtr; @@ -200,7 +200,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; @@ -258,7 +258,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)); @@ -270,8 +270,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; } @@ -379,8 +379,8 @@ DeleteStressedCmap( } else { prevPtr->nextPtr = stressPtr->nextPtr; } - ckfree((char *) stressPtr->colorPtr); - ckfree((char *) stressPtr); + ckfree(stressPtr->colorPtr); + ckfree(stressPtr); return; } } diff --git a/unix/tkUnixConfig.c b/unix/tkUnixConfig.c index 2862eff..bb39127 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..bbf5206 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,9 +180,9 @@ 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; /* @@ -332,20 +332,20 @@ 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); return NULL; @@ -375,8 +375,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 +386,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); @@ -428,7 +428,7 @@ 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); @@ -548,7 +548,7 @@ CreateCursorFromTableOrFile( } return cursor; } - + /* *---------------------------------------------------------------------- * @@ -568,8 +568,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,13 +592,13 @@ 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; } return (TkCursor *) cursorPtr; } - + /* *---------------------------------------------------------------------- * @@ -625,7 +625,7 @@ TkpFreeCursor( XFreeCursor(unixCursorPtr->display, (Cursor) unixCursorPtr->info.cursor); Tk_FreeXId(unixCursorPtr->display, (XID) unixCursorPtr->info.cursor); } - + /* * Local Variables: * mode: c 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..bd5c512 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; @@ -136,7 +137,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; } @@ -158,7 +159,7 @@ TkpUseWindow( */ Tk_CreateEventHandler(tkwin, StructureNotifyMask, EmbeddedEventProc, - (ClientData) winPtr); + winPtr); /* * Save information about the container and the embedded window in a @@ -176,7 +177,7 @@ TkpUseWindow( } } if (containerPtr == NULL) { - containerPtr = (Container *) ckalloc(sizeof(Container)); + containerPtr = ckalloc(sizeof(Container)); containerPtr->parent = parent; containerPtr->parentRoot = parentAtts.root; containerPtr->parentPtr = NULL; @@ -279,7 +280,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 +301,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); } /* @@ -405,7 +406,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. @@ -508,7 +509,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), @@ -559,7 +560,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); @@ -865,7 +866,7 @@ 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; @@ -972,7 +973,7 @@ EmbedWindowDeleted( } else { prevPtr->nextPtr = containerPtr->nextPtr; } - ckfree((char *) containerPtr); + ckfree(containerPtr); } } @@ -1013,6 +1014,176 @@ 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. The + * GetParent() function is a helper for this. + * + * Results: + * None. + * + * Side effects: + * Sets up part of the busy window structure. + * + *---------------------------------------------------------------------- + */ + +static inline Window +GetParent( + Display *display, + Window window) +{ + Window root, parent; + Window *dummy; + unsigned int count; + + if (XQueryTree(display, window, &root, &parent, &dummy, &count) > 0) { + XFree(dummy); + return parent; + } + return None; +} + +void +TkpCreateBusy( + Tk_FakeWin *winPtr, + Tk_Window tkRef, + Window *parentPtr, + Tk_Window tkParent, + TkBusy busy) +{ + 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. + */ + + *parentPtr = GetParent(Tk_Display(tkRef), Tk_WindowId(tkRef)); + } else { + *parentPtr = Tk_WindowId(tkParent); + } +} + +/* * Local Variables: * mode: c * c-basic-offset: 4 diff --git a/unix/tkUnixEvent.c b/unix/tkUnixEvent.c index 09dde72..0987129 100644 --- a/unix/tkUnixEvent.c +++ b/unix/tkUnixEvent.c @@ -113,7 +113,7 @@ DisplayExitHandler( TkDisplay * TkpOpenDisplay( - CONST char *displayNameStr) + const char *displayNameStr) { TkDisplay *dispPtr; Display *display = XOpenDisplay(displayNameStr); @@ -121,14 +121,14 @@ TkpOpenDisplay( if (display == NULL) { return NULL; } - dispPtr = (TkDisplay *) ckalloc(sizeof(TkDisplay)); + dispPtr = ckalloc(sizeof(TkDisplay)); memset(dispPtr, 0, sizeof(TkDisplay)); dispPtr->display = display; #ifdef TK_USE_INPUT_METHODS OpenIM(dispPtr); #endif Tcl_CreateFileHandler(ConnectionNumber(display), TCL_READABLE, - DisplayFileProc, (ClientData) dispPtr); + DisplayFileProc, dispPtr); return dispPtr; } @@ -154,8 +154,6 @@ TkpCloseDisplay( { TkSendCleanup(dispPtr); - TkFreeXId(dispPtr); - TkWmCleanup(dispPtr); #ifdef TK_USE_INPUT_METHODS @@ -204,7 +202,7 @@ TkClipCleanup( dispPtr->windowAtom); Tk_DestroyWindow(dispPtr->clipWindow); - Tcl_Release((ClientData) dispPtr->clipWindow); + Tcl_Release(dispPtr->clipWindow); dispPtr->clipWindow = NULL; } } @@ -280,6 +278,9 @@ TransferXEventsToTcl( int type; XEvent x; TkKeyEvent k; +#ifdef GenericEvent + xGenericEvent xge; +#endif } event; Window w; TkDisplay *dispPtr = NULL; @@ -297,6 +298,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) { @@ -545,7 +552,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)) { @@ -688,6 +695,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..136d69f 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,7 +580,7 @@ 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; @@ -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; @@ -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..494c227 100644 --- a/unix/tkUnixInit.c +++ b/unix/tkUnixInit.c @@ -67,7 +67,7 @@ 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); if ((name == NULL) || (*name == 0)) { @@ -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); diff --git a/unix/tkUnixKey.c b/unix/tkUnixKey.c index 030e472..7461d75 100644 --- a/unix/tkUnixKey.c +++ b/unix/tkUnixKey.c @@ -22,7 +22,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. * *---------------------------------------------------------------------- @@ -38,11 +38,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; } @@ -51,22 +50,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, (void *) NULL); - XSetICValues(winPtr->inputContext, - XNPreeditAttributes, preedit_attr, + XSetICValues(winPtr->inputContext, XNPreeditAttributes, preedit_attr, (void *) NULL); XFree(preedit_attr); } @@ -91,7 +89,7 @@ Tk_SetCaretPos( *---------------------------------------------------------------------- */ -char * +const char * TkpGetString( TkWindow *winPtr, /* Window where event occurred */ XEvent *eventPtr, /* X keyboard event. */ @@ -115,8 +113,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 @@ -125,10 +122,14 @@ 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), + Tcl_DStringValue(dsPtr), Tcl_DStringLength(dsPtr), &kePtr->keysym, &status); } if ((status != XLookupChars) && (status != XLookupBoth)) { @@ -142,7 +143,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); @@ -159,7 +159,6 @@ TkpGetString( if ((status != XLookupChars) && (status != XLookupBoth)) { len = 0; } - Tcl_DStringSetLength(&buf, len); Tcl_ExternalToUtfDString(NULL, Tcl_DStringValue(&buf), len, dsPtr); Tcl_DStringFree(&buf); @@ -203,7 +202,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); @@ -221,30 +220,27 @@ TkpSetKeycodeAndState( KeySym keySym, XEvent *eventPtr) { - Display *display; + Display *display = Tk_Display(tkwin); int state; KeyCode keycode; - display = Tk_Display(tkwin); - if (keySym == NoSymbol) { keycode = 0; } else { keycode = XKeysymToKeycode(display, keySym); - } - if (keycode != 0) { - for (state = 0; state < 4; state++) { - if (XKeycodeToKeysym(display, keycode, state) == keySym) { - if (state & 1) { - eventPtr->xkey.state |= ShiftMask; - } - if (state & 2) { - TkDisplay *dispPtr; - - dispPtr = ((TkWindow *) tkwin)->dispPtr; - eventPtr->xkey.state |= dispPtr->modeModMask; + if (keycode != 0) { + for (state = 0; state < 4; state++) { + if (XKeycodeToKeysym(display, keycode, state) == keySym) { + if (state & 1) { + eventPtr->xkey.state |= ShiftMask; + } + if (state & 2) { + TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr; + + eventPtr->xkey.state |= dispPtr->modeModMask; + } + break; } - break; } } } @@ -420,7 +416,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; @@ -442,12 +438,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; @@ -459,23 +454,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 38a8513..222be88 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> @@ -142,8 +127,8 @@ # define LPARAM void * # define LRESULT void * - extern int TkPutImage(unsigned long *, int, Display *, Drawable, - GC, XImage *, int, int, int, int, unsigned int, unsigned int); +EXTERN int TkPutImage (unsigned long *, int, Display *, Drawable, GC, + XImage *, int, int, int, int, unsigned int, unsigned int); #else /* !__CYGWIN__ */ /* @@ -184,7 +169,7 @@ * These functions do nothing under Unix, so we just eliminate calls to them. */ -#define TkpButtonSetDefaults(specPtr) {} +#define TkpButtonSetDefaults() {} #define TkpDestroyButton(butPtr) {} #define TkSelUpdateClipboard(a,b) {} #ifndef __CYGWIN__ @@ -210,15 +195,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 deecceb..a8f5289 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, - (void *) NULL); + FC_FAMILY, FcTypeString, "sans", + FC_SIZE, FcTypeDouble, 12.0, + FC_MATRIX, FcTypeMatrix, &mat, + (void *) 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,7 +849,279 @@ 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( Region clipRegion) /* The clipping region to install. */ @@ -817,3 +1131,10 @@ TkUnixSetXftClipRegion( tsdPtr->clipRegion = clipRegion; } + +/* + * Local Variables: + * c-basic-offset: 4 + * fill-column: 78 + * End: + */ diff --git a/unix/tkUnixScale.c b/unix/tkUnixScale.c index e158549..b156a74 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); } /* @@ -547,24 +547,24 @@ 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); 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..172d5ca 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); } @@ -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); @@ -594,7 +594,7 @@ TkSelEventProc( 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 +617,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 @@ -642,14 +642,14 @@ TkSelEventProc( } 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,14 +661,14 @@ 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; @@ -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); @@ -791,7 +791,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. */ @@ -812,18 +815,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 +849,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 { @@ -881,8 +884,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 +924,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 +958,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,7 +967,7 @@ ConvertSelection( * allows us to pass our utf-8 information untouched. */ - XChangeProperty(reply.display, reply.requestor, property, type, 8, + XChangeProperty(reply.xsel.display, reply.xsel.requestor, property, type, 8, PropModeReplace, (unsigned char *) buffer, numItems); } else if ((type == XA_STRING) || (type == winPtr->dispPtr->compoundTextAtom)) { @@ -984,7 +986,7 @@ ConvertSelection( encoding = Tcl_GetEncoding(NULL, "iso2022"); } Tcl_UtfToExternalDString(encoding, (char *) buffer, -1, &ds); - XChangeProperty(reply.display, reply.requestor, property, type, 8, + XChangeProperty(reply.xsel.display, reply.xsel.requestor, property, type, 8, PropModeReplace, (unsigned char *) Tcl_DStringValue(&ds), Tcl_DStringLength(&ds)); if (encoding) { @@ -998,7 +1000,7 @@ ConvertSelection( goto refuse; } format = 32; - XChangeProperty(reply.display, reply.requestor, property, type, + XChangeProperty(reply.xsel.display, reply.xsel.requestor, property, type, format, PropModeReplace, (unsigned char *) propPtr, numItems); ckfree(propPtr); @@ -1012,17 +1014,16 @@ 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, + XChangeProperty(reply.xsel.display, reply.xsel.requestor, reply.xsel.property, XA_ATOM, 32, PropModeReplace, (unsigned char *) incr.multAtoms, (int) incr.numConversions*2); @@ -1032,9 +1033,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); /* @@ -1052,7 +1053,7 @@ ConvertSelection( Tcl_DeleteTimerHandler(incr.timeout); errorHandler = Tk_CreateErrorHandler(winPtr->display, -1, -1,-1, (int (*)()) NULL, NULL); - XSelectInput(reply.display, reply.requestor, 0L); + XSelectInput(reply.xsel.display, reply.xsel.requestor, 0L); Tk_DeleteErrorHandler(errorHandler); if (tsdPtr->pendingIncrs == &incr) { tsdPtr->pendingIncrs = incr.nextPtr; @@ -1071,7 +1072,7 @@ ConvertSelection( * All done. Cleanup and return. */ - ckfree((char *) incr.converts); + ckfree(incr.converts); if (multiple) { XFree((char *) incr.multAtoms); } @@ -1082,8 +1083,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; } @@ -1159,7 +1160,7 @@ SelRcvIncrProc( 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 +1191,7 @@ SelRcvIncrProc( */ retrPtr->result = TCL_OK; - Tcl_Release((ClientData) interp); + Tcl_Release(interp); goto done; } else { src = propInfo; @@ -1231,9 +1232,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 @@ -1273,10 +1274,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 +1323,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; @@ -1368,7 +1369,7 @@ IncrTimeoutProc( incrPtr->numIncrs = 0; } else { incrPtr->timeout = Tcl_CreateTimerHandler(1000, IncrTimeoutProc, - (ClientData) incrPtr); + incrPtr); } } @@ -1422,7 +1423,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 +1448,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 c073309..be53ec6 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. */ @@ -994,7 +992,7 @@ Tk_SendCmd( if (argc < (i+2)) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " ?options? interpName arg ?arg ...?\"", NULL); + " ?-option value ...? interpName arg ?arg ...?\"", NULL); return TCL_ERROR; } destName = argv[i]; @@ -1018,9 +1016,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_GlobalEval(localInterp, argv[firstArg]); } else { @@ -1056,8 +1054,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; } @@ -1086,7 +1084,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 +1135,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 +1148,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 +1157,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 +1166,7 @@ Tk_SendCmd( } } } - (void) Tk_RestrictEvents(prevRestrictProc, prevArg, &prevArg); + Tk_RestrictEvents(prevProc, prevArg, &prevArg); /* * Unregister the information about the pending command and return the @@ -1197,7 +1195,8 @@ Tk_SendCmd( Tcl_SetObjErrorCode(interp, errorObjPtr); ckfree(pending.errorCode); } - Tcl_SetResult(interp, pending.result, TCL_DYNAMIC); + Tcl_SetResult(interp, pending.result, TCL_VOLATILE); + ckfree(pending.result); return pending.code; } @@ -1240,9 +1239,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; @@ -1312,9 +1311,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; } } @@ -1355,12 +1354,12 @@ SendInit( if (dispPtr->commTkwin == NULL) { Tcl_Panic("Tk_CreateWindow failed in SendInit!"); } - Tcl_Preserve((ClientData) dispPtr->commTkwin); + Tcl_Preserve(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); /* @@ -1401,14 +1400,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) @@ -1458,7 +1457,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; @@ -1547,7 +1547,7 @@ SendEventProc( break; } } - Tcl_Preserve((ClientData) riPtr); + Tcl_Preserve(riPtr); /* * We must protect the interpreter because the script may enter @@ -1555,7 +1555,7 @@ SendEventProc( */ remoteInterp = riPtr->interp; - Tcl_Preserve((ClientData) remoteInterp); + Tcl_Preserve(remoteInterp); result = Tcl_GlobalEval(remoteInterp, script); @@ -1570,7 +1570,7 @@ SendEventProc( Tcl_DStringAppend(&reply, Tcl_GetStringResult(remoteInterp), -1); if (result == TCL_ERROR) { - CONST char *varValue; + const char *varValue; varValue = Tcl_GetVar2(remoteInterp, "errorInfo", NULL, TCL_GLOBAL_ONLY); @@ -1586,8 +1586,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 @@ -1613,7 +1613,7 @@ SendEventProc( } } else if ((*p == 'r') && (p[1] == 0)) { int serial, code, gotSerial; - char *errorInfo, *errorCode, *resultString; + const char *errorInfo, *errorCode, *resultString; PendingCommand *pcPtr; /* @@ -1679,19 +1679,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); } } @@ -1747,7 +1744,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); @@ -1764,9 +1761,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) { @@ -1780,8 +1777,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; @@ -1814,10 +1810,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); @@ -1835,10 +1831,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); } /* @@ -1906,7 +1902,7 @@ UpdateCommWindow( { Tcl_DString names; RegisteredInterp *riPtr; - ThreadSpecificData *tsdPtr = (ThreadSpecificData *) + ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); Tcl_DStringInit(&names); @@ -1945,9 +1941,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], diff --git a/unix/tkUnixWm.c b/unix/tkUnixWm.c index 1d66412..48d9021 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,16 @@ 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 +53,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 +205,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. */ @@ -289,17 +289,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 +329,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 +356,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[]); -static int WmForgetCmd(Tk_Window tkwin, TkWindow *winPtr, + 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[]); -static int WmManageCmd(Tk_Window tkwin, TkWindow *winPtr, + 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 +495,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 +507,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 +550,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 +568,7 @@ TkWmNewWindow( /* * Initialize attributes. */ + wmPtr->attributes.alpha = 1.0; wmPtr->attributes.topmost = 0; wmPtr->attributes.zoomed = 0; @@ -611,7 +611,7 @@ TkWmNewWindow( * window manager. */ - Tk_ManageGeometry((Tk_Window) winPtr, &wmMgrType, (ClientData) 0); + Tk_ManageGeometry((Tk_Window) winPtr, &wmMgrType, NULL); } /* @@ -699,8 +699,8 @@ TkWmMapWindow( 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); /* @@ -728,16 +728,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 +840,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 +879,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 +903,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 +930,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; } @@ -988,7 +986,7 @@ TkWmSetClass( * * Tk_WmObjCmd -- * - * This function is invoked to process the "wm" Tcl command. + * This function is invoked to process the "wm" Tcl command. * *---------------------------------------------------------------------- */ @@ -999,32 +997,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,6 +1035,7 @@ 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; @@ -1174,7 +1171,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; @@ -1245,6 +1242,7 @@ WmSetAttribute( Tcl_Obj *value) /* New value */ { WmInfo *wmPtr = winPtr->wmInfoPtr; + switch (attribute) { case WMATT_ALPHA: { unsigned long opacity; /* 0=transparent, 0xFFFFFFFF=opaque */ @@ -1267,27 +1265,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); + XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &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 +1293,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 +1374,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; @@ -1394,7 +1391,7 @@ WmAttributesCmd( return TCL_OK; } else if (objc == 4) { /* wm attributes $win -attribute */ if (Tcl_GetIndexFromObj(interp, objv[3], WmAttributeNames, - "attribute", 0, &attribute) != TCL_OK) { + "attribute", 0, &attribute) != TCL_OK) { return TCL_ERROR; } Tcl_SetObjResult(interp, WmGetAttribute(winPtr, attribute)); @@ -1441,10 +1438,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)) { @@ -1460,7 +1457,7 @@ WmClientCmd( 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 +1468,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; @@ -1497,8 +1494,7 @@ WmClientCmd( XChangeProperty(winPtr->display, wmPtr->wrapperPtr->window, Tk_InternAtom((Tk_Window) winPtr, "_NET_WM_PID"), - XA_CARDINAL,32, PropModeReplace, (unsigned char *) &pid, - 1); + XA_CARDINAL,32, PropModeReplace, (unsigned char*)&pid, 1); } Tcl_DStringFree(&ds); } @@ -1528,7 +1524,7 @@ 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; @@ -1555,8 +1551,8 @@ WmColormapwindowsCmd( && (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); @@ -1571,15 +1567,14 @@ WmColormapwindowsCmd( != 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 +1596,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 +1623,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 +1636,16 @@ 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_SetResult(interp, arg, TCL_DYNAMIC); } 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 +1658,7 @@ WmCommandCmd( return TCL_ERROR; } if (wmPtr->cmdArgv != NULL) { - ckfree((char *) wmPtr->cmdArgv); + ckfree(wmPtr->cmdArgv); } wmPtr->cmdArgc = cmdArgc; wmPtr->cmdArgv = cmdArgv; @@ -1696,7 +1691,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; @@ -1742,10 +1737,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 }; @@ -1779,8 +1774,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 +1787,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 +1800,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,7 +1840,7 @@ 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; @@ -1853,7 +1854,7 @@ WmFrameCmd( if (window == None) { window = Tk_WindowId((Tk_Window) winPtr); } - sprintf(buf, "0x%x", (unsigned int) window); + sprintf(buf, "0x%x", (unsigned) window); Tcl_SetResult(interp, buf, TCL_VOLATILE); return TCL_OK; } @@ -1881,12 +1882,12 @@ 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?"); @@ -1944,7 +1945,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; @@ -2034,12 +2035,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)) { @@ -2080,7 +2081,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 +2111,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?"); @@ -2123,7 +2124,8 @@ WmIconbitmapCmd( if (objc == 3) { if (wmPtr->hints.flags & IconPixmapHint) { Tcl_SetResult(interp, (char *) - Tk_NameOfBitmap(winPtr->display, wmPtr->hints.icon_pixmap), + Tk_NameOfBitmap(winPtr->display, + wmPtr->hints.icon_pixmap), TCL_STATIC); } return TCL_OK; @@ -2170,9 +2172,10 @@ 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; @@ -2229,11 +2232,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?"); @@ -2288,10 +2291,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) { @@ -2305,10 +2308,10 @@ WmIconnameCmd( 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 +2343,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; @@ -2391,8 +2394,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 +2424,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 +2445,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 +2487,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; @@ -2506,11 +2506,11 @@ WmIconpositionCmd( } 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 +2544,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 +2557,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; } @@ -2597,6 +2597,7 @@ WmIconwindowCmd( } if (wmPtr->icon != NULL) { WmInfo *wmPtr3 = ((TkWindow *) wmPtr->icon)->wmInfoPtr; + wmPtr3->iconFor = NULL; wmPtr3->withdrawn = 1; wmPtr3->hints.initial_state = WithdrawnState; @@ -2641,8 +2642,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 +2655,27 @@ 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_AppendResult(interp, "window \"", Tk_PathName(frameWin), + "\" is not manageable: must be a frame, labelframe or " + "toplevel", 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 +2684,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 +2721,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; @@ -2772,7 +2779,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; @@ -2822,7 +2829,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 +2840,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 +2887,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 }; @@ -2944,12 +2951,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)) { @@ -3007,13 +3014,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 +3056,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; @@ -3109,10 +3116,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 }; @@ -3174,10 +3181,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 }; @@ -3195,7 +3202,7 @@ WmStackorderCmd( for (window_ptr = windows; *window_ptr ; window_ptr++) { Tcl_AppendElement(interp, (*window_ptr)->pathName); } - ckfree((char *) windows); + ckfree(windows); return TCL_OK; } } else { @@ -3236,18 +3243,18 @@ WmStackorderCmd( if (windows == NULL) { Tcl_AppendResult(interp, "TkWmStackorderToplevel failed", 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) { @@ -3258,7 +3265,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 +3294,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 }; @@ -3381,10 +3388,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) { @@ -3398,10 +3405,10 @@ WmTitleCmd( return TCL_OK; } 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 +3441,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 +3453,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 +3466,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 @@ -3518,13 +3525,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; } @@ -3544,7 +3550,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 +3580,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; @@ -3608,7 +3614,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 +3629,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 +3756,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 +3824,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,7 +4049,7 @@ ReparentEvent( Atom actualType; int actualFormat; unsigned long numItems, bytesAfter; - unsigned int dummy; + unsigned dummy; Tk_ErrorHandler handler; TkDisplay *dispPtr = wmPtr->winPtr->dispPtr; @@ -4083,7 +4089,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 +4176,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 +4187,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) { /* @@ -4308,15 +4314,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 +4409,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 +4433,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 +4472,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; @@ -4594,7 +4601,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 +4642,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)) { /* @@ -5158,8 +5165,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 +5180,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 +5190,7 @@ WaitForEvent( break; } } - (void) Tk_RestrictEvents(oldRestrictProc, oldRestrictData, - &oldRestrictData); + Tk_RestrictEvents(prevProc, prevArg, &prevArg); if (info.foundEvent) { return TCL_OK; } @@ -5218,7 +5223,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; @@ -5373,13 +5378,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); @@ -5401,7 +5407,7 @@ SetNetWmType(TkWindow *winPtr, Tcl_Obj *typePtr) XChangeProperty(Tk_Display(tkwin), wrapperPtr->window, typeAtom, XA_ATOM, 32, PropModeReplace, (unsigned char *) atoms, objc); - ckfree((char *)atoms); + ckfree(atoms); return TCL_OK; } @@ -5483,7 +5489,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 +5497,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. @@ -5584,7 +5590,7 @@ 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; @@ -5916,7 +5922,7 @@ UpdateVRootGeometry( { TkWindow *winPtr = wmPtr->winPtr; int bd; - unsigned int dummy; + unsigned dummy; Window dummy2; Status status; Tk_ErrorHandler handler; @@ -5942,8 +5948,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, ", @@ -6074,9 +6080,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 +6125,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"); @@ -6136,7 +6142,7 @@ UpdateWmProtocols( Tk_InternAtom((Tk_Window) wmPtr->winPtr, "WM_PROTOCOLS"), XA_ATOM, 32, PropModeReplace, (unsigned char *) arrayPtr, atomPtr-arrayPtr); - ckfree((char *) arrayPtr); + ckfree(arrayPtr); } /* @@ -6166,7 +6172,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 +6209,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_GlobalEval(interp, protPtr->command); 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 +6305,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 +6318,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 @@ -6339,7 +6343,7 @@ 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++) { @@ -6389,7 +6393,7 @@ TkWmRestackToplevel( * below *all* siblings. */ { XWindowChanges changes; - unsigned int mask; + unsigned mask; TkWindow *wrapperPtr; memset(&changes, 0, sizeof(XWindowChanges)); @@ -6515,7 +6519,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 +6530,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 +6660,7 @@ TkGetPointerCoords( WmInfo *wmPtr; Window w, root, child; int rootX, rootY; - unsigned int mask; + unsigned mask; wmPtr = winPtr->wmInfoPtr; @@ -6765,8 +6769,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. @@ -6780,11 +6784,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; @@ -6799,15 +6806,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); @@ -6920,7 +6931,7 @@ CreateWrapper( */ Tk_CreateEventHandler((Tk_Window) wmPtr->wrapperPtr, - WrapperEventMask, WrapperEventProc, (ClientData) wmPtr); + WrapperEventMask, WrapperEventProc, wmPtr); } /* @@ -6989,9 +7000,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) { /* @@ -7013,7 +7028,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); } @@ -7039,14 +7054,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; } } @@ -7085,7 +7100,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; } } @@ -7113,7 +7128,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) { @@ -7121,7 +7136,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; } } @@ -7195,8 +7210,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); @@ -7213,8 +7228,8 @@ UpdateCommand( XSetCommand(winPtr->display, wmPtr->wrapperPtr->window, cmdArgv, wmPtr->cmdArgc); Tcl_DStringFree(&cmds); - ckfree((char *) cmdArgv); - ckfree((char *) offsets); + ckfree(cmdArgv); + ckfree(offsets); } /* @@ -7299,10 +7314,10 @@ TkpWmSetState( *---------------------------------------------------------------------- */ -static void -RemapWindows(winPtr, parentPtr) - TkWindow *winPtr; - TkWindow *parentPtr; +static void +RemapWindows( + TkWindow *winPtr, + TkWindow *parentPtr) { XWindowAttributes win_attr; @@ -7310,7 +7325,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..cbc0a5d 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; |