Commit 4f3ac82f authored by Eugene Girard's avatar Eugene Girard Committed by Commit Bot

Purge unreferenced touches

This patch is a work-around for WM_TOUCH vintage drivers that sometimes
drop touchend events, confusing the chromium gesture recognizer. The
work around is to watch for touches that have disappeared from the
current touch list (and inject a simulated touchend).

Bug: 792892
Change-Id: I7e023fc4f6484e2091746e0000b41018dd8f9cb4
Reviewed-on: https://chromium-review.googlesource.com/905270
Commit-Queue: Eugene Girard <girard@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Reviewed-by: default avatarIlya Sherman <isherman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#539137}
parent da5888b2
......@@ -92629,6 +92629,17 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
<owner>pthammaiah@google.com</owner>
</histogram>
<histogram name="TouchScreen.MissedTOUCHEVENTF_UP" enum="BooleanHit">
<owner>input-dev@chromium.org</owner>
<summary>
The touch device driver failed to send a TOUCHEVENTF_UP, and chromium
generated a simulated event to maintain consistency/correctness.
This workaround will be removed once usage drops off. See
https://crbug.com/811273 for details.
</summary>
</histogram>
<histogram name="Touchscreen.TapDisambiguation" enum="TapDisambiguation">
<owner>aelias@chromium.org</owner>
<summary>
......@@ -44,4 +44,5 @@ TEST(SequentialIDGeneratorTest, MaybeRemoveNumbers) {
EXPECT_FALSE(generator.HasGeneratedIDFor(42));
generator.ReleaseNumber(42);
}
} // namespace ui
......@@ -2315,7 +2315,10 @@ LRESULT HWNDMessageHandler::OnTouchEvent(UINT message,
// so use base::TimeTicks::Now().
const base::TimeTicks event_time = base::TimeTicks::Now();
TouchEvents touch_events;
TouchIDs stale_touches(touch_ids_);
for (int i = 0; i < num_points; ++i) {
stale_touches.erase(input[i].dwID);
POINT point;
point.x = TOUCH_COORD_TO_PIXEL(input[i].x);
point.y = TOUCH_COORD_TO_PIXEL(input[i].y);
......@@ -2336,7 +2339,7 @@ LRESULT HWNDMessageHandler::OnTouchEvent(UINT message,
last_touch_or_pen_message_time_ = ::GetMessageTime();
gfx::Point touch_point(point.x, point.y);
unsigned int touch_id = id_generator_.GetGeneratedID(input[i].dwID);
size_t touch_id = id_generator_.GetGeneratedID(input[i].dwID);
if (input[i].dwFlags & TOUCHEVENTF_DOWN) {
touch_ids_.insert(input[i].dwID);
......@@ -2361,6 +2364,19 @@ LRESULT HWNDMessageHandler::OnTouchEvent(UINT message,
}
}
}
// If a touch has been dropped from the list (without a TOUCH_EVENTF_UP)
// we generate a simulated TOUCHEVENTF_UP event.
for (auto touch_number : stale_touches) {
// Log that we've hit this code. When usage drops off, we can remove
// this "workaround". See https://crbug.com/811273
UMA_HISTOGRAM_BOOLEAN("TouchScreen.MissedTOUCHEVENTF_UP", true);
size_t touch_id = id_generator_.GetGeneratedID(touch_number);
touch_ids_.erase(touch_number);
GenerateTouchEvent(ui::ET_TOUCH_RELEASED, gfx::Point(0, 0), touch_id,
event_time, &touch_events);
id_generator_.ReleaseNumber(touch_number);
}
// Handle the touch events asynchronously. We need this because touch
// events on windows don't fire if we enter a modal loop in the context of
// a touch event.
......@@ -2735,7 +2751,7 @@ LRESULT HWNDMessageHandler::HandlePointerEventTypeTouch(UINT message,
return 0;
}
unsigned int mapped_pointer_id = id_generator_.GetGeneratedID(pointer_id);
size_t mapped_pointer_id = id_generator_.GetGeneratedID(pointer_id);
POINTER_INFO pointer_info = pointer_touch_info.pointerInfo;
POINT client_point = pointer_info.ptPixelLocationRaw;
ScreenToClient(hwnd(), &client_point);
......@@ -2891,7 +2907,7 @@ void HWNDMessageHandler::PerformDwmTransition() {
void HWNDMessageHandler::GenerateTouchEvent(ui::EventType event_type,
const gfx::Point& point,
unsigned int id,
size_t id,
base::TimeTicks time_stamp,
TouchEvents* touch_events) {
ui::TouchEvent event(
......
......@@ -550,12 +550,6 @@ class VIEWS_EXPORT HWNDMessageHandler : public gfx::WindowImpl,
const POINTER_INFO& pointer_info,
const gfx::Point& point,
const ui::PointerDetails& pointer_details);
LRESULT GenerateTouchEventFromPointerEvent(
UINT message,
UINT32 pointer_id,
const POINTER_INFO& pointer_info,
const gfx::Point& point,
const ui::PointerDetails& pointer_details);
// Returns true if the mouse message passed in is an OS synthesized mouse
// message.
......@@ -575,7 +569,7 @@ class VIEWS_EXPORT HWNDMessageHandler : public gfx::WindowImpl,
// |time_stamp| is the time stamp associated with the message.
void GenerateTouchEvent(ui::EventType event_type,
const gfx::Point& point,
unsigned int id,
size_t id,
base::TimeTicks time_stamp,
TouchEvents* touch_events);
......
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