mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 07:30:15 -04:00
Fix ClipboardAction so that it only clears Clipboard when Window is active
This commit is contained in:
@@ -1 +1,2 @@
|
||||
Data is now protected in memory as well as at rest
|
||||
Data is now protected in memory as well as at rest
|
||||
Fix clipboard copy expiration issue
|
@@ -1 +1,2 @@
|
||||
Protection des donnees en memoire en plus du chiffrement de la base de donnees
|
||||
Protection des donnees en memoire en plus du chiffrement de la base de donnees
|
||||
Correction d'un bug dans l'expiration des donnees copiees
|
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using Windows.ApplicationModel.DataTransfer;
|
||||
using Windows.UI.Core;
|
||||
using Windows.UI.Xaml;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Xaml.Interactivity;
|
||||
@@ -11,6 +12,7 @@ namespace ModernKeePass.Actions
|
||||
public class ClipboardAction : DependencyObject, IAction
|
||||
{
|
||||
private DispatcherTimer _dispatcher;
|
||||
private bool _isWindowActivated = true;
|
||||
|
||||
public string Text
|
||||
{
|
||||
@@ -36,6 +38,8 @@ namespace ModernKeePass.Actions
|
||||
var settings = App.Services.GetRequiredService<ISettingsProxy>();
|
||||
var cryptography = App.Services.GetRequiredService<ICryptographyClient>();
|
||||
|
||||
CoreWindow.GetForCurrentThread().Activated += ClipboardAction_Activated;
|
||||
|
||||
_dispatcher = new DispatcherTimer {Interval = TimeSpan.FromSeconds(settings.GetSetting(Constants.Settings.ClipboardTimeout, 10))};
|
||||
_dispatcher.Tick += Dispatcher_Tick;
|
||||
|
||||
@@ -48,16 +52,14 @@ namespace ModernKeePass.Actions
|
||||
return null;
|
||||
}
|
||||
|
||||
private void ClipboardAction_Activated(CoreWindow sender, WindowActivatedEventArgs args)
|
||||
{
|
||||
_isWindowActivated = args.WindowActivationState != CoreWindowActivationState.Deactivated;
|
||||
}
|
||||
|
||||
private void Dispatcher_Tick(object sender, object e)
|
||||
{
|
||||
try
|
||||
{
|
||||
Clipboard.SetContent(null);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_dispatcher.Stop();
|
||||
}
|
||||
if (_isWindowActivated) Clipboard.SetContent(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user