Improve title bar drawing by using NSTexturedBackgroundWindowMask and CoreUI; fix bugs

The commit messages should explain everything.

While this branch adds private APIs, I want to stress that they are protected by ifdefs which are OFF by default (add -DINAPPSTOREWINDOW_USE_COREUI=1 to compiler flags to enable) - this is only intended for use outside of the Mac App Store so that developers can take advantage of the more accurate title bar gradient painting.