Fixed.
EDIT:
The fix has the side effect that you have to select a word before you can use "Find declaration of..." (but that is the lesser evil).
The best solution will probably be to check whether there is currently a selection and whether the click is inside that selection. Otherwise, proceed as before. I haven't figured that yet, though.
Another solution (a lot easier) would be to rewrite "Find declaration of..." to use the click position rather than the cursor position. Not good, don't have mouse position available at that time.
EDIT 2:
Done that, too. Right-click in selection keeps selection. Right-click outside selection behaves as before. Guess that can be considered final now.