aboutsummaryrefslogtreecommitdiff
path: root/generic
diff options
context:
space:
mode:
Diffstat (limited to 'generic')
-rw-r--r--generic/tkZinc.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/generic/tkZinc.c b/generic/tkZinc.c
index 5782f6a..cab10d3 100644
--- a/generic/tkZinc.c
+++ b/generic/tkZinc.c
@@ -3419,16 +3419,28 @@ Coords(ZnWInfo *wi,
/*printf(" coords: read %d points, first is %g@%g\n",
num_points, points->x, points->y);*/
l = Tcl_GetObjResult(wi->interp);
- for (i = 0; i < num_points; i++, points++) {
- entries[0] = Tcl_NewDoubleObj(points->x);
- entries[1] = Tcl_NewDoubleObj(points->y);
- if (controls && controls[i]) {
- c[0] = controls[i];
- entries[2] = Tcl_NewStringObj(c, -1);
- Tcl_ListObjAppendElement(wi->interp, l, Tcl_NewListObj(3, entries));
- }
- else {
- Tcl_ListObjAppendElement(wi->interp, l, Tcl_NewListObj(2, entries));
+ if (item->class->pos_offset >= 0) {
+ /*
+ * Special case for items with a -position. In this case
+ * we are guaranteed to return exactly one point, it is
+ * then more friendly to return it flat instead of as the
+ * only element of a list.
+ */
+ Tcl_ListObjAppendElement(wi->interp, l, Tcl_NewDoubleObj(points->x));
+ Tcl_ListObjAppendElement(wi->interp, l, Tcl_NewDoubleObj(points->y));
+ }
+ else {
+ for (i = 0; i < num_points; i++, points++) {
+ entries[0] = Tcl_NewDoubleObj(points->x);
+ entries[1] = Tcl_NewDoubleObj(points->y);
+ if (controls && controls[i]) {
+ c[0] = controls[i];
+ entries[2] = Tcl_NewStringObj(c, -1);
+ Tcl_ListObjAppendElement(wi->interp, l, Tcl_NewListObj(3, entries));
+ }
+ else {
+ Tcl_ListObjAppendElement(wi->interp, l, Tcl_NewListObj(2, entries));
+ }
}
}
return TCL_OK;