I'm late to the party, but…
Looks good. I'll test it in the next days on a non-Wayland and a Windows system to ensure it doesn't break there.
Tested on Debian Testing and Windows 7, all modified popup menus appear as expected. Good job!
…but the go to declaration/definition if triggered by a keyboard event (e.g. <kbd>Primary+t</kbd>). It's not terrible, but sad. And if the autocompletion popup work OK, we should be able to also adjust the logic we have to also work there (I guess being Wayland it would mean stopping to be relative to the X/Y root, but using more relative coordinates?). And if we don't, we should really just drop all idea of popup positioning function for those, as it's effectively only used in GTK < 3.22, which basically nobody will have nowadays.