The EventManager only makes sense in an environment where window exists. So no need to test for window everywhere, just use it (and cc-typecase the result of runtime.getWindow())