From: Vadim Zeitlin <vadim@wxwidgets.org>
Date: Sat, 7 Sep 2002 17:21:26 +0000 (+0000)
Subject: applied the workaround for XUnionRectWithRegion() returning ampty result if the rect... 
X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/9afe6c17502fc82d9af19c260ab4b8bedb7fe70e

applied the workaround for XUnionRectWithRegion() returning ampty result if the rect is empty to wxX11 and wxMotif as well


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@17046 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---

diff --git a/src/motif/region.cpp b/src/motif/region.cpp
index fb3b1e3db2..1bec3f26ce 100644
--- a/src/motif/region.cpp
+++ b/src/motif/region.cpp
@@ -200,8 +200,17 @@ void wxRegion::Clear()
 }
 
 //! Combine rectangle (x, y, w, h) with this.
-bool wxRegion::Combine(wxCoord x, wxCoord y, wxCoord width, wxCoord height, wxRegionOp op)
+bool
+wxRegion::Combine(wxCoord x, wxCoord y,
+                  wxCoord width, wxCoord height,
+                  wxRegionOp op)
 {
+    // work around for XUnionRectWithRegion() bug: taking a union with an empty
+    // rect results in an empty region (at least XFree 3.3.6 and 4.0 have this
+    // problem)
+    if ( op == wxRGN_OR && (!width || !height) )
+        return TRUE;
+
     // Don't change shared data
     if (!m_refData) {
         m_refData = new wxRegionRefData();
diff --git a/src/x11/region.cpp b/src/x11/region.cpp
index 1f7f4d5929..0b5130d9be 100644
--- a/src/x11/region.cpp
+++ b/src/x11/region.cpp
@@ -149,6 +149,12 @@ void wxRegion::Clear()
 
 bool wxRegion::Union( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
 {
+    // work around for XUnionRectWithRegion() bug: taking a union with an empty
+    // rect results in an empty region (at least XFree 3.3.6 and 4.0 have this
+    // problem)
+    if ( !width || !height )
+        return TRUE;
+
     XRectangle rect;
     rect.x = x;
     rect.y = y;