Refactor WindowContext::setLayout.