[core/output] rate-limit output (see #917)
according to research (Jakob Nielsen '93), roughly 0.1s is what is required for the user to feel "instantaneous". based on this, rate-limit updates to only once per ~0.03s (0.1 felt really laggy for me, so let's be conservative)
This commit is contained in:
parent
978519e130
commit
b90346424b
1 changed files with 10 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
|||
import sys
|
||||
import json
|
||||
import time
|
||||
import datetime
|
||||
|
||||
import core.theme
|
||||
import core.event
|
||||
|
@ -145,6 +146,7 @@ class i3(object):
|
|||
self.__content = {}
|
||||
self.__theme = theme
|
||||
self.__config = config
|
||||
self.__previous_draw = datetime.datetime.min
|
||||
core.event.register("update", self.update)
|
||||
core.event.register("start", self.draw, "start")
|
||||
core.event.register("draw", self.draw, "statusline")
|
||||
|
@ -176,6 +178,14 @@ class i3(object):
|
|||
self.__content[widget_id]["minimized"] = not self.__content[widget_id]["minimized"]
|
||||
|
||||
def draw(self, what, args=None):
|
||||
|
||||
if what == "statusline":
|
||||
now = datetime.datetime.now()
|
||||
prev = self.__previous_draw
|
||||
self.__previous_draw = now
|
||||
if (now - prev).total_seconds() < 0.03:
|
||||
return
|
||||
|
||||
cb = getattr(self, what)
|
||||
data = cb(args) if args else cb()
|
||||
if "blocks" in data:
|
||||
|
|
Loading…
Reference in a new issue