<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE TIP SYSTEM "http://tcl.activestate.com/cgi-bin/tct/tip/tipxml.dtd">
<!-- Converted at Thu Feb 09 12:34:03 GMT 2012 -->
<!-- TIP AutoGenerator - written by Donal K. Fellows -->

<TIP number='108'>
<header><title>Summary of Changes to Generic Tcl/Tk Code to Enable Mac OS X Port</title><author address="mailto:jingham@apple.com">Jim Ingham</author><status type='informative' state='final' vote='none'>$Revision: 1.2 $</status><history></history><created day='29' month='aug' year='2002' /></header>
<abstract>The submission of the changes to generic Tcl/Tk necessary for the Mac OS X port was discussed on the Tcl Core mailing list. In light of the very minor changes to shared code involved, and to facilitate including the port in the 8.4 release, it was decided that we would not hold a formal vote. This informational TIP is offered to summarize the work done, however, and to maintain a more complete record.</abstract>
<body><section title="What Changes are Required for the Mac OS X Port?">
<para>These fall into two parts: macosx only changes, and changes that effect generic code.</para>
<para>The Mac OS X-only changes again fall into two parts. On the one hand, we introduced new macosx directories to the Tcl and Tk trees, at the same level as the win, unix and mac directories. At present, the <emph style="italic">tcl/macosx</emph> directory only contains one <emph style="italic">.c</emph> file and a project file. The <emph style="italic">tk/macosx</emph> directory is much more substantial. This set of changes manifestly only effects this port, and since something is better than nothing, should be uncontroversial.</para>
<para>The other Mac OS X-only part is the addition of Mac OS X specific elements to the <emph style="italic">.decls</emph> files. This should also be uncontroversial, though I had to add some slightly non-trivial code to the <emph style="italic">genStubs.tcl</emph> file to handle the fact that Tk loosely uses &quot;unix&quot; to mean &quot;X11&quot;, which for Mac OS X is not the case.</para>
<para>The Tcl side of Mac OS X is clearly unix, but the same Tcl can in fact be used with X11 (there is a native X Server in quite common use on Mac OS X) and with the Aqua based Tk port.</para>
<para>In the end, however, the stubs generated for the generic, mac, win &amp; X11 parts of Tcl/Tk are the same, and there is just some extra logic for the aqua part, so the result effects only Mac OS X code.</para>
<para>The generic code changes are quite small - a testament to the design of the Tcl/Tk porting layers.</para>
<enumerate><item.e index='1'><para>We changed the <emph style="italic">configure.in</emph>, <emph style="italic">Makefile.in</emph> and <emph style="italic">tcl.m4</emph> to handle building Tcl in a the Framework form that is common on Mac OS X.</para></item.e><item.e index='2'><para>I added a bit of code (conditionalized to Mac OS X) to <emph style="italic">tclUnixInit.c</emph> (in the <emph style="italic">TclpSetVariables</emph> function) to support looking for script files embedded in the Mac OS X Framework bundle. This fits the Mac OS X model better than putting files in <emph style="italic">/usr/local</emph> or such-like.</para></item.e><item.e index='3'><para>I added a few more elements to the <emph style="italic">notifierProcPtr</emph>. For the aqua Tk, we need to swap the Unix notifier with our own, and so we needed more control over the notifier than was allowed. This change has no effect if you don&apos;t use it, however.</para></item.e><item.e index='4'><para>I added a function, <emph style="italic">TkGetFirstTextLayout</emph>, which gets the run of text up the the first wrap. I have to get this because the Mac OS X button control doesn&apos;t like a newline in the button text. It is a private function, however, so it doesn&apos;t cause any incompatibilities.</para></item.e><item.e index='5'><para>We had to change various places in the Tk script code and the demos where the implicit assumption was made that [string equal $tcl_platform(platform) &quot;unix&quot;] meant you were using X11. To this end, we will add a <emph style="italic">windowingsystem</emph> subcommand to the <emph style="italic">tk</emph> command, and then using it to replace the cases where <emph style="italic">tcl_platform</emph> was being erroneously checked. This command will return &quot;x11&quot; for an X11 server, &quot;aqua&quot; for the native Mac OS X window manager, &quot;win32&quot; for Windows, and &quot;classic&quot; for Classic MacOS.</para></item.e></enumerate>
</section>
<section title="Reference Implementation">
<para>The reference implementation is on the <emph style="italic">macosx-8-4-branch</emph> in the SourceForge CVS repository.</para>
</section>
<section title="Copyright">
<para>This document has been placed in the public domain.</para>
</section>
</body></TIP>

