SDL app keeping focus

Hi

I’m using Windows and from time to time, my SDL app loses focus (that is, gets minimised or similar) - is there a way to keep it onscreen all the time? It’s a full screen game so it gets a bit annoying when it happens!

Thanks
Ed___________________________________________________________
Yahoo! Mail is the world’s favourite email. Don’t settle for less, sign up for
your free account today http://uk.rd.yahoo.com/evt=44106/*http://uk.docs.yahoo.com/mail/winter07.html

This may not be an SDL issue. I’ve seen the same thing happen with
numerous games, and it seems to me (on my system at least) that it
happens whenever Zonealarm updates itself. There may be other causes
as well.

-JustinOn 7/19/07, Edward Byard <e_byard at yahoo.co.uk> wrote:

Hi

I’m using Windows and from time to time, my SDL app loses focus (that is,
gets minimised or similar) - is there a way to keep it onscreen all the
time? It’s a full screen game so it gets a bit annoying when it happens!

Thanks
Ed

Hello !

I’m using Windows and from time to time, my SDL app loses focus (that is,
gets minimised or similar) - is there a way to keep it onscreen all the
time? It’s a full screen game so it gets a bit annoying when it happens!

Did you try if this happens also with the
testprogramms like testsprite, testgl, … ?

What Windows do you use XP, Vista, … ?

It may be also that another programm that is running
is stealing the focus from your app. For example ZoneAlarm
has this problem, even when not opening a window, it sometimes
steals the focus.

CU

Without my docs at hand I’m just guessing. Is there an event that
detects loss of focus? If so, is there a means to regain the focus?–
Lilith

On 7/19/2007 at 7:15 AM, “Torsten Giebl” wrote:
Hello !

I’m using Windows and from time to time, my SDL app loses focus
(that is,

gets minimised or similar) - is there a way to keep it onscreen all
the

time? It’s a full screen game so it gets a bit annoying when it
happens!

Did you try if this happens also with the
testprogramms like testsprite, testgl, … ?

What Windows do you use XP, Vista, … ?

It may be also that another programm that is running
is stealing the focus from your app. For example ZoneAlarm
has this problem, even when not opening a window, it sometimes
steals the focus.

CU


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Yes and maybe.

You can detect loss or gain of focus with:
http://www.libsdl.org/cgi/docwiki.cgi/SDL_5fActiveEvent

Now, I haven’t tried this but at a guess I’d say using SDL_PushEvent to
drop in the kind of event that would cause the game to automatically
regain focus and raise to the front of the display (like a mouseclick)
would be a good bet.
http://www.libsdl.org/cgi/docwiki.cgi/SDL_5fPushEvent

Hope this helps.On Thu, 2007-07-19 at 09:29 -0500, Lilith Calbridge wrote:

Without my docs at hand I’m just guessing. Is there an event that
detects loss of focus? If so, is there a means to regain the focus?


All new Yahoo! Mail “The new Interface is stunning in its simplicity and ease of use.” - PC Magazine
http://uk.docs.yahoo.com/nowyoucan.html

Lilith Calbridge <lilith dcccd.edu> writes:

Without my docs at hand I’m just guessing. Is there an event that
detects loss of focus? If so, is there a means to regain the focus?

The only loss-of-focus message I’m aware of under Windows is WM_KILLFOCUS, which
a program can choose to handle. If not, it doesn’t get it in the event queue.

This message occurs when a program is about to lose keyboard focus, which
typically means the window which is active is about to become inactive, and
another window will become the active one. But this isn’t necessarily the case
(though I can’t think of any examples off hand for which it isn’t true).

The only way to get it back is this call (straight out of the VC docs):
HWND SetFocus(
HWND hWnd // handle to window to receive focus
);

If you are handling this message for your own window, then probably the best way
to do it is to have a handler for WM_KILLFOCUS, which internally has a little
bit of a delay and then calls SetFocus back onto the main window of your app.

IMHO, a background app grabbing the focus and then not giving back up again
within a few moments is rather scary. What’s the point of a background app
getting keyboard access anyway - it seems rather pointless. Whatever work that
app is doing should be done in a windowless worker thread - it does what it
needs to without interfering with what the user is doing.

-J

Lilith Calbridge <lilith dcccd.edu> writes:

Without my docs at hand I’m just guessing. Is there an event that
detects loss of focus? If so, is there a means to regain the
focus?

The only loss-of-focus message I’m aware of under Windows is
WM_KILLFOCUS,
which
a program can choose to handle. If not, it doesn’t get it in the
event
queue.

This message occurs when a program is about to lose keyboard focus,
which
typically means the window which is active is about to become
inactive, and
another window will become the active one. But this isn’t necessarily
the
case
(though I can’t think of any examples off hand for which it isn’t
true).

The only way to get it back is this call (straight out of the VC
docs):
HWND SetFocus(
HWND hWnd // handle to window to receive focus
);

If you are handling this message for your own window, then probably
the best
way
to do it is to have a handler for WM_KILLFOCUS, which internally has
a
little
bit of a delay and then calls SetFocus back onto the main window of
your
app.

IMHO, a background app grabbing the focus and then not giving back up
again
within a few moments is rather scary. What’s the point of a
background app
getting keyboard access anyway - it seems rather pointless. Whatever
work
that
app is doing should be done in a windowless worker thread - it does
what it
needs to without interfering with what the user is doing.

The things that pop up on me seem to be mostly system utility like
"Your Windows OS needs a security update" and utilities that feel they
need to tell you that something is complete. Apparently they seem to
feel that what they have to say is important enough to interrupt what
you’re doing.

Another thing that has cost me focus is that I have a dual monitor
system so it’s fairly easy for me to accidentally move the cursor to the
other window unintentionally.>>> On 7/22/2007 at 1:57 AM, Jason <jesus_freak at picknowl.com.au> wrote:


Lilith

Lilith Calbridge <lilith dcccd.edu> writes:

> > IMHO, a background app grabbing the focus and then not giving back up again > within a few moments is rather scary. What's the point of a background app > getting keyboard access anyway - it seems rather pointless. Whatever work > that > app is doing should be done in a windowless worker thread - it does what it > needs to without interfering with what the user is doing.

The things that pop up on me seem to be mostly system utility like
"Your Windows OS needs a security update" and utilities that feel they
need to tell you that something is complete. Apparently they seem to
feel that what they have to say is important enough to interrupt what
you’re doing.

I guess this is another thing that should go into the "good programming guide"
or whatever. My security software has an option to turn this off, which I
promptly did. Unfortunately, some companies think they are so important that
they think they can tell you what you “have” to do, in whatever way they want.
IMHO, it’s better to let the user specify to the program how to interact (if at
all!).

A good company which wants good PR will accept suggestions of changes to things
like this. If they don’t take such suggestions, well, I tell them I’m taking my
business elsewhere - and with me that’s not just words…

-J