-When the dock is at the bottom my window and controls are placed correct

-When the dock is on the right side the window is shown full height, but the controls are not at the top.

How can I detect whether the dock is at the bottom or on the side of the screen?