better focus and window state tracking