Skip to content

Commit

Permalink
Minor
Browse files Browse the repository at this point in the history
  • Loading branch information
rampaa committed Oct 8, 2024
1 parent 9fd6749 commit 48611e8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions JL.Windows/GUI/PopupWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 13 additions & 0 deletions JL.Windows/Utilities/WindowsUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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)
Expand Down

0 comments on commit 48611e8

Please sign in to comment.