Commit df242b02 authored by Joe Downing's avatar Joe Downing Committed by Commit Bot

Ignore mouse messages if the position or button states don't change

We've received reports that the disconnect window is appearing at
odd times after the auto-hide timeout has taken effect.  I suspect
there could be hardware which is emitting spurious HID events which
is triggering the reshow logic.  My assumption is that this behavior
is't egregious, otherwise the user would notice the mouse cursor
moving or errant keypresses.  Thus I want to prevent triggering the
reshow logic if we receive a RAWINPUT event where the cursor has not
moved and no button states have changed.

Bug: 891584

Change-Id: Id9efd72f24f8caf0e67b1a717fee2bbafaab55af
Reviewed-on: https://chromium-review.googlesource.com/c/1258316
Commit-Queue: Joe Downing <joedow@chromium.org>
Reviewed-by: default avatarJamie Walch <jamiewalch@chromium.org>
Cr-Commit-Position: refs/heads/master@{#596121}
parent b276e5ed
...@@ -42,6 +42,8 @@ class MouseRawInputHandlerWin : public LocalInputMonitorWin::RawInputHandler { ...@@ -42,6 +42,8 @@ class MouseRawInputHandlerWin : public LocalInputMonitorWin::RawInputHandler {
LocalInputMonitor::MouseMoveCallback on_mouse_move_; LocalInputMonitor::MouseMoveCallback on_mouse_move_;
base::OnceClosure disconnect_callback_; base::OnceClosure disconnect_callback_;
webrtc::DesktopVector mouse_position_;
// Tracks whether the instance is registered to receive raw input events. // Tracks whether the instance is registered to receive raw input events.
bool registered_ = false; bool registered_ = false;
...@@ -99,18 +101,30 @@ void MouseRawInputHandlerWin::OnInputEvent(const RAWINPUT* input) { ...@@ -99,18 +101,30 @@ void MouseRawInputHandlerWin::OnInputEvent(const RAWINPUT* input) {
// Notify the observer about mouse events generated locally. Remote (injected) // Notify the observer about mouse events generated locally. Remote (injected)
// mouse events do not specify a device handle (based on observed behavior). // mouse events do not specify a device handle (based on observed behavior).
if (input->header.dwType == RIM_TYPEMOUSE && if (input->header.dwType != RIM_TYPEMOUSE ||
input->header.hDevice != nullptr) { input->header.hDevice == nullptr) {
return;
}
POINT position; POINT position;
if (!GetCursorPos(&position)) { if (!GetCursorPos(&position)) {
position.x = 0; position.x = 0;
position.y = 0; position.y = 0;
} }
webrtc::DesktopVector new_position(position.x, position.y);
// Ignore the event if the cursor position or button states have not changed.
// Note: If GetCursorPos fails above, we err on the safe side and treat it
// like a movement.
if (mouse_position_.equals(new_position) &&
!input->data.mouse.usButtonFlags && !new_position.is_zero()) {
return;
}
mouse_position_ = new_position;
caller_task_runner_->PostTask( caller_task_runner_->PostTask(
FROM_HERE, base::BindOnce(on_mouse_move_, webrtc::DesktopVector( FROM_HERE, base::BindOnce(on_mouse_move_, std::move(new_position)));
position.x, position.y)));
}
} }
void MouseRawInputHandlerWin::OnError() { void MouseRawInputHandlerWin::OnError() {
......
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