[PD-cvs] pd/src SConscript, 1.1.4.3, 1.1.4.4 d_array.c, 1.3.4.3, 1.3.4.3.2.1 d_fft.c, 1.2.4.1, 1.2.4.1.2.1 d_filter.c, 1.3.4.3, 1.3.4.3.2.1 d_osc.c, 1.2.4.1, 1.2.4.1.2.1 d_soundfile.c, 1.4.4.11, 1.4.4.11.2.1 g_array.c, 1.3.4.4.2.1, 1.3.4.4.2.2 g_canvas.c, 1.4.4.1.2.2, 1.4.4.1.2.3 g_canvas.h, 1.3.4.3.2.1, 1.3.4.3.2.2 g_editor.c, 1.4.4.2.2.2, 1.4.4.2.2.3 g_graph.c, 1.3.4.2.2.2, 1.3.4.2.2.3 g_numbox.c, 1.4, 1.4.8.1 g_readwrite.c, 1.3.8.1, 1.3.8.2 g_rtext.c, 1.4.8.1, 1.4.8.2 g_template.c, 1.4.8.1, 1.4.8.2 g_text.c, 1.5.4.2.2.1, 1.5.4.2.2.2 m_atomic.h, 1.1.2.1, 1.1.2.1.2.1 m_fifo.c, 1.1.2.14, 1.1.2.14.2.1 m_glob.c, 1.4.4.2, 1.4.4.2.2.1 m_pd.h, 1.4.4.11.2.1, 1.4.4.11.2.2 m_sched.c, 1.5.4.35, 1.5.4.35.2.1 m_simd_sse_gcc.c, 1.1.4.13, 1.1.4.13.2.1 notes.txt, 1.6.4.3, 1.6.4.3.2.1 s_audio_asio.cpp, 1.1.4.26.2.1, 1.1.4.26.2.2 s_audio_jack.c, 1.5.4.8, 1.5.4.8.2.1 s_audio_pa.c, 1.4.4.7, 1.4.4.7.2.1 s_file.c, 1.2.4.8.2.1, 1.2.4.8.2.2 s_inter.c, 1.5.4.10.2.1, 1.5.4.10.2.2 s_loader.c, 1.4.4.5, 1.4.4.5.2.1 s_main.c, 1.7.4.17.2.1, 1.7.4.17.2.2 s_midi.c, 1.4.4.1, 1.4.4.1.2.1 s_midi_alsa.c, 1.1.2.2, 1.1.2.2.2.1 s_midi_pm.c, 1.4.4.1, 1.4.4.1.2.1 s_stuff.h, 1.5.4.10, 1.5.4.10.2.1 t_main.c, 1.2, 1.2.8.1 t_tkcmd.c, 1.2.4.1, 1.2.4.1.2.1 u_main.tk, 1.4.4.10.2.4, 1.4.4.10.2.5 u_pdsend.c, 1.2, 1.2.8.1 x_connective.c, 1.3.4.1.2.1, 1.3.4.1.2.2 x_misc.c, 1.2, 1.2.8.1 Makefile.am, 1.1.4.8, NONE

Tim Blechmann timblech at users.sourceforge.net
Tue Jul 12 17:11:16 CEST 2005


Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29080

Modified Files:
      Tag: devel_0_39
	SConscript d_array.c d_fft.c d_filter.c d_osc.c d_soundfile.c 
	g_array.c g_canvas.c g_canvas.h g_editor.c g_graph.c 
	g_numbox.c g_readwrite.c g_rtext.c g_template.c g_text.c 
	m_atomic.h m_fifo.c m_glob.c m_pd.h m_sched.c m_simd_sse_gcc.c 
	notes.txt s_audio_asio.cpp s_audio_jack.c s_audio_pa.c 
	s_file.c s_inter.c s_loader.c s_main.c s_midi.c s_midi_alsa.c 
	s_midi_pm.c s_stuff.h t_main.c t_tkcmd.c u_main.tk u_pdsend.c 
	x_connective.c x_misc.c 
Removed Files:
      Tag: devel_0_39
	Makefile.am 
Log Message:
updating devel_0_39

Index: s_loader.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/s_loader.c,v
retrieving revision 1.4.4.5
retrieving revision 1.4.4.5.2.1
diff -C2 -d -r1.4.4.5 -r1.4.4.5.2.1
*** s_loader.c	3 Mar 2005 13:39:46 -0000	1.4.4.5
--- s_loader.c	12 Jul 2005 15:11:11 -0000	1.4.4.5.2.1
***************
*** 14,18 ****
  #include <windows.h>
  #endif
! #ifdef MACOSX
  #include <mach-o/dyld.h> 
  #endif
--- 14,18 ----
  #include <windows.h>
  #endif
! #ifdef __APPLE__
  #include <mach-o/dyld.h> 
  #endif
***************
*** 38,42 ****
      ".pd_linux";
  #endif
! #ifdef MACOSX
      ".pd_darwin";
  #endif
--- 38,42 ----
      ".pd_linux";
  #endif
! #ifdef __APPLE__
      ".pd_darwin";
  #endif
***************
*** 94,98 ****
          *lastdot = 0;
  
! #ifdef MACOSX
      strcpy(symname, "_");
      strcat(symname, nameptr);
--- 94,98 ----
          *lastdot = 0;
  
! #ifdef __APPLE__
      strcpy(symname, "_");
      strcat(symname, nameptr);
***************
*** 123,127 ****
      makeout = (t_xxx)GetProcAddress(ntdll, symname);  
  #endif
! #ifdef MACOSX
      {
          NSObjectFileImage image; 
--- 123,127 ----
      makeout = (t_xxx)GetProcAddress(ntdll, symname);  
  #endif
! #ifdef __APPLE__
      {
          NSObjectFileImage image; 

Index: s_audio_asio.cpp
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/s_audio_asio.cpp,v
retrieving revision 1.1.4.26.2.1
retrieving revision 1.1.4.26.2.2
diff -C2 -d -r1.1.4.26.2.1 -r1.1.4.26.2.2
*** s_audio_asio.cpp	22 May 2005 12:54:47 -0000	1.1.4.26.2.1
--- s_audio_asio.cpp	12 Jul 2005 15:11:10 -0000	1.1.4.26.2.2
***************
*** 172,177 ****
  
  /* from m_sched.c: */
- extern "C" int sys_keepsched;
- extern "C" int sys_callbackscheduler;
  extern "C" double sys_time_per_dsp_tick;
  extern "C" double sys_time;
--- 172,175 ----
***************
*** 298,303 ****
  		{
  			/* use callback scheduler */
! 			sys_keepsched = 0;
! 			sys_callbackscheduler = 1;
  			asio_ticks_per_callback = asio_bufsize / sys_dacblocksize;
  			post("ASIO: using callback-based scheduler");
--- 296,300 ----
  		{
  			/* use callback scheduler */
! 			sys_setscheduler(1);
  			asio_ticks_per_callback = asio_bufsize / sys_dacblocksize;
  			post("ASIO: using callback-based scheduler");
***************
*** 570,574 ****
  		if (sys_callbackscheduler)
  		{
! 			sys_callbackscheduler = sys_keepsched = 0;
  		}
  	}
--- 567,571 ----
  		if (sys_callbackscheduler)
  		{
! 			sys_setscheduler(0);
  		}
  	}

Index: s_main.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/s_main.c,v
retrieving revision 1.7.4.17.2.1
retrieving revision 1.7.4.17.2.2
diff -C2 -d -r1.7.4.17.2.1 -r1.7.4.17.2.2
*** s_main.c	22 May 2005 13:02:26 -0000	1.7.4.17.2.1
--- s_main.c	12 Jul 2005 15:11:11 -0000	1.7.4.17.2.2
***************
*** 8,12 ****
   */
  
! char pd_version[] = "Pd version 0.39 TEST 2 devel\n";
  char pd_compiletime[] = __TIME__;
  char pd_compiledate[] = __DATE__;
--- 8,12 ----
   */
  
! char pd_version[] = "Pd version 0.39 TEST 3 devel\n";
  char pd_compiletime[] = __TIME__;
  char pd_compiledate[] = __DATE__;
***************
*** 41,44 ****
--- 41,45 ----
  void sys_findprogdir(char *progname);
  int sys_startgui(const char *guipath);
+ void sys_init_idle_callbacks(void);
  int sys_rcfile(void);
  int m_scheduler(void);
***************
*** 297,300 ****
--- 298,304 ----
  #endif
  	}
+ 	/* initalize idle callbacks before starting the gui */
+ 	sys_init_idle_callbacks();
+ 	
  	/* } tb */
  
***************
*** 306,309 ****
--- 310,314 ----
      if (sys_version)    /* if we were just asked our version, exit here. */
          return (0);
+ 
      if (sys_startgui(sys_guidir->s_name))       /* start the gui */
          return(1);
***************
*** 416,419 ****
--- 421,427 ----
  "-nomidiout       -- suppress MIDI output\n",
  "-nomidi          -- suppress MIDI input and output\n",
+ #ifdef USEAPI_ALSA
+ "-alsamidi        -- use ALSA midi API\n",
+ #endif
  
  "\nother flags:\n",
***************
*** 481,485 ****
      char sbuf[MAXPDSTRING], sbuf2[MAXPDSTRING], *sp;
      char *lastslash; 
! #ifdef UNISTD
      struct stat statbuf;
  #endif
--- 489,493 ----
      char sbuf[MAXPDSTRING], sbuf2[MAXPDSTRING], *sp;
      char *lastslash; 
! #if UNISTD
      struct stat statbuf;
  #endif
***************
*** 643,647 ****
          else if (!strcmp(*argv, "-cb_scheduler"))
          {
!             sys_callbackscheduler = 1;
              argc--; argv++;
  		}
--- 651,655 ----
          else if (!strcmp(*argv, "-cb_scheduler"))
          {
!             sys_setscheduler(1);
              argc--; argv++;
  		}
***************
*** 691,694 ****
--- 699,707 ----
              argc -= 2; argv +=2;
          }
+         else if (!strcmp(*argv, "-alsamidi"))
+         {
+           sys_set_midi_api(API_ALSA);
+             argc--; argv++;
+         }
  #endif
  #ifdef USEAPI_JACK

Index: u_main.tk
===================================================================
RCS file: /cvsroot/pure-data/pd/src/u_main.tk,v
retrieving revision 1.4.4.10.2.4
retrieving revision 1.4.4.10.2.5
diff -C2 -d -r1.4.4.10.2.4 -r1.4.4.10.2.5
*** u_main.tk	1 Jul 2005 18:08:55 -0000	1.4.4.10.2.4
--- u_main.tk	12 Jul 2005 15:11:12 -0000	1.4.4.10.2.5
***************
*** 13,31 ****
  # all this changes are labeled with #######iemlib##########
  
! 
  if { $tcl_platform(platform) == "windows" }  {
! 	 set pd_nt 1
! 	 puts stderr {Configuring for Windows}
! } elseif {$tcl_platform(os) == "Darwin"} {
! 	 set pd_nt 2
! 	 puts stderr {Configuring for MacOS X}
! } else {
! 	 set pd_nt 0	 
! 	 puts stderr {Configuring for UNIX}
! }
! 
! # (The above is 0 for unix, 1 for microsoft, and 2 for Mac OSX.  The first
! # line is automatically munged by the relevant makefiles.)
! 
  
  # Tearoff is set to true by default:
--- 13,24 ----
  # all this changes are labeled with #######iemlib##########
  
! # set pd_nt (bad name) 0 for unix, 1 for microsoft, and 2 for Mac OSX.
  if { $tcl_platform(platform) == "windows" }  {
!          set pd_nt 1
! } elseif { $tcl_platform(os) == "Darwin" } {  
!          set pd_nt 2
! } else { 
!          set pd_nt 0
! }        
  
  # Tearoff is set to true by default:
***************
*** 56,60 ****
      set pd_gui2 [string range $argv0 0 [expr [string last / $argv0 ] - 1]]
      set pd_guidir $pd_gui2/..
!     load $pd_guidir/bin/pdtcl
      set pd_tearoff 0
  
--- 49,53 ----
      set pd_gui2 [string range $argv0 0 [expr [string last / $argv0 ] - 1]]
      set pd_guidir $pd_gui2/..
!     load $pd_guidir/bin/libPdTcl.dylib
      set pd_tearoff 0
  
***************
*** 96,100 ****
  # the menus are instantiated here for the main window
  # for the patch windows, they are created by pdtk_canvas_new
- option add *font {{Bitstream Vera Sans} 10}
  menu .mbar
  canvas .dummy -height 2p -width 6c
--- 89,92 ----
***************
*** 111,117 ****
      .mbar add cascade -label "Windows" -menu .mbar.windows
      .mbar add cascade -label "Media" -menu .mbar.audio
- # a menu on the main menubar named $whatever.help while be treated
- # as a special menu with specific behaviors on different platforms.
- # See SPECIAL MENUS IN MENUBARS http://www.tcl.tk/man/tcl8.4/TkCmd/menu.htm
  	 menu .mbar.help -tearoff $pd_tearoff
  	 .mbar add cascade -label "Help" -menu .mbar.help
--- 103,106 ----
***************
*** 122,132 ****
      .mbar add cascade -label "Media" -menu .mbar.audio
      .mbar add cascade -label "Window" -menu .mbar.windows
! # a menu on the main menubar named "$whatever.help" while be treated
! # as a special menu with specific behaviors on different platforms.
! # See SPECIAL MENUS IN MENUBARS http://www.tcl.tk/man/tcl8.4/TkCmd/menu.htm
! # Apple doesn't allow cascading menus in their Help so I had to call this 
! # one $mbar.docs # <hans at at.or.at>
! 	 menu .mbar.docs -tearoff $pd_tearoff
! 	 .mbar add cascade -label "Help" -menu .mbar.docs
  }
  
--- 111,116 ----
      .mbar add cascade -label "Media" -menu .mbar.audio
      .mbar add cascade -label "Window" -menu .mbar.windows
!     menu .mbar.help -tearoff $pd_tearoff
!     .mbar add cascade -label "Help" -menu .mbar.help
  }
  
***************
*** 202,206 ****
  . configure -menu .mbar -width 200 -height 150
  
! ############### set up global/namespace variables ###############
  
  set untitled_number 1
--- 186,190 ----
  . configure -menu .mbar -width 200 -height 150
  
! ############### set up global variables ################################
  
  set untitled_number 1
***************
*** 212,221 ****
  set pd_undocanvas no
  
- namespace eval ::pdtheme {
- #    array set theme "border purple bg white box gray line gray50 arrow last object peru message orange inlet purple outlet red atom yellow graph red text black selected #ff049b lasso green fontweight normal"
-     array set theme "border black bg white box black line black arrow none object black message black inlet purple outlet red atom black graph black text black selected blue lasso blue fontweight bold"
-     foreach element [array names theme] {
- 	eval "set ::pdtheme::$element $theme($element)"}}
- 
  ################ utility functions #########################
  
--- 196,199 ----
***************
*** 451,459 ****
  	 global help_top_directory pd_tearoff
  
- # see if $subdir exists at all...
-     if { [ catch {
-     	if { [lsearch [glob -dir $help_top_directory * ] "$help_top_directory/$subdir" ] == -1} { return }
-     } ] } { return }
- 
  	 set menudir $help_top_directory/$subdir
  
--- 429,432 ----
***************
*** 479,483 ****
  
  proc menu_addstd {mbar} {
!     global pd_apilist pd_nt pd_tearoff
  #          the "Audio" menu
      $mbar.audio add command -label {audio ON} -accelerator [accel_munge "Ctrl+/"] \
--- 452,456 ----
  
  proc menu_addstd {mbar} {
!     global pd_apilist pd_midiapilist pd_nt pd_tearoff
  #          the "Audio" menu
      $mbar.audio add command -label {audio ON} -accelerator [accel_munge "Ctrl+/"] \
***************
*** 491,494 ****
--- 464,473 ----
  		-command {pd [concat pd audio-setapi $pd_whichapi \;]}
      }
+     for {set x 0} {$x<[llength $pd_midiapilist]} {incr x} {
+     	$mbar.audio add radiobutton -label [lindex [lindex $pd_midiapilist $x] 0] \
+ 	    -command {menu_midi 0} -variable pd_whichmidiapi \
+ 	    	-value [lindex [lindex $pd_midiapilist $x] 1]\
+ 		-command {pd [concat pd midi-setapi $pd_whichmidiapi \;]}
+     }
  	 if {$pd_nt != 2} {
      $mbar.audio add command -label {Audio settings...} \
***************
*** 528,554 ****
  #          the "Help" menu
  	 if {$pd_nt != 2} {
- # a menu on the main menubar named "$whatever.help" while be treated
- # as a special menu with specific behaviors on different platforms.
- # See SPECIAL MENUS IN MENUBARS http://www.tcl.tk/man/tcl8.4/TkCmd/menu.htm
      $mbar.help add command -label {About Pd} \
  	-command {menu_doc_open doc/1.manual 1.introduction.txt} 
-     $mbar.help add command -label {Pure Documentation...} \
- 	-command {menu_documentation} 
- 		  # add menu items for each section instead of using Pd patches
- 		  $mbar.help add separator
- 		  set helpmenuname help
- 	 } else {
- # Apple doesn't allow cascading menus in their Help so I had to call this 
- # one "docs"  <hans at at.or.at>
- 		  set helpmenuname docs
  	 }
! 
! 	 $mbar.$helpmenuname add command -label {1 manual...} \
  		  -command {menu_doc_open doc/1.manual index.htm} 
! 	 doc_submenu $mbar.$helpmenuname 2.control.examples
! 	 doc_submenu $mbar.$helpmenuname 3.audio.examples
! 	 doc_submenu $mbar.$helpmenuname 4.fft.examples
! 	 doc_submenu $mbar.$helpmenuname 5.reference
! 	 doc_submenu $mbar.$helpmenuname 6.externs
  }
  
--- 507,517 ----
  #          the "Help" menu
  	 if {$pd_nt != 2} {
      $mbar.help add command -label {About Pd} \
  	-command {menu_doc_open doc/1.manual 1.introduction.txt} 
  	 }
!     $mbar.help add command -label {Html ...} \
  		  -command {menu_doc_open doc/1.manual index.htm} 
!     $mbar.help add command -label {Browser ...} \
!     	-command {menu_documentation} 
  }
  
***************
*** 872,876 ****
  
     wm geometry $name $geometry
!     canvas $name.c -width $width -height $height -bg $::pdtheme::bg \
      	-yscrollcommand "$name.scrollvert set" \
      	-xscrollcommand "$name.scrollhort set" \
--- 835,839 ----
  
     wm geometry $name $geometry
!     canvas $name.c -width $width -height $height -background white \
      	-yscrollcommand "$name.scrollvert set" \
      	-xscrollcommand "$name.scrollhort set" \
***************
*** 1124,1139 ****
  # the help menu
  
- # a menu on the main menubar named "$whatever.help" while be treated
- # as a special menu with specific behaviors on different platforms.
- # See SPECIAL MENUS IN MENUBARS http://www.tcl.tk/man/tcl8.4/TkCmd/menu.htm
- 	 if {$pd_nt != 2} {
      menu $name.m.help -tearoff $pd_tearoff
      $name.m add cascade -label Help -menu $name.m.help
- 	 } else {
- 		  # Apple doesn't allow cascading menus in their Help
- 		  # so I had to call this one "docs". <hans at at.or.at>
- 		  menu $name.m.docs -tearoff $pd_tearoff
- 		  $name.m add cascade -label Help -menu  $name.m.docs
- 	 }
  
      menu_addstd $name.m
--- 1087,1092 ----
***************
*** 1766,1770 ****
  ############ pdtk_gatom_dialog -- run a gatom dialog #########
  
! # see graph_apply, etc., for comments about handling variable names here...
  
  proc gatom_escape {sym} {
--- 1719,1730 ----
  ############ pdtk_gatom_dialog -- run a gatom dialog #########
  
! # dialogs like this one can come up in many copies; but in TK the easiest
! # way to get data from an "entry", etc., is to set an associated variable
! # name.  This is especially true for grouped "radio buttons".  So we have
! # to synthesize variable names for each instance of the dialog.  The dialog
! # gets a TK pathname $id, from which it strips the leading "." to make a
! # variable suffix $vid.  Then you can get the actual value out by asking for
! # [eval concat $$variablename].  There should be an easier way but I don't see
! # it yet.
  
  proc gatom_escape {sym} {
***************
*** 1990,2128 ****
  }
  
- ############ pdtk_graph_dialog -- dialog window for graphs #########
- 
- # the graph and array dialogs can come up in many copies; but in TK the easiest
- # way to get data from an "entry", etc., is to set an associated variable
- # name.  This is especially true for grouped "radio buttons".  So we have
- # to synthesize variable names for each instance of the dialog.  The dialog
- # gets a TK pathname $id, from which it strips the leading "." to make a
- # variable suffix $vid.  Then you can get the actual value out by asking for
- # [eval concat $$variablename].  There should be an easier way but I don't see
- # it yet.
- 
- proc graph_apply {id} {
- # strip "." from the TK id to make a variable name suffix 
-     set vid [string trimleft $id .]
- # for each variable, make a local variable to hold its name...
-     set var_graph_x1 [concat graph_x1_$vid]
-     global $var_graph_x1
-     set var_graph_x2 [concat graph_x2_$vid]
-     global $var_graph_x2
-     set var_graph_xpix [concat graph_xpix_$vid]
-     global $var_graph_xpix
-     set var_graph_y1 [concat graph_y1_$vid]
-     global $var_graph_y1
-     set var_graph_y2 [concat graph_y2_$vid]
-     global $var_graph_y2
-     set var_graph_ypix [concat graph_ypix_$vid]
-     global $var_graph_ypix
- 
-     pd [concat $id dialog \
-     	[eval concat $$var_graph_x1] \
-     	[eval concat $$var_graph_y1] \
-     	[eval concat $$var_graph_x2] \
-     	[eval concat $$var_graph_y2] \
-     	[eval concat $$var_graph_xpix] \
-     	[eval concat $$var_graph_ypix] \
- 	\;]
- }
- 
- proc graph_cancel {id} {
-     set cmd [concat $id cancel \;]
- #    puts stderr $cmd
-     pd $cmd
- }
- 
- proc graph_ok {id} {
-     graph_apply $id
-     graph_cancel $id
- }
- 
- proc pdtk_graph_dialog {id x1 y1 x2 y2 xpix ypix} {
-     set vid [string trimleft $id .]
-     set var_graph_x1 [concat graph_x1_$vid]
-     global $var_graph_x1
-     set var_graph_x2 [concat graph_x2_$vid]
-     global $var_graph_x2
-     set var_graph_xpix [concat graph_xpix_$vid]
-     global $var_graph_xpix
-     set var_graph_y1 [concat graph_y1_$vid]
-     global $var_graph_y1
-     set var_graph_y2 [concat graph_y2_$vid]
-     global $var_graph_y2
-     set var_graph_ypix [concat graph_ypix_$vid]
-     global $var_graph_ypix
- 
-     set $var_graph_x1 $x1
-     set $var_graph_x2 $x2
-     set $var_graph_xpix $xpix
-     set $var_graph_y1 $y1
-     set $var_graph_y2 $y2
-     set $var_graph_ypix $ypix
- 
-     toplevel $id
-     wm title $id {graph}
-     wm protocol $id WM_DELETE_WINDOW [concat graph_cancel $id]
- 
-     label $id.label -text {GRAPH BOUNDS}
-     pack $id.label -side top
- 
-     frame $id.buttonframe
-     pack $id.buttonframe -side bottom -fill x -pady 2m
-     button $id.buttonframe.cancel -text {Cancel}\
-     	-command "graph_cancel $id"
-     button $id.buttonframe.apply -text {Apply}\
-     	-command "graph_apply $id"
-     button $id.buttonframe.ok -text {OK}\
-     	-command "graph_ok $id"
-     pack $id.buttonframe.cancel -side left -expand 1
-     pack $id.buttonframe.apply -side left -expand 1
-     pack $id.buttonframe.ok -side left -expand 1
-     
-     frame $id.xrangef
-     pack $id.xrangef -side top
-     
-     label $id.xrangef.l1 -text "X from:"
-     entry $id.xrangef.x1 -textvariable $var_graph_x1 -width 7
-     label $id.xrangef.l2 -text "to:"
-     entry $id.xrangef.x2 -textvariable $var_graph_x2 -width 7
-     label $id.xrangef.l3 -text "screen width:"
-     entry $id.xrangef.xpix -textvariable $var_graph_xpix -width 7
-     pack $id.xrangef.l1 $id.xrangef.x1 \
-     	 $id.xrangef.l2 $id.xrangef.x2 \
- 	 $id.xrangef.l3 $id.xrangef.xpix -side left
-     
-     frame $id.yrangef
-     pack $id.yrangef -side top
- 
- # dig in the following that the upper bound is labeled y1 but the variable is
- # y2, etc. This is to deal with the inconsistent use of "upper and lower"
- # graph bounds... in the dialog the upper Y bound is the lower valued Y pixel.
-     label $id.yrangef.l1 -text "Y from:"
-     entry $id.yrangef.y1 -textvariable $var_graph_y2 -width 7
-     label $id.yrangef.l2 -text "to:"
-     entry $id.yrangef.y2 -textvariable $var_graph_y1 -width 7
-     label $id.yrangef.l3 -text "screen height:"
-     entry $id.yrangef.ypix -textvariable $var_graph_ypix -width 7
-     pack $id.yrangef.l1 $id.yrangef.y1 \
-     	 $id.yrangef.l2 $id.yrangef.y2 \
- 	 $id.yrangef.l3 $id.yrangef.ypix -side left
- 
-     bind $id.xrangef.x1 <KeyPress-Return> [concat graph_ok $id]
-     bind $id.xrangef.x2 <KeyPress-Return> [concat graph_ok $id]
-     bind $id.xrangef.xpix <KeyPress-Return> [concat graph_ok $id]
-     bind $id.yrangef.y1 <KeyPress-Return> [concat graph_ok $id]
-     bind $id.yrangef.y2 <KeyPress-Return> [concat graph_ok $id]
-     bind $id.yrangef.ypix <KeyPress-Return> [concat graph_ok $id]
-     pdtk_standardkeybindings $id.xrangef.x1
-     pdtk_standardkeybindings $id.xrangef.x2
-     pdtk_standardkeybindings $id.xrangef.xpix
-     pdtk_standardkeybindings $id.yrangef.y1
-     pdtk_standardkeybindings $id.yrangef.y2
-     pdtk_standardkeybindings $id.yrangef.ypix
-     $id.xrangef.x2 select from 0
-     $id.xrangef.x2 select adjust end
-     focus $id.xrangef.x2
- }
  
  # begin of change "iemlib"
--- 1950,1953 ----
***************
*** 2855,2858 ****
--- 2680,2685 ----
  
  ############ pdtk_array_dialog -- dialog window for arrays #########
+ # see comments above (pdtk_gatom_dialog) about variable name handling 
+ 
  proc array_apply {id} {
  # strip "." from the TK id to make a variable name suffix 
***************
*** 2999,3006 ****
--- 2826,2836 ----
  
  ############ pdtk_canvas_dialog -- dialog window for canvass #########
+ # see comments above (pdtk_gatom_dialog) about variable name handling 
+ 
  proc canvas_apply {id} {
  # strip "." from the TK id to make a variable name suffix 
      set vid [string trimleft $id .]
  # for each variable, make a local variable to hold its name...
+ 
      set var_canvas_xscale [concat canvas_xscale_$vid]
      global $var_canvas_xscale
***************
*** 3009,3018 ****
      set var_canvas_graphme [concat canvas_graphme_$vid]
      global $var_canvas_graphme
! #    set var_canvas_stretch [concat canvas_stretch_$vid]
! #    global $var_canvas_stretch
      pd [concat $id donecanvasdialog \
      	[eval concat $$var_canvas_xscale] \
  	[eval concat $$var_canvas_yscale] \
      	[eval concat $$var_canvas_graphme] \
  	\;]
  }
--- 2839,2871 ----
      set var_canvas_graphme [concat canvas_graphme_$vid]
      global $var_canvas_graphme
!     set var_canvas_x1 [concat canvas_x1_$vid]
!     global $var_canvas_x1
!     set var_canvas_x2 [concat canvas_x2_$vid]
!     global $var_canvas_x2
!     set var_canvas_xpix [concat canvas_xpix_$vid]
!     global $var_canvas_xpix
!     set var_canvas_xmargin [concat canvas_xmargin_$vid]
!     global $var_canvas_xmargin
!     set var_canvas_y1 [concat canvas_y1_$vid]
!     global $var_canvas_y1
!     set var_canvas_y2 [concat canvas_y2_$vid]
!     global $var_canvas_y2
!     set var_canvas_ypix [concat canvas_ypix_$vid]
!     global $var_canvas_ypix
!     set var_canvas_ymargin [concat canvas_ymargin_$vid]
!     global $var_canvas_ymargin
! 
      pd [concat $id donecanvasdialog \
      	[eval concat $$var_canvas_xscale] \
  	[eval concat $$var_canvas_yscale] \
      	[eval concat $$var_canvas_graphme] \
+     	[eval concat $$var_canvas_x1] \
+     	[eval concat $$var_canvas_y1] \
+     	[eval concat $$var_canvas_x2] \
+     	[eval concat $$var_canvas_y2] \
+     	[eval concat $$var_canvas_xpix] \
+     	[eval concat $$var_canvas_ypix] \
+     	[eval concat $$var_canvas_xmargin] \
+     	[eval concat $$var_canvas_ymargin] \
  	\;]
  }
***************
*** 3028,3033 ****
  }
  
