PDA

View Full Version : detecting "user idleness"



caduel
12th November 2009, 09:22
I want to detect if the user of my program has been idle the last X seconds (like a screensaver has to).

Is there anything in Qt that already does something like that?
(I have a working prototype that uses a QTimer and overrides QApplication::notify() to detect "user input events". But I would prefer to use an existing solution that is part of Qt.)

Which leads to a second question: is there some function that classifies a QEvent as "user input" or do I have to check against KeyPress, KeyRelease etc (which means the code will break if a new input event type is introduced)?

Best regards and thanks for thinking about my question.

wysota
12th November 2009, 09:28
I think it would be easiest to use a native system call to get such information. XScreenSaverQueryInfo() will do the trick on X11.

squidge
12th November 2009, 10:02
On Windows, try GetLastInputInfo (http://msdn.microsoft.com/en-us/library/ms646302%28VS.85%29.aspx) API function.