xpra icon
Bug tracker and wiki

This bug tracker and wiki are being discontinued
please use https://github.com/Xpra-org/xpra instead.

Opened 7 years ago

Closed 7 years ago

Last modified 16 months ago

#803 closed enhancement (worksforme)

Handler for user timeout

Reported by: Scott Bennett Owned by: Scott Bennett
Priority: major Milestone: 0.14
Component: server Version: trunk
Keywords: Cc:


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.

Change History (10)

comment:1 Changed 7 years ago by Antoine Martin

Milestone: 0.14
Owner: changed from Antoine Martin to Scott Bennett

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)

comment:2 Changed 7 years ago by 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?

comment:3 Changed 7 years ago by 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.

comment:4 Changed 7 years ago by Antoine Martin

Missed bits in r8654.

comment:5 Changed 7 years ago by 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?

comment:6 Changed 7 years ago by Antoine Martin

r8679 resets the timer when:

  • the window gains focus (usually when the user clicks on it, or alt-tabs to it) - we can easily remove this if you want, I thought it made sense
  • the mouse is moved over the window whilst it has focus

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.

comment:7 Changed 7 years ago by 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.

comment:8 Changed 7 years ago by Antoine Martin

Resolution: worksforme
Status: newclosed

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

comment:9 Changed 4 years ago by Antoine Martin

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

comment:10 Changed 16 months ago by migration script

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

Note: See TracTickets for help on using tickets.