Skip to content

Commit b6047c5

Browse files
mark987paulusmack
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7426eb7 commit b6047c5

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

gitk

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ proc makewindow {} {
725725
bind . <Control-KP_Add> {incrfont 1}
726726
bind . <Control-minus> {incrfont -1}
727727
bind . <Control-KP_Subtract> {incrfont -1}
728-
bind . <Destroy> {savestuff %W}
728+
wm protocol . WM_DELETE_WINDOW doquit
729729
bind . <Button-1> "click %W"
730730
bind $fstring <Key-Return> dofind
731731
bind $sha1entry <Key-Return> gotocommit
@@ -829,12 +829,12 @@ proc savestuff {w} {
829829
puts $f [list set colors $colors]
830830
puts $f [list set diffcolors $diffcolors]
831831

832-
puts $f "set geometry(main) [winfo geometry .]"
832+
puts $f "set geometry(main) [wm geometry .]"
833833
puts $f "set geometry(topwidth) [winfo width .tf]"
834834
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]"
838838
puts $f "set geometry(botwidth) [winfo width .bleft]"
839839
puts $f "set geometry(botheight) [winfo height .bleft]"
840840

@@ -5800,6 +5800,7 @@ proc showtag {tag isnew} {
58005800
proc doquit {} {
58015801
global stopped
58025802
set stopped 100
5803+
savestuff .
58035804
destroy .
58045805
}
58055806

0 commit comments

Comments
 (0)