--- a/XWorkstation.st Thu Nov 08 11:21:34 2001 +0100
+++ b/XWorkstation.st Thu Nov 08 11:24:57 2001 +0100
@@ -3310,14 +3310,23 @@
&& __isExternalAddress(aGCId)
&& __isExternalAddress(aDrawableId)
&& __bothSmallInteger(x, y)) {
- gc = __GCVal(aGCId);
- win = __WindowVal(aDrawableId);
-
- ENTER_XLIB();
- XDrawPoint(myDpy, win, gc, __intVal(x), __intVal(y));
- LEAVE_XLIB();
-
- RETURN ( self );
+ int px, py;
+
+ gc = __GCVal(aGCId);
+ win = __WindowVal(aDrawableId);
+
+ px = __intVal(x);
+ py = __intVal(y);
+ if (px > 0x7FFF) px = 0x7FFF;
+ else if (px < -0x8000) px = -0x8000;
+ if (py > 0x7FFF) py = 0x7FFF;
+ else if (py < -0x8000) py = -0x8000;
+
+ ENTER_XLIB();
+ XDrawPoint(myDpy, win, gc, px, py);
+ LEAVE_XLIB();
+
+ RETURN ( self );
}
%}.
"badGC, badDrawable or x/y not integer"
@@ -3347,41 +3356,53 @@
&& __isExternalAddress(aGCId)
&& __isExternalAddress(aDrawableId)
&& __isSmallInteger(numberOfPoints)) {
- gc = __GCVal(aGCId);
- win = __WindowVal(aDrawableId);
- num = __intVal(numberOfPoints);
- /*
- * avoid a (slow) malloc, if the number of points is small
- */
- if (num > 100) {
- points = (XPoint *)malloc(sizeof(XPoint) * num);
- if (! points) goto fail;
- mustFree = 1;
- } else
- points = qPoints;
-
- for (i=0; i<num; i++) {
- point = __AT_(aPolygon, __MKSMALLINT(i+1));
- if (! __isPoint(point)) goto fail;
- x = _point_X(point);
- y = _point_Y(point);
- if (! __bothSmallInteger(x, y))
- goto fail;
- points[i].x = __intVal(x);
- points[i].y = __intVal(y);
- }
-
- ENTER_XLIB();
- XDrawLines(myDpy, win, gc, points, num, CoordModeOrigin);
- LEAVE_XLIB();
-
- if (mustFree)
- free(points);
- RETURN ( self );
+ gc = __GCVal(aGCId);
+ win = __WindowVal(aDrawableId);
+ num = __intVal(numberOfPoints);
+ /*
+ * avoid a (slow) malloc, if the number of points is small
+ */
+ if (num > 100) {
+ points = (XPoint *)malloc(sizeof(XPoint) * num);
+ if (! points) goto fail;
+ mustFree = 1;
+ } else
+ points = qPoints;
+
+ for (i=0; i<num; i++) {
+ int px, py;
+
+ point = __AT_(aPolygon, __MKSMALLINT(i+1));
+ if (! __isPoint(point)) goto fail;
+ x = _point_X(point);
+ y = _point_Y(point);
+ if (! __bothSmallInteger(x, y))
+ goto fail;
+
+ px = __intVal(x);
+ py = __intVal(y);
+
+ /* attention: coordinates in X are shorts and wrap; clamp here. */
+ if (px > 0x7FFF) px = 0x7FFF;
+ else if (px < -0x8000) px = -0x8000;
+ if (py > 0x7FFF) py = 0x7FFF;
+ else if (py < -0x8000) py = -0x8000;
+
+ points[i].x = px;
+ points[i].y = py;
+ }
+
+ ENTER_XLIB();
+ XDrawLines(myDpy, win, gc, points, num, CoordModeOrigin);
+ LEAVE_XLIB();
+
+ if (mustFree)
+ free(points);
+ RETURN ( self );
}
fail: ;
if (mustFree)
- free(points);
+ free(points);
%}.
"badGC, badDrawable or coordinates not integer"
self primitiveFailedOrClosedConnection
@@ -3402,19 +3423,31 @@
&& __isExternalAddress(aDrawableId)
&& __bothSmallInteger(x, y)
&& __bothSmallInteger(width, height)) {
- gc = __GCVal(aGCId);
- win = __WindowVal(aDrawableId);
- w = __intVal(width);
- h = __intVal(height);
- /*
- * need this check here: some servers simply dump core with bad args
- */
- if ((w >= 0) && (h >= 0)) {
- ENTER_XLIB();
- XDrawRectangle(myDpy, win, gc, __intVal(x), __intVal(y), w, h);
- LEAVE_XLIB();
- }
- RETURN ( self );
+ int px, py;
+
+ gc = __GCVal(aGCId);
+ win = __WindowVal(aDrawableId);
+ w = __intVal(width);
+ h = __intVal(height);
+
+ /*
+ * need this check here: some servers simply dump core with bad args
+ */
+ if ((w >= 0) && (h >= 0)) {
+ px = __intVal(x);
+ py = __intVal(y);
+
+ /* attention: coordinates in X are shorts and wrap; clamp here. */
+ if (px > 0x7FFF) px = 0x7FFF;
+ else if (px < -0x8000) px = -0x8000;
+ if (py > 0x7FFF) py = 0x7FFF;
+ else if (py < -0x8000) py = -0x8000;
+
+ ENTER_XLIB();
+ XDrawRectangle(myDpy, win, gc, px, py, w, h);
+ LEAVE_XLIB();
+ }
+ RETURN ( self );
}
%}.
"badGC, badDrawable or coordinates not integer"
@@ -11599,6 +11632,6 @@
!XWorkstation class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview/XWorkstation.st,v 1.399 2001-11-08 10:21:34 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview/XWorkstation.st,v 1.400 2001-11-08 10:24:57 cg Exp $'
! !
XWorkstation initialize!