Re: [PATCH] gitk: workaround Tcl/Tk Cmd-TAB behavior on OSX
From: Tair Sabirgaliev <hidden>
Date: 2016-06-15 22:56:55
On Apr 20, 2013, at 9:19 AM, Paul Mackerras [off-list ref] wrote:
On Thu, Apr 11, 2013 at 01:02:48AM +0600, Tair Sabirgaliev wrote:quoted
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.