Fix drawing with negative window origin
authorPeter Harris <pharris@opentext.com>
Thu, 3 Sep 2015 22:42:53 +0000 (18:42 -0400)
committerPeter Harris <pharris@opentext.com>
Thu, 3 Sep 2015 22:48:42 +0000 (18:48 -0400)
Since REGION16 uses unsigned values, when appWindow->x or appWindow->y
is negative, the region will have a very large left or top value.

Avoid this problem by clamping to 0 before casting to an unsigned value.

client/X11/xf_rail.c

index a87d7c4..d81d97d 100644 (file)
@@ -222,10 +222,10 @@ void xf_rail_invalidate_region(xfContext* xfc, REGION16* invalidRegion)
 
                if (appWindow)
                {
-                       windowRect.left = appWindow->x;
-                       windowRect.top = appWindow->y;
-                       windowRect.right = appWindow->x + appWindow->width;
-                       windowRect.bottom = appWindow->y + appWindow->height;
+                       windowRect.left = MAX(appWindow->x, 0);
+                       windowRect.top = MAX(appWindow->y, 0);
+                       windowRect.right = MAX(appWindow->x + appWindow->width, 0);
+                       windowRect.bottom = MAX(appWindow->y + appWindow->height, 0);
 
                        region16_clear(&windowInvalidRegion);
                        region16_intersect_rect(&windowInvalidRegion, invalidRegion, &windowRect);