  The Farey sequence is the sequence of all rational numbers in the real unit
interval, stratified by increasing denominators. A classical result by Hall
says that its normalized gap distribution is the same as the distribution of
the random variable 1/(2 zeta(2) xy) on a certain unit triangle. In this paper
we weight the denominators by an arbitrary piecewise-smooth continuous
function, and we characterize the resulting gap distribution as that of a
multiple of the above variable, defined on a certain unit pentagon. Our
characterization refines previous results by Boca, Cobeli and Zaharescu, but
employs completely different techniques. Building upon recent work by Athreya
and Cheung, we construct a varying-with-time Poincar\'e section for the
horocycle flow on the space of unimodular lattices, and we interpret the
weighted Farey sequence as the list of return times to the section. Under an
appropriate parametrization, our pentagon appears as the orbit of Hall's
triangle under the motion of the section, and basic equidistribution results
for long closed horocycles yield explicit formulas for the limit transverse
measure.
