The issue you describe is caused by the z-ordering of the windows, and the fact that the lines are drawn at the same layer as the 'source' window, which means when you later interact with the target of that 'source' window, it is given higher priority in the z-ordering and hence overwrites the line.
There are some solutions / work arounds, though as with all things, none will give 'perfect' results in all cases - it's actually hard to think what perfect would look like due to the nature of the windows. For example, if the line crosses another window, should it be above the window, below the window, or perhaps the line should deviate around the window? It all depends...
Anyway, the couple of ideas I will give here basically play with the z-ordering of things so that the lines get drawn at least on top of what they should be (and perhaps on top of what they shouldn't be, but that - IMO - is another issue

).
The first - and for my money - 'best' option is to manually manage the z-ordering of the windows. What this means is that you disable z-ordering on the windows, and then arrange (or create) in such a way that what I refer to as 'source' windows are always 'above' their target windows.
To disable the z-ordering, you call
Window::setZOrderingEnabled with false, and to arrange windows in the z-order, you use the
Window::moveToFront,
Window::moveToBack,
Window::moveBehind and
Window::moveInFront functions (or you could create the windows in the appropriate order, from back to front, but this is highly prone to error!). In the code from the demo app, we would put
dst1 right at the bottom, with
main above it, and then
src1 and
src2 above that.
I think this gives good results, with the trade off that certain windows will always appear above others when overlapping - this said, I think that in a lot of cases that actually makes sense from a UI perspective anyway.
The second approach involves rendering the lines to a different queue on the RenderingSurface. The main change to make this happen is to substitute the
ctx.queue in the
Window::drawSelf override with, say,
CEGUI::RQ_OVERLAY. With this done, lines will be drawn over the top of
all windows - which in my opinion, makes this slightly less 'nice' than the first approach, however, depending on your exact needs, you might prefer it.
HTH
CE.