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

[PATCH] gitk: persist position and size of the Tags and Heads window

From
Johannes Sixt <j6t@kdbg.org>
Date
Oct 4, 2025, 22:04 UTC
Message-ID
<941180e0-d8a1-4f2b-a0d8-2128428b36d8@kdbg.org>
In-Reply-To
<fd6450e2-cf56-4b99-b0ed-37a174d7ce9c@kdbg.org>

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.

Helped-by: Michael Rappazzo <rappazzo@gmail.com>
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
---
Am 04.10.25 um 19:36 schrieb Johannes Sixt:
> ... 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(+)
diff --git a/gitk b/gitk
index 275f353..6deaa3a 100755
--- a/gitk
+++ b/gitk
@@ -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} {
-- 
2.51.0.427.g504992c71c
Previous: Johannes SixtNext: Johannes Sixt
Message 11 of 12 in “gitk: make Tags and Heads window geometry sticky”
  1. 0/2 gitk: make Tags and Heads window geometry stickyMichael Rappazzo, Sep 28, 2025
  2. 1/2 Revert "gitk: Only restore window size from ~/.gitk, not position"Michael Rappazzo, Sep 28, 2025
  3. Mark LevedahlSep 28, 2025
  4. Mike RappazzoSep 28, 2025
  5. Johannes SixtOct 17, 2025
  6. Mark LevedahlOct 17, 2025
  7. Junio C HamanoSep 28, 2025
  8. 2/2 gitk: make Tags and Heads window geometry stickyMichael Rappazzo, Sep 28, 2025
  9. Junio C HamanoSep 28, 2025
  10. Johannes SixtOct 4, 2025
  11. gitk: persist position and size of the Tags and Heads windowJohannes Sixt, Oct 4, 2025
  12. gitk: persist position and size of the Tags and Heads windowJohannes Sixt, Oct 6, 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.