Skip to contentSkip to conversation

gitk: make Tags and Heads window geometry sticky

PATCH In review Michael Rappazzo 4 participants 12 messages Sep 28, 2025 – Oct 17, 2025

lore
Share & tools
lore
#0 lore raw

v3 cover gitk: make Tags and Heads window geometry sticky

Changes since v2:
- replaced my commit to restore the window size and position with the commit that was already floating around from Hannes's repository. I included this because the next commit relies on it to work correctly in some environments.
- split the manage_showrefs_geometry function into 2 functions.

Johannes Sixt (1):
Revert "gitk: Only restore window size from ~/.gitk, not position"

Michael Rappazzo (1):
gitk: make Tags and Heads window geometry sticky

 gitk | 51 +++++++++++++++++++++++++++++++++++++++------------
 1 file changed, 39 insertions(+), 12 deletions(-)
Signature · 1 line
2.51.0
#1 lore raw

PATCH v3 1/2 Revert "gitk: Only restore window size from ~/.gitk, not position"

From: Johannes Sixt <[email protected]>

This reverts commit b9bee11526ec23541ddbbd75716bfd1acc241463.

The commit catered to an unsupportable port of the Windows Tcl/Tk stuck at 8.4.1 that was used by Cygwin. 8.4.1 has some bad bugs in its layout engine, and forced changes in Gitk to be compatible. All this became irrelevant around 2011 after Cygwin gained an X11 server and switched to a supportable port of the Unix/X11 Tcl/Tk (it is now on the current 8.6 code base).

---
 gitk | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)
