Layer toolbox: improve tooltip behavior

- More reliable method for clearing the tooltip when no layer is hovered
- Fix flickering when hovering a tooltip that is word-wrapped

Thanks to Gio for reporting this.