Update position algorithm for context toolbar