This is a backport of a patch I made for 5.9 originally and I have never seen notifications being positioned in the wrong way (too far from the panel) ever since. Now that 5.9 is out for a while and we haven't had any complains as far as I can tell, I consider this patch to be safe to 5.8.
Without the patch, clicking an action in a notification usually proved enough to get the positioner confused.
(The only difference in this patch to the 5.9 one is that the onOpenUrl part is missing since that is a 5.9 addition)
* Clicking actions on notification still works
* Closing a notification (both X and clicking the popup, as we had in 5.8) works
* Configure button also works