How to disable screen blanking/saver?

Hi all,

How can I disable screen blanking or saver from SDL layer?
Someone may say that those function have to be disabled by the user explicitly,
not by the application, but adding “screen save on/off” menu to the application
is good idea, I think.

Thanks

Kentarou

Hi all,

How can I disable screen blanking or saver from SDL layer?

You can do it in a platform dependent manner, by accessing the SDL
system dependent hooks in SDL_syswm.h
Take a look at the scrap demo for an example of using this API:
http://www.libsdl.org/projects/scrap/

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

How can I disable screen blanking or saver from SDL layer?

You can do it in a platform dependent manner, by accessing the SDL
system dependent hooks in SDL_syswm.h
Take a look at the scrap demo for an example of using this API:
http://www.libsdl.org/projects/scrap/

Thank you, I’ve succeeded to disable screen saver. I had saw the code of XawTV.
IMHO, If SDL has abstracted API to disable it, SDL people could be more happy.

Kentarou

P.S.
Just for ml-member’s interests, here is a copy&pasted code:

static Display *dpy;
static void (*Lock_Display)(void);
static void (*Unlock_Display)(void);

void ScreenSaverInit()
{
SDL_SysWMinfo info;

    dpy = NULL;

    SDL_VERSION(&info.version);
    if ( SDL_GetWMInfo(&info) ) {
            if ( info.subsystem == SDL_SYSWM_X11 ) {
                    dpy = info.info.x11.display;
                    Lock_Display = info.info.x11.lock_func;
                    Unlock_Display = info.info.x11.unlock_func;
            }
    }

}

void ScreenSaver(int flag)
{
static int timeout,interval,prefer_blanking,allow_exposures;
static BOOL dpms_on;
CARD16 dpms_state;
int dpms_dummy;

    if(dpy == NULL) return;
    if(flag) {
            Lock_Display();
            XGetScreenSaver(dpy,&timeout,&interval,
                    &prefer_blanking,&allow_exposures);
            XSetScreenSaver(dpy,0,0,DefaultBlanking,DefaultExposures);
            if ((DPMSQueryExtension(dpy, &dpms_dummy, &dpms_dummy)) && 
                    (DPMSCapable(dpy))) {
                    DPMSInfo(dpy, &dpms_state, &dpms_on);
                    DPMSDisable(dpy); 
            }
            Unlock_Display();
    } else {
            Lock_Display();
            XSetScreenSaver(dpy,timeout,interval,prefer_blanking,allow_expos

ures);
if ((DPMSQueryExtension(dpy, &dpms_dummy, &dpms_dummy)) &&
(DPMSCapable(dpy)) && (dpms_on)) {
DPMSEnable(dpy);
}
Unlock_Display();
}
}From: slouken@libsdl.org (slouken)
Subject: Re: [SDL] How to disable screen blanking/saver?
Date: Sat, 04 May 2002 08:19:44 -0700

How can I disable screen blanking or saver from SDL layer?

You can do it in a platform dependent manner, by accessing the SDL
system dependent hooks in SDL_syswm.h
Take a look at the scrap demo for an example of using this API:
http://www.libsdl.org/projects/scrap/

Thank you, I’ve succeeded to disable screen saver. I had saw the code
of XawTV. IMHO, If SDL has abstracted API to disable it, SDL people
could be more happy.

I agree 100%. It would be great if SDL abstracted the disabling of
screensavers in a platform-independent manner. I too have looked at
XawTV’s code and am hoping for something more portable.–
Mike

:wq

“Me too.”

Disabling the screensaver seems to be a rather essential feature, as some
platforms totally ignore all input devices but the mouse and keyboard.
(That is, while playing with a joystick rather than mouse and/or kbd, you
get a bl**dy screensaver in your face every N minutes… grr)

//David Olofson — Programmer, Reologica Instruments AB

.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------------> http://www.linuxdj.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |-------------------------------------> http://olofson.net -'On Saturday 11 May 2002 10:46, W. Michael Petullo wrote:

How can I disable screen blanking or saver from SDL layer?

You can do it in a platform dependent manner, by accessing the SDL
system dependent hooks in SDL_syswm.h
Take a look at the scrap demo for an example of using this API:
http://www.libsdl.org/projects/scrap/

