Move window surface creation into a function.