From d4aedb67a6d99f93668745c3452b4b44a60ece3a Mon Sep 17 00:00:00 2001
From: Ivica Ico Bukvic <ico@vt.edu>
Date: Wed, 15 Feb 2012 23:26:29 -0500
Subject: [PATCH] improved parent window logic in respect to root window and
 its console

---
 src/pd.tk | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/src/pd.tk b/src/pd.tk
index 60b430826..fc467471c 100644
--- a/src/pd.tk
+++ b/src/pd.tk
@@ -1081,15 +1081,25 @@ proc menu_raisenextwindow {} {
 proc menu_raise_console {} {
 	set pd_window .
 	set top_window [lindex [wm stackorder $pd_window] end]
+	focus .
 	if {$pd_window eq $top_window} {
 		lower $pd_window
-		catch {lower .printout}
+		.controls.switches.console instate {selected} {
+			lower .printout
+		}
+		#catch {lower .printout}
 	} else {
 		wm deiconify $pd_window
 		raise $pd_window
-		catch {wm deiconify .printout}
-		catch {wm manage .prinout}
-		raise .printout
+		.controls.switches.console instate {selected} {
+			wm deiconify .printout
+			wm manage .printout
+			raise .printout
+			#focus .printout
+		}
+		#catch {wm deiconify .printout}
+		#catch {wm manage .prinout}
+		#raise .printout
 	}
 }
 
-- 
GitLab