Thank you, I’ve succeeded to disable screen saver. I had saw the code
of XawTV. IMHO, If SDL has abstracted API to disable it, SDL people
could be more happy.

I agree 100%. It would be great if SDL abstracted the disabling of
screensavers in a platform-independent manner. I too have looked at
XawTV’s code and am hoping for something more portable.

How can I disable screen blanking or saver from SDL layer?

You can do it in a platform dependent manner, by accessing the SDL
system dependent hooks in SDL_syswm.h
Take a look at the scrap demo for an example of using this API:
http://www.libsdl.org/projects/scrap/

Thank you, I’ve succeeded to disable screen saver. I had saw the code
of XawTV. IMHO, If SDL has abstracted API to disable it, SDL people
could be more happy.

I agree 100%. It would be great if SDL abstracted the disabling of
screensavers in a platform-independent manner. I too have looked at
XawTV’s code and am hoping for something more portable.

“Me too.”

Disabling the screensaver seems to be a rather essential feature, as some
platforms totally ignore all input devices but the mouse and keyboard.
(That is, while playing with a joystick rather than mouse and/or kbd, you
get a bl**dy screensaver in your face every N minutes… grr)

Has any more thought be put into this? I am very interested in seeing
this implemented.–
Mike

:wq

How can I disable screen blanking or saver from SDL layer?

You can do it in a platform dependent manner, by accessing the SDL
system dependent hooks in SDL_syswm.h
Take a look at the scrap demo for an example of using this API:
http://www.libsdl.org/projects/scrap/

Thank you, I’ve succeeded to disable screen saver. I had saw the code
of XawTV. IMHO, If SDL has abstracted API to disable it, SDL people
could be more happy.

I agree 100%. It would be great if SDL abstracted the disabling of
screensavers in a platform-independent manner. I too have looked at
XawTV’s code and am hoping for something more portable.

“Me too.”

Disabling the screensaver seems to be a rather essential feature, as some
platforms totally ignore all input devices but the mouse and keyboard.
(That is, while playing with a joystick rather than mouse and/or kbd, you
get a bl**dy screensaver in your face every N minutes… grr)

Has any more thought be put into this? I am very interested in seeing
this implemented.

Enclosed you should find a patch that begins to implement this. The patch
is against the CVS tree as of 2 June, 2002. The patch breaks the
compiling of all of the SDL video drivers except for X11. This can
easily be fixed by either implementing SDL_ScreenSaverEnable and
SDL_ScreenSaverDisable in the other drivers or adding stub functions.

Here is the patch, which will hopefully get the ball rolling:===============================================================================

diff -u --recursive SDL12-vanilla/include/SDL_video.h SDL12/include/SDL_video.h
— SDL12-vanilla/include/SDL_video.h Thu Apr 11 16:35:13 2002
+++ SDL12/include/SDL_video.h Sun Jun 2 14:46:36 2002
@@ -862,6 +862,12 @@
extern DECLSPEC int SDLCALL SDL_WM_ToggleFullScreen(SDL_Surface *surface);

/*

    • This is currently only implemented in the X11 video driver.
  • */
    +extern DECLSPEC int SDLCALL SDL_ScreenSaverDisable (void);
    +extern DECLSPEC int SDLCALL SDL_ScreenSaverEnable (void);

+/*

  • This function allows you to set and query the input grab state of
  • the application. It returns the new input grab state.
    /
    diff -u --recursive SDL12-vanilla/src/video/SDL_sysvideo.h SDL12/src/video/SDL_sysvideo.h
    — SDL12-vanilla/src/video/SDL_sysvideo.h Sun May 19 22:06:01 2002
    +++ SDL12/src/video/SDL_sysvideo.h Sun Jun 2 14:23:44 2002
    @@ -271,6 +271,10 @@
    /
    Handle any queued OS events */
    void (*PumpEvents)(_THIS);
  • /* Disable and enable screen saver */
  • int (*ScreenSaverDisable)(_THIS);
  • int (*ScreenSaverEnable)(_THIS);
  • /* * * /
    /
    Data common to all drivers */
    SDL_Surface *screen;
    diff -u --recursive SDL12-vanilla/src/video/SDL_video.c SDL12/src/video/SDL_video.c
    — SDL12-vanilla/src/video/SDL_video.c Sun May 19 22:06:01 2002
    +++ SDL12/src/video/SDL_video.c Sun Jun 2 14:47:11 2002
    @@ -1224,6 +1224,16 @@
    colors, firstcolor, ncolors);
    }

