diff -urN Tk800.022.orig/DragDrop/Win32Site/Win32Site.xs Tk800.022/DragDrop/Win32Site/Win32Site.xs --- Tk800.022.orig/DragDrop/Win32Site/Win32Site.xs Tue Jul 27 19:20:04 1999 +++ Tk800.022/DragDrop/Win32Site/Win32Site.xs Thu Aug 31 15:49:25 2000 @@ -3,11 +3,14 @@ This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. */ -#ifndef __GNUC__ +#if !defined(__GNUC__) || defined(__CYGWIN__) #include #include #endif +#ifdef __CYGWIN__ +# undef WIN32 +#endif #include #include #include diff -urN Tk800.022.orig/DragDrop/site_test Tk800.022/DragDrop/site_test --- Tk800.022.orig/DragDrop/site_test Sat Aug 21 21:03:26 1999 +++ Tk800.022/DragDrop/site_test Thu Aug 31 15:49:25 2000 @@ -3,7 +3,11 @@ use strict; use Tk::DropSite; use vars qw($kind $STRING $FILE_NAME); -BEGIN { $kind = ($^O eq 'MSWin32') ? ['Win32'] : ['Sun','XDND','KDE'] } +BEGIN +{ + $kind = ($^O eq 'MSWin32' or ($^O eq 'cygwin' and $Tk::platform eq 'MSWin32'))? + ['Win32'] : ['Sun','XDND','KDE'] +} use Tk::DropSite @$kind; use Tk::DragDrop @$kind; use Tk::Menubar; diff -urN Tk800.022.orig/IO/IO.xs Tk800.022/IO/IO.xs --- Tk800.022.orig/IO/IO.xs Sat Jul 31 10:45:19 1999 +++ Tk800.022/IO/IO.xs Thu Aug 31 15:49:25 2000 @@ -79,7 +79,7 @@ static int restore_mode _((PerlIO *f,int mode)); static int make_nonblock _((PerlIO *f,int *mode,int *newmode)); -#ifdef __WIN32__ +#if defined(__WIN32__) && !defined(__CYGWIN__) static int make_nonblock(f,mode,newmode) PerlIO *f; diff -urN Tk800.022.orig/MANIFEST Tk800.022/MANIFEST --- Tk800.022.orig/MANIFEST Mon May 1 21:14:25 2000 +++ Tk800.022/MANIFEST Thu Aug 31 15:49:25 2000 @@ -125,6 +125,7 @@ README.linux README.os2 README.ultrix +README.cygwin Scale/Makefile.PL Scale/Scale.pm Scale/Scale.xs diff -urN Tk800.022.orig/Makefile.PL Tk800.022/Makefile.PL --- Tk800.022.orig/Makefile.PL Sat Apr 29 10:28:28 2000 +++ Tk800.022/Makefile.PL Thu Aug 31 15:49:26 2000 @@ -11,7 +11,7 @@ $win_arch = shift @ARGV if @ARGV and $ARGV[0] =~ /^(open32|pm|x|MSWin32)$/; require('fix_4_os2.pl'), OS2_massage() if $^O eq 'os2'; - $win_arch = ($IsWin32) ? 'MSWin32' : 'x' + $win_arch = ($IsWin32 or $^O eq 'cygwin') ? 'MSWin32' : 'x' if not defined $win_arch; # Currently 'x', 'pm', 'open32', 'MSWin32' require "./myConfig"; @@ -106,6 +106,10 @@ ($Config{'cc'} =~ /^gcc/i) ? 'pTk\\tkres$(OBJ_EXT)' : 'pTk\\tk.res'); } + } + if ($win_arch eq 'MSWin32' and $^O eq 'cygwin') + { + push(@{$self->{'O_FILES'}}, 'pTk/tkres$(OBJ_EXT)'); } $ret; } diff -urN Tk800.022.orig/README.cygwin Tk800.022/README.cygwin --- Tk800.022.orig/README.cygwin Thu Jan 1 00:00:00 1970 +++ Tk800.022/README.cygwin Thu Aug 31 15:49:48 2000 @@ -0,0 +1,154 @@ + +This is a brief description of how to get the Tk module working with +Perl and Cygwin. + +CONFIGURE/BUILD + + Use native Win32 GUI calls: + + perl Makefile.PL + + Use X11 client libraries (and requires a X server): + + Precompiled X11 client libraries can be downloaded from + ftp://sourceware.cygnus.com/pub/cygwin/xfree/xc-4-binaries/ + xfree86-4.0-DLLs.tar.bz2 + xfree86-4.0-devel.tar.bz2 + + NOTE: Your DISPLAY must be 127.0.0.1:0.0 + Your PATH must include the DLL directory, /usr/X11R6/bin + + perl Makefile.PL x + + make + +TEST + + make test + perl -Mblib demos/widget + +INSTALL + + make install + +SIDE-BY-SIDE PORT COMPARISONS (demos/widget) + + X11 (Hummingbird/Exceed X Server, V6.1) + + + Motif look and feel + + Scroll wheel does not work with X11 (config?) + + Global grabs only affect X11 windows (config?) + + Menus, normal style + - Alt+x does not post menus (config?) + + $Tk::platform => unix + + Win32 + + + Windows look and feel + + Uses Win32 clipboard + + Help on menu bar not all the way to the right + + Tear-off menus placed at upper-left instead of near pointer + + Tile and Transparent, no tiled camels, third window not + transparent + + Menus, normal style + - File - "Error: unknown option "-label" at Tk.pm line 217 + + Menus, Perl/Tk style + - Menus do not drop as traverse with button press + - Alt+x does not post menus + + Native Win32 FileSelect dialog, FileSelect/FBox the same + + Native Win32 ChooseColor dialog + + Balls bouncing, when start restacked below widget demo window + (if bounce window not moved) + + Global grabs only affect current application + + IntelliMouse with IntelliEye (but ok with a trackball, setting?) + - Button-2 dragging/scanning does not work well + - Button-2 for copy/paste does not work well + (seems to flip into a scroll mode) + + $Tk::TkwinVtab, $Tk::TkwinintVtab variables + + $Tk::platform => MSWin32 + + Both + + Tear-off menus restack parent below widget demo window + + Meta-backspace, Meta-d not working (Meta config?) + + Menus, normal and Perl/Tk style + - Meta+x accelerators (Control+x okay) not working (config?) + + X11 (Cygwin) v X11 (Solaris) + + No differences that I could find! + + Win32 (Cygwin) v Win32 (MSWin32/ActiveState) + + + Menus, normal style + - Accelerators Win32 bound to Control, Cygwin bound to Meta + (see demos/demos/widget_lib/menus.pl, $^O eq 'MSWin32') + - Win32 ^A does not work (Meta+A with X11), ^H does + +PORTING NOTES + + + $Tk::platform is really the win_arch, where unix is x + (sometimes $^O eq 'MSWin32' is used instead of $Tk::platform + eq 'MSWin32' assuming they are equivalent and vice versa) + + #define distinctions + _WIN32 defined by gcc, if X11 need to undef + __WIN32__ win_arch MSWin32, also defined in pTk/Lang.h + WIN32 from #include + when precedes #include "perl.h" then need + a #undef WIN32 (otherwise tries to include + Win32 Perl things like win32.h, defined + by native Win32 port) + + With native Win32 GUI use Cygwin select() with /dev/windows + pseudo-device rather than using Win32 GetMessage() directly + + pTk/mTk/win/tkWinX.c, pTk/mTk/generic/tkPort.h part of core Tk, + which is ordinarily not touched by Tk Perl module? pTk/Tcl-pTk? + +FILES (with Cygwin references) + + README.cygwin MANIFEST + * documentation + + Makefile.PL Tk/MMutil.pm pTk/Makefile.PL + * make stuff + + pTk/mTk/win/tkWinX.c + * GetMessage() via select() on /dev/windows and callback + + Scrollbar/Scrollbar.xs tkWin32Dll.c + * defined(__WIN32__) && defined(__CYGWIN__) + + tkGlue.c + * refdef XS because __declspec(dllexport) incompatible with static + * defined(__WIN32__) && defined(__CYGWIN__) and pTk/tkWin.h + includes which defines WIN32 + + Tk.pm + * set $Tk::platform with help from $Tk::Config::win_arch + + DragDrop/site_test Tk/X11Font.pm t/create.t t/mwm.t + * $^O eq 'cygwin' and $Tk::platform eq 'MSWin32' + + DragDrop/Win32Site/Win32Site.xs + * #undef WIN32 from + + pTk/mTk/generic/tkPort.h + * resolve strcasecmp/stricmp #define mess + + pTk/Lang.h + * some defs ordinarily from tkUnixPort.h + + chnGlue.c + * Cygwin has O_BINARY + + IO/IO.xs + * Cygwin has O_NONBLOCK + +TODO + + + Any way to have X11 and native Win32 versions available + at the same time? Build with Xlib/Win32 emulator (see rxvt)? + + Fix gcc warnings, mostly in pTk win32 flavor? + + Test with cygwin-xfree X Server? + +Thu Aug 31 12:54:09 BST 2000 +Eric Fifer +efifer@dircon.co.uk diff -urN Tk800.022.orig/Scrollbar/Scrollbar.xs Tk800.022/Scrollbar/Scrollbar.xs --- Tk800.022.orig/Scrollbar/Scrollbar.xs Tue Jul 27 19:20:07 1999 +++ Tk800.022/Scrollbar/Scrollbar.xs Thu Aug 31 15:49:26 2000 @@ -12,7 +12,7 @@ #include "pTk/tkPort.h" #include "pTk/tkInt.h" -#ifdef WIN32 +#if defined(WIN32) || (defined(__WIN32__) && defined(__CYGWIN__)) #include "pTk/tkWin.h" #include "pTk/tkWinInt.h" #endif diff -urN Tk800.022.orig/Tk/MMutil.pm Tk800.022/Tk/MMutil.pm --- Tk800.022.orig/Tk/MMutil.pm Thu Mar 30 21:37:15 2000 +++ Tk800.022/Tk/MMutil.pm Thu Aug 31 15:49:26 2000 @@ -222,6 +222,19 @@ my @inc = split(/\s+/,$self->{'INC'}); my @def = split(/\s+/,$self->{'DEFINE'}); push(@def,qw(-DWIN32 -D__WIN32__)) if ($IsWin32); + if ($^O eq 'cygwin') + { + push(@def,qw(-D__CYGWIN__)); + if ($win_arch eq 'MSWin32') + { + push(@def,qw(-D__WIN32__)) unless $self->{'DEFINE'} =~ /-D__WIN32__/; + push(@def,qw(-DWIN32)) if $self->{'NAME'} eq 'Tk::pTk'; + } + elsif ($win_arch eq 'x') + { + push(@def,qw(-U_WIN32)); + } + } foreach (@inc) { s/\$\(TKDIR\)/$tk/g; @@ -486,6 +499,25 @@ my $extra = "-L$base -lcomdlg32 -lgdi32"; my $libs = $att{'LIBS'}->[0]; $att{'LIBS'}->[0] = "$extra $libs"; + } + if ($^O eq 'cygwin') + { + # NOTE: use gcc -shared instead of dllwrap (ld2), + # dllwrap tries to resolve all symbols, even those + # that are brought in from libraries like libpTk.a + push(@opt,'LD' => 'gcc -shared'); + if ($win_arch eq 'MSWin32') + { + my $extra = "-lcomdlg32 -lgdi32"; + my $libs = $att{'LIBS'}->[0]; + $att{'LIBS'}->[0] = "$extra $libs"; + $att{'DEFINE'} .= ' -D__WIN32__'; + $att{'DEFINE'} .= ' -DWIN32' if($att{'NAME'} eq 'Tk::pTk'); + } + elsif ($win_arch eq 'x') + { + $att{'DEFINE'} .= ' -U_WIN32'; + } } if (delete $att{'ptk_include'}) { diff -urN Tk800.022.orig/Tk/X11Font.pm Tk800.022/Tk/X11Font.pm --- Tk800.022.orig/Tk/X11Font.pm Fri Dec 24 09:41:43 1999 +++ Tk800.022/Tk/X11Font.pm Thu Aug 31 15:49:26 2000 @@ -94,7 +94,7 @@ my $me = shift; my $max = wantarray ? shift || 128 : 1; - if ($^O eq 'MSWin32') + if ($^O eq 'MSWin32' or ($^O eq 'cygwin' and $Tk::platform eq 'MSWin32')) { my $name = $me->{Name}; if (!defined $name) diff -urN Tk800.022.orig/Tk.pm Tk800.022/Tk.pm --- Tk800.022.orig/Tk.pm Sat Apr 29 10:36:41 2000 +++ Tk800.022/Tk.pm Thu Aug 31 15:49:26 2000 @@ -17,7 +17,18 @@ *fileevent = \&Tk::Event::IO::fileevent; -BEGIN { $Tk::platform = ($^O eq 'MSWin32') ? $^O : 'unix' }; +BEGIN { + if($^O eq 'cygwin') + { + require Tk::Config; + $Tk::platform = $Tk::Config::win_arch; + $Tk::platform = 'unix' if $Tk::platform eq 'x'; + } + else + { + $Tk::platform = ($^O eq 'MSWin32') ? $^O : 'unix'; + } +}; $Tk::tearoff = 1 if ($Tk::platform eq 'unix'); diff -urN Tk800.022.orig/chnGlue.c Tk800.022/chnGlue.c --- Tk800.022.orig/chnGlue.c Tue Jul 27 19:20:11 1999 +++ Tk800.022/chnGlue.c Thu Aug 31 15:49:26 2000 @@ -93,7 +93,7 @@ { if (strcmp(newValue,"binary") == 0) { -#if defined(WIN32) || defined(__EMX__) +#if defined(WIN32) || defined(__EMX__) || defined(__CYGWIN__) setmode(PerlIO_fileno(f), O_BINARY); #endif return TCL_OK; diff -urN Tk800.022.orig/pTk/Lang.h Tk800.022/pTk/Lang.h --- Tk800.022.orig/pTk/Lang.h Fri Apr 21 09:13:10 2000 +++ Tk800.022/pTk/Lang.h Thu Aug 31 15:49:26 2000 @@ -43,6 +43,11 @@ # define strcasecmp stricmp #endif +#ifdef __CYGWIN__ +#include +#define MASK_SIZE howmany(FD_SETSIZE, NFDBITS) +#endif + /* * When version numbers change here, must also go into the following files * and update the version numbers: diff -urN Tk800.022.orig/pTk/Makefile.PL Tk800.022/pTk/Makefile.PL --- Tk800.022.orig/pTk/Makefile.PL Tue Jul 27 19:20:25 1999 +++ Tk800.022/pTk/Makefile.PL Thu Aug 31 15:49:26 2000 @@ -45,6 +45,10 @@ { @list = qw(win xlib additions generic tixWin tixGeneric tclWin tclGeneric); } + elsif ($win_arch eq 'MSWin32' and $^O eq 'cygwin') + { + @list = qw(win xlib additions generic tixWin tixGeneric tclUnix tclGeneric); + } elsif ($win_arch eq 'open32') { @list = qw(open32 open32/h win xlib additions generic tixWin tixGeneric tclUnix tclGeneric ); @@ -145,7 +149,8 @@ $self->{PM}->{$name} = $self->catfile($dir,$name); } - if ($Tk::MMutil::IsWin32 or $win_arch eq 'open32' or $win_arch eq 'pm') + if ($Tk::MMutil::IsWin32 or $win_arch eq 'open32' or $win_arch eq 'pm' or + ($win_arch eq 'MSWin32' and $^O eq 'cygwin')) {my $ddir = $self->catdir('$(INST_ARCHLIBDIR)','X11'); my $sdir = $self->catdir('mTk','xlib','X11'); push(@{$self->{'dir_targets'}},$ddir); @@ -228,7 +233,7 @@ $dep .= "config :: " . join(" \\\n\t",map($self->catfile($_,".exists"),@{$self->{'dir_targets'}})) . "\n\t".$self->{NOECHO}."\$(NOOP)\n"; -if ($Tk::MMutil::IsWin32) +if ($Tk::MMutil::IsWin32 or ($win_arch eq 'MSWin32' and $^O eq 'cygwin')) { my $cc = $Config{'cc'}; my $file = 'tk.res'; diff -urN Tk800.022.orig/pTk/mTk/generic/tkPort.h Tk800.022/pTk/mTk/generic/tkPort.h --- Tk800.022.orig/pTk/mTk/generic/tkPort.h Tue Jul 27 19:20:32 1999 +++ Tk800.022/pTk/mTk/generic/tkPort.h Thu Aug 31 15:49:26 2000 @@ -29,6 +29,9 @@ # ifndef strcasecmp # define strcasecmp(a,b) stricmp(a,b) # endif +# ifdef __CYGWIN__ +# undef strcasecmp +# endif #else # if defined(MAC_TCL) # include "tkMacPort.h" diff -urN Tk800.022.orig/pTk/mTk/win/tkWinX.c Tk800.022/pTk/mTk/win/tkWinX.c --- Tk800.022.orig/pTk/mTk/win/tkWinX.c Mon Mar 27 15:07:36 2000 +++ Tk800.022/pTk/mTk/win/tkWinX.c Thu Aug 31 15:49:26 2000 @@ -53,6 +53,10 @@ * Forward declarations of procedures used in this file. */ +#ifdef __CYGWIN__ +static void DisplayFileProc _ANSI_ARGS_((ClientData clientData, + int flags)); +#endif static void GenerateXEvent _ANSI_ARGS_((HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)); static unsigned int GetState _ANSI_ARGS_((UINT message, WPARAM wParam, @@ -384,6 +388,12 @@ AllocNone); winDisplay = (TkDisplay *) ckalloc(sizeof(TkDisplay)); winDisplay->display = display; +#ifdef __CYGWIN__ + if((ConnectionNumber(display) = open("/dev/windows", O_RDONLY)) < 0) + return NULL; + Tcl_CreateFileHandler(ConnectionNumber(display), TCL_READABLE, + DisplayFileProc, (ClientData) winDisplay); +#endif return winDisplay; } @@ -447,9 +457,63 @@ } ckfree((char *) display->screens); } +#ifdef __CYGWIN__ + if (dispPtr->display != 0) { + Tcl_DeleteFileHandler(ConnectionNumber(dispPtr->display)); + close(ConnectionNumber(dispPtr->display)); + } +#endif ckfree((char *) display); ckfree((char *) dispPtr); } + +#ifdef __CYGWIN__ +/* + *---------------------------------------------------------------------- + * + * DisplayFileProc -- + * + * This procedure implements the file handler for the /dev/windows + * connection. + * + * Results: + * None. + * + * Side effects: + * Process Win32 message queue. Compare to tclWin/tclWinNotify.c + * Tcl_WaitForEvent() event loop. + * + *---------------------------------------------------------------------- + */ + +static void +DisplayFileProc(clientData, flags) + ClientData clientData; /* The display pointer. */ + int flags; /* Should be TCL_READABLE. */ +{ + TkDisplay *dispPtr = (TkDisplay *) clientData; + Display *display = dispPtr->display; + MSG msg; + int n; + + /* NOTE: read returns the result of GetMessage */ + /* *not* the number of bytes read */ + n = read(ConnectionNumber(display), &msg, sizeof(MSG)); + if(n == 0) { + /* + * The application is exiting, so repost the quit message + * and start unwinding. + */ + + PostQuitMessage(msg.wParam); + return; + } + if(n > 0) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } +} +#endif /* *---------------------------------------------------------------------- diff -urN Tk800.022.orig/t/create.t Tk800.022/t/create.t --- Tk800.022.orig/t/create.t Sun Mar 26 13:25:56 2000 +++ Tk800.022/t/create.t Thu Aug 31 15:49:27 2000 @@ -61,7 +61,10 @@ ) ); - @class = grep(!/InputO/,@class) if ($^O eq 'MSWin32'); + require Tk if ($^O eq 'cygwin'); + @class = grep(!/InputO/,@class) if ($^O eq 'MSWin32' or + ($^O eq 'cygwin' and defined($Tk::platform) + and $Tk::platform eq 'MSWin32')); plan test => (13*@class+3); diff -urN Tk800.022.orig/t/mwm.t Tk800.022/t/mwm.t --- Tk800.022.orig/t/mwm.t Tue Jul 27 19:21:22 1999 +++ Tk800.022/t/mwm.t Thu Aug 31 15:49:27 2000 @@ -1,7 +1,8 @@ BEGIN { $^W = 1; $| = 1; - if ($^O eq 'MSWin32') + require Tk if ($^O eq 'cygwin'); + if ($^O eq 'MSWin32' or ($^O eq 'cygwin' and $Tk::platform eq 'MSWin32')) { print "1..0\n"; exit; diff -urN Tk800.022.orig/tkGlue.c Tk800.022/tkGlue.c --- Tk800.022.orig/tkGlue.c Fri Apr 21 09:13:10 2000 +++ Tk800.022/tkGlue.c Thu Aug 31 15:49:27 2000 @@ -8,6 +8,10 @@ #include #include #include +#ifdef __CYGWIN__ +# undef XS +# define XS(name) void name(pTHXo_ CV* cv) +#endif #define Tkgv_fullname(x,y,z) gv_fullname3(x,y,z) @@ -26,7 +30,7 @@ #include "pTk/Xlib_f.h" #include "pTk/tkEvent.h" #include "pTk/tkEvent.m" -#ifdef WIN32 +#if defined(WIN32) || (defined(__WIN32__) && defined(__CYGWIN__)) #include "pTk/tkWin.h" #include "pTk/tkWinInt.h" #include "pTk/tkWin_f.h" @@ -5123,7 +5127,7 @@ Lang_OSHandle(fd) int fd; { -#ifdef WIN32 +#if defined(WIN32) && !defined(__CYGWIN__) return win32_get_osfhandle(fd); #else return fd; diff -urN Tk800.022.orig/tkWin32Dll.c Tk800.022/tkWin32Dll.c --- Tk800.022.orig/tkWin32Dll.c Tue Jul 27 19:21:23 1999 +++ Tk800.022/tkWin32Dll.c Thu Aug 31 15:49:27 2000 @@ -13,7 +13,7 @@ #include "pTk/tkPort.h" -#ifdef WIN32 +#if defined(WIN32) || (defined(__WIN32__) && defined(__CYGWIN__)) #include "pTk/tkWinInt.h"