git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gitk: fix history window panes position
@ 2025-12-02 13:08 tobias.boesch
  2025-12-03  9:35 ` AW: " tobias.boesch
  2025-12-03 10:15 ` Johannes Sixt
  0 siblings, 2 replies; 8+ messages in thread
From: tobias.boesch @ 2025-12-02 13:08 UTC (permalink / raw)
  To: Git Mailing List; +Cc: Johannes Sixt

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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-12-05  7:22 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-02 13:08 [PATCH] gitk: fix history window panes position tobias.boesch
2025-12-03  9:35 ` AW: " tobias.boesch
2025-12-03 10:15 ` Johannes Sixt
2025-12-04  8:39   ` AW: " tobias.boesch
2025-12-04  9:20     ` Johannes Sixt
2025-12-05  2:23       ` Junio C Hamano
2025-12-05  6:40         ` Johannes Sixt
2025-12-05  7:22           ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).