Author: AlbrechtS
Date: 2010-11-22 05:01:03 -0800 (Mon, 22 Nov 2010)
New Revision: 7882
Log:
Fix X11 coordinates > 32767 (STR #2304).


Modified:
   branches/branch-1.3/src/fl_rect.cxx

Modified: branches/branch-1.3/src/fl_rect.cxx
===================================================================
--- branches/branch-1.3/src/fl_rect.cxx 2010-11-21 18:15:32 UTC (rev 7881)
+++ branches/branch-1.3/src/fl_rect.cxx 2010-11-22 13:01:03 UTC (rev 7882)
@@ -507,7 +507,25 @@
   if (x+w <= 0 || y+h <= 0) return 0;
   Fl_Region r = rstack[rstackptr];
 #if defined (USE_X11)
-  return r ? XRectInRegion(r, x, y, w, h) : 1;
+  if (!r) return 1;
+
+  // First get rid of coordinates outside the 16-bit range the X calls take.
+  // We could probably also use max. screen coordinates instead of SHRT_MAX
+  
+#ifndef SHRT_MAX
+#define SHRT_MAX (32767)
+#endif
+
+  if (x>SHRT_MAX || y > SHRT_MAX) return 0;
+  int tx = x, ty = y, tw = w, th = h;
+  if (x < 0) { tx = 0; tw += x; }
+  if (y < 0) { ty = 0; th += y; }
+  if (tx+tw > SHRT_MAX) tw = SHRT_MAX - tx;
+  if (ty+th > SHRT_MAX) th = SHRT_MAX - ty;
+
+  // now all coordinates to test are in the range [0,32767]
+
+  return r ? XRectInRegion(r, tx, ty, tw, th) : 1;
 #elif defined(WIN32)
   if (!r) return 1;
   RECT rect;

_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit

Reply via email to