+int SDL_ScreenSaverDisable (void)
+{

  • current_video->ScreenSaverDisable (current_video);
    +}

+int SDL_ScreenSaverEnable (void)
+{

  • current_video->ScreenSaverEnable (current_video);
    +}

/*

  • Clean up the video subsystem
    */
    diff -u --recursive SDL12-vanilla/src/video/x11/SDL_x11video.c SDL12/src/video/x11/SDL_x11video.c
    — SDL12-vanilla/src/video/x11/SDL_x11video.c Wed Mar 6 12:23:08 2002
    +++ SDL12/src/video/x11/SDL_x11video.c Sun Jun 2 14:26:59 2002
    @@ -83,6 +83,8 @@
    static int X11_SetColors(_THIS, int firstcolor, int ncolors,
    SDL_Color *colors);
    static int X11_SetGammaRamp(_THIS, Uint16 *ramp);
    +static int X11_ScreenSaverDisable(_THIS);
    +static int X11_ScreenSaverEnable(_THIS);
    static void X11_VideoQuit(_THIS);

/* X11 driver bootstrap functions */
@@ -180,6 +182,8 @@
device->CheckMouseMode = X11_CheckMouseMode;
device->InitOSKeymap = X11_InitOSKeymap;
device->PumpEvents = X11_PumpEvents;

  • device->ScreenSaverDisable = X11_ScreenSaverDisable;

  • device->ScreenSaverEnable = X11_ScreenSaverEnable;

    device->free = X11_DeleteDevice;

@@ -1172,6 +1176,28 @@
return(0);
}

+int X11_ScreenSaverDisable(_THIS)
+{

  • Display *display = XOpenDisplay(NULL);
  • if (! display) {
  •   SDL_SetError("Could not obtain display");
    
  •   return -1;
    
  • }
  • XSetScreenSaver(display, 0, 0, DefaultBlanking, DefaultExposures);
  • XCloseDisplay(display);
    +}

+int X11_ScreenSaverEnable(_THIS)
+{

  • Display *display = XOpenDisplay(NULL);
  • if (! display) {
  •   SDL_SetError("Could not obtain display");
    
  •   return -1;
    
  • }
  • XSetScreenSaver(display, -1, 0, DefaultBlanking, DefaultExposures);
  • XCloseDisplay(display);
    +}

/* Note: If we are terminated, this could be called in the middle of
another SDL video routine – notably UpdateRects.
*/

===============================================================================


Mike

:wq

| >>>>>> How can I disable screen blanking or saver from SDL layer?
|
| Enclosed you should find a patch that begins to implement this. The patch
| is against the CVS tree as of 2 June, 2002. The patch breaks the

Does this work if the user is running XScreensaver (or something
else?), and what if the SDL program crashes, will the screensaver get
restarted?

I’ve tried disabling the screensaver in Xine, and the only way I could
get it working was to fake keyboard inputs every 30 seconds (so every
30s I press the shift key).On Sun, Jun 02, 2002 at 03:14:34PM +0200, W. Michael Petullo wrote:


“Give a man a fire and he’s warm for a day, but set fire to him and he’s
warm for the rest of his life.” - Solid Jackson (from Jingo, by TP)
6AD6 865A BF6E 76BB 1FC2 | www.piku.org.uk/public-key.asc
E4C4 DEEA 7D08 D511 E149 | www.piku.org.uk wnzrf at cvxh.bet.hx (rot13’d)

How can I disable screen blanking or saver from SDL layer?

Enclosed you should find a patch that begins to implement this. The patch
is against the CVS tree as of 2 June, 2002. The patch breaks the […]

Does this work if the user is running XScreensaver (or something
else?), and what if the SDL program crashes, will the screensaver get
restarted?

