refined rules to finally deal with dialog windows correctly