SDL raise window

Posts: 45
Joined: 2006.07
Post: #1
If I start my SDL app via the command line like
it starts with the window behind every other window, which is kind of annoying. However, if I open it with the command
then it starts as the topmost window. Does anyone know if there is a programmatic way of bringing the window to the top via SDL or native mac functions?
Quote this message in a reply
Posts: 283
Joined: 2006.05
Post: #2
I'm sure it'd be pretty easy to bring the application to the front after it finishes launching. If there isn't a way to do it in SDL, you could presumably use Cocoa in SDLMain.m.

But I wouldn't do that in a released application; Mac apps are meant to launch in the background if the user switches application while they're starting.
Quote this message in a reply
Posts: 1,487
Joined: 2002.09
Post: #3
Though it does end up being a problem when you get the "are you sure you want to open this app downloaded from the interwebs" dialog in the Finder. If you have a lot of Finder windows open, it will open the app underneath all of them. Very annoying, but I don't in general see a way to fix it without making it equally annoying by stealing focus.

Eclipse steals focus not once, but twice during it's lengthy startup so it can display a splash screen and then again to display the splash screen progress bar. I think without that simple but obnoxious flaw, I would hate Eclipse half as much as I do. As it is, it acts as a nice daily poke in the eye to remind me.

So it's annoying that the programs open underneath, but many users find the alternative much more frustrating.

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Posts: 5,143
Joined: 2002.04
Post: #4
[NSApp activateIgnoringOtherApps:YES];

To avoid stealing focus from a double-clicking user I don't call this unless the environment variable FOREGROUND is set, so in the terminal I can go

make && FOREGROUND=1 ./

You could also check whether stdin is a tty, for example.
Quote this message in a reply
Post Reply