Move windowing code out of the compositor

This is mainly just moving code around, in preparation for further changes to
the "windowing" API.
Merge pull request #3563 from mbrubeck/app2

Move windowing code out of compositor, take 2. r=larsberg