Improve activities support
Besides fixing KActivities detection, this adds support for closing windows when they are only shown in stopped activities and restore them when one of those activities are started again.
Note that in theory, this shouldn't be necessary, as the activities system should take care of everything itself. However, for some reason, it doesn't work.