git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
TSTair Sabirgaliev <tair.sabirgaliev@bee.kz>
Date
Apr 20, 2013, 10:45 UTC
Message-ID
<A7483D1D-2A01-4C56-85A8-DAD781171333@bee.kz>
In-Reply-To
<20130420031955.GA30856@iris.ozlabs.ibm.com>
On Apr 20, 2013, at 9:19 AM, Paul Mackerras <paulus@samba.org> wrote:
Show 17 quoted lines
> 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.
Previous: Paul MackerrasNext: Stefan Haller
Message 4 of 7 in “gitk: workaround Tcl/Tk Cmd-TAB behavior on OSX”
  1. gitk: workaround Tcl/Tk Cmd-TAB behavior on OSXTair Sabirgaliev, Apr 10, 2013
  2. Tair SabirgalievApr 10, 2013
  3. Paul MackerrasApr 20, 2013
  4. Tair SabirgalievApr 20, 2013
  5. Stefan HallerApr 23, 2013
  6. Tair SabirgalievApr 24, 2013
  7. Tair SabirgalievApr 11, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.