From d28ded0cd5a00fcd83d886feaa0fadd73da0d3b6 Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Mon, 16 Mar 2026 12:08:21 +0100 Subject: [PATCH] Fix "Cairo: Rect with negative dimensions is still drawn" (#1379) --- src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx b/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx index 3a9262f91..cc4057993 100644 --- a/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx +++ b/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx @@ -143,20 +143,20 @@ void Fl_Cairo_Graphics_Driver::set_cairo(cairo_t *cr, float s) { void Fl_Cairo_Graphics_Driver::rectf(int x, int y, int w, int h) { + if (w < 1 || h < 1) return; cairo_rectangle(cairo_, x-0.5, y-0.5, w, h); cairo_set_antialias(cairo_, CAIRO_ANTIALIAS_NONE); cairo_fill(cairo_); cairo_set_antialias(cairo_, CAIRO_ANTIALIAS_DEFAULT); - check_status(); surface_needs_commit(); } void Fl_Cairo_Graphics_Driver::rect(int x, int y, int w, int h) { + if (w <= 1 || h <= 1) return; cairo_rectangle(cairo_, x, y, w-1, h-1); if (linestyle_ == FL_SOLID) cairo_set_antialias(cairo_, CAIRO_ANTIALIAS_NONE); cairo_stroke(cairo_); if (linestyle_ == FL_SOLID) cairo_set_antialias(cairo_, CAIRO_ANTIALIAS_DEFAULT); - check_status(); surface_needs_commit(); }