Move app caching into InputHookManager

This avoids a problem I noticed in gh-6496, where a subclassed handler would have its application registered by the parent class under the wrong name.