Xpra: Ticket #803: Handler for user timeout

Looking for a way to detect that the user has not been interacting with their XPRA session for 'x' seconds. The goal would be to do something configurable when the user has not sent any keyboard or mouse click events for the specified period of time. Mouse movements may or may not be taken into consideration depending on level of effort.

Sat, 07 Feb 2015 06:24:11 GMT - Antoine Martin: owner changed; milestone set

We already have a value which fits the bill exactly: the ServerSource's last_user_event records when the last key event or button event was received by the server, you can see it with:

xpra info | grep client.idle_time

I think we can just add a server option (call it idle-timeout? and make it default to 0 = disabled), we then just (re-)schedule a timer in user_event().

As for the exact action to take, the easiest thing would be to hardcode it to drop the connection with a "idle timeout" warning message. Or maybe you want to exit the server instead? (in which case this would probably need to be configurable, in a similar way to the key shortcuts in the client)

Sun, 08 Feb 2015 03:07:46 GMT - Scott Bennett:

Adding a server option + timer would be excellent.

Dropping the connection with an "idle timeout" sounds like a good (and useful) default behavior and will work well for us.

Additionally, we would need to receive an event on the server somehow so that we can decide to trigger a shutdown of the server or not.

Perhaps a method that I can override that returns true for "disconnect and shutdown" or false for "just disconnect"? Or a void method in which I could invoke a shutdown if needed?

Sun, 08 Feb 2015 09:31:46 GMT - Antoine Martin:

Done in r8642.

To use it:

xpra start --idle-timeout=10

Then attach and the client should get disconnected after 10 seconds of inactivity (key presses or mouse clicks).

You can also change the timeout value at runtime using xpra control:

xpra control :DISPLAY idle-timeout 120

The value zero disables the timeout.

As for overriding the code to inject your own logic, you should be able to just override (or monkey patch) idle_timeout_cb in ServerBase.

Fri, 13 Feb 2015 01:47:36 GMT - Antoine Martin:

Missed bits in r8654.

Wed, 18 Feb 2015 02:22:15 GMT - alas:

Just to make it even friendlier, would it be possible to add mouse cursor events over an xpra window which has focus to the list of events that reset timeout clock?

Wed, 18 Feb 2015 04:17:01 GMT - Antoine Martin:

r8679 resets the timer when:

To make it easier to debug, I've added a new debug category for the server: -d timeout. Shows things like:

schedule_idle_timeout() idle_timer=1465, idle_timeout=20
schedule_idle_timeout() idle_timer=1467, idle_timeout=20

Something else that Scott mentioned, is the ability to have another event that fires before real the timeout so that we can trigger some things (like slowing down window updates, etc). This should probably go in a separate ticket.

Wed, 25 Feb 2015 05:59:46 GMT - Antoine Martin:

Minor fixes worth having (only relevant if the timeout does not cause a disconnection): r8701 + r8702.

If that works OK then I think we can close this and follow up in #816.

Sat, 21 Mar 2015 18:07:08 GMT - Antoine Martin: status changed; resolution set

Closing this, please re-open if you have problems or follow up in #816.

Tue, 30 Jan 2018 08:02:39 GMT - Antoine Martin:

Improved in r18200, see ticket:1688#comment:6

Sat, 23 Jan 2021 05:06:25 GMT - migration script:

this ticket has been moved to: https://github.com/Xpra-org/xpra/issues/803