git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] gitk: fix history window panes position

From
tobias.boesch@miele.com <tobias.boesch@miele.com>
Date
Dec 2, 2025, 13:08 UTC
Message-ID
<AM0PR08MB5426BC141388A69BB5087732E1D8A@AM0PR08MB5426.eurprd08.prod.outlook.com>
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
Next: tobias.boesch@miele.com
Message 1 of 8 in “gitk: fix history window panes position”
  1. gitk: fix history window panes positiontobias.boesch@miele.com, Dec 2, 2025
  2. AW: [PATCH] gitk: fix history window panes positiontobias.boesch@miele.com, Dec 3, 2025
  3. Johannes SixtDec 3, 2025
  4. AW: [PATCH] gitk: fix history window panes positiontobias.boesch@miele.com, Dec 4, 2025
  5. Johannes SixtDec 4, 2025
  6. Junio C HamanoDec 5, 2025
  7. Johannes SixtDec 5, 2025
  8. Junio C HamanoDec 5, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.