Fix positioning at right edge of narrow window

If the window was too narrow to pop the menu to the left, it would go
off the right edge. The menu position is now clamped so that this will
not happen.