This patch adds a single additional condition to the
maybe_flip_position function in
gdkwindowimpl.c. This condition checks to see if the unflipped position (referred to as "primary") is below the bounds of its containing area. If it is, then the flipped position (referred to as "secondary" ) is used instead, even if it failed the previous conditional check.
This resolves an issue that arises most often with desktop environment panels. For several panels, including (but not limited to) xfce-panel, budgie-panel, and tint2, tooltips for some applets would appear below the bounds of the screen. Issue #2784 tracks this problem.
I've tested this patch locally, and the problem is resolved on budgie-panel.