Re: [PATCH] gitk: workaround Tcl/Tk Cmd-TAB behavior on OSX

2013-04-23 Thread Stefan Haller
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 
> ---
>
>   +# 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/
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] gitk: workaround Tcl/Tk Cmd-TAB behavior on OSX

2013-04-20 Thread Tair Sabirgaliev

On Apr 20, 2013, at 9:19 AM, Paul Mackerras  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.--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] gitk: workaround Tcl/Tk Cmd-TAB behavior on OSX

2013-04-19 Thread Paul Mackerras
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 
> ---
>  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.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] gitk: workaround Tcl/Tk Cmd-TAB behavior on OSX

2013-04-10 Thread Tair Sabirgaliev

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.


--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] gitk: workaround Tcl/Tk Cmd-TAB behavior on OSX

2013-04-10 Thread Tair Sabirgaliev

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 
---
 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] gitk: workaround Tcl/Tk Cmd-TAB behavior on OSX

2013-04-10 Thread Tair Sabirgaliev

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 
---
 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html