mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2026-05-25 14:00:22 +00:00
Linux/macOS: collect mouse entropy from nested controls
wxWidgets does not propagate mouse motion events from child controls to parent windows. The Linux/macOS GUI was binding the random-pool mouse handlers only to the dialog/page and its direct children, which left nested controls such as static-box contents and the wizard image as dead zones. Add a reusable recursive child-window event binder and use it in the keyfile generator, random pool enrichment dialog, and volume creation wizard. The root windows keep their existing generated bindings, while descendants are bound explicitly, avoiding duplicate handling on the root while covering all nested controls. This makes the entropy gauge and the random pool update consistently no matter where the pointer moves inside the affected windows. Fixes #1656.
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#include "Main/GraphicUserInterface.h"
|
||||
#include "Volume/Hash.h"
|
||||
#include "KeyfileGeneratorDialog.h"
|
||||
#include "WindowEventHandlers.h"
|
||||
|
||||
namespace VeraCrypt
|
||||
{
|
||||
@@ -44,8 +45,7 @@ namespace VeraCrypt
|
||||
|
||||
MouseEventsCounter = 0;
|
||||
|
||||
foreach (wxWindow *c, this->GetChildren())
|
||||
c->Connect (wxEVT_MOTION, wxMouseEventHandler (KeyfileGeneratorDialog::OnMouseMotion), nullptr, this);
|
||||
ConnectEventToChildWindows (this, wxEVT_MOTION, wxMouseEventHandler (KeyfileGeneratorDialog::OnMouseMotion), this);
|
||||
}
|
||||
|
||||
KeyfileGeneratorDialog::~KeyfileGeneratorDialog ()
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "Main/GraphicUserInterface.h"
|
||||
#include "Volume/Hash.h"
|
||||
#include "RandomPoolEnrichmentDialog.h"
|
||||
#include "WindowEventHandlers.h"
|
||||
|
||||
namespace VeraCrypt
|
||||
{
|
||||
@@ -46,8 +47,7 @@ namespace VeraCrypt
|
||||
|
||||
MouseEventsCounter = 0;
|
||||
|
||||
foreach (wxWindow *c, this->GetChildren())
|
||||
c->Connect (wxEVT_MOTION, wxMouseEventHandler (RandomPoolEnrichmentDialog::OnMouseMotion), nullptr, this);
|
||||
ConnectEventToChildWindows (this, wxEVT_MOTION, wxMouseEventHandler (RandomPoolEnrichmentDialog::OnMouseMotion), this);
|
||||
}
|
||||
|
||||
RandomPoolEnrichmentDialog::~RandomPoolEnrichmentDialog ()
|
||||
|
||||
30
src/Main/Forms/WindowEventHandlers.h
Normal file
30
src/Main/Forms/WindowEventHandlers.h
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
Derived from source code of TrueCrypt 7.1a, which is
|
||||
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
||||
by the TrueCrypt License 3.0.
|
||||
|
||||
Modifications and additions to the original source code (contained in this file)
|
||||
and all other portions of this file are Copyright (c) 2013-2026 AM Crypto
|
||||
and are governed by the Apache License 2.0 the full text of which is
|
||||
contained in the file License.txt included in VeraCrypt binary and source
|
||||
code distribution packages.
|
||||
*/
|
||||
|
||||
#ifndef TC_HEADER_Main_Forms_WindowEventHandlers
|
||||
#define TC_HEADER_Main_Forms_WindowEventHandlers
|
||||
|
||||
#include "Main/Main.h"
|
||||
|
||||
namespace VeraCrypt
|
||||
{
|
||||
inline void ConnectEventToChildWindows (wxWindow *window, wxEventType eventType, wxObjectEventFunction handler, wxEvtHandler *eventSink)
|
||||
{
|
||||
foreach (wxWindow *child, window->GetChildren())
|
||||
{
|
||||
child->Connect (eventType, handler, nullptr, eventSink);
|
||||
ConnectEventToChildWindows (child, eventType, handler, eventSink);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // TC_HEADER_Main_Forms_WindowEventHandlers
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "Main/GraphicUserInterface.h"
|
||||
#include "Main/Resources.h"
|
||||
#include "WizardFrame.h"
|
||||
#include "WindowEventHandlers.h"
|
||||
|
||||
namespace VeraCrypt
|
||||
{
|
||||
@@ -40,8 +41,7 @@ namespace VeraCrypt
|
||||
this->SetDefaultItem (NextButton);
|
||||
NextButton->SetFocus();
|
||||
|
||||
foreach (wxWindow *c, MainPanel->GetChildren())
|
||||
c->Connect (wxEVT_MOTION, wxMouseEventHandler (WizardFrame::OnMouseMotion), nullptr, this);
|
||||
ConnectEventToChildWindows (MainPanel, wxEVT_MOTION, wxMouseEventHandler (WizardFrame::OnMouseMotion), this);
|
||||
}
|
||||
|
||||
WizardFrame::~WizardFrame ()
|
||||
@@ -145,8 +145,7 @@ namespace VeraCrypt
|
||||
CurrentPage->PageUpdatedEvent.Connect (EventConnector <WizardFrame> (this, &WizardFrame::OnPageUpdated));
|
||||
|
||||
CurrentPage->Connect (wxEVT_MOTION, wxMouseEventHandler (WizardFrame::OnMouseMotion), nullptr, this);
|
||||
foreach (wxWindow *c, CurrentPage->GetChildren())
|
||||
c->Connect (wxEVT_MOTION, wxMouseEventHandler (WizardFrame::OnMouseMotion), nullptr, this);
|
||||
ConnectEventToChildWindows (CurrentPage, wxEVT_MOTION, wxMouseEventHandler (WizardFrame::OnMouseMotion), this);
|
||||
|
||||
if (MaxStaticTextWidth > 0)
|
||||
CurrentPage->SetMaxStaticTextWidth (MaxStaticTextWidth);
|
||||
|
||||
Reference in New Issue
Block a user