Index: Headers/gnustep/xgps/XGGeometry.h =================================================================== RCS file: /cvsroot/gnustep/gnustep/core/xgps/Headers/gnustep/xgps/XGGeometry.h,v retrieving revision 1.1 diff -c -r1.1 XGGeometry.h *** Headers/gnustep/xgps/XGGeometry.h 21 Nov 2001 03:35:32 -0000 1.1 --- Headers/gnustep/xgps/XGGeometry.h 26 Jan 2002 22:47:46 -0000 *************** *** 154,160 **** an appreciable difference on speed - will it ? */ static inline int gs_floor (float f) { ! if (f >= 0) { return (int)f; } --- 154,160 ---- an appreciable difference on speed - will it ? */ static inline int gs_floor (float f) { ! if (f >= 0.0) { return (int)f; } *************** *** 162,168 **** { int g = (int)f; ! if (f - ((float)g) > 0) { return g - 1; } --- 162,168 ---- { int g = (int)f; ! if (f - ((float)g) > 0.0) { return g - 1; } *************** *** 189,207 **** return newPoint; } static inline XRectangle XGWindowRectToX (XGGState *s, NSRect r) { XRectangle newRect; newRect.x = gs_floor(r.origin.x + s->offset.x); ! /* We gs_floor the extreme points, and get the width as the difference */ ! newRect.width = gs_floor(r.origin.x + s->offset.x + r.size.width) ! - newRect.x; ! newRect.y = gs_floor(s->offset.y - r.origin.y - r.size.height); ! newRect.height = gs_floor(s->offset.y - r.origin.y) - newRect.y; ! return newRect; } --- 189,221 ---- return newPoint; } + /* + * Convert NSRect to XWindow rectangle. This means that there are + * two conversions needed. + * + * 1 - flip vertically + * 2 - round to integer coordinates. + * + * The problem is is in the rounding. + * At the moment we round the origin down to the nearest integer. + * (The rounding is done in X-coordinates) + * The size is also rounded down. + * + * an older implementation (26 Jan 2002) rounded the corner coordinates + * down. This had the disadvantage that the resulting size + * depends on the origin of the rectangle r. + */ static inline XRectangle XGWindowRectToX (XGGState *s, NSRect r) { XRectangle newRect; newRect.x = gs_floor(r.origin.x + s->offset.x); ! newRect.width = gs_floor (r.size.width); ! newRect.y = gs_floor(s->offset.y - r.origin.y - r.size.height); ! newRect.height = gs_floor (r.size.height); ! return newRect; }