From 48611e831c4d7b5100096a1103501e05c7365685 Mon Sep 17 00:00:00 2001 From: rampaa Date: Tue, 8 Oct 2024 20:22:48 +0300 Subject: [PATCH] Minor --- JL.Windows/GUI/PopupWindow.xaml.cs | 2 ++ JL.Windows/Utilities/WindowsUtils.cs | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/JL.Windows/GUI/PopupWindow.xaml.cs b/JL.Windows/GUI/PopupWindow.xaml.cs index 3c698fa6..e5791a36 100644 --- a/JL.Windows/GUI/PopupWindow.xaml.cs +++ b/JL.Windows/GUI/PopupWindow.xaml.cs @@ -1194,6 +1194,8 @@ private async void PrimarySpelling_PreviewMouseUp(object sender, MouseButtonEven if (e.ChangedButton == ConfigManager.CopyPrimarySpellingToClipboardMouseButton) { WindowsUtils.CopyTextToClipboard(((TextBlock)sender).Text); + HidePopup(); + return; } if (!MiningMode || e.ChangedButton != ConfigManager.MineMouseButton) diff --git a/JL.Windows/Utilities/WindowsUtils.cs b/JL.Windows/Utilities/WindowsUtils.cs index 76049156..5f28b36a 100644 --- a/JL.Windows/Utilities/WindowsUtils.cs +++ b/JL.Windows/Utilities/WindowsUtils.cs @@ -616,6 +616,13 @@ public static void CopyTextToClipboard(string? text) return; } + bool captureTextFromClipboard = CoreConfigManager.CaptureTextFromClipboard; + CoreConfigManager.CaptureTextFromClipboard = false; + if (captureTextFromClipboard) + { + WinApi.UnsubscribeFromClipboardChanged(MainWindow.Instance.WindowHandle); + } + bool retry = true; do { @@ -631,6 +638,12 @@ public static void CopyTextToClipboard(string? text) Utils.Logger.Warning(ex, "CopyTextToClipboard failed"); } } while (retry); + + CoreConfigManager.CaptureTextFromClipboard = captureTextFromClipboard; + if (captureTextFromClipboard) + { + WinApi.SubscribeToClipboardChanged(MainWindow.Instance.WindowHandle); + } } public static void HandlePostCopy(string text, string? subsequentText)