* [PATCH] Make gitk save and restore the user set window position.
@ 2007-02-11 14:27 Mark Levedahl
2007-02-11 14:27 ` Mark Levedahl
2007-02-11 21:49 ` [PATCH] Make gitk save and restore the user set window position Junio C Hamano
0 siblings, 2 replies; 13+ messages in thread
From: Mark Levedahl @ 2007-02-11 14:27 UTC (permalink / raw)
To: git
I sent these patches to Junio and Paul last week, mistyped the git mailing list
address so they didn't get to the list so am resending for the record.
Mark Levedahl
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH] Make gitk save and restore the user set window position.
2007-02-11 14:27 [PATCH] Make gitk save and restore the user set window position Mark Levedahl
@ 2007-02-11 14:27 ` Mark Levedahl
2007-02-11 14:27 ` [PATCH] Clean up geometry save code in gitk Mark Levedahl
2007-02-11 21:49 ` [PATCH] Make gitk save and restore the user set window position Junio C Hamano
1 sibling, 1 reply; 13+ messages in thread
From: Mark Levedahl @ 2007-02-11 14:27 UTC (permalink / raw)
To: git; +Cc: Mark Levedahl
gitk was saving widget sizes and positions when the main window was
destroyed, which is after all child widgets are destroyed. The cure
is to trap the WM_DELETE_WINDOW event before the gui is torn down. Also,
the saved geometry was captured using "winfo geometry .", rather than
"wm geometry ." Under Linux, these two return different answers and the
latter one is correct.
Signed-off-by: Mark Levedahl <mdl123@verizon.net>
---
gitk | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/gitk b/gitk
index 1c36235..23bf567 100755
--- a/gitk
+++ b/gitk
@@ -725,7 +725,7 @@ proc makewindow {} {
bind . <Control-KP_Add> {incrfont 1}
bind . <Control-minus> {incrfont -1}
bind . <Control-KP_Subtract> {incrfont -1}
- bind . <Destroy> {savestuff %W}
+ wm protocol . WM_DELETE_WINDOW doquit
bind . <Button-1> "click %W"
bind $fstring <Key-Return> dofind
bind $sha1entry <Key-Return> gotocommit
@@ -829,7 +829,7 @@ proc savestuff {w} {
puts $f [list set colors $colors]
puts $f [list set diffcolors $diffcolors]
- puts $f "set geometry(main) [winfo geometry .]"
+ puts $f "set geometry(main) [wm geometry .]"
puts $f "set geometry(topwidth) [winfo width .tf]"
puts $f "set geometry(topheight) [winfo height .tf]"
puts $f "set geometry(canv) [expr {[winfo width $canv]-0}]"
@@ -5800,6 +5800,7 @@ proc showtag {tag isnew} {
proc doquit {} {
global stopped
set stopped 100
+ savestuff .
destroy .
}
--
1.5.0.rc3.24.g0c5e
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH] Clean up geometry save code in gitk.
2007-02-11 14:27 ` Mark Levedahl
@ 2007-02-11 14:27 ` Mark Levedahl
2007-02-11 16:56 ` Sergey Vlasov
0 siblings, 1 reply; 13+ messages in thread
From: Mark Levedahl @ 2007-02-11 14:27 UTC (permalink / raw)
To: git; +Cc: Mark Levedahl
Leftover code was subtracting zero from several items before storing, an
obvious noop now deleted.
Signed-off-by: Mark Levedahl <mdl123@verizon.net>
---
gitk | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/gitk b/gitk
index 23bf567..df1ce8c 100755
--- a/gitk
+++ b/gitk
@@ -832,9 +832,9 @@ proc savestuff {w} {
puts $f "set geometry(main) [wm geometry .]"
puts $f "set geometry(topwidth) [winfo width .tf]"
puts $f "set geometry(topheight) [winfo height .tf]"
- puts $f "set geometry(canv) [expr {[winfo width $canv]-0}]"
- puts $f "set geometry(canv2) [expr {[winfo width $canv2]-0}]"
- puts $f "set geometry(canv3) [expr {[winfo width $canv3]-0}]"
+ puts $f "set geometry(canv) [winfo width $canv]"
+ puts $f "set geometry(canv2) [winfo width $canv2]"
+ puts $f "set geometry(canv3) [winfo width $canv3]"
puts $f "set geometry(botwidth) [winfo width .bleft]"
puts $f "set geometry(botheight) [winfo height .bleft]"
--
1.5.0.rc3.24.g0c5e
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH] Clean up geometry save code in gitk.
2007-02-11 14:27 ` [PATCH] Clean up geometry save code in gitk Mark Levedahl
@ 2007-02-11 16:56 ` Sergey Vlasov
2007-02-11 16:58 ` gitk: Fix restoring of pane sizes Sergey Vlasov
2007-02-11 17:44 ` [PATCH] Clean up geometry save code in gitk Mark Levedahl
0 siblings, 2 replies; 13+ messages in thread
From: Sergey Vlasov @ 2007-02-11 16:56 UTC (permalink / raw)
To: Mark Levedahl; +Cc: git, Junio C Hamano, Paul Mackerras
[-- Attachment #1: Type: text/plain, Size: 1313 bytes --]
Hello!
On Sun, 11 Feb 2007 09:27:20 -0500
Mark Levedahl <mdl123@verizon.net> wrote:
> gitk was saving widget sizes and positions when the main window was
> destroyed, which is after all child widgets are destroyed. The cure
> is to trap the WM_DELETE_WINDOW event before the gui is torn down. Also,
> the saved geometry was captured using "winfo geometry .", rather than
> "wm geometry ." Under Linux, these two return different answers and the
> latter one is correct.
> Leftover code was subtracting zero from several items before storing, an
> obvious noop now deleted.
These two patches fix saving of the window position for me; however,
some things still remain broken:
- No matter what sizes of the commit tree, patch and filelist panes I
set, on gitk restart they come up with their default sizes.
- Sizes of commit tree columns are not saved properly - on every gitk
restart the dividers are shifting more and more to the right.
This is on Linux (x86_64) with Tk 8.4.13.
I made two more patches which fix the above problems for me - please
test them (in particular, someone needs to check that the Cygwin
support is not broken - apparently something is different between Tk
on Linux and Cygwin to create the problem with commit tree columns).
See the followup messages.
--
Sergey Vlasov
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
* gitk: Fix restoring of pane sizes
2007-02-11 16:56 ` Sergey Vlasov
@ 2007-02-11 16:58 ` Sergey Vlasov
2007-02-11 16:58 ` gitk: Fix restoring of column widths in the commit tree Sergey Vlasov
2007-02-11 17:44 ` [PATCH] Clean up geometry save code in gitk Mark Levedahl
1 sibling, 1 reply; 13+ messages in thread
From: Sergey Vlasov @ 2007-02-11 16:58 UTC (permalink / raw)
To: Mark Levedahl, Junio C Hamano, Paul Mackerras; +Cc: git, Sergey Vlasov
At least on Linux with Tk 8.4.13 gitk always came up with default pane
sizes, even though they were previously saved in ~/.gitk. Apparently
setting width and height of frames in these panes when creating them
is not enough, and an explicit paneconfigure call is needed.
Signed-off-by: Sergey Vlasov <vsu@altlinux.ru>
---
gitk | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/gitk b/gitk
index df1ce8c..7e6ee56 100755
--- a/gitk
+++ b/gitk
@@ -577,6 +577,7 @@ proc makewindow {} {
pack .tf.bar -in .tf -side bottom -fill x
pack .tf.histframe -fill both -side top -expand 1
.ctop add .tf
+ .ctop paneconfigure .tf -height $geometry(topheight)
# now build up the bottom
panedwindow .pwbottom -orient horizontal
@@ -638,6 +639,7 @@ proc makewindow {} {
$ctext tag conf found -back yellow
.pwbottom add .bleft
+ .pwbottom paneconfigure .bleft -width $geometry(botwidth)
# lower right
frame .bright
--
1.5.0.rc4.50.g403de
^ permalink raw reply related [flat|nested] 13+ messages in thread
* gitk: Fix restoring of column widths in the commit tree
2007-02-11 16:58 ` gitk: Fix restoring of pane sizes Sergey Vlasov
@ 2007-02-11 16:58 ` Sergey Vlasov
0 siblings, 0 replies; 13+ messages in thread
From: Sergey Vlasov @ 2007-02-11 16:58 UTC (permalink / raw)
To: Mark Levedahl, Junio C Hamano, Paul Mackerras; +Cc: git, Sergey Vlasov
On Linux with Tk 8.4.13 after each gitk restart the column dividers
were shifting more and more to the right. Apparently the value from
[winfo width $canv] is larger than the value of the -width option
specified when creating the widget due to non-zero -highlightthickness
used by default. But gitk never shows the focus highlight on canvases
used for the commit tree, so we can just set "-highlightthickness 0",
which fixes the width mismatch.
(The code before commit 3468e71f452701b3eff6a2aeb826bbe0cdad8270
subtracted 2 from widths of canvases when saving them - apparently to
account for that hidden highlightthickness; I suppose that Cygwin
behaves differently - hope that "-highlightthickness 0" will give
proper results everywhere.)
Signed-off-by: Sergey Vlasov <vsu@altlinux.ru>
---
gitk | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/gitk b/gitk
index 7e6ee56..ea3d68a 100755
--- a/gitk
+++ b/gitk
@@ -459,14 +459,17 @@ proc makewindow {} {
set canv .tf.histframe.pwclist.canv
canvas $canv -width $geometry(canv) \
-background $bgcolor -bd 0 \
+ -highlightthickness 0 \
-yscrollincr $linespc -yscrollcommand "scrollcanv $cscroll"
.tf.histframe.pwclist add $canv
set canv2 .tf.histframe.pwclist.canv2
canvas $canv2 -width $geometry(canv2) \
+ -highlightthickness 0 \
-background $bgcolor -bd 0 -yscrollincr $linespc
.tf.histframe.pwclist add $canv2
set canv3 .tf.histframe.pwclist.canv3
canvas $canv3 -width $geometry(canv3) \
+ -highlightthickness 0 \
-background $bgcolor -bd 0 -yscrollincr $linespc
.tf.histframe.pwclist add $canv3
--
1.5.0.rc4.50.g403de
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH] Clean up geometry save code in gitk.
2007-02-11 16:56 ` Sergey Vlasov
2007-02-11 16:58 ` gitk: Fix restoring of pane sizes Sergey Vlasov
@ 2007-02-11 17:44 ` Mark Levedahl
1 sibling, 0 replies; 13+ messages in thread
From: Mark Levedahl @ 2007-02-11 17:44 UTC (permalink / raw)
To: Sergey Vlasov; +Cc: git, Junio C Hamano, Paul Mackerras
Sergey Vlasov wrote:
> These two patches fix saving of the window position for me; however,
> some things still remain broken:
>
> - No matter what sizes of the commit tree, patch and filelist panes I
> set, on gitk restart they come up with their default sizes.
>
> - Sizes of commit tree columns are not saved properly - on every gitk
> restart the dividers are shifting more and more to the right.
>
> This is on Linux (x86_64) with Tk 8.4.13.
>
> I made two more patches which fix the above problems for me - please
> test them (in particular, someone needs to check that the Cygwin
> support is not broken - apparently something is different between Tk
> on Linux and Cygwin to create the problem with commit tree columns).
>
> See the followup messages.
>
> --
> Sergey Vlasov
>
I could not actually apply your patches, but your suggested changes were
simple enough to apply by hand:
1) I do notice the change in size of panes in the upper window on Cygwin
(hadn't noticed before but it is there), and your "-highlightthickness
0" tweak fixes that. Just for grins, I tried reenabling the "subtract 2"
strategy in place before, and that only makes the problem worse on Cygwin.
2) I don't see any effect of the "pane configure" tweak on Cygwin.
Haven't checked on Linux (don't have that here) so cannot comment.
Gotta say, the more I play with Tk, the more I wonder why anyone uses
anything else ;-) .
Mark
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] Make gitk save and restore the user set window position.
2007-02-11 14:27 [PATCH] Make gitk save and restore the user set window position Mark Levedahl
2007-02-11 14:27 ` Mark Levedahl
@ 2007-02-11 21:49 ` Junio C Hamano
1 sibling, 0 replies; 13+ messages in thread
From: Junio C Hamano @ 2007-02-11 21:49 UTC (permalink / raw)
To: Mark Levedahl; +Cc: git
Mark Levedahl <mdl123@verizon.net> writes:
> I sent these patches to Junio and Paul last week, mistyped the git mailing list
> address so they didn't get to the list so am resending for the record.
Thanks. Will apply them, short-circuitting Paul.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] Make gitk save and restore the user set window position.
@ 2007-02-08 5:43 Brett Schwarz
2007-02-08 16:55 ` Mark Levedahl
0 siblings, 1 reply; 13+ messages in thread
From: Brett Schwarz @ 2007-02-08 5:43 UTC (permalink / raw)
To: Mark Levedahl, Shawn O. Pearce; +Cc: Junio C Hamano, git
>----- Original Message ----
>From: Mark Levedahl <mdl123@verizon.net>
>To: Shawn O. Pearce <spearce@spearce.org>
>Cc: Junio C Hamano <junkio@cox.net>; git@vger.kernel.org
>Sent: Wednesday, February 7, 2007 4:30:38 PM
>Subject: Re: [PATCH] Make gitk save and restore the user set window position.
>
>Shawn O. Pearce wrote:
>> Junio C Hamano <junkio@cox.net> wrote:
>>
>>> After seeing what this patch has to do, I feel dirty, but
>>> that is not Mark's fault -- rather it is Tk's.
>>>
>>> I am tempted to suggest adding an explicit "Save window
>>> configuration" action on the menubar and forget about
>>> resurrecting the window configuration immediately before the
>>> end of the last session.
>>>
>>
>> Maybe take a look at what git-gui does here, because its slightly
>> saner and still saves the geometry on exit:
>>
>> set is_quitting 0
>> proc do_quit {} {
>> global is_quitting
>> if {$is_quitting} return
>> set is_quitting 1
>> # save wm geometry
>> }
>> bind . <Destroy> do_quit
>>
>> OK, its not that much saner. But it does bypass needing to setup
>> some ugly bindings on every object in the UI. Though I recently
>> took a slightly different approach in a dialog:
>>
>> proc do_quit {} {
>> bind . <Destroy> {}
>> # do cleanup
>> }
>> bind . <Destroy> do_quit
>>
>> Yes the binding is firing in both cases for some arbitrary child
>> widget in the window, but it doesn't matter. In the latter version
>> setting the binding to the empty string removes the do_quit binding,
>> allowing the other widgets to destroy without reinvoking do_quit
>> and whacking whatever geometry data you may have saved before the
>> widgets started to get deleted.
>>
>>
>> The only problem I seem to have in git-gui is the window position
>> opens about 10 pixels lower and 2 pixels to the right than the last
>> time it opened. I think there's a bug in Tk on Windows where the
>> window position on the desktop doesn't include the titlebar when I
>> get it, but expects to include it when I attempt to set it on the
>> next start.
>>
>> I should note I also see the same behavior with my day-time-job's
>> Java apps on Windows however, so I don't think its a specific Tk
>> or git-gui issue.
>>
>>
> What you suggest is essentially what gitk does before my patch. In
> git-gui, routine do_quit is invoked when Tk is ready to destroy the top
> level window: this is _after_ Tk has destroyed everything in the window,
> and thus the problem. I still haven't isolated which object(s) being
> destroyed from gitk cause the geometry reported from wm info to change,
> clearly my patch is binding widgets that do not need to be bound, but I
> haven't found which specific one needs to be bound.
>
> With my patch, the correct position is saved and restored on both Linux
> and Cygwin. I think that should be the goal. A more elegant solution
> accomplishing that end is of course desirable, but there remains the
> issue of finding it. I think the objections to my patch are more
> theoretical than practical: I seriously doubt you can find any
> practically observable side effect of binding all the widgets other than
> that the window geometry _is_ correctly saved and restored.
>
> As to being specific to Tk, I have many windows applications that
> successfully save and restore window state, this geometry issue is not
> endemic to Windows and I have never encountered it except with Tk.
>
> Mark
>
I've only been half following this thread, so I apologize if this was already talked about.
Have you tried [wm protocol] command. You would use it like this:
wm protocol . WM_DELETE_WINDOW do_quit
This basically traps the signal from the windowmanager, and [do_quit] gets executed *before* the gui is torn down. The only bad thing about this, is if you explicitly destroy a widget inside your code (i.e. [destroy .]), then this will *not* get invoked. You also need to make sure you catch any possible errors in do_quit, otherwise the gui will hang.
HTH,
--brett
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
____________________________________________________________________________________
Be a PS3 game guru.
Get your game face on with the latest PS3 news and previews at Yahoo! Games.
http://videogames.yahoo.com/platform?platform=120121
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] Make gitk save and restore the user set window position.
2007-02-08 5:43 Brett Schwarz
@ 2007-02-08 16:55 ` Mark Levedahl
0 siblings, 0 replies; 13+ messages in thread
From: Mark Levedahl @ 2007-02-08 16:55 UTC (permalink / raw)
To: git
"Brett Schwarz" <brett_schwarz@yahoo.com> wrote in message
news:491753.81112.qm@web38915.mail.mud.yahoo.com...
>>
>> Mark
>>
>
> I've only been half following this thread, so I apologize if this was
> already talked about.
>
> Have you tried [wm protocol] command. You would use it like this:
>
> wm protocol . WM_DELETE_WINDOW do_quit
>
> This basically traps the signal from the windowmanager, and [do_quit]
> gets executed *before* the gui is torn down. The only bad thing about
> this, is if you explicitly destroy a widget inside your code (i.e.
> [destroy .]), then this will *not* get invoked. You also need to make
> sure you catch any possible errors in do_quit, otherwise the gui will
> hang.
>
> HTH,
> --brett
>
Thank you - that is exactly what I was looking for but couldn't find.
I'll generate another patch tonight.
Mark
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH] Make gitk save and restore the user set window position.
@ 2007-02-07 3:21 Junio C Hamano
2007-02-07 5:40 ` Shawn O. Pearce
0 siblings, 1 reply; 13+ messages in thread
From: Junio C Hamano @ 2007-02-07 3:21 UTC (permalink / raw)
To: git; +Cc: Mark Levedahl
From: Mark Levedahl <mdl123@verizon.net>
Date: Mon, 05 Feb 2007 22:59:50 -0500
gitk was saving widget sizes and positions when the main window was
destroyed, which is after all child widgets are destroyed. Tk resizes
container widgets as children are destroyed, so the saved main window
information was not as the user left the window. This patch causes the
info to be saved before the first child widget is destroyed. Also,
use wm geometry rather than winfo geometry (both work on Windows, on
Linux they give different answers and the former is correct).
Signed-off-by: Mark Levedahl <mdl123@verizon.net>
---
* Somehow this did not appeared on the list, so I am forwarding.
After seeing what this patch has to do, I feel dirty, but
that is not Mark's fault -- rather it is Tk's.
I am tempted to suggest adding an explicit "Save window
configuration" action on the menubar and forget about
resurrecting the window configuration immediately before the
end of the last session.
gitk | 20 ++++++++++++++++++--
1 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/gitk b/gitk
index 8132812..beec6a9 100755
--- a/gitk
+++ b/gitk
@@ -725,7 +725,7 @@ proc makewindow {} {
bind . <Control-KP_Add> {incrfont 1}
bind . <Control-minus> {incrfont -1}
bind . <Control-KP_Subtract> {incrfont -1}
- bind . <Destroy> {savestuff %W}
+ bindalldestroy .
bind . <Button-1> "click %W"
bind $fstring <Key-Return> dofind
bind $sha1entry <Key-Return> gotocommit
@@ -759,6 +759,22 @@ proc makewindow {} {
-command rmbranch
}
+# The main window resizes itself while the windows are being destroyed,
+# we want to save the size before it is resized so we write out when the
+# first widget with no children is destroyed. We don't know which this
+# will be, so we bind all child widgets (savestuff will save only once,
+# the remaining calls are ignored).
+proc bindalldestroy {w} {
+ set children [winfo children $w]
+ if {"$children" == ""} {
+ bind $w <Destroy> {savestuff %W}
+ } else {
+ foreach child $children {
+ bindalldestroy $child
+ }
+ }
+}
+
# mouse-2 makes all windows scan vertically, but only the one
# the cursor is in scans horizontally
proc canvscan {op w x y} {
@@ -829,7 +845,7 @@ proc savestuff {w} {
puts $f [list set colors $colors]
puts $f [list set diffcolors $diffcolors]
- puts $f "set geometry(main) [winfo geometry .]"
+ puts $f "set geometry(main) [wm geometry .]"
puts $f "set geometry(topwidth) [winfo width .tf]"
puts $f "set geometry(topheight) [winfo height .tf]"
puts $f "set geometry(canv) [expr {[winfo width $canv]-0}]"
--
1.5.0.rc3.24.g0c5e
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH] Make gitk save and restore the user set window position.
2007-02-07 3:21 Junio C Hamano
@ 2007-02-07 5:40 ` Shawn O. Pearce
2007-02-08 0:30 ` Mark Levedahl
0 siblings, 1 reply; 13+ messages in thread
From: Shawn O. Pearce @ 2007-02-07 5:40 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Mark Levedahl
Junio C Hamano <junkio@cox.net> wrote:
> After seeing what this patch has to do, I feel dirty, but
> that is not Mark's fault -- rather it is Tk's.
>
> I am tempted to suggest adding an explicit "Save window
> configuration" action on the menubar and forget about
> resurrecting the window configuration immediately before the
> end of the last session.
Maybe take a look at what git-gui does here, because its slightly
saner and still saves the geometry on exit:
set is_quitting 0
proc do_quit {} {
global is_quitting
if {$is_quitting} return
set is_quitting 1
# save wm geometry
}
bind . <Destroy> do_quit
OK, its not that much saner. But it does bypass needing to setup
some ugly bindings on every object in the UI. Though I recently
took a slightly different approach in a dialog:
proc do_quit {} {
bind . <Destroy> {}
# do cleanup
}
bind . <Destroy> do_quit
Yes the binding is firing in both cases for some arbitrary child
widget in the window, but it doesn't matter. In the latter version
setting the binding to the empty string removes the do_quit binding,
allowing the other widgets to destroy without reinvoking do_quit
and whacking whatever geometry data you may have saved before the
widgets started to get deleted.
The only problem I seem to have in git-gui is the window position
opens about 10 pixels lower and 2 pixels to the right than the last
time it opened. I think there's a bug in Tk on Windows where the
window position on the desktop doesn't include the titlebar when I
get it, but expects to include it when I attempt to set it on the
next start.
I should note I also see the same behavior with my day-time-job's
Java apps on Windows however, so I don't think its a specific Tk
or git-gui issue.
--
Shawn.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] Make gitk save and restore the user set window position.
2007-02-07 5:40 ` Shawn O. Pearce
@ 2007-02-08 0:30 ` Mark Levedahl
0 siblings, 0 replies; 13+ messages in thread
From: Mark Levedahl @ 2007-02-08 0:30 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: Junio C Hamano, git
Shawn O. Pearce wrote:
> Junio C Hamano <junkio@cox.net> wrote:
>
>> After seeing what this patch has to do, I feel dirty, but
>> that is not Mark's fault -- rather it is Tk's.
>>
>> I am tempted to suggest adding an explicit "Save window
>> configuration" action on the menubar and forget about
>> resurrecting the window configuration immediately before the
>> end of the last session.
>>
>
> Maybe take a look at what git-gui does here, because its slightly
> saner and still saves the geometry on exit:
>
> set is_quitting 0
> proc do_quit {} {
> global is_quitting
> if {$is_quitting} return
> set is_quitting 1
> # save wm geometry
> }
> bind . <Destroy> do_quit
>
> OK, its not that much saner. But it does bypass needing to setup
> some ugly bindings on every object in the UI. Though I recently
> took a slightly different approach in a dialog:
>
> proc do_quit {} {
> bind . <Destroy> {}
> # do cleanup
> }
> bind . <Destroy> do_quit
>
> Yes the binding is firing in both cases for some arbitrary child
> widget in the window, but it doesn't matter. In the latter version
> setting the binding to the empty string removes the do_quit binding,
> allowing the other widgets to destroy without reinvoking do_quit
> and whacking whatever geometry data you may have saved before the
> widgets started to get deleted.
>
>
> The only problem I seem to have in git-gui is the window position
> opens about 10 pixels lower and 2 pixels to the right than the last
> time it opened. I think there's a bug in Tk on Windows where the
> window position on the desktop doesn't include the titlebar when I
> get it, but expects to include it when I attempt to set it on the
> next start.
>
> I should note I also see the same behavior with my day-time-job's
> Java apps on Windows however, so I don't think its a specific Tk
> or git-gui issue.
>
>
What you suggest is essentially what gitk does before my patch. In
git-gui, routine do_quit is invoked when Tk is ready to destroy the top
level window: this is _after_ Tk has destroyed everything in the window,
and thus the problem. I still haven't isolated which object(s) being
destroyed from gitk cause the geometry reported from wm info to change,
clearly my patch is binding widgets that do not need to be bound, but I
haven't found which specific one needs to be bound.
With my patch, the correct position is saved and restored on both Linux
and Cygwin. I think that should be the goal. A more elegant solution
accomplishing that end is of course desirable, but there remains the
issue of finding it. I think the objections to my patch are more
theoretical than practical: I seriously doubt you can find any
practically observable side effect of binding all the widgets other than
that the window geometry _is_ correctly saved and restored.
As to being specific to Tk, I have many windows applications that
successfully save and restore window state, this geometry issue is not
endemic to Windows and I have never encountered it except with Tk.
Mark
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2007-02-11 21:49 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-11 14:27 [PATCH] Make gitk save and restore the user set window position Mark Levedahl
2007-02-11 14:27 ` Mark Levedahl
2007-02-11 14:27 ` [PATCH] Clean up geometry save code in gitk Mark Levedahl
2007-02-11 16:56 ` Sergey Vlasov
2007-02-11 16:58 ` gitk: Fix restoring of pane sizes Sergey Vlasov
2007-02-11 16:58 ` gitk: Fix restoring of column widths in the commit tree Sergey Vlasov
2007-02-11 17:44 ` [PATCH] Clean up geometry save code in gitk Mark Levedahl
2007-02-11 21:49 ` [PATCH] Make gitk save and restore the user set window position Junio C Hamano
-- strict thread matches above, loose matches on Subject: below --
2007-02-08 5:43 Brett Schwarz
2007-02-08 16:55 ` Mark Levedahl
2007-02-07 3:21 Junio C Hamano
2007-02-07 5:40 ` Shawn O. Pearce
2007-02-08 0:30 ` Mark Levedahl
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.