Refactor window creation for screenshots