fix background/foreground switch

fix #9689