added option to disable refresh when window hidden