From 0cc744ed1596959abf5c76526111ad8bdd1c1fc0 Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Mon, 24 Feb 2020 15:05:58 +0100 Subject: [PATCH] [core/output] Cache widget output for selective redraw To make redraw work correctly and elegantly with supplementary elements (e.g. prefix, postfix, separators), always do a full redraw of the bar (to make the theme update correctly, but cache the actual *data* to display inside the output. --- core/output.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/core/output.py b/core/output.py index 0d70a86..0aa2c38 100644 --- a/core/output.py +++ b/core/output.py @@ -70,13 +70,14 @@ class i3(object): 'full_text': self._theme.separator(), 'color': self._theme.bg(widget), 'background': self._theme.bg('previous'), + '_decorator': True, }) return [attr] - def __main(self, module, widget): + def __main(self, module, widget, text): attr = self.__common_attributes(module, widget) attr.update({ - 'full_text': self.__decorate(module, widget, widget.full_text()), + 'full_text': self.__decorate(module, widget, text), 'color': self._theme.fg(widget), 'background': self._theme.bg(widget), }) @@ -86,7 +87,7 @@ class i3(object): widgets = [] for widget in module.widgets(): widgets += self.__separator(module, widget) - widgets += self.__main(module, widget) + widgets += self.__main(module, widget, self._status[widget]) core.event.trigger('next-widget') return widgets @@ -95,13 +96,13 @@ class i3(object): if affected_modules and not module.id() in affected_modules: continue module.update() - self._status[module] = self.widgets(module) + for widget in module.widgets(): + self._status[widget] = widget.full_text() def statusline(self): widgets = [] for module in self._modules: - if module in self._status: - widgets += self._status[module] + widgets += self.widgets(module) return { 'data': widgets, 'suffix': ','