From: Damon C. <da...@tc...> - 2014-12-17 20:33:31
|
A little more background. The code Larry provided there is our solution on the Mac. It’s called on init to bring the app window into the foreground when the app starts, which is not the standard Mac behavior, but I believe it’s the right behavior for us. We got that solved. Upon further examination, the other problem we were having only occurs on Windows 8+, so it’s something Microsoft changed. Most of you may not notice it because you’re not launching your apps the way we are. In our case, our apps are launched from a Windows Explorer shell extension, and as of Windows 8, they launch BEHIND the Explorer window instead of in front where they have forever. Now, I found a solution for this as well, but I think the proper solution is to add a “-force” option to the raise command (or some tk / wm command) to force the window (and process) to the foreground. Right now we’ve modified tkWinWm.c:TkWinSetForegroundWindow() to force the window to the front, which forces the app into the foreground. This works for our apps, but I think it’s the wrong behavior overall. We should probably add a TkWinForceForegroundWindow() and then find somewhere to call that at the script level. Anyhoo, just an update to let you all know we figured out the problem. I’m sure you were all greatly concerned. :) D > On Dec 16, 2014, at 4:10 PM, Larry McVoy <lm...@mc...> wrote: > > On Tue, Dec 16, 2014 at 10:01:49PM +0000, l....@su... wrote: >> I've seen the same windows-open-backgrounded behaviour on Macs, but then my unix Tk app is launched from a command line how did you work around it? > > ==== src/gui/tcltk/tk/macosx/tkMacOSXInit.c ==== > 2014-12-16 15:53:36-06:00, damon@damon.local +13 -3 > Foreground the process using newer API calls on OS X 10.10 and beyond. > > --- 1.30/src/gui/tcltk/tk/macosx/tkMacOSXInit.c 2014-08-07 15:43:31 -05:00 > +++ 1.31/src/gui/tcltk/tk/macosx/tkMacOSXInit.c 2014-12-16 15:53:36 -06:00 > @@ -311,8 +311,6 @@ TkpInit( > CFRelease(bundleUrl); > } > #ifdef BK > - ProcessSerialNumber psn; > - > /* Make sure the window comes up in the front of the calling > * application. The problem this solves is that if you exec > * the wish shell that is inside the application bundle, the > @@ -321,8 +319,20 @@ TkpInit( > * front of the Z-axis stacking order that the Window Server > * keeps. > */ > - if (GetCurrentProcess(&psn) >= 0) SetFrontProcess(&psn); > +#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_10 > + ProcessSerialNumber psn; > + > + if (GetCurrentProcess(&psn) >= 0) { > + TransformProcessType(&psn, > + kProcessTransformToForegroundApplication); > + SetFrontProcess(&psn); > + } > +#else > + /* In case we are unbundled, make us a proper UI application */ > + [NSApp setActivationPolicy: NSApplicationActivationPolicyRegular]; > + [NSApp activateIgnoringOtherApps:YES]; > #endif > +#endif /* BK */ > > if (!bundledExecutable) { > |