Skip to content

Commit b8349cd

Browse files
committed
Merge branch 'js/persist-ref-window-geometry' into j6t-testing
* js/persist-ref-window-geometry: gitk: persist position and size of the Tags and Heads window Revert "gitk: Only restore window size from ~/.gitk, not position"
2 parents 97babc1 + f16a449 commit b8349cd

1 file changed

Lines changed: 22 additions & 15 deletions

File tree

gitk

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2138,12 +2138,14 @@ proc ttk_toplevel {w args} {
21382138
return $w
21392139
}
21402140
2141-
proc make_transient {window origin} {
2141+
proc make_transient {window origin {geometry ""}} {
21422142
wm transient $window $origin
21432143
2144-
# Windows fails to place transient windows normally, so
2145-
# schedule a callback to center them on the parent.
2146-
if {[tk windowingsystem] eq {win32}} {
2144+
if {$geometry ne ""} {
2145+
after idle [list wm geometry $window $geometry]
2146+
} elseif {[tk windowingsystem] eq {win32}} {
2147+
# Windows fails to place transient windows normally, so
2148+
# schedule a callback to center them on the parent.
21472149
after idle [list tk::PlaceWindow $window widget $origin]
21482150
}
21492151
}
@@ -2730,17 +2732,9 @@ proc makewindow {} {
27302732
.pwbottom add .bright
27312733
.ctop add .pwbottom
27322734
2733-
# restore window width & height if known
2735+
# restore window position if known
27342736
if {[info exists geometry(main)]} {
2735-
if {[scan $geometry(main) "%dx%d" w h] >= 2} {
2736-
if {$w > [winfo screenwidth .]} {
2737-
set w [winfo screenwidth .]
2738-
}
2739-
if {$h > [winfo screenheight .]} {
2740-
set h [winfo screenheight .]
2741-
}
2742-
wm geometry . "${w}x$h"
2743-
}
2737+
wm geometry . "$geometry(main)"
27442738
}
27452739
27462740
if {[info exists geometry(state)] && $geometry(state) eq "zoomed"} {
@@ -3080,6 +3074,11 @@ proc savestuff {w} {
30803074
puts $f "set geometry(pwsash1) \"[.tf.histframe.pwclist sashpos 1] 1\""
30813075
puts $f "set geometry(botwidth) [winfo width .bleft]"
30823076
puts $f "set geometry(botheight) [winfo height .bleft]"
3077+
unset -nocomplain geometry
3078+
global geometry
3079+
if {[info exists geometry(showrefs)]} {
3080+
puts $f "set geometry(showrefs) $geometry(showrefs)"
3081+
}
30833082
30843083
array set view_save {}
30853084
array set views {}
@@ -10218,6 +10217,7 @@ proc rmbranch {} {
1021810217
proc showrefs {} {
1021910218
global showrefstop bgcolor fgcolor selectbgcolor
1022010219
global bglist fglist reflistfilter reflist maincursor
10220+
global geometry
1022110221
1022210222
set top .showrefs
1022310223
set showrefstop $top
@@ -10228,7 +10228,11 @@ proc showrefs {} {
1022810228
}
1022910229
ttk_toplevel $top
1023010230
wm title $top [mc "Tags and heads: %s" [file tail [pwd]]]
10231-
make_transient $top .
10231+
if {[info exists geometry(showrefs)]} {
10232+
make_transient $top . $geometry(showrefs)
10233+
} else {
10234+
make_transient $top .
10235+
}
1023210236
text $top.list -background $bgcolor -foreground $fgcolor \
1023310237
-selectbackground $selectbgcolor -font mainfont \
1023410238
-xscrollcommand "$top.xsb set" -yscrollcommand "$top.ysb set" \
@@ -10264,6 +10268,9 @@ proc showrefs {} {
1026410268
bind $top.list <ButtonRelease-1> {sel_reflist %W %x %y; break}
1026510269
set reflist {}
1026610270
refill_reflist
10271+
# avoid <Configure> being bound to child windows
10272+
bindtags $top [linsert [bindtags $top] 1 bind$top]
10273+
bind bind$top <Configure> {set geometry(showrefs) [wm geometry %W]}
1026710274
}
1026810275
1026910276
proc sel_reflist {w x y} {

0 commit comments

Comments
 (0)