Preventing start of screensaver - handling of platform dependent messages

Hi SDL-guru’s!

I’ve written an application using SDL and OpenGL. My main target is
Windows, but my program runs just fine in Linux as well.

When my program runs fullscreen I would like to be able to prevent the
screensaver from starting. As far as I know the only possible way to do
this is described by the following comment which I copy/pasted from a
Windows header file:

/****************************************************************************
ScreenSaver support
The current application will receive a syscommand of SC_SCREENSAVE just
before the screen saver is invoked. If the app wishes to prevent a
screen save, return non-zero value, otherwise call DefWindowProc().
****************************************************************************/

Now I know that SDL has a pretty flexible way of handling platform
dependent messages. I am able to receive an event whenever a
WM_SYSCOMMAND message is sent to my window through the use of the
SDL_SYSWMEVENT event and the SDL_SysWMmsg struct.

But what I am not able to do (and what I would like to be able to do)
is specify the return value! I assume that the (Windows) SDL code does
the following whenever it receives an unhandled message:

  • fill SDL_SysWMmsg struct
  • send SDL_SYSWMEVENT event containing that struct
  • return 0

But as you know by now, I want to return everything BUT 0 … does
anyone have a solution for this? I’ve searched the SDL headers for a
different way of blocking the screensaver, but without any results.

Thanks in advance!

Marc

Hi SDL-guru’s!

I’ve written an application using SDL and OpenGL. My main target is
Windows, but my program runs just fine in Linux as well.

When my program runs fullscreen I would like to be able to prevent the
screensaver from starting. As far as I know the only possible way to do
this is described by the following comment which I copy/pasted from a
Windows header file:

/****************************************************************************
ScreenSaver support
The current application will receive a syscommand of SC_SCREENSAVE just
before the screen saver is invoked. If the app wishes to prevent a
screen save, return non-zero value, otherwise call DefWindowProc().
****************************************************************************/

Now I know that SDL has a pretty flexible way of handling platform
dependent messages. I am able to receive an event whenever a
WM_SYSCOMMAND message is sent to my window through the use of the
SDL_SYSWMEVENT event and the SDL_SysWMmsg struct.

But what I am not able to do (and what I would like to be able to do)
is specify the return value! I assume that the (Windows) SDL code does
the following whenever it receives an unhandled message:

  • fill SDL_SysWMmsg struct
  • send SDL_SYSWMEVENT event containing that struct
  • return 0

But as you know by now, I want to return everything BUT 0 … does
anyone have a solution for this? I’ve searched the SDL headers for a
different way of blocking the screensaver, but without any results.

Thanks in advance!

Marc

As far as I remember, there’s a function that sets the screensaver flag (is it running or not). So you can set it (making your application a screensaver) and no more screensavers would appear.On Thu, 18 Dec 2003 16:15:11 +0100 “M.A. Oude Kotte” wrote:


Vladimir [Farcaller] Puzanov
farcaller at bigmir.net
Vladimir_Puzanov at p7.f626.n463.z2.fidonet.org
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20031218/c7af9919/attachment.pgp

Yay! Your remark suddenly reminded me of SystemParametersInfo()! It has
a function to enable and disable screensaving, and now it works :slight_smile:
Thanks alot :slight_smile:

Marc

Vladimir Puzanov wrote:> On Thu, 18 Dec 2003 16:15:11 +0100 “M.A. Oude Kotte” <@M.A_Oude_Kotte> wrote:

Hi SDL-guru’s!
<>
Thanks in advance!

Marc

As far as I remember, there’s a function that sets the screensaver flag (is it running or not). So you can set it (making your application a screensaver) and no more screensavers would appear.

You shouldn’t have to do anything. SDL handles SC_SCREENSAVE on its own;
you should never get a screensaver while an SDL application is running
(or at least while it has focus).

However, there was a bug up to 1.2.6: the WINDIB driver failed to do
this (but the DX5 one worked). This is fixed in the development branch,
but I don’t think it’s been backported to 1.2.

I don’t really know how this went undetected for so long; screensavers
popping up in games is something people notice very quickly. Possibly
most people end up on the DX5 driver.

I’d be very careful with SystemParametersInfo: that might be a system
global setting–if you don’t restore the original setting (eg. application
or system crash), you might turn people’s screensavers off permanently,
which would be very annoying.

http://www.libsdl.org/pipermail/sdl-cvs/2003-September/000295.htmlOn Thu, Dec 18, 2003 at 04:15:11PM +0100, M.A. Oude Kotte wrote:

Now I know that SDL has a pretty flexible way of handling platform
dependent messages. I am able to receive an event whenever a
WM_SYSCOMMAND message is sent to my window through the use of the
SDL_SYSWMEVENT event and the SDL_SysWMmsg struct.


Glenn Maynard