Repository: qtile/qtile

Issue:
Bar border fails to redraw on some applications
I was trying out the [kate](https://kate-editor.org) editor and I noticed that the bar border fails to redraw after the application has been toggled fullscreen or just exited when fullscreen. Not sure how it's possible that it only happens on some applications, but so far only kate does this for me. Maybe several other KDE related apps do this? I mostly used terminal applications so I don't know.

This bug was introduced by #3067 so it happens at current master
![borderglitch](https://user-images.githubusercontent.com/46386452/147922590-5b56dcce-2661-4cd9-8ba7-6b417dab8993.gif)

The border will never redraw unless I restart qtile.

Happens with the default config that have bar border settings enabled.



Discussion:
Interesting. Thanks for reporting. 

I can take a look at this.
> Interesting. Thanks for reporting.
> 
> I can take a look at this.

Let me know if you need any help! I might also be available to do some experiments with this later
I'm struggling to recreate this. I've installed kate, made it fullscreen and quit the application and I can still see the border on the bar.
> I'm struggling to recreate this. I've installed kate, made it fullscreen and quit the application and I can still see the border on the bar.

Scratch that!

I can replicate this. I hadn't realised that I was using the `Bar` from `qtile-extras`! With that bar, I don't get the issue that you reported but, if I switch it to `libqtile.bar.Bar`, I do!

Also, the borders actually disappear _just before_ the kate window opens.

Now to work out what's different!
OK. The issue is that the bar doesn't draw borders every time `self.bar.draw()` is called. There's a flag `_borders_drawn` which, once set, prevents multiple draws as this reduces unnecessary processing time as the borders don't move (while the widgets do).

Removing this check fixes the problem but that's unsatisfactory (for the above reasons) so I'l like to understand why `kate` needs this but other windows don't. I have some ideas which I'll check.
Are you sure it's only `kate` that does it for you? I've seen this on `rofi` in fullscreen mode and `alacritty` too.

I've got a fix which I can submit shortly.

Resolving patch:
diff --git a/libqtile/bar.py b/libqtile/bar.py
--- a/libqtile/bar.py
+++ b/libqtile/bar.py
@@ -276,7 +276,7 @@ def _configure(self, qtile, screen):
             self.drawer = self.window.create_drawer(width, height)
             self.drawer.clear(self.background)
 
-            self.window.process_window_expose = self.draw
+            self.window.process_window_expose = self.process_window_expose
             self.window.process_button_click = self.process_button_click
             self.window.process_button_release = self.process_button_release
             self.window.process_pointer_enter = self.process_pointer_enter
@@ -515,6 +515,13 @@ def widget_ungrab_keyboard(self):
             self.saved_focus.focus(False)
         self.has_keyboard = None
 
+    def process_window_expose(self):
+        """
+        If the window is being redrawn we need to redraw borders too.
+        """
+        self._borders_drawn = False
+        self.draw()
+
     def draw(self):
         if not self.widgets:
             return  # calling self._actual_draw in this case would cause a NameError.


Test patch: