From 4155426928eab2265d78f4860c35e09057dde840 Mon Sep 17 00:00:00 2001
From: "N.N." <krzyszcz@users.sourceforge.net>
Date: Mon, 13 Jun 2005 20:41:52 +0000
Subject: toxy alpha19 and pddp alpha3 (see notes.txt for toxy and pddp)

svn path=/trunk/externals/miXed/; revision=3170
---
 bin/pddp/pddpserver.tcl | 27 ++++++++++++++++++++++-----
 bin/pddp/pkgIndex.tcl   |  2 +-
 2 files changed, 23 insertions(+), 6 deletions(-)

(limited to 'bin')

diff --git a/bin/pddp/pddpserver.tcl b/bin/pddp/pddpserver.tcl
index 4b96be2..eb01207 100644
--- a/bin/pddp/pddpserver.tcl
+++ b/bin/pddp/pddpserver.tcl
@@ -303,15 +303,32 @@ proc ::pddp::srvTimeout {sock} {
     srvError $sock 408
 }
 
-# FIXME test if "path" has its patch window already open...
-proc ::pddp::srvPdHandler {sock path} {
+proc ::pddp::srvPdOpen {path} {
+    global menu_windowlist
+    set name [file tail $path]
     set dir [file dirname $path]
-    set tail [file tail $path]
-    if {[catch {pd [concat pd open $tail $dir \;]}]} {
+    # FIXME white space in $name and $dir
+    # FIXME this is a fragile hack, there should be an "openx" message to pd...
+    foreach en $menu_windowlist {
+	set wd [lindex $en 1]
+	set nm [lindex $en 0]
+	set dr [lindex [wm title $wd] end]
+	if {[string equal $name $nm] && [string equal $dir $dr]} {
+	    # FIXME test on windows
+	    raise $wd
+	    focus -force $wd
+	    return
+	}
+    }
+    pd [concat pd open $name $dir \;]
+    # FIXME raise and focus on windows?
+}
+
+proc ::pddp::srvPdHandler {sock path} {
+    if {[catch {::pddp::srvPdOpen $path}]} {
 	srvError $sock 504
     } else {
 	srvError $sock 204
-	# FIXME raise; focus (test on windows)
     }
 }
 
diff --git a/bin/pddp/pkgIndex.tcl b/bin/pddp/pkgIndex.tcl
index a3abe3d..10b89a6 100644
--- a/bin/pddp/pkgIndex.tcl
+++ b/bin/pddp/pkgIndex.tcl
@@ -5,6 +5,6 @@ proc LoadPddp { version dir } {
     source [file join $dir pddpboot.tcl]
 }
 
-set version "0.1.0.2"
+set version "0.1.0.3"
 
 package ifneeded pddp $version [list LoadPddp $version $dir]
-- 
cgit v1.2.1