mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-02-23 19:49:43 +01:00
feat(advancedpaste): verify clipboard copy with sequence
This commit is contained in:
@@ -519,9 +519,12 @@ private:
|
||||
{
|
||||
constexpr int copy_attempts = 2;
|
||||
constexpr auto copy_retry_delay = std::chrono::milliseconds(100);
|
||||
constexpr int clipboard_poll_attempts = 5;
|
||||
constexpr auto clipboard_poll_delay = std::chrono::milliseconds(30);
|
||||
|
||||
for (int attempt = 0; attempt < copy_attempts; ++attempt)
|
||||
{
|
||||
const auto initial_sequence = GetClipboardSequenceNumber();
|
||||
bool copy_succeeded = try_send_copy_message();
|
||||
|
||||
if (!copy_succeeded)
|
||||
@@ -579,6 +582,23 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
if (copy_succeeded)
|
||||
{
|
||||
bool sequence_changed = false;
|
||||
for (int poll_attempt = 0; poll_attempt < clipboard_poll_attempts; ++poll_attempt)
|
||||
{
|
||||
if (GetClipboardSequenceNumber() != initial_sequence)
|
||||
{
|
||||
sequence_changed = true;
|
||||
break;
|
||||
}
|
||||
|
||||
std::this_thread::sleep_for(clipboard_poll_delay);
|
||||
}
|
||||
|
||||
copy_succeeded = sequence_changed;
|
||||
}
|
||||
|
||||
if (copy_succeeded)
|
||||
{
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user