Made get_selected_signal more reliable

If tree selection is empty, check active window.