Bug 1419 - please resurrect the "XIdle" extension from X11R5
please resurrect the "XIdle" extension from X11R5
Status: RESOLVED FIXED
Product: xorg
Classification: Unclassified
Component: Lib/Xext
6.8.0
x86 (IA32) All
: high normal
Assigned To: Xorg Project Team
Xorg Project Team
http://ftp.rge.com/pub/X/X11R5/contri...
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2004-09-19 18:20 UTC by Jamie Zawinski
Modified: 2007-05-21 03:23 UTC (History)
10 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jamie Zawinski 2004-09-19 18:20:16 UTC
It's ironic, but the MIT-SCREEN-SAVER extension is useless for the
xscreensaver program that is shipped with just about all of the Unix
desktops (I'm its author).  All xscreensaver really needs is a way to
know how long the user has been idle.  The MIT-SCREEN-SAVER extension
does all kinds of other crap that gets in the way.

Consequently, xscreensaver has to do all kinds of crufty things (like
selecting input events on every window) in order to determine idleness.
And these methods don't always work (it tends to fail to notice
activity from USB mouse wheels, for example.)

Back in X11R5, there was a nice, simple extension called "XIDLE" that
simply returned the length of time since the last user input event
(keyboard or mouse activity.)  It was never ported to X11R6.

Is there any chance that this could be resurrected and made a part of
the Xorg server?

This exension would be useful not only for xscreensaver, but for any
other program that wanted to report, or act on, idle time; for example,
chat clients that want to report "away" times.

You can find a copy of the old XIDLE code in the X11R5 contrib
directory, for example,
http://ftp.rge.com/pub/X/X11R5/contrib/xidle.tar.gz

But the gist of it is just this:

       Bool XidleQueryExtension (Display *display,
                                 int *event_basep,
                                 int *error_basep);

       Status XGetIdleTime (Display *display,
                            Time *idletime_return);

       Gets the time since the last input event.  If it succeeds, it
       returns nonzero and stores the milliseconds since last input
       event in idletime_return.

Comments?
Comment 1 Roland Mainz 2004-10-08 14:36:15 UTC
I can try my luck, but first the Xarch board (xorg_arch@x.org) has to give the
permission to restore the extension.
And it may even be interesting to extend the XIDLE extension that the idle
status for each screen and each window can be queried seperately (e.g. per
screen for per-screen screensavers and per-window for tools like xcompmgr to
make "idle" windows more transparent than those which were more recently
active).
Comment 2 Bauke Jan Douma 2004-12-29 15:11:05 UTC
(In reply to comment #1)
> I can try my luck, but first the Xarch board (xorg_arch@x.org) has to give the
> permission to restore the extension.
> And it may even be interesting to extend the XIDLE extension that the idle
> status for each screen and each window can be queried seperately (e.g. per
> screen for per-screen screensavers and per-window for tools like xcompmgr to
> make "idle" windows more transparent than those which were more recently
> active).

Yes, we will all want that ;)

bjd
Comment 3 Egbert Eich 2005-02-07 01:59:38 UTC
Jamie, I agree that resurrecting the XIdle extension may be a good idea.
One may want to add new features - but this doesn't have to happen in one step:
We can reinclude the old version and add new things in the future.

