GNOME Bugzilla – Bug 464528
gdk_rectangle_union() and gdk_rectangle_intersect() should ignore "empty" rectangles
Last modified: 2016-01-20 18:46:21 UTC
If one of the input rects has zero width or height, it should be ignored. If both are empty, dest should have width and height set to zero (x and y can stay undefined/untouched).
Probably this should go in a different bug, but while we are at it... Recently I used gdk_rectangle_intersect just for its boolean return value without being interested at all in the actual intersecting area, but it has a g_return_val_if_fail (dest != NULL, FALSE), forcing you to pass a dummy variable. IMHO a NULL value should be allowed for dest.
Created attachment 93308 [details] [review] [1/1] Allow NULL as the dest parameter for gdk_rectangle_intersect. gdk/gdkrectangle.c | 20 ++++++++++++-------- 1 files changed, 12 insertions(+), 8 deletions(-)
Should gdk_rectangle_union() really ignore zero sized rectangles? For gdk_rectangle_intersect() it sounds very reasonable, but isn't there a risk that some code might break if the union of 10,10+0x0 and 20,20+10x10 becomes 20,20+10x10 instead of 10,10+20x20?
(In reply to comment #1) > Probably this should go in a different bug, but while we are at it... Filed as bug 464847. > Recently I used gdk_rectangle_intersect just for its boolean return value > without being interested at all in the actual intersecting area, but it has a > g_return_val_if_fail (dest != NULL, FALSE), forcing you to pass a dummy > variable. IMHO a NULL value should be allowed for dest.
(In reply to comment #3) > Should gdk_rectangle_union() really ignore zero sized rectangles? For > gdk_rectangle_intersect() it sounds very reasonable, but isn't there a risk > that some code might break if the union of 10,10+0x0 and 20,20+10x10 becomes > 20,20+10x10 instead of 10,10+20x20? I agree that there may be code out there relying on the current behavior, but mathematically speaking, zero-sized rectangles should not affect the union. There is no point inside a zero-sized rectangle afterall.
2007-09-06 Matthias Clasen <mclasen@redhat.com> * gdk/gdkrectangle.c (gdk_rectangle_intersect): Allow dest to be NULL. (#464528, Xan Lopez)
Shouldn't the docs point out that dest==NULL is only allowed Since: 2.12 ?
I don't have any strong opinions either way. We have at times avoided cluttering docs with such meticulous version keeping. The idea being that docs for each version document that version (which hopefully will remain valid for future versions too). Anyway, that belongs to bug 464847, not this one.
Decided to just document the current behavior. Its been in place for too long to change it now.