cocoa_common: refactor centered resize

This refactor makes the code easier to understand. Also corrects a bug that
caused the window to move to the left when the new size was bigger than the
visible frame.