! proc pdtk_canvas_dialog {id xscale yscale graphme stretch} {
      set vid [string trimleft $id .]
  
      set var_canvas_xscale [concat canvas_xscale_$vid]
--- 2881,2887 ----
  }
  
! proc canvas_checkcommand {id} {
      set vid [string trimleft $id .]
+ #    puts stderr [concat canvas_checkcommand $id $vid]
  
      set var_canvas_xscale [concat canvas_xscale_$vid]
***************
*** 3037,3047 ****
      set var_canvas_graphme [concat canvas_graphme_$vid]
      global $var_canvas_graphme
! #    set var_canvas_stretch [concat canvas_stretch_$vid]
! #    global $var_canvas_stretch
  
      set $var_canvas_xscale $xscale
      set $var_canvas_yscale $yscale
      set $var_canvas_graphme $graphme
! #    set $var_canvas_stretch $stretch
  
      toplevel $id
--- 2891,3000 ----
      set var_canvas_graphme [concat canvas_graphme_$vid]
      global $var_canvas_graphme
!     set var_canvas_x1 [concat canvas_x1_$vid]
!     global $var_canvas_x1
!     set var_canvas_x2 [concat canvas_x2_$vid]
!     global $var_canvas_x2
!     set var_canvas_xpix [concat canvas_xpix_$vid]
!     global $var_canvas_xpix
!     set var_canvas_xmargin [concat canvas_xmargin_$vid]
!     global $var_canvas_xmargin
!     set var_canvas_y1 [concat canvas_y1_$vid]
!     global $var_canvas_y1
!     set var_canvas_y2 [concat canvas_y2_$vid]
!     global $var_canvas_y2
!     set var_canvas_ypix [concat canvas_ypix_$vid]
!     global $var_canvas_ypix
!     set var_canvas_ymargin [concat canvas_ymargin_$vid]
!     global $var_canvas_ymargin
! 
!     if { [eval concat $$var_canvas_graphme] != 0 } {
!         $id.xrange.entry1 configure -state normal
!         $id.xrange.entry2 configure -state normal
!         $id.xrange.entry3 configure -state normal
!         $id.xrange.entry4 configure -state normal
!         $id.yrange.entry1 configure -state normal
!         $id.yrange.entry2 configure -state normal
!         $id.yrange.entry3 configure -state normal
!         $id.yrange.entry4 configure -state normal
!         $id.xscale.entry configure -state disabled
!         $id.yscale.entry configure -state disabled
!         set x1 [eval concat $$var_canvas_x1]
!         set y1 [eval concat $$var_canvas_y1]
!         set x2 [eval concat $$var_canvas_x2]
!         set y2 [eval concat $$var_canvas_y2]
!         if { [eval concat $$var_canvas_x1] == 0 && \
!              [eval concat $$var_canvas_y1] == 0 && \
!              [eval concat $$var_canvas_x2] == 0 && \
!              [eval concat $$var_canvas_y2] == 0 } {
!                 set $var_canvas_x2 1
!                 set $var_canvas_y2 1
!         }
!         if { [eval concat $$var_canvas_xpix] == 0 } {
!             set $var_canvas_xpix 85
!             set $var_canvas_xmargin 100
!         }
!         if { [eval concat $$var_canvas_ypix] == 0 } {
!             set $var_canvas_ypix 60
!             set $var_canvas_ymargin 100
!         }
!     } else {
!         $id.xrange.entry1 configure -state disabled
!         $id.xrange.entry2 configure -state disabled
!         $id.xrange.entry3 configure -state disabled
!         $id.xrange.entry4 configure -state disabled
!         $id.yrange.entry1 configure -state disabled
!         $id.yrange.entry2 configure -state disabled
!         $id.yrange.entry3 configure -state disabled
!         $id.yrange.entry4 configure -state disabled
!         $id.xscale.entry configure -state normal
!         $id.yscale.entry configure -state normal
!         if { [eval concat $$var_canvas_xscale] == 0 } {
!             set $var_canvas_xscale 1
!         }
!         if { [eval concat $$var_canvas_yscale] == 0 } {
!             set $var_canvas_yscale -1
!         }
!     }
! }
! 
! proc pdtk_canvas_dialog {id xscale yscale graphme x1 y1 x2 y2 \
!     xpix ypix xmargin ymargin} {
!     set vid [string trimleft $id .]
! 
!     set var_canvas_xscale [concat canvas_xscale_$vid]
!     global $var_canvas_xscale
!     set var_canvas_yscale [concat canvas_yscale_$vid]
!     global $var_canvas_yscale
!     set var_canvas_graphme [concat canvas_graphme_$vid]
!     global $var_canvas_graphme
!     set var_canvas_x1 [concat canvas_x1_$vid]
!     global $var_canvas_x1
!     set var_canvas_x2 [concat canvas_x2_$vid]
!     global $var_canvas_x2
!     set var_canvas_xpix [concat canvas_xpix_$vid]
!     global $var_canvas_xpix
!     set var_canvas_xmargin [concat canvas_xmargin_$vid]
!     global $var_canvas_xmargin
!     set var_canvas_y1 [concat canvas_y1_$vid]
!     global $var_canvas_y1
!     set var_canvas_y2 [concat canvas_y2_$vid]
!     global $var_canvas_y2
!     set var_canvas_ypix [concat canvas_ypix_$vid]
!     global $var_canvas_ypix
!     set var_canvas_ymargin [concat canvas_ymargin_$vid]
!     global $var_canvas_ymargin
! 
  
      set $var_canvas_xscale $xscale
      set $var_canvas_yscale $yscale
      set $var_canvas_graphme $graphme
!     set $var_canvas_x1 $x1
!     set $var_canvas_y1 $y1
!     set $var_canvas_x2 $x2
!     set $var_canvas_y2 $y2
!     set $var_canvas_xpix $xpix
!     set $var_canvas_ypix $ypix
!     set $var_canvas_xmargin $xmargin
!     set $var_canvas_ymargin $ymargin
  
      toplevel $id
***************
*** 3049,3052 ****
--- 3002,3008 ----
      wm protocol $id WM_DELETE_WINDOW [concat canvas_cancel $id]
  
+     label $id.toplabel -text "Canvas Properties"
+     pack $id.toplabel -side top
+     
      frame $id.xscale
      pack $id.xscale -side top
***************
*** 3062,3072 ****
  
      checkbutton $id.graphme -text {graph on parent} \
!     	-variable $var_canvas_graphme -anchor w
      pack $id.graphme -side top
  
! #    checkbutton $id.stretch -text {stretch on resize} \
! #    	-variable $var_canvas_stretch -anchor w
! #    pack $id.stretch -side top
  
  
      frame $id.buttonframe
--- 3018,3056 ----
  
      checkbutton $id.graphme -text {graph on parent} \
!     	-variable $var_canvas_graphme -anchor w \
!         -command [concat canvas_checkcommand $id]
      pack $id.graphme -side top
  
!     frame $id.xrange
!     pack $id.xrange -side top
!     label $id.xrange.label1 -text "X range: from"
!     entry $id.xrange.entry1 -textvariable $var_canvas_x1 -width 6
!     label $id.xrange.label2 -text "to"
!     entry $id.xrange.entry2 -textvariable $var_canvas_x2 -width 6
!     label $id.xrange.label3 -text "size"
!     entry $id.xrange.entry3 -textvariable $var_canvas_xpix -width 4
!     label $id.xrange.label4 -text "margin"
!     entry $id.xrange.entry4 -textvariable $var_canvas_xmargin -width 4
!     pack $id.xrange.label1 $id.xrange.entry1 \
!         $id.xrange.label2 $id.xrange.entry2 \
!         $id.xrange.label3 $id.xrange.entry3 \
!         $id.xrange.label4 $id.xrange.entry4 \
!         -side left
  
+     frame $id.yrange
+     pack $id.yrange -side top
+     label $id.yrange.label1 -text "Y range: from"
+     entry $id.yrange.entry1 -textvariable $var_canvas_y1 -width 6
+     label $id.yrange.label2 -text "to"
+     entry $id.yrange.entry2 -textvariable $var_canvas_y2 -width 6
+     label $id.yrange.label3 -text "size"
+     entry $id.yrange.entry3 -textvariable $var_canvas_ypix -width 4
+     label $id.yrange.label4 -text "margin"
+     entry $id.yrange.entry4 -textvariable $var_canvas_ymargin -width 4
+     pack $id.yrange.label1 $id.yrange.entry1 \
+         $id.yrange.label2 $id.yrange.entry2 \
+         $id.yrange.label3 $id.yrange.entry3 \
+         $id.yrange.label4 $id.yrange.entry4 \
+         -side left
  
      frame $id.buttonframe
***************
*** 3089,3092 ****
--- 3073,3077 ----
      $id.xscale.entry select adjust end
      focus $id.xscale.entry
+     canvas_checkcommand $id
  }
  
***************
*** 3204,3222 ****
  
  # tb: user defined typefaces
! proc pdtk_pd_startup {version apilist fontname} {
  #    puts stderr [concat $version $apilist $fontname]
!     global pd_myversion pd_apilist
      set pd_myversion $version
      set pd_apilist $apilist
  	global pd_font1 pd_font2 pd_font3 pd_font4 pd_font5 pd_font6 pd_font7
  
!     
! 	set pd_font1 [format -*-%s-$::pdtheme::fontweight--normal--8-* $fontname]
! 	set pd_font2 [format -*-%s-$::pdtheme::fontweight--normal--10-* $fontname]
!  	set pd_font3 [format -*-%s-$::pdtheme::fontweight--normal--12-* $fontname]
!  	set pd_font4 [format -*-%s-$::pdtheme::fontweight--normal--14-* $fontname]
! 	set pd_font5 [format -*-%s-$::pdtheme::fontweight--normal--16-* $fontname]
! 	set pd_font6 [format -*-%s-$::pdtheme::fontweight--normal--24-* $fontname]
! 	set pd_font7 [format -*-%s-$::pdtheme::fontweight--normal--36-* $fontname]
  
      set width1 [font measure  $pd_font1 x]
--- 3189,3208 ----
  
  # tb: user defined typefaces
! proc pdtk_pd_startup {version apilist midiapilist fontname} {
  #    puts stderr [concat $version $apilist $fontname]
!     global pd_myversion pd_apilist pd_midiapilist
      set pd_myversion $version
      set pd_apilist $apilist
+     set pd_midiapilist $midiapilist
+ 
  	global pd_font1 pd_font2 pd_font3 pd_font4 pd_font5 pd_font6 pd_font7
  
! 	set pd_font1 [format -*-%s-bold--normal--8-* $fontname]
! 	set pd_font2 [format -*-%s-bold--normal--10-* $fontname]
!  	set pd_font3 [format -*-%s-bold--normal--12-* $fontname]
!  	set pd_font4 [format -*-%s-bold--normal--14-* $fontname]
! 	set pd_font5 [format -*-%s-bold--normal--16-* $fontname]
! 	set pd_font6 [format -*-%s-bold--normal--24-* $fontname]
! 	set pd_font7 [format -*-%s-bold--normal--36-* $fontname]
  
      set width1 [font measure  $pd_font1 x]
***************
*** 3774,3778 ****
      global midi_indev1 midi_indev2 midi_indev3 midi_indev4 
      global midi_outdev1 midi_outdev2 midi_outdev3 midi_outdev4
!     global midi_indevlist midi_outdevlist midi_alsain midi_alsaout
  
      set midi_indev1 $indev1
--- 3760,3765 ----
      global midi_indev1 midi_indev2 midi_indev3 midi_indev4 
      global midi_outdev1 midi_outdev2 midi_outdev3 midi_outdev4
!     global midi_indevlist midi_outdevlist
! 	global midi_alsain midi_alsaout
  
      set midi_indev1 $indev1
***************
*** 3805,3809 ****
      pack $id.buttonframe.ok -side left -expand 1
      
-     	# input device 1
      frame $id.in1f
      pack $id.in1f -side top
--- 3792,3795 ----
***************
*** 3912,3915 ****
--- 3898,4043 ----
  }
  
+ proc pdtk_alsa_midi_dialog {id indevlist indev1 indev2 indev3 indev4 \
+     	outdevlist outdev1 outdev2 outdev3 outdev4 longform alsa} {
+     global midi_indev1 midi_indev2 midi_indev3 midi_indev4 
+     global midi_outdev1 midi_outdev2 midi_outdev3 midi_outdev4
+     global midi_indevlist midi_outdevlist
+     global midi_alsain midi_alsaout
+ 
+     set midi_indev1 $indev1
+     set midi_indev2 $indev2
+     set midi_indev3 $indev3
+     set midi_indev4 $indev4
+     set midi_outdev1 $outdev1
+     set midi_outdev2 $outdev2
+     set midi_outdev3 $outdev3
+     set midi_outdev4 $outdev4
+     set midi_indevlist $indevlist
+     set midi_outdevlist $outdevlist
+     set midi_alsain [llength $indevlist]
+     set midi_alsaout [llength $outdevlist]
+     
+     toplevel $id
+     wm title $id {midi}
+     wm protocol $id WM_DELETE_WINDOW [concat midi_cancel $id]
+ 
+     frame $id.buttonframe
+     pack $id.buttonframe -side bottom -fill x -pady 2m
+     button $id.buttonframe.cancel -text {Cancel}\
+     	-command "midi_cancel $id"
+     button $id.buttonframe.apply -text {Apply}\
+     	-command "midi_apply $id"
+     button $id.buttonframe.ok -text {OK}\
+     	-command "midi_ok $id"
+     pack $id.buttonframe.cancel -side left -expand 1
+     pack $id.buttonframe.apply -side left -expand 1
+     pack $id.buttonframe.ok -side left -expand 1
+ 
+     frame $id.in1f
+     pack $id.in1f -side top
+ 
+   if {$alsa == 0} {
+     	# input device 1
+     label $id.in1f.l1 -text "input device 1:"
+     button $id.in1f.x1 -text [lindex $indevlist $midi_indev1] \
+     	-command [list midi_popup $id $id.in1f.x1 midi_indev1 $indevlist]
+     pack $id.in1f.l1 $id.in1f.x1 -side left
+ 
+     	# input device 2
+     if {$longform && [llength $indevlist] > 2} {
+ 	frame $id.in2f
+ 	pack $id.in2f -side top
+ 
+ 	label $id.in2f.l1 -text "input device 2:"
+ 	button $id.in2f.x1 -text [lindex $indevlist $midi_indev2] \
+     	    -command [list midi_popup $id $id.in2f.x1 midi_indev2 $indevlist]
+ 	pack $id.in2f.l1 $id.in2f.x1 -side left
+     }
+ 
+     	# input device 3
+     if {$longform && [llength $indevlist] > 3} {
+ 	frame $id.in3f
+ 	pack $id.in3f -side top
+ 
+ 	label $id.in3f.l1 -text "input device 3:"
+ 	button $id.in3f.x1 -text [lindex $indevlist $midi_indev3] \
+     	    -command [list midi_popup $id $id.in3f.x1 midi_indev3 $indevlist]
+ 	pack $id.in3f.l1 $id.in3f.x1 -side left
+     }
+ 
+     	# input device 4
+     if {$longform && [llength $indevlist] > 4} {
+ 	frame $id.in4f
+ 	pack $id.in4f -side top
+ 
+ 	label $id.in4f.l1 -text "input device 4:"
+ 	button $id.in4f.x1 -text [lindex $indevlist $midi_indev4] \
+     	    -command [list midi_popup $id $id.in4f.x1 midi_indev4 $indevlist]
+ 	pack $id.in4f.l1 $id.in4f.x1 -side left
+     }
+ 
+     	# output device 1
+ 
+     frame $id.out1f
+     pack $id.out1f -side top
+     label $id.out1f.l1 -text "output device 1:"
+     button $id.out1f.x1 -text [lindex $outdevlist $midi_outdev1] \
+     	-command [list midi_popup $id $id.out1f.x1 midi_outdev1 $outdevlist]
+     pack $id.out1f.l1 $id.out1f.x1 -side left
+ 
+     	# output device 2
+     if {$longform && [llength $indevlist] > 2} {
+ 	frame $id.out2f
+ 	pack $id.out2f -side top
+     	label $id.out2f.l1 -text "output device 2:"
+     	button $id.out2f.x1 -text [lindex $outdevlist $midi_outdev2] \
+     	    -command \
+ 	    [list midi_popup $id $id.out2f.x1 midi_outdev2 $outdevlist]
+     	pack $id.out2f.l1 $id.out2f.x1 -side left
+     }
+ 
+     	# output device 3
+     if {$longform && [llength $indevlist] > 3} {
+ 	frame $id.out3f
+ 	pack $id.out3f -side top
+     	label $id.out3f.l1 -text "output device 3:"
+     	button $id.out3f.x1 -text [lindex $outdevlist $midi_outdev3] \
+     	    -command \
+ 	    [list midi_popup $id $id.out3f.x1 midi_outdev3 $outdevlist]
+     	pack $id.out3f.l1 $id.out3f.x1 -side left
+     }
+ 
+     	# output device 4
+     if {$longform && [llength $indevlist] > 4} {
+ 	frame $id.out4f
+ 	pack $id.out4f -side top
+     	label $id.out4f.l1 -text "output device 4:"
+     	button $id.out4f.x1 -text [lindex $outdevlist $midi_outdev4] \
+     	    -command \
+ 	    [list midi_popup $id $id.out4f.x1 midi_outdev4 $outdevlist]
+     	pack $id.out4f.l1 $id.out4f.x1 -side left
+     }
+ 
+     	# if not the "long form" make a button to
+ 	# restart with longform set. 
+     
+     if {$longform == 0} {
+ 	frame $id.longbutton
+ 	pack $id.longbutton -side top
+     	button $id.longbutton.b -text {use multiple alsa devices} \
+     	    -command  {pd pd midi-properties 1 \;}
+     	pack $id.longbutton.b
+     }
+     }
+     if {$alsa} {
+     	label $id.in1f.l1 -text "In Channels:"
+     	entry $id.in1f.x1 -textvariable midi_alsain -width 4
+         pack $id.in1f.l1 $id.in1f.x1 -side left
+ 	label $id.in1f.l2 -text "Out Channels:"
+     	entry $id.in1f.x2 -textvariable midi_alsaout -width 4
+         pack $id.in1f.l2 $id.in1f.x2 -side left
+     }
+ }
+ 
  ############ pdtk_path_dialog -- dialog window for search path #########
  
***************
*** 4064,4070 ****
      focus $id.f0
  }
- 
- catch {
- source /usr/local/bin/tkcon.tcl
- tkcon show
- }
\ No newline at end of file
--- 4192,4193 ----

Index: g_canvas.h
===================================================================
RCS file: /cvsroot/pure-data/pd/src/g_canvas.h,v
retrieving revision 1.3.4.3.2.1
retrieving revision 1.3.4.3.2.2
diff -C2 -d -r1.3.4.3.2.1 -r1.3.4.3.2.2
*** g_canvas.h	22 May 2005 12:42:10 -0000	1.3.4.3.2.1
--- g_canvas.h	12 Jul 2005 15:11:07 -0000	1.3.4.3.2.2
***************
*** 165,168 ****
--- 165,170 ----
      int gl_screenx2;
      int gl_screeny2;
+     int gl_xmargin;                /* origin for GOP rectangle */
+     int gl_ymargin;
      t_tick gl_xtick;            /* ticks marking X values */    
      int gl_nxlabels;            /* number of X coordinate labels */
***************
*** 185,189 ****
      unsigned int gl_edit:1;         /* edit mode */
      unsigned int gl_isdeleting:1;   /* we're inside glist_delete -- hack! */
!     unsigned int gl_stretch:1;      /* stretch contents on resize */
      unsigned int gl_isgraph:1;      /* show as graph on parent */
  };
--- 187,191 ----
      unsigned int gl_edit:1;         /* edit mode */
      unsigned int gl_isdeleting:1;   /* we're inside glist_delete -- hack! */
!     unsigned int gl_goprect:1;      /* draw rectangle for graph-on-parent */
      unsigned int gl_isgraph:1;      /* show as graph on parent */
  };
***************
*** 224,227 ****
--- 226,230 ----
      t_gpointer a_gp;    /* pointer to scalar or array element we're in */
      t_gstub *a_stub;    /* stub for pointing into this array */
+     double a_lastupdate;    /* T.Grill - clock_getlogicaltime() of last array update */
  };
  
***************
*** 239,243 ****
      char x_saveit;          /* true if we should save this with parent */
      char x_listviewing;     /* true if list view window is open */
-     double x_lastupdate;    /* T.Grill - clock_getlogicaltime() of last array update */
  #ifdef GARRAY_THREAD_LOCK
      pthread_mutex_t * x_mutex; /* TB: mutex */
--- 242,245 ----
***************
*** 582,586 ****
  EXTERN int array_doclick(t_array *array, t_glist *glist, t_scalar *sc, t_array *ap,
      t_symbol *elemtemplatesym,
!     float linewidth, float xloc, float xinc, float yloc,
      t_fielddesc *xfield, t_fielddesc *yfield, t_fielddesc *wfield,
      int xpix, int ypix, int shift, int alt, int dbl, int doit);
--- 584,588 ----
  EXTERN int array_doclick(t_array *array, t_glist *glist, t_scalar *sc, t_array *ap,
      t_symbol *elemtemplatesym,
!     float linewidth, float xloc, float xinc, float yloc, float scalarvis,
      t_fielddesc *xfield, t_fielddesc *yfield, t_fielddesc *wfield,
      int xpix, int ypix, int shift, int alt, int dbl, int doit);

Index: s_stuff.h
===================================================================
RCS file: /cvsroot/pure-data/pd/src/s_stuff.h,v
retrieving revision 1.5.4.10
retrieving revision 1.5.4.10.2.1
diff -C2 -d -r1.5.4.10 -r1.5.4.10.2.1
*** s_stuff.h	15 May 2005 19:03:37 -0000	1.5.4.10
--- s_stuff.h	12 Jul 2005 15:11:12 -0000	1.5.4.10.2.1
***************
*** 78,81 ****
--- 78,82 ----
  extern int sys_schedadvance;
  extern int sys_sleepgrain;
+ extern int sys_callbackscheduler;       /* tb: scheduler to use (0: traditional, 1: callback) */
  void sys_open_audio(int naudioindev, int *audioindev,
      int nchindev, int *chindev,
***************
*** 111,114 ****
--- 112,117 ----
      int *pnmidioutdev, int *pmidioutdev);
  
+ void sys_get_midi_apis(char *buf);
+ 
  void sys_reopen_midi( void);
  void sys_close_midi( void);
***************
*** 125,128 ****
--- 128,147 ----
      int nmidioutdev, int *midioutdev);
  
+ #ifdef USEAPI_ALSA
+ EXTERN void sys_alsa_putmidimess(int portno, int a, int b, int c);
+ EXTERN void sys_alsa_putmidibyte(int portno, int a);
+ EXTERN void sys_alsa_poll_midi(void);
+ EXTERN void sys_alsa_setmiditimediff(double inbuftime, double outbuftime);
+ EXTERN void sys_alsa_midibytein(int portno, int byte);
+ EXTERN void sys_alsa_close_midi( void);
+ 
+ 
+     /* implemented in the system dependent MIDI code (s_midi_pm.c, etc. ) */
+ void midi_alsa_getdevs(char *indevlist, int *nindevs,
+     char *outdevlist, int *noutdevs, int maxndev, int devdescsize);
+ void sys_alsa_do_open_midi(int nmidiindev, int *midiindev,
+     int nmidioutdev, int *midioutdev);
+ #endif
+ 
  /* m_sched.c */
  EXTERN void sys_log_error(int type);
***************
*** 137,142 ****
  
  /* tb { */
! EXTERN int sys_keepsched;         /* if 0: change scheduler mode  */
! EXTERN int sys_callbackscheduler; /* if 1: change scheduler to callback based dsp */
  /* tb } */
  
--- 156,161 ----
  
  /* tb { */
! void sys_setscheduler(int scheduler);
! int sys_getscheduler(void);
  /* tb } */
  
***************
*** 185,189 ****
  #define API_DEFSTRING "MMIO"
  #endif
! #ifdef MACOSX
  #define API_DEFAULT API_PORTAUDIO
  #define API_DEFSTRING "portaudio"
--- 204,208 ----
  #define API_DEFSTRING "MMIO"
  #endif
! #ifdef __APPLE__
  #define API_DEFAULT API_PORTAUDIO
  #define API_DEFSTRING "portaudio"
***************
*** 266,269 ****
--- 285,289 ----
  
  void sys_listmididevs(void);
+ void sys_set_midi_api(int whichapi);
  void sys_set_audio_api(int whichapi);
  void sys_get_audio_apis(char *buf);

Index: SConscript
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/SConscript,v
retrieving revision 1.1.4.3
retrieving revision 1.1.4.4
diff -C2 -d -r1.1.4.3 -r1.1.4.4
*** SConscript	19 Jun 2005 02:19:39 -0000	1.1.4.3
--- SConscript	12 Jul 2005 15:10:50 -0000	1.1.4.4
***************
*** 3,7 ****
  pdenv = env.Copy()
  
- 
  ######################################################################
  #
--- 3,6 ----
***************
*** 13,23 ****
  	BoolOption('nosimd', 'Build without simd instructions', False),
  	BoolOption('threadedsf', 'Build with threaded soundfiler', False),
! 	BoolOption('atomic', 'Build with atomic operations', True),
  	BoolOption('newhash', 'Build with 16 bit symbol hash table', True),
  	BoolOption('lockfree', 'Build with lock-free fifos', True),
- 	BoolOption('portaudio', 'Build with portaudio', True),
  	BoolOption('pdlib', 'Build with pdlib', False),
! 	('optimize', 'Optimize for specific architecture', 'i686'),
! 	('prefix', 'install prefix', '/usr/local')
  	)
  
--- 12,21 ----
  	BoolOption('nosimd', 'Build without simd instructions', False),
  	BoolOption('threadedsf', 'Build with threaded soundfiler', False),
! 	BoolOption('atomic', 'Build with atomic operations', False),
  	BoolOption('newhash', 'Build with 16 bit symbol hash table', True),
  	BoolOption('lockfree', 'Build with lock-free fifos', True),
  	BoolOption('pdlib', 'Build with pdlib', False),
! 	('optimize', 'Optimize for specific architecture', None),
! 	('prefix', 'install prefix', '/usr/local') 
  	)
  
***************
*** 31,36 ****
  # general configuration
  
