Use this to implement different looking Terminal cursors depending on the window active state.
This turned into a huge refactoring that somehow also includes making locks recursive/reentrant.