From d7fa2bb5fd408ce4344ae295aea652cb9f9c2ee1 Mon Sep 17 00:00:00 2001 From: Daniel Chalmers Date: Thu, 18 Jun 2026 16:03:59 -0500 Subject: [PATCH 1/2] Click a player to switch cameras (hook Flyleaf surface mouse input) --- SentryReplay/MainWindow.xaml.cs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/SentryReplay/MainWindow.xaml.cs b/SentryReplay/MainWindow.xaml.cs index 524444e..d19056e 100644 --- a/SentryReplay/MainWindow.xaml.cs +++ b/SentryReplay/MainWindow.xaml.cs @@ -17,6 +17,7 @@ namespace SentryReplay; public partial class MainWindow : Window { private readonly MainWindowViewModel _viewModel; + private readonly HashSet _clickHookedSurfaces = []; private bool _isClosing; private bool _isReadyToClose; @@ -30,6 +31,14 @@ public MainWindow() _viewModel.PropertyChanged += ViewModelOnPropertyChanged; DataContext = _viewModel; + + // Clicking a player (incl. the mini previews) switches to that camera. Flyleaf renders each camera + // into its own native surface, so the click must be caught on the surface, not via a WPF overlay. + HookCameraClick(FrontFlyleafHost, MainWindowViewModel.FrontCameraView); + HookCameraClick(BackFlyleafHost, MainWindowViewModel.RearCameraView); + HookCameraClick(LeftFlyleafHost, MainWindowViewModel.LeftCameraView); + HookCameraClick(RightFlyleafHost, MainWindowViewModel.RightCameraView); + UpdateCameraHostLayout(); } @@ -113,6 +122,27 @@ private void OnSearchBoxFocusRequested(object sender, EventArgs e) SearchBox.SelectAll(); } + // The FlyleafHost creates its native Surface window when it loads (and reuses it across reparenting), + // so subscribe once it exists. handledEventsToo ensures we still see the click if Flyleaf marks it + // handled, and the HashSet guards against re-subscribing when Loaded fires again on a reparent. + private void HookCameraClick(FlyleafHost host, string cameraView) + { + host.Loaded += (_, _) => + { + if (host.Surface is { } surface && _clickHookedSurfaces.Add(surface)) + { + surface.AddHandler( + MouseLeftButtonDownEvent, + new MouseButtonEventHandler((_, e) => + { + _viewModel.SelectCameraViewCommand.Execute(cameraView); + e.Handled = true; + }), + handledEventsToo: true); + } + }; + } + private void UpdateCameraHostLayout() { if (PrimaryCameraHostSlot is null) From b19554bf456762c05171361d25da3c3fcc83b3ab Mon Sep 17 00:00:00 2001 From: Daniel Chalmers Date: Thu, 18 Jun 2026 16:08:34 -0500 Subject: [PATCH 2/2] Switch camera on mouse-up (click) rather than mouse-down --- SentryReplay/MainWindow.xaml.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SentryReplay/MainWindow.xaml.cs b/SentryReplay/MainWindow.xaml.cs index d19056e..a9b3063 100644 --- a/SentryReplay/MainWindow.xaml.cs +++ b/SentryReplay/MainWindow.xaml.cs @@ -132,7 +132,7 @@ private void HookCameraClick(FlyleafHost host, string cameraView) if (host.Surface is { } surface && _clickHookedSurfaces.Add(surface)) { surface.AddHandler( - MouseLeftButtonDownEvent, + MouseLeftButtonUpEvent, new MouseButtonEventHandler((_, e) => { _viewModel.SelectCameraViewCommand.Execute(cameraView);