* [PATCH] gitk: workaround Tcl/Tk Cmd-TAB behavior on OSX @ 2013-04-10 19:02 Tair Sabirgaliev 2013-04-10 19:12 ` Tair Sabirgaliev ` (3 more replies) 0 siblings, 4 replies; 7+ messages in thread From: Tair Sabirgaliev @ 2013-04-10 19:02 UTC (permalink / raw) To: git; +Cc: paulus On OSX Tcl/Tk application windows are created behind all the applications down the stack of windows. This is very annoying, because once a gitk window appears, it's the downmost window and switching to it is pain. The patch is trivial: if we are on OSX, emulate Cmd-Shift-TAB key event, so that the gitk application window is brought from bottom to top. Signed-off-by: Tair Sabirgaliev <tair.sabirgaliev@gmail.com> --- gitk | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/gitk b/gitk index 572f73f..60a87fc 100755 --- a/gitk +++ b/gitk @@ -11687,6 +11687,19 @@ if {[catch {package require Tk 8.4} err]} { exit 1 } +# On OSX workaround the Tcl/Tk windows going down the stack of Cmd-TAB +if {[tk windowingsystem] eq "aqua"} { + exec osascript -e { + tell application "System Events" + key down command + key down shift + keystroke tab + key up shift + key up command + end tell + } +} + # Unset GIT_TRACE var if set if { [info exists ::env(GIT_TRACE)] } { unset ::env(GIT_TRACE) -- 1.8.2 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] gitk: workaround Tcl/Tk Cmd-TAB behavior on OSX 2013-04-10 19:02 [PATCH] gitk: workaround Tcl/Tk Cmd-TAB behavior on OSX Tair Sabirgaliev @ 2013-04-10 19:12 ` Tair Sabirgaliev [not found] ` <CAJDDKr76K_-d6JSgv67DcXnZybpxkTjYPJxdObU3wrn+nYV3dw@mail.gmail.com> ` (2 subsequent siblings) 3 siblings, 0 replies; 7+ messages in thread From: Tair Sabirgaliev @ 2013-04-10 19:12 UTC (permalink / raw) To: git; +Cc: paulus The prev message was garbled :( Here is the correct patch (I hope). On OSX Tcl/Tk application windows are created behind all the applications down the stack of windows. This is very annoying, because once a gitk window appears, it's the downmost window and switching to it is pain. The patch is trivial: if we are on OSX, emulate Cmd-Shift-TAB key event, so that the gitk application window is brought from bottom to top. Signed-off-by: Tair Sabirgaliev <tair.sabirgaliev@gmail.com> --- gitk | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/gitk b/gitk index 572f73f..60a87fc 100755 --- a/gitk +++ b/gitk @@ -11687,6 +11687,19 @@ if {[catch {package require Tk 8.4} err]} { exit 1 } +# On OSX workaround the Tcl/Tk windows going down the stack of Cmd-TAB +if {[tk windowingsystem] eq "aqua"} { + exec osascript -e { + tell application "System Events" + key down command + key down shift + keystroke tab + key up shift + key up command + end tell + } +} + # Unset GIT_TRACE var if set if { [info exists ::env(GIT_TRACE)] } { unset ::env(GIT_TRACE) -- 1.8.2 ^ permalink raw reply related [flat|nested] 7+ messages in thread
[parent not found: <CAJDDKr76K_-d6JSgv67DcXnZybpxkTjYPJxdObU3wrn+nYV3dw@mail.gmail.com>]
* Re: [PATCH] gitk: workaround Tcl/Tk Cmd-TAB behavior on OSX [not found] ` <CAJDDKr76K_-d6JSgv67DcXnZybpxkTjYPJxdObU3wrn+nYV3dw@mail.gmail.com> @ 2013-04-11 4:36 ` Tair Sabirgaliev 0 siblings, 0 replies; 7+ messages in thread From: Tair Sabirgaliev @ 2013-04-11 4:36 UTC (permalink / raw) To: David Aguilar; +Cc: Git Mailing List, Paul Mackerras On 4/11/13 8:46 AM, David Aguilar wrote: > Apologies because I don't know the Tk API very well. > > In Qt there is an API method to raise windows -- QWidget::raise(). > > Is there no similar API in Tk? > > I seems like this may be related: > > http://wiki.tcl.tk/9457 > > ..but it seems that -topmost may not be exactly the same thing. > > That said, if there's no portable way to do it, then this is certainly a > workaround. Yes, I tried that one. Here is a quick test: ========== hello.tcl ============= #!/bin/sh # Tcl ignores the next line -*- tcl -*- \ exec wish "$0" -- "$@" package require Tk grid [ttk::button .b -text "Hello World"] wm attributes . -topmost true ================================== I'm not sure I'm doing it right, but it doesn't work. Look like Tcl/Tk dev are very paranoic about windows created from Terminal/shell scripts: they don't let them take over , even if it is desired. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] gitk: workaround Tcl/Tk Cmd-TAB behavior on OSX 2013-04-10 19:02 [PATCH] gitk: workaround Tcl/Tk Cmd-TAB behavior on OSX Tair Sabirgaliev 2013-04-10 19:12 ` Tair Sabirgaliev [not found] ` <CAJDDKr76K_-d6JSgv67DcXnZybpxkTjYPJxdObU3wrn+nYV3dw@mail.gmail.com> @ 2013-04-20 3:19 ` Paul Mackerras 2013-04-20 10:45 ` Tair Sabirgaliev 2013-04-23 13:26 ` Stefan Haller 3 siblings, 1 reply; 7+ messages in thread From: Paul Mackerras @ 2013-04-20 3:19 UTC (permalink / raw) To: Tair Sabirgaliev; +Cc: git On Thu, Apr 11, 2013 at 01:02:48AM +0600, Tair Sabirgaliev wrote: > On OSX Tcl/Tk application windows are created behind all > the applications down the stack of windows. This is very > annoying, because once a gitk window appears, it's the > downmost window and switching to it is pain. > > The patch is trivial: if we are on OSX, emulate Cmd-Shift-TAB > key event, so that the gitk application window is brought > from bottom to top. > > Signed-off-by: Tair Sabirgaliev <tair.sabirgaliev@gmail.com> > --- > gitk | 13 +++++++++++++ > 1 file changed, 13 insertions(+) > > diff --git a/gitk b/gitk > index 572f73f..60a87fc 100755 > --- a/gitk > +++ b/gitk > @@ -11687,6 +11687,19 @@ if {[catch {package require Tk 8.4} err]} { > exit 1 > } > +# On OSX workaround the Tcl/Tk windows going down the stack of Cmd-TAB > +if {[tk windowingsystem] eq "aqua"} { > + exec osascript -e { > + tell application "System Events" > + key down command > + key down shift > + keystroke tab > + key up shift > + key up command > + end tell + } > +} Is this really the only way to do it? It seems a bit hacky to me. I would think you should be able to use the "wm" command to achieve what you want. I don't use Mac OS, so I don't know exactly how Tcl/Tk behaves on it, but this page looks like it might hold some clues for what you want to do: http://teapot.activestate.com/package/name/windowlist/ver/1.4/arch/tcl/file.tm Paul. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] gitk: workaround Tcl/Tk Cmd-TAB behavior on OSX 2013-04-20 3:19 ` Paul Mackerras @ 2013-04-20 10:45 ` Tair Sabirgaliev 0 siblings, 0 replies; 7+ messages in thread From: Tair Sabirgaliev @ 2013-04-20 10:45 UTC (permalink / raw) To: Paul Mackerras; +Cc: git On Apr 20, 2013, at 9:19 AM, Paul Mackerras <paulus@samba.org> wrote: > On Thu, Apr 11, 2013 at 01:02:48AM +0600, Tair Sabirgaliev wrote: >> On OSX Tcl/Tk application windows are created behind all >> the applications down the stack of windows. This is very >> annoying, because once a gitk window appears, it's the >> downmost window and switching to it is pain. >> >> The patch is trivial: if we are on OSX, emulate Cmd-Shift-TAB >> key event, so that the gitk application window is brought >> from bottom to top. > > Is this really the only way to do it? It seems a bit hacky to me. I > would think you should be able to use the "wm" command to achieve what > you want. I don't use Mac OS, so I don't know exactly how Tcl/Tk > behaves on it, but this page looks like it might hold some clues for > what you want to do: > > http://teapot.activestate.com/package/name/windowlist/ver/1.4/arch/tcl/file.tm Today I did some further investigations on reasons app windows going behind. Turns out this is not something specific to Tcl/Tk. On OSX, GUI applications can be launched from Terminal in 2 ways: 1. Interactively, directly using app executable: sh$ /Applications/Chess.app/Contents/MacOS/Chess 2. Asynchronously, using OSX 'open' facility sh$ open -a Chess The problem with 1st way is that OSX always puts the new app window behind the others, thus making sure the focus remains at Terminal input. The problem with the 2nd approach is that app is launched 'asynchronously', detached from Terminal, so when you close the app, focus doesn't necessarily return back to Terminal as it would normally do in Linux for example. So, yes, this is a really hacky workaround, but it consistently takes the interactively launched app window to foreground on most modern OSX versions. And regarding the link you provided -- I tried them, unfortunately the techniques there don't bring the application to foreground. Looks like they are mostly intended to manipulate windows within a single multi-window application. Tair. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] gitk: workaround Tcl/Tk Cmd-TAB behavior on OSX 2013-04-10 19:02 [PATCH] gitk: workaround Tcl/Tk Cmd-TAB behavior on OSX Tair Sabirgaliev ` (2 preceding siblings ...) 2013-04-20 3:19 ` Paul Mackerras @ 2013-04-23 13:26 ` Stefan Haller 2013-04-24 9:48 ` [PATCH 1] gitk: on OSX bring the gitk window to front Tair Sabirgaliev 3 siblings, 1 reply; 7+ messages in thread From: Stefan Haller @ 2013-04-23 13:26 UTC (permalink / raw) To: Tair Sabirgaliev, git; +Cc: paulus Tair Sabirgaliev <tair.sabirgaliev@bee.kz> wrote: > On OSX Tcl/Tk application windows are created behind all > the applications down the stack of windows. This is very > annoying, because once a gitk window appears, it's the > downmost window and switching to it is pain. > > The patch is trivial: if we are on OSX, emulate Cmd-Shift-TAB > key event, so that the gitk application window is brought > from bottom to top. > > Signed-off-by: Tair Sabirgaliev <tair.sabirgaliev@gmail.com> > --- > > +# On OSX workaround the Tcl/Tk windows going down the stack of Cmd-TAB > +if {[tk windowingsystem] eq "aqua"} { > + exec osascript -e { > + tell application "System Events" > + key down command > + key down shift > + keystroke tab > + key up shift > + key up command > + end tell + } > +} > + First of all, I absolutely want this behaviour. Bringing windows up in the background is one of the biggest usability problems of git on Mac. However, I don't think that synthesizing the keystrokes for Command-Shift-Tab is a good solution. It would be better to explicitly bring our process to the front. One way to achieve this would be: if {[tk windowingsystem] eq "aqua"} { exec osascript -e [format { tell application "System Events" set frontmost of processes whose unix id is %d to true end tell } [pid] ] } (Not sure about the formatting, I don't speak Tcl...) Also, we need the same thing in git gui as well. Best, Stefan -- Stefan Haller Berlin, Germany http://www.haller-berlin.de/ ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1] gitk: on OSX bring the gitk window to front 2013-04-23 13:26 ` Stefan Haller @ 2013-04-24 9:48 ` Tair Sabirgaliev 0 siblings, 0 replies; 7+ messages in thread From: Tair Sabirgaliev @ 2013-04-24 9:48 UTC (permalink / raw) To: Stefan Haller; +Cc: git, paulus On OSX Tcl/Tk application windows are created behind all the applications down the stack of windows. This is very annoying, because once a gitk window appears, it's the downmost window and switching to it is pain. The patch is: if we are on OSX, use osascript to bring the current Wish process window to front. Signed-off-by: Tair Sabirgaliev <tair.sabirgaliev@gmail.com> Thanks-to: Stefan Haller <lists@haller-berlin.de> --- gitk | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gitk b/gitk index 572f73f..66e59b1 100755 --- a/gitk +++ b/gitk @@ -11687,6 +11687,15 @@ if {[catch {package require Tk 8.4} err]} { exit 1 } +# on OSX bring the current Wish process window to front +if {[tk windowingsystem] eq "aqua"} { + exec osascript -e [format { + tell application "System Events" + set frontmost of processes whose unix id is %d to true + end tell + } [pid] ] +} + # Unset GIT_TRACE var if set if { [info exists ::env(GIT_TRACE)] } { unset ::env(GIT_TRACE) -- 1.8.2.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2013-04-24 9:48 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-04-10 19:02 [PATCH] gitk: workaround Tcl/Tk Cmd-TAB behavior on OSX Tair Sabirgaliev 2013-04-10 19:12 ` Tair Sabirgaliev [not found] ` <CAJDDKr76K_-d6JSgv67DcXnZybpxkTjYPJxdObU3wrn+nYV3dw@mail.gmail.com> 2013-04-11 4:36 ` Tair Sabirgaliev 2013-04-20 3:19 ` Paul Mackerras 2013-04-20 10:45 ` Tair Sabirgaliev 2013-04-23 13:26 ` Stefan Haller 2013-04-24 9:48 ` [PATCH 1] gitk: on OSX bring the gitk window to front Tair Sabirgaliev
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).