improve showorhideWindow logic