Skip to content

Commit ed7b603

Browse files
snauryspearce
authored andcommitted
git-gui: store wm state and fix wm geometry
I often close git gui window when it is maximized, and when I reopen it next time the it would usually become out of place (e.g. a huge window with a top-left corner somewhere close to the center of the screen). Fix it by storing and restoring wm state in config, as well as setting wm state to normal before retrieving wm geometry info. Signed-off-by: Alexey Borzenkov <[email protected]> Signed-off-by: Shawn O. Pearce <[email protected]>
1 parent 118d938 commit ed7b603

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

git-gui.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2025,6 +2025,19 @@ proc do_quit {{rc {1}}} {
20252025
20262026
# -- Stash our current window geometry into this repository.
20272027
#
2028+
set cfg_wmstate [wm state .]
2029+
if {[catch {set rc_wmstate $repo_config(gui.wmstate)}]} {
2030+
set rc_wmstate {}
2031+
}
2032+
if {$cfg_wmstate ne $rc_wmstate} {
2033+
catch {git config gui.wmstate $cfg_wmstate}
2034+
}
2035+
if {$cfg_wmstate eq {zoomed}} {
2036+
# on Windows wm geometry will lie about window
2037+
# position (but not size) when window is zoomed
2038+
# restore the window before querying wm geometry
2039+
wm state . normal
2040+
}
20282041
set cfg_geometry [list]
20292042
lappend cfg_geometry [wm geometry .]
20302043
lappend cfg_geometry [lindex [.vpane sash coord 0] 0]
@@ -3264,6 +3277,14 @@ wm geometry . [lindex $gm 0]
32643277
unset gm
32653278
}
32663279
3280+
# -- Load window state
3281+
#
3282+
catch {
3283+
set gws $repo_config(gui.wmstate)
3284+
wm state . $gws
3285+
unset gws
3286+
}
3287+
32673288
# -- Key Bindings
32683289
#
32693290
bind $ui_comm <$M1B-Key-Return> {do_commit;break}

0 commit comments

Comments
 (0)