mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2026-06-09 21:22:41 +00:00
macOS: add screen protection preference
Persist a macOS-only preference for disabling wx content protection while keeping protection enabled by default. Add a Preferences checkbox that reuses IDC_DISABLE_SCREEN_PROTECTION and reapply the protection state after preference changes. Apply content-protection updates to all current top-level wx windows so changing the preference while a modal dialog is active does not leave the main frame or other windows with stale protection state.
This commit is contained in:
@@ -479,7 +479,11 @@ namespace VeraCrypt
|
||||
|
||||
void MainFrame::InitWindowPrivacy ()
|
||||
{
|
||||
Gui->SetContentProtection(!CmdLine->ArgAllowScreencapture);
|
||||
bool enableContentProtection = !CmdLine->ArgAllowScreencapture;
|
||||
#ifdef TC_MACOSX
|
||||
enableContentProtection = enableContentProtection && !GetPreferences().DisableScreenProtection;
|
||||
#endif
|
||||
Gui->SetContentProtection (enableContentProtection);
|
||||
}
|
||||
|
||||
void MainFrame::InitPreferences ()
|
||||
@@ -1296,6 +1300,7 @@ namespace VeraCrypt
|
||||
if (Gui->IsInBackgroundMode() && !prefs.BackgroundTaskEnabled)
|
||||
Close (true);
|
||||
|
||||
InitWindowPrivacy();
|
||||
SavePreferences();
|
||||
}
|
||||
|
||||
|
||||
@@ -94,6 +94,21 @@ namespace VeraCrypt
|
||||
TC_CHECK_BOX_VALIDATOR (WipeCacheOnAutoDismount);
|
||||
TC_CHECK_BOX_VALIDATOR (WipeCacheOnClose);
|
||||
|
||||
#ifdef TC_MACOSX
|
||||
wxStaticBoxSizer *screenProtectionSizer = new wxStaticBoxSizer (new wxStaticBox (SecurityPage, wxID_ANY, LangString["IDT_SECURITY_OPTIONS"]), wxVERTICAL);
|
||||
DisableScreenProtectionCheckBox = new wxCheckBox (screenProtectionSizer->GetStaticBox(), wxID_ANY, LangString["IDC_DISABLE_SCREEN_PROTECTION"]);
|
||||
DisableScreenProtectionCheckBox->SetToolTip (LangString["DISABLE_SCREEN_PROTECTION_WARNING"]);
|
||||
screenProtectionSizer->Add (DisableScreenProtectionCheckBox, 0, wxALL, 5);
|
||||
SecurityPage->GetSizer()->Add (screenProtectionSizer, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 10);
|
||||
TC_CHECK_BOX_VALIDATOR (DisableScreenProtection);
|
||||
DisableScreenProtectionCheckBox->Bind (wxEVT_CHECKBOX,
|
||||
[] (wxCommandEvent& event)
|
||||
{
|
||||
if (event.IsChecked())
|
||||
Gui->ShowWarning ("DISABLE_SCREEN_PROTECTION_WARNING");
|
||||
});
|
||||
#endif
|
||||
|
||||
// Mount options
|
||||
CachePasswordsCheckBox->SetValidator (wxGenericValidator (&Preferences.DefaultMountOptions.CachePassword));
|
||||
MountReadOnlyCheckBox->SetValue (Preferences.DefaultMountOptions.Protection == VolumeProtection::ReadOnly);
|
||||
|
||||
@@ -57,6 +57,9 @@ namespace VeraCrypt
|
||||
KeyfilesPanel *DefaultKeyfilesPanel;
|
||||
#ifdef TC_LINUX
|
||||
wxCheckBox *MountNtfsWithKernelDriverCheckBox;
|
||||
#endif
|
||||
#ifdef TC_MACOSX
|
||||
wxCheckBox *DisableScreenProtectionCheckBox;
|
||||
#endif
|
||||
int LastVirtualKeyPressed;
|
||||
unique_ptr <wxTimer> mTimer;
|
||||
|
||||
@@ -2053,7 +2053,12 @@ namespace VeraCrypt
|
||||
void GraphicUserInterface::SetContentProtection (bool enable) const
|
||||
{
|
||||
#if defined(TC_WINDOWS) || defined(TC_MACOSX)
|
||||
GetActiveWindow()->SetContentProtection(enable ? wxCONTENT_PROTECTION_ENABLED : wxCONTENT_PROTECTION_NONE);
|
||||
foreach (wxWindow *window, wxTopLevelWindows)
|
||||
{
|
||||
wxTopLevelWindow *topLevelWindow = dynamic_cast <wxTopLevelWindow *> (window);
|
||||
if (topLevelWindow)
|
||||
topLevelWindow->SetContentProtection (enable ? wxCONTENT_PROTECTION_ENABLED : wxCONTENT_PROTECTION_NONE);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -84,6 +84,9 @@ namespace VeraCrypt
|
||||
TC_CONFIG_SET (CloseSecurityTokenSessionsAfterMount);
|
||||
TC_CONFIG_SET (EMVSupportEnabled);
|
||||
TC_CONFIG_SET (DisableKernelEncryptionModeWarning);
|
||||
#ifdef TC_MACOSX
|
||||
TC_CONFIG_SET (DisableScreenProtection);
|
||||
#endif
|
||||
TC_CONFIG_SET (DismountOnInactivity);
|
||||
TC_CONFIG_SET (DismountOnLogOff);
|
||||
TC_CONFIG_SET (DismountOnPowerSaving);
|
||||
@@ -212,6 +215,9 @@ namespace VeraCrypt
|
||||
TC_CONFIG_ADD (CloseSecurityTokenSessionsAfterMount);
|
||||
TC_CONFIG_ADD (EMVSupportEnabled);
|
||||
TC_CONFIG_ADD (DisableKernelEncryptionModeWarning);
|
||||
#ifdef TC_MACOSX
|
||||
TC_CONFIG_ADD (DisableScreenProtection);
|
||||
#endif
|
||||
TC_CONFIG_ADD (DismountOnInactivity);
|
||||
TC_CONFIG_ADD (DismountOnLogOff);
|
||||
TC_CONFIG_ADD (DismountOnPowerSaving);
|
||||
|
||||
@@ -33,6 +33,7 @@ namespace VeraCrypt
|
||||
CloseSecurityTokenSessionsAfterMount (false),
|
||||
EMVSupportEnabled (false),
|
||||
DisableKernelEncryptionModeWarning (false),
|
||||
DisableScreenProtection (false),
|
||||
DismountOnInactivity (false),
|
||||
DismountOnLogOff (true),
|
||||
DismountOnPowerSaving (false),
|
||||
@@ -76,6 +77,7 @@ namespace VeraCrypt
|
||||
bool CloseSecurityTokenSessionsAfterMount;
|
||||
bool EMVSupportEnabled;
|
||||
bool DisableKernelEncryptionModeWarning;
|
||||
bool DisableScreenProtection;
|
||||
bool DismountOnInactivity;
|
||||
bool DismountOnLogOff;
|
||||
bool DismountOnPowerSaving;
|
||||
|
||||
Reference in New Issue
Block a user