AW: [PATCH] gitk: fix history window panes position
- From
tobias.boesch@miele.com <tobias.boesch@miele.com>
- Date
- Dec 3, 2025, 09:35 UTC
- Message-ID
- <AM0PR08MB5426A65AA721DCA6CACF6C7AE1D9A@AM0PR08MB5426.eurprd08.prod.outlook.com>
- In-Reply-To
- <AM0PR08MB5426BC141388A69BB5087732E1D8A@AM0PR08MB5426.eurprd08.prod.outlook.com>
An addition for testing:
To test or simulate the usage of a smaller monitor one can move both sashes of the history window all the way to the right. Then close the application. That are the same conditions as if using a smaller screen, after using a bigger screen. On restart of gitk the panes should then be resized automatically to a reasonable size.
Show 131 quoted lines
> -----Ursprüngliche Nachricht-----
> Von: Boesch, Tobias
> Gesendet: Dienstag, 2. Dezember 2025 14:08
> An: Git Mailing List <git@vger.kernel.org>
> Cc: Johannes Sixt <j6t@kdbg.org>
> Betreff: [PATCH] gitk: fix history window panes position
>
> From b2ca7abc7d7efffc7312859b700780abb927e0b3 Mon Sep 17 00:00:00
> 2001
> From: Tobias Boesch <tobias.boesch@miele.com>
> Date: Thu, 27 Nov 2025 11:27:16 +0100
> Subject: [PATCH] gitk: fix history window panes position
>
> When the history window panes in are resized by moving either of the two
> sashes and then the gitk window is vertically resized, the sashes fall back into
> their previous position without respecting the users wish for resizing.
> Save the sash position when the sashes are moved to make them keep their
> position when the window is resized afterwards.
>
> When the gitk window is opened and maximized on a screen, then closed and
> opened on a screen smaller than the previously used one, the author pane and
> time pane of the history window only are a few pixels wide and their contents
> are barely visible.
> Widen the two panes on start of gitk to a reasonable fixed size that shows a
> good amount of text of authors and time.
>
> Signed-off-by: Tobias Boesch <tobias.boesch@miele.com>
> ---
>
> Notes:
> Debug print statements are left in the code for easier
> testing by maintainers.
> They will be removed when the review is finished.
>
> gitk-git/gitk | 41 +++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 41 insertions(+)
>
> diff --git a/gitk-git/gitk b/gitk-git/gitk index 7f62c8041d..6fbc2588fb 100755
> --- a/gitk-git/gitk
> +++ b/gitk-git/gitk
> @@ -2471,6 +2471,23 @@ proc makewindow {} {
> -xscrollincr $linespc \
> -yscrollincr $linespc -yscrollcommand "scrollcanv $cscroll"
> .tf.histframe.pwclist add $canv
> + bind .tf.histframe.pwclist.canv <Configure> {
> + global oldsash
> + set parent [regsub {\.[A-Za-z]+$} %W ""]
> + puts "Canvas (pwclist) configuration changed saving sash \
> + position if parent panedwindow $parent is initialised \
> + (oldsash exist)"
> + if {[info exists oldsash($parent)]} {
> + set s0 [$parent sashpos 0]
> + set s1 [$parent sashpos 1]
> + puts " Sash0 is $s0"
> + puts " Sash1 is $s1"
> + set oldsash($parent) [list $s0 $s1]
> + puts " oldsash saved for $parent"
> + } else {
> + puts " oldsash not yet existing so oldsash is not saved for $parent"
> + }
> + }
> set canv2 .tf.histframe.pwclist.canv2
> canvas $canv2 \
> -selectbackground $selectbgcolor \ @@ -3116,30 +3133,53 @@ proc
> savestuff {w} {
>
> proc resizeclistpanes {win w} {
> global oldwidth oldsash
> + puts "Starting resizeclistpanes..."
> if {[info exists oldwidth($win)]} {
> if {[info exists oldsash($win)]} {
> + puts " Using oldsash from window"
> set s0 [lindex $oldsash($win) 0]
> set s1 [lindex $oldsash($win) 1]
> + puts " Sash0 is $s0"
> + puts " Sash1 is $s1"
> } else {
> + puts " New window creation detected"
> + puts " Width is $w"
> + puts " Using sash from window sashpos directly"
> set s0 [$win sashpos 0]
> set s1 [$win sashpos 1]
> + puts " Sash0 is $s0"
> + puts " Sash1 is $s1"
> + if {$s1 > $w - 140} {
> + puts " Sash1 greater than width - 140, setting max size"
> + set s1 [expr {$w - 140}]
> + if {$s0 > $s1 - 300} {
> + puts " Sash0 greater than sash1 - 300, setting max size"
> + set s0 [expr {$s1 - 300}]
> + }
> + }
> }
> if {$w < 60} {
> + puts " Narrow window ($w), scaling sash in dependency to window
> width"
> set sash0 [expr {int($w/2 - 2)}]
> set sash1 [expr {int($w*5/6 - 2)}]
> } else {
> + puts " Wide window ($w), scaling sash in dependency to old width,
> oldsash and window width"
> set factor [expr {1.0 * $w / $oldwidth($win)}]
> set sash0 [expr {int($factor * [lindex $s0 0])}]
> set sash1 [expr {int($factor * [lindex $s1 0])}]
> if {$sash0 < 30} {
> + puts " Sash0 too small, setting min size"
> set sash0 30
> }
> if {$sash1 < $sash0 + 20} {
> + puts " Sash1 smaller than sash0 + 20, setting min size"
> set sash1 [expr {$sash0 + 20}]
> }
> if {$sash1 > $w - 10} {
> + puts " Sash1 greater than width - 140, setting max size"
> set sash1 [expr {$w - 10}]
> if {$sash0 > $sash1 - 20} {
> + puts " Sash0 greater than sash1 - 300, setting max size"
> set sash0 [expr {$sash1 - 20}]
> }
> }
> @@ -3149,6 +3189,7 @@ proc resizeclistpanes {win w} {
> set oldsash($win) [list $sash0 $sash1]
> }
> set oldwidth($win) $w
> + puts "Finished resizeclistpanes..."
> }
>
> proc resizecdetpanes {win w} {
> --
> 2.47.1.windows.2
>------------------------------------------------------------------------------------------------- imperial-Werke oHG, Sitz Bünde, Registergericht Bad Oeynhausen - HRA 4825