{"thread":{"id":"16276","subject":"[PATCH (GITK)] gitk: Fix transient windows on Win32 and MacOS.","startedAt":"2008-11-11T20:55:42Z","lastAt":"2008-11-13T11:41:45Z","messageCount":7,"participants":["Alexander Gavrilov","Johannes Sixt","Paul Mackerras"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"95489","messageId":"200811112355.43352.angavrilov@gmail.com","threadId":"16276","inReplyTo":null,"subject":"[PATCH (GITK)] gitk: Fix transient windows on Win32 and MacOS.","fromName":"Alexander Gavrilov","fromEmail":"angavrilov@gmail.com","sentAt":"2008-11-11T20:55:42Z","receivedAt":"2008-11-11T20:55:42Z","isPatch":true,"sender":{"key":"angavrilov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42666?v=4"},"body":"Transient windows cause problems on these platforms:\n\n- On Win32 the windows appear in the top left corner\n  of the screen. In order to fix it, this patch causes\n  them to be explicitly centered on their parents by\n  an idle handler.\n\n- On MacOS with Tk 8.4 they appear without a title bar.\n  Since it is clearly unacceptable, this patch disables\n  transient on that platform.\n\nSigned-off-by: Alexander Gavrilov <angavrilov@gmail.com>\n---\n\n\tNOTE: This patch DEPRECATES the earlier one, called\n\t\t\"Explicitly position popup windows\"\n\n\tAlexander\n\n gitk |   44 +++++++++++++++++++++++++++++++-------------\n 1 files changed, 31 insertions(+), 13 deletions(-)\n\ndiff --git a/gitk b/gitk\nindex 9b2a6e5..e6aafe8 100755\n--- a/gitk\n+++ b/gitk\n@@ -1739,6 +1739,24 @@ proc removehead {id name} {\n     unset headids($name)\n }\n \n+proc make_transient {window origin} {\n+    global have_tk85\n+\n+    # In MacOS Tk 8.4 transient appears to work by setting\n+    # overrideredirect, which is utterly useless, since the\n+    # windows get no border, and are not even kept above\n+    # the parent.\n+    if {!$have_tk85 && [tk windowingsystem] eq {aqua}} return\n+\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+\tafter idle [list tk::PlaceWindow $window widget $origin]\n+    }\n+}\n+\n proc show_error {w top msg} {\n     message $w.m -text $msg -justify center -aspect 400\n     pack $w.m -side top -fill x -padx 20 -pady 20\n@@ -1754,7 +1772,7 @@ proc show_error {w top msg} {\n proc error_popup {msg {owner .}} {\n     set w .error\n     toplevel $w\n-    wm transient $w $owner\n+    make_transient $w $owner\n     show_error $w $w $msg\n }\n \n@@ -1763,7 +1781,7 @@ proc confirm_popup {msg {owner .}} {\n     set confirm_ok 0\n     set w .confirm\n     toplevel $w\n-    wm transient $w $owner\n+    make_transient $w $owner\n     message $w.m -text $msg -justify center -aspect 400\n     pack $w.m -side top -fill x -padx 20 -pady 20\n     button $w.ok -text [mc OK] -command \"set confirm_ok 1; destroy $w\"\n@@ -2558,7 +2576,7 @@ proc about {} {\n     }\n     toplevel $w\n     wm title $w [mc \"About gitk\"]\n-    wm transient $w .\n+    make_transient $w .\n     message $w.m -text [mc \"\n Gitk - a commit viewer for git\n \n@@ -2587,7 +2605,7 @@ proc keys {} {\n     }\n     toplevel $w\n     wm title $w [mc \"Gitk key bindings\"]\n-    wm transient $w .\n+    make_transient $w .\n     message $w.m -text \"\n [mc \"Gitk key bindings:\"]\n \n@@ -3669,7 +3687,7 @@ proc vieweditor {top n title} {\n \n     toplevel $top\n     wm title $top $title\n-    wm transient $top .\n+    make_transient $top .\n \n     # View name\n     frame $top.nfr\n@@ -7912,7 +7930,7 @@ proc mkpatch {} {\n     set patchtop $top\n     catch {destroy $top}\n     toplevel $top\n-    wm transient $top .\n+    make_transient $top .\n     label $top.title -text [mc \"Generate patch\"]\n     grid $top.title - -pady 10\n     label $top.from -text [mc \"From:\"]\n@@ -7999,7 +8017,7 @@ proc mktag {} {\n     set mktagtop $top\n     catch {destroy $top}\n     toplevel $top\n-    wm transient $top .\n+    make_transient $top .\n     label $top.title -text [mc \"Create tag\"]\n     grid $top.title - -pady 10\n     label $top.id -text [mc \"ID:\"]\n@@ -8102,7 +8120,7 @@ proc writecommit {} {\n     set wrcomtop $top\n     catch {destroy $top}\n     toplevel $top\n-    wm transient $top .\n+    make_transient $top .\n     label $top.title -text [mc \"Write commit to file\"]\n     grid $top.title - -pady 10\n     label $top.id -text [mc \"ID:\"]\n@@ -8159,7 +8177,7 @@ proc mkbranch {} {\n     set top .makebranch\n     catch {destroy $top}\n     toplevel $top\n-    wm transient $top .\n+    make_transient $top .\n     label $top.title -text [mc \"Create new branch\"]\n     grid $top.title - -pady 10\n     label $top.id -text [mc \"ID:\"]\n@@ -8322,7 +8340,7 @@ proc resethead {} {\n     set confirm_ok 0\n     set w \".confirmreset\"\n     toplevel $w\n-    wm transient $w .\n+    make_transient $w .\n     wm title $w [mc \"Confirm reset\"]\n     message $w.m -text \\\n \t[mc \"Reset branch %s to %s?\" $mainhead [string range $rowmenuid 0 7]] \\\n@@ -8502,7 +8520,7 @@ proc showrefs {} {\n     }\n     toplevel $top\n     wm title $top [mc \"Tags and heads: %s\" [file tail [pwd]]]\n-    wm transient $top .\n+    make_transient $top .\n     text $top.list -background $bgcolor -foreground $fgcolor \\\n \t-selectbackground $selectbgcolor -font mainfont \\\n \t-xscrollcommand \"$top.xsb set\" -yscrollcommand \"$top.ysb set\" \\\n@@ -9844,7 +9862,7 @@ proc choosefont {font which} {\n \tfont create sample\n \teval font config sample [font actual $font]\n \ttoplevel $top\n-\twm transient $top $prefstop\n+\tmake_transient $top $prefstop\n \twm title $top [mc \"Gitk font chooser\"]\n \tlabel $top.l -textvariable fontparam(which)\n \tpack $top.l -side top\n@@ -9961,7 +9979,7 @@ proc doprefs {} {\n     }\n     toplevel $top\n     wm title $top [mc \"Gitk preferences\"]\n-    wm transient $top .\n+    make_transient $top .\n     label $top.ldisp -text [mc \"Commit list display options\"]\n     grid $top.ldisp - -sticky w -pady 10\n     label $top.spacer -text \" \"\n-- \n1.6.0.3.15.gb8d36\n"},{"id":"95528","messageId":"491A827C.3010000@viscovery.net","threadId":"16276","inReplyTo":"200811112355.43352.angavrilov@gmail.com","subject":"Re: [PATCH (GITK)] gitk: Fix transient windows on Win32 and MacOS.","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2008-11-12T07:15:08Z","receivedAt":"2008-11-12T07:15:08Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Alexander Gavrilov schrieb:\n> Transient windows cause problems on these platforms:\n...\n> diff --git a/gitk b/gitk\n> index 9b2a6e5..e6aafe8 100755\n\nI'd appreciate if you could make it a habit to base your patches on\nversions of gitk etc. that are available from a public repository so that\nthe index information is useful:\n\nApplying: gitk: Fix transient windows on Win32 and MacOS.\nwarning: gitk-git/gitk has type 100644, expected 100755\nerror: patch failed: gitk-git/gitk:1754\nerror: gitk-git/gitk: patch does not apply\nfatal: sha1 information is lacking or useless (gitk-git/gitk).\nRepository lacks necessary blobs to fall back on 3-way merge.\nCannot fall back to three-way merge.\nPatch failed at 0001.\n\nI'm stopping here... :-(\n\n-- Hannes\n"},{"id":"95532","messageId":"18714.36964.666759.654975@cargo.ozlabs.ibm.com","threadId":"16276","inReplyTo":"491A827C.3010000@viscovery.net","subject":"Re: [PATCH (GITK)] gitk: Fix transient windows on Win32 and MacOS.","fromName":"Paul Mackerras","fromEmail":"paulus@samba.org","sentAt":"2008-11-12T08:14:28Z","receivedAt":"2008-11-12T08:14:28Z","isPatch":true,"sender":{"key":"paulus@samba.org","avatar":"https://avatars.githubusercontent.com/u/1606439?v=4"},"body":"Johannes Sixt writes:\n\n> Alexander Gavrilov schrieb:\n> > Transient windows cause problems on these platforms:\n> ...\n> > diff --git a/gitk b/gitk\n> > index 9b2a6e5..e6aafe8 100755\n> \n> I'd appreciate if you could make it a habit to base your patches on\n> versions of gitk etc. that are available from a public repository\n\nYou mean, like, git://git.kernel.org/pub/scm/gitk/gitk.git, for\ninstance? :)  That is the primary repository for gitk and it seems to\nbe what Alexander bases his patches on.\n\nPaul.\n"},{"id":"95539","messageId":"491A9398.1060100@viscovery.net","threadId":"16276","inReplyTo":"18714.36964.666759.654975@cargo.ozlabs.ibm.com","subject":"Re: [PATCH (GITK)] gitk: Fix transient windows on Win32 and MacOS.","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2008-11-12T08:28:08Z","receivedAt":"2008-11-12T08:28:08Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Paul Mackerras schrieb:\n> Johannes Sixt writes:\n>> Alexander Gavrilov schrieb:\n>>> Transient windows cause problems on these platforms:\n>> ...\n>>> diff --git a/gitk b/gitk\n>>> index 9b2a6e5..e6aafe8 100755\n>> I'd appreciate if you could make it a habit to base your patches on\n>> versions of gitk etc. that are available from a public repository\n> \n> You mean, like, git://git.kernel.org/pub/scm/gitk/gitk.git, for\n> instance? :)  That is the primary repository for gitk and it seems to\n> be what Alexander bases his patches on.\n\nYes, I mean exactly this repository. It doesn't have 9b2a6e5:\n\n$ git fetch gitk\n$ git show 9b2a6e5 --\nfatal: bad revision '9b2a6e5'\n\nI assume that Alexander has another patch applied in addition to the one\nthat he submitted, which, therefore, is no longer \"based on a publically\navailable version\".\n\n-- Hannes\n"},{"id":"95550","messageId":"bb6f213e0811120236j7c65bfe4xf95f88df440cbafb@mail.gmail.com","threadId":"16276","inReplyTo":"491A9398.1060100@viscovery.net","subject":"Re: [PATCH (GITK)] gitk: Fix transient windows on Win32 and MacOS.","fromName":"Alexander Gavrilov","fromEmail":"angavrilov@gmail.com","sentAt":"2008-11-12T10:36:48Z","receivedAt":"2008-11-12T10:36:48Z","isPatch":true,"sender":{"key":"angavrilov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42666?v=4"},"body":"On Wed, Nov 12, 2008 at 11:28 AM, Johannes Sixt <j.sixt@viscovery.net> wrote:\n> I assume that Alexander has another patch applied in addition to the one\n> that he submitted, which, therefore, is no longer \"based on a publically\n> available version\".\n\nI'm sorry, it is indeed applied over another patch (attached because I\nonly have access to Gmail Web UI right now). These patches eventually\ncome from two ends of one long series that has been gradually applied\nover the time, so I still think of them as a unit.\n\nAlexander\n\n\nFrom fc6b3728e15483734ee44a35d5023660a7da8882 Mon Sep 17 00:00:00 2001\nFrom: Alexander Gavrilov <angavrilov@gmail.com>\nDate: Sun, 9 Nov 2008 13:00:45 +0300\nSubject: [PATCH] gitk: Add accelerators to frequently used menu commands.\n\nThis commit documents keyboard accelerators used for menu\ncommands in the menu, as it is usually done, and adds some\nmore, e.g. F4 to invoke Edit View.\n\nThe changes include a workaround for handling Shift-F4 on\nsystems where XKB binds special XF86_Switch_VT_* symbols\nto Ctrl-Alt-F* combinations. Tk often receives these codes\nwhen Shift-F* is pressed, so it is necessary to bind the\nrelevant actions to them as well.\n\nSigned-off-by: Alexander Gavrilov <angavrilov@gmail.com>\n---\n gitk |   36 +++++++++++++++++++++++++++++-------\n 1 files changed, 29 insertions(+), 7 deletions(-)\n\ndiff --git a/gitk b/gitk\nindex 18d153e..9b2a6e5 100755\n--- a/gitk\n+++ b/gitk\n@@ -1801,6 +1801,11 @@ proc setoptions {} {\n # command to invoke for command, or {variable value} for radiobutton\n proc makemenu {m items} {\n     menu $m\n+    if {[tk windowingsystem] eq {aqua}} {\n+\tset Meta1 Cmd\n+    } else {\n+\tset Meta1 Ctrl\n+    }\n     foreach i $items {\n \tset name [mc [lindex $i 1]]\n \tset type [lindex $i 2]\n@@ -1826,7 +1831,9 @@ proc makemenu {m items} {\n \t\t    -value [lindex $thing 1]\n \t    }\n \t}\n-\teval $m add $params [lrange $i 4 end]\n+\tset tail [lrange $i 4 end]\n+\tregsub -all {\\yMeta1\\y} $tail $Meta1 tail\n+\teval $m add $params $tail\n \tif {$type eq \"cascade\"} {\n \t    makemenu $m.$submenu $thing\n \t}\n@@ -1860,17 +1867,17 @@ proc makewindow {} {\n     makemenu .bar {\n \t{mc \"File\" cascade {\n \t    {mc \"Update\" command updatecommits -accelerator F5}\n-\t    {mc \"Reload\" command reloadcommits}\n+\t    {mc \"Reload\" command reloadcommits -accelerator Meta1-F5}\n \t    {mc \"Reread references\" command rereadrefs}\n-\t    {mc \"List references\" command showrefs}\n-\t    {mc \"Quit\" command doquit}\n+\t    {mc \"List references\" command showrefs -accelerator F2}\n+\t    {mc \"Quit\" command doquit -accelerator Meta1-Q}\n \t}}\n \t{mc \"Edit\" cascade {\n \t    {mc \"Preferences\" command doprefs}\n \t}}\n \t{mc \"View\" cascade {\n-\t    {mc \"New view...\" command {newview 0}}\n-\t    {mc \"Edit view...\" command editview -state disabled}\n+\t    {mc \"New view...\" command {newview 0} -accelerator Shift-F4}\n+\t    {mc \"Edit view...\" command editview -state disabled -accelerator F4}\n \t    {mc \"Delete view\" command delview -state disabled}\n \t    {xx \"\" separator}\n \t    {mc \"All files\" radiobutton {selectedview 0} -command {showview 0}}\n@@ -2232,7 +2239,12 @@ proc makewindow {} {\n     bindkey <Key-Return> {dofind 1 1}\n     bindkey ? {dofind -1 1}\n     bindkey f nextfile\n-    bindkey <F5> updatecommits\n+    bind . <F5> updatecommits\n+    bind . <$M1B-F5> reloadcommits\n+    bind . <F2> showrefs\n+    bind . <Shift-F4> {newview 0}\n+    catch { bind . <Shift-Key-XF86_Switch_VT_4> {newview 0} }\n+    bind . <F4> edit_or_newview\n     bind . <$M1B-q> doquit\n     bind . <$M1B-f> {dofind 1 1}\n     bind . <$M1B-g> {dofind 1 0}\n@@ -3624,6 +3636,16 @@ proc decode_view_opts {n view_args} {\n     set newviewopts($n,args) [shellarglist $oargs]\n }\n \n+proc edit_or_newview {} {\n+    global curview\n+\n+    if {$curview > 0} {\n+\teditview\n+    } else {\n+\tnewview 0\n+    }\n+}\n+\n proc editview {} {\n     global curview\n     global viewname viewperm newviewname newviewopts\n-- \n1.6.0.2.GIT\n\n"},{"id":"95678","messageId":"18716.4705.722175.771410@cargo.ozlabs.ibm.com","threadId":"16276","inReplyTo":"bb6f213e0811120236j7c65bfe4xf95f88df440cbafb@mail.gmail.com","subject":"Re: [PATCH (GITK)] gitk: Fix transient windows on Win32 and MacOS.","fromName":"Paul Mackerras","fromEmail":"paulus@samba.org","sentAt":"2008-11-13T11:41:21Z","receivedAt":"2008-11-13T11:41:21Z","isPatch":true,"sender":{"key":"paulus@samba.org","avatar":"https://avatars.githubusercontent.com/u/1606439?v=4"},"body":"Alexander Gavrilov writes:\n\n> I'm sorry, it is indeed applied over another patch (attached because I\n> only have access to Gmail Web UI right now). These patches eventually\n> come from two ends of one long series that has been gradually applied\n> over the time, so I still think of them as a unit.\n\nI applied the attached patch.\n\nThanks,\nPaul.\n"},{"id":"95676","messageId":"18716.4729.74357.207955@cargo.ozlabs.ibm.com","threadId":"16276","inReplyTo":"200811112355.43352.angavrilov@gmail.com","subject":"Re: [PATCH (GITK)] gitk: Fix transient windows on Win32 and MacOS.","fromName":"Paul Mackerras","fromEmail":"paulus@samba.org","sentAt":"2008-11-13T11:41:45Z","receivedAt":"2008-11-13T11:41:45Z","isPatch":true,"sender":{"key":"paulus@samba.org","avatar":"https://avatars.githubusercontent.com/u/1606439?v=4"},"body":"Alexander Gavrilov writes:\n\n> Transient windows cause problems on these platforms:\n> \n> - On Win32 the windows appear in the top left corner\n>   of the screen. In order to fix it, this patch causes\n>   them to be explicitly centered on their parents by\n>   an idle handler.\n> \n> - On MacOS with Tk 8.4 they appear without a title bar.\n>   Since it is clearly unacceptable, this patch disables\n>   transient on that platform.\n> \n> Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>\n\nThanks, applied.\nPaul.\n"}]}