fix bug in handling hidden window situation
Tested on darcy.