Tooltip placement

Fixes #1718 and #1721

Include the window in the "overflow" calculations, and use an unobstructed clone to measure the size of the tooltip.

Also included tests.

All these are covered by the top level function positionTooltip(). You can increase the coverage by using that instead of doing the same thing in the test.