How to get the position in viewport of a widget item

from what i see, i think your padding is correct, so your math in terms of that should be good.
one thing i forgot to mention, make sure to remove the wrap box location from the cursor location, do the calculation, then add the wrap box back. if the wrap box is part of a canvas panel, get the wrap box as a canvas slot. that will give you its coordinates on the canvas panel. i forgot that you’ll be referencing the top left of the screen, rather than the wrap box. see if accounting for the wrap box like this helps.