{"thread":{"id":"34037","subject":"[PATCH] git-gui: bring Wish process to front on Mac","startedAt":"2013-06-06T08:17:47Z","lastAt":"2013-06-15T23:07:21Z","messageCount":8,"participants":["Stefan Haller","Pat Thoyts","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"219489","messageId":"1370506667-24576-1-git-send-email-stefan@haller-berlin.de","threadId":"34037","inReplyTo":null,"subject":"[PATCH] git-gui: bring Wish process to front on Mac","fromName":"Stefan Haller","fromEmail":"stefan@haller-berlin.de","sentAt":"2013-06-06T08:17:47Z","receivedAt":"2013-06-06T08:17:47Z","isPatch":true,"sender":{"key":"stefan@haller-berlin.de","avatar":"https://avatars.githubusercontent.com/u/1225667?v=4"},"body":"On Mac OS X, any application that is started from the Terminal will open\nbehind all running applications; as a work-around, manually bring ourselves\nto the front. (Stolen from gitk, commit 76bf6ff93e.)\n\nWe do this as the very first thing, so that any message boxes that might pop\nup during the rest of the startup sequence are actually seen by the user.\n\nSigned-off-by: Stefan Haller <stefan@haller-berlin.de>\n---\n git-gui.sh | 13 +++++++++++++\n 1 file changed, 13 insertions(+)\n\ndiff --git a/git-gui.sh b/git-gui.sh\nindex e133331..c464928 100755\n--- a/git-gui.sh\n+++ b/git-gui.sh\n@@ -29,6 +29,19 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA}]\n \n ######################################################################\n ##\n+## On Mac, bring the current Wish process window to front\n+\n+if {[tk windowingsystem] eq \"aqua\"} {\n+\texec osascript -e [format {\n+\t\ttell application \"System Events\"\n+\t\t\tset frontmost of processes whose unix id is %d to true\n+\t\tend tell\n+\t} [pid] ]\n+}\n+\n+\n+######################################################################\n+##\n ## Tcl/Tk sanity check\n \n if {[catch {package require Tcl 8.4} err]\n-- \n1.8.3.14.g33f718c\n"},{"id":"219508","messageId":"CABNJ2G+h3zh+=wLA0KHjUn8TsfhqUK1Kn-1_=6hnXVRJUPhuuA@mail.gmail.com","threadId":"34037","inReplyTo":"1370506667-24576-1-git-send-email-stefan@haller-berlin.de","subject":"Re: [PATCH] git-gui: bring Wish process to front on Mac","fromName":"Pat Thoyts","fromEmail":"patthoyts@gmail.com","sentAt":"2013-06-06T14:09:32Z","receivedAt":"2013-06-06T14:09:32Z","isPatch":true,"sender":{"key":"patthoyts@gmail.com","avatar":"https://gravatar.com/avatar/bee887a777c790bd241f398217723fbe4b854428671db83db32216a28654cb25?d=mp&s=160"},"body":"On 6 June 2013 09:17, Stefan Haller <stefan@haller-berlin.de> wrote:\n> On Mac OS X, any application that is started from the Terminal will open\n> behind all running applications; as a work-around, manually bring ourselves\n> to the front. (Stolen from gitk, commit 76bf6ff93e.)\n>\n> We do this as the very first thing, so that any message boxes that might pop\n> up during the rest of the startup sequence are actually seen by the user.\n>\n> Signed-off-by: Stefan Haller <stefan@haller-berlin.de>\n> ---\n>  git-gui.sh | 13 +++++++++++++\n>  1 file changed, 13 insertions(+)\n>\n> diff --git a/git-gui.sh b/git-gui.sh\n> index e133331..c464928 100755\n> --- a/git-gui.sh\n> +++ b/git-gui.sh\n> @@ -29,6 +29,19 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA}]\n>\n>  ######################################################################\n>  ##\n> +## On Mac, bring the current Wish process window to front\n> +\n> +if {[tk windowingsystem] eq \"aqua\"} {\n> +       exec osascript -e [format {\n> +               tell application \"System Events\"\n> +                       set frontmost of processes whose unix id is %d to true\n> +               end tell\n> +       } [pid] ]\n> +}\n> +\n> +\n> +######################################################################\n> +##\n>  ## Tcl/Tk sanity check\n>\n>  if {[catch {package require Tcl 8.4} err]\n> --\n> 1.8.3.14.g33f718c\n>\n\nSeems fine to me. I can't test this as I have no access to this\nplatform. Possibly you should run this in a catch statement so it can\nignore any errors and I would tend to use the 'auto_execok' command to\nensure that osascript actually exists. Something like\n\n  set arg [format {tell application......}]\n  catch {exec {*}[auto_execok osascript] -e $arg [pid]}\n\nbut possibly this is guaranteed to exist on all macs which would make\nthe above redundant. What I'm thinking is you dont want the app to\nexit just because something goes wrong in this call.\n"},{"id":"219514","messageId":"1l424u5.uk987q18u3oxfM%lists@haller-berlin.de","threadId":"34037","inReplyTo":"CABNJ2G+h3zh+=wLA0KHjUn8TsfhqUK1Kn-1_=6hnXVRJUPhuuA@mail.gmail.com","subject":"Re: [PATCH] git-gui: bring Wish process to front on Mac","fromName":"Stefan Haller","fromEmail":"lists@haller-berlin.de","sentAt":"2013-06-06T17:12:07Z","receivedAt":"2013-06-06T17:12:07Z","isPatch":true,"sender":{"key":"lists@haller-berlin.de","avatar":null},"body":"Pat Thoyts <patthoyts@gmail.com> wrote:\n\n> On 6 June 2013 09:17, Stefan Haller <stefan@haller-berlin.de> wrote:\n> > +## On Mac, bring the current Wish process window to front\n> > +\n> > +if {[tk windowingsystem] eq \"aqua\"} {\n> > +       exec osascript -e [format {\n> > +               tell application \"System Events\"\n> > +                       set frontmost of processes whose unix id is %d to true\n> > +               end tell\n> > +       } [pid] ]\n> > +}\n> \n> Seems fine to me. I can't test this as I have no access to this\n> platform. Possibly you should run this in a catch statement so it can\n> ignore any errors and I would tend to use the 'auto_execok' command to\n> ensure that osascript actually exists. Something like\n> \n>   set arg [format {tell application......}]\n>   catch {exec {*}[auto_execok osascript] -e $arg [pid]}\n> \n> but possibly this is guaranteed to exist on all macs which would make\n> the above redundant. What I'm thinking is you dont want the app to\n> exit just because something goes wrong in this call.\n\nI don't think we need auto_execok here, as osascript is available on\nevery Mac system. We might even specify the exact path, it's always\n/usr/bin/osascript. Is that preferable?\n\nI agree that \"catch\" might be a good idea though. It raises two\nquestions though:\n\n1) Should we make the same change in gitk then? It already has the same\n   code without the catch (released in 1.8.3 already, btw).\n\n2) Should we think about some way of sharing code between gitk and\n   git gui, so that these kinds of changes don't have to be made twice?\n\n\n-- \nStefan Haller\nBerlin, Germany\nhttp://www.haller-berlin.de/\n"},{"id":"219522","messageId":"7vk3m7yukc.fsf@alter.siamese.dyndns.org","threadId":"34037","inReplyTo":"CABNJ2G+h3zh+=wLA0KHjUn8TsfhqUK1Kn-1_=6hnXVRJUPhuuA@mail.gmail.com","subject":"Re: [PATCH] git-gui: bring Wish process to front on Mac","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-06-06T18:15:31Z","receivedAt":"2013-06-06T18:15:31Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Pat Thoyts <patthoyts@gmail.com> writes:\n\n> Seems fine to me. I can't test this as I have no access to this\n> platform. Possibly you should run this in a catch statement so it can\n> ignore any errors and I would tend to use the 'auto_execok' command to\n> ensure that osascript actually exists. Something like\n>\n>   set arg [format {tell application......}]\n>   catch {exec {*}[auto_execok osascript] -e $arg [pid]}\n>\n> but possibly this is guaranteed to exist on all macs which would make\n> the above redundant. What I'm thinking is you dont want the app to\n> exit just because something goes wrong in this call.\n\nSounds like a sensible concern; gitk in v1.8.3 has it without catch\nso we may see failure reports from OSX users soonish, in which case\nboth this patch and gitk need to be updated for it.\n\nStefan (as your name appears in 76bf6ff93e, I am assuming that you\nwere the OSX-osascript guru in that commit) could you keep an eye on\nthe list traffic to see if users of latest gitk have issues with\nthat change, please?\n\nThanks.\n"},{"id":"219742","messageId":"1370642211-34416-1-git-send-email-stefan@haller-berlin.de","threadId":"34037","inReplyTo":"1l424u5.uk987q18u3oxfM%lists@haller-berlin.de","subject":"[PATCH v2] git-gui: bring Wish process to front on Mac","fromName":"Stefan Haller","fromEmail":"stefan@haller-berlin.de","sentAt":"2013-06-07T21:56:51Z","receivedAt":"2013-06-07T21:56:51Z","isPatch":true,"sender":{"key":"stefan@haller-berlin.de","avatar":"https://avatars.githubusercontent.com/u/1225667?v=4"},"body":"On Mac OS X, any application that is started from the Terminal will open\nbehind all running applications; as a work-around, manually bring ourselves\nto the front. (Stolen from gitk, commit 76bf6ff93e.)\n\nWe do this as the very first thing, so that any message boxes that might pop\nup during the rest of the startup sequence are actually seen by the user.\n\nSigned-off-by: Stefan Haller <stefan@haller-berlin.de>\n---\nChanges since the first patch: \n - add catch\n - specify full path to /usr/bin/osascript\n\n git-gui.sh | 15 +++++++++++++++\n 1 file changed, 15 insertions(+)\n\ndiff --git a/git-gui.sh b/git-gui.sh\nindex e133331..a792924 100755\n--- a/git-gui.sh\n+++ b/git-gui.sh\n@@ -29,6 +29,21 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA}]\n \n ######################################################################\n ##\n+## On Mac, bring the current Wish process window to front\n+\n+if {[tk windowingsystem] eq \"aqua\"} {\n+\tcatch {\n+\t\texec /usr/bin/osascript -e [format {\n+\t\t\ttell application \"System Events\"\n+\t\t\t\tset frontmost of processes whose unix id is %d to true\n+\t\t\tend tell\n+\t\t} [pid] ]\n+\t}\n+}\n+\n+\n+######################################################################\n+##\n ## Tcl/Tk sanity check\n \n if {[catch {package require Tcl 8.4} err]\n-- \n1.8.3.14.g33f718c\n"},{"id":"219743","messageId":"1l44d7u.14dslvlcdev12M%lists@haller-berlin.de","threadId":"34037","inReplyTo":"7vk3m7yukc.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] git-gui: bring Wish process to front on Mac","fromName":"Stefan Haller","fromEmail":"lists@haller-berlin.de","sentAt":"2013-06-07T21:58:35Z","receivedAt":"2013-06-07T21:58:35Z","isPatch":true,"sender":{"key":"lists@haller-berlin.de","avatar":null},"body":"Junio C Hamano <gitster@pobox.com> wrote:\n\n> Stefan (as your name appears in 76bf6ff93e, I am assuming that you\n> were the OSX-osascript guru in that commit) could you keep an eye on\n> the list traffic to see if users of latest gitk have issues with\n> that change, please?\n\nSure, will do.\n\n\n-- \nStefan Haller\nBerlin, Germany\nhttp://www.haller-berlin.de/\n"},{"id":"220898","messageId":"7vwqpwo9wd.fsf@alter.siamese.dyndns.org","threadId":"34037","inReplyTo":"1370642211-34416-1-git-send-email-stefan@haller-berlin.de","subject":"Re: [PATCH v2] git-gui: bring Wish process to front on Mac","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-06-14T17:54:42Z","receivedAt":"2013-06-14T17:54:42Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stefan Haller <stefan@haller-berlin.de> writes:\n\n> On Mac OS X, any application that is started from the Terminal will open\n> behind all running applications; as a work-around, manually bring ourselves\n> to the front. (Stolen from gitk, commit 76bf6ff93e.)\n>\n> We do this as the very first thing, so that any message boxes that might pop\n> up during the rest of the startup sequence are actually seen by the user.\n>\n> Signed-off-by: Stefan Haller <stefan@haller-berlin.de>\n> ---\n\nPat, is there any progress on this?  I do not mind, and I actually\nwould prefer, a pull request early in the development cycle.\n\n\"I've been busy and haven't got around to it\", is a perfectly\nacceptable response.  Just pinging to check.\n\n> Changes since the first patch: \n>  - add catch\n>  - specify full path to /usr/bin/osascript\n>\n>  git-gui.sh | 15 +++++++++++++++\n>  1 file changed, 15 insertions(+)\n>\n> diff --git a/git-gui.sh b/git-gui.sh\n> index e133331..a792924 100755\n> --- a/git-gui.sh\n> +++ b/git-gui.sh\n> @@ -29,6 +29,21 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA}]\n>  \n>  ######################################################################\n>  ##\n> +## On Mac, bring the current Wish process window to front\n> +\n> +if {[tk windowingsystem] eq \"aqua\"} {\n> +\tcatch {\n> +\t\texec /usr/bin/osascript -e [format {\n> +\t\t\ttell application \"System Events\"\n> +\t\t\t\tset frontmost of processes whose unix id is %d to true\n> +\t\t\tend tell\n> +\t\t} [pid] ]\n> +\t}\n> +}\n> +\n> +\n> +######################################################################\n> +##\n>  ## Tcl/Tk sanity check\n>  \n>  if {[catch {package require Tcl 8.4} err]\n"},{"id":"220967","messageId":"CABNJ2GL3zK9UqsQ-ZCVVkZwXEesjGnmuVbUeQfSKZhL6njm3BA@mail.gmail.com","threadId":"34037","inReplyTo":"7vwqpwo9wd.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v2] git-gui: bring Wish process to front on Mac","fromName":"Pat Thoyts","fromEmail":"patthoyts@gmail.com","sentAt":"2013-06-15T23:07:21Z","receivedAt":"2013-06-15T23:07:21Z","isPatch":true,"sender":{"key":"patthoyts@gmail.com","avatar":"https://gravatar.com/avatar/bee887a777c790bd241f398217723fbe4b854428671db83db32216a28654cb25?d=mp&s=160"},"body":"On 14 June 2013 18:54, Junio C Hamano <gitster@pobox.com> wrote:\n> Stefan Haller <stefan@haller-berlin.de> writes:\n>\n>> On Mac OS X, any application that is started from the Terminal will open\n>> behind all running applications; as a work-around, manually bring ourselves\n>> to the front. (Stolen from gitk, commit 76bf6ff93e.)\n>>\n>> We do this as the very first thing, so that any message boxes that might pop\n>> up during the rest of the startup sequence are actually seen by the user.\n>>\n>> Signed-off-by: Stefan Haller <stefan@haller-berlin.de>\n>> ---\n>\n> Pat, is there any progress on this?  I do not mind, and I actually\n> would prefer, a pull request early in the development cycle.\n>\n\nyep - I applied this and a couple of others and sent up a pull request\nnow. I see there are some commits in git's tree that I don't have on\nthis side so I'll merge those in here shortly.\n"}]}