[master] 12c0509 - X11: fix fl_clip_box() coordinates > 16-bit (STR 3134)

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.commit  ]
 
Previous Message ]Next Message ]

[master] 12c0509 - X11: fix fl_clip_box() coordinates > 16-bit (STR 3134) "Albrecht Schlosser" 06:32 May 26 top right image
 
commit 12c050980692c05fb3eb59acd7aba6a46bea4bf8
Author:     Albrecht Schlosser <albrechts.fltk@online.de>
AuthorDate: Wed May 26 15:25:36 2021 +0200
Commit:     Albrecht Schlosser <albrechts.fltk@online.de>
CommitDate: Wed May 26 15:25:36 2021 +0200

    X11: fix fl_clip_box() coordinates > 16-bit (STR 3134)
    
    Pre-clip coordinates to 16-bit range before using X11 clipping
    functions because X11 supports only 16-bit int's.

 src/drivers/Xlib/Fl_Xlib_Graphics_Driver_rect.cxx | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git src/drivers/Xlib/Fl_Xlib_Graphics_Driver_rect.cxx src/drivers/Xlib/Fl_Xlib_Graphics_Driver_rect.cxx
index 7bf905f..df29a5d 100644
--- src/drivers/Xlib/Fl_Xlib_Graphics_Driver_rect.cxx
+++ src/drivers/Xlib/Fl_Xlib_Graphics_Driver_rect.cxx
@@ -326,9 +326,18 @@ void Fl_Xlib_Graphics_Driver::push_clip(int x, int y, int w, int h) {
 
 int Fl_Xlib_Graphics_Driver::clip_box(int x, int y, int w, int h, int& X, int& Y, int& W, int& H) {
   X = x; Y = y; W = w; H = h;
+  // pre-clip rectangle to 16-bit coordinates (STR #3134)
+  if (clip_rect(X, Y, W, H)) { // entirely clipped (outside)
+    W = H = 0;
+    return 2;
+  }
   Fl_Region r = rstack[rstackptr];
-  if (!r) return 0;
-  switch (XRectInRegion(r, x, y, w, h)) {
+  if (!r) { // no clipping region
+    if (X != x || Y != y || W != w || H != h) // pre-clipped
+      return 1; // partially outside, region differs
+    return 0;
+  }
+  switch (XRectInRegion(r, X, Y, W, H)) {
     case 0: // completely outside
       W = H = 0;
       return 2;
@@ -337,7 +346,7 @@ int Fl_Xlib_Graphics_Driver::clip_box(int x, int y, int w, int h, int& X, int& Y
     default: // partial:
       break;
   }
-  Fl_Region rr = XRectangleRegion(x,y,w,h);
+  Fl_Region rr = XRectangleRegion(X, Y, W, H);
   Fl_Region temp = XCreateRegion();
   XIntersectRegion(r, rr, temp);
   XRectangle rect;
Direct Link to Message ]
 
bottom left image   bottom right image
Previous Message ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2022 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.