/* Change a window's parent. 
This function detaches a window from its parent and attaches it to a new parent, as the top child window. This essentially moves a window from one parent to another. If the window is not mapped, it will still be unmapped at the new parent. */
void win_reparent(struct win_window *child, struct win_window *new_parent)
/* Change a window's parent. 
This function detaches a window from its parent and attaches it to a new parent, as the top child window. This essentially moves a window from one parent to another. If the window is not mapped, it will still be unmapped at the new parent. */
void win_reparent(struct win_window *child, struct win_window *new_parent)
{
	bool was_mapped;
	Assert(child != NULL);
	Assert(child != &win_root);
	Assert(new_parent != NULL);
	was_mapped = child->is_mapped;
	if (was_mapped) {
		win_hide(child);
	}
	win_unlink(child);
	win_add_top_child(new_parent, child);
	if (was_mapped) {
		win_show(child);
	}
}