'add_physical_source' here just doesn't look consistent with other functions in device_manager. Maybe add a "BOOL is_physical" or something in struct device_manager_ctx so that when both is_physical and is_virtual_desktop() are TRUE we report sources as detached. Then we set is_physical to FALSE and start adding sources for the virtual desktop. Use your best judgment.