/* Hide window, clear it from screen if it was visible. 
This function unmaps a window from its parent. If it was visible, it will be removed from the screen. If the root window is hidden, the screen background will be erased to the color WIN_SCREEN_COLOR. */
void win_hide(struct win_window *win)
/* Hide window, clear it from screen if it was visible. 
This function unmaps a window from its parent. If it was visible, it will be removed from the screen. If the root window is hidden, the screen background will be erased to the color WIN_SCREEN_COLOR. */
void win_hide(struct win_window *win)
{
	Assert(win != NULL);
	if (!win->is_mapped) {
		return;
	}
	if (win == &win_root) {
		win->is_mapped = false;
		gfx_set_clipping(0, 0, gfx_get_width(), gfx_get_height());
		gfx_draw_filled_rect(0, 0, gfx_get_width(), gfx_get_height(),
				WIN_SCREEN_COLOR);
	} else {
		if (win_is_visible(win)) {
			win->is_mapped = false;
			win_draw_parent(win, &win->attributes.area);
		} else {
			win->is_mapped = false;
		}
	}
}