* [PATCH v3 0/2] gitk: make Tags and Heads window geometry sticky @ 2025-09-28 13:54 Michael Rappazzo 2025-09-28 13:54 ` [PATCH v3 1/2] Revert "gitk: Only restore window size from ~/.gitk, not position" Michael Rappazzo 2025-09-28 13:54 ` [PATCH v3 2/2] gitk: make Tags and Heads window geometry sticky Michael Rappazzo 0 siblings, 2 replies; 12+ messages in thread From: Michael Rappazzo @ 2025-09-28 13:54 UTC (permalink / raw) To: git; +Cc: j6t, Michael Rappazzo Changes since v2: - replaced my commit to restore the window size and position with the commit that was already floating around from Hannes's repository. I included this because the next commit relies on it to work correctly in some environments. - split the manage_showrefs_geometry function into 2 functions. Johannes Sixt (1): Revert "gitk: Only restore window size from ~/.gitk, not position" Michael Rappazzo (1): gitk: make Tags and Heads window geometry sticky gitk | 51 +++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 12 deletions(-) -- 2.51.0 ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v3 1/2] Revert "gitk: Only restore window size from ~/.gitk, not position" 2025-09-28 13:54 [PATCH v3 0/2] gitk: make Tags and Heads window geometry sticky Michael Rappazzo @ 2025-09-28 13:54 ` Michael Rappazzo 2025-09-28 14:17 ` Mark Levedahl 2025-09-28 15:49 ` Junio C Hamano 2025-09-28 13:54 ` [PATCH v3 2/2] gitk: make Tags and Heads window geometry sticky Michael Rappazzo 1 sibling, 2 replies; 12+ messages in thread From: Michael Rappazzo @ 2025-09-28 13:54 UTC (permalink / raw) To: git; +Cc: j6t, Johannes Sixt, Mark Levedahl From: Johannes Sixt <johannes.sixt@telecom.at> This reverts commit b9bee11526ec23541ddbbd75716bfd1acc241463. The commit catered to an unsupportable port of the Windows Tcl/Tk stuck at 8.4.1 that was used by Cygwin. 8.4.1 has some bad bugs in its layout engine, and forced changes in Gitk to be compatible. All this became irrelevant around 2011 after Cygwin gained an X11 server and switched to a supportable port of the Unix/X11 Tcl/Tk (it is now on the current 8.6 code base). Helped-by: Mark Levedahl <mlevedahl@gmail.com> Signed-off-by: Johannes Sixt <j6t@kdbg.org> --- gitk | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/gitk b/gitk index 6e4d71d585..275f353811 100755 --- a/gitk +++ b/gitk @@ -2764,17 +2764,9 @@ proc makewindow {} { .pwbottom add .bright .ctop add .pwbottom - # restore window width & height if known + # restore window position if known if {[info exists geometry(main)]} { - if {[scan $geometry(main) "%dx%d" w h] >= 2} { - if {$w > [winfo screenwidth .]} { - set w [winfo screenwidth .] - } - if {$h > [winfo screenheight .]} { - set h [winfo screenheight .] - } - wm geometry . "${w}x$h" - } + wm geometry . "$geometry(main)" } if {[info exists geometry(state)] && $geometry(state) eq "zoomed"} { -- 2.51.0 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v3 1/2] Revert "gitk: Only restore window size from ~/.gitk, not position" 2025-09-28 13:54 ` [PATCH v3 1/2] Revert "gitk: Only restore window size from ~/.gitk, not position" Michael Rappazzo @ 2025-09-28 14:17 ` Mark Levedahl 2025-09-28 15:01 ` Mike Rappazzo 2025-10-17 16:36 ` Johannes Sixt 2025-09-28 15:49 ` Junio C Hamano 1 sibling, 2 replies; 12+ messages in thread From: Mark Levedahl @ 2025-09-28 14:17 UTC (permalink / raw) To: Michael Rappazzo, git; +Cc: j6t, Johannes Sixt On 9/28/25 9:54 AM, Michael Rappazzo wrote: > From: Johannes Sixt <johannes.sixt@telecom.at> > > This reverts commit b9bee11526ec23541ddbbd75716bfd1acc241463. > > The commit catered to an unsupportable port of the Windows Tcl/Tk > stuck at 8.4.1 that was used by Cygwin. 8.4.1 has some bad bugs in its > layout engine, and forced changes in Gitk to be compatible. All this > became irrelevant around 2011 after Cygwin gained an X11 server and > switched to a supportable port of the Unix/X11 Tcl/Tk (it is now on the > current 8.6 code base). > > Helped-by: Mark Levedahl <mlevedahl@gmail.com> > Signed-off-by: Johannes Sixt <j6t@kdbg.org> > --- > gitk | 12 ++---------- > 1 file changed, 2 insertions(+), 10 deletions(-) > > diff --git a/gitk b/gitk > index 6e4d71d585..275f353811 100755 > --- a/gitk > +++ b/gitk > @@ -2764,17 +2764,9 @@ proc makewindow {} { > .pwbottom add .bright > .ctop add .pwbottom > > - # restore window width & height if known > + # restore window position if known > if {[info exists geometry(main)]} { > - if {[scan $geometry(main) "%dx%d" w h] >= 2} { > - if {$w > [winfo screenwidth .]} { > - set w [winfo screenwidth .] > - } > - if {$h > [winfo screenheight .]} { > - set h [winfo screenheight .] > - } > - wm geometry . "${w}x$h" > - } > + wm geometry . "$geometry(main)" > } > > if {[info exists geometry(state)] && $geometry(state) eq "zoomed"} { I mis-interpreted an earlier inquiry about the patch being reverted here. Patch e9937d2a03 actually addressed the issues of Cygwin's 8.4.1 Tcl/Tk. Part of that was fixing the window geometry being restored, as sometimes the window manager would size the main window in a manner causing 8.4.1 to fail. But, this override of the main window manager on all platforms raised complaints on the mailing list, and commit b9bee11526 was the response: it was only the SIZE of the Window that mattered on Cygwin, not its location, so allowing window managers to set the location was ok. Personally, I'm fine with gitk remembering / restoring the full window geometry (I wrote it that way in e9937d2a03). Mark ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v3 1/2] Revert "gitk: Only restore window size from ~/.gitk, not position" 2025-09-28 14:17 ` Mark Levedahl @ 2025-09-28 15:01 ` Mike Rappazzo 2025-10-17 16:36 ` Johannes Sixt 1 sibling, 0 replies; 12+ messages in thread From: Mike Rappazzo @ 2025-09-28 15:01 UTC (permalink / raw) To: Mark Levedahl; +Cc: git, j6t, Johannes Sixt On Sun, Sep 28, 2025 at 10:17 AM Mark Levedahl <mlevedahl@gmail.com> wrote: > > On 9/28/25 9:54 AM, Michael Rappazzo wrote: > > From: Johannes Sixt <johannes.sixt@telecom.at> > > > > This reverts commit b9bee11526ec23541ddbbd75716bfd1acc241463. > > > > The commit catered to an unsupportable port of the Windows Tcl/Tk > > stuck at 8.4.1 that was used by Cygwin. 8.4.1 has some bad bugs in its > > layout engine, and forced changes in Gitk to be compatible. All this > > became irrelevant around 2011 after Cygwin gained an X11 server and > > switched to a supportable port of the Unix/X11 Tcl/Tk (it is now on the > > current 8.6 code base). > > > > Helped-by: Mark Levedahl <mlevedahl@gmail.com> > > Signed-off-by: Johannes Sixt <j6t@kdbg.org> > > --- > > gitk | 12 ++---------- > > 1 file changed, 2 insertions(+), 10 deletions(-) > > > > diff --git a/gitk b/gitk > > index 6e4d71d585..275f353811 100755 > > --- a/gitk > > +++ b/gitk > > @@ -2764,17 +2764,9 @@ proc makewindow {} { > > .pwbottom add .bright > > .ctop add .pwbottom > > > > - # restore window width & height if known > > + # restore window position if known > > if {[info exists geometry(main)]} { > > - if {[scan $geometry(main) "%dx%d" w h] >= 2} { > > - if {$w > [winfo screenwidth .]} { > > - set w [winfo screenwidth .] > > - } > > - if {$h > [winfo screenheight .]} { > > - set h [winfo screenheight .] > > - } > > - wm geometry . "${w}x$h" > > - } > > + wm geometry . "$geometry(main)" > > } > > > > if {[info exists geometry(state)] && $geometry(state) eq "zoomed"} { > I mis-interpreted an earlier inquiry about the patch being reverted here. Patch e9937d2a03 > actually addressed the issues of Cygwin's 8.4.1 Tcl/Tk. Part of that was fixing the window > geometry being restored, as sometimes the window manager would size the main window in a > manner causing 8.4.1 to fail. But, this override of the main window manager on all > platforms raised complaints on the mailing list, and commit b9bee11526 was the response: > it was only the SIZE of the Window that mattered on Cygwin, not its location, so allowing > window managers to set the location was ok. > > Personally, I'm fine with gitk remembering / restoring the full window geometry (I wrote > it that way in e9937d2a03). In my v2 version there is a slight difference: + after idle [list wm geometry . $geometry(main)] This seems likely related to my second patch changes where I use `after idle` due to the timing concerns which I reported on in my latest email from that series[1]. [1] https://lore.kernel.org/git/CANoM8SXnxxF6UMSfQ06ANfEv7HFCEEMCVoGgod1-DuFeHp6tXg@mail.gmail.com/T/#e1fc2a76267e3077c0de40ad8902e2158c00164e1 > > Mark ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v3 1/2] Revert "gitk: Only restore window size from ~/.gitk, not position" 2025-09-28 14:17 ` Mark Levedahl 2025-09-28 15:01 ` Mike Rappazzo @ 2025-10-17 16:36 ` Johannes Sixt 2025-10-17 19:27 ` Mark Levedahl 1 sibling, 1 reply; 12+ messages in thread From: Johannes Sixt @ 2025-10-17 16:36 UTC (permalink / raw) To: Mark Levedahl; +Cc: Michael Rappazzo, git Am 28.09.25 um 16:17 schrieb Mark Levedahl: > On 9/28/25 9:54 AM, Michael Rappazzo wrote: >> From: Johannes Sixt <johannes.sixt@telecom.at> >> >> This reverts commit b9bee11526ec23541ddbbd75716bfd1acc241463. >> >> The commit catered to an unsupportable port of the Windows Tcl/Tk >> stuck at 8.4.1 that was used by Cygwin. 8.4.1 has some bad bugs in its >> layout engine, and forced changes in Gitk to be compatible. All this >> became irrelevant around 2011 after Cygwin gained an X11 server and >> switched to a supportable port of the Unix/X11 Tcl/Tk (it is now on the >> current 8.6 code base). >> >> Helped-by: Mark Levedahl <mlevedahl@gmail.com> >> Signed-off-by: Johannes Sixt <j6t@kdbg.org> >> --- >> gitk | 12 ++---------- >> 1 file changed, 2 insertions(+), 10 deletions(-) >> >> diff --git a/gitk b/gitk >> index 6e4d71d585..275f353811 100755 >> --- a/gitk >> +++ b/gitk >> @@ -2764,17 +2764,9 @@ proc makewindow {} { >> .pwbottom add .bright >> .ctop add .pwbottom >> >> - # restore window width & height if known >> + # restore window position if known >> if {[info exists geometry(main)]} { >> - if {[scan $geometry(main) "%dx%d" w h] >= 2} { >> - if {$w > [winfo screenwidth .]} { >> - set w [winfo screenwidth .] >> - } >> - if {$h > [winfo screenheight .]} { >> - set h [winfo screenheight .] >> - } >> - wm geometry . "${w}x$h" >> - } >> + wm geometry . "$geometry(main)" >> } >> >> if {[info exists geometry(state)] && $geometry(state) eq "zoomed"} { > I mis-interpreted an earlier inquiry about the patch being reverted here. Patch e9937d2a03 > actually addressed the issues of Cygwin's 8.4.1 Tcl/Tk. Part of that was fixing the window > geometry being restored, as sometimes the window manager would size the main window in a > manner causing 8.4.1 to fail. But, this override of the main window manager on all > platforms raised complaints on the mailing list, and commit b9bee11526 was the response: > it was only the SIZE of the Window that mattered on Cygwin, not its location, so allowing > window managers to set the location was ok. > > Personally, I'm fine with gitk remembering / restoring the full window geometry (I wrote > it that way in e9937d2a03). Thank you for the hint. I found the thread, and after reading it I notice that the opposition is based on that restoring the position doesn't put the window on the desired monitor. I can't test this right now. I've rewritten the commit message as follows. Whether or not the position should be restored seems to be a personal preference, and the patch applies my and your preference, but obviously not everyone's. Please let me know whether I understood the situation correctly or not. Revert "gitk: Only restore window size from ~/.gitk, not position" This reverts commit b9bee11526ec (gitk: Only restore window size from ~/.gitk, not position, 2008-03-10). The earlier commit e9937d2a03a4 (Make gitk work reasonably well on Cygwin, 2007-02-01) reworked the window layout considerably. Much of this became irrelevant around 2011 after Cygwin gained an X11 server and switched to a supportable port of the Unix/X11 Tcl/Tk (it is now on the current 8.6 code base). Part of the necessary change was to restore the window size across sessions, but the position was also restored. This raised complaints on the mailing list[*], because Gitk was opened on the wrong monitor. b9bee11526ec was the compromise, because it was only the size that mattered for the Cygwin layout engine to work. I personally, find it annoying when Gitk pops up on a random location on the screen, in particular, since many other applications restore the window positions across sessions, so why not Gitk as well? (I do not operate multi-monitor setups, so I cannot test the case.) [*] https://lore.kernel.org/git/47AAA254.2020008@thorn.ws/ -- Hannes ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v3 1/2] Revert "gitk: Only restore window size from ~/.gitk, not position" 2025-10-17 16:36 ` Johannes Sixt @ 2025-10-17 19:27 ` Mark Levedahl 0 siblings, 0 replies; 12+ messages in thread From: Mark Levedahl @ 2025-10-17 19:27 UTC (permalink / raw) To: Johannes Sixt; +Cc: Michael Rappazzo, git On 10/17/25 12:36 PM, Johannes Sixt wrote: > Thank you for the hint. I found the thread, and after reading it I > notice that the opposition is based on that restoring the position > doesn't put the window on the desired monitor. I can't test this right > now. I've rewritten the commit message as follows. Whether or not the > position should be restored seems to be a personal preference, and the > patch applies my and your preference, but obviously not everyone's. > Please let me know whether I understood the situation correctly or not. > > -- Hannes > Your commit message accurately captures the issues as I understand them. I also cannot contribute on the multi-monitor setup, nor about the broader context wanting this patch. Mark ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v3 1/2] Revert "gitk: Only restore window size from ~/.gitk, not position" 2025-09-28 13:54 ` [PATCH v3 1/2] Revert "gitk: Only restore window size from ~/.gitk, not position" Michael Rappazzo 2025-09-28 14:17 ` Mark Levedahl @ 2025-09-28 15:49 ` Junio C Hamano 1 sibling, 0 replies; 12+ messages in thread From: Junio C Hamano @ 2025-09-28 15:49 UTC (permalink / raw) To: Michael Rappazzo; +Cc: git, j6t, Johannes Sixt, Mark Levedahl Michael Rappazzo <rappazzo@gmail.com> writes: > From: Johannes Sixt <johannes.sixt@telecom.at> > > This reverts commit b9bee11526ec23541ddbbd75716bfd1acc241463. If you wrote it like Revert b9bee115 (gitk: Only restore window size from ~/.gitk, not position, 2008-03-10). it would make it obvious that this is not a revert of a recent screwup, but historical wart carried from long time ago. > The commit catered to an unsupportable port of the Windows Tcl/Tk > stuck at 8.4.1 that was used by Cygwin. 8.4.1 has some bad bugs in its > layout engine, and forced changes in Gitk to be compatible. All this > became irrelevant around 2011 after Cygwin gained an X11 server and > switched to a supportable port of the Unix/X11 Tcl/Tk (it is now on the > current 8.6 code base). > > Helped-by: Mark Levedahl <mlevedahl@gmail.com> > Signed-off-by: Johannes Sixt <j6t@kdbg.org> > --- Very nice to see such a clean-up. ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v3 2/2] gitk: make Tags and Heads window geometry sticky 2025-09-28 13:54 [PATCH v3 0/2] gitk: make Tags and Heads window geometry sticky Michael Rappazzo 2025-09-28 13:54 ` [PATCH v3 1/2] Revert "gitk: Only restore window size from ~/.gitk, not position" Michael Rappazzo @ 2025-09-28 13:54 ` Michael Rappazzo 2025-09-28 15:57 ` Junio C Hamano 2025-10-04 17:36 ` Johannes Sixt 1 sibling, 2 replies; 12+ messages in thread From: Michael Rappazzo @ 2025-09-28 13:54 UTC (permalink / raw) To: git; +Cc: j6t, Michael Rappazzo Currently, the Tags and Heads window always opens at a default position and size, requiring users to reposition it each time. This patch makes the window remember its geometry between sessions. This change saves and restores the Tags and Heads window size and position relative to the main gitk window. The geometry is stored in the config file as `geometry(showrefs)` and persists between gitk sessions. The window position is stored relative to the main window, so it maintains the same spatial relationship when the main window is moved or when gitk is restarted on different monitors. Signed-off-by: Michael Rappazzo <rappazzo@gmail.com> --- gitk | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/gitk b/gitk index 275f353811..79a6dcdb4c 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]" + if {[winfo exists .showrefs]} { + puts $f "set geometry(showrefs) \"[wm geometry .showrefs]\"" + } elseif {[info exists geometry(showrefs)]} { + puts $f "set geometry(showrefs) \"$geometry(showrefs)\"" + } array set view_save {} array set views {} @@ -10199,11 +10204,13 @@ proc showrefs {} { if {[winfo exists $top]} { raise $top refill_reflist + wm protocol $top WM_DELETE_WINDOW [list destroy_showrefs $top] return } ttk_toplevel $top wm title $top [mc "Tags and heads: %s" [file tail [pwd]]] make_transient $top . + wm protocol $top WM_DELETE_WINDOW [list destroy_showrefs $top] text $top.list -background $bgcolor -foreground $fgcolor \ -selectbackground $selectbgcolor -font mainfont \ -xscrollcommand "$top.xsb set" -yscrollcommand "$top.ysb set" \ @@ -10229,8 +10236,8 @@ proc showrefs {} { ttk::checkbutton $top.sort -text [mc "Sort refs by type"] \ -variable sortrefsbytype -command {refill_reflist} grid $top.sort - -sticky w -pady 2 - ttk::button $top.close -command [list destroy $top] -text [mc "Close"] - bind $top <Key-Escape> [list destroy $top] + ttk::button $top.close -command [list destroy_showrefs $top] -text [mc "Close"] + bind $top <Key-Escape> [list destroy_showrefs $top] grid $top.close - grid columnconfigure $top 0 -weight 1 grid rowconfigure $top 0 -weight 1 @@ -10239,6 +10246,9 @@ proc showrefs {} { bind $top.list <ButtonRelease-1> {sel_reflist %W %x %y; break} set reflist {} refill_reflist + # Restore geometry after the window is fully created and mapped + # Delay Configure binding to avoid overwriting restored geometry + bind $top <Map> [list after idle [list setup_showrefs_geometry_tracking $top]] } proc sel_reflist {w x y} { @@ -10271,6 +10281,31 @@ proc reflistfilter_change {n1 n2 op} { after 200 refill_reflist } +proc save_showrefs_geometry {top} { + global geometry + if {[winfo exists $top]} { + set geometry(showrefs) [wm geometry $top] + } +} + +proc restore_showrefs_geometry {top} { + global geometry + if {[info exists geometry(showrefs)] && [winfo exists $top]} { + wm geometry $top $geometry(showrefs) + } +} + +proc setup_showrefs_geometry_tracking {top} { + restore_showrefs_geometry $top + bind $top <Configure> [list save_showrefs_geometry $top] +} + +proc destroy_showrefs {top} { + save_showrefs_geometry $top + savestuff . + destroy $top +} + proc refill_reflist {} { global reflist reflistfilter showrefstop headids tagids otherrefids sortrefsbytype global curview upstreamofref -- 2.51.0 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v3 2/2] gitk: make Tags and Heads window geometry sticky 2025-09-28 13:54 ` [PATCH v3 2/2] gitk: make Tags and Heads window geometry sticky Michael Rappazzo @ 2025-09-28 15:57 ` Junio C Hamano 2025-10-04 17:36 ` Johannes Sixt 1 sibling, 0 replies; 12+ messages in thread From: Junio C Hamano @ 2025-09-28 15:57 UTC (permalink / raw) To: Michael Rappazzo; +Cc: git, j6t Michael Rappazzo <rappazzo@gmail.com> writes: > Currently, the Tags and Heads window always opens at a default position > and size, requiring users to reposition it each time. This patch makes > the window remember its geometry between sessions. As the second patch in two-patch series, whose first step is a revert we just saw, it is unclear what state of the code "Currently" above refers to. Has it been that way even before the revert (in other words, even with the ancient Tcl/Tk 8.4.1 workaround), or have we briefly regressed with the previous step to fix it correctly and this is the right fix suitable for Tcl/Tk of the modern times? > This change saves and restores the Tags and Heads window size and position > relative to the main gitk window. The geometry is stored in the config file > as `geometry(showrefs)` and persists between gitk sessions. The window > position is stored relative to the main window, so it maintains the same > spatial relationship when the main window is moved or when gitk is restarted > on different monitors. > > Signed-off-by: Michael Rappazzo <rappazzo@gmail.com> > --- > gitk | 39 +++++++++++++++++++++++++++++++++++++-- > 1 file changed, 37 insertions(+), 2 deletions(-) Nice. Very well written explanation that tells why this is a good thing to do to those who do not even use gitk very often. As a pair of patches to an area with an official submaintainer, I won't touch them and instead expect them to be fed via a pull request once the reviews are done on them, but it still is appreciated to see patches sent here for reviews even when the submaintainer is part of the team that authored them. Thanks. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v3 2/2] gitk: make Tags and Heads window geometry sticky 2025-09-28 13:54 ` [PATCH v3 2/2] gitk: make Tags and Heads window geometry sticky Michael Rappazzo 2025-09-28 15:57 ` Junio C Hamano @ 2025-10-04 17:36 ` Johannes Sixt 2025-10-04 22:04 ` [PATCH] gitk: persist position and size of the Tags and Heads window Johannes Sixt 1 sibling, 1 reply; 12+ messages in thread From: Johannes Sixt @ 2025-10-04 17:36 UTC (permalink / raw) To: Michael Rappazzo; +Cc: git Am 28.09.25 um 15:54 schrieb Michael Rappazzo: > Currently, the Tags and Heads window always opens at a default position > and size, requiring users to reposition it each time. This patch makes > the window remember its geometry between sessions. > > This change saves and restores the Tags and Heads window size and position > relative to the main gitk window. The geometry is stored in the config file > as `geometry(showrefs)` and persists between gitk sessions. The window > position is stored relative to the main window, so it maintains the same > spatial relationship when the main window is moved or when gitk is restarted > on different monitors. > > Signed-off-by: Michael Rappazzo <rappazzo@gmail.com> > --- > gitk | 39 +++++++++++++++++++++++++++++++++++++-- > 1 file changed, 37 insertions(+), 2 deletions(-) > > diff --git a/gitk b/gitk > index 275f353811..79a6dcdb4c 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]" > + if {[winfo exists .showrefs]} { > + puts $f "set geometry(showrefs) \"[wm geometry .showrefs]\"" > + } elseif {[info exists geometry(showrefs)]} { > + puts $f "set geometry(showrefs) \"$geometry(showrefs)\"" > + } > > array set view_save {} > array set views {} > @@ -10199,11 +10204,13 @@ proc showrefs {} { > if {[winfo exists $top]} { > raise $top > refill_reflist > + wm protocol $top WM_DELETE_WINDOW [list destroy_showrefs $top] > return > } > ttk_toplevel $top > wm title $top [mc "Tags and heads: %s" [file tail [pwd]]] > make_transient $top . > + wm protocol $top WM_DELETE_WINDOW [list destroy_showrefs $top] > text $top.list -background $bgcolor -foreground $fgcolor \ > -selectbackground $selectbgcolor -font mainfont \ > -xscrollcommand "$top.xsb set" -yscrollcommand "$top.ysb set" \ > @@ -10229,8 +10236,8 @@ proc showrefs {} { > ttk::checkbutton $top.sort -text [mc "Sort refs by type"] \ > -variable sortrefsbytype -command {refill_reflist} > grid $top.sort - -sticky w -pady 2 > - ttk::button $top.close -command [list destroy $top] -text [mc "Close"] > - bind $top <Key-Escape> [list destroy $top] > + ttk::button $top.close -command [list destroy_showrefs $top] -text [mc "Close"] > + bind $top <Key-Escape> [list destroy_showrefs $top] > grid $top.close - > grid columnconfigure $top 0 -weight 1 > grid rowconfigure $top 0 -weight 1 > @@ -10239,6 +10246,9 @@ proc showrefs {} { > bind $top.list <ButtonRelease-1> {sel_reflist %W %x %y; break} > set reflist {} > refill_reflist > + # Restore geometry after the window is fully created and mapped > + # Delay Configure binding to avoid overwriting restored geometry > + bind $top <Map> [list after idle [list setup_showrefs_geometry_tracking $top]] > } > > proc sel_reflist {w x y} { > @@ -10271,6 +10281,31 @@ proc reflistfilter_change {n1 n2 op} { > after 200 refill_reflist > } > > +proc save_showrefs_geometry {top} { > + global geometry > + if {[winfo exists $top]} { > + set geometry(showrefs) [wm geometry $top] > + } > +} > + > +proc restore_showrefs_geometry {top} { > + global geometry > + if {[info exists geometry(showrefs)] && [winfo exists $top]} { > + wm geometry $top $geometry(showrefs) > + } > +} > + > +proc setup_showrefs_geometry_tracking {top} { > + restore_showrefs_geometry $top > + bind $top <Configure> [list save_showrefs_geometry $top] > +} > + > +proc destroy_showrefs {top} { > + save_showrefs_geometry $top > + savestuff . > + destroy $top > +} > + > proc refill_reflist {} { > global reflist reflistfilter showrefstop headids tagids otherrefids sortrefsbytype > global curview upstreamofref A patch should be much smaller than this. I was thinking along the lines of the below diff. However, 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. Nevertheless, within a session, the window geometry *is* preserved, just not across sessions. diff --git a/gitk b/gitk index 275f353..77d5acc 100755 --- a/gitk +++ b/gitk @@ -3058,7 +3058,7 @@ proc config_variable_change_cb {name name2 op} { } proc savestuff {w} { - global stuffsaved + global stuffsaved geometry global config_file config_file_tmp global config_variables config_variable_changed global viewchanged @@ -3106,6 +3106,9 @@ 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]" + if {[info exists geometry(showrefs)]} { + puts $f "set geometry(showrefs) \"$geometry(showrefs)\"" + } array set view_save {} array set views {} @@ -10193,6 +10196,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 +10243,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} { ^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH] gitk: persist position and size of the Tags and Heads window 2025-10-04 17:36 ` Johannes Sixt @ 2025-10-04 22:04 ` Johannes Sixt 2025-10-06 15:29 ` [PATCH v2] " Johannes Sixt 0 siblings, 1 reply; 12+ messages in thread From: Johannes Sixt @ 2025-10-04 22:04 UTC (permalink / raw) To: Michael Rappazzo; +Cc: git 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 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v2] gitk: persist position and size of the Tags and Heads window 2025-10-04 22:04 ` [PATCH] gitk: persist position and size of the Tags and Heads window Johannes Sixt @ 2025-10-06 15:29 ` Johannes Sixt 0 siblings, 0 replies; 12+ messages in thread From: Johannes Sixt @ 2025-10-06 15:29 UTC (permalink / raw) To: Michael Rappazzo; +Cc: git 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> --- Changes since v1: - On Windows, only the size was restored, but not the position. There is special logic for Windows that positions popup windows. Now we take this into account. gitk | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/gitk b/gitk index 275f353..ed61661 100755 --- a/gitk +++ b/gitk @@ -2131,12 +2131,14 @@ proc ttk_toplevel {w args} { return $w } -proc make_transient {window origin} { +proc make_transient {window origin {geometry ""}} { wm transient $window $origin - # Windows fails to place transient windows normally, so - # schedule a callback to center them on the parent. - if {[tk windowingsystem] eq {win32}} { + if {$geometry ne ""} { + after idle [list wm geometry $window $geometry] + } elseif {[tk windowingsystem] eq {win32}} { + # Windows fails to place transient windows normally, so + # schedule a callback to center them on the parent. after idle [list tk::PlaceWindow $window widget $origin] } } @@ -3106,6 +3108,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 +10200,7 @@ proc rmbranch {} { proc showrefs {} { global showrefstop bgcolor fgcolor selectbgcolor global bglist fglist reflistfilter reflist maincursor + global geometry set top .showrefs set showrefstop $top @@ -10203,7 +10211,11 @@ proc showrefs {} { } ttk_toplevel $top wm title $top [mc "Tags and heads: %s" [file tail [pwd]]] - make_transient $top . + if {[info exists geometry(showrefs)]} { + make_transient $top . $geometry(showrefs) + } else { + make_transient $top . + } text $top.list -background $bgcolor -foreground $fgcolor \ -selectbackground $selectbgcolor -font mainfont \ -xscrollcommand "$top.xsb set" -yscrollcommand "$top.ysb set" \ @@ -10239,6 +10251,9 @@ proc showrefs {} { bind $top.list <ButtonRelease-1> {sel_reflist %W %x %y; break} set reflist {} refill_reflist + # 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.431.g0f99086cdf ^ permalink raw reply related [flat|nested] 12+ messages in thread
end of thread, other threads:[~2025-10-17 19:27 UTC | newest] Thread overview: 12+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2025-09-28 13:54 [PATCH v3 0/2] gitk: make Tags and Heads window geometry sticky Michael Rappazzo 2025-09-28 13:54 ` [PATCH v3 1/2] Revert "gitk: Only restore window size from ~/.gitk, not position" Michael Rappazzo 2025-09-28 14:17 ` Mark Levedahl 2025-09-28 15:01 ` Mike Rappazzo 2025-10-17 16:36 ` Johannes Sixt 2025-10-17 19:27 ` Mark Levedahl 2025-09-28 15:49 ` Junio C Hamano 2025-09-28 13:54 ` [PATCH v3 2/2] gitk: make Tags and Heads window geometry sticky Michael Rappazzo 2025-09-28 15:57 ` Junio C Hamano 2025-10-04 17:36 ` Johannes Sixt 2025-10-04 22:04 ` [PATCH] gitk: persist position and size of the Tags and Heads window Johannes Sixt 2025-10-06 15:29 ` [PATCH v2] " Johannes Sixt
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).