Fixing screen savers

Keith Packard keithp at keithp.com
Mon Oct 25 12:02:07 PDT 2010


We've had a long sequence of brief conversations within the X.org
developer community about how screen saving should work in X, but it
doesn't appear that they've ever been converted to email form. Let me
try to reconstruct the discussion here and see if we can't finish this
work up.

Here's my understanding of the requirements:

With no external screen saver program running:

 1) Use DPMS to turn off monitors when the built-in idle time
    has been exceeded. 

 2) Allow applications to disable the automatic screen saver using
    the XScreenSaverSuspend call

When an external screen saver is running:

 1) The server should never touch the hardware automatically.

 2) The XScreenSaverSuspend call must continue to work so that
    other applications can disable monitor off while playing movies
    or whatever.

 3) There must be a mechanism to control the DPMS state of all monitors
    connected to the machine. Independently would be ideal.

 4) If the screen saver crashes, the server should get itself back
    to the state that it would have been in had the screen saver
    never been started.

 5) The screen saver application timeouts should be controllable by the
    core screen saver and XDPMS timeouts.

Right now, many screen savers are using the Sync IDLETIME counter which
serves to let them tell when the server has not received input for some
time. This does not, however, report when the screen saver has been
disabled or track the current core screen saver and XDPMS timeouts.

The last proposed solution we came up with was to have all of the
state tracked entirely within the screen saver app:

 * Have XScreenSaverSuspend calls generate events with the current
   suspend count.

 * (unknown) track the core screen saver and DPMS timeouts

 * Call XScreenSaverSuspend to disable the automatic screen saver
   inside the X server. Note that this will bump the current
   suspend count by one.
 
 * Use the IDLETIME counter to detect when the screen saver should
   be activated.

 * Add a 'set DPMS' call to the RandR extension to control the DPMS
   state of the monitors.

However, looking at the code, I think there's a simpler mechanism already
available to us:

 * Register a screen saver window with XScreenSaverSetAttributes. This
   ensures that automatic screen saving will not turn off the screen.
   I can't figure out how this window could be useful to us as it gets
   automatically destroyed when the screen is unsaved, and so cannot
   be used for a transition or lock screen dialog.

 * Monitor screen saver timeouts using the existing XScreenSaver events.

 * Disable the DPMS extension by setting the DPMS timeouts to all zeros.
   The DPMS code doesn't respect the X screen saver extension's external
   screen saver mode. (note A*)

 * Control DPMS on the monitors by using DPMSForceLevel. This will
   generate another screen saver event, but that will have the 'force'
   value set to TRUE.

When the user generates input, the DPMS mode will get set back to On and
the screen saver will get a XScreenSaver event, along with having the
screen saver window get unmapped. It can then provide a transition back
to normal operation or an unlock screen dialog.

A* The one thing this fails at is when the screen saver crashes, the DPMS
   timeouts will remain at 0.

I see a couple of useful cleanups:

 1) Don't require the creation of the external screen saver window. It
    isn't useful anyways. We would need a separate mechanism to register
    an external screen saver application, but a simple boolean is all
    that is required for that.

 2) Provide a way, similar to XScreenSaverSuspend, to disable automatic
    DPMS transitions without also disabling automatic screen saver
    timeouts. This would fix note A*. I'd do this in the DPMS extension.

 3) Unify the DPMS and core screen saver timers (would require 2):

    * Eliminate the core timers inside the server
    * XGetScreenSaver would return the Standby time for
      'timeout' and the difference between Off and Standby for
      'interval'
    * XSetScreenSaver would set the Standby time to 'timeout',
      the Suspend time to 'timeout' + 'interval'/2 and the
      Off time to 'timeout' + 'interval'.

-- 
keith.packard at intel.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.x.org/archives/xorg-devel/attachments/20101025/88fa1676/attachment.pgp>


More information about the xorg-devel mailing list