- prefix = pdenv['prefix']
- 
  sources = Split("""d_arithmetic.c
                     d_array.c
--- 29,32 ----
***************
*** 102,122 ****
  defs = []
  
! 
  ######################################################################
  #
  # configure the build
  conf = pdenv.Configure()
  
! for libs in [['m','sin'],['tcl8.5','main'],['tk8.5','main'],['X11','XCreateWindow'],['pthread','pthread_create']]:
! 	if not conf.CheckLib(libs[0],libs[1]):
! 		print "error, missing lib: " + libs[0]
  		Exit(1)
  
! if conf.CheckLib('dl', 'dlopen'):
! 	defs.append('DL_OPEN')
  
! jack = conf.CheckLib('jack','jack_activate')
! alsa = conf.CheckLib('asound','snd_pcm_info')
! portaudio = conf.CheckLib('portaudio','Pa_Initialize')
  
  env=conf.Finish()
--- 98,197 ----
  defs = []
  
! ######################################################################
  ######################################################################
  #
  # configure the build
+ #
+ 
+ 
  conf = pdenv.Configure()
  
! if not conf.CheckLib('m','sin'):
! 	print "can't find Math library"
! 	Exit(1)
! 
! 
! if not conf.CheckLib('tcl'):
! 	for i in range (0,10):
! 		if conf.CheckLib('tcl8.%d' % i):
! 			break
! 	else:
! 		print "can't find tcl"
  		Exit(1)
  
! if not conf.CheckLib('tk'):
! 	for i in range (0,10):
! 		if conf.CheckLib('tk8.%d' % i):
! 			break
! 	else:
! 		print "can't find tk"
  
! 
! if not ( conf.CheckHeader('tcl.h') or conf.CheckHeader('tcl/tcl.h') ):  
! 	for i in range (0,10):
! 		if conf.CheckHeader('tcl8.%d/tcl.h' % i):
! 			break
! 	else:
! 		print "can't find tcl header"
! 		Exit(1)
! 
! if not ( conf.CheckHeader('tk.h') or conf.CheckHeader('tk/tk.h') ):
! 	for i in range (0,10):
! 		if conf.CheckHeader('tk8.%d/tk.h' % i):
! 			break
! 	else:
! 		for i in range (0,10):
! 			if conf.CheckHeader('tcl8.%d/tk.h' % i):
! 				break
! 		else:
! 			print "can't find tk header"
! 
! 
! if not conf.CheckLib('pthread', 'pthread_create'):
! 	print "can't find pthread library"
! 	Exit(1)
! 
! if conf.CheckLib('fftw3f'):
! 	defs.append('HAVE_LIBFFTW3F')
! 
! ######################################################################
! #
! # system specific configuration
! 
! if pdenv['PLATFORM'] == 'posix':
! 	if conf.CheckLib('dl', 'dlopen'):
! 		defs.append('DL_OPEN')
! 	else:
! 		print "libdl not found. dynamic loading of externals disabled"
! 
! 		
! 	jack = conf.CheckLib('jack','jack_activate')
! 	alsa = conf.CheckLib('asound','snd_pcm_info')
! 
! 	
! 	portaudio = conf.CheckLib('portaudio','Pa_Initialize') ## on linux portaudio is a shared library
! 
! 	if not portaudio:
! 		print "libportaudio not found"
! 
! 
! 
! if pdenv['PLATFORM'] == 'win32':
! 	portaudio = True
! 	pass
! 
! if pdenv['PLATFORM'] == 'darwin':
! 	portaudio = True
! 
! 	pdenv.Append(CPPPATH=Split("""/Library/Frameworks/Tk.framework/Headers/
! 				/Library/Frameworks/Tcl.framework/Headers/"""))
! #	conf.CheckHeader('/Library/Frameworks/Tk.framework/Headers/tk.h')
! 
! 	
! 
! 
! ######################################################################
! #
! # cleaning up
  
  env=conf.Finish()
***************
*** 154,165 ****
  simd_ve_gcc_sources = Split("m_simd_ve_gcc.c")
  
- if portaudio and pdenv['portaudio']:
- 	sources.append(pa_sources)
- 	pdenv.Append(CPPDEFINES=Split("USEAPI_PA PA19"))
- 	pdenv.Append(CPPPATH=Split("../portaudio ../portaudio/pablio"))
- 
  pdenv.Append(CPPPATH=".")
  pdenv.Append(LIBPATH=".")
  
  
  ######################################################################
--- 229,249 ----
  simd_ve_gcc_sources = Split("m_simd_ve_gcc.c")
  
  pdenv.Append(CPPPATH=".")
  pdenv.Append(LIBPATH=".")
  
+ ######################################################################
+ #
+ # portaudio stuff
+ pa_common_sources = map(lambda x: '../portaudio/pa_common/' + x,
+ 						Split("""pa_allocation.c
+ 						         pa_converters.c
+ 								 pa_cpuload.c
+ 								 pa_dither.c
+ 								 pa_front.c
+ 								 pa_process.c
+ 								 pa_skeleton.c
+ 								 pa_stream.c
+ 								 pa_trace.c"""))
+ 
  
  ######################################################################
***************
*** 173,177 ****
  
  if pdenv['PLATFORM'] == 'win32':
! 	sources.append(windows_sources + simd_sse_vc_sources)
  	pdenv.Append(CPPDEFINES=windows_defs)
  
--- 257,264 ----
  
  if pdenv['PLATFORM'] == 'win32':
! 	if ['msvc'] in pdenv['TOOLS']:
! 		sources.append(windows_sources + simd_sse_vc_sources)
! 	else:
! 		sources.append(windows_sources + simd_sse_gcc_sources)
  	pdenv.Append(CPPDEFINES=windows_defs)
  
***************
*** 181,231 ****
  #
  # linux configuration
  
! jack_sources = Split("s_audio_jack.c")
! alsa_sources = Split("""s_audio_alsamm.c
                          s_audio_alsa.c""")
! oss_sources = Split("s_audio_oss.c")
! 
! linux_defs = Split("UNISTD UNIX USEAPI_OSS")
! linux_defs.append('INSTALL_PREFIX=\\\"%s\\\"' % prefix)
! 
! linux_libs = []
  
! if alsa:
! 	midi_sources = Split("s_midi_alsa.c")
! else:
! 	midi_sources = Split("s_midi_oss.c")
  
! linux_sources = oss_sources + midi_sources
  
! if not pdenv['nosimd']:
! 	linux_sources.append(simd_sse_gcc_sources)
  
! if alsa:
! 	linux_sources.append(alsa_sources)
! 	linux_defs.append("USEAPI_ALSA")
! 	linux_libs.append('asound')
  	
! if jack:
! 	linux_sources.append(jack_sources)
! 	linux_defs.append("USEAPI_JACK")
! 	linux_libs.append('jack')
  
- if pdenv['PLATFORM'] == 'posix':
  	sources.append(linux_sources)
  	pdenv.Append(CPPDEFINES=linux_defs)
  	pdenv.Append(LIBS=linux_libs)
  
  ######################################################################
  #
  # osx configuration
  
! osx_sources = pa_sources + pm_sources + simd_ve_gcc_sources
! osx_defs = Split("UNIX")
  
- if pdenv['PLATFORM'] == 'osx':
  	sources.append(osx_sources)
  	pdenv.Append(CPPDEFINES=osx_defs)
  
  ######################################################################
  #
--- 268,337 ----
  #
  # linux configuration
+ if pdenv['PLATFORM'] == 'posix':
  
! 	jack_sources = Split("s_audio_jack.c")
! 	alsa_sources = Split("""s_audio_alsamm.c
                          s_audio_alsa.c""")
! 	oss_sources = Split("s_audio_oss.c")
  
! 	linux_defs = Split("UNISTD UNIX USEAPI_OSS")
! 	linux_defs.append('INSTALL_PREFIX=\\\"%s\\\"' % pdenv['prefix'])
  
! 	linux_libs = []
  
! 	if alsa:
! 		midi_sources = Split("s_midi_alsa.c")
! 	else:
! 		midi_sources = Split("s_midi_oss.c")
! 	
! 	linux_sources = oss_sources + midi_sources
! 	
! 	if not pdenv['nosimd']:
! 		linux_sources.append(simd_sse_gcc_sources)
  
! 	if alsa:
! 		linux_sources.append(alsa_sources)
! 		linux_defs.append("USEAPI_ALSA")
! 		linux_libs.append('asound')
  	
! 	if jack:
! 		linux_sources.append(jack_sources)
! 		linux_defs.append("USEAPI_JACK")
! 		linux_libs.append('jack')
  
  	sources.append(linux_sources)
  	pdenv.Append(CPPDEFINES=linux_defs)
  	pdenv.Append(LIBS=linux_libs)
  
+ 	pdenv.Append(LINKFLAGS= ' -Wl,-export-dynamic')
+ 
  ######################################################################
  #
  # osx configuration
  
! if pdenv['PLATFORM'] == 'darwin':
! 	pm_osx_sources = Split("""../portmidi_osx/pmdarwin.c
! 							  ../portmidi_osx/pmmacosx.c
! 							  ../portmidi_osx/pmutil.c
! 							  ../portmidi_osx/portmidi.c
! 							  ../portmidi_osx/ptdarwin.c""")
! 
! 	pa_osx_sources = (Split("""../portaudio/pa_mac_core/pa_mac_core.c
! 	                           ../portaudio/pa_mac/pa_mac_hostapis.c
! 							   ../portaudio/pa_unix/pa_unix_util.c"""))
! 
! 
! 	osx_sources = pa_osx_sources + pa_osx_sources + pm_sources + pm_osx_sources + simd_ve_gcc_sources
! 
! 	osx_defs = Split("UNISTD PA_BIG_ENDIAN PA_USE_COREAUDIO")
  
  	sources.append(osx_sources)
+ 	pdenv.Append(CPPPATH='../portmidi_osx/')
  	pdenv.Append(CPPDEFINES=osx_defs)
  
+ 	pdenv.Append(LINKFLAGS=" -framework CoreAudio -framework AudioUnit "
+ 				 +" -framework AudioToolbox -framework Carbon -framework CoreMIDI")
+ 	ldflags = ''
+ 
  ######################################################################
  #
***************
*** 240,243 ****
--- 346,359 ----
  ######################################################################
  #
+ # portaudio stuff
+ 
+ sources.append(pa_sources)
+ pdenv.Append(CPPDEFINES=Split("USEAPI_PORTAUDIO PA19"))
+ pdenv.Append(CPPPATH=Split("../portaudio/pa_common ../portaudio/pablio"))
+ 
+ 
+ 
+ ######################################################################
+ #
  # compiler options
  flags = ''
***************
*** 252,304 ****
  		pass # how to switch on optimizing on msvc?
  	else:
! 		flags += " -O3"
  
! if pdenv['optimize']:
! 	if ['msvc'] in pdenv['TOOLS']:
! 		pass # is there any machine optmizisation on msvc?
  	else:
! 		flags += " -march=" + pdenv['optimize']
! 	
  if not pdenv['nosimd']:
! 	flags += " -mfpmath=sse -mmmx -msse -msse2"
  
  pdenv.Append(CCFLAGS=flags)
  pdenv.Append(CXXFLAGS=flags)
  
  ######################################################################
  #
  # binaries
  
! pdwatchdog = pdenv.Program('pd-watchdog', "s_watchdog.c")
! pdsend = pdenv.Program('pdsend', "u_pdsend.c")
! pdreceive = pdenv.Program('pdreceive', "u_pdreceive.c")
! pdgui = pdenv.Program('pd-gui', Split("t_main.c t_tkcmd.c"))
  
  
  if pdenv['pdlib']:
  	pdlib = pdenv.SharedLibrary('pd', sources)
! 	pdenv.Append(LIBS=pdlib)
! 	pd = pdenv.Program('pd', 's_entry.c')
! 	Default(pdwatchdog, pdsend, pdreceive, pdgui, pd, pdstarter)
  else:
!  	pd = pdenv.Program('pd', ['s_entry.c', sources],
! 					   LINKFLAGS="-Wl,-export-dynamic")
  	Default(pdwatchdog, pdsend, pdreceive, pdgui, pd)
  
  
- ######################################################################
- #
- # installing stuff
  
! if pdenv['PLATFORM'] == 'posix':
! 	pdenv.Install(prefix+'/bin', pdsend)
! 	pdenv.Install(prefix+'/bin', pdreceive)
! 	pdenv.Install(prefix+'/bin', pd)
! 	pdenv.Install(prefix+'/lib/pd/bin', pdgui)
! 	pdenv.Install(prefix+'/lib/pd/bin', pdwatchdog)
! 	pdenv.InstallAs(prefix + '/lib/pd/bin/pd.tk','u_main.tk')
! 
! 	if pdenv['pdlib']:
! 		pdenv.Install(prefix+'/lib', pdlib)
! 
! 	pdenv.Alias('install', prefix)
--- 368,429 ----
  		pass # how to switch on optimizing on msvc?
  	else:
! 		flags += " -O3 -fprefetch-loop-arrays"
  
! if pdenv.Dictionary().has_key('optimize'):
! 	for statement in ["None", "0", "False"]:
! 		if statement  in pdenv['optimize']:
! 			break
  	else:
! 		if ['msvc'] in pdenv['TOOLS']:
! 			pass # is there any machine optmizisation on msvc?
! 		else:
! 			flags += " -march=" + pdenv['optimize']
! 			
  if not pdenv['nosimd']:
! 	if pdenv['PLATFORM'] != 'darwin':
! 		flags += " -mfpmath=sse -mmmx -msse -msse2"
  
  pdenv.Append(CCFLAGS=flags)
  pdenv.Append(CXXFLAGS=flags)
+ pdenv.Append(LINKFLAGS=flags)
+ 
  
  ######################################################################
+ ######################################################################
  #
  # binaries
  
! pdwatchdog = pdenv.Program('../bin/pd-watchdog', "s_watchdog.c")
! pdsend = pdenv.Program('../bin/pdsend', "u_pdsend.c")
! pdreceive = pdenv.Program('../bin/pdreceive', "u_pdreceive.c")
  
  
+ ######################################################################
+ # build pd's gui
+ if pdenv['PLATFORM']=='posix':
+ 	pdgui = pdenv.Program('../bin/pd-gui', Split("t_main.c t_tkcmd.c"))
+ 
+ if pdenv['PLATFORM']=='darwin':
+ 	pdgui = pdenv.SharedLibrary('../bin/pdtcl', Split("t_main.c t_tkcmd.c"),
+ 								LINKFLAGS='-framework Tcl -framework Tk')
+ if pdenv['PLATFORM']=='win32':
+ 	pdgui = pdenv.SharedLibrary('../bin/pdtcl', Split("t_main.c t_tkcmd.c"),
+ 								LIBS=Split('tcl tk'))
+ 
+ 
+ ######################################################################
+ # build pd's kernel
+ 
  if pdenv['pdlib']:
  	pdlib = pdenv.SharedLibrary('pd', sources)
! 	pdenv.Append(LIBPATH=['.'])
! 	pd = pdenv.Program('../bin/pd', 's_entry.c', LIBS=['pd'])
! 	Default(pdwatchdog, pdsend, pdreceive, pdgui, pd, pdlib)
  else:
!  	pd = pdenv.Program('../bin/pd', ['s_entry.c'] + sources)
! 	pdlib = None
  	Default(pdwatchdog, pdsend, pdreceive, pdgui, pd)
  
  
  
! Return("pdwatchdog pdsend pdreceive pdgui pd pdlib")

Index: s_midi.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/s_midi.c,v
retrieving revision 1.4.4.1
retrieving revision 1.4.4.1.2.1
diff -C2 -d -r1.4.4.1 -r1.4.4.1.2.1
*** s_midi.c	5 Nov 2004 14:27:47 -0000	1.4.4.1
--- s_midi.c	12 Jul 2005 15:11:11 -0000	1.4.4.1.2.1
***************
*** 43,46 ****
--- 43,48 ----
  static double sys_midiinittime;
  
+ int sys_midiapi = API_DEFAULT;
+ 
      /* this is our current estimate for at what "system" real time the
      current logical time's output should occur. */
***************
*** 100,108 ****
  {
      int portno = midi_outqueue[midi_outtail].q_portno;
!     if (midi_outqueue[midi_outtail].q_onebyte)
!         sys_putmidibyte(portno, midi_outqueue[midi_outtail].q_byte1);
!     else sys_putmidimess(portno, midi_outqueue[midi_outtail].q_byte1,
!             midi_outqueue[midi_outtail].q_byte2,
!                 midi_outqueue[midi_outtail].q_byte3);
      midi_outtail  = (midi_outtail + 1 == MIDIQSIZE ? 0 : midi_outtail + 1);
  }
--- 102,123 ----
  {
      int portno = midi_outqueue[midi_outtail].q_portno;
! #ifdef USEAPI_ALSA
!     if (sys_midiapi == API_ALSA)
!       {
!         if (midi_outqueue[midi_outtail].q_onebyte)
!           sys_alsa_putmidibyte(portno, midi_outqueue[midi_outtail].q_byte1);
!         else sys_alsa_putmidimess(portno, midi_outqueue[midi_outtail].q_byte1,
!                              midi_outqueue[midi_outtail].q_byte2,
!                              midi_outqueue[midi_outtail].q_byte3);
!       }
!     else
! #endif /* ALSA */
!       {
!         if (midi_outqueue[midi_outtail].q_onebyte)
!           sys_putmidibyte(portno, midi_outqueue[midi_outtail].q_byte1);
!         else sys_putmidimess(portno, midi_outqueue[midi_outtail].q_byte1,
!                              midi_outqueue[midi_outtail].q_byte2,
!                              midi_outqueue[midi_outtail].q_byte3);
!       }
      midi_outtail  = (midi_outtail + 1 == MIDIQSIZE ? 0 : midi_outtail + 1);
  }
***************
*** 442,445 ****
--- 457,465 ----
      lasttime = newtime;
  #endif
+ #ifdef USEAPI_ALSA
+       if (sys_midiapi == API_ALSA)
+         sys_alsa_poll_midi();
+       else
+ #endif /* ALSA */
      sys_poll_midi();    /* OS dependent poll for MIDI input */
      sys_pollmidioutqueue();
***************
*** 449,457 ****
  /******************** dialog window and device listing ********************/
  
! #ifndef USEAPI_ALSA
  #ifdef USEAPI_OSS
  void midi_oss_init( void);
  #endif
- #endif
  
      /* last requested parameters */
--- 469,478 ----
  /******************** dialog window and device listing ********************/
  
! #ifdef USEAPI_ALSA
! void midi_alsa_init( void);
! #endif
  #ifdef USEAPI_OSS
  void midi_oss_init( void);
  #endif
  
      /* last requested parameters */
***************
*** 461,464 ****
--- 482,500 ----
  static int midi_midioutdev[MAXMIDIOUTDEV];
  
+ 
+ void sys_get_midi_apis(char *buf)
+ {
+     int n = 0;
+     strcpy(buf, "{ ");
+     sprintf(buf + strlen(buf), "{default-MIDI %d} ", API_DEFAULT); n++;
+ #ifdef USEAPI_ALSA
+     sprintf(buf + strlen(buf), "{ALSA-MIDI %d} ", API_ALSA); n++;
+ #endif
+     strcat(buf, "}");
+         /* then again, if only one API (or none) we don't offer any choice. */
+     if (n < 2)
+         strcpy(buf, "{}");
+     
+ }
  void sys_get_midi_params(int *pnmidiindev, int *pmidiindev,
      int *pnmidioutdev, int *pmidioutdev)
***************
*** 489,501 ****
      int nmidioutdev, int *midioutdev, int enable)
  {
! #ifndef USEAPI_ALSA
  #ifdef USEAPI_OSS
      midi_oss_init();
  #endif
- #endif
      if (enable)
!         sys_do_open_midi(nmidiindev, midiindev, nmidioutdev, midioutdev);
      sys_save_midi_params(nmidiindev, midiindev,
          nmidioutdev, midioutdev);
  }
  
--- 525,545 ----
      int nmidioutdev, int *midioutdev, int enable)
  {
! #ifdef USEAPI_ALSA
! 	midi_alsa_init();
! #endif
  #ifdef USEAPI_OSS
      midi_oss_init();
  #endif
      if (enable)
! #ifdef USEAPI_ALSA
! 		if (sys_midiapi == API_ALSA)
! 			sys_alsa_do_open_midi(nmidiindev, midiindev, nmidioutdev, midioutdev);
! 		else
! #endif /* ALSA */
! 			sys_do_open_midi(nmidiindev, midiindev, nmidioutdev, midioutdev);
      sys_save_midi_params(nmidiindev, midiindev,
          nmidioutdev, midioutdev);
+ 
+ 	sys_vgui("set pd_whichmidiapi %d\n", sys_midiapi);
  }
  
***************
*** 512,520 ****
  #define DEVDESCSIZE 80
  
- #ifdef MSW
- #define DEVONSET 0  /* microsoft device list starts at 0 (the "mapper"). */
- #else               /* (see also MSW ifdef in sys_parsedevlist(), s_main.c)  */
  #define DEVONSET 1  /* To agree with command line flags, normally start at 1 */
- #endif
  
  void sys_listmididevs(void )
--- 556,560 ----
***************
*** 523,526 ****
--- 563,572 ----
      int nindevs = 0, noutdevs = 0, i;
  
+ #ifdef USEAPI_ALSA
+     if (sys_midiapi == API_ALSA)
+       midi_alsa_getdevs(indevlist, &nindevs, outdevlist, &noutdevs,
+         MAXNDEV, DEVDESCSIZE);
+     else
+ #endif /* ALSA */
      midi_getdevs(indevlist, &nindevs, outdevlist, &noutdevs,
          MAXNDEV, DEVDESCSIZE);
***************
*** 544,547 ****
--- 590,637 ----
  }
  
+ void sys_set_midi_api(int which)
+ {
+      sys_midiapi = which;
+      if (sys_verbose)
+         post("sys_midiapi %d", sys_midiapi);
+ }
+ 
+ void glob_midi_properties(t_pd *dummy, t_floatarg flongform);
+ 
+ void glob_midi_setapi(void *dummy, t_floatarg f)
+ {
+     int newapi = f;
+     if (newapi)
+     {
+         if (newapi == sys_midiapi)
+         {
+           //if (!midi_isopen())
+           //  s_reopen_midi();
+         }
+         else
+         {
+ #ifdef USEAPI_ALSA
+           if (sys_midiapi == API_ALSA)
+               sys_alsa_close_midi();
+           else
+ #endif
+             sys_close_midi();
+           sys_midiapi = newapi;
+           /* bash device params back to default */
+           midi_nmidiindev = midi_nmidioutdev = 1;
+           //midi_midiindev[0] = midi_midioutdev[0] = DEFAULTMIDIDEV;
+           //midi_midichindev[0] = midi_midichoutdev[0] = SYS_DEFAULTCH;
+           sys_reopen_midi();
+         }
+ 
+         glob_midi_properties(0, 0);
+     }
+     else //if (midi_isopen())
+     {
+         sys_close_midi();
+         //midi_state = 0;
+     }
+ }
+ 
  extern t_class *glob_pdobject;
  
***************
*** 598,604 ****
      midioutdev4 = (noutdev > 3 && midioutdev[3]>=0 ? midioutdev[3]+1 : 0);  
  
! #ifndef USEAPI_ALSA
! 	sprintf(buf,
! 			"pdtk_midi_dialog %%s \
   %s %d %d %d %d %s %d %d %d %d \
   %d 0\n",
--- 688,706 ----
      midioutdev4 = (noutdev > 3 && midioutdev[3]>=0 ? midioutdev[3]+1 : 0);  
  
! #ifdef USEAPI_ALSA
! 	if (sys_midiapi == API_ALSA)
! 		sprintf(buf,
! 			"pdtk_alsa_midi_dialog %%s \
! %s %d %d %d %d %s %d %d %d %d \
! %d 1\n",
! 			indevliststring,
! 			midiindev1, midiindev2, midiindev3, midiindev4, 
! 			outdevliststring,
! 			midioutdev1, midioutdev2, midioutdev3, midioutdev4,
! 			(flongform != 0));
! 	else
! #endif
! 		sprintf(buf,
!  "pdtk_midi_dialog %%s \
   %s %d %d %d %d %s %d %d %d %d \
   %d 0\n",
***************
*** 608,623 ****
  			midioutdev1, midioutdev2, midioutdev3, midioutdev4,
  			(flongform != 0));
- #endif
- #ifdef USEAPI_ALSA
-     sprintf(buf,
- "pdtk_midi_dialog %%s \
- %s %d %d %d %d %s %d %d %d %d \
- %d 1\n",
-         indevliststring,
-         midiindev1, midiindev2, midiindev3, midiindev4, 
-         outdevliststring,
-         midioutdev1, midioutdev2, midioutdev3, midioutdev4,
-         (flongform != 0));
- #endif
      gfxstub_deleteforkey(0);
      gfxstub_new(&glob_pdobject, (void *)glob_midi_properties, buf);
--- 710,713 ----
***************
*** 658,668 ****
      alsadevout = atom_getintarg(9, argc, argv);
  	
- 
-     sys_close_midi();
- #ifndef USEAPI_ALSA
-     sys_open_midi(nindev, newmidiindev, noutdev, newmidioutdev, 1);
- #endif
  #ifdef USEAPI_ALSA
!     sys_open_midi(alsadevin, newmidiindev, alsadevout, newmidioutdev, 1);
  #endif
  }
--- 748,762 ----
      alsadevout = atom_getintarg(9, argc, argv);
  	
  #ifdef USEAPI_ALSA
!     if (sys_midiapi == API_ALSA)
! 	{
!         sys_alsa_close_midi();
! 		sys_open_midi(alsadevin, newmidiindev, alsadevout, newmidioutdev, 1);
! 	}
!     else
  #endif
+ 	{
+         sys_close_midi();
+         sys_open_midi(nindev, newmidiindev, noutdev, newmidioutdev, 1);
+ 	}
  }

Index: s_audio_jack.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/s_audio_jack.c,v
retrieving revision 1.5.4.8
retrieving revision 1.5.4.8.2.1
diff -C2 -d -r1.5.4.8 -r1.5.4.8.2.1
*** s_audio_jack.c	13 May 2005 17:01:48 -0000	1.5.4.8
--- s_audio_jack.c	12 Jul 2005 15:11:10 -0000	1.5.4.8.2.1
***************
*** 1,5 ****
  
  
! /* ----------------------- Experimental routines for jack -------------- */
  #ifdef USEAPI_JACK
  
--- 1,5 ----
  
  
! /* ----------------------- Routines for jack ---------------------------- */
  #ifdef USEAPI_JACK
  
***************
*** 31,40 ****
  char *jack_client_names[MAX_CLIENTS];
  static int jack_dio_error;
  
  pthread_mutex_t jack_mutex;
  pthread_cond_t jack_sem;
  
! extern int sys_keepsched;
! extern int sys_callbackscheduler;
  
  static int
--- 31,41 ----
  char *jack_client_names[MAX_CLIENTS];
  static int jack_dio_error;
+ static int jack_scheduler;
  
  pthread_mutex_t jack_mutex;
  pthread_cond_t jack_sem;
  
! t_int jack_save_connection_state(t_int* dummy);
! static void jack_restore_connection_state(void);
  
  static int
***************
*** 88,100 ****
  	int timeout = nframes * 1e6 / sys_dacsr;
  	
! 	if (sys_timedlock(timeout) == ETIMEDOUT)
! 		/* we're late ... lets hope that jack doesn't kick us out */
! 	{
! 		static int k = 0;
! 		post("timeout %d", timeout);
! 
! 		sys_log_error(ERR_SYSLOCK);
! 		return 0;
! 	}
  
  	for (i = 0; i != dspticks_per_jacktick; ++i)
--- 89,109 ----
  	int timeout = nframes * 1e6 / sys_dacsr;
  	
! 	int status = sys_timedlock(timeout);
! 	
! 	if (status)
! 		if (status == ETIMEDOUT)
! 			/* we're late ... lets hope that jack doesn't kick us out */
! 		{
! 			static int k = 0;
! 			post("timeout %d", (timeout));
! 			
! 			sys_log_error(ERR_SYSLOCK);
! 			return 0;
! 		}
! 		else
! 		{
! 			post ("sys_timedlock returned %d", status);
! 			return 0;
! 		}
  
  	for (i = 0; i != dspticks_per_jacktick; ++i)
***************
*** 144,157 ****
  
  
  static t_int jack_shutdown_handler(t_int* none)
  {
  	jack_close_audio();
! 	post("jack most likely kicked us out ... trying to reconnect");
  	/* try to reconnect to jack server */
  	jack_open_audio(sys_inchannels, sys_outchannels,\
! 					sys_dacsr, sys_callbackscheduler);
  	return 0;
  }
  
  static void
  jack_shutdown (void *arg)
--- 153,177 ----
  
  
+ static int jack_ignore_graph_callback = 0;
  static t_int jack_shutdown_handler(t_int* none)
  {
+ 	int i;
+ 	post("jack kicked us out ... trying to reconnect");
+ 	jack_ignore_graph_callback = 1;
+ 	/* clean up */
  	jack_close_audio();
! 
  	/* try to reconnect to jack server */
  	jack_open_audio(sys_inchannels, sys_outchannels,\
! 		sys_dacsr, jack_scheduler);
! 
! 	/* restore last connection state */
!  	jack_restore_connection_state();
! 	jack_ignore_graph_callback = 0;
  	return 0;
  }
  
+ 
+ 
  static void
  jack_shutdown (void *arg)
***************
*** 167,170 ****
--- 187,196 ----
  }
  
+ static int jack_graph_order_callback(void* arg)
+ {
+ 	sys_callback(jack_save_connection_state, NULL, 0);
+ 	return 0;
+ }
+ 
  
  static char** jack_get_clients(void)
***************
*** 174,177 ****
--- 200,204 ----
      int num_clients = 0;
      regex_t port_regex;
+ 	
  	jack_ports = jack_get_ports( jack_client, "", "", 0 );
      regcomp( &port_regex, "^[^:]*", REG_EXTENDED );
***************
*** 228,232 ****
      }
  
!     /*    for (i=0;i<num_clients;i++) post("client: %s",jack_client_names[i]); */
  
      free( jack_ports );
--- 255,259 ----
      }
  
! /* 	for (i=0;i<num_clients;i++) post("client: %s",jack_client_names[i]); */
  
      free( jack_ports );
***************
*** 244,247 ****
--- 271,279 ----
  	int i;
  	const char **jack_ports;
+ 	static int entered = 0;
+ 	
+ 	if (entered)
+ 		return 0;
+ 	entered = 1;
      
  	if (strlen(client) > 96)  return -1;
***************
*** 251,254 ****
--- 283,288 ----
  	jack_ports = jack_get_ports( jack_client, regex_pattern,
  								 NULL, JackPortIsOutput);
+ 	
+ 	
  	if (jack_ports) 
  		for (i=0;jack_ports[i] != NULL && i < sys_inchannels;i++)      
***************
*** 264,270 ****
  			if (jack_connect (jack_client, jack_port_name (output_port[i]), jack_ports[i])) 
  				fprintf (stderr, "cannot connect output ports %s -> %s\n", jack_port_name (output_port[i]),jack_ports[i]);
!   
!   
!   
  	free(jack_ports);
  	return 0;
--- 298,304 ----
  			if (jack_connect (jack_client, jack_port_name (output_port[i]), jack_ports[i])) 
  				fprintf (stderr, "cannot connect output ports %s -> %s\n", jack_port_name (output_port[i]),jack_ports[i]);
! 	
! 	
! 	
  	free(jack_ports);
  	return 0;
***************
*** 272,276 ****
  
  
! void jack_error(const char *desc) {
  	return;
  }
--- 306,311 ----
  
  
! static void jack_error(const char *desc) 
! {
  	return;
  }
***************
*** 285,292 ****
  	int new_jack = 0;
  	int srate;
! 
  	jack_dio_error = 0;
          
! 	if ((inchans == 0) && (outchans == 0)) return 0;
  
  	if (outchans > NUM_JACK_PORTS) {
--- 320,332 ----
  	int new_jack = 0;
  	int srate;
! 	int ret;
! 	
  	jack_dio_error = 0;
          
! 	if ((inchans == 0) && (outchans == 0))
! 	{
! 		ret = 0;
! 		goto bailout;
! 	}
  
  	if (outchans > NUM_JACK_PORTS) {
***************
*** 300,304 ****
  	}
  
! 	if (jack_client && sys_callbackscheduler != scheduler)
  	{
  		jack_client_close(jack_client);
--- 340,344 ----
  	}
  
! 	if (jack_client && scheduler != sys_getscheduler())
  	{
  		jack_client_close(jack_client);
***************
*** 306,311 ****
  	}
  	
! 	sys_keepsched = 0;
! 	sys_callbackscheduler = scheduler;
  
  	/* try to become a client of the JACK server (we allow two pd's)*/
--- 346,351 ----
  	}
  	
! 	sys_setscheduler(scheduler);
! 	jack_scheduler = scheduler;
  
  	/* try to become a client of the JACK server (we allow two pd's)*/
***************
*** 319,323 ****
  		if (!jack_client) { // jack spits out enough messages already, do not warn
              sys_inchannels = sys_outchannels = 0;
!             return 1;
  		}
            
--- 359,364 ----
  		if (!jack_client) { // jack spits out enough messages already, do not warn
              sys_inchannels = sys_outchannels = 0;
! 			ret = 1;
! 			goto bailout;
  		}
            
***************
*** 339,342 ****
--- 380,387 ----
  		jack_set_xrun_callback (jack_client, jack_xrun, NULL);
  #endif
+ 
+ 		jack_set_graph_order_callback(jack_client,
+ 			jack_graph_order_callback, NULL);
+ 
            
  		/* tell the JACK server to call `srate()' whenever
***************
*** 358,362 ****
  			output_port[j] = NULL;
  		}
-           
  		new_jack = 1;
  	}
--- 403,406 ----
***************
*** 371,375 ****
                  
  	/* create the ports */
!         
  	for (j = 0; j < inchans; j++) {
  		sprintf(port_name, "input%d", j);
--- 415,419 ----
                  
  	/* create the ports */
! 
  	for (j = 0; j < inchans; j++) {
  		sprintf(port_name, "input%d", j);
***************
*** 385,397 ****
  	/* tell the JACK server that we are ready to roll */
   
! 	if (new_jack) {
! 		if (jack_activate (jack_client)) {
              fprintf (stderr, "cannot activate client\n");
              sys_inchannels = sys_outchannels = 0;
!             return 1;
  		}
!           
  		memset(jack_outbuf,0,sizeof(jack_outbuf));
!           
  		if (jack_client_names[0])
              jack_connect_ports(jack_client_names[0]);
--- 429,444 ----
  	/* tell the JACK server that we are ready to roll */
   
! 	if (new_jack) 
! 	{
! 		if (jack_activate (jack_client)) 
! 		{
              fprintf (stderr, "cannot activate client\n");
              sys_inchannels = sys_outchannels = 0;
!             ret = 1;
! 			goto bailout;
  		}
! 
  		memset(jack_outbuf,0,sizeof(jack_outbuf));
! 		
  		if (jack_client_names[0])
              jack_connect_ports(jack_client_names[0]);
***************
*** 422,425 ****
--- 469,477 ----
  
  	return 0;
+ 		
+  bailout:
+ 	/* tb: if we can't start jack, go to traditional scheduler */
+ 	sys_setscheduler(0);
+ 	return ret;
  }
  
***************
*** 429,436 ****
--- 481,496 ----
  	if (jack_client)
  	{
+ 		int i;
+ 		sys_setscheduler(0);
  		jack_deactivate(jack_client);
  		jack_started = 0;
  		jack_client_close(jack_client);
  		jack_client = NULL;
+ 
+ 		for (i = 0; i <NUM_JACK_PORTS; i++) 
+ 		{
+ 			input_port[i] = NULL;
+ 			output_port[i] = NULL;
+ 		}
  	}
  }
***************
*** 501,503 ****
--- 561,654 ----
  }
  
+ 
+ /* ports connected to the inputs */
+ static const char ** jack_in_connections[NUM_JACK_PORTS];
+ /* ports connected to the outputs */
+ static const char ** jack_out_connections[NUM_JACK_PORTS];
+ 
+ /* tb: save the current state of pd's jack connections */
+ t_int jack_save_connection_state(t_int* dummy)
+ {
+ 	int i;
+ 
+ 	if (jack_ignore_graph_callback)
+ 		return 0;
+ 	
+ 	for (i = 0; i != NUM_JACK_PORTS; ++i)
+ 	{
+ 		/* saving the inputs connections */
+ 		if (jack_in_connections[i])
+ 			free(jack_in_connections[i]);
+ 		
+ 		if (i < sys_inchannels)
+ 			jack_in_connections[i] = 
+ 				jack_port_get_all_connections(jack_client, input_port[i]);
+ 		else
+ 			jack_in_connections[i] = 0;
+ 
+ 		/* saving the inputs connections */
+ 		if (jack_out_connections[i])
+ 			free(jack_out_connections[i]);
+ 		
+ 		if (i < sys_outchannels)
+ 			jack_out_connections[i] = 
+ 				jack_port_get_all_connections(jack_client, output_port[i]);
+ 		else
+ 			jack_out_connections[i] = 0;
+ 	}
+ 	return 0;
+ }
+ 
+ /* todo: don't try to connect twice if we're both input and output host */
+ static void jack_restore_connection_state(void)
+ {
+ 	int i, j, status;
+ 	
+ 	post("restoring connections");
+ 
+ 	for (i = 0; i != NUM_JACK_PORTS; ++i)
+ 	{
+ 		/* restoring the inputs connections */
+ 		if (jack_in_connections[i])
+ 		{
+ 			j = 0;
+ 			while (1)
+ 			{
+ 				const char* src_port = jack_in_connections[i][j];
+ 				if (!src_port)
+ 					/* we've connected all incoming ports */
+ 					break;
+ 				
+ 				status = jack_connect(jack_client, src_port, 
+ 					jack_port_name(input_port[i]));
+ 				if (status)
+ 					post("cannot connect input ports %s -> %s", 
+ 						src_port, jack_port_name (input_port[i]));
+ 				++j;
+ 			}
+ 			
+ 		}
+ 
+ 		/* restoring the output connections */
+ 		if (jack_out_connections[i])
+ 		{
+ 			j = 0;
+ 			while (1)
+ 			{
+ 				const char* dst_port = jack_out_connections[i][j];
+ 				if (!dst_port)
+ 					/* we've connected all outgoing ports */
+ 					break;
+ 				
+ 				status = jack_connect(jack_client, jack_port_name(output_port[i]),
+ 					dst_port);
+ 				if (status)
+ 					post("cannot connect output ports %s -> %s", 
+ 						jack_port_name(output_port[i]), dst_port);
+ 				++j;
+ 			}
+ 		}
+ 	}
+ }
+ 
  #endif /* JACK */

Index: t_main.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/t_main.c,v
retrieving revision 1.2
retrieving revision 1.2.8.1
diff -C2 -d -r1.2 -r1.2.8.1
*** t_main.c	6 Sep 2004 20:20:36 -0000	1.2
--- t_main.c	12 Jul 2005 15:11:12 -0000	1.2.8.1
***************
*** 15,19 ****
  
  
! #ifndef MACOSX     /* linux and IRIX only; in MACOSX we don't link this in */
  #include "tk.h"
  #include <stdlib.h>
--- 15,19 ----
  
  
! #ifndef __APPLE__     /* linux and IRIX only; in MACOSX we don't link this in */
  #include "tk.h"
  #include <stdlib.h>
***************
*** 113,115 ****
  }
  
! #endif  /* MACOSX */
--- 113,115 ----
  }
  
! #endif  /* __APPLE__ */

Index: g_template.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/g_template.c,v
retrieving revision 1.4.8.1
retrieving revision 1.4.8.2
diff -C2 -d -r1.4.8.1 -r1.4.8.2
*** g_template.c	22 May 2005 12:49:24 -0000	1.4.8.1
--- g_template.c	12 Jul 2005 15:11:09 -0000	1.4.8.2
***************
*** 1225,1229 ****
  {
      t_object x_obj;
-     int x_vis;
      t_canvas *x_canvas;
      t_fielddesc x_outlinecolor;
--- 1225,1228 ----
***************
*** 1237,1240 ****
--- 1236,1241 ----
      t_fielddesc x_ypoints;
      t_fielddesc x_wpoints;
+     t_fielddesc x_vis;          /* visible */
+     t_fielddesc x_scalarvis;    /* true if drawing the scalar at each point */
  } t_plot;
  
***************
*** 1242,1247 ****
  {
      t_plot *x = (t_plot *)pd_new(plot_class);
!     int defstyle = PLOTSTYLE_POLY;
!     x->x_vis = 1;
      x->x_canvas = canvas_getcurrent();
  
--- 1243,1247 ----
  {
      t_plot *x = (t_plot *)pd_new(plot_class);
!     int defstyle = PLOTSTYLE_POLY, vis = 1, scalarvis = 1;
      x->x_canvas = canvas_getcurrent();
  
***************
*** 1261,1265 ****
          else if (!strcmp(firstarg->s_name, "-n"))
          {
!             x->x_vis = 0;
              argc--; argv++;
          }
--- 1261,1270 ----
          else if (!strcmp(firstarg->s_name, "-n"))
          {
!             vis = 0;
!             argc--; argv++;
!         }
!         else if (!strcmp(firstarg->s_name, "-noscalar"))
!         {
!             scalarvis = 0;
              argc--; argv++;
          }
***************
*** 1295,1298 ****
--- 1300,1307 ----
      if (argc) fielddesc_setfloatarg(&x->x_style, argc--, argv++);
      else fielddesc_setfloat_const(&x->x_style, defstyle);
+     if (argc) fielddesc_setfloatarg(&x->x_vis, argc--, argv++);
+     else fielddesc_setfloat_const(&x->x_vis, vis);
+     if (argc) fielddesc_setfloatarg(&x->x_scalarvis, argc--, argv++);
+     else fielddesc_setfloat_const(&x->x_scalarvis, 1);
      return (x);
  }
***************
*** 1300,1307 ****
  void plot_float(t_plot *x, t_floatarg f)
  {
!     if ((f != 0 && x->x_vis) || (f == 0 && !x->x_vis))
          return;
      canvas_redrawallfortemplatecanvas(x->x_canvas, 2);
!     x->x_vis = (f!= 0);
      canvas_redrawallfortemplatecanvas(x->x_canvas, 1);
  }
--- 1309,1324 ----
  void plot_float(t_plot *x, t_floatarg f)
  {
!     int viswas;
!     if (x->x_vis.fd_type != A_FLOAT || x->x_vis.fd_var)
!     {
!         pd_error(x, "global vis/invis for a template with variable visibility");
!         return;
!     }
!     viswas = (x->x_vis.fd_un.fd_float != 0);
!     
!     if ((f != 0 && viswas) || (f == 0 && !viswas))
          return;
      canvas_redrawallfortemplatecanvas(x->x_canvas, 2);
!     fielddesc_setfloat_const(&x->x_vis, (f != 0));
      canvas_redrawallfortemplatecanvas(x->x_canvas, 1);
  }
***************
*** 1316,1319 ****
--- 1333,1337 ----
      t_symbol **elemtemplatesymp, t_array **arrayp,
      float *linewidthp, float *xlocp, float *xincp, float *ylocp, float *stylep,
+     float *visp, float *scalarvisp,
      t_fielddesc **xfield, t_fielddesc **yfield, t_fielddesc **wfield)
  {
***************
*** 1345,1348 ****
--- 1363,1368 ----
      *ylocp = fielddesc_getfloat(&x->x_yloc, ownertemplate, data, 1);
      *stylep = fielddesc_getfloat(&x->x_style, ownertemplate, data, 1);
+     *visp = fielddesc_getfloat(&x->x_vis, ownertemplate, data, 1);
+     *scalarvisp = fielddesc_getfloat(&x->x_scalarvis, ownertemplate, data, 1);
      *elemtemplatesymp = elemtemplatesym;
      *arrayp = array;
***************
*** 1420,1424 ****
      t_template *elemtemplate;
      t_symbol *elemtemplatesym;
!     float linewidth, xloc, xinc, yloc, style, xsum, yval;
      t_array *array;
      int x1 = 0x7fffffff, y1 = 0x7fffffff, x2 = -0x7fffffff, y2 = -0x7fffffff;
--- 1440,1444 ----
      t_template *elemtemplate;
      t_symbol *elemtemplatesym;
!     float linewidth, xloc, xinc, yloc, style, xsum, yval, vis, scalarvis;
      t_array *array;
      int x1 = 0x7fffffff, y1 = 0x7fffffff, x2 = -0x7fffffff, y2 = -0x7fffffff;
***************
*** 1426,1432 ****
      float xpix, ypix, wpix;
      t_fielddesc *xfielddesc, *yfielddesc, *wfielddesc;
!     if (x->x_vis && !plot_readownertemplate(x, data, template, 
          &elemtemplatesym, &array, &linewidth, &xloc, &xinc, &yloc, &style,
!                 &xfielddesc, &yfielddesc, &wfielddesc) &&
              !array_getfields(elemtemplatesym, &elemtemplatecanvas,
                  &elemtemplate, &elemsize, 
--- 1446,1453 ----
      float xpix, ypix, wpix;
      t_fielddesc *xfielddesc, *yfielddesc, *wfielddesc;
!     if (!plot_readownertemplate(x, data, template, 
          &elemtemplatesym, &array, &linewidth, &xloc, &xinc, &yloc, &style,
!             &vis, &scalarvis, &xfielddesc, &yfielddesc, &wfielddesc) &&
!                 (vis != 0) &&
              !array_getfields(elemtemplatesym, &elemtemplatecanvas,
                  &elemtemplate, &elemsize, 
***************
*** 1451,1482 ****
                  y2 = ypix + wpix;
              
!                 /* check also the drawing instructions for the scalar */ 
!             if (xonset >= 0)
!                 usexloc = basex + xloc + fielddesc_cvttocoord(xfielddesc, 
!                     *(float *)(((char *)(array->a_vec) + elemsize * i)
!                         + xonset));
!             else usexloc = basex + xsum, xsum += xinc;
!             if (yonset >= 0)
!                 yval = *(float *)(((char *)(array->a_vec) + elemsize * i)
!                     + yonset);
!             else yval = 0;
!             useyloc = basey + yloc + fielddesc_cvttocoord(yfielddesc, yval);
!             for (y = elemtemplatecanvas->gl_list; y; y = y->g_next)
              {
!                 int xx1, xx2, yy1, yy2;
!                 t_parentwidgetbehavior *wb = pd_getparentwidget(&y->g_pd);
!                 if (!wb) continue;
!                 (*wb->w_parentgetrectfn)(y, glist,
!                     (t_word *)((char *)(array->a_vec) + elemsize * i),
!                         elemtemplate, usexloc, useyloc, 
!                             &xx1, &yy1, &xx2, &yy2);
!                 if (xx1 < x1)
!                     x1 = xx1;
!                 if (yy1 < y1)
!                     y1 = yy1;
!                  if (xx2 > x2)
!                     x2 = xx2;
!                 if (yy2 > y2)
!                     y2 = yy2;   
              }
          }
--- 1472,1506 ----
                  y2 = ypix + wpix;
              
!             if (scalarvis != 0)
              {
!                     /* check also the drawing instructions for the scalar */ 
!                 if (xonset >= 0)
!                     usexloc = basex + xloc + fielddesc_cvttocoord(xfielddesc, 
!                         *(float *)(((char *)(array->a_vec) + elemsize * i)
!                             + xonset));
!                 else usexloc = basex + xsum, xsum += xinc;
!                 if (yonset >= 0)
!                     yval = *(float *)(((char *)(array->a_vec) + elemsize * i)
!                         + yonset);
!                 else yval = 0;
!                 useyloc = basey + yloc + fielddesc_cvttocoord(yfielddesc, yval);
!                 for (y = elemtemplatecanvas->gl_list; y; y = y->g_next)
!                 {
!                     int xx1, xx2, yy1, yy2;
!                     t_parentwidgetbehavior *wb = pd_getparentwidget(&y->g_pd);
!                     if (!wb) continue;
!                     (*wb->w_parentgetrectfn)(y, glist,
!                         (t_word *)((char *)(array->a_vec) + elemsize * i),
!                             elemtemplate, usexloc, useyloc, 
!                                 &xx1, &yy1, &xx2, &yy2);
!                     if (xx1 < x1)
!                         x1 = xx1;
!                     if (yy1 < y1)
!                         y1 = yy1;
!                      if (xx2 > x2)
!                         x2 = xx2;
!                     if (yy2 > y2)
!                         y2 = yy2;   
!                 }
              }
          }
***************
*** 1512,1516 ****
  static void plot_vis(t_gobj *z, t_glist *glist, 
      t_word *data, t_template *template, float basex, float basey,
!     int vis)
  {
      t_plot *x = (t_plot *)z;
--- 1536,1540 ----
  static void plot_vis(t_gobj *z, t_glist *glist, 
      t_word *data, t_template *template, float basex, float basey,
!     int tovis)
  {
      t_plot *x = (t_plot *)z;
***************
*** 1519,1523 ****
      t_template *elemtemplate;
      t_symbol *elemtemplatesym;
!     float linewidth, xloc, xinc, yloc, style, usexloc, xsum, yval;
      t_array *array;
      int nelem;
--- 1543,1548 ----
      t_template *elemtemplate;
      t_symbol *elemtemplatesym;
!     float linewidth, xloc, xinc, yloc, style, usexloc, xsum, yval, vis,
!         scalarvis;
      t_array *array;
      int nelem;
***************
*** 1525,1533 ****
      t_fielddesc *xfielddesc, *yfielddesc, *wfielddesc;
      
-     if (!x->x_vis)
-         return;
      if (plot_readownertemplate(x, data, template, 
          &elemtemplatesym, &array, &linewidth, &xloc, &xinc, &yloc, &style,
!         &xfielddesc, &yfielddesc, &wfielddesc) ||
              array_getfields(elemtemplatesym, &elemtemplatecanvas,
                  &elemtemplate, &elemsize, xfielddesc, yfielddesc, wfielddesc,
--- 1550,1557 ----
      t_fielddesc *xfielddesc, *yfielddesc, *wfielddesc;
      
      if (plot_readownertemplate(x, data, template, 
          &elemtemplatesym, &array, &linewidth, &xloc, &xinc, &yloc, &style,
!         &vis, &scalarvis, &xfielddesc, &yfielddesc, &wfielddesc) ||
!             (vis == 0) || 
              array_getfields(elemtemplatesym, &elemtemplatecanvas,
                  &elemtemplate, &elemsize, xfielddesc, yfielddesc, wfielddesc,
***************
*** 1537,1541 ****
      elem = (char *)array->a_vec;
  
!     if (vis)
      {
          if (style == PLOTSTYLE_POINTS)
--- 1561,1565 ----
      elem = (char *)array->a_vec;
  
!     if (tovis)
      {
          if (style == PLOTSTYLE_POINTS)
***************
*** 1724,1747 ****
              This code is inefficient since the template has to be
              searched for drawing instructions for every last point. */
!         
!         for (xsum = xloc, i = 0; i < nelem; i++)
          {
!             float usexloc, useyloc;
!             t_gobj *y;
!             if (xonset >= 0)
!                 usexloc = basex + xloc +
!                     *(float *)((elem + elemsize * i) + xonset);
!             else usexloc = basex + xsum, xsum += xinc;
!             if (yonset >= 0)
!                 yval = *(float *)((elem + elemsize * i) + yonset);
!             else yval = 0;
!             useyloc = basey + fielddesc_cvttocoord(yfielddesc, yloc + yval);
!             for (y = elemtemplatecanvas->gl_list; y; y = y->g_next)
              {
!                 t_parentwidgetbehavior *wb = pd_getparentwidget(&y->g_pd);
!                 if (!wb) continue;
!                 (*wb->w_parentvisfn)(y, glist,
!                     (t_word *)(elem + elemsize * i),
!                         elemtemplate, usexloc, useyloc, vis);
              }
          }
--- 1748,1773 ----
              This code is inefficient since the template has to be
              searched for drawing instructions for every last point. */
!         if (scalarvis != 0)
          {
!             for (xsum = xloc, i = 0; i < nelem; i++)
              {
!                 float usexloc, useyloc;
!                 t_gobj *y;
!                 if (xonset >= 0)
!                     usexloc = basex + xloc +
!                         *(float *)((elem + elemsize * i) + xonset);
!                 else usexloc = basex + xsum, xsum += xinc;
!                 if (yonset >= 0)
!                     yval = *(float *)((elem + elemsize * i) + yonset);
!                 else yval = 0;
!                 useyloc = basey + fielddesc_cvttocoord(yfielddesc, yloc+yval);
!                 for (y = elemtemplatecanvas->gl_list; y; y = y->g_next)
!                 {
!                     t_parentwidgetbehavior *wb = pd_getparentwidget(&y->g_pd);
!                     if (!wb) continue;
!                     (*wb->w_parentvisfn)(y, glist,
!                         (t_word *)(elem + elemsize * i),
!                             elemtemplate, usexloc, useyloc, tovis);
!                 }
              }
          }
***************
*** 1750,1764 ****
      {
              /* un-draw the individual points */
!         int i;
!         for (i = 0; i < nelem; i++)
          {
!             t_gobj *y;
!             for (y = elemtemplatecanvas->gl_list; y; y = y->g_next)
              {
!                 t_parentwidgetbehavior *wb = pd_getparentwidget(&y->g_pd);
!                 if (!wb) continue;
!                 (*wb->w_parentvisfn)(y, glist,
!                     (t_word *)(elem + elemsize * i), elemtemplate,
!                         0, 0, 0);
              }
          }
--- 1776,1793 ----
      {
              /* un-draw the individual points */
!         if (scalarvis != 0)
          {
!             int i;
!             for (i = 0; i < nelem; i++)
              {
!                 t_gobj *y;
!                 for (y = elemtemplatecanvas->gl_list; y; y = y->g_next)
!                 {
!                     t_parentwidgetbehavior *wb = pd_getparentwidget(&y->g_pd);
!                     if (!wb) continue;
!                     (*wb->w_parentvisfn)(y, glist,
!                         (t_word *)(elem + elemsize * i), elemtemplate,
!                             0, 0, 0);
!                 }
              }
          }
***************
*** 1776,1780 ****
      t_plot *x = (t_plot *)z;
      t_symbol *elemtemplatesym;
!     float linewidth, xloc, xinc, yloc, style;
      t_array *array;
      t_fielddesc *xfielddesc, *yfielddesc, *wfielddesc;
--- 1805,1809 ----
      t_plot *x = (t_plot *)z;
      t_symbol *elemtemplatesym;
!     float linewidth, xloc, xinc, yloc, style, vis, scalarvis;
      t_array *array;
      t_fielddesc *xfielddesc, *yfielddesc, *wfielddesc;
***************
*** 1782,1790 ****
      if (!plot_readownertemplate(x, data, template, 
          &elemtemplatesym, &array, &linewidth, &xloc, &xinc, &yloc, &style,
!         &xfielddesc, &yfielddesc, &wfielddesc))
      {
          return (array_doclick(array, glist, sc, ap,
              elemtemplatesym,
!             linewidth, basex + xloc, xinc, basey + yloc,
              xfielddesc, yfielddesc, wfielddesc,
              xpix, ypix, shift, alt, dbl, doit));
--- 1811,1820 ----
      if (!plot_readownertemplate(x, data, template, 
          &elemtemplatesym, &array, &linewidth, &xloc, &xinc, &yloc, &style,
!         &vis, &scalarvis,
!         &xfielddesc, &yfielddesc, &wfielddesc) && (vis != 0))
      {
          return (array_doclick(array, glist, sc, ap,
              elemtemplatesym,
!             linewidth, basex + xloc, xinc, basey + yloc, scalarvis,
              xfielddesc, yfielddesc, wfielddesc,
              xpix, ypix, shift, alt, dbl, doit));
***************
*** 2014,2018 ****
          &x1, &y1, &x2, &y2);
      if (xpix >= x1 && xpix <= x2 && ypix >= y1 && ypix <= y2
!         && x->x_value.fd_var)
      {
          if (doit)
--- 2044,2048 ----
          &x1, &y1, &x2, &y2);
      if (xpix >= x1 && xpix <= x2 && ypix >= y1 && ypix <= y2
!         && x->x_value.fd_var && x->x_vis)
      {
          if (doit)

Index: g_array.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/g_array.c,v
retrieving revision 1.3.4.4.2.1
retrieving revision 1.3.4.4.2.2
diff -C2 -d -r1.3.4.4.2.1 -r1.3.4.4.2.2
*** g_array.c	22 May 2005 12:39:48 -0000	1.3.4.4.2.1
--- g_array.c	12 Jul 2005 15:11:07 -0000	1.3.4.4.2.2
***************
*** 262,293 ****
  }
  
- /* tb: dummy garray lockgim */
- void garray_lock(t_garray *x)
- {
- }
- 
- void garray_unlock(t_garray *x)
- {
- }
- 
- int garray_trylock(t_garray *x)
- {
-     return 0;
- }
- 
- 
- /* T.Grill - set update time */
- static void garray_update(t_garray *x)
- {
-     x->x_lastupdate = clock_getlogicaltime();
- }
- 
- /* T.Grill - return last update time */
- double garray_updatetime(t_garray *x)
- {
-     return x->x_lastupdate;
- }
- 
- 
  /* handle "array" message to glists; call graph_scalar above with
  an appropriate template; then set size and flags.  This is called
--- 262,265 ----
***************
*** 489,493 ****
      {
          yval = *(float *)(a->a_vec +
!                elemsize * i * sizeof (t_word) + yonset);
          sys_vgui(".%sArrayWindow.lb insert %d {%d) %g}\n",
                   x->x_realname->s_name,
--- 461,465 ----
      {
          yval = *(float *)(a->a_vec +
!                elemsize * i + yonset);
          sys_vgui(".%sArrayWindow.lb insert %d {%d) %g}\n",
                   x->x_realname->s_name,
***************
*** 533,537 ****
      {
          yval = *(float *)(a->a_vec + \
!                elemsize * i * sizeof (t_word) + yonset);
          sys_vgui(".%sArrayWindow.lb insert %d {%d) %g}\n",
                   x->x_realname->s_name,
--- 505,509 ----
      {
          yval = *(float *)(a->a_vec + \
!                elemsize * i + yonset);
          sys_vgui(".%sArrayWindow.lb insert %d {%d) %g}\n",
                   x->x_realname->s_name,
***************
*** 705,709 ****
      if (array_motion_array)
          array_redraw(array_motion_array, array_motion_glist);
- 	garray_update((t_garray *)&array_motion_scalar->sc_gobj);
  }
  
--- 677,680 ----
***************
*** 751,755 ****
  int array_doclick(t_array *array, t_glist *glist, t_scalar *sc, t_array *ap,
      t_symbol *elemtemplatesym,
!     float linewidth, float xloc, float xinc, float yloc,
      t_fielddesc *xfield, t_fielddesc *yfield, t_fielddesc *wfield,
      int xpix, int ypix, int shift, int alt, int dbl, int doit)
--- 722,726 ----
  int array_doclick(t_array *array, t_glist *glist, t_scalar *sc, t_array *ap,
      t_symbol *elemtemplatesym,
!     float linewidth, float xloc, float xinc, float yloc, float scalarvis,
      t_fielddesc *xfield, t_fielddesc *yfield, t_fielddesc *wfield,
      int xpix, int ypix, int shift, int alt, int dbl, int doit)
***************
*** 798,805 ****
--- 769,780 ----
          }
          if (best > 8)
+         {
+             if (scalarvis != 0)
              return (array_doclick_element(array, glist, sc, ap,
                  elemtemplatesym, linewidth, xloc, xinc, yloc,
                      xfield, yfield, wfield,
                      xpix, ypix, shift, alt, dbl, doit));
+             else return (0);
+         }
          best += 0.001;  /* add truncation error margin */
          for (i = 0; i < array->a_n; i += incr)
***************
*** 1076,1082 ****
          garray_vis(&x->x_gobj, x->x_glist, 1);
      }
- 	
- 	/* T.Grill - last update time */
-     garray_update(x);
  }
  
--- 1051,1054 ----

Index: m_sched.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/m_sched.c,v
retrieving revision 1.5.4.35
retrieving revision 1.5.4.35.2.1
diff -C2 -d -r1.5.4.35 -r1.5.4.35.2.1
*** m_sched.c	18 May 2005 09:15:18 -0000	1.5.4.35
--- m_sched.c	12 Jul 2005 15:11:10 -0000	1.5.4.35.2.1
***************
*** 18,21 ****
--- 18,22 ----
  #endif
  
+ #include "assert.h"
  
      /* LATER consider making this variable.  It's now the LCM of all sample
***************
*** 51,58 ****
  struct _clock
  {
!     double c_settime;
      void *c_owner;
      t_clockmethod c_fn;
!     struct _clock *c_next;
  };
  
--- 52,60 ----
  struct _clock
  {
!     double c_settime; /* -1 if unset */
      void *c_owner;
      t_clockmethod c_fn;
!     struct _clock *c_next_time; /* clocks with settimes > c_settime */
!     struct _clock *c_next;      /* clocks with settimes == c_settime */
  };
  
***************
*** 69,72 ****
--- 71,75 ----
      x->c_owner = owner;
      x->c_fn = (t_clockmethod)fn;
+     x->c_next_time = 0;
      x->c_next = 0;
      return (x);
***************
*** 75,89 ****
  void clock_unset(t_clock *x)
  {
!     if (x->c_settime >= 0)
!     {
!         if (x == clock_setlist) clock_setlist = x->c_next;
!         else
!         {
!             t_clock *x2 = clock_setlist;
!             while (x2->c_next != x) x2 = x2->c_next;
!             x2->c_next = x->c_next;
!         }
!         x->c_settime = -1;
!     }
  }
  
--- 78,136 ----
  void clock_unset(t_clock *x)
  {
! 	if (x->c_settime == -1)
! 		return;
! 
! 	assert (clock_setlist);
! 	if (x == clock_setlist)
! 	{
! 		if (x->c_next == 0)
! 			clock_setlist = x->c_next_time;
! 		else
! 		{
! 			x->c_next->c_next_time = x->c_next_time;
! 			clock_setlist = x->c_next;
! 		}
! 	}
! 	else
! 	{
! 		t_clock *x2 = clock_setlist;
! 		t_clock *x_before = 0;
! 		
! 		/* find correct settime list */
! 		while (x2->c_settime != x->c_settime)
! 		{
! 			assert (x2->c_next_time != 0);
! 			if (x2->c_next_time == 0) /* todo: remove when checked */
! 				goto done;
! 			
! 			x_before = x2;
! 			x2 = x2->c_next_time;
! 		}
! 		
! 		if (x2 == x) /* we're the first in the queue */
! 		{
! 			if (x->c_next == NULL) /* we're the only one in the queue */
! 				x_before->c_next_time = x->c_next_time;
! 			else
! 			{
! 				x_before->c_next_time = x->c_next;
! 				x->c_next->c_next_time = x->c_next_time;
! 			}
! 		}
! 		else
! 		{
! 			/* find entry */
! 			while (x2->c_next != x)
! 			{
! 				assert(x2->c_next);
! 				if (!x2->c_next) /* todo: remove when checked */
! 					goto done;
! 				x2 = x2->c_next;
! 			}
! 			x2->c_next = x->c_next;
! 		}
! 	}
!  done:
! 	x->c_settime = -1;
  }
  
***************
*** 93,112 ****
      if (setticks < sys_time) setticks = sys_time;
      clock_unset(x);
!     x->c_settime = setticks;
      if (clock_setlist && clock_setlist->c_settime <= setticks)
      {
!         t_clock *cbefore, *cafter;
!         for (cbefore = clock_setlist, cafter = clock_setlist->c_next;
!             cbefore; cbefore = cafter, cafter = cbefore->c_next)
!         {
!             if (!cafter || cafter->c_settime > setticks)
!             {
!                 cbefore->c_next = x;
!                 x->c_next = cafter;
!                 return;
!             }
!         }
      }
!     else x->c_next = clock_setlist, clock_setlist = x;
  }
  
--- 140,188 ----
      if (setticks < sys_time) setticks = sys_time;
      clock_unset(x);
! 	x->c_settime = setticks;
! 	
      if (clock_setlist && clock_setlist->c_settime <= setticks)
      {
! 		if (clock_setlist->c_settime == setticks)
! 		{
! 			/* our slot is the first in the list */
! 			x->c_next_time = 0;
! 			x->c_next = clock_setlist->c_next;
! 			clock_setlist->c_next = x;
! 		}
! 		else
! 		{
! 			t_clock *cbefore = clock_setlist;
! 			t_clock *cafter = clock_setlist->c_next_time;
! 			
! 			while (cafter && cafter->c_settime < setticks)
! 			{
! 				cbefore = cafter;
! 				cafter = cafter->c_next_time;
! 			}
! 
! 			if (cafter && cafter->c_settime == setticks)
! 			{
! 				/* we found our slot */
! 				x->c_next_time = 0;
! 				x->c_next = cafter->c_next;
! 				cafter->c_next = x;
! 			}
! 			else
! 			{
! 				/* we have to create our slot */
! 				x->c_next_time = cafter;
! 				x->c_next = 0;
! 				cbefore->c_next_time = x;
! 			}
! 		}
      }
!     else 
! 	{
! 		/* we have to create a new slot and prepend it */
! 		x->c_next = 0;
! 		x->c_next_time = clock_setlist;
! 		clock_setlist = x;
! 	}
  }
  
***************
*** 368,383 ****
  
  
! static void run_clock_callbacks(double next_sys_time)
  {
!     while (clock_setlist && clock_setlist->c_settime < next_sys_time)
!     {
!         t_clock *c = clock_setlist;
!         sys_time = c->c_settime;
!         clock_unset(clock_setlist);
!         outlet_setstacklim();
!         (*c->c_fn)(c->c_owner);
!         if (sys_quit)
!             return;
      }
  }
  
--- 444,465 ----
  
  
! static int run_clock_callbacks(double next_sys_time)
  {
! 	if (clock_setlist && clock_setlist->c_settime < next_sys_time) 
! 	{
! 		do
! 		{
! 			t_clock *c = clock_setlist;
! 			clock_unset(c); /* the compiler should easily inline this */
! 			outlet_setstacklim();
! 			(*c->c_fn)(c->c_owner);
! 			if (sys_quit)
! 				break;
! 		}
! 		while (clock_setlist && clock_setlist->c_settime <= next_sys_time);
! 		return 1;
      }
+ 	else 
+ 		return 0;
  }
  
***************
*** 386,393 ****
  void sched_tick(double next_sys_time)
  {
-     run_clock_callbacks(next_sys_time); /* tb: is the dsp tick the right place for this? */
  	sys_time = next_sys_time;
  	sched_diddsp++; /* rethink: how to get rid of this stupid histogram??? */
      dsp_tick();
  }
  
--- 468,478 ----
  void sched_tick(double next_sys_time)
  {
  	sys_time = next_sys_time;
  	sched_diddsp++; /* rethink: how to get rid of this stupid histogram??? */
      dsp_tick();
+ 
+ 	/* rethink: should we really do all this midi messaging in the realtime thread ? */
+ 	sys_pollmidiqueue();
+ 	sys_setmiditimediff(0, 1e-6 * sys_schedadvance);
  }
  
***************
*** 428,433 ****
      sys_initmidiqueue();
  
- 	callback_fifo = fifo_init(); /* tb: initialize fifo for idle callbacks */
- 	
      while (!sys_quit)
      {
--- 513,516 ----
***************
*** 475,479 ****
--- 558,565 ----
  
  				if (timeforward != SENDDACS_NO)
+ 				{
  					sched_tick(sys_time + sys_time_per_dsp_tick);
+ 					run_clock_callbacks(sys_time);
+ 				}				
  				if (timeforward == SENDDACS_YES)
  					didsomething = 1;
***************
*** 494,500 ****
  					if (timeforward != SENDDACS_SLEPT)
  					{
- 						sys_unlock();
  						run_idle_callbacks(sys_sleepgrain);
- 						sys_lock();
  					}
  				}
--- 580,584 ----
***************
*** 505,534 ****
  				int didsomething = 0;
  				
! 				sys_setmiditimediff(0, 1e-6 * sys_schedadvance);
! 
! 				
! 				sys_pollmidiqueue();
  				sys_unlock();
  				sys_lock();
  
  				if (sys_pollgui())
! 				{
! 					/* tb: allow the audio callback to run */
! 					sys_unlock();
! 					sys_lock();
! 					didsomething = 1;
! 				}
  				
! 				/* test for idle; if so, do graphics updates. */
! 				if (!didsomething)
! 				{
  					sched_pollformeters();
- 					sys_unlock();
- 					sys_lock();
- 				}
- 				
- 				sys_unlock();
  				run_idle_callbacks(sys_sleepgrain);
- 				sys_lock();
  			}
  		sys_keepsched = 1;
--- 589,607 ----
  				int didsomething = 0;
  				
! 				/* tb: allow the audio callback to run */
  				sys_unlock();
  				sys_lock();
  
+ 				sys_pollmidiqueue();
+ 				
+  				if (run_clock_callbacks(sys_time))
+ 					continue;
+ 
  				if (sys_pollgui())
! 					continue;
  				
! 				/* do graphics updates and run idle callbacks */
  					sched_pollformeters();
  				run_idle_callbacks(sys_sleepgrain);
  			}
  		sys_keepsched = 1;
***************
*** 703,706 ****
--- 776,784 ----
  
  
+ void sys_init_idle_callbacks(void)
+ {
+ 	callback_fifo = fifo_init(); /* tb: initialize fifo for idle callbacks */
+ }	
+ 
  static t_sched_callback *ringbuffer_head;
  
***************
*** 710,720 ****
  	double stop;
  
  	stop = sys_getrealtime()*1.e6 + (double)microsec;
  
  	/* append idle callback to ringbuffer */
! 	new_callback = (t_sched_callback*) fifo_get(callback_fifo);
! 	while (new_callback != NULL)
  	{
  		t_sched_callback * next;
  		if (ringbuffer_head == NULL)
  		{
--- 788,802 ----
  	double stop;
  
+ 	sys_unlock();
+ 	
  	stop = sys_getrealtime()*1.e6 + (double)microsec;
  
  	/* append idle callback to ringbuffer */
! 	while (new_callback = (t_sched_callback*) fifo_get(callback_fifo))
  	{
  		t_sched_callback * next;
+ 		
+ 		/* set the next field to NULL ... it might be set in the fifo */
+ 		new_callback->next = NULL;
  		if (ringbuffer_head == NULL)
  		{
***************
*** 728,732 ****
  			next->next = new_callback;
  		}
- 		new_callback = (t_sched_callback*) fifo_get(callback_fifo);
  	}
  
--- 810,813 ----
***************
*** 775,783 ****
  
  		/* sleep for the rest of the time */
! 		if(remain > 0) sys_microsleep(remain);
  	}
      else
  		sys_microsleep(microsec);
  }
  /* } tb */
  
--- 856,877 ----
  
  		/* sleep for the rest of the time */
! 		if(remain > 0)
! 			sys_microsleep(remain);
  	}
      else
  		sys_microsleep(microsec);
+ 	sys_lock();
  }
  /* } tb */
  
+ void sys_setscheduler(int scheduler)
+ {
+ 	sys_keepsched = 0;
+ 	sys_callbackscheduler = scheduler;
+ 	return;
+ }
+ 
+ int sys_getscheduler(void)
+ {
+ 	return sys_callbackscheduler;
+ }

Index: m_fifo.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/m_fifo.c,v
retrieving revision 1.1.2.14
retrieving revision 1.1.2.14.2.1
diff -C2 -d -r1.1.2.14 -r1.1.2.14.2.1
*** m_fifo.c	11 May 2005 21:30:35 -0000	1.1.2.14
--- m_fifo.c	12 Jul 2005 15:11:10 -0000	1.1.2.14.2.1
***************
*** 185,189 ****
  		"	mr		%0, %4		\n"
         :"=r" (data), "=r" (c)
! 	   : "r" (&lifo->top), "r" (&lf->oc), "r" (a), "r" (b), "1" (c)
  	   : "r0" 		/* prevents using r0 because of the ambiguity of 'addi' coding: */
  	  				/* gcc version 2.95.3 20010315 (release - Linux-Mandrake 8.0 for PPC) */
--- 185,189 ----
  		"	mr		%0, %4		\n"
         :"=r" (data), "=r" (c)
! 	   : "r" (&lifo->top), "r" (&lifo->oc), "r" (a), "r" (b), "1" (c)
  	   : "r0" 		/* prevents using r0 because of the ambiguity of 'addi' coding: */
  	  				/* gcc version 2.95.3 20010315 (release - Linux-Mandrake 8.0 for PPC) */
***************
*** 212,216 ****
  	  "   bne-    0b		  \n"
  	  : "=r" (t1)
! 	  : "r" (&lifo->top), "r" (data), "r" (t2), "r" (&lf->oc), "0" (t1)
  	  : "r0" 		/* prevents using r0 because of the ambiguity of 'addi' coding: */
  	  				/* gcc version 2.95.3 20010315 (release - Linux-Mandrake 8.0 for PPC) */
--- 212,216 ----
  	  "   bne-    0b		  \n"
  	  : "=r" (t1)
! 	  : "r" (&lifo->top), "r" (data), "r" (t2), "r" (&lifo->oc), "0" (t1)
  	  : "r0" 		/* prevents using r0 because of the ambiguity of 'addi' coding: */
  	  				/* gcc version 2.95.3 20010315 (release - Linux-Mandrake 8.0 for PPC) */

Index: s_midi_alsa.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/s_midi_alsa.c,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.2.2.1
diff -C2 -d -r1.1.2.2 -r1.1.2.2.2.1
*** s_midi_alsa.c	2 May 2005 09:29:47 -0000	1.1.2.2
--- s_midi_alsa.c	12 Jul 2005 15:11:12 -0000	1.1.2.2.2.1
***************
*** 39,43 ****
  }
  
! void sys_do_open_midi(int nmidiin, int *midiinvec,
      int nmidiout, int *midioutvec)
  {
--- 39,43 ----
  }
  
! void sys_alsa_do_open_midi(int nmidiin, int *midiinvec,
      int nmidiout, int *midioutvec)
  {
***************
*** 104,108 ****
      ((x)==0xF2)?2:((x)<0xF4)?1:0)
  
! void sys_putmidimess(int portno, int a, int b, int c)
  {
      int channel;
--- 104,108 ----
      ((x)==0xF2)?2:((x)<0xF4)?1:0)
  
! void sys_alsa_putmidimess(int portno, int a, int b, int c)
  {
      int channel;
***************
*** 146,150 ****
          snd_seq_ev_set_direct(&ev);
          snd_seq_ev_set_subs(&ev);
!         snd_seq_ev_set_source(&ev,alsa_midioutfd[0]);
          snd_seq_event_output_direct(midi_handle,&ev);
      }
--- 146,150 ----
          snd_seq_ev_set_direct(&ev);
          snd_seq_ev_set_subs(&ev);
!         snd_seq_ev_set_source(&ev,alsa_midioutfd[portno]);
          snd_seq_event_output_direct(midi_handle,&ev);
      }
***************
*** 152,177 ****
  }
  
! void sys_putmidibyte(int portno, int byte)
  {
- 
-     post("putmidibyte not implemented, please report as a bug");
- /*    snd_midi_event_t *dev;
      snd_seq_event_t ev;
      snd_seq_ev_clear(&ev);
-     dev = (snd_midi_event_t*)malloc(4);
      if (portno >= 0 && portno < alsa_nmidiout)
      {
!         //alsa_midiout(alsa_midioutfd[portno], byte);       
!         snd_midi_event_encode_byte(dev, byte,&ev);
          snd_seq_ev_set_direct(&ev);
          snd_seq_ev_set_subs(&ev);
!         snd_seq_ev_set_source(&ev,alsa_port);
          snd_seq_event_output_direct(midi_handle,&ev);
!     }*/
  }
  
  
      /* this version uses the asynchronous "read()" ... */
! void sys_poll_midi(void)
  {
     char buf[20];
--- 152,177 ----
  }
  
! void sys_alsa_putmidibyte(int portno, int byte)
  {
      snd_seq_event_t ev;
      snd_seq_ev_clear(&ev);
      if (portno >= 0 && portno < alsa_nmidiout)
      {
!         // repack into 1 byte char and put somewhere to point at
!         unsigned char data = (unsigned char)byte;
!         unsigned char *dataptr = malloc(1);
!         memcpy(dataptr,&byte,1);
! 
!         snd_seq_ev_set_sysex(&ev,1,dataptr); //...set_variable *should* have worked but didn't
          snd_seq_ev_set_direct(&ev);
          snd_seq_ev_set_subs(&ev);
!         snd_seq_ev_set_source(&ev,alsa_midioutfd[portno]);
          snd_seq_event_output_direct(midi_handle,&ev);
!     }
  }
  
  
      /* this version uses the asynchronous "read()" ... */
! void sys_alsa_poll_midi(void)
  {
     char buf[20];
***************
*** 198,202 ****
  }
  
! void sys_close_midi()
  {
      alsa_nmidiin = alsa_nmidiout = 0;
--- 198,202 ----
  }
  
! void sys_alsa_close_midi()
  {
      alsa_nmidiin = alsa_nmidiout = 0;
***************
*** 216,220 ****
  }
  
! void midi_getdevs(char *indevlist, int *nindevs,
      char *outdevlist, int *noutdevs, int maxndev, int devdescsize)
  {
--- 216,220 ----
  }
  
! void midi_alsa_getdevs(char *indevlist, int *nindevs,
      char *outdevlist, int *noutdevs, int maxndev, int devdescsize)
  {

Index: g_canvas.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/g_canvas.c,v
retrieving revision 1.4.4.1.2.2
retrieving revision 1.4.4.1.2.3
diff -C2 -d -r1.4.4.1.2.2 -r1.4.4.1.2.3
*** g_canvas.c	19 Jun 2005 03:18:59 -0000	1.4.4.1.2.2
--- g_canvas.c	12 Jul 2005 15:11:07 -0000	1.4.4.1.2.3
***************
*** 28,31 ****
--- 28,32 ----
  #include "g_all_guis.h"
  
+     /* LATER consider adding font size to this struct (see glist_getfont()) */
  struct _canvasenvironment
  {
***************
*** 415,418 ****
--- 416,420 ----
          pd_bind(&x->gl_pd, canvas_makebindsym(x->gl_name));
      x->gl_loading = 1;
+     x->gl_goprect = 0;      /* no GOP rectangle unless it's turned on later */
      x->gl_willvis = vis;
      x->gl_edit = !strncmp(x->gl_name->s_name, "Untitled", 8);
***************
*** 422,426 ****
  }
  
! void canvas_setgraph(t_glist *x, int flag);
  
  static void canvas_coords(t_glist *x, t_symbol *s, int argc, t_atom *argv)
--- 424,428 ----
  }
  
! void canvas_setgraph(t_glist *x, int flag, int nogoprect);
  
  static void canvas_coords(t_glist *x, t_symbol *s, int argc, t_atom *argv)
***************
*** 432,436 ****
      x->gl_pixwidth = atom_getintarg(4, argc, argv);
      x->gl_pixheight = atom_getintarg(5, argc, argv);
!     canvas_setgraph(x, atom_getintarg(6, argc, argv));
  }
  
--- 434,445 ----
      x->gl_pixwidth = atom_getintarg(4, argc, argv);
      x->gl_pixheight = atom_getintarg(5, argc, argv);
!     if (argc <= 7)
!         canvas_setgraph(x, atom_getintarg(6, argc, argv), 1);
!     else
!     {
!         x->gl_xmargin = atom_getintarg(7, argc, argv);
!         x->gl_ymargin = atom_getintarg(8, argc, argv);
!         canvas_setgraph(x, atom_getintarg(6, argc, argv), 0);
!     }
  }
  
***************
*** 494,499 ****
          pd_bind(&x->gl_pd, canvas_makebindsym(x->gl_name));
      x->gl_owner = g;
-     x->gl_stretch = 1;
      x->gl_isgraph = 1;
      x->gl_obj.te_binbuf = binbuf_new();
      binbuf_addv(x->gl_obj.te_binbuf, "s", gensym("graph"));
--- 503,508 ----
          pd_bind(&x->gl_pd, canvas_makebindsym(x->gl_name));
      x->gl_owner = g;
      x->gl_isgraph = 1;
+     x->gl_goprect = 0;
      x->gl_obj.te_binbuf = binbuf_new();
      binbuf_addv(x->gl_obj.te_binbuf, "s", gensym("graph"));
***************
*** 603,606 ****
--- 612,629 ----
  }
  
+ void canvas_drawredrect(t_canvas *x, int doit)
+ {
+     if (doit)
+         sys_vgui(".x%lx.c create line\
+             %d %d %d %d %d %d %d %d %d %d -fill #ff8080 -tags GOP\n",
+             glist_getcanvas(x),
+             x->gl_xmargin, x->gl_ymargin,
+             x->gl_xmargin + x->gl_pixwidth, x->gl_ymargin,
+             x->gl_xmargin + x->gl_pixwidth, x->gl_ymargin + x->gl_pixheight,
+             x->gl_xmargin, x->gl_ymargin + x->gl_pixheight,
+             x->gl_xmargin, x->gl_ymargin);
+     else sys_vgui(".x%lx.c delete GOP\n",  glist_getcanvas(x));
+ }
+ 
      /* the window becomes "mapped" (visible and not miniaturized) or
      "unmapped" (either miniaturized or just plain gone.)  This should be
***************
*** 626,629 ****
--- 649,654 ----
              x->gl_mapped = 1;
              canvas_drawlines(x);
+             if (x->gl_isgraph && x->gl_goprect)
+                 canvas_drawredrect(x, 1);
              sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", x);
          }
***************
*** 635,638 ****
--- 660,664 ----
                  /* just clear out the whole canvas... */
              sys_vgui(".x%lx.c delete all\n", x);
+ #if 0
                  /* alternatively, we could have erased them one by one...
              for (y = x->gl_list; y; y = y->g_next)
***************
*** 640,643 ****
--- 666,670 ----
                      ... but we should go through and erase the lines as well
                      if we do it that way. */
+ #endif
              x->gl_mapped = 0;
          }
***************
*** 830,834 ****
  int glist_getfont(t_glist *x)
  {
!     return (glist_getcanvas(x)->gl_font);
  }
  
--- 857,864 ----
  int glist_getfont(t_glist *x)
  {
!     while (!x->gl_env)
!         if (!(x = x->gl_owner))
!             bug("t_canvasenvironment");
!     return (x->gl_font);
  }
  
***************
*** 870,874 ****
          linetraverser_start(&t, x);
          while (oc = linetraverser_next(&t))
! 	    sys_vgui(".x%lx.c create line %d %d %d %d -fill $::pdtheme::line -arrow $::pdtheme::arrow -width %d -tags l%lx\n",
                      glist_getcanvas(x),
                          t.tr_lx1, t.tr_ly1, t.tr_lx2, t.tr_ly2, 
--- 900,904 ----
          linetraverser_start(&t, x);
          while (oc = linetraverser_next(&t))
!             sys_vgui(".x%lx.c create line %d %d %d %d -width %d -tags l%lx\n",
                      glist_getcanvas(x),
                          t.tr_lx1, t.tr_ly1, t.tr_lx2, t.tr_ly2, 
***************
*** 1427,1431 ****
  void g_editor_setup(void);
  void g_readwrite_setup(void);
! extern void graph_properties(t_gobj *z, t_glist *owner);
  
  void g_canvas_setup(void)
--- 1457,1461 ----
  void g_editor_setup(void);
  void g_readwrite_setup(void);
! extern void canvas_properties(t_gobj *z);
  
  void g_canvas_setup(void)
***************
*** 1498,1502 ****
      class_addmethod(canvas_class, (t_method)canvas_map,
          gensym("map"), A_FLOAT, A_NULL);
!     class_setpropertiesfn(canvas_class, graph_properties);
  
  /* ---------------------- list handling ------------------------ */
--- 1528,1532 ----
      class_addmethod(canvas_class, (t_method)canvas_map,
          gensym("map"), A_FLOAT, A_NULL);
!     class_setpropertiesfn(canvas_class, (t_propertiesfn)canvas_properties);
  
  /* ---------------------- list handling ------------------------ */

Index: g_text.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/g_text.c,v
retrieving revision 1.5.4.2.2.1
retrieving revision 1.5.4.2.2.2
diff -C2 -d -r1.5.4.2.2.1 -r1.5.4.2.2.2
*** g_text.c	19 Jun 2005 03:18:59 -0000	1.5.4.2.2.1
--- g_text.c	12 Jul 2005 15:11:09 -0000	1.5.4.2.2.2
***************
*** 751,755 ****
                  canvas_realizedollar(x->a_glist, x->a_label)->s_name,
                  sys_hostfontsize(glist_getfont(glist)),
! 		"$::pdtheme::text");
          }
          else sys_vgui(".x%lx.c delete %lx.l\n", glist_getcanvas(glist), x);
--- 751,755 ----
                  canvas_realizedollar(x->a_glist, x->a_label)->s_name,
                  sys_hostfontsize(glist_getfont(glist)),
!                 "black");
          }
          else sys_vgui(".x%lx.c delete %lx.l\n", glist_getcanvas(glist), x);
***************
*** 935,939 ****
      if (glist_isvisible(glist) && text_shouldvis(x, glist))
          sys_vgui(".x%lx.c itemconfigure %sR -fill %s\n", glist, 
! 	    rtext_gettag(y), (state? "$::pdtheme::selected" : "$::pdtheme::object"));
  }
  
--- 935,939 ----
      if (glist_isvisible(glist) && text_shouldvis(x, glist))
          sys_vgui(".x%lx.c itemconfigure %sR -fill %s\n", glist, 
!             rtext_gettag(y), (state? "blue" : "black"));
  }
  
***************
*** 951,961 ****
  }
  
!     /* return true if the text box should be drawn.
!     We don't show object boxes inside graphs. */
  int text_shouldvis(t_text *x, t_glist *glist)
  {
      return (glist->gl_havewindow ||
          (x->te_pd != canvas_class && x->te_pd->c_wb != &text_widgetbehavior) ||
!         (x->te_pd == canvas_class && (((t_glist *)x)->gl_isgraph)));
  }
  
--- 951,962 ----
  }
  
!     /* return true if the text box should be drawn.  We don't show text boxes
!     inside graphs---except comments, if we're doing the new (goprect) style. */
  int text_shouldvis(t_text *x, t_glist *glist)
  {
      return (glist->gl_havewindow ||
          (x->te_pd != canvas_class && x->te_pd->c_wb != &text_widgetbehavior) ||
!         (x->te_pd == canvas_class && (((t_glist *)x)->gl_isgraph)) ||
!         (glist->gl_goprect && (x->te_type == T_TEXT)));
  }
  
***************
*** 1117,1121 ****
          int onset = x1 + (width - IOWIDTH) * i / nplus;
          if (firsttime)
! 	    sys_vgui(".x%lx.c create rectangle %d %d %d %d -outline $::pdtheme::outlet -tags %so%d\n",
                  glist_getcanvas(glist),
                  onset, y2 - 1,
--- 1118,1122 ----
          int onset = x1 + (width - IOWIDTH) * i / nplus;
          if (firsttime)
!             sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %so%d\n",
                  glist_getcanvas(glist),
                  onset, y2 - 1,
***************
*** 1134,1138 ****
          int onset = x1 + (width - IOWIDTH) * i / nplus;
          if (firsttime)
! 	    sys_vgui(".x%lx.c create rectangle %d %d %d %d -outline $::pdtheme::inlet -tags %si%d\n",
                  glist_getcanvas(glist),
                  onset, y1,
--- 1135,1139 ----
          int onset = x1 + (width - IOWIDTH) * i / nplus;
          if (firsttime)
!             sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %si%d\n",
                  glist_getcanvas(glist),
                  onset, y1,
***************
*** 1160,1164 ****
          if (firsttime)
              sys_vgui(".x%lx.c create line\
!  %d %d %d %d %d %d %d %d %d %d -fill $::pdtheme::object -dash %s -tags %sR\n",
                  glist_getcanvas(glist),
                      x1, y1,  x2, y1,  x2, y2,  x1, y2,  x1, y1,  pattern, tag);
--- 1161,1165 ----
          if (firsttime)
              sys_vgui(".x%lx.c create line\
!  %d %d %d %d %d %d %d %d %d %d -dash %s -tags %sR\n",
                  glist_getcanvas(glist),
                      x1, y1,  x2, y1,  x2, y2,  x1, y2,  x1, y1,  pattern, tag);
***************
*** 1177,1181 ****
          if (firsttime)
              sys_vgui(".x%lx.c create line\
!  %d %d %d %d %d %d %d %d %d %d %d %d %d %d -fill $::pdtheme::message -tags %sR\n",
                  glist_getcanvas(glist),
                  x1, y1,  x2+4, y1,  x2, y1+4,  x2, y2-4,  x2+4, y2,
--- 1178,1182 ----
          if (firsttime)
              sys_vgui(".x%lx.c create line\
!  %d %d %d %d %d %d %d %d %d %d %d %d %d %d -tags %sR\n",
                  glist_getcanvas(glist),
                  x1, y1,  x2+4, y1,  x2, y1+4,  x2, y2-4,  x2+4, y2,
***************
*** 1193,1197 ****
          if (firsttime)
              sys_vgui(".x%lx.c create line\
!  %d %d %d %d %d %d %d %d %d %d %d %d -fill $::pdtheme::atom -tags %sR\n",
                  glist_getcanvas(glist),
                  x1, y1,  x2-4, y1,  x2, y1+4,  x2, y2,  x1, y2,  x1, y1,
--- 1194,1198 ----
          if (firsttime)
              sys_vgui(".x%lx.c create line\
!  %d %d %d %d %d %d %d %d %d %d %d %d -tags %sR\n",
                  glist_getcanvas(glist),
                  x1, y1,  x2-4, y1,  x2, y1+4,  x2, y2,  x1, y2,  x1, y1,

Index: s_midi_pm.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/s_midi_pm.c,v
retrieving revision 1.4.4.1
retrieving revision 1.4.4.1.2.1
diff -C2 -d -r1.4.4.1 -r1.4.4.1.2.1
*** s_midi_pm.c	16 May 2005 13:07:25 -0000	1.4.4.1
--- s_midi_pm.c	12 Jul 2005 15:11:12 -0000	1.4.4.1.2.1
***************
*** 38,53 ****
      Pt_Start(1, 0, 0); /* start a timer with millisecond accuracy */
  
-         /* protect the unwary from having MIDI inputs open; they're
-         bad news if you close Pd's terminal window.  see sys_nmidiin
-         in s_main.c too. */
- #ifdef MSW
-     if (nmidiin)
-     {
-         post(
-          "midi input enabled; warning, don't close the DOS window directly!");
-     }
-     else post("not using MIDI input (use 'pd -midiindev 1' to override)");
- #endif
- 
      mac_nmidiindev = 0;
      for (i = 0; i < nmidiin; i++)
--- 38,41 ----

Index: d_filter.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/d_filter.c,v
retrieving revision 1.3.4.3
retrieving revision 1.3.4.3.2.1
diff -C2 -d -r1.3.4.3 -r1.3.4.3.2.1
*** d_filter.c	21 May 2005 13:08:13 -0000	1.3.4.3
--- d_filter.c	12 Jul 2005 15:11:06 -0000	1.3.4.3.2.1
***************
*** 399,402 ****
--- 399,472 ----
  }
  
+ /* tb: some loop unrolling & do some relaxed denormal bashing */
+ #if 1
+ static t_int *sigbiquad_perf8(t_int *w)
+ {
+     float *in = (float *)(w[1]);
+     float *out = (float *)(w[2]);
+     t_biquadctl *c = (t_biquadctl *)(w[3]);
+     int n = (t_int)(w[4])>>3;
+     int i;
+     float last = c->c_x1;
+     float prev = c->c_x2;
+     float fb1 = c->c_fb1;
+     float fb2 = c->c_fb2;
+     float ff1 = c->c_ff1;
+     float ff2 = c->c_ff2;
+     float ff3 = c->c_ff3;
+     for (i = 0; i < n; i++)
+     {
+         float output =  *in++ + fb1 * last + fb2 * prev;
+ #ifdef __i386__
+         output += 1e-10; /* quantizing should be faster than PD_BIGORSMALL */
+         output -= 1e-10; /* only doing this every 8th sample should be ok */
+ #endif
+ 		*out++ = ff1 * output + ff2 * last + ff3 * prev;
+         prev = last;
+         last = output;
+ 
+         output =  *in++ + fb1 * last + fb2 * prev;
+         *out++ = ff1 * output + ff2 * last + ff3 * prev;
+         prev = last;
+         last = output;
+ 
+         output =  *in++ + fb1 * last + fb2 * prev;
+         *out++ = ff1 * output + ff2 * last + ff3 * prev;
+         prev = last;
+         last = output;
+ 
+         output =  *in++ + fb1 * last + fb2 * prev;
+         *out++ = ff1 * output + ff2 * last + ff3 * prev;
+         prev = last;
+         last = output;
+ 
+         output =  *in++ + fb1 * last + fb2 * prev;
+ 		output += 1e-10;
+ 		output -= 1e-10;
+ 		*out++ = ff1 * output + ff2 * last + ff3 * prev;
+         prev = last;
+         last = output;
+ 
+         output =  *in++ + fb1 * last + fb2 * prev;
+         *out++ = ff1 * output + ff2 * last + ff3 * prev;
+         prev = last;
+         last = output;
+ 
+         output =  *in++ + fb1 * last + fb2 * prev;
+         *out++ = ff1 * output + ff2 * last + ff3 * prev;
+         prev = last;
+         last = output;
+ 
+         output =  *in++ + fb1 * last + fb2 * prev;
+         *out++ = ff1 * output + ff2 * last + ff3 * prev;
+         prev = last;
+         last = output;
+     }
+     c->c_x1 = last;
+     c->c_x2 = prev;
+     return (w+5);
+ }
+ #endif
+ 
  static void sigbiquad_list(t_sigbiquad *x, t_symbol *s, int argc, t_atom *argv)
  {
***************
*** 442,449 ****
  static void sigbiquad_dsp(t_sigbiquad *x, t_signal **sp)
  {
      dsp_add(sigbiquad_perform, 4,
          sp[0]->s_vec, sp[1]->s_vec, 
              x->x_ctl, sp[0]->s_n);
! 
  }
  
--- 512,530 ----
  static void sigbiquad_dsp(t_sigbiquad *x, t_signal **sp)
  {
+ #if 1
+ 	const int n = sp[0]->s_n;
+ 	if (n&7)
+ 		dsp_add(sigbiquad_perform, 4,
+ 			sp[0]->s_vec, sp[1]->s_vec, 
+             x->x_ctl, sp[0]->s_n);
+ 	else
+ 		dsp_add(sigbiquad_perf8, 4,
+ 			sp[0]->s_vec, sp[1]->s_vec, 
+             x->x_ctl, sp[0]->s_n);
+ #else
      dsp_add(sigbiquad_perform, 4,
          sp[0]->s_vec, sp[1]->s_vec, 
              x->x_ctl, sp[0]->s_n);
! #endif
  }
  

--- Makefile.am DELETED ---

Index: x_misc.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/x_misc.c,v
retrieving revision 1.2
retrieving revision 1.2.8.1
diff -C2 -d -r1.2 -r1.2.8.1
*** x_misc.c	6 Sep 2004 20:20:36 -0000	1.2
--- x_misc.c	12 Jul 2005 15:11:13 -0000	1.2.8.1
***************
*** 22,26 ****
  #endif
  
! #if defined (MACOSX) || defined (__FreeBSD__)
  #define HZ CLK_TCK
  #endif
--- 22,26 ----
  #endif
  
! #if defined (__APPLE__) || defined (__FreeBSD__)
  #define HZ CLK_TCK
  #endif

Index: m_glob.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/m_glob.c,v
retrieving revision 1.4.4.2
retrieving revision 1.4.4.2.2.1
diff -C2 -d -r1.4.4.2 -r1.4.4.2.2.1
*** m_glob.c	27 Dec 2004 16:02:34 -0000	1.4.4.2
--- m_glob.c	12 Jul 2005 15:11:10 -0000	1.4.4.2.2.1
***************
*** 24,27 ****
--- 24,28 ----
  void glob_midi_properties(t_pd *dummy, t_floatarg flongform);
  void glob_midi_dialog(t_pd *dummy, t_symbol *s, int argc, t_atom *argv);
+ void glob_midi_setapi(t_pd *dummy, t_floatarg f);
  void glob_start_path_dialog(t_pd *dummy, t_floatarg flongform);
  void glob_path_dialog(t_pd *dummy, t_symbol *s, int argc, t_atom *argv);
***************
*** 104,107 ****
--- 105,110 ----
      class_addmethod(glob_pdobject, (t_method)glob_audio_setapi,
          gensym("audio-setapi"), A_FLOAT, 0);
+     class_addmethod(glob_pdobject, (t_method)glob_midi_setapi,
+         gensym("midi-setapi"), A_FLOAT, 0);
      class_addmethod(glob_pdobject, (t_method)glob_midi_properties,
          gensym("midi-properties"), A_DEFFLOAT, 0);

Index: notes.txt
===================================================================
RCS file: /cvsroot/pure-data/pd/src/notes.txt,v
retrieving revision 1.6.4.3
retrieving revision 1.6.4.3.2.1
diff -C2 -d -r1.6.4.3 -r1.6.4.3.2.1
*** notes.txt	14 Dec 2004 09:40:40 -0000	1.6.4.3
--- notes.txt	12 Jul 2005 15:11:10 -0000	1.6.4.3.2.1
***************
*** 95,99 ****
  data:
  arrays of non-existent templates crash
- allow field(1,5,0,100) etc. in drawing commands
  vget, vset traversal objects
  cursor to show (x, y) location
--- 95,98 ----

Index: t_tkcmd.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/t_tkcmd.c,v
retrieving revision 1.2.4.1
retrieving revision 1.2.4.1.2.1
diff -C2 -d -r1.2.4.1 -r1.2.4.1.2.1
*** t_tkcmd.c	5 Nov 2004 14:27:47 -0000	1.2.4.1
--- t_tkcmd.c	12 Jul 2005 15:11:12 -0000	1.2.4.1.2.1
***************
*** 41,45 ****
  #endif
  
! #ifdef MACOSX
  #define STARTGUI
  #endif
--- 41,45 ----
  #endif
  
! #ifdef __APPLE__
  #define STARTGUI
  #endif
***************
*** 529,533 ****
      is done by passing the name of the file as a startup argument to
      the wish shell.) */
! #if !defined(MSW) && !defined(MACOSX)
  void pdgui_doevalfile(Tcl_Interp *interp, char *s)
  {
--- 529,533 ----
      is done by passing the name of the file as a startup argument to
      the wish shell.) */
! #if !defined(MSW) && !defined(__APPLE__)
  void pdgui_doevalfile(Tcl_Interp *interp, char *s)
  {
***************
*** 567,571 ****
      pdgui_setupsocket();
          /* read in the startup file */
! #if !defined(MSW) && !defined(MACOSX)
      pdgui_evalfile("pd.tk");
  #endif
--- 567,571 ----
      pdgui_setupsocket();
          /* read in the startup file */
! #if !defined(MSW) && !defined(__APPLE__)
      pdgui_evalfile("pd.tk");
  #endif

Index: s_file.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/s_file.c,v
retrieving revision 1.2.4.8.2.1
retrieving revision 1.2.4.8.2.2
diff -C2 -d -r1.2.4.8.2.1 -r1.2.4.8.2.2
*** s_file.c	22 May 2005 12:57:45 -0000	1.2.4.8.2.1
--- s_file.c	12 Jul 2005 15:11:11 -0000	1.2.4.8.2.2
***************
*** 206,210 ****
  #endif /* MSW */
  
! #ifdef MACOSX
  
  static void sys_initloadpreferences( void)
--- 206,210 ----
  #endif /* MSW */
  
! #ifdef __APPLE__
  
  static void sys_initloadpreferences( void)
***************
*** 256,260 ****
  }
  
! #endif /* MACOSX */
  
  void sys_loadpreferences( void)
--- 256,260 ----
  }
  
! #endif /* __APPLE__ */
  
  void sys_loadpreferences( void)
***************
*** 271,276 ****
          && sscanf(prefbuf, "%d", &api) > 0)
              sys_set_audio_api(api);
!     if (sys_getpreference("noaudioin", prefbuf, MAXPDSTRING))
!         naudioindev = 0;
      else
      {
--- 271,277 ----
          && sscanf(prefbuf, "%d", &api) > 0)
              sys_set_audio_api(api);
!     if (sys_getpreference("noaudioin", prefbuf, MAXPDSTRING) &&
!         !strcmp(prefbuf, ".") || !strcmp(prefbuf, "True"))
!             naudioindev = 0;
      else
      {
***************
*** 288,293 ****
              naudioindev = -1;
      }
!     if (sys_getpreference("noaudioout", prefbuf, MAXPDSTRING))
!         naudiooutdev = 0;
      else
      {
--- 289,295 ----
              naudioindev = -1;
      }
!     if (sys_getpreference("noaudioout", prefbuf, MAXPDSTRING) &&
!         !strcmp(prefbuf, ".") || !strcmp(prefbuf, "True"))
!             naudiooutdev = 0;
      else
      {
***************
*** 318,322 ****
          
          /* load MIDI preferences */
!     for (i = 0, nmidiindev = 0; i < MAXMIDIINDEV; i++)
      {
          sprintf(keybuf, "midiindev%d", i+1);
--- 320,327 ----
          
          /* load MIDI preferences */
!     if (sys_getpreference("nomidiin", prefbuf, MAXPDSTRING) &&
!         !strcmp(prefbuf, ".") || !strcmp(prefbuf, "True"))
!             nmidiindev = 0;
!     else for (i = 0, nmidiindev = 0; i < MAXMIDIINDEV; i++)
      {
          sprintf(keybuf, "midiindev%d", i+1);
***************
*** 327,331 ****
          nmidiindev++;
      }
!     for (i = 0, nmidioutdev = 0; i < MAXMIDIOUTDEV; i++)
      {
          sprintf(keybuf, "midioutdev%d", i+1);
--- 332,339 ----
          nmidiindev++;
      }
!     if (sys_getpreference("nomidiout", prefbuf, MAXPDSTRING) &&
!         !strcmp(prefbuf, ".") || !strcmp(prefbuf, "True"))
!             nmidioutdev = 0;
!     else for (i = 0, nmidioutdev = 0; i < MAXMIDIOUTDEV; i++)
      {
          sprintf(keybuf, "midioutdev%d", i+1);
***************
*** 400,405 ****
          &naudiooutdev, audiooutdev, choutdev, &rate, &dacblocksize, &advance, &scheduler);
  
!     if (naudioindev <= 0)
!         sys_putpreference("noaudioin", ".");
      for (i = 0; i < naudioindev; i++)
      {
--- 408,412 ----
          &naudiooutdev, audiooutdev, choutdev, &rate, &dacblocksize, &advance, &scheduler);
  
!     sys_putpreference("noaudioin", (naudioindev <= 0 ? "True" : "False"));
      for (i = 0; i < naudioindev; i++)
      {
***************
*** 408,413 ****
          sys_putpreference(buf1, buf2);
      }
!     if (naudiooutdev <= 0)
!         sys_putpreference("noaudioout", ".");
      for (i = 0; i < naudiooutdev; i++)
      {
--- 415,419 ----
          sys_putpreference(buf1, buf2);
      }
!     sys_putpreference("noaudioout", (naudiooutdev <= 0 ? "True" : "False"));
      for (i = 0; i < naudiooutdev; i++)
      {
***************
*** 433,438 ****
          /* MIDI settings */
      sys_get_midi_params(&nmidiindev, midiindev, &nmidioutdev, midioutdev);
!     if (nmidiindev <= 0)
!         sys_putpreference("nomidiin", ".");
      for (i = 0; i < nmidiindev; i++)
      {
--- 439,443 ----
          /* MIDI settings */
      sys_get_midi_params(&nmidiindev, midiindev, &nmidioutdev, midioutdev);
!     sys_putpreference("nomidiin", (nmidiindev <= 0 ? "True" : "False"));
      for (i = 0; i < nmidiindev; i++)
      {
***************
*** 441,446 ****
          sys_putpreference(buf1, buf2);
      }
!     if (nmidioutdev <= 0)
!         sys_putpreference("nomidiout", ".");
      for (i = 0; i < nmidioutdev; i++)
      {
--- 446,450 ----
          sys_putpreference(buf1, buf2);
      }
!     sys_putpreference("nomidiout", (nmidioutdev <= 0 ? "True" : "False"));
      for (i = 0; i < nmidioutdev; i++)
      {

Index: d_fft.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/d_fft.c,v
retrieving revision 1.2.4.1
retrieving revision 1.2.4.1.2.1
diff -C2 -d -r1.2.4.1 -r1.2.4.1.2.1
*** d_fft.c	5 Nov 2004 13:55:58 -0000	1.2.4.1
--- d_fft.c	12 Jul 2005 15:11:06 -0000	1.2.4.1.2.1
***************
*** 408,418 ****
      else    
      {
! 	x->dim.n=n;
! 	x->dim.is=1;
! 	x->dim.os=1;
! 	x->plan = fftwf_plan_guru_split_dft_r2c(1, &(x->dim), 0, NULL, 
! 						in, out1, out2,
! 						FFTW_MEASURE);
! 	dsp_add(sigrfftw_perform,3,&x->plan,out2+1,n2-1);
      }
  
--- 408,417 ----
      else    
      {
! 		x->dim.n=n;
! 		x->dim.is=1;
! 		x->dim.os=1;
! 		x->plan = fftwf_plan_guru_split_dft_r2c(1, &(x->dim), 0, NULL, 
! 			in, out1, out2, FFTW_MEASURE | FFTW_PRESERVE_INPUT);
! 		dsp_add(sigrfftw_perform,3,&x->plan,out2+1,n2-1);
      }
  
***************
*** 483,493 ****
      else    
      {
! 	x->dim.n=n;
! 	x->dim.is=1;
! 	x->dim.os=1;
! 	x->plan = fftwf_plan_guru_split_dft_c2r(1, &(x->dim), 0, NULL, 
! 						in1, in2, out,
! 						FFTW_MEASURE);
! 	dsp_add(sigrifftw_perform,3,&x->plan,in2,n2);
      }
  }
--- 482,492 ----
      else    
      {
! 		x->dim.n=n;
! 		x->dim.is=1;
! 		x->dim.os=1;
! 		x->plan = fftwf_plan_guru_split_dft_c2r(1, &(x->dim), 0, NULL, 
! 			in1, in2, out, FFTW_MEASURE | FFTW_PRESERVE_INPUT);
! 		dsp_add_zero(in1+ n/2, n/2);
! 		dsp_add(sigrifftw_perform,3,&x->plan,in2,n2);
      }
  }

Index: s_inter.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/s_inter.c,v
retrieving revision 1.5.4.10.2.1
retrieving revision 1.5.4.10.2.2
diff -C2 -d -r1.5.4.10.2.1 -r1.5.4.10.2.2
*** s_inter.c	22 May 2005 13:00:13 -0000	1.5.4.10.2.1
--- s_inter.c	12 Jul 2005 15:11:11 -0000	1.5.4.10.2.2
***************
*** 6,9 ****
--- 6,11 ----
  that didn't really belong anywhere. */
  
+ #define WATCHDOGTHREAD
+ 
  #include "m_pd.h"
  #include "s_stuff.h"
***************
*** 40,44 ****
  #include <stdio.h>
  
! #ifdef MACOSX
  #include <sys/types.h>
  #include <sys/stat.h>
--- 42,46 ----
  #include <stdio.h>
  
! #ifdef __APPLE__
  #include <sys/types.h>
  #include <sys/stat.h>
***************
*** 51,54 ****
--- 53,57 ----
  #define DEBUG_MESSDOWN 2    /* messages down from pd-gui to pd */
  
+ /* T.Grill - make it a _little_ more adaptable... */
  #ifndef PDBINDIR
  #define PDBINDIR "bin/"
***************
*** 162,182 ****
      timout.tv_usec = 0;
  
!         FD_ZERO(&writeset);
!         FD_ZERO(&readset);
!         FD_ZERO(&exceptset);
!         for (fp = sys_fdpoll, i = sys_nfdpoll; i--; fp++)
!             FD_SET(fp->fdp_fd, &readset);
!         select(sys_maxfd+1, &readset, &writeset, &exceptset, &timout);
!         for (i = 0; i < sys_nfdpoll; i++)
!             if (FD_ISSET(sys_fdpoll[i].fdp_fd, &readset))
          {
              (*sys_fdpoll[i].fdp_fn)(sys_fdpoll[i].fdp_ptr, sys_fdpoll[i].fdp_fd);
              didsomething = 1;
          }
!         return (didsomething);
!     }
  
  void sys_microsleep(int microsec)
!     {
  	/* tb:
  	   sleep granularity on "modern" operating systems is only 1ms??? 
--- 165,185 ----
      timout.tv_usec = 0;
  
! 	FD_ZERO(&writeset);
! 	FD_ZERO(&readset);
! 	FD_ZERO(&exceptset);
! 	for (fp = sys_fdpoll, i = sys_nfdpoll; i--; fp++)
! 		FD_SET(fp->fdp_fd, &readset);
! 	select(sys_maxfd+1, &readset, &writeset, &exceptset, &timout);
! 	for (i = 0; i < sys_nfdpoll; i++)
! 		if (FD_ISSET(sys_fdpoll[i].fdp_fd, &readset))
          {
              (*sys_fdpoll[i].fdp_fn)(sys_fdpoll[i].fdp_ptr, sys_fdpoll[i].fdp_fd);
              didsomething = 1;
          }
! 	return (didsomething);
! }
  
  void sys_microsleep(int microsec)
! {
  	/* tb:
  	   sleep granularity on "modern" operating systems is only 1ms??? 
***************
*** 191,201 ****
  	*/
  
! 	if (microsec < 1000)
! 				microsec = 1000;
  #ifndef MSW
! 	struct timespec rec, rem;
! 	rec.tv_sec = 0;
! 	rec.tv_nsec = 1000 * microsec;
! 	nanosleep(&rec, &rem);
  #else
                Sleep(microsec/1000);
--- 194,205 ----
  	*/
  
! 	/* 	if (!sys_callbackscheduler && microsec < 1000) */
! 	/* 		microsec = 1000; */
  #ifndef MSW
! 	struct timeval timeout;
! 	timeout.tv_sec = 0;
! 	timeout.tv_usec = microsec;
! 	select(0,0,0,0,&timeout);
! 
  #else
                Sleep(microsec/1000);
***************
*** 203,207 ****
  
  	/* a solution for lower timeslices might be a busysleep but this might
! 	   block a low-prority thread and won't work for win9x
  
  #define _WIN32_WINNT 0x0400
--- 207,211 ----
  
  	/* a solution for lower timeslices might be a busysleep but this might
! 	   block a low-priority thread and won't work for win9x
  
  #define _WIN32_WINNT 0x0400
***************
*** 214,218 ****
  		SwitchToThread();
  #else 
! 		sched_yield()
  #endif
  	}
--- 218,222 ----
  		SwitchToThread();
  #else 
! 		sched_yield();
  #endif
  	}
***************
*** 236,239 ****
--- 240,244 ----
      if (sigaction(signo, &action, 0) < 0)
          perror("sigaction");
+ 
  }
  
***************
*** 241,245 ****
  {
      static int trouble = 0;
!     if (!trouble)
      {
          trouble = 1;
--- 246,250 ----
  {
      static int trouble = 0;
! 	if (!trouble)
      {
          trouble = 1;
***************
*** 247,251 ****
          sys_bail(1);
      }
!     else _exit(1);
  }
  
--- 252,257 ----
          sys_bail(1);
      }
!     else 
! 		sys_bail(0);
  }
  
***************
*** 281,285 ****
  #endif
  
! #ifdef __linux
  
  #if defined(_POSIX_PRIORITY_SCHEDULING) || defined(_POSIX_MEMLOCK)
--- 287,291 ----
  #endif
  
! #if defined(__linux) || defined(__APPLE__)
  
  #if defined(_POSIX_PRIORITY_SCHEDULING) || defined(_POSIX_MEMLOCK)
***************
*** 843,848 ****
  int sys_pollgui(void)
  {
! /*     return (sys_domicrosleep(0, 1) || sys_poll_togui()); */
!     return (sys_pollsockets() || sys_poll_togui());
  }
  
--- 849,853 ----
  int sys_pollgui(void)
  {
! 	return (sys_pollsockets() || sys_poll_togui());
  }
  
***************
*** 856,859 ****
--- 861,865 ----
  void glob_watchdog(t_pd *dummy)
  {
+ #ifndef WATCHDOGTHREAD
      if (write(sys_watchfd, "\n", 1) < 1)
      {
***************
*** 861,864 ****
--- 867,871 ----
          sys_bail(1);
      }
+ #endif
  }
  #endif
***************
*** 870,873 ****
--- 877,906 ----
          24, 15, 28};
  
+ static int sys_start_watchdog_thread();
+ 
+ static t_int fake_initfromgui(t_int* dummy)
+ {
+ 	/* fake the GUI's message giving cwd and font sizes; then
+ 	   skip starting the GUI up. */
+ 	char cmdbuf[4*MAXPDSTRING];
+ 	t_atom zz[19];
+ 	int i;
+ #ifdef MSW
+ 	if (GetCurrentDirectory(MAXPDSTRING, cmdbuf) == 0)
+ 		strcpy(cmdbuf, ".");
+ #endif
+ #ifdef UNISTD
+ 	if (!getcwd(cmdbuf, MAXPDSTRING))
+ 		strcpy(cmdbuf, ".");
+ 	
+ #endif
+ 	SETSYMBOL(zz, gensym(cmdbuf));
+ 	for (i = 1; i < 22; i++)
+ 		SETFLOAT(zz + i, defaultfontshit[i-1]);
+ 	SETFLOAT(zz+22,0);
+ 	glob_initfromgui(0, 0, 23, zz);
+ 	return 0;
+ }
+ 
  int sys_startgui(const char *guidir)
  {
***************
*** 900,906 ****
      signal(SIGIOT, sys_exithandler);
      signal(SIGFPE, SIG_IGN);
!     /* signal(SIGILL, sys_exithandler);
      signal(SIGBUS, sys_exithandler);
!     signal(SIGSEGV, sys_exithandler); */
      signal(SIGPIPE, SIG_IGN);
      signal(SIGALRM, SIG_IGN);
--- 933,939 ----
      signal(SIGIOT, sys_exithandler);
      signal(SIGFPE, SIG_IGN);
! /*	signal(SIGILL, sys_exithandler);
      signal(SIGBUS, sys_exithandler);
! 	signal(SIGSEGV, sys_exithandler); */
      signal(SIGPIPE, SIG_IGN);
      signal(SIGALRM, SIG_IGN);
***************
*** 915,936 ****
      if (sys_nogui)
      {
!             /* fake the GUI's message giving cwd and font sizes; then
!             skip starting the GUI up. */
!         t_atom zz[19];
!         int i;
! #ifdef MSW
!         if (GetCurrentDirectory(MAXPDSTRING, cmdbuf) == 0)
!             strcpy(cmdbuf, ".");
! #endif
! #ifdef UNISTD
!         if (!getcwd(cmdbuf, MAXPDSTRING))
!             strcpy(cmdbuf, ".");
!         
! #endif
!         SETSYMBOL(zz, gensym(cmdbuf));
!         for (i = 1; i < 22; i++)
!             SETFLOAT(zz + i, defaultfontshit[i-1]);
!         SETFLOAT(zz+22,0);
!         glob_initfromgui(0, 0, 23, zz);
      }
      else if (sys_guisetportnumber)  /* GUI exists and sent us a port number */
--- 948,952 ----
      if (sys_nogui)
      {
! 		sys_callback((void*)fake_initfromgui,0,0);
      }
      else if (sys_guisetportnumber)  /* GUI exists and sent us a port number */
***************
*** 1043,1047 ****
          {
              seteuid(getuid());          /* lose setuid priveliges */
! #ifndef MACOSX
                  /* the wish process in Unix will make a wish shell and
                      read/write standard in and out unless we close the
--- 1059,1063 ----
          {
              seteuid(getuid());          /* lose setuid priveliges */
! #ifndef __APPLE__
                  /* the wish process in Unix will make a wish shell and
                      read/write standard in and out unless we close the
***************
*** 1062,1066 ****
              if (!sys_guicmd)
              {
! #ifdef MACOSX
                  char *homedir = getenv("HOME"), filename[250];
                  struct stat statbuf;
--- 1078,1082 ----
              if (!sys_guicmd)
              {
! #ifdef __APPLE__
                  char *homedir = getenv("HOME"), filename[250];
                  struct stat statbuf;
***************
*** 1079,1082 ****
--- 1095,1108 ----
              nohomedir:
                  strcpy(filename, 
+                     "/System/Library/Frameworks/Tk.Framework/Resources/Wish Shell.app/Contents/MacOS/Wish Shell");
+                 if (stat(filename, &statbuf) >= 0)
+                     goto foundit;
+ 
+                 strcpy(filename, 
+                     "/Library/Frameworks/Tk.Framework/Resources/Wish Shell.app/Contents/MacOS/Wish Shell");
+                 if (stat(filename, &statbuf) >= 0)
+                     goto foundit;
+ 
+                 strcpy(filename, 
                      "/Applications/Utilities/Wish Shell.app/Contents/MacOS/Wish Shell");
                  if (stat(filename, &statbuf) >= 0)
***************
*** 1140,1143 ****
--- 1166,1170 ----
      if (sys_hipriority)
      {
+ #ifndef WATCHDOGTHREAD
              /* To prevent lockup, we fork off a watchdog process with
              higher real-time priority than ours.  The GUI has to send
***************
*** 1192,1195 ****
--- 1219,1226 ----
                  this is done later when the socket is open. */
          }
+ #else
+ 		sys_start_watchdog_thread();
+ 		sys_set_priority(0);
+ #endif
      }
  
***************
*** 1201,1205 ****
          fprintf(stderr, "pd: couldn't set high priority class\n");
  #endif
! #ifdef MACOSX
      if (sys_hipriority)
      {
--- 1232,1236 ----
          fprintf(stderr, "pd: couldn't set high priority class\n");
  #endif
! #ifdef __APPLE__
      if (sys_hipriority)
      {
***************
*** 1213,1217 ****
              post("warning: high priority scheduling failed\n");
      }
! #endif /* MACOSX */
  
      if (!sys_nogui && !sys_guisetportnumber)
--- 1244,1248 ----
              post("warning: high priority scheduling failed\n");
      }
! #endif /* __APPLE__ */
  
      if (!sys_nogui && !sys_guisetportnumber)
***************
*** 1232,1236 ****
      if (!sys_nogui)
      {
!          char buf[256];
           sys_socketreceiver = socketreceiver_new(0, 0, 0, 0);
           sys_addpollfn(sys_guisock, (t_fdpollfn)socketreceiver_read,
--- 1263,1267 ----
      if (!sys_nogui)
      {
!          char buf[256], buf2[256];
           sys_socketreceiver = socketreceiver_new(0, 0, 0, 0);
           sys_addpollfn(sys_guisock, (t_fdpollfn)socketreceiver_read,
***************
*** 1239,1248 ****
              /* here is where we start the pinging. */
  #if defined(__linux__) || defined(IRIX)
           if (sys_hipriority)
               sys_gui("pdtk_watchdog\n");
  #endif
           sys_get_audio_apis(buf);
!          sys_vgui("pdtk_pd_startup {%s} %s {%s}\n", pd_version, buf, 
!                                   sys_font); 
      }
      return (0);
--- 1270,1282 ----
              /* here is where we start the pinging. */
  #if defined(__linux__) || defined(IRIX)
+ #ifndef WATCHDOGTHREAD
           if (sys_hipriority)
               sys_gui("pdtk_watchdog\n");
  #endif
+ #endif
           sys_get_audio_apis(buf);
! 		 sys_get_midi_apis(buf2);
!          sys_vgui("pdtk_pd_startup {%s} %s %s {%s}\n", pd_version, buf, buf2,
! 			 sys_font); 
      }
      return (0);
***************
*** 1250,1253 ****
--- 1284,1289 ----
  }
  
+ 
+ /* T.Grill - import clean quit function */
  extern void sys_exit(void);
  
***************
*** 1258,1265 ****
  {
      static int reentered = 0;
!     if (!reentered)
      {
          reentered = 1;
- #ifndef __linux__  /* sys_close_audio() hangs if you're in a signal? */
          fprintf(stderr, "closing audio...\n");
          sys_close_audio();
--- 1294,1300 ----
  {
      static int reentered = 0;
! 	if (!reentered)
      {
          reentered = 1;
          fprintf(stderr, "closing audio...\n");
          sys_close_audio();
***************
*** 1267,1272 ****
          sys_close_midi();
          fprintf(stderr, "... done.\n");
! #endif
!         exit(1);
      }
      else _exit(n);
--- 1302,1306 ----
          sys_close_midi();
          fprintf(stderr, "... done.\n");
!         _exit(n);
      }
      else _exit(n);
***************
*** 1284,1285 ****
--- 1318,1401 ----
  }
  
+ #include "pthread.h"
+ static pthread_t watchdog_id;
+ static pthread_t main_pd_thread;
+ static pthread_mutex_t watchdog_mutex = PTHREAD_MUTEX_INITIALIZER;
+ static pthread_cond_t watchdog_cond = PTHREAD_COND_INITIALIZER;
+ 
+ static void * watchdog_thread(void*);
+ 
+ /* start a high priority watchdog thread */
+ static int sys_start_watchdog_thread()
+ {
+ 	pthread_attr_t w_attr;
+ 	int status;
+ 	
+ 	/* get parent thread ID */
+ 	main_pd_thread = pthread_self();
+ 	
+ 	/* set up attributes */
+ 	pthread_attr_init(&w_attr);
+ 	
+ 	pthread_attr_setschedpolicy(&w_attr, SCHED_FIFO); /* use rt scheduling */
+ 	
+ 	status = pthread_create(&watchdog_id, &w_attr, (void*) watchdog_thread, NULL);
+ }
+ 
+ 
+ 
+ #ifdef MSW
+ int gettimeofday (struct timeval *tv, void* tz);
+ #endif
+ 
+ 
+ static t_int* watchdog_callback(t_int* dummy)
+ {
+ 	/* signal the condition */
+ 	pthread_cond_signal(&watchdog_cond);
+ 	return 0;
+ }
+ 
+ /* this watchdog thread registers an idle callback once a minute 
+    if the idle callback isn't excecuted within one minute, we're probably
+    blocking the system.
+    kill the whole process!
+ */
+ 
+ static void * watchdog_thread(void* dummy)
+ {
+ 	sys_set_priority(1);
+ 	post("watchdog thread started");
+ 	
+ 	sys_microsleep(3e7); /* start polling after 30 seconds ... hoping that everything is set up */
+ 
+ 	while (1)
+ 	{
+ 		/* - register idle callback
+ 		   - wait for condition variable
+ 		   - in case of timeout kill the parent thread 
+ 		   - sleep
+ 		*/
+ 		struct timespec timeout;
+ 		struct timeval now;
+ 		
+ 		int status;
+ 		
+ 		gettimeofday(&now,0);
+ 		timeout.tv_sec = now.tv_sec + 15; /* timeout: 15 seconds */
+ 		timeout.tv_nsec = now.tv_usec * 1000;
+ 		
+ 		sys_callback((void*)watchdog_callback, 0, 0);
+ 		status = pthread_cond_timedwait(&watchdog_cond, &watchdog_mutex, &timeout);
+ 		
+ 		if (status)
+ 		{
+ 			fprintf(stderr, "watchdog killing");
+ 			/* kill parent thread */
+ 			kill(0,9);
+ 		}
+ 		
+ 		sys_microsleep(6e7); /* and sleep for another 60 seconds */
+ 	}
+ }
+ 

Index: x_connective.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/x_connective.c,v
retrieving revision 1.3.4.1.2.1
retrieving revision 1.3.4.1.2.2
diff -C2 -d -r1.3.4.1.2.1 -r1.3.4.1.2.2
*** x_connective.c	3 Jun 2005 11:02:13 -0000	1.3.4.1.2.1
--- x_connective.c	12 Jul 2005 15:11:13 -0000	1.3.4.1.2.2
***************
*** 492,496 ****
                  outlet_anything(e->e_outlet, argv[0].a_w.w_symbol,
                      argc-1, argv+1);
!             else outlet_list(e->e_outlet, 0, argc, argv);
              return;
          }
--- 492,513 ----
                  outlet_anything(e->e_outlet, argv[0].a_w.w_symbol,
                      argc-1, argv+1);
!             else
! 				/* tb {: avoid 1 element lists */
! 			{
! 				if (argc > 1) /* list */
! 					outlet_list(e->e_outlet, 0, argc, argv);
! 
! 				else if (argc == 0) /* bang */
! 					outlet_bang(e->e_outlet);
! 				
! 				else /* argc == 1 */
! 					if (argv[0].a_type == A_FLOAT)
! 						outlet_float(e->e_outlet, argv[0].a_w.w_float);
! 					else if (argv[0].a_type == A_SYMBOL)
! 						outlet_symbol(e->e_outlet, argv[0].a_w.w_symbol);
! 					else if (argv[0].a_type == A_POINTER)
! 						outlet_pointer(e->e_outlet, argv[0].a_w.w_gpointer);
! 				/* tb } */
! 			}
              return;
          }
***************
*** 518,522 ****
                  outlet_anything(e->e_outlet, argv[1].a_w.w_symbol,
                      argc-2, argv+2);
!             else outlet_list(e->e_outlet, 0, argc-1, argv+1);
              return;
          }
--- 535,558 ----
                  outlet_anything(e->e_outlet, argv[1].a_w.w_symbol,
                      argc-2, argv+2);
!             else /* outlet_list(e->e_outlet, 0, argc-1, argv+1); */
! 							/* tb {: avoid 1 element lists */
! 			{
! 				argc -= 1, argv+=1;
! 				if (argc > 1) /* list */
! 					outlet_list(e->e_outlet, 0, argc, argv);
! 
! 				else if (argc == 0) /* bang */
! 					outlet_bang(e->e_outlet);
! 				
! 				else /* argc == 1 */
! 					if (argv[0].a_type == A_FLOAT)
! 						outlet_float(e->e_outlet, argv[0].a_w.w_float);
! 					else if (argv[0].a_type == A_SYMBOL)
! 						outlet_symbol(e->e_outlet, argv[0].a_w.w_symbol);
! 					else if (argv[0].a_type == A_POINTER)
! 						outlet_pointer(e->e_outlet, argv[0].a_w.w_gpointer);
! 				/* tb } */
! 			}
! 
              return;
          }
***************
*** 598,618 ****
     /* JMZ: type checking: arguments must bei either floats xor symbols */
      if (x->x_type == A_FLOAT) 
!       {
! 	for(n=0; n<argc; n++)
! 	  if (argv[n].a_type!=A_FLOAT)
! 	    {
! 	      pd_error(x, "route: cannot route floats and symbols at the same time");
! 	      return 0;
! 	    }
!       }
      else
!       {
! 	for(n=0; n<argc; n++)
! 	  if(argv[n].a_type==A_FLOAT)
! 	    {
! 	      pd_error(x, "route: cannot route symbols and floats at the same time");
! 	      return 0;
! 	    }
!       }
  
      x->x_vec = (t_routeelement *)getbytes(argc * sizeof(*x->x_vec));
--- 634,654 ----
     /* JMZ: type checking: arguments must bei either floats xor symbols */
      if (x->x_type == A_FLOAT) 
! 	{
! 		for(n=0; n<argc; n++)
! 			if (argv[n].a_type!=A_FLOAT)
! 			{
! 				pd_error(x, "route: cannot route floats and symbols at the same time");
! 				return 0;
! 			}
! 	}
      else
! 	{
! 		for(n=0; n<argc; n++)
! 			if(argv[n].a_type==A_FLOAT)
! 			{
! 				pd_error(x, "route: cannot route symbols and floats at the same time");
! 				return 0;
! 			}
! 	}
  
      x->x_vec = (t_routeelement *)getbytes(argc * sizeof(*x->x_vec));

Index: d_array.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/d_array.c,v
retrieving revision 1.3.4.3
retrieving revision 1.3.4.3.2.1
diff -C2 -d -r1.3.4.3 -r1.3.4.3.2.1
*** d_array.c	11 Jan 2005 21:41:14 -0000	1.3.4.3
--- d_array.c	12 Jul 2005 15:10:50 -0000	1.3.4.3.2.1
***************
*** 571,580 ****
  
  #else
! #ifdef MACOSX
  #define HIOFFSET 0    /* word offset to find MSB */
  #define LOWOFFSET 1    /* word offset to find LSB */
  #define int32 int  /* a data type that has 32 bits */
  
! #endif /* MACOSX */
  #endif /* __linux__ */
  #endif /* MSW */
--- 571,580 ----
  
  #else
! #ifdef __APPLE__
  #define HIOFFSET 0    /* word offset to find MSB */
  #define LOWOFFSET 1    /* word offset to find LSB */
  #define int32 int  /* a data type that has 32 bits */
  
! #endif /* __APPLE__ */
  #endif /* __linux__ */
  #endif /* MSW */

Index: m_pd.h
===================================================================
RCS file: /cvsroot/pure-data/pd/src/m_pd.h,v
retrieving revision 1.4.4.11.2.1
retrieving revision 1.4.4.11.2.2
diff -C2 -d -r1.4.4.11.2.1 -r1.4.4.11.2.2
*** m_pd.h	22 May 2005 12:52:10 -0000	1.4.4.11.2.1
--- m_pd.h	12 Jul 2005 15:11:10 -0000	1.4.4.11.2.2
***************
*** 712,716 ****
  EXTERN float garray_get(t_garray *x, t_symbol *s, t_int indx);
  EXTERN void garray_redraw(t_garray *x);
- EXTERN double garray_updatetime(t_garray *x); /* T.Grill - get last update time (clock_getlogicaltime) */
  EXTERN int garray_npoints(t_garray *x);
  EXTERN char *garray_vec(t_garray *x);
--- 712,715 ----
***************
*** 718,724 ****
  EXTERN void garray_usedindsp(t_garray *x);
  EXTERN void garray_setsaveit(t_garray *x, int saveit);
- EXTERN void garray_lock(t_garray *x);   /* TB: array locking */
- EXTERN void garray_unlock(t_garray *x);
- EXTERN int garray_trylock(t_garray *x);
  
  EXTERN t_class *scalar_class;
--- 717,720 ----

Index: g_graph.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/g_graph.c,v
retrieving revision 1.3.4.2.2.2
retrieving revision 1.3.4.2.2.3
diff -C2 -d -r1.3.4.2.2.2 -r1.3.4.2.2.3
*** g_graph.c	19 Jun 2005 03:18:59 -0000	1.3.4.2.2.2
--- g_graph.c	12 Jul 2005 15:11:07 -0000	1.3.4.2.2.3
***************
*** 25,28 ****
--- 25,30 ----
  /* -------------------- maintaining the list -------------------- */
  
+ void canvas_drawredrect(t_canvas *x, int doit);
+ 
  void glist_add(t_glist *x, t_gobj *y)
  {
***************
*** 38,41 ****
--- 40,49 ----
      if (x->gl_editor && (ob = pd_checkobject(&y->g_pd)))
          rtext_new(x, ob);
+     if (x->gl_editor && x->gl_isgraph && !x->gl_goprect
+         && pd_checkobject(&y->g_pd))
+     {
+         x->gl_goprect = 1;
+         canvas_drawredrect(x, 1);
+     }
      if (glist_isvisible(x))
          gobj_vis(y, x, 1);
***************
*** 595,604 ****
      /* get the window location in pixels of a "text" object.  The
      object's x and y positions are in pixels when the glist they're
!     in is toplevel.  If it's not, we convert to pixels on the parent
!     window. */
  int text_xpix(t_text *x, t_glist *glist)
  {
      if (glist->gl_havewindow || !glist->gl_isgraph)
          return (x->te_xpix);
      else return (glist_xtopixels(glist, 
              glist->gl_x1 + (glist->gl_x2 - glist->gl_x1) * 
--- 603,616 ----
      /* get the window location in pixels of a "text" object.  The
      object's x and y positions are in pixels when the glist they're
!     in is toplevel.  Otherwise, if it's a new-style graph-on-parent
!     (so gl_goprect is set) we use the offset into the framing subrectangle
!     as an offset into the parent rectangle.  Finally, it might be an old,
!     proportional-style GOP.  In this case we do a coordinate transformation. */
  int text_xpix(t_text *x, t_glist *glist)
  {
      if (glist->gl_havewindow || !glist->gl_isgraph)
          return (x->te_xpix);
+     else if (glist->gl_goprect)
+          return (glist->gl_obj.te_xpix + x->te_xpix - glist->gl_xmargin);
      else return (glist_xtopixels(glist, 
              glist->gl_x1 + (glist->gl_x2 - glist->gl_x1) * 
***************
*** 610,613 ****
--- 622,627 ----
      if (glist->gl_havewindow || !glist->gl_isgraph)
          return (x->te_ypix);
+     else if (glist->gl_goprect)
+          return (glist->gl_obj.te_ypix + x->te_ypix - glist->gl_ymargin);
      else return (glist_ytopixels(glist, 
              glist->gl_y1 + (glist->gl_y2 - glist->gl_y1) * 
***************
*** 640,643 ****
--- 654,663 ----
                      glist_getcanvas(x), oc,
                          t.tr_lx1, t.tr_ly1, t.tr_lx2, t.tr_ly2);
+             canvas_drawredrect(x, 0);
+             if (x->gl_goprect)
+             {
+                 post("draw it");
+                 canvas_drawredrect(x, 1);
+             }
          }
          if (x->gl_owner && glist_isvisible(x->gl_owner))
***************
*** 708,712 ****
              /* draw a rectangle around the graph */
          sys_vgui(".x%lx.c create line\
!             %d %d %d %d %d %d %d %d %d %d -fill $::pdtheme::graph -tags %s\n",
              glist_getcanvas(x->gl_owner),
              x1, y1, x1, y2, x2, y2, x2, y1, x1, y1, tag);
--- 728,732 ----
              /* draw a rectangle around the graph */
          sys_vgui(".x%lx.c create line\
!             %d %d %d %d %d %d %d %d %d %d -tags %s\n",
              glist_getcanvas(x->gl_owner),
              x1, y1, x1, y2, x2, y2, x2, y1, x1, y1, tag);
***************
*** 718,722 ****
              int ymin = (y1 < y2 ? y1 : y2);
              t_symbol *s = garray_getname((t_garray *)g);
!             sys_vgui(".x%lx.c create text %d %d -fill $::pdtheme::text -text {%s} -anchor sw\
               -font -*-courier-bold--normal--%d-* -tags %s\n",
                  (long)glist_getcanvas(x),  x1, ymin, s->s_name,
--- 738,742 ----
              int ymin = (y1 < y2 ? y1 : y2);
              t_symbol *s = garray_getname((t_garray *)g);
!             sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor sw\
               -font -*-courier-bold--normal--%d-* -tags %s\n",
                  (long)glist_getcanvas(x),  x1, ymin, s->s_name,
***************
*** 737,745 ****
              {
                  int tickpix = (i % x->gl_xtick.k_lperb ? 2 : 4);
!                 sys_vgui(".x%lx.c create line %d %d %d %d -fill $::pdtheme::graph -tags %s\n",
                      glist_getcanvas(x->gl_owner),
                      (int)glist_xtopixels(x, f), (int)upix,
                      (int)glist_xtopixels(x, f), (int)upix - tickpix, tag);
!                 sys_vgui(".x%lx.c create line %d %d %d %d -fill $::pdtheme::graph -tags %s\n",
                      glist_getcanvas(x->gl_owner),
                      (int)glist_xtopixels(x, f), (int)lpix,
--- 757,765 ----
              {
                  int tickpix = (i % x->gl_xtick.k_lperb ? 2 : 4);
!                 sys_vgui(".x%lx.c create line %d %d %d %d -tags %s\n",
                      glist_getcanvas(x->gl_owner),
                      (int)glist_xtopixels(x, f), (int)upix,
                      (int)glist_xtopixels(x, f), (int)upix - tickpix, tag);
!                 sys_vgui(".x%lx.c create line %d %d %d %d -tags %s\n",
                      glist_getcanvas(x->gl_owner),
                      (int)glist_xtopixels(x, f), (int)lpix,
***************
*** 751,759 ****
              {
                  int tickpix = (i % x->gl_xtick.k_lperb ? 2 : 4);
!                 sys_vgui(".x%lx.c create line %d %d %d %d -fill $::pdtheme::graph -tags %s\n",
                      glist_getcanvas(x->gl_owner),
                      (int)glist_xtopixels(x, f), (int)upix,
                      (int)glist_xtopixels(x, f), (int)upix - tickpix, tag);
!                 sys_vgui(".x%lx.c create line %d %d %d %d -fill $::pdtheme::graph -tags %s\n",
                      glist_getcanvas(x->gl_owner),
                      (int)glist_xtopixels(x, f), (int)lpix,
--- 771,779 ----
              {
                  int tickpix = (i % x->gl_xtick.k_lperb ? 2 : 4);
!                 sys_vgui(".x%lx.c create line %d %d %d %d -tags %s\n",
                      glist_getcanvas(x->gl_owner),
                      (int)glist_xtopixels(x, f), (int)upix,
                      (int)glist_xtopixels(x, f), (int)upix - tickpix, tag);
!                 sys_vgui(".x%lx.c create line %d %d %d %d -tags %s\n",
                      glist_getcanvas(x->gl_owner),
                      (int)glist_xtopixels(x, f), (int)lpix,
***************
*** 774,782 ****
              {
                  int tickpix = (i % x->gl_ytick.k_lperb ? 2 : 4);
!                 sys_vgui(".x%lx.c create line %d %d %d %d -fill $::pdtheme::graph -tags %s\n",
                      glist_getcanvas(x->gl_owner),
                      x1, (int)glist_ytopixels(x, f), 
                      x1 + tickpix, (int)glist_ytopixels(x, f), tag);
!                 sys_vgui(".x%lx.c create line %d %d %d %d -fill $::pdtheme::graph -tags %s\n",
                      glist_getcanvas(x->gl_owner),
                      x2, (int)glist_ytopixels(x, f), 
--- 794,802 ----
              {
                  int tickpix = (i % x->gl_ytick.k_lperb ? 2 : 4);
!                 sys_vgui(".x%lx.c create line %d %d %d %d -tags %s\n",
                      glist_getcanvas(x->gl_owner),
                      x1, (int)glist_ytopixels(x, f), 
                      x1 + tickpix, (int)glist_ytopixels(x, f), tag);
!                 sys_vgui(".x%lx.c create line %d %d %d %d -tags %s\n",
                      glist_getcanvas(x->gl_owner),
                      x2, (int)glist_ytopixels(x, f), 
***************
*** 788,796 ****
              {
                  int tickpix = (i % x->gl_ytick.k_lperb ? 2 : 4);
!                 sys_vgui(".x%lx.c create line %d %d %d %d -fill $::pdtheme::graph -tags %s\n",
                      glist_getcanvas(x->gl_owner),
                      x1, (int)glist_ytopixels(x, f), 
                      x1 + tickpix, (int)glist_ytopixels(x, f), tag);
!                 sys_vgui(".x%lx.c create line %d %d %d %d -fill $::pdtheme::graph -tags %s\n",
                      glist_getcanvas(x->gl_owner),
                      x2, (int)glist_ytopixels(x, f), 
--- 808,816 ----
              {
                  int tickpix = (i % x->gl_ytick.k_lperb ? 2 : 4);
!                 sys_vgui(".x%lx.c create line %d %d %d %d -tags %s\n",
                      glist_getcanvas(x->gl_owner),
                      x1, (int)glist_ytopixels(x, f), 
                      x1 + tickpix, (int)glist_ytopixels(x, f), tag);
!                 sys_vgui(".x%lx.c create line %d %d %d %d -tags %s\n",
                      glist_getcanvas(x->gl_owner),
                      x2, (int)glist_ytopixels(x, f), 
***************
*** 801,805 ****
          for (i = 0; i < x->gl_nxlabels; i++)
              sys_vgui(".x%lx.c create text\
!         %d %d -fill $::pdtheme::text -text {%s} -font -*-courier-bold--normal--%d-* -tags %s\n",
                  glist_getcanvas(x),
                  (int)glist_xtopixels(x, atof(x->gl_xlabel[i]->s_name)),
--- 821,825 ----
          for (i = 0; i < x->gl_nxlabels; i++)
              sys_vgui(".x%lx.c create text\
!         %d %d -text {%s} -font -*-courier-bold--normal--%d-* -tags %s\n",
                  glist_getcanvas(x),
                  (int)glist_xtopixels(x, atof(x->gl_xlabel[i]->s_name)),
***************
*** 810,814 ****
          for (i = 0; i < x->gl_nylabels; i++)
              sys_vgui(".x%lx.c create text\
!         %d %d -fill $::pdtheme::text -text {%s} -font -*-courier-bold--normal--%d-* -tags %s\n",
                  glist_getcanvas(x),
                  (int)glist_xtopixels(x, x->gl_ylabelx),
--- 830,834 ----
          for (i = 0; i < x->gl_nylabels; i++)
              sys_vgui(".x%lx.c create text\
!         %d %d -text {%s} -font -*-courier-bold--normal--%d-* -tags %s\n",
                  glist_getcanvas(x),
                  (int)glist_xtopixels(x, x->gl_ylabelx),
***************
*** 840,863 ****
      int y1 = text_ypix(&x->gl_obj, glist);
      int x2, y2;
- #if 0   /* this used to adjust graph size when it was in another graph;
-             now we just preserve the size. */
-         /* same logic here as in text_xpix(): */
-     if (glist->gl_havewindow)
-     {
-         x2 = x1 + x->gl_pixwidth;
-         y2 = y1 + x->gl_pixheight;
-     }
-     else
-     {
-         x2 = glist_xtopixels(glist, 
-             glist->gl_x1 + (glist->gl_x2 - glist->gl_x1) * 
-                 (x->gl_obj.te_xpix + x->gl_pixwidth) /
-                     (glist->gl_screenx2 - glist->gl_screenx1));
-         y2 = glist_ytopixels(glist, 
-             glist->gl_y1 + (glist->gl_y2 - glist->gl_y1) * 
-                 (x->gl_obj.te_ypix + x->gl_pixheight) /
-                     (glist->gl_screeny2 - glist->gl_screeny1));
-     }
- #endif
      x2 = x1 + x->gl_pixwidth;
      y2 = y1 + x->gl_pixheight;
--- 860,863 ----
***************
*** 892,913 ****
                  y2 = y22;
          }
!             /* lie about whether we have our own window to affect gobj_getrect
!             calls below.  (LATER add argument to gobj_getrect()?) */
!         hadwindow = x->gl_havewindow;
!         x->gl_havewindow = 0;
!         for (g = x->gl_list; g; g = g->g_next)
!             if ((!(ob = pd_checkobject(&g->g_pd))) || text_shouldvis(ob, x))
          {
!                 /* don't do this for arrays, just let them hang outsize the
!                 box. */
!             if (pd_class(&g->g_pd) == garray_class)
!                 continue;
!             gobj_getrect(g, x, &x21, &y21, &x22, &y22);
!             if (x22 > x2) 
!                 x2 = x22;
!             if (y22 > y2) 
!                 y2 = y22;
          }
-         x->gl_havewindow = hadwindow;
      }
      else text_widgetbehavior.w_getrectfn(z, glist, &x1, &y1, &x2, &y2);
--- 892,918 ----
                  y2 = y22;
          }
!         if (!x->gl_goprect)
          {
!             /* expand the rectangle to fit in text objects; this applies only
!             to the old (0.37) graph-on-parent behavior. */
!             /* lie about whether we have our own window to affect gobj_getrect
!             calls below.  */
!             hadwindow = x->gl_havewindow;
!             x->gl_havewindow = 0;
!             for (g = x->gl_list; g; g = g->g_next)
!                 if ((!(ob = pd_checkobject(&g->g_pd))) || text_shouldvis(ob, x))
!             {
!                     /* don't do this for arrays, just let them hang outside the
!                     box. */
!                 if (pd_class(&g->g_pd) == garray_class)
!                     continue;
!                 gobj_getrect(g, x, &x21, &y21, &x22, &y22);
!                 if (x22 > x2) 
!                     x2 = x22;
!                 if (y22 > y2) 
!                     y2 = y22;
!             }
!             x->gl_havewindow = hadwindow;
          }
      }
      else text_widgetbehavior.w_getrectfn(z, glist, &x1, &y1, &x2, &y2);
***************
*** 942,949 ****
          if (canvas_showtext(x))
              rtext_select(y, state);
!         sys_vgui(".x%lx.c itemconfigure %sR -fill %s\n", glist,
! 	rtext_gettag(y), (state? "$::pdtheme::selected" : "$::pdtheme::graph"));
          sys_vgui(".x%lx.c itemconfigure graph%lx -fill %s\n",
! 	    glist_getcanvas(glist), z, (state? "$::pdtheme::selected" : "$::pdtheme::graph"));
      }
  }
--- 947,954 ----
          if (canvas_showtext(x))
              rtext_select(y, state);
!         sys_vgui(".x%lx.c itemconfigure %sR -fill %s\n", glist, 
!         rtext_gettag(y), (state? "blue" : "black"));
          sys_vgui(".x%lx.c itemconfigure graph%lx -fill %s\n",
!             glist_getcanvas(glist), z, (state? "blue" : "black"));
      }
  }
***************
*** 1057,1062 ****
  }
  
- void garray_properties(t_garray *x);
- 
  t_widgetbehavior graph_widgetbehavior =
  {
--- 1062,1065 ----
***************
*** 1070,1090 ****
  };
  
- void graph_properties(t_gobj *z, t_glist *owner)
- {
-     t_glist *x = (t_glist *)z;
-     {
-         t_gobj *y;
-         char graphbuf[200];
-         sprintf(graphbuf, "pdtk_graph_dialog %%s %g %g %g %g %d %d\n",
-             x->gl_x1, x->gl_y1, x->gl_x2, x->gl_y2,
-                 x->gl_pixwidth, x->gl_pixheight);
-         gfxstub_new(&x->gl_pd, x, graphbuf);
- 
-         for (y = x->gl_list; y; y = y->g_next)
-             if (pd_class(&y->g_pd) == garray_class) 
-                 garray_properties((t_garray *)y);
-     }
- }
- 
      /* find the graph most recently added to this glist;
          if none exists, return 0. */
--- 1073,1076 ----
***************
*** 1099,1125 ****
  }
  
-     /* message back from dialog GUI to set parameters.  Args are:
-         1-4: bounds in our coordinates; 5-6: size in parent */
- static void graph_dialog(t_glist *x, t_symbol *s, int argc, t_atom *argv)
- {
-     t_float x1 = atom_getfloatarg(0, argc, argv);
-     t_float y1 = atom_getfloatarg(1, argc, argv);
-     t_float x2 = atom_getfloatarg(2, argc, argv);
-     t_float y2 = atom_getfloatarg(3, argc, argv);
-     t_float xpix = atom_getfloatarg(4, argc, argv);
-     t_float ypix = atom_getfloatarg(5, argc, argv);
-     if (x1 != x->gl_x1 || x2 != x->gl_x2 ||
-         y1 != x->gl_y1 || y2 != x->gl_y2)
-             graph_bounds(x, x1, y1, x2, y2);
-     if (xpix != x->gl_pixwidth || ypix != x->gl_pixheight)
-     {
-         x->gl_pixwidth = xpix;
-         x->gl_pixheight = ypix;
-         glist_redraw(x);
-         if (x->gl_owner)
-             canvas_fixlinesfor(x->gl_owner, &x->gl_obj);
-     }
- }
- 
  extern void canvas_menuarray(t_glist *canvas);
  
--- 1085,1088 ----
***************
*** 1141,1146 ****
      class_addmethod(canvas_class, (t_method)canvas_menuarray,
          gensym("menuarray"), A_NULL);
-     class_addmethod(canvas_class, (t_method)graph_dialog, gensym("dialog"),
-         A_GIMME, 0);
      class_addmethod(canvas_class, (t_method)glist_arraydialog,
          gensym("arraydialog"), A_SYMBOL, A_FLOAT, A_FLOAT, A_FLOAT, A_NULL);
--- 1104,1107 ----

Index: g_readwrite.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/g_readwrite.c,v
retrieving revision 1.3.8.1
retrieving revision 1.3.8.2
diff -C2 -d -r1.3.8.1 -r1.3.8.2
*** g_readwrite.c	22 May 2005 12:46:50 -0000	1.3.8.1
--- g_readwrite.c	12 Jul 2005 15:11:09 -0000	1.3.8.2
***************
*** 598,606 ****
      if (x->gl_isgraph || x->gl_x1 || x->gl_y1 ||
          x->gl_x2 != 1 ||  x->gl_y2 != 1 || x->gl_pixwidth || x->gl_pixheight)
!             binbuf_addv(b, "ssfffffff;", gensym("#X"), gensym("coords"),
                  x->gl_x1, x->gl_y1,
                  x->gl_x2, x->gl_y2,
                  (float)x->gl_pixwidth, (float)x->gl_pixheight,
                  (float)x->gl_isgraph);
  }
  
--- 598,618 ----
      if (x->gl_isgraph || x->gl_x1 || x->gl_y1 ||
          x->gl_x2 != 1 ||  x->gl_y2 != 1 || x->gl_pixwidth || x->gl_pixheight)
!     {
!         if (x->gl_isgraph && x->gl_goprect)
!                 /* if we have a graph-on-parent rectangle, we're new style.
!                 The format is arranged so
!                 that old versions of Pd can at least do something with it. */
!             binbuf_addv(b, "ssfffffffff;", gensym("#X"), gensym("coords"),
!                 x->gl_x1, x->gl_y1,
!                 x->gl_x2, x->gl_y2,
!                 (float)x->gl_pixwidth, (float)x->gl_pixheight,
!                 1., (float)x->gl_xmargin, (float)x->gl_ymargin); 
!                     /* otherwise write in 0.38-compatible form */
!         else binbuf_addv(b, "ssfffffff;", gensym("#X"), gensym("coords"),
                  x->gl_x1, x->gl_y1,
                  x->gl_x2, x->gl_y2,
                  (float)x->gl_pixwidth, (float)x->gl_pixheight,
                  (float)x->gl_isgraph);
+     }
  }
  

Index: g_rtext.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/g_rtext.c,v
retrieving revision 1.4.8.1
retrieving revision 1.4.8.2
diff -C2 -d -r1.4.8.1 -r1.4.8.2
*** g_rtext.c	19 Jun 2005 03:18:59 -0000	1.4.8.1
--- g_rtext.c	12 Jul 2005 15:11:09 -0000	1.4.8.2
***************
*** 154,162 ****
      char smallbuf[200], *tempbuf;
      int outchars = 0, nlines = 0, ncolumns = 0,
!         pixwide, pixhigh;
!     int font = glist_getfont(x->x_glist);
!     int fontwidth = sys_fontwidth(font), fontheight = sys_fontheight(font);
!     int findx = (*widthp + (fontwidth/2)) / fontwidth,
!         findy = *heightp / fontheight;
      int reportedindex = 0;
      t_canvas *canvas = glist_getcanvas(x->x_glist);
--- 154,158 ----
      char smallbuf[200], *tempbuf;
      int outchars = 0, nlines = 0, ncolumns = 0,
!         pixwide, pixhigh, font, fontwidth, fontheight, findx, findy;
      int reportedindex = 0;
      t_canvas *canvas = glist_getcanvas(x->x_glist);
***************
*** 165,168 ****
--- 161,175 ----
      int inindex = 0;
      int selstart = 0, selend = 0;
+         /* if we're a GOP (the new, "goprect" style) borrow the font size
+         from the inside to preserve the spacing */
+     if (pd_class(&x->x_text->te_pd) == canvas_class &&
+         ((t_glist *)(x->x_text))->gl_isgraph &&
+         ((t_glist *)(x->x_text))->gl_goprect)
+             font =  glist_getfont((t_glist *)(x->x_text));
+     else font = glist_getfont(x->x_glist);
+     fontwidth = sys_fontwidth(font);
+     fontheight = sys_fontheight(font);
+     findx = (*widthp + (fontwidth/2)) / fontwidth;
+     findy = *heightp / fontheight;
      if (x->x_bufsize >= 100)
           tempbuf = (char *)t_getbytes(2 * x->x_bufsize + 1);
***************
*** 236,240 ****
              outchars, tempbuf, sys_hostfontsize(font),
              (glist_isselected(x->x_glist,
! 		&x->x_glist->gl_gobj)? "$::pdtheme::selected" : "$::pdtheme::text"));
      else if (action == SEND_UPDATE)
      {
--- 243,247 ----
              outchars, tempbuf, sys_hostfontsize(font),
              (glist_isselected(x->x_glist,
!                 &x->x_glist->gl_gobj)? "blue" : "black"));
      else if (action == SEND_UPDATE)
      {
***************
*** 372,376 ****
      t_canvas *canvas = glist_getcanvas(glist);
      sys_vgui(".x%lx.c itemconfigure %s -fill %s\n", canvas, 
! 	x->x_tag, (state? "$::pdtheme::selected" : "$::pdtheme::text"));
      canvas_editing = canvas;
  }
--- 379,383 ----
      t_canvas *canvas = glist_getcanvas(glist);
      sys_vgui(".x%lx.c itemconfigure %s -fill %s\n", canvas, 
!         x->x_tag, (state? "blue" : "black"));
      canvas_editing = canvas;
  }

Index: d_osc.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/d_osc.c,v
retrieving revision 1.2.4.1
retrieving revision 1.2.4.1.2.1
diff -C2 -d -r1.2.4.1 -r1.2.4.1.2.1
*** d_osc.c	5 Nov 2004 13:55:58 -0000	1.2.4.1
--- d_osc.c	12 Jul 2005 15:11:06 -0000	1.2.4.1.2.1
***************
*** 57,66 ****
  
  #else
! #ifdef MACOSX
  #define HIOFFSET 0    /* word offset to find MSB */
  #define LOWOFFSET 1    /* word offset to find LSB */
  #define int32 int  /* a data type that has 32 bits */
  
! #endif /* MACOSX */
  #endif /* __linux__ */
  #endif /* MSW */
--- 57,66 ----
  
  #else
! #ifdef __APPLE__
  #define HIOFFSET 0    /* word offset to find MSB */
  #define LOWOFFSET 1    /* word offset to find LSB */
  #define int32 int  /* a data type that has 32 bits */
  
! #endif /* __APPLE__ */
  #endif /* __linux__ */
  #endif /* MSW */

Index: d_soundfile.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/d_soundfile.c,v
retrieving revision 1.4.4.11
retrieving revision 1.4.4.11.2.1
diff -C2 -d -r1.4.4.11 -r1.4.4.11.2.1
*** d_soundfile.c	8 Mar 2005 23:41:39 -0000	1.4.4.11
--- d_soundfile.c	12 Jul 2005 15:11:06 -0000	1.4.4.11.2.1
***************
*** 1434,1458 ****
  	pthread_cond_t * conditional = (pthread_cond_t*) w[3];
  
- #ifdef GARRAY_THREAD_LOCK
- 
- #ifdef SFDEBUG
- 	post("lock array %p", garray);
- #endif
- 
- 	garray_lock(garray);
- #endif
  	garray->x_array.a_vec = (char *) nvec;
  	garray->x_array.a_n = finalsize;
  	if (garray->x_usedindsp) canvas_update_dsp();
  
- #ifdef GARRAY_THREAD_LOCK
- 
- #ifdef SFDEBUG
- 	post("unlock array %p", garray);
- #endif
- 
- 	garray_unlock(garray);
- #endif
- 
  	/* signal helper thread */
  	pthread_cond_broadcast(conditional);
--- 1434,1441 ----
***************
*** 1711,1722 ****
      /* TB: we'll have to be sure that no one is accessing the array */
      sys_lock();
! #ifdef GARRAY_THREAD_LOCK 
!     garray_lock(x); 
! #endif
      x->x_array.a_vec = nvec;
      x->x_array.a_n = n;
! #ifdef GARRAY_THREAD_LOCK 
!     garray_unlock(x); 
! #endif
      if (x->x_usedindsp) canvas_update_dsp();
      sys_unlock();
--- 1694,1701 ----
      /* TB: we'll have to be sure that no one is accessing the array */
      sys_lock();
! 
      x->x_array.a_vec = nvec;
      x->x_array.a_n = n;
! 
      if (x->x_usedindsp) canvas_update_dsp();
      sys_unlock();
***************
*** 1821,1831 ****
      /* TB: we'll have to be sure that no one is accessing the array */
      sys_lock();
- #ifdef GARRAY_THREAD_LOCK 
-     garray_lock(x); 
- #endif
      x->x_array.a_vec = nvec;
! #ifdef GARRAY_THREAD_LOCK 
!     garray_unlock(x); 
! #endif
      if (x->x_usedindsp) canvas_update_dsp();
      sys_unlock();
--- 1800,1805 ----
      /* TB: we'll have to be sure that no one is accessing the array */
      sys_lock();
      x->x_array.a_vec = nvec;
! 	
      if (x->x_usedindsp) canvas_update_dsp();
      sys_unlock();
***************
*** 3162,3165 ****
--- 3136,3145 ----
              sfread_cond_signal(&x->x_requestcondition);
              sfread_cond_wait(&x->x_answercondition, &x->x_mutex);
+ 			/* resync local cariables -- bug fix thanks to Shahrokh */
+ 			vecsize = x->x_vecsize;
+ 			bytespersample = x->x_bytespersample;
+ 			sfchannels = x->x_sfchannels;
+ 			wantbytes = sfchannels * vecsize * bytespersample;
+ 			bigendian = x->x_bigendian;
  #ifdef DEBUG_SOUNDFILE
              pute("done\n");

Index: g_editor.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/g_editor.c,v
retrieving revision 1.4.4.2.2.2
retrieving revision 1.4.4.2.2.3
diff -C2 -d -r1.4.4.2.2.2 -r1.4.4.2.2.3
*** g_editor.c	19 Jun 2005 03:18:59 -0000	1.4.4.2.2.2
--- g_editor.c	12 Jul 2005 15:11:07 -0000	1.4.4.2.2.3
***************
*** 66,70 ****
--- 66,88 ----
  {
      if (x->g_pd->c_wb && x->g_pd->c_wb->w_visfn)
+     {
+         if (!glist->gl_havewindow && glist->gl_isgraph && glist->gl_goprect &&
+             glist->gl_owner && (pd_class(&glist->gl_pd) != garray_class))
+         {
+             /* if we're graphing-on-parent and the object falls outside the
+             graph rectangle, don't draw it. */
+             int x1, y1, x2, y2, gx1, gy1, gx2, gy2, m;
+             gobj_getrect(&glist->gl_gobj, glist->gl_owner, &x1, &y1, &x2, &y2);
+             if (x1 > x2)
+                 m = x1, x1 = x2, x2 = m;
+             if (y1 > y2)
+                 m = y1, y1 = y2, x2 = m;
+             gobj_getrect(x, glist, &gx1, &gy1, &gx2, &gy2);
+             if (gx1 < x1 || gx1 > x2 || gx2 < x1 || gx2 > x2 ||
+                 gy1 < y1 || gy1 > y2 || gy2 < y1 || gy2 > y2)
+                     return;
+         }
          (*x->g_pd->c_wb->w_visfn)(x, glist, flag);
+     }
  }
  
***************
*** 97,101 ****
          x->gl_editor->e_selectline_inno = inno;
          x->gl_editor->e_selectline_tag = oc;
! 	sys_vgui(".x%lx.c itemconfigure l%lx -fill $::pdtheme::selected \n",
              x, x->gl_editor->e_selectline_tag);
      }    
--- 115,119 ----
          x->gl_editor->e_selectline_inno = inno;
          x->gl_editor->e_selectline_tag = oc;
!         sys_vgui(".x%lx.c itemconfigure l%lx -fill blue\n",
              x, x->gl_editor->e_selectline_tag);
      }    
***************
*** 107,111 ****
      {
          x->gl_editor->e_selectedline = 0;
! 	sys_vgui(".x%lx.c itemconfigure l%lx -fill $::pdtheme::line\n",
              x, x->gl_editor->e_selectline_tag);
      }    
--- 125,129 ----
      {
          x->gl_editor->e_selectedline = 0;
!         sys_vgui(".x%lx.c itemconfigure l%lx -fill black\n",
              x, x->gl_editor->e_selectline_tag);
      }    
***************
*** 810,827 ****
  }
  
!     /* tell GUI to create a properties dialog on the canvas.  We tell
!     the user the negative of the "pixel" y scale to make it appear to grow
!     naturally upward, whereas pixels grow downward. */
! static void canvas_properties(t_glist *x)
! {
!     char graphbuf[200];
!     sprintf(graphbuf, "pdtk_canvas_dialog %%s %g %g %g %g \n",
!         glist_dpixtodx(x, 1), -glist_dpixtody(x, 1),
!         (float)glist_isgraph(x), (float)x->gl_stretch);
!     gfxstub_new(&x->gl_pd, x, graphbuf);
! }
! 
! 
! void canvas_setgraph(t_glist *x, int flag)
  {
      if (!flag && glist_isgraph(x))
--- 828,834 ----
  }
  
!     /* set a canvas up as a graph-on-parent.  Set reasonable defaults for
!     any missing paramters and redraw things if necessary. */
! void canvas_setgraph(t_glist *x, int flag, int nogoprect)
  {
      if (!flag && glist_isgraph(x))
***************
*** 847,852 ****
              gobj_vis(&x->gl_gobj, x->gl_owner, 0);
          x->gl_isgraph = 1;
!         /* if (x->gl_owner && glist_isvisible(x->gl_owner))
!             canvas_vis(x, 1); */
          if (x->gl_loading && x->gl_owner && glist_isvisible(x->gl_owner))
              canvas_create_editor(x, 1);
--- 854,869 ----
              gobj_vis(&x->gl_gobj, x->gl_owner, 0);
          x->gl_isgraph = 1;
!         if (!nogoprect && !x->gl_goprect)
!         {
!             t_gobj *g;
!             for (g = x->gl_list; g; g = g->g_next)
!                 if (pd_checkobject(&g->g_pd))
!             {
!                 x->gl_goprect = 1;
!                 break;
!             }
!         }
!         if (glist_isvisible(x) && x->gl_goprect)
!             glist_redraw(x);
          if (x->gl_loading && x->gl_owner && glist_isvisible(x->gl_owner))
              canvas_create_editor(x, 1);
***************
*** 859,868 ****
  }
  
      /* called from the gui when "OK" is selected on the canvas properties
          dialog.  Again we negate "y" scale. */
! static void canvas_donecanvasdialog(t_glist *x,  t_floatarg xperpix,
!     t_floatarg yperpix, t_floatarg fgraphme)
  {
!     int graphme = (fgraphme != 0), redraw = 0;
      yperpix = -yperpix;
      if (xperpix == 0)
--- 876,937 ----
  }
  
+ void garray_properties(t_garray *x);
+ 
+     /* tell GUI to create a properties dialog on the canvas.  We tell
+     the user the negative of the "pixel" y scale to make it appear to grow
+     naturally upward, whereas pixels grow downward. */
+ void canvas_properties(t_glist *x)
+ {
+     t_gobj *y;
+     char graphbuf[200];
+     if (glist_isgraph(x) != 0)
+         sprintf(graphbuf,
+             "pdtk_canvas_dialog %%s %g %g %d %g %g %g %g %d %d %d %d\n",
+                 0., 0.,
+                 1,
+                 x->gl_x1, x->gl_y1, x->gl_x2, x->gl_y2, 
+                 (int)x->gl_pixwidth, (int)x->gl_pixheight,
+                 (int)x->gl_xmargin, (int)x->gl_ymargin);
+     else sprintf(graphbuf,
+             "pdtk_canvas_dialog %%s %g %g %d %g %g %g %g %d %d %d %d\n",
+                 glist_dpixtodx(x, 1), -glist_dpixtody(x, 1),
+                 0,
+                 0., -1., 1., 1., 
+                 (int)x->gl_pixwidth, (int)x->gl_pixheight,
+                 (int)x->gl_xmargin, (int)x->gl_ymargin);
+     gfxstub_new(&x->gl_pd, x, graphbuf);
+         /* if any arrays are in the graph, put out their dialogs too */
+     for (y = x->gl_list; y; y = y->g_next)
+         if (pd_class(&y->g_pd) == garray_class) 
+             garray_properties((t_garray *)y);
+ }
+ 
      /* called from the gui when "OK" is selected on the canvas properties
          dialog.  Again we negate "y" scale. */
! static void canvas_donecanvasdialog(t_glist *x,
!     t_symbol *s, int argc, t_atom *argv)
  {
! 
! 
!     float xperpix, yperpix, x1, y1, x2, y2, xpix, ypix, xmargin, ymargin; 
!     int graphme, redraw = 0;
! 
!     xperpix = atom_getfloatarg(0, argc, argv);
!     yperpix = atom_getfloatarg(1, argc, argv);
!     graphme = (atom_getfloatarg(2, argc, argv) != 0);
!     x1 = atom_getfloatarg(3, argc, argv);
!     y1 = atom_getfloatarg(4, argc, argv);
!     x2 = atom_getfloatarg(5, argc, argv);
!     y2 = atom_getfloatarg(6, argc, argv);
!     xpix = atom_getfloatarg(7, argc, argv);
!     ypix = atom_getfloatarg(8, argc, argv);
!     xmargin = atom_getfloatarg(9, argc, argv);
!     ymargin = atom_getfloatarg(10, argc, argv);
!     
!     x->gl_pixwidth = xpix;
!     x->gl_pixheight = ypix;
!     x->gl_xmargin = xmargin;
!     x->gl_ymargin = ymargin;
! 
      yperpix = -yperpix;
      if (xperpix == 0)
***************
*** 870,876 ****
      if (yperpix == 0)
          yperpix = 1;
!     canvas_setgraph(x, graphme);
!     if (!x->gl_isgraph && (xperpix != glist_dpixtodx(x, 1)))
      {
          if (xperpix > 0)
          {
--- 939,956 ----
      if (yperpix == 0)
          yperpix = 1;
! 
!     if (graphme)
!     {
!         if (x1 != x2)
!             x->gl_x1 = x1, x->gl_x2 = x2;
!         else x->gl_x1 = 0, x->gl_x2 = 1;
!         if (y1 != y2)
!             x->gl_y1 = y1, x->gl_y2 = y2;
!         else x->gl_y1 = 0, x->gl_y2 = 1;
!     }
!     else
      {
+         if (xperpix != glist_dpixtodx(x, 1) || yperpix != glist_dpixtody(x, 1))
+             redraw = 1;
          if (xperpix > 0)
          {
***************
*** 883,890 ****
              x->gl_x2 = x->gl_x1 + xperpix;
          }
-         redraw = 1;
-     }   
-     if (!x->gl_isgraph && (yperpix != glist_dpixtody(x, 1)))
-     {
          if (yperpix > 0)
          {
--- 963,966 ----
***************
*** 897,904 ****
              x->gl_y2 = x->gl_y1 + yperpix;
          }
-         redraw = 1;
      }
!     if (redraw)
          canvas_redraw(x);
  }
  
--- 973,982 ----
              x->gl_y2 = x->gl_y1 + yperpix;
          }
      }
!         /* LATER avoid doing 2 redraws here (possibly one inside setgraph) */
!     canvas_setgraph(x, graphme, 0);
!     if (x->gl_havewindow)
          canvas_redraw(x);
+     else gobj_redraw(&x->gl_gobj, x->gl_owner);
  }
  
***************
*** 1098,1102 ****
                          x->gl_editor->e_ywas = ypos;
                          sys_vgui(
!                           ".x%lx.c create line %d %d %d %d -fill $::pdtheme::line -arrow $::pdtheme::arrow -width %d -tags x\n",
                                  x, xpos, ypos, xpos, ypos,
                                      (issignal ? 2 : 1));
--- 1176,1180 ----
                          x->gl_editor->e_ywas = ypos;
                          sys_vgui(
!                           ".x%lx.c create line %d %d %d %d -width %d -tags x\n",
                                  x, xpos, ypos, xpos, ypos,
                                      (issignal ? 2 : 1));
***************
*** 1197,1201 ****
      {
          if (!shiftmod) glist_noselect(x);
! 	sys_vgui(".x%lx.c create rectangle %d %d %d %d -outline $::pdtheme::lasso -tags x\n",
                x, xpos, ypos, xpos, ypos);
          x->gl_editor->e_xwas = xpos;
--- 1275,1279 ----
      {
          if (!shiftmod) glist_noselect(x);
!         sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags x\n",
                x, xpos, ypos, xpos, ypos);
          x->gl_editor->e_xwas = xpos;
***************
*** 1297,1301 ****
                              + IOMIDDLE;
                  ly2 = y21;
!                 sys_vgui(".x%lx.c create line %d %d %d %d -fill $::pdtheme::line -arrow $::pdtheme::arrow -width %d -tags l%lx\n",
                      glist_getcanvas(x),
                          lx1, ly1, lx2, ly2,
--- 1375,1379 ----
                              + IOMIDDLE;
                  ly2 = y21;
!                 sys_vgui(".x%lx.c create line %d %d %d %d -width %d -tags l%lx\n",
                      glist_getcanvas(x),
                          lx1, ly1, lx2, ly2,
***************
*** 2090,2094 ****
      if (glist_isvisible(x))
      {
!         sys_vgui(".x%lx.c create line %d %d %d %d -fill $::pdtheme::line -arrow $::pdtheme::arrow -width %d -tags l%lx\n",
              glist_getcanvas(x), 0, 0, 0, 0,
              (obj_issignaloutlet(objsrc, outno) ? 2 : 1),oc);
--- 2168,2172 ----
      if (glist_isvisible(x))
      {
!         sys_vgui(".x%lx.c create line %d %d %d %d -width %d -tags l%lx\n",
              glist_getcanvas(x), 0, 0, 0, 0,
              (obj_issignaloutlet(objsrc, outno) ? 2 : 1),oc);
***************
*** 2362,2366 ****
          gensym("done-popup"), A_FLOAT, A_FLOAT, A_FLOAT, A_NULL);
      class_addmethod(canvas_class, (t_method)canvas_donecanvasdialog,
!         gensym("donecanvasdialog"), A_FLOAT, A_FLOAT, A_FLOAT, A_NULL);
      class_addmethod(canvas_class, (t_method)glist_arraydialog,
          gensym("arraydialog"), A_SYMBOL, A_FLOAT, A_FLOAT, A_FLOAT, A_NULL);
--- 2440,2444 ----
          gensym("done-popup"), A_FLOAT, A_FLOAT, A_FLOAT, A_NULL);
      class_addmethod(canvas_class, (t_method)canvas_donecanvasdialog,
!         gensym("donecanvasdialog"), A_GIMME, A_NULL);
      class_addmethod(canvas_class, (t_method)glist_arraydialog,
          gensym("arraydialog"), A_SYMBOL, A_FLOAT, A_FLOAT, A_FLOAT, A_NULL);

Index: m_atomic.h
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/m_atomic.h,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.1.2.1
diff -C2 -d -r1.1.2.1 -r1.1.2.1.2.1
*** m_atomic.h	2 Jan 2005 19:56:02 -0000	1.1.2.1
--- m_atomic.h	12 Jul 2005 15:11:10 -0000	1.1.2.1.2.1
***************
*** 29,33 ****
  
  /* ppc */
! #define ATOMIC_INC(X)							\
  int X##_i;										\
  asm __volatile__(								\
--- 29,33 ----
  
  /* ppc */
! #define ATOMIC_INC(X) {							\
  int X##_i;										\
  asm __volatile__(								\
***************
*** 35,46 ****
  				 "lwarx %0, 0, %2   \n"			\
  				 "addic %0, %0, 1   \n"			\
! 				 "stwcx %0, 0, %2   \n"			\
  				 "bne-  1b          \n"			\
  				 :"=&r"(X##_i), "=m"(X)			\
  				 : "r" (&X), "m"(X)				\
! 				 : "cc");
      
  
! #define ATOMIC_DEC(X)							\
  int X##_i;										\
  asm __volatile__(								\
--- 35,46 ----
  				 "lwarx %0, 0, %2   \n"			\
  				 "addic %0, %0, 1   \n"			\
! 				 "stwcx. %0, 0, %2   \n"			\
  				 "bne-  1b          \n"			\
  				 :"=&r"(X##_i), "=m"(X)			\
  				 : "r" (&X), "m"(X)				\
! 				 : "cc"); }
      
  
! #define ATOMIC_DEC(X) {							\
  int X##_i;										\
  asm __volatile__(								\
***************
*** 48,55 ****
  				 "lwarx %0, 0, %2   \n"			\
  				 "addic %0, %0, -1  \n"			\
! 				 "stwcx %0, 0, %2   \n"			\
  				 "bne-  1b          \n"			\
! 				 :"=&r"(i), "=m"(X)				\
! 				 : "r" (X##_&X), "m"(X)			\
! 				 : "cc");
  #endif
--- 48,55 ----
  				 "lwarx %0, 0, %2   \n"			\
  				 "addic %0, %0, -1  \n"			\
! 				 "stwcx. %0, 0, %2   \n"			\
  				 "bne-  1b          \n"			\
! 				 :"=&r"(X##_i), "=m"(X)				\
! 				 : "r" (&X), "m"(X)			\
! 				 : "cc"); }
  #endif

Index: m_simd_sse_gcc.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/m_simd_sse_gcc.c,v
retrieving revision 1.1.4.13
retrieving revision 1.1.4.13.2.1
diff -C2 -d -r1.1.4.13 -r1.1.4.13.2.1
*** m_simd_sse_gcc.c	6 May 2005 09:40:07 -0000	1.1.4.13
--- m_simd_sse_gcc.c	12 Jul 2005 15:11:10 -0000	1.1.4.13.2.1
***************
*** 950,955 ****
  int simd_runtime_check()
  {
!     unsigned int eax, edx;
!     __asm__("cpuid" : "=a"(eax),"=d"(edx) : "a" (1): "bx", "cx");
      return (0x2000000 & edx);
  }
--- 950,958 ----
  int simd_runtime_check()
  {
!     unsigned int eax, ebx, ecx, edx;
!     __asm__("push %%ebx \n" /* ebx might be used as PIC register :-( */
!             "cpuid      \n"
!             "pop  %%ebx \n"
! 		: "=a"(eax),"=d"(edx) : "a" (1): "cx");
      return (0x2000000 & edx);
  }

Index: u_pdsend.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/u_pdsend.c,v
retrieving revision 1.2
retrieving revision 1.2.8.1
diff -C2 -d -r1.2 -r1.2.8.1
*** u_pdsend.c	6 Sep 2004 20:20:36 -0000	1.2
--- u_pdsend.c	12 Jul 2005 15:11:13 -0000	1.2.8.1
***************
*** 106,110 ****
      while (1)
      {
!         char buf[BUFSIZE], *bp, nsent, nsend;
          if (!fgets(buf, BUFSIZE, stdin))
              break;
--- 106,111 ----
      while (1)
      {
!         char buf[BUFSIZE], *bp;
! 	unsigned int  nsent, nsend;
          if (!fgets(buf, BUFSIZE, stdin))
              break;

Index: g_numbox.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/g_numbox.c,v
retrieving revision 1.4
retrieving revision 1.4.8.1
diff -C2 -d -r1.4 -r1.4.8.1
*** g_numbox.c	6 Sep 2004 20:20:34 -0000	1.4
--- g_numbox.c	12 Jul 2005 15:11:08 -0000	1.4.8.1
***************
*** 37,44 ****
  static void my_numbox_tick_reset(t_my_numbox *x)
  {
!     if(x->x_gui.x_fsf.x_change)
      {
          x->x_gui.x_fsf.x_change = 0;
-         glist_grab(x->x_gui.x_glist, 0, 0, 0, 0, 0);
          (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
      }
--- 37,43 ----
  static void my_numbox_tick_reset(t_my_numbox *x)
  {
!   if(x->x_gui.x_fsf.x_change && x->x_gui.x_glist)
      {
          x->x_gui.x_fsf.x_change = 0;
          (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
      }
***************
*** 384,390 ****
          x->x_gui.x_fsf.x_change = 0;
          clock_unset(x->x_clock_reset);
-         glist_grab(x->x_gui.x_glist, 0, 0, 0, 0, 0);
          (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
- 
      }
      binbuf_addv(b, "ssiisiiffiisssiiiiiiifi", gensym("#X"),gensym("obj"),
--- 383,387 ----
***************
*** 450,454 ****
          x->x_gui.x_fsf.x_change = 0;
          clock_unset(x->x_clock_reset);
-         glist_grab(x->x_gui.x_glist, 0, 0, 0, 0, 0);
          (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
  
--- 447,450 ----
***************
*** 557,562 ****
              x->x_gui.x_fsf.x_change = 1;
              clock_delay(x->x_clock_reset, 3000);
-             /* glist_grab(x->x_gui.x_glist, &x->x_gui.x_obj.ob_g,
-                 0, my_numbox_key, 0, 0); */
  
              x->x_buf[0] = 0;
--- 553,556 ----
***************
*** 566,570 ****
              x->x_gui.x_fsf.x_change = 0;
              clock_unset(x->x_clock_reset);
-             glist_grab(x->x_gui.x_glist, 0, 0, 0, 0, 0);
              x->x_buf[0] = 0;
              (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
--- 560,563 ----

Index: s_audio_pa.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/s_audio_pa.c,v
retrieving revision 1.4.4.7
retrieving revision 1.4.4.7.2.1
diff -C2 -d -r1.4.4.7 -r1.4.4.7.2.1
*** s_audio_pa.c	16 May 2005 12:57:08 -0000	1.4.4.7
--- s_audio_pa.c	12 Jul 2005 15:11:11 -0000	1.4.4.7.2.1
***************
*** 63,68 ****
  		pa_callback = NULL;
  
! 	sys_keepsched = 0;
! 	sys_callbackscheduler = schedmode;
  
  	/* Initialize PortAudio  */
--- 63,67 ----
  		pa_callback = NULL;
  
! 	sys_setscheduler(schedmode);
  
  	/* Initialize PortAudio  */





More information about the Pd-cvs mailing list