+
+ /* Finished for neutral position */
+ if (!dir)
+ return pos;
+
+ /* If we have a voiced position, make sure that it's on the
+ proper side of neutral before using it. If it isn't, we fall
+ back to a constant offset from neutral position.
+ */
+
+ Real neutral = staff_position_internal (me, duration_log, 0);
+
+ if (dir * (pos - neutral) > 0)
+ return pos;
+
+ return neutral + 4 * dir;
+}
+
+/* A rest might lie under a beam, in which case it should be cross-staff if
+ the beam is cross-staff because the rest's position depends on the
+ formatting of the beam. */
+MAKE_SCHEME_CALLBACK (Rest, calc_cross_staff, 1);
+SCM
+Rest::calc_cross_staff (SCM smob)
+{
+ Grob *me = unsmob_grob (smob);
+ Grob *stem = unsmob_grob (me->get_object ("stem"));
+
+ if (!stem)
+ return SCM_BOOL_F;
+
+ return stem->get_property ("cross-staff");