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:
Mounir IDRASSI
2026-04-15 16:16:54 +09:00
parent 631d0cc420
commit 3e9c47d256
4 changed files with 37 additions and 8 deletions

View File

@@ -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 ()

View File

@@ -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 ()

View 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

View File

@@ -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);