Centralize focus handling (bug 863328)