However I'm curious why the MIT-SCREEN-SAVER extension doesn't meet your needs:
It is very easy to receive an event when the time for the screen saver has
expired (ie. no input has been made). So I assume that the overhead with the
'screen saver window' doesn't meet your needs.
Comment 4 ajax at nwnk dot net 2005-02-07 06:56:58 UTC
(In reply to comment #3)
> However I'm curious why the MIT-SCREEN-SAVER extension doesn't meet your needs:
> It is very easy to receive an event when the time for the screen saver has
> expired (ie. no input has been made). So I assume that the overhead with the
> 'screen saver window' doesn't meet your needs.

http://www.jwz.org/xscreensaver/man1.html

There's a section in there about MIT-SCREEN-SAVER being ugly when fading into
the screensaver (the way you can do on SGI and XIDLE-having machines).  That
alone justifies it for me.

Roland's comment about extending XIDLE to report idle times per-window seems
excessive in the presence of XEVIE, which any serious compmgr will end up using.
 Per-screen almost makes sense but would assuredly confuse users (neither XP nor
OS X do independent screen saver timeouts per screen).
Comment 5 Alan Coopersmith 2005-02-07 07:16:02 UTC
Would it be more difficult to "fix" MIT-SCREEN-SAVER than reviving XIDLE?
Comment 6 Roland Mainz 2005-02-07 07:22:30 UTC
(In reply to comment #5)
> Would it be more difficult to "fix" MIT-SCREEN-SAVER than reviving XIDLE?

Primary purpose of MIT-SCREEN-SAVER are screen-savers while XIDLE could be used
for other stuff, too (custom IME comes in mind).
Comment 7 Roland Mainz 2005-02-07 07:28:07 UTC
(In reply to comment #4)
[snip]
> Roland's comment about extending XIDLE to report idle times per-window seems
> excessive in the presence of XEVIE, which any serious compmgr will end up using.

Using XEVIE here may be possible but it would be a pain. Why having the compmgr
to track each and every single event per window when the same information is
already in the Xserver ? XIDLE would just expose these values.
And the idea with compmgr usage was just an example - there are likely more
places where these values could be used to implement usefull stuff...

> Per-screen almost makes sense but would assuredly confuse users (neither XP 
> nor OS X do independent screen saver timeouts per screen).

AFAIK both XP and MacOSX treat both monitors as a single surface - but X11 also
allows that multiple monitors act completely independently ("traditional
multihead") so having (optional) ways to do the screen blanking independently
sounds a good idea for me...
Comment 8 Jamie Zawinski 2005-02-07 11:37:26 UTC
The MIT-SCREEN-SAVER extension takes this approach:

   - when the user is idle, immediately map full screen
     black windows on each screen;

   - inform the screen saver client that the screen is now
     black;

   - when user activity occurs, unmap the windows an inform
     the screen saver client.

The screen saver client can specify a few parameters of that
window, like visual and depth, but that's it.

The way xscreensaver works is:

   - detect when the user is idle;

   - optionally fade the screen slowly to black (by playing
     games with gamma and/or colormaps);

   - map a black window or windows.  note that in xinerama-
     mode, it may map more than one window per X screen (to
     achieve the effect of having different graphics on each
     monitor.)

   - choose a screen saver to run, and choose an appropriate
     visual for it (e.g., different visuals may be needed
     for "normal" X programs than for OpenGL programs.)

   - after a timeout, choose a different screen saver to
     run.  If the new one needs a different visual, create a
     new window for it and destroy the old window.

   - detect user activity;

   - optionally fade the desktop in from black.

So what this comes down to is that xscreensaver just *can't*
use the window that was created by the MIT extension.  It
appears on screen too early, is removed from the screen too
early, its visual cannot be changed after it was created,
and there might be one window instead of four.

There's a lot of complicated logic and policy up there,
related to when and what manner of windows get mapped when
the user is idle.  Currently, the MIT extension is dictating
policy, and that policy belongs in a client, not in the
server.

Also, in my experience, use of the MIT extension led to
occasional server crashes on various systems.  Given its
other shortcomings, I never bothered to track that down, and
instead, just disabled it by default in xscreensaver long
ago.

So, yeah, I don't really have much desire to see the
MIT-SCREEN-SAVER extension fixed, because, not to mince
words, I think it's junk...

SGI had their own SCREEN-SAVER extension that just reported
two events: "user is idle" and "user is no longer idle."  I
was able to make good use of that in xscreensaver.  However,
given the namespace collisions, it wouldn't be possible for
the MIT and SGI savers to exist simultaniously in either the
same X server or the same X client.  So porting/cloning that
extension isn't really an option.

So I think that XIDLE is our best bet.

For my purposes, a single per-display query that gives me
the time at which the last user input occurred would be
sufficient.

If we're talking about extending XIDLE with additional
features, one thing that would be useful would be a way to
feed idle times back upstream: for example, xscreensaver
would sometimes like to say "consider the user to be idle
now" and "consider the user to no longer be idle now."

I don't think that per-Screen idle-reporting would be
particularly useful.  99.9% of the people who have multiple
monitors use Xinerama instead of multiple screens per
display, and such a thing wouldn't work in that case anyway.

The old XIDLE code is here:
http://ftp.rge.com/pub/X/X11R5/contrib/xidle.tar.gz

(I wanted to check out XEVIE and see if perhaps it would be
appropriate for to be making use of that in xscreensaver,
but all the links on http://freedesktop.org/Software/XEvIE
are 404.)
Comment 9 ajax at nwnk dot net 2005-02-07 11:56:47 UTC
> (I wanted to check out XEVIE and see if perhaps it would be
> appropriate for to be making use of that in xscreensaver,
> but all the links on http://freedesktop.org/Software/XEvIE
> are 404.)

I've fixed the links, thanks for the catch.
Comment 10 Alan Coopersmith 2005-02-07 14:13:35 UTC
Thanks for the explanation.   It does sound like resurrecting XIdle is more 
reasonable than attempting to completely rewhack MIT-SCREEN-SAVER to simply
end up with something that's much more like XIdle.
Comment 11 Roland Mainz 2005-02-07 14:19:42 UTC
Are there any objections that I take the bug and try my luck with a patch (and
ask xorg_arch to get the extension back in the default build) ?
Comment 12 Egbert Eich 2005-02-08 07:43:52 UTC
Roland, please go for it.
But forget about xorg_arch. I would think discussing this on xorg@ would get 
more feedback. Simply point people to this ticket and they should understand why
this is a good idea.

Comment 13 Aaron Stone 2006-02-13 13:03:37 UTC
*ping* One year since the last comment!

I am writing a backlight dimming utility for laptops, and need idle times
separate from any screen blanking activity. May I bug the assignee to work on it
or pass the project along to someone else?

My two cents:

 o JWZ's suggestion of feeding idle times back to the system
   would be excellent; on a laptop, if the user clicks "lock
   screen now" then the backlight would also dim immediately,
   away messages would go up on your instant messenger, etc.

  o From the sample code I've read over, the old XIDLE required
   polling of the idle state; async notification would be nice.
Comment 14 Alan Coopersmith 2006-02-13 14:43:03 UTC
The assignee is xorg-team, which means it's unassigned and simply sitting here
waiting for someone to care enough about it to volunteer to do the work.
Comment 15 Aaron Stone 2006-02-17 15:30:51 UTC
I know absolutely nothing about the internals of X nor or Xlib programming...
assuming that the old xidle contrib code would just need to be ported and
updated, where would you put this on a 1-10 scale of difficulty?
Comment 16 ajax at nwnk dot net 2006-02-19 10:58:01 UTC
(In reply to comment #15)
> I know absolutely nothing about the internals of X nor or Xlib programming...
> assuming that the old xidle contrib code would just need to be ported and
> updated, where would you put this on a 1-10 scale of difficulty?

3 to 5 (assuming you mean 10 as hardest).
Comment 17 Havoc Pennington 2006-09-01 11:52:16 UTC
It seems you can use the screensaver extension just to get the idle time, and 
ignore all the rest of it...

See for example:
http://svn.mugshot.org/dumbhippo/trunk/client/linux/src/hippo-idle.c

Originally found in the GNOME "typing break" code. It seems to work OK so far.

This does involve polling still, maybe getting an event is slightly better.
Comment 18 Joshua Rodman 2007-02-22 05:43:57 UTC
I too would like to be able to feed the idle time back.  I'm in the process of trying to hash out a pleasant system where joystick activity reasonably delays screensaver activation.  It might be nice to have the X Server pick this up itself, but there are some issues there (is it worth it to add a driver to X just to pick up idleness?).  

Right now I've a userspace program that finds out about joystick plugin events events via dbus, blocks a read on each joystick, and delays screensaving via 'xset' or 'xscreensaver-command', which the user has to pick.  It would certainly be more elegant to simply notify the X server that user activity is occurring.
Comment 19 Daniel Stone 2007-02-27 01:24:11 UTC
Sorry about the phenomenal bug spam, guys.  Adding xorg-team@ to the QA contact so bugs don't get lost in future.
Comment 20 Daniel Stone 2007-05-21 03:23:56 UTC
XIDLE is fundamentally the wrong approach, since a polling-based API is not very useful.  fredrikh committed a new idle sync counter to xserver's git master, which doesn't require any new extensions, requests, or events, and allows you to avoid polling.