Calculate the position of the context menu