added a global variable to check if layout surface should be refreshed