Make gitk save and restore the user set window position.
gitk was saving widget sizes and positions when the main window was destroyed, which is after all child widgets are destroyed. The cure is to trap the WM_DELETE_WINDOW event before the gui is torn down. Also, the saved geometry was captured using "winfo geometry .", rather than "wm geometry ." Under Linux, these two return different answers and the latter one is correct. [jc: credit goes to Brett Schwarz for suggesting the use of "wm protocol"; I also squashed the follow-up patch to remove extraneous -0 from expressions.] Signed-off-by: Mark Levedahl <mdl123@verizon.net> Signed-off-by: Junio C Hamano <junkio@cox.net>
Mark Levedahl committed
Feb 8, 2007 at 22:22 UTC
602598fd5d8f64028f84d2772725c5e3414a112f
1 file changed
+6
-5
gitk
+6
-5
@@ -725,7 +725,7 @@ proc makewindow {} {
725
bind . <Control-KP_Add> {incrfont 1}
726
bind . <Control-minus> {incrfont -1}
727
bind . <Control-KP_Subtract> {incrfont -1}
728
- bind . <Destroy> {savestuff %W}
728
+ wm protocol . WM_DELETE_WINDOW doquit
729
bind . <Button-1> "click %W"
730
bind $fstring <Key-Return> dofind
731
bind $sha1entry <Key-Return> gotocommit
@@ -829,12 +829,12 @@ proc savestuff {w} {
829
puts $f [list set colors $colors]
830
puts $f [list set diffcolors $diffcolors]
831
832
- puts $f "set geometry(main) [winfo geometry .]"
832
+ puts $f "set geometry(main) [wm geometry .]"
833
puts $f "set geometry(topwidth) [winfo width .tf]"
834
puts $f "set geometry(topheight) [winfo height .tf]"
835
- puts $f "set geometry(canv) [expr {[winfo width $canv]-0}]"
836
- puts $f "set geometry(canv2) [expr {[winfo width $canv2]-0}]"
837
- puts $f "set geometry(canv3) [expr {[winfo width $canv3]-0}]"
835
+ puts $f "set geometry(canv) [winfo width $canv]"
836
+ puts $f "set geometry(canv2) [winfo width $canv2]"
837
+ puts $f "set geometry(canv3) [winfo width $canv3]"
838
puts $f "set geometry(botwidth) [winfo width .bleft]"
839
puts $f "set geometry(botheight) [winfo height .bleft]"
840
@@ -5800,6 +5800,7 @@ proc showtag {tag isnew} {
5800
proc doquit {} {
5801
global stopped
5802
set stopped 100
5803
+ savestuff .
5804
destroy .
5805
}
5806