git-gui: bring wish process to front on Mac
authorStefan Haller <stefan@haller-berlin.de>
Thu, 6 Jun 2013 08:17:47 +0000 (10:17 +0200)
committerPat Thoyts <patthoyts@users.sourceforge.net>
Fri, 7 Jun 2013 00:34:42 +0000 (01:34 +0100)
On Mac OS X, any application that is started from the Terminal will open
behind all running applications; as a work-around, manually bring ourselves
to the front. (Stolen from gitk, commit 76bf6ff93e.)

We do this as the very first thing, so that any message boxes that might pop
up during the rest of the startup sequence are actually seen by the user.

[PT: added catch and moved down to ensure Tk has been loaded]

Signed-off-by: Stefan Haller <stefan@haller-berlin.de>
Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
git-gui.sh
index e133331ef59a44315f5f5e42e4219902024a5c81..7031759751b87fad0e930bca9def049b30c97626 100755 (executable)
@@ -135,6 +135,20 @@ proc strcat {args} {
 ::msgcat::mcload $oguimsg
 unset oguimsg
 
+######################################################################
+##
+## On Mac, bring the current Wish process window to front
+
+if {[tk windowingsystem] eq "aqua"} {
+       catch {
+               exec osascript -e [format {
+                       tell application "System Events"
+                               set frontmost of processes whose unix id is %d to true
+                       end tell
+               } [pid]]
+       }
+}
+
 ######################################################################
 ##
 ## read only globals