Skip to content

Commit

Permalink
#816: when we reach the grace period, call go_idle() which slows down…
Browse files Browse the repository at this point in the history
… the screen updates to just 2 per second

git-svn-id: https://xpra.org/svn/Xpra/trunk@8705 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Feb 25, 2015
1 parent 96ecb0d commit 95f9481
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/xpra/server/batch_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def __init__(self):
self.max_delay = self.MAX_DELAY
self.timeout_delay = self.TIMEOUT_DELAY
self.delay = self.START_DELAY
self.saved = self.START_DELAY
self.locked = False #to force a specific delay
self.last_delays = deque(maxlen=64) #the delays we have tried to use (milliseconds)
self.last_actual_delays = deque(maxlen=64) #the delays we actually used (milliseconds)
Expand Down
1 change: 1 addition & 0 deletions src/xpra/server/server_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,7 @@ def idle_grace_timeout_cb(self, source):
log("idle_grace_timeout_cb(%s)", source)
timeout_nid = 2**16 + 2**8 + 1
source.notify(0, timeout_nid, "xpra", 0, "", "This Xpra session will timeout soon", "Activate one of the windows to avoid this timeout", 10)
source.go_idle()


def _process_disconnect(self, proto, packet):
Expand Down
21 changes: 21 additions & 0 deletions src/xpra/server/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ def __init__(self, protocol, disconnect_cb, idle_add, timeout_add, source_remove
self.idle_add = idle_add
self.timeout_add = timeout_add
self.source_remove = source_remove
self.idle = False
self.idle_timeout = idle_timeout
self.idle_timeout_cb = idle_timeout_cb
self.idle_grace_timeout_cb = idle_grace_timeout_cb
Expand Down Expand Up @@ -449,11 +450,30 @@ def resume(self, ui, wd):
self.send_cursor()


def go_idle(self):
#usually fires from the server's idle_grace_timeout_cb
if self.idle:
return
self.idle = True
for window_source in self.window_sources.values():
window_source.go_idle()

def no_idle(self):
#on user event, we stop being idle
if not self.idle:
return
self.idle = False
for window_source in self.window_sources.values():
window_source.no_idle()


def user_event(self):
timeoutlog("user_event()")
self.last_user_event = time.time()
self.schedule_idle_grace_timeout()
self.schedule_idle_timeout()
if self.idle:
self.no_idle()

def schedule_idle_timeout(self):
timeoutlog("schedule_idle_timeout() idle_timer=%s, idle_timeout=%s", self.idle_timer, self.idle_timeout)
Expand Down Expand Up @@ -1104,6 +1124,7 @@ def get_info(self):
"platform_name" : platform_name(self.client_platform, self.client_release),
"uuid" : self.uuid,
"idle_time" : int(time.time()-self.last_user_event),
"idle" : self.idle,
"hostname" : self.hostname,
"auto_refresh" : self.auto_refresh_delay,
"desktop_size" : self.desktop_size or "",
Expand Down
9 changes: 9 additions & 0 deletions src/xpra/server/window_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,15 @@ def get_property_info(self):
}


def go_idle(self):
self.batch_config.locked = True
self.batch_config.saved = self.batch_config.delay
self.batch_config.delay = max(500, self.batch_config.delay)

def no_idle(self):
self.batch_config.locked = False
self.batch_config.delay = self.batch_config.saved


def suspend(self):
self.cancel_damage()
Expand Down

0 comments on commit 95f9481

Please sign in to comment.