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

Do not reshow the disconnect window for small mouse movements

This change adds a fudge factor of ~1px to the logic which determines
whether to reshow the disconnect window after it has been hidden.
I suspect the reports of the window being reshown are due to small
accumulations for the cursor position or potentially just raw input
events where the cursor does not change.  We want to avoid reshowing
the dialog in cases such as this because it is quite annoying for the
remote user.

Bug: 891584

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.

Change-Id: I310f2cb4a5f30b0b7e14bf7221d250030492add8
Reviewed-on: https://chromium-review.googlesource.com/c/1258979
Commit-Queue: Joe Downing <joedow@chromium.org>
Reviewed-by: default avatarJamie Walch <jamiewalch@chromium.org>
Cr-Commit-Position: refs/heads/master@{#596308}
parent 931b6ae7
......@@ -5,6 +5,7 @@
#include <stddef.h>
#include <windows.h>
#include <cstdlib>
#include <memory>
#include "base/compiler_specific.h"
......@@ -122,6 +123,8 @@ class DisconnectWindowWin : public HostWindow {
bool has_hotkey_ = false;
base::win::ScopedGDIObject<HPEN> border_pen_;
webrtc::DesktopVector mouse_position_;
base::WeakPtrFactory<DisconnectWindowWin> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(DisconnectWindowWin);
......@@ -380,7 +383,16 @@ void DisconnectWindowWin::StopAutoHideBehavior() {
void DisconnectWindowWin::OnLocalMouseEvent(
const webrtc::DesktopVector& position) {
ShowDialog();
// Don't show the dialog if the position changes by ~1px in any direction.
// This will prevent the dialog from being reshown due to small movements
// caused by hardware/software issues which cause cursor drift or small
// vibrations in the environment around the remote host.
if (std::abs(position.x() - mouse_position_.x()) > 1 ||
std::abs(position.y() - mouse_position_.y()) > 1) {
ShowDialog();
}
mouse_position_ = position;
}
void DisconnectWindowWin::OnLocalKeyboardEvent() {
......
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