[KDE/Mac] making applications "launch in the foreground"

Ian Wadham iandw.au at gmail.com
Fri Jul 4 05:11:47 UTC 2014

Welcome aboard, René,

On 03/07/2014, at 12:48 AM, René J.V. Bertin wrote:
> I saw a patch for DrKonqi that ensures its dialog appears in the foreground on OS X, and not somewhere behind the other open (or crashed) applications. It uses the easiest solution: bring the dialog to the foreground after opening it. That's a valid approach in this case (probably not just on OS X), but the underlying reason applications open in the background appears to be an OS X default when system(), execve() or similar are used. Even OS X's own app bundles open behind the calling Terminal.app window.

That's an interesting insight.  The DrKonqi case is a bit different.  KCrash (in kdelibs) tries
to start DrK as a stand-alone process using kdeinit as an intermediary, but that always fails
in my test setup.  So the fallback is to start DrK using fork(), etc.  That is *not* preferred because
the crash might have corrupted the stack or heap, which might corrupt Dr K, but I guess it is
definitely what makes the DrK dialog come out under the window of the app that crashed.

I also found that starting a KDE application from the command-line with "open", brings the app
window on top of the terminal window, but starting it Linux-style does not.

> I've uploaded an example to a bug report about non-foreground kwallet windows that I created a while ago: https://bugs.kde.org/show_bug.cgi?id=335881#c3
> It uses code I found on StackExchange, and can easily be adapted to implement a drop-in replacement on OS X for system(), execve() or whatever posixy function is used to spawn a required application.

Cheers, Ian W.

More information about the kde-mac mailing list