I’ve tried disabling the screensaver in Xine, and the only way I could
get it working was to fake keyboard inputs every 30 seconds (so every
30s I press the shift key).

My current, published patch only disables X’s built in screensaver.

I have some prototype code which disables xscreensaver correctly. If the
process crashes, xscreensaver will run as before it was deactivated.
JWZ doesn’t provide a very good API for this in his xscreensaver (see
xscreensaver FAQ), so my code will need a little cleaning. I hope to
get an xscreensaver-aware patch out in the next week. I’ll also propose
some type of API to JWZ.–
Mike

:wq

How can I disable screen blanking or saver from SDL layer?

Enclosed you should find a patch that begins to implement this. The patch
is against the CVS tree as of 2 June, 2002. The patch breaks the […]

Does this work if the user is running XScreensaver (or something
else?), and what if the SDL program crashes, will the screensaver get
restarted?

[…]

My current, published patch only disables X’s built in screensaver.

I have some prototype code which disables xscreensaver correctly. If the
process crashes, xscreensaver will run as before it was deactivated.
JWZ doesn’t provide a very good API for this in his xscreensaver (see
xscreensaver FAQ), so my code will need a little cleaning. I hope to
get an xscreensaver-aware patch out in the next week. I’ll also propose
some type of API to JWZ.

I just finished a new patch which disables xscreensaver. The patch is
available at http://www.flyn.org and can be found by looking for the
string “SDL”.

I’d like to hear what people think.–
Mike

:wq

I’d like to hear what people think.

Pretty cool.

In the top level enable/disable calls, you might check to see if
current_video->ScreenSaver* are non-NULL before you call them.
That will make the code work (well, not crash) on platforms besides X11.

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

I’d like to hear what people think.

Pretty cool.

In the top level enable/disable calls, you might check to see if
current_video->ScreenSaver* are non-NULL before you call them.
That will make the code work (well, not crash) on platforms besides X11.

