mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 23:50:18 -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 System;
|
||||||
using Windows.ApplicationModel.DataTransfer;
|
using Windows.ApplicationModel.DataTransfer;
|
||||||
|
using Windows.UI.Core;
|
||||||
using Windows.UI.Xaml;
|
using Windows.UI.Xaml;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Xaml.Interactivity;
|
using Microsoft.Xaml.Interactivity;
|
||||||
@@ -11,6 +12,7 @@ namespace ModernKeePass.Actions
|
|||||||
public class ClipboardAction : DependencyObject, IAction
|
public class ClipboardAction : DependencyObject, IAction
|
||||||
{
|
{
|
||||||
private DispatcherTimer _dispatcher;
|
private DispatcherTimer _dispatcher;
|
||||||
|
private bool _isWindowActivated = true;
|
||||||
|
|
||||||
public string Text
|
public string Text
|
||||||
{
|
{
|
||||||
@@ -36,6 +38,8 @@ namespace ModernKeePass.Actions
|
|||||||
var settings = App.Services.GetRequiredService<ISettingsProxy>();
|
var settings = App.Services.GetRequiredService<ISettingsProxy>();
|
||||||
var cryptography = App.Services.GetRequiredService<ICryptographyClient>();
|
var cryptography = App.Services.GetRequiredService<ICryptographyClient>();
|
||||||
|
|
||||||
|
CoreWindow.GetForCurrentThread().Activated += ClipboardAction_Activated;
|
||||||
|
|
||||||
_dispatcher = new DispatcherTimer {Interval = TimeSpan.FromSeconds(settings.GetSetting(Constants.Settings.ClipboardTimeout, 10))};
|
_dispatcher = new DispatcherTimer {Interval = TimeSpan.FromSeconds(settings.GetSetting(Constants.Settings.ClipboardTimeout, 10))};
|
||||||
_dispatcher.Tick += Dispatcher_Tick;
|
_dispatcher.Tick += Dispatcher_Tick;
|
||||||
|
|
||||||
@@ -48,16 +52,14 @@ namespace ModernKeePass.Actions
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ClipboardAction_Activated(CoreWindow sender, WindowActivatedEventArgs args)
|
||||||
|
{
|
||||||
|
_isWindowActivated = args.WindowActivationState != CoreWindowActivationState.Deactivated;
|
||||||
|
}
|
||||||
|
|
||||||
private void Dispatcher_Tick(object sender, object e)
|
private void Dispatcher_Tick(object sender, object e)
|
||||||
{
|
{
|
||||||
try
|
if (_isWindowActivated) Clipboard.SetContent(null);
|
||||||
{
|
|
||||||
Clipboard.SetContent(null);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
_dispatcher.Stop();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user