URI: 
       Fix clipping on border sides - ltk - GUI toolkit for X11 (WIP)
  HTML git clone git://lumidify.org/ltk.git (fast, but not encrypted)
  HTML git clone https://lumidify.org/ltk.git (encrypted, but very slow)
  HTML git clone git://4kcetb7mo7hj6grozzybxtotsub5bempzo4lirzc3437amof2c2impyd.onion/ltk.git (over tor)
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
   DIR commit 9c2187caf6ed1ae879c74854af037777707eb23d
   DIR parent 07a20345dc4d1ff7a311dc1359c36394dfbc3769
  HTML Author: lumidify <nobody@lumidify.org>
       Date:   Fri,  3 May 2024 10:40:31 +0200
       
       Fix clipping on border sides
       
       Diffstat:
         M src/ltk/graphics_xlib.c             |      16 ++++++++++++----
       
       1 file changed, 12 insertions(+), 4 deletions(-)
       ---
   DIR diff --git a/src/ltk/graphics_xlib.c b/src/ltk/graphics_xlib.c
       @@ -151,32 +151,40 @@ ltk_surface_draw_border_clipped(ltk_surface *s, ltk_color *c, ltk_rect rect, ltk
                XSetForeground(s->window->renderdata->dpy, s->window->gc, c->xcolor.pixel);
                int width;
                ltk_rect final_rect = ltk_rect_intersect(rect, clip_rect);
       +        if (final_rect.w == 0 || final_rect.h == 0)
       +                return;
       +        /* TODO: I guess this could be done with fewer branches because it isn't really necessary to perform
       +           a completel rect intersection each time, but it probably doesn't matter. */
                if (border_sides & LTK_BORDER_TOP) {
                        width = rect.y - final_rect.y;
                        if (width > -line_width) {
                                width = line_width + width;
       -                        XFillRectangle(s->window->renderdata->dpy, s->d, s->window->gc, final_rect.x, final_rect.y, final_rect.w, width);
       +                        ltk_rect draw_rect = ltk_rect_intersect(final_rect, (ltk_rect){final_rect.x, final_rect.y, final_rect.w, width});
       +                        XFillRectangle(s->window->renderdata->dpy, s->d, s->window->gc, draw_rect.x, draw_rect.y, draw_rect.w, draw_rect.h);
                        }
                }
                if (border_sides & LTK_BORDER_BOTTOM) {
                        width = (final_rect.y + final_rect.h) - (rect.y + rect.h);
                        if (width > -line_width) {
                                width = line_width + width;
       -                        XFillRectangle(s->window->renderdata->dpy, s->d, s->window->gc, final_rect.x, final_rect.y + final_rect.h - width, final_rect.w, width);
       +                        ltk_rect draw_rect = ltk_rect_intersect(final_rect, (ltk_rect){final_rect.x, final_rect.y + final_rect.h - width, final_rect.w, width});
       +                        XFillRectangle(s->window->renderdata->dpy, s->d, s->window->gc, draw_rect.x, draw_rect.y, draw_rect.w, draw_rect.h);
                        }
                }
                if (border_sides & LTK_BORDER_LEFT) {
                        width = rect.x - final_rect.x;
                        if (width > -line_width) {
                                width = line_width + width;
       -                        XFillRectangle(s->window->renderdata->dpy, s->d, s->window->gc, final_rect.x, final_rect.y, width, final_rect.h);
       +                        ltk_rect draw_rect = ltk_rect_intersect(final_rect, (ltk_rect){final_rect.x, final_rect.y, width, final_rect.h});
       +                        XFillRectangle(s->window->renderdata->dpy, s->d, s->window->gc, draw_rect.x, draw_rect.y, draw_rect.w, draw_rect.h);
                        }
                }
                if (border_sides & LTK_BORDER_RIGHT) {
                        width = (final_rect.x + final_rect.w) - (rect.x + rect.w);
                        if (width > -line_width) {
                                width = line_width + width;
       -                        XFillRectangle(s->window->renderdata->dpy, s->d, s->window->gc, final_rect.x + final_rect.w - width, final_rect.y, width, final_rect.h);
       +                        ltk_rect draw_rect = ltk_rect_intersect(final_rect, (ltk_rect){final_rect.x + final_rect.w - width, final_rect.y, width, final_rect.h});
       +                        XFillRectangle(s->window->renderdata->dpy, s->d, s->window->gc, draw_rect.x, draw_rect.y, draw_rect.w, draw_rect.h);
                        }
                }
        }