Correctly draw window snapping hints on multi-head systems
Previously, the transparent frames that were drawn prior to snapping a
window assumed that there was only one head, i.e., that the new
position and dimensions of the window would be based on the dimensions
of the entire screen.
However, this is not the case on multi-head systems, and so we now
base the transparent frame's position and dimensions on the current
head of the window.
We also refactor the code so that the new dimensions are computed in
the switch statement and finish with one final call to
drawTransparentFrame.
Use dock to determine whether drawer is on right side when swapping
Previously, we assumed that it always switched from left to right or
vice versa when calling swapDrawer. However, now we may also call
swapDrawer when changing the value of "KeepDockOnPrimaryHead", which
wouldn't actually switch which side of the screen it's on.
So instead, we determine which side of the screen it should be on
based on the dock.
Previously, we either saved it as 0 or -ICON_SIZE, and then adjusted
it depending on the screen width when restoring the state.
But since the introduction of the "KeepDockOnPrimaryHead" option, the
state-restoring code has changed so that the dock will go on the left if the
x-coordinate of the position in WMState is to the left of the midpoint
of the screen and on the right otherwise. But previously (unless the
user manually set the value in WMState) this would always send the
dock to the left, even if it had been on the right, since the x-coordinate
automatically saved to WMState in this case was negative.
We simplify things by saving the actual x position of the dock to WMState.
Use dock's position to determine position of dock menu
Previously, we assumed that if the dock was on the right, then the
menu should be on the far right of the entire screen, but this is no
longer the case with "KeepDockOnPrimaryHead" set to "YES".
Support "KeepDockOnPrimaryHead" when restoring state
We use the new helper function getDockXPosition to determine where
to put the dock. If WMState gives an x-coordinate less than the
center of the screen, we put it on the left, and otherwise we put it
on the right.
Support "KeepDockOnPrimaryHead" when initially creating dock
We use the new "getDockXPosition" helper function to find the x
position of the main icon, whose position is used in "wDockCreate" to
get the position of the entire dock.
Previously, "KeepDockOnPrimaryHead" was only taken into account
when *moving* the dock and not when creating it.