[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.
This commit is contained in:
parent
1a093a73b1
commit
0cc744ed15
1 changed files with 7 additions and 6 deletions
|
@ -70,13 +70,14 @@ class i3(object):
|
||||||
'full_text': self._theme.separator(),
|
'full_text': self._theme.separator(),
|
||||||
'color': self._theme.bg(widget),
|
'color': self._theme.bg(widget),
|
||||||
'background': self._theme.bg('previous'),
|
'background': self._theme.bg('previous'),
|
||||||
|
'_decorator': True,
|
||||||
})
|
})
|
||||||
return [attr]
|
return [attr]
|
||||||
|
|
||||||
def __main(self, module, widget):
|
def __main(self, module, widget, text):
|
||||||
attr = self.__common_attributes(module, widget)
|
attr = self.__common_attributes(module, widget)
|
||||||
attr.update({
|
attr.update({
|
||||||
'full_text': self.__decorate(module, widget, widget.full_text()),
|
'full_text': self.__decorate(module, widget, text),
|
||||||
'color': self._theme.fg(widget),
|
'color': self._theme.fg(widget),
|
||||||
'background': self._theme.bg(widget),
|
'background': self._theme.bg(widget),
|
||||||
})
|
})
|
||||||
|
@ -86,7 +87,7 @@ class i3(object):
|
||||||
widgets = []
|
widgets = []
|
||||||
for widget in module.widgets():
|
for widget in module.widgets():
|
||||||
widgets += self.__separator(module, widget)
|
widgets += self.__separator(module, widget)
|
||||||
widgets += self.__main(module, widget)
|
widgets += self.__main(module, widget, self._status[widget])
|
||||||
core.event.trigger('next-widget')
|
core.event.trigger('next-widget')
|
||||||
return widgets
|
return widgets
|
||||||
|
|
||||||
|
@ -95,13 +96,13 @@ class i3(object):
|
||||||
if affected_modules and not module.id() in affected_modules:
|
if affected_modules and not module.id() in affected_modules:
|
||||||
continue
|
continue
|
||||||
module.update()
|
module.update()
|
||||||
self._status[module] = self.widgets(module)
|
for widget in module.widgets():
|
||||||
|
self._status[widget] = widget.full_text()
|
||||||
|
|
||||||
def statusline(self):
|
def statusline(self):
|
||||||
widgets = []
|
widgets = []
|
||||||
for module in self._modules:
|
for module in self._modules:
|
||||||
if module in self._status:
|
widgets += self.widgets(module)
|
||||||
widgets += self._status[module]
|
|
||||||
return {
|
return {
|
||||||
'data': widgets,
|
'data': widgets,
|
||||||
'suffix': ','
|
'suffix': ','
|
||||||
|
|
Loading…
Reference in a new issue