Minor tweaks to ensure contextmenu stays within window bounds

This is useful with overflow: hidden, or other times when the context menu disappears completely from the screen.