Skip to content

Commit

Permalink
Fix bugs in Mirror widget
Browse files Browse the repository at this point in the history
The Mirror widget has two bugs:
1) Static width widgets do not have their width copied to the reflection
2) Negative width widgets break the widget.

The use case for point 2 is a bit of a hack: a `Spacer` with a negative
width will not be drawn as the widget is only drawn where the width is
greater than zero. However, the length is taken into account when
positioning other widgets in ths bar.

This PR fixes both issues by setting the width and preventing the widget
from drawing when it has a width <= 0.
  • Loading branch information
elParaguayo authored and tych0 committed Mar 4, 2024
1 parent 39fc0b7 commit 435a3c8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions libqtile/widget/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -937,6 +937,8 @@ def __init__(self, reflection, **config):
self.reflects = reflection
self._length = 0
self.length_type = self.reflects.length_type
if self.length_type is bar.STATIC:
self._length = self.reflects._length

def _configure(self, qtile, bar):
_Widget._configure(self, qtile, bar)
Expand All @@ -959,6 +961,8 @@ def length(self, value):
self._length = value

def draw(self):
if self.length <= 0:
return
self.drawer.clear_rect()
self.reflects.drawer.paint_to(self.drawer)
self.drawer.draw(offsetx=self.offset, offsety=self.offsety, width=self.width)
Expand Down

0 comments on commit 435a3c8

Please sign in to comment.