{"thread":{"id":"6735","subject":"Re: [PATCH] Make gitk save and restore the user set window position.","startedAt":"2007-02-08T05:43:31Z","lastAt":"2007-02-08T16:55:28Z","messageCount":2,"participants":["Brett Schwarz","Mark Levedahl"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"33912","messageId":"491753.81112.qm@web38915.mail.mud.yahoo.com","threadId":"6735","inReplyTo":null,"subject":"Re: [PATCH] Make gitk save and restore the user set window position.","fromName":"Brett Schwarz","fromEmail":"brett_schwarz@yahoo.com","sentAt":"2007-02-08T05:43:31Z","receivedAt":"2007-02-08T05:43:31Z","isPatch":true,"sender":{"key":"brett_schwarz@yahoo.com","avatar":null},"body":">----- Original Message ----\n>From: Mark Levedahl <mdl123@verizon.net>\n>To: Shawn O. Pearce <spearce@spearce.org>\n>Cc: Junio C Hamano <junkio@cox.net>; git@vger.kernel.org\n>Sent: Wednesday, February 7, 2007 4:30:38 PM\n>Subject: Re: [PATCH] Make gitk save and restore the user set window position.\n>\n>Shawn O. Pearce wrote:\n>> Junio C Hamano <junkio@cox.net> wrote:\n>>  \n>>>    After seeing what this patch has to do, I feel dirty, but\n>>>    that is not Mark's fault -- rather it is Tk's.\n>>>\n>>>    I am tempted to suggest adding an explicit \"Save window\n>>>    configuration\" action on the menubar and forget about\n>>>    resurrecting the window configuration immediately before the\n>>>    end of the last session.\n>>>    \n>>\n>> Maybe take a look at what git-gui does here, because its slightly\n>> saner and still saves the geometry on exit:\n>>\n>>     set is_quitting 0\n>>     proc do_quit {} {\n>>         global is_quitting\n>>         if {$is_quitting} return\n>>         set is_quitting 1\n>>         # save wm geometry\n>>     }\n>>     bind . <Destroy> do_quit\n>>\n>> OK, its not that much saner.  But it does bypass needing to setup\n>> some ugly bindings on every object in the UI.  Though I recently\n>> took a slightly different approach in a dialog:\n>>\n>>     proc do_quit {} {\n>>         bind . <Destroy> {}\n>>         # do cleanup\n>>     }\n>>     bind . <Destroy> do_quit\n>>\n>> Yes the binding is firing in both cases for some arbitrary child\n>> widget in the window, but it doesn't matter.  In the latter version\n>> setting the binding to the empty string removes the do_quit binding,\n>> allowing the other widgets to destroy without reinvoking do_quit\n>> and whacking whatever geometry data you may have saved before the\n>> widgets started to get deleted.\n>>\n>>\n>> The only problem I seem to have in git-gui is the window position\n>> opens about 10 pixels lower and 2 pixels to the right than the last\n>> time it opened.  I think there's a bug in Tk on Windows where the\n>> window position on the desktop doesn't include the titlebar when I\n>> get it, but expects to include it when I attempt to set it on the\n>> next start.\n>>\n>> I should note I also see the same behavior with my day-time-job's\n>> Java apps on Windows however, so I don't think its a specific Tk\n>> or git-gui issue.\n>>\n>>  \n> What you suggest is essentially what gitk does before my patch. In\n> git-gui, routine do_quit is invoked when Tk is ready to destroy the top\n> level window: this is _after_ Tk has destroyed everything in the window,\n> and thus the problem. I still haven't isolated which object(s) being\n> destroyed from gitk cause the geometry reported from wm info to change,\n> clearly my patch is binding widgets that do not need to be bound, but I\n> haven't found which specific one needs to be bound.\n> \n> With my patch, the correct position is saved and restored on both Linux\n> and Cygwin. I think that should be the goal. A more elegant solution\n> accomplishing that end is of course desirable, but there remains the\n> issue of finding it. I think the objections to my patch are more\n> theoretical than practical: I seriously doubt you can find any\n> practically observable side effect of binding all the widgets other than\n> that the window geometry _is_ correctly saved and restored.\n> \n> As to being specific to Tk, I have many windows applications that\n> successfully save and restore window state, this geometry issue is not\n> endemic to Windows and I have never encountered it except with Tk.\n> \n> Mark\n> \n\nI've only been half following this thread, so I apologize if this was already talked about.\n\nHave you tried [wm protocol] command. You would use it like this:\n\n    wm protocol . WM_DELETE_WINDOW do_quit\n\nThis 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.\n\nHTH,\n    --brett\n\n\n-\nTo unsubscribe from this list: send the line \"unsubscribe git\" in\nthe body of a message to majordomo@vger.kernel.org\nMore majordomo info at  http://vger.kernel.org/majordomo-info.html\n\n\n\n\n\n \n____________________________________________________________________________________\nBe a PS3 game guru.\nGet your game face on with the latest PS3 news and previews at Yahoo! Games.\nhttp://videogames.yahoo.com/platform?platform=120121\n"},{"id":"33944","messageId":"eqfkm4$fd3$1@sea.gmane.org","threadId":"6735","inReplyTo":"491753.81112.qm@web38915.mail.mud.yahoo.com","subject":"Re: [PATCH] Make gitk save and restore the user set window position.","fromName":"Mark Levedahl","fromEmail":"mdl123@verizon.net","sentAt":"2007-02-08T16:55:28Z","receivedAt":"2007-02-08T16:55:28Z","isPatch":true,"sender":{"key":"mdl123@verizon.net","avatar":"https://avatars.githubusercontent.com/u/5302462?v=4"},"body":"\"Brett Schwarz\" <brett_schwarz@yahoo.com> wrote in message \nnews:491753.81112.qm@web38915.mail.mud.yahoo.com...\n>>\n>> Mark\n>>\n>\n> I've only been half following this thread, so I apologize if this was \n> already talked about.\n>\n> Have you tried [wm protocol] command. You would use it like this:\n>\n>    wm protocol . WM_DELETE_WINDOW do_quit\n>\n> This basically traps the signal from the windowmanager, and [do_quit] \n> gets executed *before* the gui is torn down. The only bad thing about \n> this, is if you explicitly destroy a widget inside your code (i.e. \n> [destroy .]), then this will *not* get invoked. You also need to make \n> sure you catch any possible errors in do_quit, otherwise the gui will \n> hang.\n>\n> HTH,\n>    --brett\n>\nThank you - that is exactly what I was looking for but couldn't find. \nI'll generate another patch tonight.\n\nMark \n"}]}