Skip to content

Commit 6cd8049

Browse files
committed
gitk: Resize panes correctly when reducing window size
The resizeclistpanes and resizecdetpanes procedures attempt to keep the horizontal proportions of the panes of the gitk window approximately constant when the gitk window is resized. However, if the size is reduced enough that an existing sash position would go outside the window, Tk moves the sash to the left to keep it inside the window (without moving other sash positions to keep the proportions). This happens before these resize procedures get control, and so they work with incorrect proportions. To fix this, we record the sash positions we set previously and use those previously-set sash positions rather than the current sash positions when computing the proportions. Signed-off-by: Paul Mackerras <[email protected]>
1 parent e244588 commit 6cd8049

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

gitk

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2953,9 +2953,12 @@ proc savestuff {w} {
29532953
}
29542954

29552955
proc resizeclistpanes {win w} {
2956-
global oldwidth use_ttk
2956+
global oldwidth oldsash use_ttk
29572957
if {[info exists oldwidth($win)]} {
2958-
if {$use_ttk} {
2958+
if {[info exists oldsash($win)]} {
2959+
set s0 [lindex $oldsash($win) 0]
2960+
set s1 [lindex $oldsash($win) 1]
2961+
} elseif {$use_ttk} {
29592962
set s0 [$win sashpos 0]
29602963
set s1 [$win sashpos 1]
29612964
} else {
@@ -2989,14 +2992,17 @@ proc resizeclistpanes {win w} {
29892992
$win sash place 0 $sash0 [lindex $s0 1]
29902993
$win sash place 1 $sash1 [lindex $s1 1]
29912994
}
2995+
set oldsash($win) [list $sash0 $sash1]
29922996
}
29932997
set oldwidth($win) $w
29942998
}
29952999

29963000
proc resizecdetpanes {win w} {
2997-
global oldwidth use_ttk
3001+
global oldwidth oldsash use_ttk
29983002
if {[info exists oldwidth($win)]} {
2999-
if {$use_ttk} {
3003+
if {[info exists oldsash($win)]} {
3004+
set s0 $oldsash($win)
3005+
} elseif {$use_ttk} {
30003006
set s0 [$win sashpos 0]
30013007
} else {
30023008
set s0 [$win sash coord 0]
@@ -3018,6 +3024,7 @@ proc resizecdetpanes {win w} {
30183024
} else {
30193025
$win sash place 0 $sash0 [lindex $s0 1]
30203026
}
3027+
set oldsash($win) $sash0
30213028
}
30223029
set oldwidth($win) $w
30233030
}

0 commit comments

Comments
 (0)