Therefore it happens that a screen saver starts when you are editing text or playing snake game, i.e. not using mouse.
One could think that a possible solutions could be to allow inactive windows to get keyboard input via another event mask bit (like it's done for mouse).
But this is a true key logger.
Actually, the screen saver doesn't need to know each key that was pressed.
It needs to know the timestamp of the latest user input.
And the kernel could track and provide this information via a new syscall:
- Add variable [user_activity_timestamp].
- For each keyboard and mouse input update [user_activity_timestamp] from [timer_ticks].
- Return [user_activity_timestamp] when the new syscall is called.
- Overhead of updating [user_activity_timestamp] at each user input.
+ Now the screen saver receives and handles each mouse input. With the new syscall this overhead is eliminated.
Next, sometimes the screen saver starts when you are watching a movie, i.e. not touching a computer at all.
In this case I can think of three approaches:
- The user touches a mouse from time to time. No way.
- The screen saver has a white list of proc names that prevent its start. This doesn't work too, e.g. if fplay (white listed) is on pause or playing audio.
- Applications can inform the kernel to update [user_activity_timestamp]. Needs another syscall and additional effort from the apps but finally works.
- Needs modification of applications.
+ Nothing breaks when apps are not modified.
+ Screen saver finally works as expected.
Total:
- A syscall to read activity timestamp (say, 26.7);
- A syscall to update activity timestamp (say, 26.8);
- Kernel modification to update the timestamp on each user input;
- Apps modification to ask the kernel to update the timestamp.
Kernel side and scrsaver are on me.