[core] fix broken "sparse" updates

c77f3aa accidentially broke "sparse" updates (i.e. updates that do not
trigger during each update interval).

Introduce a new update parameter, "force", to model the use case "update
everything on SIGUSR1".

fixes #692
This commit is contained in:
tobi-wan-kenobi 2020-08-28 17:14:05 +02:00
parent 362d1a5f6f
commit 905f71fa52
2 changed files with 3 additions and 5 deletions

View file

@ -106,7 +106,7 @@ def main():
def sig_USR1_handler(signum,stack):
if update_lock.acquire(blocking=False) == True:
core.event.trigger("update", redraw_only=False)
core.event.trigger("update", force=True)
core.event.trigger("draw")
update_lock.release()

View file

@ -221,15 +221,13 @@ class i3(object):
core.event.trigger("next-widget")
return blocks
# TODO: only updates full text, not the state!?
# can this TODO be removed now? Will update the state if not redraw_only
def update(self, affected_modules=None, redraw_only=False):
def update(self, affected_modules=None, redraw_only=False, force=False):
now = time.time()
for module in self.__modules:
if affected_modules and not module.id in affected_modules:
continue
if not affected_modules and module.next_update:
if now < module.next_update and redraw_only:
if now < module.next_update and not force:
continue
if not redraw_only: