[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