diff options
| author | Albrecht Schlosser <albrechts.fltk@online.de> | 2010-11-22 13:01:03 +0000 |
|---|---|---|
| committer | Albrecht Schlosser <albrechts.fltk@online.de> | 2010-11-22 13:01:03 +0000 |
| commit | 7d84aea1fbaf57a0fa2da1ee9a838005562b9a37 (patch) | |
| tree | dca220a3441627a85d87505fadc7731200f05ad0 /src/fl_rect.cxx | |
| parent | 07a94f6b09d1b2c718367eff007795e2b317895f (diff) | |
Fix X11 coordinates > 32767 (STR #2304).
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7882 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/fl_rect.cxx')
| -rw-r--r-- | src/fl_rect.cxx | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/fl_rect.cxx b/src/fl_rect.cxx index d27ab2287..4a4a46031 100644 --- a/src/fl_rect.cxx +++ b/src/fl_rect.cxx @@ -507,7 +507,25 @@ int Fl_Graphics_Driver::not_clipped(int x, int y, int w, int h) { 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; |
