+#----- subwindow -----
+
+variable subwindow_on_destroying
+variable subwindow_on_ready
+
+proc subwindow-need-recreate {} {
+ variable innerwindow_after
+puts "IW-EVENT"
+ if {[info exists innerwindow_after]} return
+ set innerwindow_after [after idle applet::innerwindow-resetup]
+}
+
+proc innerwindow-resetup {} {
+ variable innerwindow_after
+ variable subwindow_on_destroying
+ variable subwindow_on_ready
+ unset innerwindow_after
+
+puts RESETUP
+
+
+ if {![winfo exists .i.i]} return
+ destroy [frame .i.i.make-exist]
+
+ uplevel #0 $subwindow_on_destroying
+ catch { destroy .i.i.b.c }
+
+ catch { destroy .i.i.b }
+
+ frame .i.i.b
+ pack .i.i.b -fill both -side left -expand 1
+#
+ global inner_lastw inner_lasth
+ #set w [winfo width .i.i]
+# set w [winfo width .i.i]
+# set h [winfo height .i.i]
+
+# if {$w != $inner_lastw || $h != $inner_lasth} {
+# set inner_lastw $w
+# set inner_lasth $h
+# innerwindow-ph-dummy configure -width $w -height 2
+
+ uplevel #0 $subwindow_on_ready
+# }
+}
+
+proc setup-subwindow {w on_destroying on_ready} {
+ foreach v {destroying ready} {
+ variable subwindow_on_$v [set on_$v]
+ }
+
+ global inner_lastw inner_lasth
+ set inner_lastw -2
+ set inner_lasth -2
+
+ image create photo applet::innerwindow-ph-dummy -width $w -height 2
+ .i configure -image applet::innerwindow-ph-dummy
+
+ destroy [frame .i.make-exist]
+ destroy [frame .i.i.make-exist]
+ bind .i <<IconConfigure>> {
+ applet::subwindow-need-recreate
+ }
+}
+
+#----- subprocess -----
+
+variable subproc none
+variable ratelimit {}
+
+proc setup-subproc {w get_cmdline} {
+ variable subproc_get_cmdline $get_cmdline
+ setup-subwindow $w applet::subproc-destroying applet::subproc-ready
+}
+
+proc subproc-destroying {} {
+ variable subproc
+ puts "DESTROYING $subproc"
+ switch -exact $subproc {
+ none { }
+ old { }
+ default { kill $subproc; set subproc old }