Repository: qtile/qtile

Issue:
Mirrored widgets on multi-display get wrong background transparency
### Issue description

I'm trying to use the advised way of putting the same widget on multiple bars (displays). That means I define a widget object like this:
```python
widget_volume = widget.PulseVolume(
  fmt="󰕾 {}",
  mouse_callbacks={"Button3": lambda: qtile.spawn("pavucontrol")},
  limit_max_volume=True,
  background="#242936" + "99",
  **powerline_left,
)
```
Note that for clarity I have separated out the alpha channel from the background color.

After this, I add this widget variable to multiple Bar objects:
```python
screens = []
  for monitor in range(monitors):
      screens.append(
        Screen(
          top=bar.Bar(
            widgets=[
...
              widget.Sep(
                  background="#242936" + "99",
                  size_percent=60,
              ),
              widget_volume,
...
```
On Screen 1, this works fine, but on Screens 2 and 3 the same widget gets a weird background transparency. Please see the screenshots below for what I mean. All widgets except the volume widget are declared inside the bar and they get the correct background color and transparency.

Screen 1:
![Screenshot_2023-11-24_09-11-1700815250](https://github.com/qtile/qtile/assets/10400299/0d9ca2e1-4549-4799-961e-d933b647e06a)
Screen 2:
![Screenshot_2023-11-24_09-11-1700815269](https://github.com/qtile/qtile/assets/10400299/a80a00ef-eb58-400d-a749-39ee65467870)
Screen 3:
![Screenshot_2023-11-24_09-11-1700815282](https://github.com/qtile/qtile/assets/10400299/424e724b-dc55-4c84-9549-e1b2ea193da3)

I have tried modifying the transparency part ("99") to fully opaque ("ff") and fully transparent ("00") and those show as expected on all screens. It's just with partial transparency that the calculation seems to be off on my 2nd and 3rd screen.

Additionally, as you can see these screenshots are when using the powerline decoration from qtile_extras, but the same happens when using the widgets from qtile proper.

### Version

Current master (551269802) + PR 4525 patch

### Backend

Wayland (experimental)

### Config

_No response_

### Logs

_No response_

### Required

- [X] I have searched past issues to see if this bug has already been reported, and it hasn't been.
- [X] I understand that people give their precious time for free, and thus I've done my very best to make this problem as easy as possible to investigate.


Discussion:
Thanks. I've had issues with mirrors before. I'll take a look when I can but I'm traveling for work for the next week.
If you change the volume, does the text change properly or does it start overlapping previous text?
I wish I knew, but I was trying to find a workaround for https://github.com/qtile/qtile/issues/4439 :)
Seriously though, other widgets have the same issue and they don't show overlapping text.
Ha. OK. I don't think mirrors will solve that issue (the latest version of the widget only creates a single connection to the pulse server, regardless of how many widgets you use).

I've got some theories about the mirror background issue so I'll take a look when I can.
Thank you!
Can you provide a minimal config file to recreate this? My suspicion is that this is related to the decorations but would be good to see if you can recreate with and without decorations.
@arjan-s are you able to help with the above request?
Struggling to recreate this. Can you share your config?
Sorry, took me a while to make time for this. Here is a dumbed down version of my config: https://gist.github.com/arjan-s/e7b3835f0ef8e1febd08b6253360d2c6
This is how it looks on display 1:
![Screenshot_2024-02-05_11-02-1707130321](https://github.com/qtile/qtile/assets/10400299/d23f9990-1341-4cbb-af96-24c245d630bf)
And on display 2:
![Screenshot_2024-02-05_11-02-1707130688](https://github.com/qtile/qtile/assets/10400299/a374c444-9bf7-46a1-bcf4-ca323b510b98)
Note that the different background color (the widgets are transparent) is due to a different wallpaper on the second display.
Running on master revision 0aca7be183be00134acb3221dd39cadf690b7b6c patched with https://github.com/qtile/qtile/pull/4524.
Great. Thank you. I'll take a look when I can (hopefully tonight).
OK - I can recreate this now. I have some ideas. Will test when I've got a bit more spare time.
Thanks! No hurry though, I'm not bothered by it.

Resolving patch:
diff --git a/libqtile/widget/base.py b/libqtile/widget/base.py
--- a/libqtile/widget/base.py
+++ b/libqtile/widget/base.py
@@ -959,7 +959,7 @@ def length(self, value):
         self._length = value
 
     def draw(self):
-        self.drawer.clear(self.reflects.background or self.bar.background)
+        self.drawer.clear_rect()
         self.reflects.drawer.paint_to(self.drawer)
         self.drawer.draw(offsetx=self.offset, offsety=self.offsety, width=self.width)
 


Test patch: