diff --git a/KeePassNatMsg/Properties/AssemblyInfo.cs b/KeePassNatMsg/Properties/AssemblyInfo.cs index 9eb585c..24ad7ef 100644 --- a/KeePassNatMsg/Properties/AssemblyInfo.cs +++ b/KeePassNatMsg/Properties/AssemblyInfo.cs @@ -31,4 +31,4 @@ // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("2.0.13")] \ No newline at end of file +[assembly: AssemblyVersion("2.0.17")] diff --git a/KeePassNatMsg/Protocol/Handlers.cs b/KeePassNatMsg/Protocol/Handlers.cs index e39565f..bcf37e2 100644 --- a/KeePassNatMsg/Protocol/Handlers.cs +++ b/KeePassNatMsg/Protocol/Handlers.cs @@ -63,9 +63,25 @@ private bool UnlockDatabase(bool triggerUnlock) lock (_unlockLock) { var config = new ConfigOpt(_host.CustomConfig); - if (!_host.Database.IsOpen && config.UnlockDatabaseRequest && KeePass.UI.GlobalWindowManager.WindowCount == 0 && triggerUnlock) + if (!_host.Database.IsOpen && config.UnlockDatabaseRequest && triggerUnlock) { - _host.MainWindow.Invoke(new System.Action(() => _host.MainWindow.OpenDatabase(_host.MainWindow.DocumentManager.ActiveDocument.LockedIoc, null, false))); + _host.MainWindow.Invoke(new System.Action(() => + { + if (KeePass.UI.GlobalWindowManager.WindowCount == 0) + { + // No dialog open yet for this database — start a fresh one. + _host.MainWindow.OpenDatabase(_host.MainWindow.DocumentManager.ActiveDocument.LockedIoc, null, false); + } + else + { + // A dialog (likely the master-key prompt from an earlier + // triggerUnlock, or KeePass's own auto-lock prompt) may + // already be open but hidden behind other windows. + // Bring KeePass to the foreground so the user actually + // sees it, instead of silently doing nothing. + _host.MainWindow.Activate(); + } + })); } return _host.Database.IsOpen;