Skip to content

Commit f16a449

Browse files
committed
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. Helped-by: Michael Rappazzo <rappazzo@gmail.com> Signed-off-by: Johannes Sixt <j6t@kdbg.org>
1 parent 3caa13b commit f16a449

1 file changed

Lines changed: 20 additions & 5 deletions

File tree

gitk

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2131,12 +2131,14 @@ proc ttk_toplevel {w args} {
21312131
return $w
21322132
}
21332133
2134-
proc make_transient {window origin} {
2134+
proc make_transient {window origin {geometry ""}} {
21352135
wm transient $window $origin
21362136
2137-
# Windows fails to place transient windows normally, so
2138-
# schedule a callback to center them on the parent.
2139-
if {[tk windowingsystem] eq {win32}} {
2137+
if {$geometry ne ""} {
2138+
after idle [list wm geometry $window $geometry]
2139+
} elseif {[tk windowingsystem] eq {win32}} {
2140+
# Windows fails to place transient windows normally, so
2141+
# schedule a callback to center them on the parent.
21402142
after idle [list tk::PlaceWindow $window widget $origin]
21412143
}
21422144
}
@@ -3106,6 +3108,11 @@ proc savestuff {w} {
31063108
puts $f "set geometry(pwsash1) \"[.tf.histframe.pwclist sashpos 1] 1\""
31073109
puts $f "set geometry(botwidth) [winfo width .bleft]"
31083110
puts $f "set geometry(botheight) [winfo height .bleft]"
3111+
unset -nocomplain geometry
3112+
global geometry
3113+
if {[info exists geometry(showrefs)]} {
3114+
puts $f "set geometry(showrefs) $geometry(showrefs)"
3115+
}
31093116
31103117
array set view_save {}
31113118
array set views {}
@@ -10193,6 +10200,7 @@ proc rmbranch {} {
1019310200
proc showrefs {} {
1019410201
global showrefstop bgcolor fgcolor selectbgcolor
1019510202
global bglist fglist reflistfilter reflist maincursor
10203+
global geometry
1019610204
1019710205
set top .showrefs
1019810206
set showrefstop $top
@@ -10203,7 +10211,11 @@ proc showrefs {} {
1020310211
}
1020410212
ttk_toplevel $top
1020510213
wm title $top [mc "Tags and heads: %s" [file tail [pwd]]]
10206-
make_transient $top .
10214+
if {[info exists geometry(showrefs)]} {
10215+
make_transient $top . $geometry(showrefs)
10216+
} else {
10217+
make_transient $top .
10218+
}
1020710219
text $top.list -background $bgcolor -foreground $fgcolor \
1020810220
-selectbackground $selectbgcolor -font mainfont \
1020910221
-xscrollcommand "$top.xsb set" -yscrollcommand "$top.ysb set" \
@@ -10239,6 +10251,9 @@ proc showrefs {} {
1023910251
bind $top.list <ButtonRelease-1> {sel_reflist %W %x %y; break}
1024010252
set reflist {}
1024110253
refill_reflist
10254+
# avoid <Configure> being bound to child windows
10255+
bindtags $top [linsert [bindtags $top] 1 bind$top]
10256+
bind bind$top <Configure> {set geometry(showrefs) [wm geometry %W]}
1024210257
}
1024310258
1024410259
proc sel_reflist {w x y} {

0 commit comments

Comments
 (0)