gitk +2 -10
index 6e4d71d585..275f353811 100755
@@ -2764,17 +2764,9 @@ proc makewindow {} {
     .pwbottom add .bright
     .ctop add .pwbottom
 
-    # restore window width & height if known
+    # restore window position if known
     if {[info exists geometry(main)]} {
-        if {[scan $geometry(main) "%dx%d" w h] >= 2} {
-            if {$w > [winfo screenwidth .]} {
-                set w [winfo screenwidth .]
-            }
-            if {$h > [winfo screenheight .]} {
-                set h [winfo screenheight .]
-            }
-            wm geometry . "${w}x$h"
-        }
+        wm geometry . "$geometry(main)"
     }
 
     if {[info exists geometry(state)] && $geometry(state) eq "zoomed"} {
Signature · 1 line
2.51.0
#7 lore raw

PATCH v3 2/2 gitk: make Tags and Heads window geometry sticky

In reply to Michael Rappazzo

Currently, the Tags and Heads window always opens at a default position and size, requiring users to reposition it each time. This patch makes the window remember its geometry between sessions.

This change saves and restores the Tags and Heads window size and position relative to the main gitk window. The geometry is stored in the config file as geometry(showrefs) and persists between gitk sessions. The window position is stored relative to the main window, so it maintains the same spatial relationship when the main window is moved or when gitk is restarted on different monitors.

---
 gitk | 39 +++++++++++++++++++++++++++++++++++++--
 1 file changed, 37 insertions(+), 2 deletions(-)
gitk +37 -2
index 275f353811..79a6dcdb4c 100755
@@ -3106,6 +3106,11 @@ proc savestuff {w} {
         puts $f "set geometry(pwsash1) \"[.tf.histframe.pwclist sashpos 1] 1\""
         puts $f "set geometry(botwidth) [winfo width .bleft]"
         puts $f "set geometry(botheight) [winfo height .bleft]"
+        if {[winfo exists .showrefs]} {
+            puts $f "set geometry(showrefs) \"[wm geometry .showrefs]\""
+        } elseif {[info exists geometry(showrefs)]} {
+            puts $f "set geometry(showrefs) \"$geometry(showrefs)\""
+        }
 
         array set view_save {}
         array set views {}
@@ -10199,11 +10204,13 @@ proc showrefs {} {
     if {[winfo exists $top]} {
         raise $top
         refill_reflist
+        wm protocol $top WM_DELETE_WINDOW [list destroy_showrefs $top]
         return
     }
     ttk_toplevel $top
     wm title $top [mc "Tags and heads: %s" [file tail [pwd]]]
     make_transient $top .
+    wm protocol $top WM_DELETE_WINDOW [list destroy_showrefs $top]
     text $top.list -background $bgcolor -foreground $fgcolor \
         -selectbackground $selectbgcolor -font mainfont \
         -xscrollcommand "$top.xsb set" -yscrollcommand "$top.ysb set" \
@@ -10229,8 +10236,8 @@ proc showrefs {} {
     ttk::checkbutton $top.sort -text [mc "Sort refs by type"] \
         -variable sortrefsbytype -command {refill_reflist}
     grid $top.sort - -sticky w -pady 2
-    ttk::button $top.close -command [list destroy $top] -text [mc "Close"]
-    bind $top <Key-Escape> [list destroy $top]
+    ttk::button $top.close -command [list destroy_showrefs $top] -text [mc "Close"]
+    bind $top <Key-Escape> [list destroy_showrefs $top]
     grid $top.close -
     grid columnconfigure $top 0 -weight 1
     grid rowconfigure $top 0 -weight 1
@@ -10239,6 +10246,9 @@ proc showrefs {} {
     bind $top.list <ButtonRelease-1> {sel_reflist %W %x %y; break}
     set reflist {}
     refill_reflist
+    # Restore geometry after the window is fully created and mapped
+    # Delay Configure binding to avoid overwriting restored geometry
+    bind $top <Map> [list after idle [list setup_showrefs_geometry_tracking $top]]
 }
 
 proc sel_reflist {w x y} {
@@ -10271,6 +10281,31 @@ proc reflistfilter_change {n1 n2 op} {
     after 200 refill_reflist
 }
 
+proc save_showrefs_geometry {top} {
+    global geometry
+    if {[winfo exists $top]} {
+        set geometry(showrefs) [wm geometry $top]
+    }
+}
+
+proc restore_showrefs_geometry {top} {
+    global geometry
+    if {[info exists geometry(showrefs)] && [winfo exists $top]} {
+        wm geometry $top $geometry(showrefs)
+    }
+}
+
+proc setup_showrefs_geometry_tracking {top} {
+    restore_showrefs_geometry $top
+    bind $top <Configure> [list save_showrefs_geometry $top]
+}
+
+proc destroy_showrefs {top} {
+    save_showrefs_geometry $top
+    savestuff .
+    destroy $top
+}
+
 proc refill_reflist {} {
     global reflist reflistfilter showrefstop headids tagids otherrefids sortrefsbytype
     global curview upstreamofref
Signature · 1 line
2.51.0
#2 lore raw

Re: [PATCH v3 1/2] Revert "gitk: Only restore window size from ~/.gitk, not position"

In reply to Michael Rappazzo
Quoted 31 lines · Michael Rappazzo

From: Johannes Sixt <[email protected]>

This reverts commit b9bee11526ec23541ddbbd75716bfd1acc241463.

The commit catered to an unsupportable port of the Windows Tcl/Tk stuck at 8.4.1 that was used by Cygwin. 8.4.1 has some bad bugs in its layout engine, and forced changes in Gitk to be compatible. All this became irrelevant around 2011 after Cygwin gained an X11 server and switched to a supportable port of the Unix/X11 Tcl/Tk (it is now on the current 8.6 code base).

---
 gitk | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)
gitk +1 -4
index 6e4d71d585..275f353811 100755
@@ -2764,17 +2764,9 @@ proc makewindow {} {
     .pwbottom add .bright
     .ctop add .pwbottom
 
-    # restore window width & height if known
+    # restore window position if known
     if {[info exists geometry(main)]} {
-        if {[scan $geometry(main) "%dx%d" w h] >= 2} {
-            if {$w > [winfo screenwidth .]} {
-                set w [winfo screenwidth .]

gitk proc makewindow {} { · line 2772

Quoted 10 lines
gitk +1 -6
-            }
-            if {$h > [winfo screenheight .]} {
-                set h [winfo screenheight .]
-            }
-            wm geometry . "${w}x$h"
-        }
+        wm geometry . "$geometry(main)"
     }
 
     if {[info exists geometry(state)] && $geometry(state) eq "zoomed"} {

I mis-interpreted an earlier inquiry about the patch being reverted here. Patch e9937d2a03 actually addressed the issues of Cygwin's 8.4.1 Tcl/Tk. Part of that was fixing the window geometry being restored, as sometimes the window manager would size the main window in a manner causing 8.4.1 to fail. But, this override of the main window manager on all platforms raised complaints on the mailing list, and commit b9bee11526 was the response:
it was only the SIZE of the Window that mattered on Cygwin, not its location, so allowing window managers to set the location was ok.

Personally, I'm fine with gitk remembering / restoring the full window geometry (I wrote it that way in e9937d2a03).

Mark

#3 lore raw

Re: [PATCH v3 1/2] Revert "gitk: Only restore window size from ~/.gitk, not position"

Quoted 51 lines · Mark Levedahl
Quoted 31 lines · Michael Rappazzo

From: Johannes Sixt <[email protected]>

This reverts commit b9bee11526ec23541ddbbd75716bfd1acc241463.

The commit catered to an unsupportable port of the Windows Tcl/Tk stuck at 8.4.1 that was used by Cygwin. 8.4.1 has some bad bugs in its layout engine, and forced changes in Gitk to be compatible. All this became irrelevant around 2011 after Cygwin gained an X11 server and switched to a supportable port of the Unix/X11 Tcl/Tk (it is now on the current 8.6 code base).

---
 gitk | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)
gitk +1 -4
index 6e4d71d585..275f353811 100755
@@ -2764,17 +2764,9 @@ proc makewindow {} {
     .pwbottom add .bright
     .ctop add .pwbottom
 
-    # restore window width & height if known
+    # restore window position if known
     if {[info exists geometry(main)]} {
-        if {[scan $geometry(main) "%dx%d" w h] >= 2} {
-            if {$w > [winfo screenwidth .]} {
-                set w [winfo screenwidth .]

gitk proc makewindow {} { · line 2772

Quoted 10 lines
gitk +1 -6
-            }
-            if {$h > [winfo screenheight .]} {
-                set h [winfo screenheight .]
-            }
-            wm geometry . "${w}x$h"
-        }
+        wm geometry . "$geometry(main)"
     }
 
     if {[info exists geometry(state)] && $geometry(state) eq "zoomed"} {

I mis-interpreted an earlier inquiry about the patch being reverted here. Patch e9937d2a03 actually addressed the issues of Cygwin's 8.4.1 Tcl/Tk. Part of that was fixing the window geometry being restored, as sometimes the window manager would size the main window in a manner causing 8.4.1 to fail. But, this override of the main window manager on all platforms raised complaints on the mailing list, and commit b9bee11526 was the response:
it was only the SIZE of the Window that mattered on Cygwin, not its location, so allowing window managers to set the location was ok.

Quoted 2 lines

Personally, I'm fine with gitk remembering / restoring the full window geometry (I wrote it that way in e9937d2a03).

In my v2 version there is a slight difference:
+ after idle [list wm geometry . $geometry(main)]

This seems likely related to my second patch changes where I use after idle due to the timing concerns which I reported on in my latest email from that series[1].

[1] https://lore.kernel.org/git/CANoM8SXnxxF6UMSfQ06ANfEv7HFCEEMCVoGgod1-DuFeHp6tXg@mail.gmail.com/T/#e1fc2a76267e3077c0de40ad8902e2158c00164e1

Quoted 2 lines

Mark

#6 lore raw

Re: [PATCH v3 1/2] Revert "gitk: Only restore window size from ~/.gitk, not position"

In reply to Michael Rappazzo
Quoted 3 lines · Michael Rappazzo

From: Johannes Sixt <[email protected]>

This reverts commit b9bee11526ec23541ddbbd75716bfd1acc241463.

If you wrote it like

Revert b9bee115 (gitk: Only restore window size from ~/.gitk, not position, 2008-03-10).

it would make it obvious that this is not a revert of a recent screwup, but historical wart carried from long time ago.

Quoted 10 lines

The commit catered to an unsupportable port of the Windows Tcl/Tk stuck at 8.4.1 that was used by Cygwin. 8.4.1 has some bad bugs in its layout engine, and forced changes in Gitk to be compatible. All this became irrelevant around 2011 after Cygwin gained an X11 server and switched to a supportable port of the Unix/X11 Tcl/Tk (it is now on the current 8.6 code base).

---

Very nice to see such a clean-up.

#8 lore raw
In reply to Michael Rappazzo
Quoted 3 lines · Michael Rappazzo

Currently, the Tags and Heads window always opens at a default position and size, requiring users to reposition it each time. This patch makes the window remember its geometry between sessions.

As the second patch in two-patch series, whose first step is a revert we just saw, it is unclear what state of the code "Currently" above refers to. Has it been that way even before the revert (in other words, even with the ancient Tcl/Tk 8.4.1 workaround), or have we briefly regressed with the previous step to fix it correctly and this is the right fix suitable for Tcl/Tk of the modern times?

Quoted 11 lines

This change saves and restores the Tags and Heads window size and position relative to the main gitk window. The geometry is stored in the config file as geometry(showrefs) and persists between gitk sessions. The window position is stored relative to the main window, so it maintains the same spatial relationship when the main window is moved or when gitk is restarted on different monitors.

---
 gitk | 39 +++++++++++++++++++++++++++++++++++++--
 1 file changed, 37 insertions(+), 2 deletions(-)

Nice. Very well written explanation that tells why this is a good thing to do to those who do not even use gitk very often.

As a pair of patches to an area with an official submaintainer, I won't touch them and instead expect them to be fed via a pull request once the reviews are done on them, but it still is appreciated to see patches sent here for reviews even when the submaintainer is part of the team that authored them.

Thanks.

#9 lore raw
In reply to Michael Rappazzo

Am 28.09.25 um 15:54 schrieb Michael Rappazzo:

Quoted 89 lines

Currently, the Tags and Heads window always opens at a default position and size, requiring users to reposition it each time. This patch makes the window remember its geometry between sessions.

This change saves and restores the Tags and Heads window size and position relative to the main gitk window. The geometry is stored in the config file as geometry(showrefs) and persists between gitk sessions. The window position is stored relative to the main window, so it maintains the same spatial relationship when the main window is moved or when gitk is restarted on different monitors.

---
 gitk | 39 +++++++++++++++++++++++++++++++++++++--
 1 file changed, 37 insertions(+), 2 deletions(-)
gitk +30 -2
index 275f353811..79a6dcdb4c 100755
@@ -3106,6 +3106,11 @@ proc savestuff {w} {
         puts $f "set geometry(pwsash1) \"[.tf.histframe.pwclist sashpos 1] 1\""
         puts $f "set geometry(botwidth) [winfo width .bleft]"
         puts $f "set geometry(botheight) [winfo height .bleft]"
+        if {[winfo exists .showrefs]} {
+            puts $f "set geometry(showrefs) \"[wm geometry .showrefs]\""
+        } elseif {[info exists geometry(showrefs)]} {
+            puts $f "set geometry(showrefs) \"$geometry(showrefs)\""
+        }
 
         array set view_save {}
         array set views {}
@@ -10199,11 +10204,13 @@ proc showrefs {} {
     if {[winfo exists $top]} {
         raise $top
         refill_reflist
+        wm protocol $top WM_DELETE_WINDOW [list destroy_showrefs $top]
         return
     }
     ttk_toplevel $top
     wm title $top [mc "Tags and heads: %s" [file tail [pwd]]]
     make_transient $top .
+    wm protocol $top WM_DELETE_WINDOW [list destroy_showrefs $top]
     text $top.list -background $bgcolor -foreground $fgcolor \
         -selectbackground $selectbgcolor -font mainfont \
         -xscrollcommand "$top.xsb set" -yscrollcommand "$top.ysb set" \
@@ -10229,8 +10236,8 @@ proc showrefs {} {
     ttk::checkbutton $top.sort -text [mc "Sort refs by type"] \
         -variable sortrefsbytype -command {refill_reflist}
     grid $top.sort - -sticky w -pady 2
-    ttk::button $top.close -command [list destroy $top] -text [mc "Close"]
-    bind $top <Key-Escape> [list destroy $top]
+    ttk::button $top.close -command [list destroy_showrefs $top] -text [mc "Close"]
+    bind $top <Key-Escape> [list destroy_showrefs $top]
     grid $top.close -
     grid columnconfigure $top 0 -weight 1
     grid rowconfigure $top 0 -weight 1
@@ -10239,6 +10246,9 @@ proc showrefs {} {
     bind $top.list <ButtonRelease-1> {sel_reflist %W %x %y; break}
     set reflist {}
     refill_reflist
+    # Restore geometry after the window is fully created and mapped
+    # Delay Configure binding to avoid overwriting restored geometry
+    bind $top <Map> [list after idle [list setup_showrefs_geometry_tracking $top]]
 }
 
 proc sel_reflist {w x y} {
@@ -10271,6 +10281,31 @@ proc reflistfilter_change {n1 n2 op} {
     after 200 refill_reflist
 }
 
+proc save_showrefs_geometry {top} {
+    global geometry
+    if {[winfo exists $top]} {
+        set geometry(showrefs) [wm geometry $top]
+    }
+}
+
+proc restore_showrefs_geometry {top} {
+    global geometry
+    if {[info exists geometry(showrefs)] && [winfo exists $top]} {
+        wm geometry $top $geometry(showrefs)
+    }
+}
+
+proc setup_showrefs_geometry_tracking {top} {
+    restore_showrefs_geometry $top
+    bind $top <Configure> [list save_showrefs_geometry $top]
+}

gitk proc reflistfilter_change {n1 n2 op} { · line 10311

Quoted 10 lines
gitk +7 -0
+
+proc destroy_showrefs {top} {
+    save_showrefs_geometry $top
+    savestuff .
+    destroy $top
+}
+
 proc refill_reflist {} {
     global reflist reflistfilter showrefstop headids tagids otherrefids sortrefsbytype
     global curview upstreamofref

A patch should be much smaller than this. I was thinking along the lines of the below diff. However, it doesn't work for some reason: the variable that is updated from the Configure handler is not the same that is serialized in proc savestuff, and I don't know why. Nevertheless, within a session, the window geometry *is* preserved, just not across sessions.

gitk +1 -1
index 275f353..77d5acc 100755
@@ -3058,7 +3058,7 @@ proc config_variable_change_cb {name name2 op} {
 }
 
 proc savestuff {w} {
-    global stuffsaved
+    global stuffsaved geometry
     global config_file config_file_tmp
     global config_variables config_variable_changed
     global viewchanged
@@ -3106,6 +3106,9 @@ proc savestuff {w} {
         puts $f "set geometry(pwsash1) \"[.tf.histframe.pwclist sashpos

1] 1\""
puts $f "set geometry(botwidth) [winfo width .bleft]" puts $f "set geometry(botheight) [winfo height .bleft]"
+ if {[info exists geometry(showrefs)]} {
+ puts $f "set geometry(showrefs) \"$geometry(showrefs)\""
+ }

         array set view_save {}
         array set views {}

@@ -10193,6 +10196,7 @@ proc rmbranch {} {
proc showrefs {} {
global showrefstop bgcolor fgcolor selectbgcolor global bglist fglist reflistfilter reflist maincursor
+ global geometry

set top .showrefs
set showrefstop $top

@@ -10239,6 +10243,12 @@ proc showrefs {} {
     bind $top.list <ButtonRelease-1> {sel_reflist %W %x %y; break}
     set reflist {}
     refill_reflist
+    if {[info exists geometry(showrefs)]} {
+        after idle [list wm geometry $top $geometry(showrefs)]
+    }
+    # avoid <Configure> being bound to child windows
+    bindtags $top [linsert [bindtags $top] 1 bind$top]
+    bind bind$top <Configure> {set geometry(showrefs) [wm geometry %W]}

}

proc sel_reflist {w x y} {

#10 lore raw

PATCH 1/1 gitk: persist position and size of the Tags and Heads window

The Tags and Heads window always opens at a default position and size, requiring users to reposition it each time. Remember its geometry between sessions in the config file as geometry(showrefs).

Note that the existing configuration is sourced in proc savestuff right before new settings are written. This makes the old settings available as local variables(!) and does not overwrite the current settings. Since we need access to the global geometry(showrefs), it is necessary to unset the local variable.

---
Am 04.10.25 um 19:36 schrieb Johannes Sixt:

Quoted 3 lines

... it doesn't work for some reason: the
variable that is updated from the Configure handler is not the same that is serialized in proc savestuff, and I don't know why.

Very simple: the old settings are sourced before being written out again and overwrite the current setting. But things turn out to be more sutle than that. See above and below.

 gitk | 12 ++++++++++++
 1 file changed, 12 insertions(+)
gitk +12 -0
index 275f353..6deaa3a 100755
@@ -3106,6 +3106,11 @@ proc savestuff {w} {
         puts $f "set geometry(pwsash1) \"[.tf.histframe.pwclist sashpos 1] 1\""
         puts $f "set geometry(botwidth) [winfo width .bleft]"
         puts $f "set geometry(botheight) [winfo height .bleft]"
+        unset -nocomplain geometry
+        global geometry
+        if {[info exists geometry(showrefs)]} {
+            puts $f "set geometry(showrefs) $geometry(showrefs)"
+        }
 
         array set view_save {}
         array set views {}
@@ -10193,6 +10198,7 @@ proc rmbranch {} {
 proc showrefs {} {
     global showrefstop bgcolor fgcolor selectbgcolor
     global bglist fglist reflistfilter reflist maincursor
+    global geometry
 
     set top .showrefs
     set showrefstop $top
@@ -10239,6 +10245,12 @@ proc showrefs {} {
     bind $top.list <ButtonRelease-1> {sel_reflist %W %x %y; break}
     set reflist {}
     refill_reflist
+    if {[info exists geometry(showrefs)]} {
+        after idle [list wm geometry $top $geometry(showrefs)]
+    }
+    # avoid <Configure> being bound to child windows
+    bindtags $top [linsert [bindtags $top] 1 bind$top]
+    bind bind$top <Configure> {set geometry(showrefs) [wm geometry %W]}
 }
 
 proc sel_reflist {w x y} {
Signature · 1 line
2.51.0.427.g504992c71c
#11 lore raw

PATCH v2 1/1 gitk: persist position and size of the Tags and Heads window

The Tags and Heads window always opens at a default position and size, requiring users to reposition it each time. Remember its geometry between sessions in the config file as geometry(showrefs).

Note that the existing configuration is sourced in proc savestuff right before new settings are written. This makes the old settings available as local variables(!) and does not overwrite the current settings. Since we need access to the global geometry(showrefs), it is necessary to unset the local variable.

---
Changes since v1:
- On Windows, only the size was restored, but not the position. There is special logic for Windows that positions popup windows. Now we take this into account.

 gitk | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)
gitk +20 -5
index 275f353..ed61661 100755
@@ -2131,12 +2131,14 @@ proc ttk_toplevel {w args} {
     return $w
 }
 
-proc make_transient {window origin} {
+proc make_transient {window origin {geometry ""}} {
     wm transient $window $origin
 
-    # Windows fails to place transient windows normally, so
-    # schedule a callback to center them on the parent.
-    if {[tk windowingsystem] eq {win32}} {
+    if {$geometry ne ""} {
+        after idle [list wm geometry $window $geometry]
+    } elseif {[tk windowingsystem] eq {win32}} {
+        # Windows fails to place transient windows normally, so
+        # schedule a callback to center them on the parent.
         after idle [list tk::PlaceWindow $window widget $origin]
     }
 }
@@ -3106,6 +3108,11 @@ proc savestuff {w} {
         puts $f "set geometry(pwsash1) \"[.tf.histframe.pwclist sashpos 1] 1\""
         puts $f "set geometry(botwidth) [winfo width .bleft]"
         puts $f "set geometry(botheight) [winfo height .bleft]"
+        unset -nocomplain geometry
+        global geometry
+        if {[info exists geometry(showrefs)]} {
+            puts $f "set geometry(showrefs) $geometry(showrefs)"
+        }
 
         array set view_save {}
         array set views {}
@@ -10193,6 +10200,7 @@ proc rmbranch {} {
 proc showrefs {} {
     global showrefstop bgcolor fgcolor selectbgcolor
     global bglist fglist reflistfilter reflist maincursor
+    global geometry
 
     set top .showrefs
     set showrefstop $top
@@ -10203,7 +10211,11 @@ proc showrefs {} {
     }
     ttk_toplevel $top
     wm title $top [mc "Tags and heads: %s" [file tail [pwd]]]
-    make_transient $top .
+    if {[info exists geometry(showrefs)]} {
+        make_transient $top . $geometry(showrefs)
+    } else {
+        make_transient $top .
+    }
     text $top.list -background $bgcolor -foreground $fgcolor \
         -selectbackground $selectbgcolor -font mainfont \
         -xscrollcommand "$top.xsb set" -yscrollcommand "$top.ysb set" \
@@ -10239,6 +10251,9 @@ proc showrefs {} {
     bind $top.list <ButtonRelease-1> {sel_reflist %W %x %y; break}
     set reflist {}
     refill_reflist
+    # avoid <Configure> being bound to child windows
+    bindtags $top [linsert [bindtags $top] 1 bind$top]
+    bind bind$top <Configure> {set geometry(showrefs) [wm geometry %W]}
 }
 
 proc sel_reflist {w x y} {
Signature · 1 line
2.51.0.431.g0f99086cdf
#4 lore raw

Re: [PATCH v3 1/2] Revert "gitk: Only restore window size from ~/.gitk, not position"

In reply to Mark Levedahl

Am 28.09.25 um 16:17 schrieb Mark Levedahl:

Quoted 50 lines · Michael Rappazzo
Quoted 31 lines

From: Johannes Sixt <[email protected]>

This reverts commit b9bee11526ec23541ddbbd75716bfd1acc241463.

The commit catered to an unsupportable port of the Windows Tcl/Tk stuck at 8.4.1 that was used by Cygwin. 8.4.1 has some bad bugs in its layout engine, and forced changes in Gitk to be compatible. All this became irrelevant around 2011 after Cygwin gained an X11 server and switched to a supportable port of the Unix/X11 Tcl/Tk (it is now on the current 8.6 code base).

---
 gitk | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)
gitk +1 -4
index 6e4d71d585..275f353811 100755
@@ -2764,17 +2764,9 @@ proc makewindow {} {
     .pwbottom add .bright
     .ctop add .pwbottom
 
-    # restore window width & height if known
+    # restore window position if known
     if {[info exists geometry(main)]} {
-        if {[scan $geometry(main) "%dx%d" w h] >= 2} {
-            if {$w > [winfo screenwidth .]} {
-                set w [winfo screenwidth .]

gitk proc makewindow {} { · line 2772

Quoted 10 lines
gitk +1 -6
-            }
-            if {$h > [winfo screenheight .]} {
-                set h [winfo screenheight .]
-            }
-            wm geometry . "${w}x$h"
-        }
+        wm geometry . "$geometry(main)"
     }
 
     if {[info exists geometry(state)] && $geometry(state) eq "zoomed"} {

I mis-interpreted an earlier inquiry about the patch being reverted here. Patch e9937d2a03 actually addressed the issues of Cygwin's 8.4.1 Tcl/Tk. Part of that was fixing the window geometry being restored, as sometimes the window manager would size the main window in a manner causing 8.4.1 to fail. But, this override of the main window manager on all platforms raised complaints on the mailing list, and commit b9bee11526 was the response:
it was only the SIZE of the Window that mattered on Cygwin, not its location, so allowing window managers to set the location was ok.

Quoted 2 lines

Personally, I'm fine with gitk remembering / restoring the full window geometry (I wrote it that way in e9937d2a03).

Thank you for the hint. I found the thread, and after reading it I notice that the opposition is based on that restoring the position doesn't put the window on the desired monitor. I can't test this right now. I've rewritten the commit message as follows. Whether or not the position should be restored seems to be a personal preference, and the patch applies my and your preference, but obviously not everyone's. Please let me know whether I understood the situation correctly or not.

Revert "gitk: Only restore window size from ~/.gitk, not position"

This reverts commit b9bee11526ec (gitk: Only restore window size from ~/.gitk, not position, 2008-03-10).

The earlier commit e9937d2a03a4 (Make gitk work reasonably well on Cygwin, 2007-02-01) reworked the window layout considerably. Much of this became irrelevant around 2011 after Cygwin gained an X11 server and switched to a supportable port of the Unix/X11 Tcl/Tk (it is now on the current 8.6 code base).

Part of the necessary change was to restore the window size across sessions, but the position was also restored. This raised complaints on the mailing list[*], because Gitk was opened on the wrong monitor. b9bee11526ec was the compromise, because it was only the size that mattered for the Cygwin layout engine to work.

I personally, find it annoying when Gitk pops up on a random location on the screen, in particular, since many other applications restore the window positions across sessions, so why not Gitk as well? (I do not operate multi-monitor setups, so I cannot test the case.)

[*] https://lore.kernel.org/git/[email protected]/

-- Hannes

#5 lore raw

Re: [PATCH v3 1/2] Revert "gitk: Only restore window size from ~/.gitk, not position"

Quoted 10 lines · Johannes Sixt

Thank you for the hint. I found the thread, and after reading it I notice that the opposition is based on that restoring the position doesn't put the window on the desired monitor. I can't test this right now. I've rewritten the commit message as follows. Whether or not the position should be restored seems to be a personal preference, and the patch applies my and your preference, but obviously not everyone's. Please let me know whether I understood the situation correctly or not.

-- Hannes

Your commit message accurately captures the issues as I understand them. I also cannot contribute on the multi-monitor setup, nor about the broader context wanting this patch.

Mark