I’m launching a second instance of an application using :
File::startAsProcess();
Once the app has finished initialized, it calls toFront(true) on the window to bring itself to the fore, and gain focus. On Windows this works as expected. On OSX the new instance opens behind the primary instance, and focus remains with the primary instance.
Is there any way to have the new instance promote itself, or does OSX just not allow that kind of thing?
The following hack worked for me on the mac (without using ObjC++):
File app = File::getSpecialLocation(File::currentApplicationFile);
system(String::formatted(T("open %ls"), (const tchar*)app.getFullPathName()));
The ‘open’ command line program acts as if the app bundle was double clicked in the Finder, bringing it to the front.
If you call Process::makeForegroundProcess(), that actually makes exactly the same call internally. Maybe just call that before bringing the window to the front?
I find that really hard to believe, as it’d do almost exactly the same thing! Literally the first call that Component::toFront() makes will invoke that ComponentPeer::toFront method. Maybe the difference is your test for isForegroundProcess() ?