From 9417fca2c55406e03031098196778f64f3016abe Mon Sep 17 00:00:00 2001 From: rolandlo Date: Tue, 22 Sep 2020 18:16:59 +0200 Subject: [PATCH] Fixup #2254 --- src/model/Element.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/model/Element.cpp b/src/model/Element.cpp index 1cc25bb1..67e3f0fb 100644 --- a/src/model/Element.cpp +++ b/src/model/Element.cpp @@ -75,7 +75,14 @@ void Element::setColor(Color color) { this->color = color; } auto Element::getColor() const -> Color { return this->color; } auto Element::intersectsArea(const GdkRectangle* src) -> bool { - GdkRectangle rect = {gint(getX()), gint(getY()), gint(getElementWidth()), gint(getElementHeight())}; + // compute the smallest rectangle with integer coordinates containing the bounding box and having width, height > 0 + auto x = getX(); + auto y = getY(); + auto x1 = gint(std::floor(getX())); + auto y1 = gint(std::floor(getY())); + auto x2 = gint(std::ceil(x + getElementWidth())); + auto y2 = gint(std::ceil(y + getElementHeight())); + GdkRectangle rect = {x1, y1, std::max(1, x2 - x1), std::max(1, y2 - y1)}; return gdk_rectangle_intersect(src, &rect, nullptr); }