Commit a97cf659 authored by Alex Newcomer's avatar Alex Newcomer Committed by Chromium LUCI CQ

[multipaste] send Ctrl and V seperately

Instead of sending a single Ctrl + V event, send a control, then a V.
This may be better on other platforms.

Bug: 1161254
Change-Id: I8178ab36304c5ef1c675418b1132777bcdb1293e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2622007
Commit-Queue: Andrew Xu <andrewxu@chromium.org>
Auto-Submit: Alex Newcomer <newcomer@chromium.org>
Reviewed-by: default avatarAndrew Xu <andrewxu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#842724}
parent 9f81cdc5
......@@ -70,19 +70,6 @@ bool IsRectContainedByAnyDisplay(const gfx::Rect& rect) {
return false;
}
void SendSyntheticKeyEvent(ui::KeyboardCode key_code, int flags) {
ui::KeyEvent key_pressed(/*type=*/ui::ET_KEY_PRESSED, key_code,
/*code=*/static_cast<ui::DomCode>(0), flags);
auto* host = GetWindowTreeHostForDisplay(
display::Screen::GetScreen()->GetDisplayForNewWindows().id());
DCHECK(host);
host->DeliverEventToSink(&key_pressed);
ui::KeyEvent key_released(/*type=*/ui::ET_KEY_RELEASED, key_code,
/*code=*/static_cast<ui::DomCode>(0), flags);
host->DeliverEventToSink(&key_released);
}
} // namespace
// ClipboardHistoryControllerImpl::AcceleratorTarget ---------------------------
......@@ -496,7 +483,28 @@ void ClipboardHistoryControllerImpl::PasteClipboardHistoryItem(
original_data = clipboard->WriteClipboardData(std::move(temp_data));
}
SendSyntheticKeyEvent(ui::VKEY_V, ui::EF_CONTROL_DOWN);
ui::KeyEvent control_press(/*type=*/ui::ET_KEY_PRESSED, ui::VKEY_CONTROL,
/*code=*/static_cast<ui::DomCode>(0), /*flags=*/0);
auto* host = GetWindowTreeHostForDisplay(
display::Screen::GetScreen()->GetDisplayForNewWindows().id());
DCHECK(host);
host->DeliverEventToSink(&control_press);
ui::KeyEvent v_press(/*type=*/ui::ET_KEY_PRESSED, ui::VKEY_V,
/*code=*/static_cast<ui::DomCode>(0),
/*flags=*/ui::EF_CONTROL_DOWN);
host->DeliverEventToSink(&v_press);
ui::KeyEvent v_release(/*type=*/ui::ET_KEY_RELEASED, ui::VKEY_V,
/*code=*/static_cast<ui::DomCode>(0),
/*flags=*/ui::EF_CONTROL_DOWN);
host->DeliverEventToSink(&v_release);
ui::KeyEvent control_release(/*type=*/ui::ET_KEY_RELEASED, ui::VKEY_CONTROL,
/*code=*/static_cast<ui::DomCode>(0),
/*flags=*/0);
host->DeliverEventToSink(&control_release);
for (auto& observer : observers_)
observer.OnClipboardHistoryPasted();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment