improved logic to choose right window to show dialogs in
Merge pull request #84 from Soph/develop

improved logic to choose right window to show dialogs in