My latest patch (http://www.flyn.org) implements this.–
Mike

:wq

How can I disable screen blanking or saver from SDL layer?

Enclosed you should find a patch that begins to implement this. The patch
is against the CVS tree as of 2 June, 2002. The patch breaks the […]

Does this work if the user is running XScreensaver (or something
else?), and what if the SDL program crashes, will the screensaver get
restarted?

[…]

My current, published patch only disables X’s built in screensaver.

I have some prototype code which disables xscreensaver correctly. If the
process crashes, xscreensaver will run as before it was deactivated.
JWZ doesn’t provide a very good API for this in his xscreensaver (see
xscreensaver FAQ), so my code will need a little cleaning. I hope to
get an xscreensaver-aware patch out in the next week. I’ll also propose
some type of API to JWZ.

I just finished a new patch which disables xscreensaver. The patch is
available at http://www.flyn.org and can be found by looking for the
string “SDL”.

I’d like to hear what people think.

Does anyone else think this is worthwhile? Should I continue to develop
it as a part of the core SDL library or separate it like SDL_image does?
Personally, I feel this is a fundamental enough feature to be in the
core library.–
Mike

:wq

I think it should probably go into the core library, given that just about
any fullscreen multimedia application which does not use keyboard input
(any video player, for instance) will probably need this to keep from
annoying users.

I glanced over the patch, did not see a way to query the screensaver
state. It would be nice if SDL_Quit were to restore the state to whatever
it was (enabled or disabled) when it exits.On Sat, Jun 22, 2002 at 11:10:35AM +0200, W. Michael Petullo wrote:

My current, published patch only disables X’s built in screensaver.

I have some prototype code which disables xscreensaver correctly. If the
process crashes, xscreensaver will run as before it was deactivated.
JWZ doesn’t provide a very good API for this in his xscreensaver (see
xscreensaver FAQ), so my code will need a little cleaning. I hope to
get an xscreensaver-aware patch out in the next week. I’ll also propose
some type of API to JWZ.

I just finished a new patch which disables xscreensaver. The patch is
available at http://www.flyn.org and can be found by looking for the
string “SDL”.

I’d like to hear what people think.

Does anyone else think this is worthwhile? Should I continue to develop
it as a part of the core SDL library or separate it like SDL_image does?
Personally, I feel this is a fundamental enough feature to be in the
core library.


Joseph Carter We can hope for the future
But there might not be one

“PLEASE RESPECT INTELLECTUAL RIGHTS!”
“Please demonstrate intellect.” :wink:

-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 273 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20020622/16935ec0/attachment.pgp

My current, published patch only disables X’s built in screensaver.

I have some prototype code which disables xscreensaver correctly. If the
process crashes, xscreensaver will run as before it was deactivated.
JWZ doesn’t provide a very good API for this in his xscreensaver (see
xscreensaver FAQ), so my code will need a little cleaning. I hope to
get an xscreensaver-aware patch out in the next week. I’ll also propose
some type of API to JWZ.

I just finished a new patch which disables xscreensaver. The patch is
available at http://www.flyn.org and can be found by looking for the
string “SDL”.

I’d like to hear what people think.

Does anyone else think this is worthwhile? Should I continue to develop
it as a part of the core SDL library or separate it like SDL_image does?
Personally, I feel this is a fundamental enough feature to be in the
core library.

I think it should probably go into the core library, given that just about
any fullscreen multimedia application which does not use keyboard input
(any video player, for instance) will probably need this to keep from
annoying users.

I glanced over the patch, did not see a way to query the screensaver
state. It would be nice if SDL_Quit were to restore the state to whatever
it was (enabled or disabled) when it exits.

My patch already does this as far as xscreensaver is concerned. A thread
is started which simulates screensaver-killing input – as recommended
by the xscreensaver FAQ. This ensures that the original xscreensaver
state is restored when an SDL program quits, crashes, is killed, etc.

I’ll implement some type of state variable so that the built in X11
screensaver is handled in a similar fashion.

If we could commit this patch into CVS maybe I could get some help!–
Mike

:wq

I’ve no problems with it, but you’ll have to convince Sam it’s worth
adding new functions to the API before the mythical 1.3 tree (which sure
does feel like pure vapour sometimes…)On Sun, Jun 30, 2002 at 10:02:44AM +0200, W. Michael Petullo wrote:

I glanced over the patch, did not see a way to query the screensaver
state. It would be nice if SDL_Quit were to restore the state to whatever
it was (enabled or disabled) when it exits.

My patch already does this as far as xscreensaver is concerned. A thread
is started which simulates screensaver-killing input – as recommended
by the xscreensaver FAQ. This ensures that the original xscreensaver
state is restored when an SDL program quits, crashes, is killed, etc.

I’ll implement some type of state variable so that the built in X11
screensaver is handled in a similar fashion.

If we could commit this patch into CVS maybe I could get some help!


Joseph Carter Certified free software nut

r0bert: in short, we’re moving several things the client
currently is responsible for telling the server into things the
server checks for itself
If Neo says “There is no spoon”, The Matrix will say “Oh yes
there is—no cheating!”
But he knows kung fu…
Sure he does, but I have a rocket launcher.

-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 273 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20020630/0ab70b6f/attachment.pgp

I glanced over the patch, did not see a way to query the screensaver
state. It would be nice if SDL_Quit were to restore the state to whatever
it was (enabled or disabled) when it exits.

My patch already does this as far as xscreensaver is concerned. A thread
is started which simulates screensaver-killing input – as recommended
by the xscreensaver FAQ. This ensures that the original xscreensaver
state is restored when an SDL program quits, crashes, is killed, etc.

I’ll implement some type of state variable so that the built in X11
screensaver is handled in a similar fashion.

If we could commit this patch into CVS maybe I could get some help!

I’ve no problems with it, but you’ll have to convince Sam it’s worth
adding new functions to the API before the mythical 1.3 tree (which sure
does feel like pure vapour sometimes…)

It does not appear that my screensaver code will make it into SDL 1.3.
I have decided to package it as a separate library, libss, until it can
be integrated into SDL down the road. A /very/ raw, initial version on
libss is now available at http://www.flyn.org (search for the text libss).

Libss should be considered a proof-of-concept at this point. I don’t
know if its destiny is to be swallowed completely by SDL or maintained
as a separate library. Regardless, libss should benefit SDL users –
please consider contributing to the project (especially in supporting
different platforms).–
Mike

:wq