From 2d3f4e18c1168e575175bf18f2e03ed48cf00ee3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Deuc=D0=B5?= <shurd@sasktel.net>
Date: Mon, 5 Jun 2023 19:16:18 -0400
Subject: [PATCH] Fix black bar generation

Was wrong and therefore causing flickering.
---
 src/conio/x_events.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/conio/x_events.c b/src/conio/x_events.c
index 63a12edb93..2cf10e7b0f 100644
--- a/src/conio/x_events.c
+++ b/src/conio/x_events.c
@@ -1335,10 +1335,15 @@ local_draw_rect(struct rectlist *rect)
 
 	// TODO: We really only need to do this once after changing resolution...
 	if (xoff > 0 || yoff > 0) {
-		x11.XFillRectangle(dpy, win, gc, 0, 0, w, yoff);
-		x11.XFillRectangle(dpy, win, gc, 0, yoff, xoff, yoff + xim->height);
-		x11.XFillRectangle(dpy, win, gc, xoff+xim->width, yoff, w, yoff + xim->height);
-		x11.XFillRectangle(dpy, win, gc, 0, yoff + xim->height, w, h);
+		if (yoff != 0) {
+			x11.XFillRectangle(dpy, win, gc, 0, 0, w, yoff);
+		}
+		if (xoff != 0) {
+			x11.XFillRectangle(dpy, win, gc, 0, yoff, xoff, yoff + ctop);
+		}
+		// These clean up odd-numbered widths,
+		x11.XFillRectangle(dpy, win, gc, xoff + cleft, yoff, w, yoff + ctop);
+		x11.XFillRectangle(dpy, win, gc, 0, yoff + ctop, w, h);
 	}
 	if (internal_scaling || xrender_found == false) {
 		if (last == NULL)
-- 
GitLab