Skip to content

Commit

Permalink
gitk: Resize panes correctly when reducing window size
Browse files Browse the repository at this point in the history
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 <paulus@ozlabs.org>
  • Loading branch information
paulusmack committed Oct 3, 2020
1 parent e244588 commit 6cd8049
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions gitk
Expand Up @@ -2953,9 +2953,12 @@ proc savestuff {w} {
}

proc resizeclistpanes {win w} {
global oldwidth use_ttk
global oldwidth oldsash use_ttk
if {[info exists oldwidth($win)]} {
if {$use_ttk} {
if {[info exists oldsash($win)]} {
set s0 [lindex $oldsash($win) 0]
set s1 [lindex $oldsash($win) 1]
} elseif {$use_ttk} {
set s0 [$win sashpos 0]
set s1 [$win sashpos 1]
} else {
Expand Down Expand Up @@ -2989,14 +2992,17 @@ proc resizeclistpanes {win w} {
$win sash place 0 $sash0 [lindex $s0 1]
$win sash place 1 $sash1 [lindex $s1 1]
}
set oldsash($win) [list $sash0 $sash1]
}
set oldwidth($win) $w
}

proc resizecdetpanes {win w} {
global oldwidth use_ttk
global oldwidth oldsash use_ttk
if {[info exists oldwidth($win)]} {
if {$use_ttk} {
if {[info exists oldsash($win)]} {
set s0 $oldsash($win)
} elseif {$use_ttk} {
set s0 [$win sashpos 0]
} else {
set s0 [$win sash coord 0]
Expand All @@ -3018,6 +3024,7 @@ proc resizecdetpanes {win w} {
} else {
$win sash place 0 $sash0 [lindex $s0 1]
}
set oldsash($win) $sash0
}
set oldwidth($win) $w
}
Expand Down

0 comments on commit 6cd8049

Please sign in to comment.