{"thread":{"id":"64220","subject":"[PATCH v3 0/2] gitk: make Tags and Heads window geometry sticky","startedAt":"2025-09-28T13:54:40Z","lastAt":"2025-10-17T19:27:53Z","messageCount":12,"participants":["Michael Rappazzo","Mark Levedahl","Mike Rappazzo","Junio C Hamano","Johannes Sixt"],"isPatch":true,"patchVersion":3,"patchTotal":2},"messages":[{"id":"527505","messageId":"20250928135435.59623-1-rappazzo@gmail.com","threadId":"64220","inReplyTo":null,"subject":"[PATCH v3 0/2] gitk: make Tags and Heads window geometry sticky","fromName":"Michael Rappazzo","fromEmail":"rappazzo@gmail.com","sentAt":"2025-09-28T13:54:33Z","receivedAt":"2025-09-28T13:54:40Z","isPatch":true,"sender":{"key":"rappazzo@gmail.com","avatar":"https://avatars.githubusercontent.com/u/525287?v=4"},"body":"Changes since v2:\n - replaced my commit to restore the window size and position with the\n   commit that was already floating around from Hannes's repository.  I\n   included this because the next commit relies on it to work correctly\n   in some environments.\n - split the manage_showrefs_geometry function into 2 functions.\n\nJohannes Sixt (1):\n  Revert \"gitk: Only restore window size from ~/.gitk, not position\"\n\nMichael Rappazzo (1):\n  gitk: make Tags and Heads window geometry sticky\n\n gitk | 51 +++++++++++++++++++++++++++++++++++++++------------\n 1 file changed, 39 insertions(+), 12 deletions(-)\n\n-- \n2.51.0\n\n"},{"id":"527506","messageId":"20250928135435.59623-2-rappazzo@gmail.com","threadId":"64220","inReplyTo":"20250928135435.59623-1-rappazzo@gmail.com","subject":"[PATCH v3 1/2] Revert \"gitk: Only restore window size from ~/.gitk, not position\"","fromName":"Michael Rappazzo","fromEmail":"rappazzo@gmail.com","sentAt":"2025-09-28T13:54:34Z","receivedAt":"2025-09-28T13:54:45Z","isPatch":true,"sender":{"key":"rappazzo@gmail.com","avatar":"https://avatars.githubusercontent.com/u/525287?v=4"},"body":"From: Johannes Sixt <johannes.sixt@telecom.at>\n\nThis reverts commit b9bee11526ec23541ddbbd75716bfd1acc241463.\n\nThe commit catered to an unsupportable port of the Windows Tcl/Tk\nstuck at 8.4.1 that was used by Cygwin. 8.4.1 has some bad bugs in its\nlayout engine, and forced changes in Gitk to be compatible. All this\nbecame irrelevant around 2011 after Cygwin gained an X11 server and\nswitched to a supportable port of the Unix/X11 Tcl/Tk (it is now on the\ncurrent 8.6 code base).\n\nHelped-by: Mark Levedahl <mlevedahl@gmail.com>\nSigned-off-by: Johannes Sixt <j6t@kdbg.org>\n---\n gitk | 12 ++----------\n 1 file changed, 2 insertions(+), 10 deletions(-)\n\ndiff --git a/gitk b/gitk\nindex 6e4d71d585..275f353811 100755\n--- a/gitk\n+++ b/gitk\n@@ -2764,17 +2764,9 @@ proc makewindow {} {\n     .pwbottom add .bright\n     .ctop add .pwbottom\n \n-    # restore window width & height if known\n+    # restore window position if known\n     if {[info exists geometry(main)]} {\n-        if {[scan $geometry(main) \"%dx%d\" w h] >= 2} {\n-            if {$w > [winfo screenwidth .]} {\n-                set w [winfo screenwidth .]\n-            }\n-            if {$h > [winfo screenheight .]} {\n-                set h [winfo screenheight .]\n-            }\n-            wm geometry . \"${w}x$h\"\n-        }\n+        wm geometry . \"$geometry(main)\"\n     }\n \n     if {[info exists geometry(state)] && $geometry(state) eq \"zoomed\"} {\n-- \n2.51.0\n\n"},{"id":"527507","messageId":"20250928135435.59623-3-rappazzo@gmail.com","threadId":"64220","inReplyTo":"20250928135435.59623-1-rappazzo@gmail.com","subject":"[PATCH v3 2/2] gitk: make Tags and Heads window geometry sticky","fromName":"Michael Rappazzo","fromEmail":"rappazzo@gmail.com","sentAt":"2025-09-28T13:54:35Z","receivedAt":"2025-09-28T13:54:47Z","isPatch":true,"sender":{"key":"rappazzo@gmail.com","avatar":"https://avatars.githubusercontent.com/u/525287?v=4"},"body":"Currently, the Tags and Heads window always opens at a default position\nand size, requiring users to reposition it each time. This patch makes\nthe window remember its geometry between sessions.\n\nThis change saves and restores the Tags and Heads window size and position\nrelative to the main gitk window. The geometry is stored in the config file\nas `geometry(showrefs)` and persists between gitk sessions. The window\nposition is stored relative to the main window, so it maintains the same\nspatial relationship when the main window is moved or when gitk is restarted\non different monitors.\n\nSigned-off-by: Michael Rappazzo <rappazzo@gmail.com>\n---\n gitk | 39 +++++++++++++++++++++++++++++++++++++--\n 1 file changed, 37 insertions(+), 2 deletions(-)\n\ndiff --git a/gitk b/gitk\nindex 275f353811..79a6dcdb4c 100755\n--- a/gitk\n+++ b/gitk\n@@ -3106,6 +3106,11 @@ proc savestuff {w} {\n         puts $f \"set geometry(pwsash1) \\\"[.tf.histframe.pwclist sashpos 1] 1\\\"\"\n         puts $f \"set geometry(botwidth) [winfo width .bleft]\"\n         puts $f \"set geometry(botheight) [winfo height .bleft]\"\n+        if {[winfo exists .showrefs]} {\n+            puts $f \"set geometry(showrefs) \\\"[wm geometry .showrefs]\\\"\"\n+        } elseif {[info exists geometry(showrefs)]} {\n+            puts $f \"set geometry(showrefs) \\\"$geometry(showrefs)\\\"\"\n+        }\n \n         array set view_save {}\n         array set views {}\n@@ -10199,11 +10204,13 @@ proc showrefs {} {\n     if {[winfo exists $top]} {\n         raise $top\n         refill_reflist\n+        wm protocol $top WM_DELETE_WINDOW [list destroy_showrefs $top]\n         return\n     }\n     ttk_toplevel $top\n     wm title $top [mc \"Tags and heads: %s\" [file tail [pwd]]]\n     make_transient $top .\n+    wm protocol $top WM_DELETE_WINDOW [list destroy_showrefs $top]\n     text $top.list -background $bgcolor -foreground $fgcolor \\\n         -selectbackground $selectbgcolor -font mainfont \\\n         -xscrollcommand \"$top.xsb set\" -yscrollcommand \"$top.ysb set\" \\\n@@ -10229,8 +10236,8 @@ proc showrefs {} {\n     ttk::checkbutton $top.sort -text [mc \"Sort refs by type\"] \\\n         -variable sortrefsbytype -command {refill_reflist}\n     grid $top.sort - -sticky w -pady 2\n-    ttk::button $top.close -command [list destroy $top] -text [mc \"Close\"]\n-    bind $top <Key-Escape> [list destroy $top]\n+    ttk::button $top.close -command [list destroy_showrefs $top] -text [mc \"Close\"]\n+    bind $top <Key-Escape> [list destroy_showrefs $top]\n     grid $top.close -\n     grid columnconfigure $top 0 -weight 1\n     grid rowconfigure $top 0 -weight 1\n@@ -10239,6 +10246,9 @@ proc showrefs {} {\n     bind $top.list <ButtonRelease-1> {sel_reflist %W %x %y; break}\n     set reflist {}\n     refill_reflist\n+    # Restore geometry after the window is fully created and mapped\n+    # Delay Configure binding to avoid overwriting restored geometry\n+    bind $top <Map> [list after idle [list setup_showrefs_geometry_tracking $top]]\n }\n \n proc sel_reflist {w x y} {\n@@ -10271,6 +10281,31 @@ proc reflistfilter_change {n1 n2 op} {\n     after 200 refill_reflist\n }\n \n+proc save_showrefs_geometry {top} {\n+    global geometry\n+    if {[winfo exists $top]} {\n+        set geometry(showrefs) [wm geometry $top]\n+    }\n+}\n+\n+proc restore_showrefs_geometry {top} {\n+    global geometry\n+    if {[info exists geometry(showrefs)] && [winfo exists $top]} {\n+        wm geometry $top $geometry(showrefs)\n+    }\n+}\n+\n+proc setup_showrefs_geometry_tracking {top} {\n+    restore_showrefs_geometry $top\n+    bind $top <Configure> [list save_showrefs_geometry $top]\n+}\n+\n+proc destroy_showrefs {top} {\n+    save_showrefs_geometry $top\n+    savestuff .\n+    destroy $top\n+}\n+\n proc refill_reflist {} {\n     global reflist reflistfilter showrefstop headids tagids otherrefids sortrefsbytype\n     global curview upstreamofref\n-- \n2.51.0\n\n"},{"id":"527510","messageId":"be1e6cba-c94d-4c2f-ab68-e368ffe9daa5@gmail.com","threadId":"64220","inReplyTo":"20250928135435.59623-2-rappazzo@gmail.com","subject":"Re: [PATCH v3 1/2] Revert \"gitk: Only restore window size from ~/.gitk, not position\"","fromName":"Mark Levedahl","fromEmail":"mlevedahl@gmail.com","sentAt":"2025-09-28T14:17:06Z","receivedAt":"2025-09-28T14:17:08Z","isPatch":true,"sender":{"key":"mdl123@verizon.net","avatar":"https://avatars.githubusercontent.com/u/5302462?v=4"},"body":"On 9/28/25 9:54 AM, Michael Rappazzo wrote:\n> From: Johannes Sixt <johannes.sixt@telecom.at>\n>\n> This reverts commit b9bee11526ec23541ddbbd75716bfd1acc241463.\n>\n> The commit catered to an unsupportable port of the Windows Tcl/Tk\n> stuck at 8.4.1 that was used by Cygwin. 8.4.1 has some bad bugs in its\n> layout engine, and forced changes in Gitk to be compatible. All this\n> became irrelevant around 2011 after Cygwin gained an X11 server and\n> switched to a supportable port of the Unix/X11 Tcl/Tk (it is now on the\n> current 8.6 code base).\n>\n> Helped-by: Mark Levedahl <mlevedahl@gmail.com>\n> Signed-off-by: Johannes Sixt <j6t@kdbg.org>\n> ---\n>  gitk | 12 ++----------\n>  1 file changed, 2 insertions(+), 10 deletions(-)\n>\n> diff --git a/gitk b/gitk\n> index 6e4d71d585..275f353811 100755\n> --- a/gitk\n> +++ b/gitk\n> @@ -2764,17 +2764,9 @@ proc makewindow {} {\n>      .pwbottom add .bright\n>      .ctop add .pwbottom\n>  \n> -    # restore window width & height if known\n> +    # restore window position if known\n>      if {[info exists geometry(main)]} {\n> -        if {[scan $geometry(main) \"%dx%d\" w h] >= 2} {\n> -            if {$w > [winfo screenwidth .]} {\n> -                set w [winfo screenwidth .]\n> -            }\n> -            if {$h > [winfo screenheight .]} {\n> -                set h [winfo screenheight .]\n> -            }\n> -            wm geometry . \"${w}x$h\"\n> -        }\n> +        wm geometry . \"$geometry(main)\"\n>      }\n>  \n>      if {[info exists geometry(state)] && $geometry(state) eq \"zoomed\"} {\nI mis-interpreted an earlier inquiry about the patch being reverted here. Patch e9937d2a03\nactually addressed the issues of Cygwin's 8.4.1 Tcl/Tk. Part of that was fixing the window\ngeometry being restored, as sometimes the window manager would size the main window in a\nmanner causing 8.4.1 to fail. But, this override of the main window manager on all\nplatforms raised complaints on the mailing list, and commit b9bee11526 was the response:\nit was only the SIZE of the Window that mattered on Cygwin, not its location, so allowing\nwindow managers to set the location was ok.\n\nPersonally, I'm fine with gitk remembering / restoring the full window geometry (I wrote\nit that way in e9937d2a03).\n\nMark\n"},{"id":"527511","messageId":"CANoM8SWT4atDtFDgMvx5ivun9-sXZCsmT6gUG07byYOB0+2DFw@mail.gmail.com","threadId":"64220","inReplyTo":"be1e6cba-c94d-4c2f-ab68-e368ffe9daa5@gmail.com","subject":"Re: [PATCH v3 1/2] Revert \"gitk: Only restore window size from ~/.gitk, not position\"","fromName":"Mike Rappazzo","fromEmail":"rappazzo@gmail.com","sentAt":"2025-09-28T15:01:02Z","receivedAt":"2025-09-28T15:01:16Z","isPatch":true,"sender":{"key":"rappazzo@gmail.com","avatar":"https://avatars.githubusercontent.com/u/525287?v=4"},"body":"On Sun, Sep 28, 2025 at 10:17 AM Mark Levedahl <mlevedahl@gmail.com> wrote:\n>\n> On 9/28/25 9:54 AM, Michael Rappazzo wrote:\n> > From: Johannes Sixt <johannes.sixt@telecom.at>\n> >\n> > This reverts commit b9bee11526ec23541ddbbd75716bfd1acc241463.\n> >\n> > The commit catered to an unsupportable port of the Windows Tcl/Tk\n> > stuck at 8.4.1 that was used by Cygwin. 8.4.1 has some bad bugs in its\n> > layout engine, and forced changes in Gitk to be compatible. All this\n> > became irrelevant around 2011 after Cygwin gained an X11 server and\n> > switched to a supportable port of the Unix/X11 Tcl/Tk (it is now on the\n> > current 8.6 code base).\n> >\n> > Helped-by: Mark Levedahl <mlevedahl@gmail.com>\n> > Signed-off-by: Johannes Sixt <j6t@kdbg.org>\n> > ---\n> >  gitk | 12 ++----------\n> >  1 file changed, 2 insertions(+), 10 deletions(-)\n> >\n> > diff --git a/gitk b/gitk\n> > index 6e4d71d585..275f353811 100755\n> > --- a/gitk\n> > +++ b/gitk\n> > @@ -2764,17 +2764,9 @@ proc makewindow {} {\n> >      .pwbottom add .bright\n> >      .ctop add .pwbottom\n> >\n> > -    # restore window width & height if known\n> > +    # restore window position if known\n> >      if {[info exists geometry(main)]} {\n> > -        if {[scan $geometry(main) \"%dx%d\" w h] >= 2} {\n> > -            if {$w > [winfo screenwidth .]} {\n> > -                set w [winfo screenwidth .]\n> > -            }\n> > -            if {$h > [winfo screenheight .]} {\n> > -                set h [winfo screenheight .]\n> > -            }\n> > -            wm geometry . \"${w}x$h\"\n> > -        }\n> > +        wm geometry . \"$geometry(main)\"\n> >      }\n> >\n> >      if {[info exists geometry(state)] && $geometry(state) eq \"zoomed\"} {\n> I mis-interpreted an earlier inquiry about the patch being reverted here. Patch e9937d2a03\n> actually addressed the issues of Cygwin's 8.4.1 Tcl/Tk. Part of that was fixing the window\n> geometry being restored, as sometimes the window manager would size the main window in a\n> manner causing 8.4.1 to fail. But, this override of the main window manager on all\n> platforms raised complaints on the mailing list, and commit b9bee11526 was the response:\n> it was only the SIZE of the Window that mattered on Cygwin, not its location, so allowing\n> window managers to set the location was ok.\n>\n> Personally, I'm fine with gitk remembering / restoring the full window geometry (I wrote\n> it that way in e9937d2a03).\n\nIn my v2 version there is a slight difference:\n+        after idle [list wm geometry . $geometry(main)]\n\nThis seems likely related to my second patch changes where I use `after\nidle` due to the timing concerns which I reported on in my latest email\nfrom that series[1].\n\n[1] https://lore.kernel.org/git/CANoM8SXnxxF6UMSfQ06ANfEv7HFCEEMCVoGgod1-DuFeHp6tXg@mail.gmail.com/T/#e1fc2a76267e3077c0de40ad8902e2158c00164e1\n\n\n>\n> Mark\n"},{"id":"527514","messageId":"xmqqh5wm7f2q.fsf@gitster.g","threadId":"64220","inReplyTo":"20250928135435.59623-2-rappazzo@gmail.com","subject":"Re: [PATCH v3 1/2] Revert \"gitk: Only restore window size from ~/.gitk, not position\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-09-28T15:49:01Z","receivedAt":"2025-09-28T15:49:05Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael Rappazzo <rappazzo@gmail.com> writes:\n\n> From: Johannes Sixt <johannes.sixt@telecom.at>\n>\n> This reverts commit b9bee11526ec23541ddbbd75716bfd1acc241463.\n\nIf you wrote it like\n\n    Revert b9bee115 (gitk: Only restore window size from ~/.gitk,\n    not position, 2008-03-10).\n\nit would make it obvious that this is not a revert of a recent\nscrewup, but historical wart carried from long time ago.\n\n> The commit catered to an unsupportable port of the Windows Tcl/Tk\n> stuck at 8.4.1 that was used by Cygwin. 8.4.1 has some bad bugs in its\n> layout engine, and forced changes in Gitk to be compatible. All this\n> became irrelevant around 2011 after Cygwin gained an X11 server and\n> switched to a supportable port of the Unix/X11 Tcl/Tk (it is now on the\n> current 8.6 code base).\n>\n> Helped-by: Mark Levedahl <mlevedahl@gmail.com>\n> Signed-off-by: Johannes Sixt <j6t@kdbg.org>\n> ---\n\nVery nice to see such a clean-up.\n"},{"id":"527515","messageId":"xmqqbjmu7eo8.fsf@gitster.g","threadId":"64220","inReplyTo":"20250928135435.59623-3-rappazzo@gmail.com","subject":"Re: [PATCH v3 2/2] gitk: make Tags and Heads window geometry sticky","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-09-28T15:57:43Z","receivedAt":"2025-09-28T15:57:46Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael Rappazzo <rappazzo@gmail.com> writes:\n\n> Currently, the Tags and Heads window always opens at a default position\n> and size, requiring users to reposition it each time. This patch makes\n> the window remember its geometry between sessions.\n\nAs the second patch in two-patch series, whose first step is a\nrevert we just saw, it is unclear what state of the code \"Currently\"\nabove refers to.  Has it been that way even before the revert (in\nother words, even with the ancient Tcl/Tk 8.4.1 workaround), or have\nwe briefly regressed with the previous step to fix it correctly and\nthis is the right fix suitable for Tcl/Tk of the modern times?\n\n> This change saves and restores the Tags and Heads window size and position\n> relative to the main gitk window. The geometry is stored in the config file\n> as `geometry(showrefs)` and persists between gitk sessions. The window\n> position is stored relative to the main window, so it maintains the same\n> spatial relationship when the main window is moved or when gitk is restarted\n> on different monitors.\n>\n> Signed-off-by: Michael Rappazzo <rappazzo@gmail.com>\n> ---\n>  gitk | 39 +++++++++++++++++++++++++++++++++++++--\n>  1 file changed, 37 insertions(+), 2 deletions(-)\n\nNice.  Very well written explanation that tells why this is a good\nthing to do to those who do not even use gitk very often.\n\nAs a pair of patches to an area with an official submaintainer, I\nwon't touch them and instead expect them to be fed via a pull\nrequest once the reviews are done on them, but it still is\nappreciated to see patches sent here for reviews even when the\nsubmaintainer is part of the team that authored them.\n\nThanks.\n"},{"id":"527919","messageId":"fd6450e2-cf56-4b99-b0ed-37a174d7ce9c@kdbg.org","threadId":"64220","inReplyTo":"20250928135435.59623-3-rappazzo@gmail.com","subject":"Re: [PATCH v3 2/2] gitk: make Tags and Heads window geometry sticky","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2025-10-04T17:36:35Z","receivedAt":"2025-10-04T18:25:42Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 28.09.25 um 15:54 schrieb Michael Rappazzo:\n> Currently, the Tags and Heads window always opens at a default position\n> and size, requiring users to reposition it each time. This patch makes\n> the window remember its geometry between sessions.\n> \n> This change saves and restores the Tags and Heads window size and position\n> relative to the main gitk window. The geometry is stored in the config file\n> as `geometry(showrefs)` and persists between gitk sessions. The window\n> position is stored relative to the main window, so it maintains the same\n> spatial relationship when the main window is moved or when gitk is restarted\n> on different monitors.\n> \n> Signed-off-by: Michael Rappazzo <rappazzo@gmail.com>\n> ---\n>  gitk | 39 +++++++++++++++++++++++++++++++++++++--\n>  1 file changed, 37 insertions(+), 2 deletions(-)\n> \n> diff --git a/gitk b/gitk\n> index 275f353811..79a6dcdb4c 100755\n> --- a/gitk\n> +++ b/gitk\n> @@ -3106,6 +3106,11 @@ proc savestuff {w} {\n>          puts $f \"set geometry(pwsash1) \\\"[.tf.histframe.pwclist sashpos 1] 1\\\"\"\n>          puts $f \"set geometry(botwidth) [winfo width .bleft]\"\n>          puts $f \"set geometry(botheight) [winfo height .bleft]\"\n> +        if {[winfo exists .showrefs]} {\n> +            puts $f \"set geometry(showrefs) \\\"[wm geometry .showrefs]\\\"\"\n> +        } elseif {[info exists geometry(showrefs)]} {\n> +            puts $f \"set geometry(showrefs) \\\"$geometry(showrefs)\\\"\"\n> +        }\n>  \n>          array set view_save {}\n>          array set views {}\n> @@ -10199,11 +10204,13 @@ proc showrefs {} {\n>      if {[winfo exists $top]} {\n>          raise $top\n>          refill_reflist\n> +        wm protocol $top WM_DELETE_WINDOW [list destroy_showrefs $top]\n>          return\n>      }\n>      ttk_toplevel $top\n>      wm title $top [mc \"Tags and heads: %s\" [file tail [pwd]]]\n>      make_transient $top .\n> +    wm protocol $top WM_DELETE_WINDOW [list destroy_showrefs $top]\n>      text $top.list -background $bgcolor -foreground $fgcolor \\\n>          -selectbackground $selectbgcolor -font mainfont \\\n>          -xscrollcommand \"$top.xsb set\" -yscrollcommand \"$top.ysb set\" \\\n> @@ -10229,8 +10236,8 @@ proc showrefs {} {\n>      ttk::checkbutton $top.sort -text [mc \"Sort refs by type\"] \\\n>          -variable sortrefsbytype -command {refill_reflist}\n>      grid $top.sort - -sticky w -pady 2\n> -    ttk::button $top.close -command [list destroy $top] -text [mc \"Close\"]\n> -    bind $top <Key-Escape> [list destroy $top]\n> +    ttk::button $top.close -command [list destroy_showrefs $top] -text [mc \"Close\"]\n> +    bind $top <Key-Escape> [list destroy_showrefs $top]\n>      grid $top.close -\n>      grid columnconfigure $top 0 -weight 1\n>      grid rowconfigure $top 0 -weight 1\n> @@ -10239,6 +10246,9 @@ proc showrefs {} {\n>      bind $top.list <ButtonRelease-1> {sel_reflist %W %x %y; break}\n>      set reflist {}\n>      refill_reflist\n> +    # Restore geometry after the window is fully created and mapped\n> +    # Delay Configure binding to avoid overwriting restored geometry\n> +    bind $top <Map> [list after idle [list setup_showrefs_geometry_tracking $top]]\n>  }\n>  \n>  proc sel_reflist {w x y} {\n> @@ -10271,6 +10281,31 @@ proc reflistfilter_change {n1 n2 op} {\n>      after 200 refill_reflist\n>  }\n>  \n> +proc save_showrefs_geometry {top} {\n> +    global geometry\n> +    if {[winfo exists $top]} {\n> +        set geometry(showrefs) [wm geometry $top]\n> +    }\n> +}\n> +\n> +proc restore_showrefs_geometry {top} {\n> +    global geometry\n> +    if {[info exists geometry(showrefs)] && [winfo exists $top]} {\n> +        wm geometry $top $geometry(showrefs)\n> +    }\n> +}\n> +\n> +proc setup_showrefs_geometry_tracking {top} {\n> +    restore_showrefs_geometry $top\n> +    bind $top <Configure> [list save_showrefs_geometry $top]\n> +}\n> +\n> +proc destroy_showrefs {top} {\n> +    save_showrefs_geometry $top\n> +    savestuff .\n> +    destroy $top\n> +}\n> +\n>  proc refill_reflist {} {\n>      global reflist reflistfilter showrefstop headids tagids otherrefids sortrefsbytype\n>      global curview upstreamofref\n\nA patch should be much smaller than this. I was thinking along the lines\nof the below diff. However, it doesn't work for some reason: the\nvariable that is updated from the Configure handler is not the same that\nis serialized in proc savestuff, and I don't know why. Nevertheless,\nwithin a session, the window geometry *is* preserved, just not across\nsessions.\n\n\ndiff --git a/gitk b/gitk\nindex 275f353..77d5acc 100755\n--- a/gitk\n+++ b/gitk\n@@ -3058,7 +3058,7 @@ proc config_variable_change_cb {name name2 op} {\n }\n\n proc savestuff {w} {\n-    global stuffsaved\n+    global stuffsaved geometry\n     global config_file config_file_tmp\n     global config_variables config_variable_changed\n     global viewchanged\n@@ -3106,6 +3106,9 @@ proc savestuff {w} {\n         puts $f \"set geometry(pwsash1) \\\"[.tf.histframe.pwclist sashpos\n1] 1\\\"\"\n         puts $f \"set geometry(botwidth) [winfo width .bleft]\"\n         puts $f \"set geometry(botheight) [winfo height .bleft]\"\n+        if {[info exists geometry(showrefs)]} {\n+            puts $f \"set geometry(showrefs) \\\"$geometry(showrefs)\\\"\"\n+        }\n\n         array set view_save {}\n         array set views {}\n@@ -10193,6 +10196,7 @@ proc rmbranch {} {\n proc showrefs {} {\n     global showrefstop bgcolor fgcolor selectbgcolor\n     global bglist fglist reflistfilter reflist maincursor\n+    global geometry\n\n     set top .showrefs\n     set showrefstop $top\n@@ -10239,6 +10243,12 @@ proc showrefs {} {\n     bind $top.list <ButtonRelease-1> {sel_reflist %W %x %y; break}\n     set reflist {}\n     refill_reflist\n+    if {[info exists geometry(showrefs)]} {\n+        after idle [list wm geometry $top $geometry(showrefs)]\n+    }\n+    # avoid <Configure> being bound to child windows\n+    bindtags $top [linsert [bindtags $top] 1 bind$top]\n+    bind bind$top <Configure> {set geometry(showrefs) [wm geometry %W]}\n }\n\n proc sel_reflist {w x y} {\n\n"},{"id":"527920","messageId":"941180e0-d8a1-4f2b-a0d8-2128428b36d8@kdbg.org","threadId":"64220","inReplyTo":"fd6450e2-cf56-4b99-b0ed-37a174d7ce9c@kdbg.org","subject":"[PATCH] gitk: persist position and size of the Tags and Heads window","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2025-10-04T22:04:41Z","receivedAt":"2025-10-04T22:04:53Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"The Tags and Heads window always opens at a default position and size,\nrequiring users to reposition it each time. Remember its geometry\nbetween sessions in the config file as `geometry(showrefs)`.\n\nNote that the existing configuration is sourced in proc savestuff\nright before new settings are written. This makes the old settings\navailable as local variables(!) and does not overwrite the current\nsettings. Since we need access to the global geometry(showrefs), it\nis necessary to unset the local variable.\n\nHelped-by: Michael Rappazzo <rappazzo@gmail.com>\nSigned-off-by: Johannes Sixt <j6t@kdbg.org>\n---\nAm 04.10.25 um 19:36 schrieb Johannes Sixt:\n> ... it doesn't work for some reason: the\n> variable that is updated from the Configure handler is not the same that\n> is serialized in proc savestuff, and I don't know why.\n\nVery simple: the old settings are sourced before being written out again\nand overwrite the current setting. But things turn out to be more sutle\nthan that. See above and below.\n\n gitk | 12 ++++++++++++\n 1 file changed, 12 insertions(+)\n\ndiff --git a/gitk b/gitk\nindex 275f353..6deaa3a 100755\n--- a/gitk\n+++ b/gitk\n@@ -3106,6 +3106,11 @@ proc savestuff {w} {\n         puts $f \"set geometry(pwsash1) \\\"[.tf.histframe.pwclist sashpos 1] 1\\\"\"\n         puts $f \"set geometry(botwidth) [winfo width .bleft]\"\n         puts $f \"set geometry(botheight) [winfo height .bleft]\"\n+        unset -nocomplain geometry\n+        global geometry\n+        if {[info exists geometry(showrefs)]} {\n+            puts $f \"set geometry(showrefs) $geometry(showrefs)\"\n+        }\n \n         array set view_save {}\n         array set views {}\n@@ -10193,6 +10198,7 @@ proc rmbranch {} {\n proc showrefs {} {\n     global showrefstop bgcolor fgcolor selectbgcolor\n     global bglist fglist reflistfilter reflist maincursor\n+    global geometry\n \n     set top .showrefs\n     set showrefstop $top\n@@ -10239,6 +10245,12 @@ proc showrefs {} {\n     bind $top.list <ButtonRelease-1> {sel_reflist %W %x %y; break}\n     set reflist {}\n     refill_reflist\n+    if {[info exists geometry(showrefs)]} {\n+        after idle [list wm geometry $top $geometry(showrefs)]\n+    }\n+    # avoid <Configure> being bound to child windows\n+    bindtags $top [linsert [bindtags $top] 1 bind$top]\n+    bind bind$top <Configure> {set geometry(showrefs) [wm geometry %W]}\n }\n \n proc sel_reflist {w x y} {\n-- \n2.51.0.427.g504992c71c\n\n"},{"id":"527989","messageId":"e999c9d2-01d2-4569-ab32-2922ded29dcf@kdbg.org","threadId":"64220","inReplyTo":"941180e0-d8a1-4f2b-a0d8-2128428b36d8@kdbg.org","subject":"[PATCH v2] gitk: persist position and size of the Tags and Heads window","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2025-10-06T15:29:53Z","receivedAt":"2025-10-06T15:30:02Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"The Tags and Heads window always opens at a default position and size,\nrequiring users to reposition it each time. Remember its geometry\nbetween sessions in the config file as `geometry(showrefs)`.\n\nNote that the existing configuration is sourced in proc savestuff\nright before new settings are written. This makes the old settings\navailable as local variables(!) and does not overwrite the current\nsettings. Since we need access to the global geometry(showrefs), it\nis necessary to unset the local variable.\n\nHelped-by: Michael Rappazzo <rappazzo@gmail.com>\nSigned-off-by: Johannes Sixt <j6t@kdbg.org>\n---\nChanges since v1:\n- On Windows, only the size was restored, but not the position. There is\n  special logic for Windows that positions popup windows. Now we take\n  this into account.\n\n gitk | 25 ++++++++++++++++++++-----\n 1 file changed, 20 insertions(+), 5 deletions(-)\n\ndiff --git a/gitk b/gitk\nindex 275f353..ed61661 100755\n--- a/gitk\n+++ b/gitk\n@@ -2131,12 +2131,14 @@ proc ttk_toplevel {w args} {\n     return $w\n }\n \n-proc make_transient {window origin} {\n+proc make_transient {window origin {geometry \"\"}} {\n     wm transient $window $origin\n \n-    # Windows fails to place transient windows normally, so\n-    # schedule a callback to center them on the parent.\n-    if {[tk windowingsystem] eq {win32}} {\n+    if {$geometry ne \"\"} {\n+        after idle [list wm geometry $window $geometry]\n+    } elseif {[tk windowingsystem] eq {win32}} {\n+        # Windows fails to place transient windows normally, so\n+        # schedule a callback to center them on the parent.\n         after idle [list tk::PlaceWindow $window widget $origin]\n     }\n }\n@@ -3106,6 +3108,11 @@ proc savestuff {w} {\n         puts $f \"set geometry(pwsash1) \\\"[.tf.histframe.pwclist sashpos 1] 1\\\"\"\n         puts $f \"set geometry(botwidth) [winfo width .bleft]\"\n         puts $f \"set geometry(botheight) [winfo height .bleft]\"\n+        unset -nocomplain geometry\n+        global geometry\n+        if {[info exists geometry(showrefs)]} {\n+            puts $f \"set geometry(showrefs) $geometry(showrefs)\"\n+        }\n \n         array set view_save {}\n         array set views {}\n@@ -10193,6 +10200,7 @@ proc rmbranch {} {\n proc showrefs {} {\n     global showrefstop bgcolor fgcolor selectbgcolor\n     global bglist fglist reflistfilter reflist maincursor\n+    global geometry\n \n     set top .showrefs\n     set showrefstop $top\n@@ -10203,7 +10211,11 @@ proc showrefs {} {\n     }\n     ttk_toplevel $top\n     wm title $top [mc \"Tags and heads: %s\" [file tail [pwd]]]\n-    make_transient $top .\n+    if {[info exists geometry(showrefs)]} {\n+        make_transient $top . $geometry(showrefs)\n+    } else {\n+        make_transient $top .\n+    }\n     text $top.list -background $bgcolor -foreground $fgcolor \\\n         -selectbackground $selectbgcolor -font mainfont \\\n         -xscrollcommand \"$top.xsb set\" -yscrollcommand \"$top.ysb set\" \\\n@@ -10239,6 +10251,9 @@ proc showrefs {} {\n     bind $top.list <ButtonRelease-1> {sel_reflist %W %x %y; break}\n     set reflist {}\n     refill_reflist\n+    # avoid <Configure> being bound to child windows\n+    bindtags $top [linsert [bindtags $top] 1 bind$top]\n+    bind bind$top <Configure> {set geometry(showrefs) [wm geometry %W]}\n }\n \n proc sel_reflist {w x y} {\n-- \n2.51.0.431.g0f99086cdf\n\n"},{"id":"529084","messageId":"fd4437c2-ca62-4221-b426-f3c3dc3d2a47@kdbg.org","threadId":"64220","inReplyTo":"be1e6cba-c94d-4c2f-ab68-e368ffe9daa5@gmail.com","subject":"Re: [PATCH v3 1/2] Revert \"gitk: Only restore window size from ~/.gitk, not position\"","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2025-10-17T16:36:15Z","receivedAt":"2025-10-17T17:16:23Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 28.09.25 um 16:17 schrieb Mark Levedahl:\n> On 9/28/25 9:54 AM, Michael Rappazzo wrote:\n>> From: Johannes Sixt <johannes.sixt@telecom.at>\n>>\n>> This reverts commit b9bee11526ec23541ddbbd75716bfd1acc241463.\n>>\n>> The commit catered to an unsupportable port of the Windows Tcl/Tk\n>> stuck at 8.4.1 that was used by Cygwin. 8.4.1 has some bad bugs in its\n>> layout engine, and forced changes in Gitk to be compatible. All this\n>> became irrelevant around 2011 after Cygwin gained an X11 server and\n>> switched to a supportable port of the Unix/X11 Tcl/Tk (it is now on the\n>> current 8.6 code base).\n>>\n>> Helped-by: Mark Levedahl <mlevedahl@gmail.com>\n>> Signed-off-by: Johannes Sixt <j6t@kdbg.org>\n>> ---\n>>  gitk | 12 ++----------\n>>  1 file changed, 2 insertions(+), 10 deletions(-)\n>>\n>> diff --git a/gitk b/gitk\n>> index 6e4d71d585..275f353811 100755\n>> --- a/gitk\n>> +++ b/gitk\n>> @@ -2764,17 +2764,9 @@ proc makewindow {} {\n>>      .pwbottom add .bright\n>>      .ctop add .pwbottom\n>>  \n>> -    # restore window width & height if known\n>> +    # restore window position if known\n>>      if {[info exists geometry(main)]} {\n>> -        if {[scan $geometry(main) \"%dx%d\" w h] >= 2} {\n>> -            if {$w > [winfo screenwidth .]} {\n>> -                set w [winfo screenwidth .]\n>> -            }\n>> -            if {$h > [winfo screenheight .]} {\n>> -                set h [winfo screenheight .]\n>> -            }\n>> -            wm geometry . \"${w}x$h\"\n>> -        }\n>> +        wm geometry . \"$geometry(main)\"\n>>      }\n>>  \n>>      if {[info exists geometry(state)] && $geometry(state) eq \"zoomed\"} {\n> I mis-interpreted an earlier inquiry about the patch being reverted here. Patch e9937d2a03\n> actually addressed the issues of Cygwin's 8.4.1 Tcl/Tk. Part of that was fixing the window\n> geometry being restored, as sometimes the window manager would size the main window in a\n> manner causing 8.4.1 to fail. But, this override of the main window manager on all\n> platforms raised complaints on the mailing list, and commit b9bee11526 was the response:\n> it was only the SIZE of the Window that mattered on Cygwin, not its location, so allowing\n> window managers to set the location was ok.\n> \n> Personally, I'm fine with gitk remembering / restoring the full window geometry (I wrote\n> it that way in e9937d2a03).\nThank you for the hint. I found the thread, and after reading it I\nnotice that the opposition is based on that restoring the position\ndoesn't put the window on the desired monitor. I can't test this right\nnow. I've rewritten the commit message as follows. Whether or not the\nposition should be restored seems to be a personal preference, and the\npatch applies my and your preference, but obviously not everyone's.\nPlease let me know whether I understood the situation correctly or not.\n\n    Revert \"gitk: Only restore window size from ~/.gitk, not position\"\n    \n    This reverts commit b9bee11526ec (gitk: Only restore window size from\n    ~/.gitk, not position, 2008-03-10).\n    \n    The earlier commit e9937d2a03a4 (Make gitk work reasonably well on\n    Cygwin, 2007-02-01) reworked the window layout considerably. Much of\n    this became irrelevant around 2011 after Cygwin gained an X11 server\n    and switched to a supportable port of the Unix/X11 Tcl/Tk (it is now\n    on the current 8.6 code base).\n    \n    Part of the necessary change was to restore the window size across\n    sessions, but the position was also restored. This raised complaints\n    on the mailing list[*], because Gitk was opened on the wrong monitor.\n    b9bee11526ec was the compromise, because it was only the size that\n    mattered for the Cygwin layout engine to work.\n    \n    I personally, find it annoying when Gitk pops up on a random location\n    on the screen, in particular, since many other applications restore\n    the window positions across sessions, so why not Gitk as well? (I do\n    not operate multi-monitor setups, so I cannot test the case.)\n    \n    [*] https://lore.kernel.org/git/47AAA254.2020008@thorn.ws/\n\n-- Hannes\n\n"},{"id":"529091","messageId":"534bfdd4-319d-4421-a650-42c65af9011c@gmail.com","threadId":"64220","inReplyTo":"fd4437c2-ca62-4221-b426-f3c3dc3d2a47@kdbg.org","subject":"Re: [PATCH v3 1/2] Revert \"gitk: Only restore window size from ~/.gitk, not position\"","fromName":"Mark Levedahl","fromEmail":"mlevedahl@gmail.com","sentAt":"2025-10-17T19:27:50Z","receivedAt":"2025-10-17T19:27:53Z","isPatch":true,"sender":{"key":"mdl123@verizon.net","avatar":"https://avatars.githubusercontent.com/u/5302462?v=4"},"body":"\n\nOn 10/17/25 12:36 PM, Johannes Sixt wrote:\n> Thank you for the hint. I found the thread, and after reading it I\n> notice that the opposition is based on that restoring the position\n> doesn't put the window on the desired monitor. I can't test this right\n> now. I've rewritten the commit message as follows. Whether or not the\n> position should be restored seems to be a personal preference, and the\n> patch applies my and your preference, but obviously not everyone's.\n> Please let me know whether I understood the situation correctly or not.\n>\n> -- Hannes\n>\nYour commit message accurately captures the issues as I understand them. I also cannot\ncontribute on the multi-monitor setup, nor about the broader context wanting this patch.\n\nMark\n"}]}